diff --git a/libs/filamat/src/GLSLPostProcessor.cpp b/libs/filamat/src/GLSLPostProcessor.cpp index 678f06966f..9dcd6b6610 100644 --- a/libs/filamat/src/GLSLPostProcessor.cpp +++ b/libs/filamat/src/GLSLPostProcessor.cpp @@ -346,7 +346,7 @@ void GLSLPostProcessor::fullOptimization(const TShader& tShader, if (tShader.getStage() == EShLangFragment && glslOptions.es) { for (auto i : config.glsl.subpassInputToColorLocation) { - glslCompiler.remap_ext_framebuffer_fetch(i.first, i.second); + glslCompiler.remap_ext_framebuffer_fetch(i.first, i.second, true); } } diff --git a/third_party/spirv-cross/.github/workflows/main.yml b/third_party/spirv-cross/.github/workflows/main.yml new file mode 100644 index 0000000000..4ebca7229b --- /dev/null +++ b/third_party/spirv-cross/.github/workflows/main.yml @@ -0,0 +1,54 @@ +name: CI + +on: + push: + branches: [ master ] + pull_request: + types: [ opened, synchronize, reopened ] + +jobs: + build: + name: "Build ${{ matrix.platform }}" + strategy: + matrix: + platform: [windows-latest, ubuntu-16.04, ubuntu-18.04, ubuntu-20.04, macos-latest] + env: + PARALLEL: -j 2 + + runs-on: "${{ matrix.platform }}" + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Pull glslang / SPIRV-Tools + shell: bash + working-directory: ${{github.workspace}} + run: ./checkout_glslang_spirv_tools.sh + + - name: Build glslang / SPIRV-Tools + shell: bash + working-directory: ${{github.workspace}} + run: ./build_glslang_spirv_tools.sh Release + + - 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 + cmake --build . --config Release --target install + + - name: Test SPIRV-Cross + shell: bash + working-directory: ${{github.workspace}}/build + run: ctest --verbose -C Release + diff --git a/third_party/spirv-cross/CMakeLists.txt b/third_party/spirv-cross/CMakeLists.txt index 66f19a6627..39acf9a303 100644 --- a/third_party/spirv-cross/CMakeLists.txt +++ b/third_party/spirv-cross/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2016-2020 Google Inc. +# Copyright 2016-2021 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,8 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -cmake_minimum_required(VERSION 2.8) +# +# 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 . +# SPDX-License-Identifier: Apache-2.0 OR MIT. +# + +cmake_minimum_required(VERSION 3.0) 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") @@ -133,7 +141,8 @@ if (CMAKE_COMPILER_IS_GNUCXX OR ((${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") AND set(spirv-cross-link-flags "${spirv-cross-link-flags} -fsanitize=thread") endif() elseif (MSVC) - set(spirv-compiler-options ${spirv-compiler-options} /wd4267 /wd4996) + # 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) @@ -323,7 +332,7 @@ if (SPIRV_CROSS_STATIC) endif() set(spirv-cross-abi-major 0) -set(spirv-cross-abi-minor 42) +set(spirv-cross-abi-minor 47) set(spirv-cross-abi-patch 0) if (SPIRV_CROSS_SHARED) diff --git a/third_party/spirv-cross/README.md b/third_party/spirv-cross/README.md index 058db89fb2..7d8990b035 100644 --- a/third_party/spirv-cross/README.md +++ b/third_party/spirv-cross/README.md @@ -2,7 +2,7 @@ SPIRV-Cross is a tool designed for parsing and converting SPIR-V to other shader languages. -[![Build Status](https://travis-ci.org/KhronosGroup/SPIRV-Cross.svg?branch=master)](https://travis-ci.org/KhronosGroup/SPIRV-Cross) +[![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=master)](https://ci.appveyor.com/project/HansKristian-Work/SPIRV-Cross) ## Features @@ -161,12 +161,12 @@ for (i = 0; i < count; i++) } // Modify options. -spvc_compiler_create_compiler_options(context, &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, &result); +spvc_compiler_compile(compiler_glsl, &result); printf("Cross-compiled source: %s\n", result); // Frees all memory we allocated so far. @@ -418,7 +418,8 @@ Reserved identifiers currently assumed by the implementation are (in pseudo-rege - _$digit+_.+, e.g. `_100_tmp`, `_2_foobar`. `_2Bar` is **not** reserved. - gl_- prefix - spv- prefix -- SPIRV_Cross 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: diff --git a/third_party/spirv-cross/checkout_glslang_spirv_tools.sh b/third_party/spirv-cross/checkout_glslang_spirv_tools.sh index 51643d1d2b..02024c441a 100755 --- a/third_party/spirv-cross/checkout_glslang_spirv_tools.sh +++ b/third_party/spirv-cross/checkout_glslang_spirv_tools.sh @@ -1,8 +1,8 @@ #!/bin/bash -GLSLANG_REV=4dcc12d1a441b29d5901bc708bb1343d29d6459f -SPIRV_TOOLS_REV=0a1fb588cd365f7737cb121fdd64553923e0cef6 -SPIRV_HEADERS_REV=060627f0b0d2fa8581b5acb939f46e3b9e500593 +GLSLANG_REV=3de5cfe50edecd001e6d703555284d9b10b3dd57 +SPIRV_TOOLS_REV=f3ccb633dfd7c5de1f9f0a2d2e9d7a25f2478206 +SPIRV_HEADERS_REV=f027d53ded7e230e008d37c8b47ede7cd308e19d if [ -z $PROTOCOL ]; then PROTOCOL=git diff --git a/third_party/spirv-cross/gn/BUILD.gn b/third_party/spirv-cross/gn/BUILD.gn index 8458c1a703..5b8071e98b 100644 --- a/third_party/spirv-cross/gn/BUILD.gn +++ b/third_party/spirv-cross/gn/BUILD.gn @@ -38,6 +38,8 @@ source_set("spirv_cross_sources") { "../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", @@ -46,7 +48,9 @@ source_set("spirv_cross_sources") { "../spirv_reflect.hpp", ] - cflags = [ "-fno-exceptions" ] + if (!is_win) { + cflags = [ "-fno-exceptions" ] + } if (is_clang) { cflags_cc = [ diff --git a/third_party/spirv-cross/main.cpp b/third_party/spirv-cross/main.cpp index da2477689e..0da9644963 100644 --- a/third_party/spirv-cross/main.cpp +++ b/third_party/spirv-cross/main.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2020 Arm Limited + * Copyright 2015-2021 Arm Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #include "spirv_cpp.hpp" #include "spirv_cross_util.hpp" #include "spirv_glsl.hpp" @@ -31,6 +38,11 @@ #include #include +#ifdef _WIN32 +#include +#include +#endif + #ifdef HAVE_SPIRV_CROSS_GIT_VERSION #include "gitversion.h" #endif @@ -213,8 +225,27 @@ struct CLIParser #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) { @@ -254,6 +285,61 @@ static bool write_string_to_file(const char *path, const char *string) #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); @@ -444,6 +530,8 @@ static void print_resources(const Compiler &compiler, const ShaderResources &res 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, 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) @@ -566,10 +654,16 @@ struct CLIArguments 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; + 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; 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; @@ -586,6 +680,8 @@ struct CLIArguments SmallVector variable_type_remaps; SmallVector interface_variable_renames; SmallVector hlsl_attr_remap; + SmallVector> masked_stage_outputs; + SmallVector masked_stage_builtins; string entry; string entry_stage; @@ -660,6 +756,7 @@ static void print_help_glsl() "\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" @@ -779,7 +876,17 @@ static void print_help_msl() "\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\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-combined-sampler-suffix ]:\n\t\tUses a custom suffix for combined samplers.\n"); // clang-format on } @@ -801,6 +908,11 @@ static void print_help_common() "\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" ); // clang-format on } @@ -829,7 +941,7 @@ static void print_help() // clang-format off fprintf(stderr, "Usage: spirv-cross <...>\n" "\nBasic:\n" - "\t[SPIR-V file]\n" + "\t[SPIR-V file] (- is stdin)\n" "\t[--output ]: If not provided, prints output to stdout.\n" "\t[--dump-resources]:\n\t\tPrints a basic reflection of the SPIR-V module along with other output.\n" "\t[--help]:\n\t\tPrints this help message.\n" @@ -1021,6 +1133,10 @@ static string compile_iteration(const CLIArguments &args, std::vector msl_opts.r32ui_linear_texture_alignment = args.msl_r32ui_linear_texture_alignment; msl_opts.r32ui_alignment_constant_id = args.msl_r32ui_alignment_constant_id; msl_opts.texture_1D_as_2D = args.msl_texture_1d_as_2d; + msl_opts.ios_use_simdgroup_functions = args.msl_ios_use_simdgroup_functions; + msl_opts.emulate_subgroups = args.msl_emulate_subgroups; + msl_opts.fixed_subgroup_size = args.msl_fixed_subgroup_size; + msl_opts.force_sample_rate_shading = args.msl_force_sample_rate_shading; msl_comp->set_msl_options(msl_opts); for (auto &v : args.msl_discrete_descriptor_sets) msl_comp->add_discrete_descriptor_set(v); @@ -1033,6 +1149,8 @@ static string compile_iteration(const CLIArguments &args, std::vector msl_comp->add_inline_uniform_block(v.first, v.second); for (auto &v : args.msl_shader_inputs) msl_comp->add_msl_shader_input(v); + if (args.msl_combined_sampler_suffix) + msl_comp->set_combined_sampler_suffix(args.msl_combined_sampler_suffix); } else if (args.hlsl) compiler.reset(new CompilerHLSL(move(spirv_parser.get_parsed_ir()))); @@ -1055,6 +1173,11 @@ static string compile_iteration(const CLIArguments &args, std::vector compiler->set_variable_type_remap_callback(move(remap_cb)); } + for (auto &masked : args.masked_stage_outputs) + compiler->mask_stage_output_by_location(masked.first, masked.second); + for (auto &masked : args.masked_stage_builtins) + compiler->mask_stage_output_by_builtin(masked); + for (auto &rename : args.entry_point_rename) compiler->rename_entry_point(rename.old_name, rename.new_name, rename.execution_model); @@ -1162,7 +1285,7 @@ static string compile_iteration(const CLIArguments &args, std::vector compiler->set_common_options(opts); for (auto &fetch : args.glsl_ext_framebuffer_fetch) - compiler->remap_ext_framebuffer_fetch(fetch.first, fetch.second); + compiler->remap_ext_framebuffer_fetch(fetch.first, fetch.second, !args.glsl_ext_framebuffer_fetch_noncoherent); // Set HLSL specific options. if (args.hlsl) @@ -1298,6 +1421,7 @@ static string compile_iteration(const CLIArguments &args, std::vector if (args.dump_resources) { + compiler->update_active_builtins(); print_resources(*compiler, res); print_push_constant_resources(*compiler, res.push_constant_buffers); print_spec_constants(*compiler); @@ -1351,6 +1475,9 @@ static int main_inner(int argc, char *argv[]) uint32_t color_attachment = parser.next_uint(); args.glsl_ext_framebuffer_fetch.push_back({ input_index, color_attachment }); }); + cbs.add("--glsl-ext-framebuffer-fetch-noncoherent", [&args](CLIParser &) { + args.glsl_ext_framebuffer_fetch_noncoherent = true; + }); cbs.add("--vulkan-glsl-disable-ext-samplerless-texture-functions", [&args](CLIParser &) { args.vulkan_glsl_disable_ext_samplerless_texture_functions = true; }); cbs.add("--disable-storage-image-qualifier-deduction", @@ -1449,6 +1576,14 @@ static int main_inner(int argc, char *argv[]) cbs.add("--msl-r32ui-linear-texture-align-constant-id", [&args](CLIParser &parser) { args.msl_r32ui_alignment_constant_id = parser.next_uint(); }); cbs.add("--msl-texture-1d-as-2d", [&args](CLIParser &) { args.msl_texture_1d_as_2d = true; }); + cbs.add("--msl-ios-use-simdgroup-functions", [&args](CLIParser &) { args.msl_ios_use_simdgroup_functions = true; }); + cbs.add("--msl-emulate-subgroups", [&args](CLIParser &) { args.msl_emulate_subgroups = true; }); + cbs.add("--msl-fixed-subgroup-size", + [&args](CLIParser &parser) { args.msl_fixed_subgroup_size = parser.next_uint(); }); + cbs.add("--msl-force-sample-rate-shading", [&args](CLIParser &) { args.msl_force_sample_rate_shading = true; }); + cbs.add("--msl-combined-sampler-suffix", [&args](CLIParser &parser) { + args.msl_combined_sampler_suffix = parser.next_string(); + }); cbs.add("--extension", [&args](CLIParser &parser) { args.extensions.push_back(parser.next_string()); }); cbs.add("--rename-entry-point", [&args](CLIParser &parser) { auto old_name = parser.next_string(); @@ -1518,7 +1653,33 @@ static int main_inner(int argc, char *argv[]) cbs.add("--no-support-nonzero-baseinstance", [&](CLIParser &) { args.support_nonzero_baseinstance = false; }); cbs.add("--emit-line-directives", [&args](CLIParser &) { args.emit_line_directives = true; }); + cbs.add("--mask-stage-output-location", [&](CLIParser &parser) { + uint32_t location = parser.next_uint(); + uint32_t component = parser.next_uint(); + args.masked_stage_outputs.push_back({ location, component }); + }); + + cbs.add("--mask-stage-output-builtin", [&](CLIParser &parser) { + BuiltIn masked_builtin = BuiltInMax; + std::string builtin = parser.next_string(); + if (builtin == "Position") + masked_builtin = BuiltInPosition; + else if (builtin == "PointSize") + masked_builtin = BuiltInPointSize; + else if (builtin == "CullDistance") + masked_builtin = BuiltInCullDistance; + else if (builtin == "ClipDistance") + masked_builtin = BuiltInClipDistance; + else + { + print_help(); + exit(EXIT_FAILURE); + } + args.masked_stage_builtins.push_back(masked_builtin); + }); + cbs.default_handler = [&args](const char *value) { args.input = value; }; + cbs.add("-", [&args](CLIParser &) { args.input = "-"; }); cbs.error_handler = [] { print_help(); }; CLIParser parser{ move(cbs), argc - 1, argv + 1 }; diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/image-extract-reuse.asm.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/image-extract-reuse.asm.frag index ed53720d94..2527d10fdc 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/image-extract-reuse.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/image-extract-reuse.asm.frag @@ -8,7 +8,7 @@ struct SPIRV_Cross_Output int2 Size : SV_Target0; }; -uint2 SPIRV_Cross_textureSize(Texture2D Tex, uint Level, out uint Param) +uint2 spvTextureSize(Texture2D Tex, uint Level, out uint Param) { uint2 ret; Tex.GetDimensions(Level, ret.x, ret.y, Param); @@ -19,7 +19,7 @@ void frag_main() { uint _19_dummy_parameter; uint _20_dummy_parameter; - Size = int2(SPIRV_Cross_textureSize(uTexture, uint(0), _19_dummy_parameter)) + int2(SPIRV_Cross_textureSize(uTexture, uint(1), _20_dummy_parameter)); + Size = int2(spvTextureSize(uTexture, uint(0), _19_dummy_parameter)) + int2(spvTextureSize(uTexture, uint(1), _20_dummy_parameter)); } SPIRV_Cross_Output main() diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/line-directive.line.asm.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/line-directive.line.asm.frag index bb5ff558b2..7fb40355a6 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/line-directive.line.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/line-directive.line.asm.frag @@ -29,15 +29,18 @@ void frag_main() #line 16 "test.frag" FragColor = 4.0f; } +#line 19 "test.frag" for (int _127 = 0; float(_127) < (40.0f + vColor); ) { #line 21 "test.frag" FragColor += 0.20000000298023223876953125f; #line 22 "test.frag" FragColor += 0.300000011920928955078125f; +#line 19 "test.frag" _127 += (int(vColor) + 5); continue; } +#line 25 "test.frag" switch (int(vColor)) { case 0: @@ -64,7 +67,10 @@ void frag_main() } for (;;) { +#line 42 "test.frag" FragColor += (10.0f + vColor); +#line 43 "test.frag" +#line 42 "test.frag" #line 43 "test.frag" if (FragColor < 100.0f) { @@ -74,6 +80,7 @@ void frag_main() break; } } +#line 48 "test.frag" } SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/pack-and-unpack-uint2.fxconly.nofxc.sm60.asm.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/pack-and-unpack-uint2.fxconly.nofxc.sm60.asm.frag index c7534f38f2..0841b7cace 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/pack-and-unpack-uint2.fxconly.nofxc.sm60.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/pack-and-unpack-uint2.fxconly.nofxc.sm60.asm.frag @@ -5,12 +5,12 @@ struct SPIRV_Cross_Output float4 FragColor : SV_Target0; }; -uint64_t SPIRV_Cross_packUint2x32(uint2 value) +uint64_t spvPackUint2x32(uint2 value) { return (uint64_t(value.y) << 32) | uint64_t(value.x); } -uint2 SPIRV_Cross_unpackUint2x32(uint64_t value) +uint2 spvUnpackUint2x32(uint64_t value) { uint2 Unpacked; Unpacked.x = uint(value & 0xffffffff); @@ -20,7 +20,7 @@ uint2 SPIRV_Cross_unpackUint2x32(uint64_t value) void frag_main() { - uint2 unpacked = SPIRV_Cross_unpackUint2x32(SPIRV_Cross_packUint2x32(uint2(18u, 52u))); + uint2 unpacked = spvUnpackUint2x32(spvPackUint2x32(uint2(18u, 52u))); FragColor = float4(float(unpacked.x), float(unpacked.y), 1.0f, 1.0f); } diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/comp/inverse.comp b/third_party/spirv-cross/reference/opt/shaders-hlsl/comp/inverse.comp index f9ec89aa31..698f647cec 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/comp/inverse.comp +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/comp/inverse.comp @@ -5,7 +5,7 @@ ByteAddressBuffer _20 : register(t1); // Returns the inverse of a matrix, by using the algorithm of calculating the classical // adjoint and dividing by the determinant. The contents of the matrix are changed. -float2x2 SPIRV_Cross_Inverse(float2x2 m) +float2x2 spvInverse(float2x2 m) { float2x2 adj; // The adjoint matrix (inverse after dividing by determinant) @@ -25,29 +25,29 @@ float2x2 SPIRV_Cross_Inverse(float2x2 m) } // Returns the determinant of a 2x2 matrix. -float SPIRV_Cross_Det2x2(float a1, float a2, float b1, float b2) +float spvDet2x2(float a1, float a2, float b1, float b2) { return a1 * b2 - b1 * a2; } // Returns the inverse of a matrix, by using the algorithm of calculating the classical // adjoint and dividing by the determinant. The contents of the matrix are changed. -float3x3 SPIRV_Cross_Inverse(float3x3 m) +float3x3 spvInverse(float3x3 m) { float3x3 adj; // The adjoint matrix (inverse after dividing by determinant) // Create the transpose of the cofactors, as the classical adjoint of the matrix. - adj[0][0] = SPIRV_Cross_Det2x2(m[1][1], m[1][2], m[2][1], m[2][2]); - adj[0][1] = -SPIRV_Cross_Det2x2(m[0][1], m[0][2], m[2][1], m[2][2]); - adj[0][2] = SPIRV_Cross_Det2x2(m[0][1], m[0][2], m[1][1], m[1][2]); + adj[0][0] = spvDet2x2(m[1][1], m[1][2], m[2][1], m[2][2]); + adj[0][1] = -spvDet2x2(m[0][1], m[0][2], m[2][1], m[2][2]); + adj[0][2] = spvDet2x2(m[0][1], m[0][2], m[1][1], m[1][2]); - adj[1][0] = -SPIRV_Cross_Det2x2(m[1][0], m[1][2], m[2][0], m[2][2]); - adj[1][1] = SPIRV_Cross_Det2x2(m[0][0], m[0][2], m[2][0], m[2][2]); - adj[1][2] = -SPIRV_Cross_Det2x2(m[0][0], m[0][2], m[1][0], m[1][2]); + adj[1][0] = -spvDet2x2(m[1][0], m[1][2], m[2][0], m[2][2]); + adj[1][1] = spvDet2x2(m[0][0], m[0][2], m[2][0], m[2][2]); + adj[1][2] = -spvDet2x2(m[0][0], m[0][2], m[1][0], m[1][2]); - adj[2][0] = SPIRV_Cross_Det2x2(m[1][0], m[1][1], m[2][0], m[2][1]); - adj[2][1] = -SPIRV_Cross_Det2x2(m[0][0], m[0][1], m[2][0], m[2][1]); - adj[2][2] = SPIRV_Cross_Det2x2(m[0][0], m[0][1], m[1][0], m[1][1]); + adj[2][0] = spvDet2x2(m[1][0], m[1][1], m[2][0], m[2][1]); + adj[2][1] = -spvDet2x2(m[0][0], m[0][1], m[2][0], m[2][1]); + adj[2][2] = spvDet2x2(m[0][0], m[0][1], m[1][0], m[1][1]); // Calculate the determinant as a combination of the cofactors of the first row. float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]) + (adj[0][2] * m[2][0]); @@ -58,37 +58,37 @@ float3x3 SPIRV_Cross_Inverse(float3x3 m) } // Returns the determinant of a 3x3 matrix. -float SPIRV_Cross_Det3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3) +float spvDet3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3) { - return a1 * SPIRV_Cross_Det2x2(b2, b3, c2, c3) - b1 * SPIRV_Cross_Det2x2(a2, a3, c2, c3) + c1 * SPIRV_Cross_Det2x2(a2, a3, b2, b3); + return a1 * spvDet2x2(b2, b3, c2, c3) - b1 * spvDet2x2(a2, a3, c2, c3) + c1 * spvDet2x2(a2, a3, b2, b3); } // Returns the inverse of a matrix, by using the algorithm of calculating the classical // adjoint and dividing by the determinant. The contents of the matrix are changed. -float4x4 SPIRV_Cross_Inverse(float4x4 m) +float4x4 spvInverse(float4x4 m) { float4x4 adj; // The adjoint matrix (inverse after dividing by determinant) // Create the transpose of the cofactors, as the classical adjoint of the matrix. - adj[0][0] = SPIRV_Cross_Det3x3(m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]); - adj[0][1] = -SPIRV_Cross_Det3x3(m[0][1], m[0][2], m[0][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]); - adj[0][2] = SPIRV_Cross_Det3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[3][1], m[3][2], m[3][3]); - adj[0][3] = -SPIRV_Cross_Det3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3]); + adj[0][0] = spvDet3x3(m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]); + adj[0][1] = -spvDet3x3(m[0][1], m[0][2], m[0][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]); + adj[0][2] = spvDet3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[3][1], m[3][2], m[3][3]); + adj[0][3] = -spvDet3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3]); - adj[1][0] = -SPIRV_Cross_Det3x3(m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]); - adj[1][1] = SPIRV_Cross_Det3x3(m[0][0], m[0][2], m[0][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]); - adj[1][2] = -SPIRV_Cross_Det3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[3][0], m[3][2], m[3][3]); - adj[1][3] = SPIRV_Cross_Det3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3]); + adj[1][0] = -spvDet3x3(m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]); + adj[1][1] = spvDet3x3(m[0][0], m[0][2], m[0][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]); + adj[1][2] = -spvDet3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[3][0], m[3][2], m[3][3]); + adj[1][3] = spvDet3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3]); - adj[2][0] = SPIRV_Cross_Det3x3(m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]); - adj[2][1] = -SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]); - adj[2][2] = SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], m[3][3]); - adj[2][3] = -SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3]); + adj[2][0] = spvDet3x3(m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]); + adj[2][1] = -spvDet3x3(m[0][0], m[0][1], m[0][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]); + adj[2][2] = spvDet3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], m[3][3]); + adj[2][3] = -spvDet3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3]); - adj[3][0] = -SPIRV_Cross_Det3x3(m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]); - adj[3][1] = SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]); - adj[3][2] = -SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[3][0], m[3][1], m[3][2]); - adj[3][3] = SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2]); + adj[3][0] = -spvDet3x3(m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]); + adj[3][1] = spvDet3x3(m[0][0], m[0][1], m[0][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]); + adj[3][2] = -spvDet3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[3][0], m[3][1], m[3][2]); + adj[3][3] = spvDet3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2]); // Calculate the determinant as a combination of the cofactors of the first row. float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]) + (adj[0][2] * m[2][0]) + (adj[0][3] * m[3][0]); @@ -101,16 +101,16 @@ float4x4 SPIRV_Cross_Inverse(float4x4 m) void comp_main() { float2x2 _23 = asfloat(uint2x2(_20.Load2(0), _20.Load2(8))); - float2x2 _24 = SPIRV_Cross_Inverse(_23); + float2x2 _24 = spvInverse(_23); _15.Store2(0, asuint(_24[0])); _15.Store2(8, asuint(_24[1])); float3x3 _29 = asfloat(uint3x3(_20.Load3(16), _20.Load3(32), _20.Load3(48))); - float3x3 _30 = SPIRV_Cross_Inverse(_29); + float3x3 _30 = spvInverse(_29); _15.Store3(16, asuint(_30[0])); _15.Store3(32, asuint(_30[1])); _15.Store3(48, asuint(_30[2])); float4x4 _35 = asfloat(uint4x4(_20.Load4(64), _20.Load4(80), _20.Load4(96), _20.Load4(112))); - float4x4 _36 = SPIRV_Cross_Inverse(_35); + float4x4 _36 = spvInverse(_35); _15.Store4(64, asuint(_36[0])); _15.Store4(80, asuint(_36[1])); _15.Store4(96, asuint(_36[2])); diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/fp16-packing.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/fp16-packing.frag index d87828225f..54b91e2aa5 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/fp16-packing.frag +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/fp16-packing.frag @@ -15,21 +15,21 @@ struct SPIRV_Cross_Output uint FP16Out : SV_Target1; }; -uint SPIRV_Cross_packHalf2x16(float2 value) +uint spvPackHalf2x16(float2 value) { uint2 Packed = f32tof16(value); return Packed.x | (Packed.y << 16); } -float2 SPIRV_Cross_unpackHalf2x16(uint value) +float2 spvUnpackHalf2x16(uint value) { return f16tof32(uint2(value & 0xffff, value >> 16)); } void frag_main() { - FP32Out = SPIRV_Cross_unpackHalf2x16(FP16); - FP16Out = SPIRV_Cross_packHalf2x16(FP32); + FP32Out = spvUnpackHalf2x16(FP16); + FP16Out = spvPackHalf2x16(FP32); } SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/nonuniform-qualifier.nonuniformresource.sm51.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/nonuniform-qualifier.nonuniformresource.sm51.frag index 65b486518d..f1b6bfafcb 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/nonuniform-qualifier.nonuniformresource.sm51.frag +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/nonuniform-qualifier.nonuniformresource.sm51.frag @@ -3,12 +3,15 @@ struct UBO_1_1 float4 v[64]; }; -ConstantBuffer ubos[] : register(b0, space3); -ByteAddressBuffer ssbos[] : register(t0, space4); +ConstantBuffer ubos[] : register(b2, space9); +RWByteAddressBuffer ssbos[] : register(u3, space10); Texture2D uSamplers[] : register(t0, space0); -SamplerState uSamps[] : register(s0, space2); -Texture2D uCombinedSamplers[] : register(t0, space1); -SamplerState _uCombinedSamplers_sampler[] : register(s0, space1); +SamplerState uSamps[] : register(s1, space3); +Texture2D uCombinedSamplers[] : register(t4, space2); +SamplerState _uCombinedSamplers_sampler[] : register(s4, space2); +Texture2DMS uSamplersMS[] : register(t0, space1); +RWTexture2D uImages[] : register(u5, space7); +RWTexture2D uImagesU32[] : register(u5, space8); static int vIndex; static float4 FragColor; @@ -25,17 +28,70 @@ struct SPIRV_Cross_Output float4 FragColor : SV_Target0; }; +uint2 spvTextureSize(Texture2D Tex, uint Level, out uint Param) +{ + uint2 ret; + Tex.GetDimensions(Level, ret.x, ret.y, Param); + return ret; +} + +uint2 spvTextureSize(Texture2DMS Tex, uint Level, out uint Param) +{ + uint2 ret; + Tex.GetDimensions(ret.x, ret.y, Param); + return ret; +} + +uint2 spvImageSize(RWTexture2D Tex, out uint Param) +{ + uint2 ret; + Tex.GetDimensions(ret.x, ret.y); + Param = 0u; + return ret; +} + void frag_main() { - int _23 = vIndex + 10; - int _34 = vIndex + 40; - FragColor = uSamplers[NonUniformResourceIndex(_23)].Sample(uSamps[NonUniformResourceIndex(_34)], vUV); - FragColor = uCombinedSamplers[NonUniformResourceIndex(_23)].Sample(_uCombinedSamplers_sampler[NonUniformResourceIndex(_23)], vUV); - int _66 = vIndex + 20; - FragColor += ubos[NonUniformResourceIndex(_66)].v[_34]; - int _84 = vIndex + 50; + int _22 = vIndex + 10; + int _32 = vIndex + 40; + FragColor = uSamplers[NonUniformResourceIndex(_22)].Sample(uSamps[NonUniformResourceIndex(_32)], vUV); + int _49 = _22; + FragColor = uCombinedSamplers[NonUniformResourceIndex(_49)].Sample(_uCombinedSamplers_sampler[NonUniformResourceIndex(_49)], vUV); + int _65 = vIndex + 20; + int _69 = _32; + FragColor += ubos[NonUniformResourceIndex(_65)].v[_69]; + int _83 = vIndex + 50; int _88 = vIndex + 60; - FragColor += asfloat(ssbos[NonUniformResourceIndex(_84)].Load4(_88 * 16 + 0)); + FragColor += asfloat(ssbos[NonUniformResourceIndex(_83)].Load4(_88 * 16 + 16)); + int _100 = vIndex + 70; + ssbos[NonUniformResourceIndex(_88)].Store4(_100 * 16 + 16, asuint(20.0f.xxxx)); + int2 _111 = int2(vUV); + FragColor = uSamplers[NonUniformResourceIndex(_49)].Load(int3(_111, 0)); + int _116 = vIndex + 100; + uint _122; + ssbos[_116].InterlockedAdd(0, 100u, _122); + float _136_tmp = uSamplers[NonUniformResourceIndex(_22)].CalculateLevelOfDetail(uSamps[NonUniformResourceIndex(_32)], vUV); + float2 _136 = _136_tmp.xx; + float _143_tmp = uCombinedSamplers[NonUniformResourceIndex(_49)].CalculateLevelOfDetail(_uCombinedSamplers_sampler[NonUniformResourceIndex(_49)], vUV); + float2 _143 = _143_tmp.xx; + float2 _149 = FragColor.xy + (_136 + _143); + FragColor = float4(_149.x, _149.y, FragColor.z, FragColor.w); + int _157; + spvTextureSize(uSamplers[NonUniformResourceIndex(_65)], 0u, _157); + FragColor.x += float(int(_157)); + int _174; + spvTextureSize(uSamplersMS[NonUniformResourceIndex(_65)], 0u, _174); + FragColor.y += float(int(_174)); + uint _185_dummy_parameter; + float2 _189 = FragColor.xy + float2(int2(spvTextureSize(uSamplers[NonUniformResourceIndex(_65)], uint(0), _185_dummy_parameter))); + FragColor = float4(_189.x, _189.y, FragColor.z, FragColor.w); + FragColor += uImages[NonUniformResourceIndex(_83)][_111].xxxx; + uint _212_dummy_parameter; + float2 _216 = FragColor.xy + float2(int2(spvImageSize(uImages[NonUniformResourceIndex(_65)], _212_dummy_parameter))); + FragColor = float4(_216.x, _216.y, FragColor.z, FragColor.w); + uImages[NonUniformResourceIndex(_88)][_111] = 50.0f.x; + uint _242; + InterlockedAdd(uImagesU32[NonUniformResourceIndex(_100)][_111], 40u, _242); } SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/scalar-refract-reflect.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/scalar-refract-reflect.frag index 0fb694c543..6c2d0be4f7 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/scalar-refract-reflect.frag +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/scalar-refract-reflect.frag @@ -11,12 +11,12 @@ struct SPIRV_Cross_Output float FragColor : SV_Target0; }; -float SPIRV_Cross_Reflect(float i, float n) +float spvReflect(float i, float n) { return i - 2.0 * dot(n, i) * n; } -float SPIRV_Cross_Refract(float i, float n, float eta) +float spvRefract(float i, float n, float eta) { float NoI = n * i; float NoI2 = NoI * NoI; @@ -33,8 +33,8 @@ float SPIRV_Cross_Refract(float i, float n, float eta) void frag_main() { - FragColor = SPIRV_Cross_Refract(vRefract.x, vRefract.y, vRefract.z); - FragColor += SPIRV_Cross_Reflect(vRefract.x, vRefract.y); + FragColor = spvRefract(vRefract.x, vRefract.y, vRefract.z); + FragColor += spvReflect(vRefract.x, vRefract.y); FragColor += refract(vRefract.xy, vRefract.yz, vRefract.z).y; FragColor += reflect(vRefract.xy, vRefract.zy).y; } diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/texture-size-combined-image-sampler.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/texture-size-combined-image-sampler.frag index d5c373746d..dd2eb251fc 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/texture-size-combined-image-sampler.frag +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/texture-size-combined-image-sampler.frag @@ -8,7 +8,7 @@ struct SPIRV_Cross_Output int2 FooOut : SV_Target0; }; -uint2 SPIRV_Cross_textureSize(Texture2D Tex, uint Level, out uint Param) +uint2 spvTextureSize(Texture2D Tex, uint Level, out uint Param) { uint2 ret; Tex.GetDimensions(Level, ret.x, ret.y, Param); @@ -18,7 +18,7 @@ uint2 SPIRV_Cross_textureSize(Texture2D Tex, uint Level, out uint Param) void frag_main() { uint _23_dummy_parameter; - FooOut = int2(SPIRV_Cross_textureSize(uTex, uint(0), _23_dummy_parameter)); + FooOut = int2(spvTextureSize(uTex, uint(0), _23_dummy_parameter)); } SPIRV_Cross_Output main() diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/unorm-snorm-packing.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/unorm-snorm-packing.frag index 57b5950636..0dd9ed3fa8 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/unorm-snorm-packing.frag +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/unorm-snorm-packing.frag @@ -27,50 +27,50 @@ struct SPIRV_Cross_Output uint SNORM16Out : SV_Target4; }; -uint SPIRV_Cross_packUnorm4x8(float4 value) +uint spvPackUnorm4x8(float4 value) { uint4 Packed = uint4(round(saturate(value) * 255.0)); return Packed.x | (Packed.y << 8) | (Packed.z << 16) | (Packed.w << 24); } -float4 SPIRV_Cross_unpackUnorm4x8(uint value) +float4 spvUnpackUnorm4x8(uint value) { uint4 Packed = uint4(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, value >> 24); return float4(Packed) / 255.0; } -uint SPIRV_Cross_packSnorm4x8(float4 value) +uint spvPackSnorm4x8(float4 value) { int4 Packed = int4(round(clamp(value, -1.0, 1.0) * 127.0)) & 0xff; return uint(Packed.x | (Packed.y << 8) | (Packed.z << 16) | (Packed.w << 24)); } -float4 SPIRV_Cross_unpackSnorm4x8(uint value) +float4 spvUnpackSnorm4x8(uint value) { int SignedValue = int(value); int4 Packed = int4(SignedValue << 24, SignedValue << 16, SignedValue << 8, SignedValue) >> 24; return clamp(float4(Packed) / 127.0, -1.0, 1.0); } -uint SPIRV_Cross_packUnorm2x16(float2 value) +uint spvPackUnorm2x16(float2 value) { uint2 Packed = uint2(round(saturate(value) * 65535.0)); return Packed.x | (Packed.y << 16); } -float2 SPIRV_Cross_unpackUnorm2x16(uint value) +float2 spvUnpackUnorm2x16(uint value) { uint2 Packed = uint2(value & 0xffff, value >> 16); return float2(Packed) / 65535.0; } -uint SPIRV_Cross_packSnorm2x16(float2 value) +uint spvPackSnorm2x16(float2 value) { int2 Packed = int2(round(clamp(value, -1.0, 1.0) * 32767.0)) & 0xffff; return uint(Packed.x | (Packed.y << 16)); } -float2 SPIRV_Cross_unpackSnorm2x16(uint value) +float2 spvUnpackSnorm2x16(uint value) { int SignedValue = int(value); int2 Packed = int2(SignedValue << 16, SignedValue) >> 16; @@ -79,16 +79,16 @@ float2 SPIRV_Cross_unpackSnorm2x16(uint value) void frag_main() { - FP32Out = SPIRV_Cross_unpackUnorm4x8(UNORM8); - FP32Out = SPIRV_Cross_unpackSnorm4x8(SNORM8); - float2 _21 = SPIRV_Cross_unpackUnorm2x16(UNORM16); + FP32Out = spvUnpackUnorm4x8(UNORM8); + FP32Out = spvUnpackSnorm4x8(SNORM8); + float2 _21 = spvUnpackUnorm2x16(UNORM16); FP32Out = float4(_21.x, _21.y, FP32Out.z, FP32Out.w); - float2 _26 = SPIRV_Cross_unpackSnorm2x16(SNORM16); + float2 _26 = spvUnpackSnorm2x16(SNORM16); FP32Out = float4(_26.x, _26.y, FP32Out.z, FP32Out.w); - UNORM8Out = SPIRV_Cross_packUnorm4x8(FP32); - SNORM8Out = SPIRV_Cross_packSnorm4x8(FP32); - UNORM16Out = SPIRV_Cross_packUnorm2x16(FP32.xy); - SNORM16Out = SPIRV_Cross_packSnorm2x16(FP32.zw); + UNORM8Out = spvPackUnorm4x8(FP32); + SNORM8Out = spvPackSnorm4x8(FP32); + UNORM16Out = spvPackUnorm2x16(FP32.xy); + SNORM16Out = spvPackSnorm2x16(FP32.zw); } SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/vert/invariant.vert b/third_party/spirv-cross/reference/opt/shaders-hlsl/vert/invariant.vert new file mode 100644 index 0000000000..5473962686 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/vert/invariant.vert @@ -0,0 +1,40 @@ +static float4 gl_Position; +static float4 vInput0; +static float4 vInput1; +static float4 vInput2; +static float4 vColor; + +struct SPIRV_Cross_Input +{ + float4 vInput0 : TEXCOORD0; + float4 vInput1 : TEXCOORD1; + float4 vInput2 : TEXCOORD2; +}; + +struct SPIRV_Cross_Output +{ + precise float4 vColor : TEXCOORD0; + precise float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + float4 _20 = vInput1 * vInput2; + float4 _21 = vInput0 + _20; + gl_Position = _21; + float4 _27 = vInput0 - vInput1; + float4 _29 = _27 * vInput2; + vColor = _29; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vInput0 = stage_input.vInput0; + vInput1 = stage_input.vInput1; + vInput2 = stage_input.vInput2; + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + stage_output.vColor = vColor; + return stage_output; +} diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/vert/no-contraction.vert b/third_party/spirv-cross/reference/opt/shaders-hlsl/vert/no-contraction.vert new file mode 100644 index 0000000000..10763fbee5 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/vert/no-contraction.vert @@ -0,0 +1,39 @@ +static float4 gl_Position; +static float4 vA; +static float4 vB; +static float4 vC; + +struct SPIRV_Cross_Input +{ + float4 vA : TEXCOORD0; + float4 vB : TEXCOORD1; + float4 vC : TEXCOORD2; +}; + +struct SPIRV_Cross_Output +{ + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + precise float4 _15 = vA * vB; + precise float4 _19 = vA + vB; + precise float4 _23 = vA - vB; + precise float4 _30 = _15 + vC; + precise float4 _34 = _15 + _19; + precise float4 _36 = _34 + _23; + precise float4 _38 = _36 + _30; + gl_Position = _38; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vA = stage_input.vA; + vB = stage_input.vB; + vC = stage_input.vC; + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + return stage_output; +} diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/image-load-store-short-vector.asm.comp b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/image-load-store-short-vector.asm.comp deleted file mode 100644 index fb97d0da9b..0000000000 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/image-load-store-short-vector.asm.comp +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include - -using namespace metal; - -kernel void main0(texture2d TargetTexture [[texture(0)]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]]) -{ - TargetTexture.write((TargetTexture.read(uint2(gl_WorkGroupID.xy)).xy + float2(1.0)).xyyy, uint2((gl_WorkGroupID.xy + uint2(1u)))); -} - diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/comp/image-load-store-short-vector.asm.comp b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/image-load-store-short-vector.invalid.asm.comp similarity index 100% rename from third_party/spirv-cross/reference/shaders-msl/asm/comp/image-load-store-short-vector.asm.comp rename to third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/image-load-store-short-vector.invalid.asm.comp diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/line-directive.line.asm.frag b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/line-directive.line.asm.frag index f70254a87d..3634499f28 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/line-directive.line.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/line-directive.line.asm.frag @@ -32,15 +32,18 @@ fragment main0_out main0(main0_in in [[stage_in]]) #line 16 "test.frag" out.FragColor = 4.0; } +#line 19 "test.frag" for (int _127 = 0; float(_127) < (40.0 + in.vColor); ) { #line 21 "test.frag" out.FragColor += 0.20000000298023223876953125; #line 22 "test.frag" out.FragColor += 0.300000011920928955078125; +#line 19 "test.frag" _127 += (int(in.vColor) + 5); continue; } +#line 25 "test.frag" switch (int(in.vColor)) { case 0: @@ -67,7 +70,10 @@ fragment main0_out main0(main0_in in [[stage_in]]) } for (;;) { +#line 42 "test.frag" out.FragColor += (10.0 + in.vColor); +#line 43 "test.frag" +#line 42 "test.frag" #line 43 "test.frag" if (out.FragColor < 100.0) { @@ -77,6 +83,7 @@ fragment main0_out main0(main0_in in [[stage_in]]) break; } } +#line 48 "test.frag" return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/tesc/tess-level-overrun.multi-patch.asm.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/asm/tesc/tess-level-overrun.multi-patch.asm.tesc index a5f316ddfe..79395a4bbb 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/tesc/tess-level-overrun.multi-patch.asm.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/tesc/tess-level-overrun.multi-patch.asm.tesc @@ -15,7 +15,7 @@ struct TessLevels kernel void main0(const device TessLevels& sb_levels [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], constant uint* spvIndirectParams [[buffer(29)]], device MTLTriangleTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 1, spvIndirectParams[1]); + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 1, spvIndirectParams[1] - 1); spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(sb_levels.inner0); spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(sb_levels.outer0); spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1] = half(sb_levels.outer1); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/tese/unnamed-builtin-array.asm.tese b/third_party/spirv-cross/reference/opt/shaders-msl/asm/tese/unnamed-builtin-array.asm.tese index 83ef729321..99803754d8 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/tese/unnamed-builtin-array.asm.tese +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/tese/unnamed-builtin-array.asm.tese @@ -1,8 +1,49 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct main0_out { float4 gl_Position [[position]]; @@ -10,14 +51,22 @@ struct main0_out struct main0_patchIn { - float2 gl_TessLevelInner [[attribute(0)]]; - float4 gl_TessLevelOuter [[attribute(1)]]; + float4 gl_TessLevelOuter [[attribute(0)]]; + float2 gl_TessLevelInner [[attribute(1)]]; }; [[ patch(quad, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]], float2 gl_TessCoord [[position_in_patch]]) { main0_out out = {}; - out.gl_Position = float4(((gl_TessCoord.x * patchIn.gl_TessLevelInner.x) * patchIn.gl_TessLevelOuter.x) + (((1.0 - gl_TessCoord.x) * patchIn.gl_TessLevelInner.x) * patchIn.gl_TessLevelOuter.z), ((gl_TessCoord.y * patchIn.gl_TessLevelInner.y) * patchIn.gl_TessLevelOuter.y) + (((1.0 - gl_TessCoord.y) * patchIn.gl_TessLevelInner.y) * patchIn.gl_TessLevelOuter.w), 0.0, 1.0); + spvUnsafeArray gl_TessLevelInner = {}; + spvUnsafeArray gl_TessLevelOuter = {}; + gl_TessLevelInner[0] = patchIn.gl_TessLevelInner.x; + gl_TessLevelInner[1] = patchIn.gl_TessLevelInner.y; + gl_TessLevelOuter[0] = patchIn.gl_TessLevelOuter.x; + gl_TessLevelOuter[1] = patchIn.gl_TessLevelOuter.y; + gl_TessLevelOuter[2] = patchIn.gl_TessLevelOuter.z; + gl_TessLevelOuter[3] = patchIn.gl_TessLevelOuter.w; + out.gl_Position = float4(((gl_TessCoord.x * gl_TessLevelInner[0]) * gl_TessLevelOuter[0]) + (((1.0 - gl_TessCoord.x) * gl_TessLevelInner[0]) * gl_TessLevelOuter[2]), ((gl_TessCoord.y * gl_TessLevelInner[1]) * gl_TessLevelOuter[1]) + (((1.0 - gl_TessCoord.y) * gl_TessLevelInner[1]) * gl_TessLevelOuter[3]), 0.0, 1.0); return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/vert/fake-builtin-input.asm.vert b/third_party/spirv-cross/reference/opt/shaders-msl/asm/vert/fake-builtin-input.asm.vert index f9fcbc85c3..3079ae9bcb 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/vert/fake-builtin-input.asm.vert +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/vert/fake-builtin-input.asm.vert @@ -5,6 +5,7 @@ using namespace metal; struct main0_out { + half4 out_var_SV_Target [[user(locn0)]]; float4 gl_Position [[position]]; }; diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/desktop-only/tesc/basic.desktop.sso.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/desktop-only/tesc/basic.desktop.sso.multi-patch.tesc index 863a32a839..8ebde9d9d7 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/desktop-only/tesc/basic.desktop.sso.multi-patch.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/desktop-only/tesc/basic.desktop.sso.multi-patch.tesc @@ -26,7 +26,7 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 1]; device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 1, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; uint gl_InvocationID = gl_GlobalInvocationID.x % 1; - uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 1, spvIndirectParams[1]); + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 1, spvIndirectParams[1] - 1); spvTessLevel[gl_PrimitiveID].insideTessellationFactor[0] = half(8.8999996185302734375); spvTessLevel[gl_PrimitiveID].insideTessellationFactor[1] = half(6.900000095367431640625); spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(8.8999996185302734375); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/desktop-only/tesc/struct-copy.desktop.sso.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/desktop-only/tesc/struct-copy.desktop.sso.multi-patch.tesc index e47d56a202..184a4a6f9b 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/desktop-only/tesc/struct-copy.desktop.sso.multi-patch.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/desktop-only/tesc/struct-copy.desktop.sso.multi-patch.tesc @@ -16,8 +16,7 @@ struct main0_out struct main0_in { - float3 Boo_a; - uint3 Boo_b; + Boo vInput; }; kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]]) @@ -25,9 +24,8 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; - uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1]); - Boo _26 = Boo{ gl_in[gl_InvocationID].Boo_a, gl_in[gl_InvocationID].Boo_b }; - gl_out[gl_InvocationID].vVertex = _26; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + gl_out[gl_InvocationID].vVertex = gl_in[gl_InvocationID].vInput; spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(1.0); spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1] = half(2.0); spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2] = half(3.0); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/array-component-io.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/array-component-io.frag new file mode 100644 index 0000000000..9b4c5b5204 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/array-component-io.frag @@ -0,0 +1,99 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 m_location_0 [[color(0)]]; + float4 m_location_1 [[color(1)]]; + float4 m_location_2 [[color(2)]]; +}; + +struct main0_in +{ + float InC_0 [[user(locn0_1), flat]]; + float InA_0 [[user(locn1), flat]]; + float InC_1 [[user(locn1_1), flat]]; + float2 InB_0 [[user(locn1_2), flat]]; + float InA_1 [[user(locn2), flat]]; + float InC_2 [[user(locn2_1), flat]]; + float2 InB_1 [[user(locn2_2), flat]]; + float InD [[user(locn3_1), sample_perspective]]; + float InE [[user(locn4_2), center_no_perspective]]; + float InF [[user(locn5_3), centroid_perspective]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + spvUnsafeArray A = {}; + spvUnsafeArray B = {}; + spvUnsafeArray C = {}; + float D = {}; + spvUnsafeArray InA = {}; + spvUnsafeArray InB = {}; + spvUnsafeArray InC = {}; + InA[0] = in.InA_0; + InA[1] = in.InA_1; + InB[0] = in.InB_0; + InB[1] = in.InB_1; + InC[0] = in.InC_0; + InC[1] = in.InC_1; + InC[2] = in.InC_2; + A = InA; + B = InB; + C = InC; + D = (in.InD + in.InE) + in.InF; + out.m_location_1.x = A[0]; + out.m_location_2.x = A[1]; + out.m_location_1.zw = B[0]; + out.m_location_2.zw = B[1]; + out.m_location_0.y = C[0]; + out.m_location_1.y = C[1]; + out.m_location_2.y = C[2]; + out.m_location_0.w = D; + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/basic.force-sample.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/basic.force-sample.frag new file mode 100644 index 0000000000..b9706b73f5 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/basic.force-sample.frag @@ -0,0 +1,23 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +struct main0_in +{ + float4 vColor [[user(locn0)]]; + float2 vTex [[user(locn1)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texture2d uTex [[texture(0)]], sampler uTexSmplr [[sampler(0)]], uint gl_SampleID [[sample_id]]) +{ + main0_out out = {}; + out.FragColor = in.vColor * uTex.sample(uTexSmplr, in.vTex); + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/cull-distance-varying.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/cull-distance-varying.frag new file mode 100644 index 0000000000..708a295710 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/cull-distance-varying.frag @@ -0,0 +1,67 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +struct main0_in +{ + float gl_CullDistance_0 [[user(cull0)]]; + float gl_CullDistance_1 [[user(cull1)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + spvUnsafeArray gl_CullDistance = {}; + gl_CullDistance[0] = in.gl_CullDistance_0; + gl_CullDistance[1] = in.gl_CullDistance_1; + out.FragColor = float4((1.0 - gl_CullDistance[0]) - gl_CullDistance[1]); + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/input-attachment-ms.arrayed-subpass.msl21.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/input-attachment-ms.arrayed-subpass.msl21.frag index 5f137b048e..52a78cf93a 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/frag/input-attachment-ms.arrayed-subpass.msl21.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/input-attachment-ms.arrayed-subpass.msl21.frag @@ -11,6 +11,7 @@ struct main0_out fragment main0_out main0(texture2d_ms_array uSubpass0 [[texture(0)]], texture2d_ms_array uSubpass1 [[texture(1)]], uint gl_SampleID [[sample_id]], float4 gl_FragCoord [[position]], uint gl_Layer [[render_target_array_index]]) { main0_out out = {}; + gl_FragCoord.xy += get_sample_position(gl_SampleID) - 0.5; out.FragColor = (uSubpass0.read(uint2(gl_FragCoord.xy), gl_Layer, 1) + uSubpass1.read(uint2(gl_FragCoord.xy), gl_Layer, 2)) + uSubpass0.read(uint2(gl_FragCoord.xy), gl_Layer, gl_SampleID); return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/input-attachment-ms.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/input-attachment-ms.frag index 906cabbf47..0c47348d6e 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/frag/input-attachment-ms.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/input-attachment-ms.frag @@ -11,6 +11,7 @@ struct main0_out fragment main0_out main0(texture2d_ms uSubpass0 [[texture(0)]], texture2d_ms uSubpass1 [[texture(1)]], uint gl_SampleID [[sample_id]], float4 gl_FragCoord [[position]]) { main0_out out = {}; + gl_FragCoord.xy += get_sample_position(gl_SampleID) - 0.5; out.FragColor = (uSubpass0.read(uint2(gl_FragCoord.xy), 1) + uSubpass1.read(uint2(gl_FragCoord.xy), 2)) + uSubpass0.read(uint2(gl_FragCoord.xy), gl_SampleID); return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/input-attachment-ms.multiview.msl21.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/input-attachment-ms.multiview.msl21.frag index 2e4ca8a7ae..e27b24adf3 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/frag/input-attachment-ms.multiview.msl21.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/input-attachment-ms.multiview.msl21.frag @@ -11,6 +11,7 @@ struct main0_out fragment main0_out main0(constant uint* spvViewMask [[buffer(24)]], texture2d_ms_array uSubpass0 [[texture(0)]], texture2d_ms_array uSubpass1 [[texture(1)]], uint gl_SampleID [[sample_id]], float4 gl_FragCoord [[position]], uint gl_ViewIndex [[render_target_array_index]]) { main0_out out = {}; + gl_FragCoord.xy += get_sample_position(gl_SampleID) - 0.5; gl_ViewIndex += spvViewMask[0]; out.FragColor = (uSubpass0.read(uint2(gl_FragCoord.xy), gl_ViewIndex, 1) + uSubpass1.read(uint2(gl_FragCoord.xy), gl_ViewIndex, 2)) + uSubpass0.read(uint2(gl_FragCoord.xy), gl_ViewIndex, gl_SampleID); return out; diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/nonuniform-qualifier.msl2.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/nonuniform-qualifier.msl2.frag index c120959c34..bdd8d1419b 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/frag/nonuniform-qualifier.msl2.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/nonuniform-qualifier.msl2.frag @@ -44,10 +44,10 @@ fragment main0_out main0(main0_in in [[stage_in]], constant UBO* ubos_0 [[buffer out.FragColor = uSamplers[_25].sample(uSamps[_37], in.vUV); out.FragColor = uCombinedSamplers[_25].sample(uCombinedSamplersSmplr[_25], in.vUV); int _69 = in.vIndex + 20; - out.FragColor += ubos[(_69)]->v[_37]; + out.FragColor += ubos[_69]->v[_37]; int _87 = in.vIndex + 50; int _91 = in.vIndex + 60; - out.FragColor += ssbos[(_87)]->v[_91]; + out.FragColor += ssbos[_87]->v[_91]; return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/read-cull-clip-distance-in-function.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/read-cull-clip-distance-in-function.frag new file mode 100644 index 0000000000..3c9757ebd2 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/read-cull-clip-distance-in-function.frag @@ -0,0 +1,72 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +struct main0_in +{ + float gl_ClipDistance_0 [[user(clip0)]]; + float gl_ClipDistance_1 [[user(clip1)]]; + float gl_CullDistance_0 [[user(cull0)]]; + float gl_CullDistance_1 [[user(cull1)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + spvUnsafeArray gl_CullDistance = {}; + spvUnsafeArray gl_ClipDistance = {}; + gl_CullDistance[0] = in.gl_CullDistance_0; + gl_CullDistance[1] = in.gl_CullDistance_1; + gl_ClipDistance[0] = in.gl_ClipDistance_0; + gl_ClipDistance[1] = in.gl_ClipDistance_1; + out.FragColor = float4(gl_CullDistance[0], gl_CullDistance[1], gl_ClipDistance[0], gl_ClipDistance[1]); + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-rate-frag-coord-sample-id.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-rate-frag-coord-sample-id.frag new file mode 100644 index 0000000000..5df60f909e --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-rate-frag-coord-sample-id.frag @@ -0,0 +1,19 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(texture2d_array tex [[texture(0)]], sampler texSmplr [[sampler(0)]], float4 gl_FragCoord [[position]], uint gl_SampleID [[sample_id]]) +{ + main0_out out = {}; + gl_FragCoord.xy += get_sample_position(gl_SampleID) - 0.5; + float3 _28 = float3(gl_FragCoord.xy, float(gl_SampleID)); + out.FragColor = tex.sample(texSmplr, _28.xy, uint(round(_28.z))); + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-rate-frag-coord-sample-input.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-rate-frag-coord-sample-input.frag new file mode 100644 index 0000000000..386230ef0c --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-rate-frag-coord-sample-input.frag @@ -0,0 +1,24 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +struct main0_in +{ + float foo [[user(locn0), sample_perspective]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texture2d_array tex [[texture(0)]], sampler texSmplr [[sampler(0)]], float4 gl_FragCoord [[position]], uint gl_SampleID [[sample_id]]) +{ + main0_out out = {}; + gl_FragCoord.xy += get_sample_position(gl_SampleID) - 0.5; + float3 _26 = float3(gl_FragCoord.xy, in.foo); + out.FragColor = tex.sample(texSmplr, _26.xy, uint(round(_26.z))); + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-rate-frag-coord-sample-pos.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-rate-frag-coord-sample-pos.frag new file mode 100644 index 0000000000..f8f357fe7c --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-rate-frag-coord-sample-pos.frag @@ -0,0 +1,19 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(texture2d tex [[texture(0)]], sampler texSmplr [[sampler(0)]], float4 gl_FragCoord [[position]], uint gl_SampleID [[sample_id]]) +{ + main0_out out = {}; + gl_FragCoord.xy += get_sample_position(gl_SampleID) - 0.5; + float2 gl_SamplePosition = get_sample_position(gl_SampleID); + out.FragColor = tex.sample(texSmplr, (gl_FragCoord.xy - gl_SamplePosition)); + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-rate-frag-coord.force-sample.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-rate-frag-coord.force-sample.frag new file mode 100644 index 0000000000..1ed8148d4c --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-rate-frag-coord.force-sample.frag @@ -0,0 +1,18 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(texture2d tex [[texture(0)]], sampler texSmplr [[sampler(0)]], float4 gl_FragCoord [[position]], uint gl_SampleID [[sample_id]]) +{ + main0_out out = {}; + gl_FragCoord.xy += get_sample_position(gl_SampleID) - 0.5; + out.FragColor = tex.sample(texSmplr, gl_FragCoord.xy); + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/subgroup-globals-extract.msl22.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/subgroup-globals-extract.msl22.frag new file mode 100644 index 0000000000..bb8fadcf11 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/subgroup-globals-extract.msl22.frag @@ -0,0 +1,56 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_out +{ + uint2 FragColor [[color(0)]]; +}; + +inline uint spvSubgroupBallotFindLSB(uint4 ballot, uint gl_SubgroupSize) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupSize, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupSize - 32, 0)), uint2(0)); + ballot &= mask; + return select(ctz(ballot.x), select(32 + ctz(ballot.y), select(64 + ctz(ballot.z), select(96 + ctz(ballot.w), uint(-1), ballot.w == 0), ballot.z == 0), ballot.y == 0), ballot.x == 0); +} + +inline uint spvSubgroupBallotFindMSB(uint4 ballot, uint gl_SubgroupSize) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupSize, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupSize - 32, 0)), uint2(0)); + ballot &= mask; + return select(128 - (clz(ballot.w) + 1), select(96 - (clz(ballot.z) + 1), select(64 - (clz(ballot.y) + 1), select(32 - (clz(ballot.x) + 1), uint(-1), ballot.x == 0), ballot.y == 0), ballot.z == 0), ballot.w == 0); +} + +inline uint spvPopCount4(uint4 ballot) +{ + return popcount(ballot.x) + popcount(ballot.y) + popcount(ballot.z) + popcount(ballot.w); +} + +inline uint spvSubgroupBallotBitCount(uint4 ballot, uint gl_SubgroupSize) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupSize, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupSize - 32, 0)), uint2(0)); + return spvPopCount4(ballot & mask); +} + +inline uint spvSubgroupBallotInclusiveBitCount(uint4 ballot, uint gl_SubgroupInvocationID) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID + 1, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID + 1 - 32, 0)), uint2(0)); + return spvPopCount4(ballot & mask); +} + +inline uint spvSubgroupBallotExclusiveBitCount(uint4 ballot, uint gl_SubgroupInvocationID) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID - 32, 0)), uint2(0)); + return spvPopCount4(ballot & mask); +} + +fragment main0_out main0(uint gl_SubgroupInvocationID [[thread_index_in_simdgroup]], uint gl_SubgroupSize [[threads_per_simdgroup]]) +{ + main0_out out = {}; + out.FragColor.x = (((spvSubgroupBallotFindLSB(uint4(1u, 2u, 3u, 4u), gl_SubgroupSize) + spvSubgroupBallotFindMSB(uint4(1u, 2u, 3u, 4u), gl_SubgroupSize)) + spvSubgroupBallotBitCount(uint4(1u, 2u, 3u, 4u), gl_SubgroupSize)) + spvSubgroupBallotInclusiveBitCount(uint4(1u, 2u, 3u, 4u), gl_SubgroupInvocationID)) + spvSubgroupBallotExclusiveBitCount(uint4(1u, 2u, 3u, 4u), gl_SubgroupInvocationID); + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/copy-arrays.mask-location-0.msl2.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/copy-arrays.mask-location-0.msl2.multi-patch.tesc new file mode 100644 index 0000000000..406feed975 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/copy-arrays.mask-location-0.msl2.multi-patch.tesc @@ -0,0 +1,188 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 gl_Position; +}; + +struct main0_patchOut +{ + spvUnsafeArray pFoo; +}; + +struct main0_in +{ + spvUnsafeArray iFoo; + float4 ipFoo; +}; + +template +inline void spvArrayCopyFromConstantToStack1(thread T (&dst)[A], constant T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromConstantToThreadGroup1(threadgroup T (&dst)[A], constant T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromStackToStack1(thread T (&dst)[A], thread const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromStackToThreadGroup1(threadgroup T (&dst)[A], thread const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromThreadGroupToStack1(thread T (&dst)[A], threadgroup const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromThreadGroupToThreadGroup1(threadgroup T (&dst)[A], threadgroup const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromDeviceToDevice1(device T (&dst)[A], device const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromConstantToDevice1(device T (&dst)[A], constant T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromStackToDevice1(device T (&dst)[A], thread const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromThreadGroupToDevice1(device T (&dst)[A], threadgroup const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromDeviceToStack1(thread T (&dst)[A], device const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromDeviceToThreadGroup1(threadgroup T (&dst)[A], device const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]]) +{ + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + threadgroup float4 spvStorageFoo[8][4][2]; + threadgroup float4 (&Foo)[4][2] = spvStorageFoo[(gl_GlobalInvocationID.x / 4) % 8]; + device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; + device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + gl_out[gl_InvocationID].gl_Position = float4(1.0); + spvArrayCopyFromDeviceToThreadGroup1(Foo[gl_InvocationID], gl_in[gl_InvocationID].iFoo.elements); + if (gl_InvocationID == 0) + { + spvUnsafeArray _56 = spvUnsafeArray({ gl_in[0].ipFoo, gl_in[1].ipFoo }); + patchOut.pFoo = _56; + } +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/copy-arrays.mask-location-0.msl2.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/copy-arrays.mask-location-0.msl2.tesc new file mode 100644 index 0000000000..e9dd68dc37 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/copy-arrays.mask-location-0.msl2.tesc @@ -0,0 +1,191 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 gl_Position; +}; + +struct main0_patchOut +{ + spvUnsafeArray pFoo; +}; + +struct main0_in +{ + float4 iFoo_0 [[attribute(0)]]; + float4 iFoo_1 [[attribute(1)]]; + float4 ipFoo [[attribute(2)]]; +}; + +template +inline void spvArrayCopyFromConstantToStack1(thread T (&dst)[A], constant T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromConstantToThreadGroup1(threadgroup T (&dst)[A], constant T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromStackToStack1(thread T (&dst)[A], thread const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromStackToThreadGroup1(threadgroup T (&dst)[A], thread const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromThreadGroupToStack1(thread T (&dst)[A], threadgroup const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromThreadGroupToThreadGroup1(threadgroup T (&dst)[A], threadgroup const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromDeviceToDevice1(device T (&dst)[A], device const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromConstantToDevice1(device T (&dst)[A], constant T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromStackToDevice1(device T (&dst)[A], thread const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromThreadGroupToDevice1(device T (&dst)[A], threadgroup const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromDeviceToStack1(thread T (&dst)[A], device const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromDeviceToThreadGroup1(threadgroup T (&dst)[A], device const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +kernel void main0(main0_in in [[stage_in]], uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], threadgroup main0_in* gl_in [[threadgroup(0)]]) +{ + threadgroup float4 Foo[4][2]; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + if (gl_InvocationID < spvIndirectParams[0]) + gl_in[gl_InvocationID] = in; + threadgroup_barrier(mem_flags::mem_threadgroup); + if (gl_InvocationID >= 4) + return; + gl_out[gl_InvocationID].gl_Position = float4(1.0); + spvUnsafeArray _38 = spvUnsafeArray({ gl_in[gl_InvocationID].iFoo_0, gl_in[gl_InvocationID].iFoo_1 }); + spvArrayCopyFromStackToThreadGroup1(Foo[gl_InvocationID], _38.elements); + if (gl_InvocationID == 0) + { + spvUnsafeArray _56 = spvUnsafeArray({ gl_in[0].ipFoo, gl_in[1].ipFoo }); + patchOut.pFoo = _56; + } +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/copy-arrays.mask-location-1.msl2.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/copy-arrays.mask-location-1.msl2.multi-patch.tesc new file mode 100644 index 0000000000..abc95ca899 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/copy-arrays.mask-location-1.msl2.multi-patch.tesc @@ -0,0 +1,79 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + spvUnsafeArray Foo; + float4 gl_Position; +}; + +struct main0_patchOut +{ + spvUnsafeArray pFoo; +}; + +struct main0_in +{ + spvUnsafeArray iFoo; + float4 ipFoo; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]]) +{ + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; + device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + gl_out[gl_InvocationID].gl_Position = float4(1.0); + gl_out[gl_InvocationID].Foo = gl_in[gl_InvocationID].iFoo; + if (gl_InvocationID == 0) + { + spvUnsafeArray _56 = spvUnsafeArray({ gl_in[0].ipFoo, gl_in[1].ipFoo }); + patchOut.pFoo = _56; + } +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/copy-arrays.mask-location-1.msl2.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/copy-arrays.mask-location-1.msl2.tesc new file mode 100644 index 0000000000..3da1d18c61 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/copy-arrays.mask-location-1.msl2.tesc @@ -0,0 +1,83 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + spvUnsafeArray Foo; + float4 gl_Position; +}; + +struct main0_patchOut +{ + spvUnsafeArray pFoo; +}; + +struct main0_in +{ + float4 iFoo_0 [[attribute(0)]]; + float4 iFoo_1 [[attribute(1)]]; + float4 ipFoo [[attribute(2)]]; +}; + +kernel void main0(main0_in in [[stage_in]], uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], threadgroup main0_in* gl_in [[threadgroup(0)]]) +{ + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + if (gl_InvocationID < spvIndirectParams[0]) + gl_in[gl_InvocationID] = in; + threadgroup_barrier(mem_flags::mem_threadgroup); + if (gl_InvocationID >= 4) + return; + gl_out[gl_InvocationID].gl_Position = float4(1.0); + spvUnsafeArray _38 = spvUnsafeArray({ gl_in[gl_InvocationID].iFoo_0, gl_in[gl_InvocationID].iFoo_1 }); + gl_out[gl_InvocationID].Foo = _38; + if (gl_InvocationID == 0) + { + spvUnsafeArray _56 = spvUnsafeArray({ gl_in[0].ipFoo, gl_in[1].ipFoo }); + patchOut.pFoo = _56; + } +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-0.for-tess.vert b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-0.for-tess.vert new file mode 100644 index 0000000000..f7b1acb576 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-0.for-tess.vert @@ -0,0 +1,35 @@ +#include +#include + +using namespace metal; + +struct V +{ + float4 a; + float4 b; + float4 c; + float4 d; +}; + +struct main0_out +{ + float4 V_b; + float4 V_c; + float4 V_d; + float4 gl_Position; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 spvStageInputSize [[grid_size]], device main0_out* spvOut [[buffer(28)]]) +{ + V _22 = {}; + device main0_out& out = spvOut[gl_GlobalInvocationID.y * spvStageInputSize.x + gl_GlobalInvocationID.x]; + if (any(gl_GlobalInvocationID >= spvStageInputSize)) + return; + out.gl_Position = float4(1.0); + _22.a = float4(2.0); + _22.b = float4(3.0); + out.V_b = _22.b; + out.V_c = _22.c; + out.V_d = _22.d; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-0.msl2.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-0.msl2.tesc new file mode 100644 index 0000000000..a8d1b75093 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-0.msl2.tesc @@ -0,0 +1,41 @@ +#include +#include + +using namespace metal; + +struct P +{ + float a; + float b; +}; + +struct C +{ + float a; + float b; +}; + +struct main0_out +{ + float C_a; + float C_b; + float4 gl_Position; +}; + +struct main0_patchOut +{ + float P_b; +}; + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + threadgroup P _11; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + _11.a = 1.0; + patchOut.P_b = 2.0; + gl_out[gl_InvocationID].C_a = 3.0; + gl_out[gl_InvocationID].C_b = 4.0; + gl_out[gl_InvocationID].gl_Position = float4(1.0); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-0.multi-patch.msl2.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-0.multi-patch.msl2.tesc new file mode 100644 index 0000000000..ef9877b1f1 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-0.multi-patch.msl2.tesc @@ -0,0 +1,44 @@ +#include +#include + +using namespace metal; + +struct P +{ + float a; + float b; +}; + +struct C +{ + float a; + float b; +}; + +struct main0_out +{ + float C_a; + float C_b; + float4 gl_Position; +}; + +struct main0_patchOut +{ + float P_b; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; + threadgroup P spvStorage_11[8]; + threadgroup P (&_11) = spvStorage_11[(gl_GlobalInvocationID.x / 4) % 8]; + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + _11.a = 1.0; + patchOut.P_b = 2.0; + gl_out[gl_InvocationID].C_a = 3.0; + gl_out[gl_InvocationID].C_b = 4.0; + gl_out[gl_InvocationID].gl_Position = float4(1.0); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-0.vert b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-0.vert new file mode 100644 index 0000000000..648a11adce --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-0.vert @@ -0,0 +1,34 @@ +#include +#include + +using namespace metal; + +struct V +{ + float4 a; + float4 b; + float4 c; + float4 d; +}; + +struct main0_out +{ + float4 V_b [[user(locn1)]]; + float4 V_c [[user(locn2)]]; + float4 V_d [[user(locn3)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0() +{ + main0_out out = {}; + V _22 = {}; + out.gl_Position = float4(1.0); + _22.a = float4(2.0); + _22.b = float4(3.0); + out.V_b = _22.b; + out.V_c = _22.c; + out.V_d = _22.d; + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-1.for-tess.vert b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-1.for-tess.vert new file mode 100644 index 0000000000..25fd5f5089 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-1.for-tess.vert @@ -0,0 +1,35 @@ +#include +#include + +using namespace metal; + +struct V +{ + float4 a; + float4 b; + float4 c; + float4 d; +}; + +struct main0_out +{ + float4 V_a; + float4 V_c; + float4 V_d; + float4 gl_Position; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 spvStageInputSize [[grid_size]], device main0_out* spvOut [[buffer(28)]]) +{ + V _22 = {}; + device main0_out& out = spvOut[gl_GlobalInvocationID.y * spvStageInputSize.x + gl_GlobalInvocationID.x]; + if (any(gl_GlobalInvocationID >= spvStageInputSize)) + return; + out.gl_Position = float4(1.0); + _22.a = float4(2.0); + _22.b = float4(3.0); + out.V_a = _22.a; + out.V_c = _22.c; + out.V_d = _22.d; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-1.msl2.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-1.msl2.tesc new file mode 100644 index 0000000000..8af75f7bb2 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-1.msl2.tesc @@ -0,0 +1,41 @@ +#include +#include + +using namespace metal; + +struct P +{ + float a; + float b; +}; + +struct C +{ + float a; + float b; +}; + +struct main0_out +{ + float C_b; + float4 gl_Position; +}; + +struct main0_patchOut +{ + float P_a; + float P_b; +}; + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + threadgroup C c[4]; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + patchOut.P_a = 1.0; + patchOut.P_b = 2.0; + c[gl_InvocationID].a = 3.0; + gl_out[gl_InvocationID].C_b = 4.0; + gl_out[gl_InvocationID].gl_Position = float4(1.0); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-1.multi-patch.msl2.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-1.multi-patch.msl2.tesc new file mode 100644 index 0000000000..7b72ded6b8 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-1.multi-patch.msl2.tesc @@ -0,0 +1,44 @@ +#include +#include + +using namespace metal; + +struct P +{ + float a; + float b; +}; + +struct C +{ + float a; + float b; +}; + +struct main0_out +{ + float C_b; + float4 gl_Position; +}; + +struct main0_patchOut +{ + float P_a; + float P_b; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + threadgroup C spvStoragec[8][4]; + threadgroup C (&c)[4] = spvStoragec[(gl_GlobalInvocationID.x / 4) % 8]; + device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + patchOut.P_a = 1.0; + patchOut.P_b = 2.0; + c[gl_InvocationID].a = 3.0; + gl_out[gl_InvocationID].C_b = 4.0; + gl_out[gl_InvocationID].gl_Position = float4(1.0); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-1.vert b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-1.vert new file mode 100644 index 0000000000..1a4c18f05b --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs-block.mask-location-1.vert @@ -0,0 +1,34 @@ +#include +#include + +using namespace metal; + +struct V +{ + float4 a; + float4 b; + float4 c; + float4 d; +}; + +struct main0_out +{ + float4 V_a [[user(locn0)]]; + float4 V_c [[user(locn2)]]; + float4 V_d [[user(locn3)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0() +{ + main0_out out = {}; + V _22 = {}; + out.gl_Position = float4(1.0); + _22.a = float4(2.0); + _22.b = float4(3.0); + out.V_a = _22.a; + out.V_c = _22.c; + out.V_d = _22.d; + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-clip-distance.vert b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-clip-distance.vert new file mode 100644 index 0000000000..1f56f34a76 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-clip-distance.vert @@ -0,0 +1,67 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 v0 [[user(locn0)]]; + float4 v1 [[user(locn1)]]; + float4 gl_Position [[position]]; + float gl_PointSize [[point_size]]; +}; + +vertex main0_out main0() +{ + main0_out out = {}; + spvUnsafeArray gl_ClipDistance = {}; + out.v0 = float4(1.0); + out.v1 = float4(2.0); + out.gl_Position = float4(3.0); + out.gl_PointSize = 4.0; + gl_ClipDistance[0] = 1.0; + gl_ClipDistance[1] = 0.5; + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.for-tess.vert b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.for-tess.vert new file mode 100644 index 0000000000..1c0aab5037 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.for-tess.vert @@ -0,0 +1,68 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 v1; + float4 gl_Position; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 spvStageInputSize [[grid_size]], device main0_out* spvOut [[buffer(28)]]) +{ + float4 v0 = {}; + device main0_out& out = spvOut[gl_GlobalInvocationID.y * spvStageInputSize.x + gl_GlobalInvocationID.x]; + if (any(gl_GlobalInvocationID >= spvStageInputSize)) + return; + v0 = float4(1.0); + out.v1 = float4(2.0); + out.gl_Position = float4(3.0); + out.gl_PointSize = 4.0; + out.gl_ClipDistance[0] = 1.0; + out.gl_ClipDistance[1] = 0.5; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.msl2.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.msl2.tesc new file mode 100644 index 0000000000..7c8e387824 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.msl2.tesc @@ -0,0 +1,34 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 gl_Position; + float gl_PointSize; +}; + +struct main0_patchOut +{ + float4 v1; +}; + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + threadgroup float4 v0[4]; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + v0[gl_InvocationID] = float4(1.0); + v0[gl_InvocationID].x = 2.0; + if (gl_InvocationID == 0) + { + patchOut.v1 = float4(2.0); + ((device float*)&patchOut.v1)[3u] = 4.0; + } + gl_out[gl_InvocationID].gl_Position = float4(3.0); + gl_out[gl_InvocationID].gl_PointSize = 4.0; + gl_out[gl_InvocationID].gl_Position.z = 5.0; + gl_out[gl_InvocationID].gl_PointSize = 4.0; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.multi-patch.tesc new file mode 100644 index 0000000000..7a5e183a26 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.multi-patch.tesc @@ -0,0 +1,81 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 gl_Position; + float gl_PointSize; +}; + +struct main0_patchOut +{ + spvUnsafeArray v1; + float4 v3; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + threadgroup float4 spvStoragev0[8][4]; + threadgroup float4 (&v0)[4] = spvStoragev0[(gl_GlobalInvocationID.x / 4) % 8]; + device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + v0[gl_InvocationID] = float4(1.0); + v0[gl_InvocationID].z = 3.0; + if (gl_InvocationID == 0) + { + patchOut.v1[0] = float4(2.0); + ((device float*)&patchOut.v1[0])[0u] = 3.0; + patchOut.v1[1] = float4(2.0); + ((device float*)&patchOut.v1[1])[0u] = 5.0; + } + patchOut.v3 = float4(5.0); + gl_out[gl_InvocationID].gl_Position = float4(10.0); + gl_out[gl_InvocationID].gl_Position.z = 20.0; + gl_out[gl_InvocationID].gl_PointSize = 40.0; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.tesc new file mode 100644 index 0000000000..ef3ff9c221 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.tesc @@ -0,0 +1,78 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 gl_Position; + float gl_PointSize; +}; + +struct main0_patchOut +{ + spvUnsafeArray v1; + float4 v3; +}; + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + threadgroup float4 v0[4]; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + v0[gl_InvocationID] = float4(1.0); + v0[gl_InvocationID].z = 3.0; + if (gl_InvocationID == 0) + { + patchOut.v1[0] = float4(2.0); + ((device float*)&patchOut.v1[0])[0u] = 3.0; + patchOut.v1[1] = float4(2.0); + ((device float*)&patchOut.v1[1])[0u] = 5.0; + } + patchOut.v3 = float4(5.0); + gl_out[gl_InvocationID].gl_Position = float4(10.0); + gl_out[gl_InvocationID].gl_Position.z = 20.0; + gl_out[gl_InvocationID].gl_PointSize = 40.0; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.vert b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.vert new file mode 100644 index 0000000000..88c6bb6fac --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-0.vert @@ -0,0 +1,30 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 v1 [[user(locn1)]]; + float4 gl_Position [[position]]; + float gl_PointSize [[point_size]]; + float gl_ClipDistance [[clip_distance]] [2]; + float gl_ClipDistance_0 [[user(clip0)]]; + float gl_ClipDistance_1 [[user(clip1)]]; +}; + +vertex main0_out main0() +{ + main0_out out = {}; + float4 v0 = {}; + v0 = float4(1.0); + out.v1 = float4(2.0); + out.gl_Position = float4(3.0); + out.gl_PointSize = 4.0; + out.gl_ClipDistance[0] = 1.0; + out.gl_ClipDistance[1] = 0.5; + out.gl_ClipDistance_0 = out.gl_ClipDistance[0]; + out.gl_ClipDistance_1 = out.gl_ClipDistance[1]; + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-1.for-tess.vert b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-1.for-tess.vert new file mode 100644 index 0000000000..d558b7aed7 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-1.for-tess.vert @@ -0,0 +1,68 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 v0; + float4 gl_Position; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 spvStageInputSize [[grid_size]], device main0_out* spvOut [[buffer(28)]]) +{ + float4 v1 = {}; + device main0_out& out = spvOut[gl_GlobalInvocationID.y * spvStageInputSize.x + gl_GlobalInvocationID.x]; + if (any(gl_GlobalInvocationID >= spvStageInputSize)) + return; + out.v0 = float4(1.0); + v1 = float4(2.0); + out.gl_Position = float4(3.0); + out.gl_PointSize = 4.0; + out.gl_ClipDistance[0] = 1.0; + out.gl_ClipDistance[1] = 0.5; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-1.msl2.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-1.msl2.tesc new file mode 100644 index 0000000000..bb87ced750 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-1.msl2.tesc @@ -0,0 +1,33 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 v0; + float4 gl_Position; + float gl_PointSize; +}; + +struct main0_patchOut +{ +}; +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + threadgroup float4 v1; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + gl_out[gl_InvocationID].v0 = float4(1.0); + gl_out[gl_InvocationID].v0.x = 2.0; + if (gl_InvocationID == 0) + { + v1 = float4(2.0); + ((threadgroup float*)&v1)[3u] = 4.0; + } + gl_out[gl_InvocationID].gl_Position = float4(3.0); + gl_out[gl_InvocationID].gl_PointSize = 4.0; + gl_out[gl_InvocationID].gl_Position.z = 5.0; + gl_out[gl_InvocationID].gl_PointSize = 4.0; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-1.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-1.multi-patch.tesc new file mode 100644 index 0000000000..28ec0be0c6 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-1.multi-patch.tesc @@ -0,0 +1,40 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 v0; + float4 gl_Position; + float gl_PointSize; +}; + +struct main0_patchOut +{ + float4 v3; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; + threadgroup float4 spvStoragev1[8][2]; + threadgroup float4 (&v1)[2] = spvStoragev1[(gl_GlobalInvocationID.x / 4) % 8]; + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + gl_out[gl_InvocationID].v0 = float4(1.0); + gl_out[gl_InvocationID].v0.z = 3.0; + if (gl_InvocationID == 0) + { + v1[0] = float4(2.0); + ((threadgroup float*)&v1[0])[0u] = 3.0; + v1[1] = float4(2.0); + ((threadgroup float*)&v1[1])[0u] = 5.0; + } + patchOut.v3 = float4(5.0); + gl_out[gl_InvocationID].gl_Position = float4(10.0); + gl_out[gl_InvocationID].gl_Position.z = 20.0; + gl_out[gl_InvocationID].gl_PointSize = 40.0; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-1.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-1.tesc new file mode 100644 index 0000000000..1673d52329 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-1.tesc @@ -0,0 +1,37 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 v0; + float4 gl_Position; + float gl_PointSize; +}; + +struct main0_patchOut +{ + float4 v3; +}; + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + threadgroup float4 v1[2]; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + gl_out[gl_InvocationID].v0 = float4(1.0); + gl_out[gl_InvocationID].v0.z = 3.0; + if (gl_InvocationID == 0) + { + v1[0] = float4(2.0); + ((threadgroup float*)&v1[0])[0u] = 3.0; + v1[1] = float4(2.0); + ((threadgroup float*)&v1[1])[0u] = 5.0; + } + patchOut.v3 = float4(5.0); + gl_out[gl_InvocationID].gl_Position = float4(10.0); + gl_out[gl_InvocationID].gl_Position.z = 20.0; + gl_out[gl_InvocationID].gl_PointSize = 40.0; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-1.vert b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-1.vert new file mode 100644 index 0000000000..cc7d41794d --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-location-1.vert @@ -0,0 +1,30 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 v0 [[user(locn0)]]; + float4 gl_Position [[position]]; + float gl_PointSize [[point_size]]; + float gl_ClipDistance [[clip_distance]] [2]; + float gl_ClipDistance_0 [[user(clip0)]]; + float gl_ClipDistance_1 [[user(clip1)]]; +}; + +vertex main0_out main0() +{ + main0_out out = {}; + float4 v1 = {}; + out.v0 = float4(1.0); + v1 = float4(2.0); + out.gl_Position = float4(3.0); + out.gl_PointSize = 4.0; + out.gl_ClipDistance[0] = 1.0; + out.gl_ClipDistance[1] = 0.5; + out.gl_ClipDistance_0 = out.gl_ClipDistance[0]; + out.gl_ClipDistance_1 = out.gl_ClipDistance[1]; + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-point-size.for-tess.vert b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-point-size.for-tess.vert new file mode 100644 index 0000000000..463ecc87b5 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-point-size.for-tess.vert @@ -0,0 +1,68 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 v0; + float4 v1; + float4 gl_Position; + spvUnsafeArray gl_ClipDistance; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 spvStageInputSize [[grid_size]], device main0_out* spvOut [[buffer(28)]]) +{ + float gl_PointSize = {}; + device main0_out& out = spvOut[gl_GlobalInvocationID.y * spvStageInputSize.x + gl_GlobalInvocationID.x]; + if (any(gl_GlobalInvocationID >= spvStageInputSize)) + return; + out.v0 = float4(1.0); + out.v1 = float4(2.0); + out.gl_Position = float4(3.0); + gl_PointSize = 4.0; + out.gl_ClipDistance[0] = 1.0; + out.gl_ClipDistance[1] = 0.5; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-point-size.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-point-size.multi-patch.tesc new file mode 100644 index 0000000000..694cdbb7ff --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-point-size.multi-patch.tesc @@ -0,0 +1,89 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct gl_PerVertex +{ + float4 gl_Position; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +struct main0_out +{ + float4 v0; + float4 gl_Position; +}; + +struct main0_patchOut +{ + spvUnsafeArray v1; + float4 v3; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + threadgroup gl_PerVertex spvStoragegl_out_masked[8][4]; + threadgroup gl_PerVertex (&gl_out_masked)[4] = spvStoragegl_out_masked[(gl_GlobalInvocationID.x / 4) % 8]; + device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + gl_out[gl_InvocationID].v0 = float4(1.0); + gl_out[gl_InvocationID].v0.z = 3.0; + if (gl_InvocationID == 0) + { + patchOut.v1[0] = float4(2.0); + ((device float*)&patchOut.v1[0])[0u] = 3.0; + patchOut.v1[1] = float4(2.0); + ((device float*)&patchOut.v1[1])[0u] = 5.0; + } + patchOut.v3 = float4(5.0); + gl_out[gl_InvocationID].gl_Position = float4(10.0); + gl_out[gl_InvocationID].gl_Position.z = 20.0; + gl_out_masked[gl_InvocationID].gl_PointSize = 40.0; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-point-size.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-point-size.tesc new file mode 100644 index 0000000000..da976c9a8a --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-point-size.tesc @@ -0,0 +1,86 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct gl_PerVertex +{ + float4 gl_Position; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +struct main0_out +{ + float4 v0; + float4 gl_Position; +}; + +struct main0_patchOut +{ + spvUnsafeArray v1; + float4 v3; +}; + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + threadgroup gl_PerVertex gl_out_masked[4]; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + gl_out[gl_InvocationID].v0 = float4(1.0); + gl_out[gl_InvocationID].v0.z = 3.0; + if (gl_InvocationID == 0) + { + patchOut.v1[0] = float4(2.0); + ((device float*)&patchOut.v1[0])[0u] = 3.0; + patchOut.v1[1] = float4(2.0); + ((device float*)&patchOut.v1[1])[0u] = 5.0; + } + patchOut.v3 = float4(5.0); + gl_out[gl_InvocationID].gl_Position = float4(10.0); + gl_out[gl_InvocationID].gl_Position.z = 20.0; + gl_out_masked[gl_InvocationID].gl_PointSize = 40.0; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-point-size.vert b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-point-size.vert new file mode 100644 index 0000000000..ffdfdaaff4 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-point-size.vert @@ -0,0 +1,30 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 v0 [[user(locn0)]]; + float4 v1 [[user(locn1)]]; + float4 gl_Position [[position]]; + float gl_ClipDistance [[clip_distance]] [2]; + float gl_ClipDistance_0 [[user(clip0)]]; + float gl_ClipDistance_1 [[user(clip1)]]; +}; + +vertex main0_out main0() +{ + main0_out out = {}; + float gl_PointSize = {}; + out.v0 = float4(1.0); + out.v1 = float4(2.0); + out.gl_Position = float4(3.0); + gl_PointSize = 4.0; + out.gl_ClipDistance[0] = 1.0; + out.gl_ClipDistance[1] = 0.5; + out.gl_ClipDistance_0 = out.gl_ClipDistance[0]; + out.gl_ClipDistance_1 = out.gl_ClipDistance[1]; + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-position.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-position.multi-patch.tesc new file mode 100644 index 0000000000..c55e337682 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-position.multi-patch.tesc @@ -0,0 +1,89 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct gl_PerVertex +{ + float4 gl_Position; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +struct main0_out +{ + float4 v0; + float gl_PointSize; +}; + +struct main0_patchOut +{ + spvUnsafeArray v1; + float4 v3; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + threadgroup gl_PerVertex spvStoragegl_out_masked[8][4]; + threadgroup gl_PerVertex (&gl_out_masked)[4] = spvStoragegl_out_masked[(gl_GlobalInvocationID.x / 4) % 8]; + device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + gl_out[gl_InvocationID].v0 = float4(1.0); + gl_out[gl_InvocationID].v0.z = 3.0; + if (gl_InvocationID == 0) + { + patchOut.v1[0] = float4(2.0); + ((device float*)&patchOut.v1[0])[0u] = 3.0; + patchOut.v1[1] = float4(2.0); + ((device float*)&patchOut.v1[1])[0u] = 5.0; + } + patchOut.v3 = float4(5.0); + gl_out_masked[gl_InvocationID].gl_Position = float4(10.0); + gl_out_masked[gl_InvocationID].gl_Position.z = 20.0; + gl_out[gl_InvocationID].gl_PointSize = 40.0; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-position.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-position.tesc new file mode 100644 index 0000000000..04584de49f --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/masking/write-outputs.mask-position.tesc @@ -0,0 +1,86 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct gl_PerVertex +{ + float4 gl_Position; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +struct main0_out +{ + float4 v0; + float gl_PointSize; +}; + +struct main0_patchOut +{ + spvUnsafeArray v1; + float4 v3; +}; + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + threadgroup gl_PerVertex gl_out_masked[4]; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + gl_out[gl_InvocationID].v0 = float4(1.0); + gl_out[gl_InvocationID].v0.z = 3.0; + if (gl_InvocationID == 0) + { + patchOut.v1[0] = float4(2.0); + ((device float*)&patchOut.v1[0])[0u] = 3.0; + patchOut.v1[1] = float4(2.0); + ((device float*)&patchOut.v1[1])[0u] = 5.0; + } + patchOut.v3 = float4(5.0); + gl_out_masked[gl_InvocationID].gl_Position = float4(10.0); + gl_out_masked[gl_InvocationID].gl_Position.z = 20.0; + gl_out[gl_InvocationID].gl_PointSize = 40.0; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/basic.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/basic.multi-patch.tesc index b1403a3fe8..fe26831673 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/basic.multi-patch.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/basic.multi-patch.tesc @@ -11,7 +11,7 @@ struct main0_patchOut kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 1]; - uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 1, spvIndirectParams[1]); + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 1, spvIndirectParams[1] - 1); spvTessLevel[gl_PrimitiveID].insideTessellationFactor[0] = half(8.8999996185302734375); spvTessLevel[gl_PrimitiveID].insideTessellationFactor[1] = half(6.900000095367431640625); spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(8.8999996185302734375); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/complex-control-point-inout-types.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/complex-control-point-inout-types.multi-patch.tesc new file mode 100644 index 0000000000..d3b4738d5e --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/complex-control-point-inout-types.multi-patch.tesc @@ -0,0 +1,128 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct Meep +{ + float a; + float b; +}; + +struct Block +{ + spvUnsafeArray a; + float b; + float2x2 m; + Meep meep; + spvUnsafeArray meeps; +}; + +struct Block_1 +{ + spvUnsafeArray a; + float b; + float2x2 m; + Meep meep; + spvUnsafeArray meeps; +}; + +struct main0_out +{ + spvUnsafeArray a; + float b; + float2x2 m; + Meep meep; + spvUnsafeArray meeps; + spvUnsafeArray Block_a; + float Block_b; + float2x2 Block_m; + Meep Block_meep; + spvUnsafeArray Block_meeps; + float4 gl_Position; +}; + +struct main0_in +{ + spvUnsafeArray in_a; + float in_b; + float2x2 in_m; + Meep in_meep; + spvUnsafeArray in_meeps; + spvUnsafeArray Block_a; + float Block_b; + float2x2 Block_m; + Meep Block_meep; + spvUnsafeArray Block_meeps; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]]) +{ + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + gl_out[gl_InvocationID].gl_Position = float4(1.0); + gl_out[gl_InvocationID].a[0] = gl_in[gl_InvocationID].in_a[0]; + gl_out[gl_InvocationID].a[1] = gl_in[gl_InvocationID].in_a[1]; + gl_out[gl_InvocationID].b = gl_in[gl_InvocationID].in_b; + gl_out[gl_InvocationID].m = gl_in[gl_InvocationID].in_m; + gl_out[gl_InvocationID].meep.a = gl_in[gl_InvocationID].in_meep.a; + gl_out[gl_InvocationID].meep.b = gl_in[gl_InvocationID].in_meep.b; + gl_out[gl_InvocationID].meeps[0].a = gl_in[gl_InvocationID].in_meeps[0].a; + gl_out[gl_InvocationID].meeps[0].b = gl_in[gl_InvocationID].in_meeps[0].b; + gl_out[gl_InvocationID].meeps[1].a = gl_in[gl_InvocationID].in_meeps[1].a; + gl_out[gl_InvocationID].meeps[1].b = gl_in[gl_InvocationID].in_meeps[1].b; + gl_out[gl_InvocationID].Block_a[0] = gl_in[gl_InvocationID].Block_a[0]; + gl_out[gl_InvocationID].Block_a[1] = gl_in[gl_InvocationID].Block_a[1]; + gl_out[gl_InvocationID].Block_b = gl_in[gl_InvocationID].Block_b; + gl_out[gl_InvocationID].Block_m = gl_in[gl_InvocationID].Block_m; + gl_out[gl_InvocationID].Block_meep.a = gl_in[gl_InvocationID].Block_meep.a; + gl_out[gl_InvocationID].Block_meep.b = gl_in[gl_InvocationID].Block_meep.b; + gl_out[gl_InvocationID].Block_meeps[0].a = gl_in[gl_InvocationID].Block_meeps[0].a; + gl_out[gl_InvocationID].Block_meeps[0].b = gl_in[gl_InvocationID].Block_meeps[0].b; + gl_out[gl_InvocationID].Block_meeps[1].a = gl_in[gl_InvocationID].Block_meeps[1].a; + gl_out[gl_InvocationID].Block_meeps[1].b = gl_in[gl_InvocationID].Block_meeps[1].b; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/complex-control-point-inout-types.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/complex-control-point-inout-types.tesc new file mode 100644 index 0000000000..5fabb4539f --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/complex-control-point-inout-types.tesc @@ -0,0 +1,132 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct Meep +{ + float a; + float b; +}; + +struct Block +{ + spvUnsafeArray a; + float b; + float2x2 m; + Meep meep; + spvUnsafeArray meeps; +}; + +struct Block_1 +{ + spvUnsafeArray a; + float b; + float2x2 m; +}; + +struct main0_out +{ + spvUnsafeArray a; + float b; + float2x2 m; + Meep meep; + spvUnsafeArray meeps; + spvUnsafeArray Block_a; + float Block_b; + float2x2 Block_m; + Meep Block_meep; + spvUnsafeArray Block_meeps; + float4 gl_Position; +}; + +struct main0_in +{ + float in_a_0 [[attribute(0)]]; + float in_a_1 [[attribute(1)]]; + float in_b [[attribute(2)]]; + float2 in_m_0 [[attribute(3)]]; + float2 in_m_1 [[attribute(4)]]; + float Meep_a [[attribute(5)]]; + float Meep_b [[attribute(6)]]; + float Block_a_0 [[attribute(11)]]; + float Block_a_1 [[attribute(12)]]; + float Block_b [[attribute(13)]]; + float2 Block_m_0 [[attribute(14)]]; + float2 Block_m_1 [[attribute(15)]]; +}; + +kernel void main0(main0_in in [[stage_in]], uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], threadgroup main0_in* gl_in [[threadgroup(0)]]) +{ + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + if (gl_InvocationID < spvIndirectParams[0]) + gl_in[gl_InvocationID] = in; + threadgroup_barrier(mem_flags::mem_threadgroup); + if (gl_InvocationID >= 4) + return; + gl_out[gl_InvocationID].gl_Position = float4(1.0); + gl_out[gl_InvocationID].a[0] = gl_in[gl_InvocationID].in_a_0; + gl_out[gl_InvocationID].a[1] = gl_in[gl_InvocationID].in_a_1; + gl_out[gl_InvocationID].b = gl_in[gl_InvocationID].in_b; + float2x2 _178 = float2x2(gl_in[gl_InvocationID].in_m_0, gl_in[gl_InvocationID].in_m_1); + gl_out[gl_InvocationID].m = _178; + gl_out[gl_InvocationID].meep.a = gl_in[gl_InvocationID].Meep_a; + gl_out[gl_InvocationID].meep.b = gl_in[gl_InvocationID].Meep_b; + gl_out[gl_InvocationID].meeps[0].a = 1.0; + gl_out[gl_InvocationID].meeps[0].b = 2.0; + gl_out[gl_InvocationID].meeps[1].a = 3.0; + gl_out[gl_InvocationID].meeps[1].b = 4.0; + gl_out[gl_InvocationID].Block_a[0] = gl_in[gl_InvocationID].Block_a_0; + gl_out[gl_InvocationID].Block_a[1] = gl_in[gl_InvocationID].Block_a_1; + gl_out[gl_InvocationID].Block_b = gl_in[gl_InvocationID].Block_b; + float2x2 _216 = float2x2(gl_in[gl_InvocationID].Block_m_0, gl_in[gl_InvocationID].Block_m_1); + gl_out[gl_InvocationID].Block_m = _216; + gl_out[gl_InvocationID].Block_meep.a = 10.0; + gl_out[gl_InvocationID].Block_meep.b = 20.0; + gl_out[gl_InvocationID].Block_meeps[0].a = 5.0; + gl_out[gl_InvocationID].Block_meeps[0].b = 6.0; + gl_out[gl_InvocationID].Block_meeps[1].a = 7.0; + gl_out[gl_InvocationID].Block_meeps[1].b = 8.0; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/complex-patch-out-types.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/complex-patch-out-types.tesc new file mode 100644 index 0000000000..d4a59bb772 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/complex-patch-out-types.tesc @@ -0,0 +1,107 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct Meep +{ + float a; + float b; +}; + +struct Block +{ + spvUnsafeArray a; + float b; + float2x2 m; + Meep meep; + spvUnsafeArray meeps; +}; + +struct main0_out +{ + float4 gl_Position; +}; + +struct main0_patchOut +{ + spvUnsafeArray a; + float b; + float2x2 m; + Meep meep; + spvUnsafeArray meeps; + spvUnsafeArray Block_a; + float Block_b; + float2x2 Block_m; + Meep Block_meep; + spvUnsafeArray Block_meeps; +}; + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + gl_out[gl_InvocationID].gl_Position = float4(1.0); + patchOut.a[0] = 1.0; + patchOut.a[1] = 2.0; + patchOut.b = 3.0; + patchOut.m = float2x2(float2(2.0, 0.0), float2(0.0, 2.0)); + patchOut.meep.a = 4.0; + patchOut.meep.b = 5.0; + patchOut.meeps[0].a = 6.0; + patchOut.meeps[0].b = 7.0; + patchOut.meeps[1].a = 8.0; + patchOut.meeps[1].b = 9.0; + patchOut.Block_a[0] = 1.0; + patchOut.Block_a[1] = 2.0; + patchOut.Block_b = 3.0; + patchOut.Block_m = float2x2(float2(4.0, 0.0), float2(0.0, 4.0)); + patchOut.Block_meep.a = 4.0; + patchOut.Block_meep.b = 5.0; + patchOut.Block_meeps[0].a = 6.0; + patchOut.Block_meeps[0].b = 7.0; + patchOut.Block_meeps[1].a = 8.0; + patchOut.Block_meeps[1].b = 9.0; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/load-control-point-array-of-matrix.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/load-control-point-array-of-matrix.multi-patch.tesc index 4f4cf0b012..28effad215 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/load-control-point-array-of-matrix.multi-patch.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/load-control-point-array-of-matrix.multi-patch.tesc @@ -59,7 +59,7 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; - uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1]); + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); spvUnsafeArray _16 = spvUnsafeArray({ gl_in[0].vInputs, gl_in[1].vInputs, gl_in[2].vInputs, gl_in[3].vInputs, gl_in[4].vInputs, gl_in[5].vInputs, gl_in[6].vInputs, gl_in[7].vInputs, gl_in[8].vInputs, gl_in[9].vInputs, gl_in[10].vInputs, gl_in[11].vInputs, gl_in[12].vInputs, gl_in[13].vInputs, gl_in[14].vInputs, gl_in[15].vInputs, gl_in[16].vInputs, gl_in[17].vInputs, gl_in[18].vInputs, gl_in[19].vInputs, gl_in[20].vInputs, gl_in[21].vInputs, gl_in[22].vInputs, gl_in[23].vInputs, gl_in[24].vInputs, gl_in[25].vInputs, gl_in[26].vInputs, gl_in[27].vInputs, gl_in[28].vInputs, gl_in[29].vInputs, gl_in[30].vInputs, gl_in[31].vInputs }); spvUnsafeArray tmp; tmp = _16; diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/load-control-point-array-of-struct.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/load-control-point-array-of-struct.multi-patch.tesc index 8bd5515b2c..e6bd83e809 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/load-control-point-array-of-struct.multi-patch.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/load-control-point-array-of-struct.multi-patch.tesc @@ -58,9 +58,7 @@ struct main0_out struct main0_in { - float4x4 VertexData_a; - spvUnsafeArray VertexData_b; - float4 VertexData_c; + VertexData vInputs; }; kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]]) @@ -68,11 +66,11 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; - uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1]); - spvUnsafeArray _19 = spvUnsafeArray({ VertexData{ gl_in[0].VertexData_a, spvUnsafeArray({ gl_in[0].VertexData_b[0], gl_in[0].VertexData_b[1] }), gl_in[0].VertexData_c }, VertexData{ gl_in[1].VertexData_a, spvUnsafeArray({ gl_in[1].VertexData_b[0], gl_in[1].VertexData_b[1] }), gl_in[1].VertexData_c }, VertexData{ gl_in[2].VertexData_a, spvUnsafeArray({ gl_in[2].VertexData_b[0], gl_in[2].VertexData_b[1] }), gl_in[2].VertexData_c }, VertexData{ gl_in[3].VertexData_a, spvUnsafeArray({ gl_in[3].VertexData_b[0], gl_in[3].VertexData_b[1] }), gl_in[3].VertexData_c }, VertexData{ gl_in[4].VertexData_a, spvUnsafeArray({ gl_in[4].VertexData_b[0], gl_in[4].VertexData_b[1] }), gl_in[4].VertexData_c }, VertexData{ gl_in[5].VertexData_a, spvUnsafeArray({ gl_in[5].VertexData_b[0], gl_in[5].VertexData_b[1] }), gl_in[5].VertexData_c }, VertexData{ gl_in[6].VertexData_a, spvUnsafeArray({ gl_in[6].VertexData_b[0], gl_in[6].VertexData_b[1] }), gl_in[6].VertexData_c }, VertexData{ gl_in[7].VertexData_a, spvUnsafeArray({ gl_in[7].VertexData_b[0], gl_in[7].VertexData_b[1] }), gl_in[7].VertexData_c }, VertexData{ gl_in[8].VertexData_a, spvUnsafeArray({ gl_in[8].VertexData_b[0], gl_in[8].VertexData_b[1] }), gl_in[8].VertexData_c }, VertexData{ gl_in[9].VertexData_a, spvUnsafeArray({ gl_in[9].VertexData_b[0], gl_in[9].VertexData_b[1] }), gl_in[9].VertexData_c }, VertexData{ gl_in[10].VertexData_a, spvUnsafeArray({ gl_in[10].VertexData_b[0], gl_in[10].VertexData_b[1] }), gl_in[10].VertexData_c }, VertexData{ gl_in[11].VertexData_a, spvUnsafeArray({ gl_in[11].VertexData_b[0], gl_in[11].VertexData_b[1] }), gl_in[11].VertexData_c }, VertexData{ gl_in[12].VertexData_a, spvUnsafeArray({ gl_in[12].VertexData_b[0], gl_in[12].VertexData_b[1] }), gl_in[12].VertexData_c }, VertexData{ gl_in[13].VertexData_a, spvUnsafeArray({ gl_in[13].VertexData_b[0], gl_in[13].VertexData_b[1] }), gl_in[13].VertexData_c }, VertexData{ gl_in[14].VertexData_a, spvUnsafeArray({ gl_in[14].VertexData_b[0], gl_in[14].VertexData_b[1] }), gl_in[14].VertexData_c }, VertexData{ gl_in[15].VertexData_a, spvUnsafeArray({ gl_in[15].VertexData_b[0], gl_in[15].VertexData_b[1] }), gl_in[15].VertexData_c }, VertexData{ gl_in[16].VertexData_a, spvUnsafeArray({ gl_in[16].VertexData_b[0], gl_in[16].VertexData_b[1] }), gl_in[16].VertexData_c }, VertexData{ gl_in[17].VertexData_a, spvUnsafeArray({ gl_in[17].VertexData_b[0], gl_in[17].VertexData_b[1] }), gl_in[17].VertexData_c }, VertexData{ gl_in[18].VertexData_a, spvUnsafeArray({ gl_in[18].VertexData_b[0], gl_in[18].VertexData_b[1] }), gl_in[18].VertexData_c }, VertexData{ gl_in[19].VertexData_a, spvUnsafeArray({ gl_in[19].VertexData_b[0], gl_in[19].VertexData_b[1] }), gl_in[19].VertexData_c }, VertexData{ gl_in[20].VertexData_a, spvUnsafeArray({ gl_in[20].VertexData_b[0], gl_in[20].VertexData_b[1] }), gl_in[20].VertexData_c }, VertexData{ gl_in[21].VertexData_a, spvUnsafeArray({ gl_in[21].VertexData_b[0], gl_in[21].VertexData_b[1] }), gl_in[21].VertexData_c }, VertexData{ gl_in[22].VertexData_a, spvUnsafeArray({ gl_in[22].VertexData_b[0], gl_in[22].VertexData_b[1] }), gl_in[22].VertexData_c }, VertexData{ gl_in[23].VertexData_a, spvUnsafeArray({ gl_in[23].VertexData_b[0], gl_in[23].VertexData_b[1] }), gl_in[23].VertexData_c }, VertexData{ gl_in[24].VertexData_a, spvUnsafeArray({ gl_in[24].VertexData_b[0], gl_in[24].VertexData_b[1] }), gl_in[24].VertexData_c }, VertexData{ gl_in[25].VertexData_a, spvUnsafeArray({ gl_in[25].VertexData_b[0], gl_in[25].VertexData_b[1] }), gl_in[25].VertexData_c }, VertexData{ gl_in[26].VertexData_a, spvUnsafeArray({ gl_in[26].VertexData_b[0], gl_in[26].VertexData_b[1] }), gl_in[26].VertexData_c }, VertexData{ gl_in[27].VertexData_a, spvUnsafeArray({ gl_in[27].VertexData_b[0], gl_in[27].VertexData_b[1] }), gl_in[27].VertexData_c }, VertexData{ gl_in[28].VertexData_a, spvUnsafeArray({ gl_in[28].VertexData_b[0], gl_in[28].VertexData_b[1] }), gl_in[28].VertexData_c }, VertexData{ gl_in[29].VertexData_a, spvUnsafeArray({ gl_in[29].VertexData_b[0], gl_in[29].VertexData_b[1] }), gl_in[29].VertexData_c }, VertexData{ gl_in[30].VertexData_a, spvUnsafeArray({ gl_in[30].VertexData_b[0], gl_in[30].VertexData_b[1] }), gl_in[30].VertexData_c }, VertexData{ gl_in[31].VertexData_a, spvUnsafeArray({ gl_in[31].VertexData_b[0], gl_in[31].VertexData_b[1] }), gl_in[31].VertexData_c } }); + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + spvUnsafeArray _19 = spvUnsafeArray({ gl_in[0].vInputs, gl_in[1].vInputs, gl_in[2].vInputs, gl_in[3].vInputs, gl_in[4].vInputs, gl_in[5].vInputs, gl_in[6].vInputs, gl_in[7].vInputs, gl_in[8].vInputs, gl_in[9].vInputs, gl_in[10].vInputs, gl_in[11].vInputs, gl_in[12].vInputs, gl_in[13].vInputs, gl_in[14].vInputs, gl_in[15].vInputs, gl_in[16].vInputs, gl_in[17].vInputs, gl_in[18].vInputs, gl_in[19].vInputs, gl_in[20].vInputs, gl_in[21].vInputs, gl_in[22].vInputs, gl_in[23].vInputs, gl_in[24].vInputs, gl_in[25].vInputs, gl_in[26].vInputs, gl_in[27].vInputs, gl_in[28].vInputs, gl_in[29].vInputs, gl_in[30].vInputs, gl_in[31].vInputs }); spvUnsafeArray tmp; tmp = _19; int _27 = gl_InvocationID ^ 1; - gl_out[gl_InvocationID].vOutputs = ((tmp[gl_InvocationID].a[1] + tmp[gl_InvocationID].b[1]) + tmp[gl_InvocationID].c) + gl_in[_27].VertexData_c; + gl_out[gl_InvocationID].vOutputs = ((tmp[gl_InvocationID].a[1] + tmp[gl_InvocationID].b[1]) + tmp[gl_InvocationID].c) + gl_in[_27].vInputs.c; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/load-control-point-array.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/load-control-point-array.multi-patch.tesc index 416bc68172..45baadb6f2 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/load-control-point-array.multi-patch.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/load-control-point-array.multi-patch.tesc @@ -60,7 +60,7 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; - uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1]); + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); spvUnsafeArray _15 = spvUnsafeArray({ gl_in[0].vInputs, gl_in[1].vInputs, gl_in[2].vInputs, gl_in[3].vInputs, gl_in[4].vInputs, gl_in[5].vInputs, gl_in[6].vInputs, gl_in[7].vInputs, gl_in[8].vInputs, gl_in[9].vInputs, gl_in[10].vInputs, gl_in[11].vInputs, gl_in[12].vInputs, gl_in[13].vInputs, gl_in[14].vInputs, gl_in[15].vInputs, gl_in[16].vInputs, gl_in[17].vInputs, gl_in[18].vInputs, gl_in[19].vInputs, gl_in[20].vInputs, gl_in[21].vInputs, gl_in[22].vInputs, gl_in[23].vInputs, gl_in[24].vInputs, gl_in[25].vInputs, gl_in[26].vInputs, gl_in[27].vInputs, gl_in[28].vInputs, gl_in[29].vInputs, gl_in[30].vInputs, gl_in[31].vInputs }); spvUnsafeArray tmp; tmp = _15; diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/matrix-output.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/matrix-output.multi-patch.tesc index b3b06d18b0..28fff01555 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/matrix-output.multi-patch.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/matrix-output.multi-patch.tesc @@ -21,7 +21,7 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 3]; device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 3, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; uint gl_InvocationID = gl_GlobalInvocationID.x % 3; - uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 3, spvIndirectParams[1]); + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 3, spvIndirectParams[1] - 1); float _15 = float(gl_InvocationID); float3 _18 = float3(_15, 0.0, 0.0); float3 _19 = float3(0.0, _15, 0.0); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/reload-tess-level.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/reload-tess-level.multi-patch.tesc index a55755e028..ae33de517a 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/reload-tess-level.multi-patch.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/reload-tess-level.multi-patch.tesc @@ -20,7 +20,7 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; - uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1]); + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); if (gl_InvocationID == 0) { spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(2.0); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/struct-output.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/struct-output.multi-patch.tesc index eb59973c9f..6c52654615 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/struct-output.multi-patch.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/struct-output.multi-patch.tesc @@ -28,7 +28,7 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 3]; device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 3, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; uint gl_InvocationID = gl_GlobalInvocationID.x % 3; - uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 3, spvIndirectParams[1]); + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 3, spvIndirectParams[1] - 1); float _15 = float(gl_InvocationID); int _18 = gl_InvocationID + 1; float _19 = float(_18); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/water_tess.multi-patch.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/water_tess.multi-patch.tesc index 6264a8ef1a..99e094c95a 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/water_tess.multi-patch.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/water_tess.multi-patch.tesc @@ -29,7 +29,7 @@ kernel void main0(constant UBO& _41 [[buffer(0)]], uint3 gl_GlobalInvocationID [ { device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 1]; device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 1, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; - uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 1, spvIndirectParams[1]); + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 1, spvIndirectParams[1] - 1); float2 _431 = (gl_in[0].vPatchPosBase.xy - float2(10.0)) * _41.uScale.xy; float2 _441 = ((gl_in[0].vPatchPosBase.xy + _41.uPatchSize) + float2(10.0)) * _41.uScale.xy; float3 _446 = float3(_431.x, -10.0, _431.y); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tese/quad.domain.tese b/third_party/spirv-cross/reference/opt/shaders-msl/tese/quad.domain.tese index 78b58ab997..9dadebc4e4 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/tese/quad.domain.tese +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tese/quad.domain.tese @@ -1,8 +1,49 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct main0_out { float4 gl_Position [[position]]; @@ -10,15 +51,23 @@ struct main0_out struct main0_patchIn { - float2 gl_TessLevelInner [[attribute(0)]]; - float4 gl_TessLevelOuter [[attribute(1)]]; + float4 gl_TessLevelOuter [[attribute(0)]]; + float2 gl_TessLevelInner [[attribute(1)]]; }; [[ patch(quad, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]], float2 gl_TessCoord [[position_in_patch]]) { main0_out out = {}; + spvUnsafeArray gl_TessLevelInner = {}; + spvUnsafeArray gl_TessLevelOuter = {}; + gl_TessLevelInner[0] = patchIn.gl_TessLevelInner.x; + gl_TessLevelInner[1] = patchIn.gl_TessLevelInner.y; + gl_TessLevelOuter[0] = patchIn.gl_TessLevelOuter.x; + gl_TessLevelOuter[1] = patchIn.gl_TessLevelOuter.y; + gl_TessLevelOuter[2] = patchIn.gl_TessLevelOuter.z; + gl_TessLevelOuter[3] = patchIn.gl_TessLevelOuter.w; gl_TessCoord.y = 1.0 - gl_TessCoord.y; - out.gl_Position = float4(((gl_TessCoord.x * patchIn.gl_TessLevelInner.x) * patchIn.gl_TessLevelOuter.x) + (((1.0 - gl_TessCoord.x) * patchIn.gl_TessLevelInner.x) * patchIn.gl_TessLevelOuter.z), ((gl_TessCoord.y * patchIn.gl_TessLevelInner.y) * patchIn.gl_TessLevelOuter.w) + (((1.0 - gl_TessCoord.y) * patchIn.gl_TessLevelInner.y) * patchIn.gl_TessLevelOuter.y), 0.0, 1.0); + out.gl_Position = float4(((gl_TessCoord.x * gl_TessLevelInner[0]) * gl_TessLevelOuter[0]) + (((1.0 - gl_TessCoord.x) * gl_TessLevelInner[0]) * gl_TessLevelOuter[2]), ((gl_TessCoord.y * gl_TessLevelInner[1]) * gl_TessLevelOuter[3]) + (((1.0 - gl_TessCoord.y) * gl_TessLevelInner[1]) * gl_TessLevelOuter[1]), 0.0, 1.0); return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tese/quad.tese b/third_party/spirv-cross/reference/opt/shaders-msl/tese/quad.tese index 83ef729321..99803754d8 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/tese/quad.tese +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tese/quad.tese @@ -1,8 +1,49 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct main0_out { float4 gl_Position [[position]]; @@ -10,14 +51,22 @@ struct main0_out struct main0_patchIn { - float2 gl_TessLevelInner [[attribute(0)]]; - float4 gl_TessLevelOuter [[attribute(1)]]; + float4 gl_TessLevelOuter [[attribute(0)]]; + float2 gl_TessLevelInner [[attribute(1)]]; }; [[ patch(quad, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]], float2 gl_TessCoord [[position_in_patch]]) { main0_out out = {}; - out.gl_Position = float4(((gl_TessCoord.x * patchIn.gl_TessLevelInner.x) * patchIn.gl_TessLevelOuter.x) + (((1.0 - gl_TessCoord.x) * patchIn.gl_TessLevelInner.x) * patchIn.gl_TessLevelOuter.z), ((gl_TessCoord.y * patchIn.gl_TessLevelInner.y) * patchIn.gl_TessLevelOuter.y) + (((1.0 - gl_TessCoord.y) * patchIn.gl_TessLevelInner.y) * patchIn.gl_TessLevelOuter.w), 0.0, 1.0); + spvUnsafeArray gl_TessLevelInner = {}; + spvUnsafeArray gl_TessLevelOuter = {}; + gl_TessLevelInner[0] = patchIn.gl_TessLevelInner.x; + gl_TessLevelInner[1] = patchIn.gl_TessLevelInner.y; + gl_TessLevelOuter[0] = patchIn.gl_TessLevelOuter.x; + gl_TessLevelOuter[1] = patchIn.gl_TessLevelOuter.y; + gl_TessLevelOuter[2] = patchIn.gl_TessLevelOuter.z; + gl_TessLevelOuter[3] = patchIn.gl_TessLevelOuter.w; + out.gl_Position = float4(((gl_TessCoord.x * gl_TessLevelInner[0]) * gl_TessLevelOuter[0]) + (((1.0 - gl_TessCoord.x) * gl_TessLevelInner[0]) * gl_TessLevelOuter[2]), ((gl_TessCoord.y * gl_TessLevelInner[1]) * gl_TessLevelOuter[1]) + (((1.0 - gl_TessCoord.y) * gl_TessLevelInner[1]) * gl_TessLevelOuter[3]), 0.0, 1.0); return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tese/read-tess-level-in-func-quad.msl2.tese b/third_party/spirv-cross/reference/opt/shaders-msl/tese/read-tess-level-in-func-quad.msl2.tese new file mode 100644 index 0000000000..251cb2fa43 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tese/read-tess-level-in-func-quad.msl2.tese @@ -0,0 +1,72 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +struct main0_patchIn +{ + float4 gl_TessLevelOuter [[attribute(0)]]; + float2 gl_TessLevelInner [[attribute(1)]]; +}; + +[[ patch(quad, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]]) +{ + main0_out out = {}; + spvUnsafeArray gl_TessLevelOuter = {}; + spvUnsafeArray gl_TessLevelInner = {}; + gl_TessLevelOuter[0] = patchIn.gl_TessLevelOuter.x; + gl_TessLevelOuter[1] = patchIn.gl_TessLevelOuter.y; + gl_TessLevelOuter[2] = patchIn.gl_TessLevelOuter.z; + gl_TessLevelOuter[3] = patchIn.gl_TessLevelOuter.w; + gl_TessLevelInner[0] = patchIn.gl_TessLevelInner.x; + gl_TessLevelInner[1] = patchIn.gl_TessLevelInner.y; + out.gl_Position = float4(gl_TessLevelOuter[0], gl_TessLevelOuter[1], gl_TessLevelOuter[2], gl_TessLevelOuter[3]) + float2(gl_TessLevelInner[0], gl_TessLevelInner[1]).xyxy; + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tese/read-tess-level-in-func.msl2.tese b/third_party/spirv-cross/reference/opt/shaders-msl/tese/read-tess-level-in-func.msl2.tese new file mode 100644 index 0000000000..bb2e1e59d3 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tese/read-tess-level-in-func.msl2.tese @@ -0,0 +1,69 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +struct main0_patchIn +{ + float4 gl_TessLevel [[attribute(0)]]; +}; + +[[ patch(triangle, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]]) +{ + main0_out out = {}; + spvUnsafeArray gl_TessLevelOuter = {}; + spvUnsafeArray gl_TessLevelInner = {}; + gl_TessLevelOuter[0] = patchIn.gl_TessLevel.x; + gl_TessLevelOuter[1] = patchIn.gl_TessLevel.y; + gl_TessLevelOuter[2] = patchIn.gl_TessLevel.z; + gl_TessLevelInner[0] = patchIn.gl_TessLevel.w; + out.gl_Position = float4(gl_TessLevelOuter[0], gl_TessLevelOuter[1], gl_TessLevelOuter[2], gl_TessLevelOuter[3]) + float2(gl_TessLevelInner[0], gl_TessLevelInner[1]).xyxy; + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/vert/array-component-io.for-tess.vert b/third_party/spirv-cross/reference/opt/shaders-msl/vert/array-component-io.for-tess.vert new file mode 100644 index 0000000000..24958eb50d --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/vert/array-component-io.for-tess.vert @@ -0,0 +1,98 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 m_location_0; + float4 m_location_1; + float4 m_location_2; + float4 gl_Position; +}; + +struct main0_in +{ + float4 m_location_0 [[attribute(0)]]; + float4 m_location_1 [[attribute(1)]]; + float4 m_location_2 [[attribute(2)]]; + float4 Pos [[attribute(4)]]; +}; + +kernel void main0(main0_in in [[stage_in]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 spvStageInputSize [[grid_size]], device main0_out* spvOut [[buffer(28)]]) +{ + spvUnsafeArray A = {}; + spvUnsafeArray B = {}; + spvUnsafeArray C = {}; + float D = {}; + spvUnsafeArray InA = {}; + spvUnsafeArray InB = {}; + spvUnsafeArray InC = {}; + float InD = {}; + device main0_out& out = spvOut[gl_GlobalInvocationID.y * spvStageInputSize.x + gl_GlobalInvocationID.x]; + InA[0] = in.m_location_1.x; + InA[1] = in.m_location_2.x; + InB[0] = in.m_location_1.zw; + InB[1] = in.m_location_2.zw; + InC[0] = in.m_location_0.y; + InC[1] = in.m_location_1.y; + InC[2] = in.m_location_2.y; + InD = in.m_location_0.w; + if (any(gl_GlobalInvocationID >= spvStageInputSize)) + return; + out.gl_Position = in.Pos; + A = InA; + B = InB; + C = InC; + D = InD; + out.m_location_1.x = A[0]; + out.m_location_2.x = A[1]; + out.m_location_1.zw = B[0]; + out.m_location_2.zw = B[1]; + out.m_location_0.y = C[0]; + out.m_location_1.y = C[1]; + out.m_location_2.y = C[2]; + out.m_location_0.w = D; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/vert/array-component-io.vert b/third_party/spirv-cross/reference/opt/shaders-msl/vert/array-component-io.vert new file mode 100644 index 0000000000..352c9d2ef0 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/vert/array-component-io.vert @@ -0,0 +1,100 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float C_0 [[user(locn0_1)]]; + float D [[user(locn0_3)]]; + float A_0 [[user(locn1)]]; + float C_1 [[user(locn1_1)]]; + float2 B_0 [[user(locn1_2)]]; + float A_1 [[user(locn2)]]; + float C_2 [[user(locn2_1)]]; + float2 B_1 [[user(locn2_2)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 m_location_0 [[attribute(0)]]; + float4 m_location_1 [[attribute(1)]]; + float4 m_location_2 [[attribute(2)]]; + float4 Pos [[attribute(4)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + spvUnsafeArray A = {}; + spvUnsafeArray B = {}; + spvUnsafeArray C = {}; + spvUnsafeArray InA = {}; + spvUnsafeArray InB = {}; + spvUnsafeArray InC = {}; + float InD = {}; + InA[0] = in.m_location_1.x; + InA[1] = in.m_location_2.x; + InB[0] = in.m_location_1.zw; + InB[1] = in.m_location_2.zw; + InC[0] = in.m_location_0.y; + InC[1] = in.m_location_1.y; + InC[2] = in.m_location_2.y; + InD = in.m_location_0.w; + out.gl_Position = in.Pos; + A = InA; + B = InB; + C = InC; + out.D = InD; + out.A_0 = A[0]; + out.A_1 = A[1]; + out.B_0 = B[0]; + out.B_1 = B[1]; + out.C_0 = C[0]; + out.C_1 = C[1]; + out.C_2 = C[2]; + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/vert/implicit-position-1.vert b/third_party/spirv-cross/reference/opt/shaders-msl/vert/implicit-position-1.vert new file mode 100644 index 0000000000..5cea4ee2c2 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/vert/implicit-position-1.vert @@ -0,0 +1,18 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 V [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0() +{ + main0_out out = {}; + out.V = float4(1.0); + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/vert/implicit-position-2.vert b/third_party/spirv-cross/reference/opt/shaders-msl/vert/implicit-position-2.vert new file mode 100644 index 0000000000..9e024c2095 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/vert/implicit-position-2.vert @@ -0,0 +1,9 @@ +#include +#include + +using namespace metal; + +vertex void main0() +{ +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/vert/no-contraction.vert b/third_party/spirv-cross/reference/opt/shaders-msl/vert/no-contraction.vert new file mode 100644 index 0000000000..a48731ed81 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/vert/no-contraction.vert @@ -0,0 +1,88 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 vA [[attribute(0)]]; + float4 vB [[attribute(1)]]; + float4 vC [[attribute(2)]]; +}; + +template +T spvFMul(T l, T r) +{ + return fma(l, r, T(0)); +} + +template +vec spvFMulVectorMatrix(vec v, matrix m) +{ + vec res = vec(0); + for (uint i = Rows; i > 0; --i) + { + vec tmp(0); + for (uint j = 0; j < Cols; ++j) + { + tmp[j] = m[j][i - 1]; + } + res = fma(tmp, vec(v[i - 1]), res); + } + return res; +} + +template +vec spvFMulMatrixVector(matrix m, vec v) +{ + vec res = vec(0); + for (uint i = Cols; i > 0; --i) + { + res = fma(m[i - 1], vec(v[i - 1]), res); + } + return res; +} + +template +matrix spvFMulMatrixMatrix(matrix l, matrix r) +{ + matrix res; + for (uint i = 0; i < RCols; i++) + { + vec tmp(0); + for (uint j = 0; j < LCols; j++) + { + tmp = fma(vec(r[i][j]), l[j], tmp); + } + res[i] = tmp; + } + return res; +} + +template +T spvFAdd(T l, T r) +{ + return fma(T(1), l, r); +} + +template +T spvFSub(T l, T r) +{ + return fma(T(-1), r, l); +} + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + float4 _15 = spvFMul(in.vA, in.vB); + out.gl_Position = spvFAdd(spvFAdd(spvFAdd(_15, spvFAdd(in.vA, in.vB)), spvFSub(in.vA, in.vB)), spvFAdd(_15, in.vC)); + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/subpass-input.ios.framebuffer-fetch.asm.frag b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/subpass-input.ios.framebuffer-fetch.asm.frag index 817b1cff71..8bffca1733 100644 --- a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/subpass-input.ios.framebuffer-fetch.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/subpass-input.ios.framebuffer-fetch.asm.frag @@ -197,9 +197,10 @@ struct main0_out float4 out_var_SV_Target0 [[color(0)]]; }; -fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_Globals& _Globals [[buffer(1)]], float4 _RESERVED_IDENTIFIER_FIXUP_gl_LastFragData [[color(0)]], texture2d ShadowDepthTexture [[texture(0)]], sampler ShadowDepthTextureSampler [[sampler(0)]], float4 gl_FragCoord [[position]]) +fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_Globals& _Globals [[buffer(1)]], float4 _RESERVED_IDENTIFIER_FIXUP_gl_LastFragData [[color(0)]], texture2d ShadowDepthTexture [[texture(0)]], sampler ShadowDepthTextureSampler [[sampler(0)]], float4 gl_FragCoord [[position]], uint gl_SampleID [[sample_id]]) { main0_out out = {}; + gl_FragCoord.xy += get_sample_position(gl_SampleID) - 0.5; float4 _67 = _RESERVED_IDENTIFIER_FIXUP_gl_LastFragData; float _68 = _67.w; float4 _82 = _Globals.ScreenToShadowMatrix * float4((((gl_FragCoord.xy * View.View_BufferSizeAndInvSize.zw) - View.View_ScreenPositionScaleBias.wz) / View.View_ScreenPositionScaleBias.xy) * float2(_68), _68, 1.0); diff --git a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/subpass-input.msl23.framebuffer-fetch.asm.frag b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/subpass-input.msl23.framebuffer-fetch.asm.frag index 817b1cff71..8bffca1733 100644 --- a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/subpass-input.msl23.framebuffer-fetch.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/subpass-input.msl23.framebuffer-fetch.asm.frag @@ -197,9 +197,10 @@ struct main0_out float4 out_var_SV_Target0 [[color(0)]]; }; -fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_Globals& _Globals [[buffer(1)]], float4 _RESERVED_IDENTIFIER_FIXUP_gl_LastFragData [[color(0)]], texture2d ShadowDepthTexture [[texture(0)]], sampler ShadowDepthTextureSampler [[sampler(0)]], float4 gl_FragCoord [[position]]) +fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_Globals& _Globals [[buffer(1)]], float4 _RESERVED_IDENTIFIER_FIXUP_gl_LastFragData [[color(0)]], texture2d ShadowDepthTexture [[texture(0)]], sampler ShadowDepthTextureSampler [[sampler(0)]], float4 gl_FragCoord [[position]], uint gl_SampleID [[sample_id]]) { main0_out out = {}; + gl_FragCoord.xy += get_sample_position(gl_SampleID) - 0.5; float4 _67 = _RESERVED_IDENTIFIER_FIXUP_gl_LastFragData; float _68 = _67.w; float4 _82 = _Globals.ScreenToShadowMatrix * float4((((gl_FragCoord.xy * View.View_BufferSizeAndInvSize.zw) - View.View_ScreenPositionScaleBias.wz) / View.View_ScreenPositionScaleBias.xy) * float2(_68), _68, 1.0); diff --git a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tese/ds-patch-input-fixes.asm.tese b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tese/ds-patch-input-fixes.asm.tese index 738b073a1d..3c063c93b1 100644 --- a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tese/ds-patch-input-fixes.asm.tese +++ b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tese/ds-patch-input-fixes.asm.tese @@ -246,9 +246,9 @@ struct main0_out float4 out_var_TEXCOORD7 [[user(locn1)]]; float4 out_var_TEXCOORD10_centroid [[user(locn2)]]; float4 out_var_TEXCOORD11_centroid [[user(locn3)]]; + float4 gl_Position [[position]]; float gl_ClipDistance [[clip_distance]] [1]; float gl_ClipDistance_0 [[user(clip0)]]; - float4 gl_Position [[position]]; }; struct main0_in diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/line-directive.line.asm.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/line-directive.line.asm.frag index 55408080a4..4c108eda60 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/line-directive.line.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/line-directive.line.asm.frag @@ -22,15 +22,18 @@ void main() #line 16 "test.frag" FragColor = 4.0; } +#line 19 "test.frag" for (int _127 = 0; float(_127) < (40.0 + vColor); ) { #line 21 "test.frag" FragColor += 0.20000000298023223876953125; #line 22 "test.frag" FragColor += 0.300000011920928955078125; +#line 19 "test.frag" _127 += (int(vColor) + 5); continue; } +#line 25 "test.frag" switch (int(vColor)) { case 0: @@ -57,7 +60,10 @@ void main() } for (;;) { +#line 42 "test.frag" FragColor += (10.0 + vColor); +#line 43 "test.frag" +#line 42 "test.frag" #line 43 "test.frag" if (FragColor < 100.0) { @@ -67,5 +73,6 @@ void main() break; } } +#line 48 "test.frag" } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag index 4df83d4889..4f382ba8b8 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag @@ -12,7 +12,7 @@ layout(location = 0) out int _entryPointOutput; int _231; -mat4 SPIRV_Cross_workaround_load_row_major(mat4 wrap) { return wrap; } +mat4 spvWorkaroundRowMajor(mat4 wrap) { return wrap; } void main() { @@ -37,7 +37,7 @@ void main() _223 = mat4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0)); break; } while(false); - vec4 _170 = (_223 * SPIRV_Cross_workaround_load_row_major(_11.lightVP[_222])) * vec4(fragWorld, 1.0); + vec4 _170 = (_223 * spvWorkaroundRowMajor(_11.lightVP[_222])) * vec4(fragWorld, 1.0); float _172 = _170.z; float _179 = _170.x; float _181 = _170.y; diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/storage-class-output-initializer.asm.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/storage-class-output-initializer.asm.frag index 229358757a..a5faaefb30 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/storage-class-output-initializer.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/storage-class-output-initializer.asm.frag @@ -2,10 +2,12 @@ layout(location = 0) out vec4 FragColors[2]; layout(location = 2) out vec4 FragColor; +const vec4 _3_init[2] = vec4[](vec4(1.0, 2.0, 3.0, 4.0), vec4(10.0)); +const vec4 _4_init = vec4(5.0); void main() { - FragColors = vec4[](vec4(1.0, 2.0, 3.0, 4.0), vec4(10.0)); - FragColor = vec4(5.0); + FragColors = _3_init; + FragColor = _4_init; } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/vert/empty-io.asm.vert b/third_party/spirv-cross/reference/opt/shaders/asm/vert/empty-io.asm.vert index 3819a71dd2..52fd706565 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/vert/empty-io.asm.vert +++ b/third_party/spirv-cross/reference/opt/shaders/asm/vert/empty-io.asm.vert @@ -6,6 +6,7 @@ struct VSOutput }; layout(location = 0) in vec4 position; +layout(location = 0) out VSOutput _entryPointOutput; void main() { diff --git a/third_party/spirv-cross/reference/opt/shaders/frag/ubo-load-row-major-workaround.frag b/third_party/spirv-cross/reference/opt/shaders/frag/ubo-load-row-major-workaround.frag index 6ed3f788ce..dbb008af64 100644 --- a/third_party/spirv-cross/reference/opt/shaders/frag/ubo-load-row-major-workaround.frag +++ b/third_party/spirv-cross/reference/opt/shaders/frag/ubo-load-row-major-workaround.frag @@ -34,12 +34,12 @@ layout(binding = 3, std140) uniform UBONoWorkaround layout(location = 0) out vec4 FragColor; layout(location = 0) in vec4 Clip; -NestedRowMajor SPIRV_Cross_workaround_load_row_major(NestedRowMajor wrap) { return wrap; } -mat4 SPIRV_Cross_workaround_load_row_major(mat4 wrap) { return wrap; } +NestedRowMajor spvWorkaroundRowMajor(NestedRowMajor wrap) { return wrap; } +mat4 spvWorkaroundRowMajor(mat4 wrap) { return wrap; } void main() { - FragColor = (((SPIRV_Cross_workaround_load_row_major(_17.rm2).rm.B * SPIRV_Cross_workaround_load_row_major(_35.rm.B)) * SPIRV_Cross_workaround_load_row_major(_42.A)) * SPIRV_Cross_workaround_load_row_major(_42.C)) * Clip; + FragColor = (((spvWorkaroundRowMajor(_17.rm2).rm.B * spvWorkaroundRowMajor(_35.rm.B)) * spvWorkaroundRowMajor(_42.A)) * spvWorkaroundRowMajor(_42.C)) * Clip; FragColor += (_56.D * Clip); FragColor += (_42.A[1] * Clip); } diff --git a/third_party/spirv-cross/reference/opt/shaders/legacy/fragment/switch.legacy.frag b/third_party/spirv-cross/reference/opt/shaders/legacy/fragment/switch.legacy.frag index 1920958d50..169f591a74 100644 --- a/third_party/spirv-cross/reference/opt/shaders/legacy/fragment/switch.legacy.frag +++ b/third_party/spirv-cross/reference/opt/shaders/legacy/fragment/switch.legacy.frag @@ -10,7 +10,7 @@ void main() highp vec4 _65; highp vec4 _66; highp vec4 _68; - for (int SPIRV_Cross_Dummy25 = 0; SPIRV_Cross_Dummy25 < 1; SPIRV_Cross_Dummy25++) + for (int spvDummy25 = 0; spvDummy25 < 1; spvDummy25++) { if (_13 == 2) { @@ -59,7 +59,7 @@ void main() } } highp vec4 _70; - for (int SPIRV_Cross_Dummy146 = 0; SPIRV_Cross_Dummy146 < 1; SPIRV_Cross_Dummy146++) + for (int spvDummy146 = 0; spvDummy146 < 1; spvDummy146++) { if ((_13 == 10) || (_13 == 20)) { diff --git a/third_party/spirv-cross/reference/opt/shaders/legacy/vert/switch-nested.legacy.vert b/third_party/spirv-cross/reference/opt/shaders/legacy/vert/switch-nested.legacy.vert index fb8d46ec9c..7fcf6847a7 100644 --- a/third_party/spirv-cross/reference/opt/shaders/legacy/vert/switch-nested.legacy.vert +++ b/third_party/spirv-cross/reference/opt/shaders/legacy/vert/switch-nested.legacy.vert @@ -11,12 +11,12 @@ uniform UBO _34; void main() { vec4 _102; - for (int SPIRV_Cross_Dummy30 = 0; SPIRV_Cross_Dummy30 < 1; SPIRV_Cross_Dummy30++) + for (int spvDummy30 = 0; spvDummy30 < 1; spvDummy30++) { if (_34.func_arg != 0) { vec4 _101; - for (int SPIRV_Cross_Dummy45 = 0; SPIRV_Cross_Dummy45 < 1; SPIRV_Cross_Dummy45++) + for (int spvDummy45 = 0; spvDummy45 < 1; spvDummy45++) { if (_34.inner_func_arg != 0) { diff --git a/third_party/spirv-cross/reference/opt/shaders/legacy/vert/transpose.legacy.vert b/third_party/spirv-cross/reference/opt/shaders/legacy/vert/transpose.legacy.vert index 0f9b97a6f2..9c7f465a1d 100644 --- a/third_party/spirv-cross/reference/opt/shaders/legacy/vert/transpose.legacy.vert +++ b/third_party/spirv-cross/reference/opt/shaders/legacy/vert/transpose.legacy.vert @@ -11,9 +11,9 @@ uniform Buffer _13; attribute vec4 Position; -mat4 SPIRV_Cross_workaround_load_row_major(mat4 wrap) { return wrap; } +mat4 spvWorkaroundRowMajor(mat4 wrap) { return wrap; } -mat4 SPIRV_Cross_Transpose(mat4 m) +mat4 spvTranspose(mat4 m) { return mat4(m[0][0], m[1][0], m[2][0], m[3][0], m[0][1], m[1][1], m[2][1], m[3][1], m[0][2], m[1][2], m[2][2], m[3][2], m[0][3], m[1][3], m[2][3], m[3][3]); } @@ -21,9 +21,9 @@ mat4 SPIRV_Cross_Transpose(mat4 m) void main() { mat4 _55 = _13.MVPRowMajor; - mat4 _61 = SPIRV_Cross_workaround_load_row_major(_13.MVPColMajor); - mat4 _80 = SPIRV_Cross_Transpose(_13.MVPRowMajor) * 2.0; - mat4 _87 = SPIRV_Cross_Transpose(_61) * 2.0; - gl_Position = (((((((((((SPIRV_Cross_workaround_load_row_major(_13.M) * (Position * _13.MVPRowMajor)) + (SPIRV_Cross_workaround_load_row_major(_13.M) * (SPIRV_Cross_workaround_load_row_major(_13.MVPColMajor) * Position))) + (SPIRV_Cross_workaround_load_row_major(_13.M) * (_13.MVPRowMajor * Position))) + (SPIRV_Cross_workaround_load_row_major(_13.M) * (Position * SPIRV_Cross_workaround_load_row_major(_13.MVPColMajor)))) + (_55 * Position)) + (Position * _61)) + (Position * _55)) + (_61 * Position)) + (_80 * Position)) + (_87 * Position)) + (Position * _80)) + (Position * _87); + mat4 _61 = spvWorkaroundRowMajor(_13.MVPColMajor); + mat4 _80 = spvTranspose(_13.MVPRowMajor) * 2.0; + mat4 _87 = spvTranspose(_61) * 2.0; + gl_Position = (((((((((((spvWorkaroundRowMajor(_13.M) * (Position * _13.MVPRowMajor)) + (spvWorkaroundRowMajor(_13.M) * (spvWorkaroundRowMajor(_13.MVPColMajor) * Position))) + (spvWorkaroundRowMajor(_13.M) * (_13.MVPRowMajor * Position))) + (spvWorkaroundRowMajor(_13.M) * (Position * spvWorkaroundRowMajor(_13.MVPColMajor)))) + (_55 * Position)) + (Position * _61)) + (Position * _55)) + (_61 * Position)) + (_80 * Position)) + (_87 * Position)) + (Position * _80)) + (Position * _87); } diff --git a/third_party/spirv-cross/reference/opt/shaders/vert/no-contraction.vert b/third_party/spirv-cross/reference/opt/shaders/vert/no-contraction.vert new file mode 100644 index 0000000000..9f9969cd74 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vert/no-contraction.vert @@ -0,0 +1,18 @@ +#version 450 + +layout(location = 0) in vec4 vA; +layout(location = 1) in vec4 vB; +layout(location = 2) in vec4 vC; + +void main() +{ + precise vec4 _15 = vA * vB; + precise vec4 _19 = vA + vB; + precise vec4 _23 = vA - vB; + precise vec4 _30 = _15 + vC; + precise vec4 _34 = _15 + _19; + precise vec4 _36 = _34 + _23; + precise vec4 _38 = _36 + _30; + gl_Position = _38; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vert/read-from-row-major-array.vert b/third_party/spirv-cross/reference/opt/shaders/vert/read-from-row-major-array.vert index 6c31cae9f8..6c68979b73 100644 --- a/third_party/spirv-cross/reference/opt/shaders/vert/read-from-row-major-array.vert +++ b/third_party/spirv-cross/reference/opt/shaders/vert/read-from-row-major-array.vert @@ -8,11 +8,11 @@ layout(binding = 0, std140) uniform Block layout(location = 0) in vec4 a_position; layout(location = 0) out mediump float v_vtxResult; -mat2x3 SPIRV_Cross_workaround_load_row_major(mat2x3 wrap) { return wrap; } +mat2x3 spvWorkaroundRowMajor(mat2x3 wrap) { return wrap; } void main() { gl_Position = a_position; - v_vtxResult = ((float(abs(SPIRV_Cross_workaround_load_row_major(_104.var[0][0])[0].x - 2.0) < 0.0500000007450580596923828125) * float(abs(SPIRV_Cross_workaround_load_row_major(_104.var[0][0])[0].y - 6.0) < 0.0500000007450580596923828125)) * float(abs(SPIRV_Cross_workaround_load_row_major(_104.var[0][0])[0].z - (-6.0)) < 0.0500000007450580596923828125)) * ((float(abs(SPIRV_Cross_workaround_load_row_major(_104.var[0][0])[1].x) < 0.0500000007450580596923828125) * float(abs(SPIRV_Cross_workaround_load_row_major(_104.var[0][0])[1].y - 5.0) < 0.0500000007450580596923828125)) * float(abs(SPIRV_Cross_workaround_load_row_major(_104.var[0][0])[1].z - 5.0) < 0.0500000007450580596923828125)); + v_vtxResult = ((float(abs(spvWorkaroundRowMajor(_104.var[0][0])[0].x - 2.0) < 0.0500000007450580596923828125) * float(abs(spvWorkaroundRowMajor(_104.var[0][0])[0].y - 6.0) < 0.0500000007450580596923828125)) * float(abs(spvWorkaroundRowMajor(_104.var[0][0])[0].z - (-6.0)) < 0.0500000007450580596923828125)) * ((float(abs(spvWorkaroundRowMajor(_104.var[0][0])[1].x) < 0.0500000007450580596923828125) * float(abs(spvWorkaroundRowMajor(_104.var[0][0])[1].y - 5.0) < 0.0500000007450580596923828125)) * float(abs(spvWorkaroundRowMajor(_104.var[0][0])[1].z - 5.0) < 0.0500000007450580596923828125)); } diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-decorations.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-decorations.nocompat.vk.comp.vk new file mode 100644 index 0000000000..5b3cf49e7a --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/buffer-reference-decorations.nocompat.vk.comp.vk @@ -0,0 +1,35 @@ +#version 450 +#extension GL_EXT_buffer_reference : require +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +layout(buffer_reference) buffer RO; +layout(buffer_reference) buffer RW; +layout(buffer_reference) buffer WO; +layout(buffer_reference, std430) readonly buffer RO +{ + vec4 v[]; +}; + +layout(buffer_reference, std430) restrict buffer RW +{ + vec4 v[]; +}; + +layout(buffer_reference, std430) coherent writeonly buffer WO +{ + vec4 v[]; +}; + +layout(push_constant, std430) uniform Registers +{ + RO ro; + RW rw; + WO wo; +} registers; + +void main() +{ + registers.rw.v[gl_GlobalInvocationID.x] = registers.ro.v[gl_GlobalInvocationID.x]; + registers.wo.v[gl_GlobalInvocationID.x] = registers.ro.v[gl_GlobalInvocationID.x]; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/frag/nonuniform-qualifier.vk.nocompat.frag.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/frag/nonuniform-qualifier.vk.nocompat.frag.vk index 7662cd2156..74e375fd1f 100644 --- a/third_party/spirv-cross/reference/opt/shaders/vulkan/frag/nonuniform-qualifier.vk.nocompat.frag.vk +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/frag/nonuniform-qualifier.vk.nocompat.frag.vk @@ -1,19 +1,24 @@ #version 450 #extension GL_EXT_nonuniform_qualifier : require +#extension GL_EXT_samplerless_texture_functions : require layout(set = 0, binding = 2, std140) uniform UBO { vec4 v[64]; } ubos[]; -layout(set = 0, binding = 3, std430) readonly buffer SSBO +layout(set = 0, binding = 3, std430) buffer SSBO { + uint counter; vec4 v[]; } ssbos[]; layout(set = 0, binding = 0) uniform texture2D uSamplers[]; layout(set = 0, binding = 1) uniform sampler uSamps[]; layout(set = 0, binding = 4) uniform sampler2D uCombinedSamplers[]; +layout(set = 0, binding = 0) uniform texture2DMS uSamplersMS[]; +layout(set = 0, binding = 5, r32f) uniform image2D uImages[]; +layout(set = 0, binding = 5, r32ui) uniform uimage2D uImagesU32[]; layout(location = 0) flat in int vIndex; layout(location = 0) out vec4 FragColor; @@ -21,14 +26,33 @@ layout(location = 1) in vec2 vUV; void main() { - int _23 = vIndex + 10; - int _34 = vIndex + 40; - FragColor = texture(sampler2D(uSamplers[nonuniformEXT(_23)], uSamps[nonuniformEXT(_34)]), vUV); - FragColor = texture(uCombinedSamplers[nonuniformEXT(_23)], vUV); - int _66 = vIndex + 20; - FragColor += ubos[nonuniformEXT(_66)].v[_34]; - int _84 = vIndex + 50; + int _22 = vIndex + 10; + int _32 = vIndex + 40; + FragColor = texture(nonuniformEXT(sampler2D(uSamplers[_22], uSamps[_32])), vUV); + int _49 = _22; + FragColor = texture(uCombinedSamplers[nonuniformEXT(_49)], vUV); + int _65 = vIndex + 20; + int _69 = _32; + FragColor += ubos[nonuniformEXT(_65)].v[_69]; + int _83 = vIndex + 50; int _88 = vIndex + 60; - FragColor += ssbos[nonuniformEXT(_84)].v[_88]; + FragColor += ssbos[nonuniformEXT(_83)].v[_88]; + int _100 = vIndex + 70; + ssbos[nonuniformEXT(_88)].v[_100] = vec4(20.0); + ivec2 _111 = ivec2(vUV); + FragColor = texelFetch(uSamplers[nonuniformEXT(_49)], _111, 0); + int _116 = vIndex + 100; + uint _122 = atomicAdd(ssbos[_116].counter, 100u); + vec2 _149 = FragColor.xy + (textureQueryLod(nonuniformEXT(sampler2D(uSamplers[_22], uSamps[_32])), vUV) + textureQueryLod(uCombinedSamplers[nonuniformEXT(_49)], vUV)); + FragColor = vec4(_149.x, _149.y, FragColor.z, FragColor.w); + FragColor.x += float(textureQueryLevels(uSamplers[nonuniformEXT(_65)])); + FragColor.y += float(textureSamples(uSamplersMS[nonuniformEXT(_65)])); + vec2 _189 = FragColor.xy + vec2(textureSize(uSamplers[nonuniformEXT(_65)], 0)); + FragColor = vec4(_189.x, _189.y, FragColor.z, FragColor.w); + FragColor += imageLoad(uImages[nonuniformEXT(_83)], _111); + vec2 _216 = FragColor.xy + vec2(imageSize(uImages[nonuniformEXT(_65)])); + FragColor = vec4(_216.x, _216.y, FragColor.z, FragColor.w); + imageStore(uImages[nonuniformEXT(_88)], _111, vec4(50.0)); + uint _242 = imageAtomicAdd(uImagesU32[nonuniformEXT(_100)], _111, 40u); } diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rahit/terminators.khr.spv14.nocompat.vk.rahit.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rahit/terminators.khr.spv14.nocompat.vk.rahit.vk new file mode 100644 index 0000000000..2f7fbc1d95 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rahit/terminators.khr.spv14.nocompat.vk.rahit.vk @@ -0,0 +1,17 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT float payload; + +void main() +{ + if (payload > 0.0) + { + ignoreIntersectionEXT; + } + else + { + terminateRayEXT; + } +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rahit/terminators.nocompat.vk.rahit.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rahit/terminators.nocompat.vk.rahit.vk new file mode 100644 index 0000000000..9b9e34b325 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rahit/terminators.nocompat.vk.rahit.vk @@ -0,0 +1,17 @@ +#version 460 +#extension GL_NV_ray_tracing : require + +rayPayloadInNV float payload; + +void main() +{ + if (payload > 0.0) + { + ignoreIntersectionNV(); + } + else + { + terminateRayNV(); + } +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rcall/incoming-callable.khr.spv14.nocompat.vk.rcall.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rcall/incoming-callable.khr.spv14.nocompat.vk.rcall.vk new file mode 100644 index 0000000000..5adfac164f --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rcall/incoming-callable.khr.spv14.nocompat.vk.rcall.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) callableDataInEXT float c; + +void main() +{ + executeCallableEXT(10u, 0); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/hit_attribute_block.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/hit_attribute_block.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..b6c1876d31 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/hit_attribute_block.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,24 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +struct Foo +{ + float a; + float b; +}; + +struct Foo2 +{ + float a; + float b; +}; + +layout(location = 0) rayPayloadInEXT Foo payload; +hitAttributeEXT Foo2 hit; + +void main() +{ + payload.a = hit.a; + payload.b = hit.b; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/hit_attribute_block_in_function.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/hit_attribute_block_in_function.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..b6c1876d31 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/hit_attribute_block_in_function.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,24 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +struct Foo +{ + float a; + float b; +}; + +struct Foo2 +{ + float a; + float b; +}; + +layout(location = 0) rayPayloadInEXT Foo payload; +hitAttributeEXT Foo2 hit; + +void main() +{ + payload.a = hit.a; + payload.b = hit.b; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/hit_attribute_plain.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/hit_attribute_plain.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..eeccd3bb09 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/hit_attribute_plain.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,11 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT vec2 payload; +hitAttributeEXT vec2 hit; + +void main() +{ + payload = hit; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/hit_attribute_struct.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/hit_attribute_struct.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..a51e6b088f --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/hit_attribute_struct.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,17 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +struct Foo +{ + float a; + float b; +}; + +layout(location = 0) rayPayloadInEXT Foo payload; +hitAttributeEXT Foo hit; + +void main() +{ + payload = hit; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/hit_kind.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/hit_kind.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..e4e0103ddb --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/hit_kind.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT uint payload; + +void main() +{ + payload = gl_HitKindEXT; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/hit_t.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/hit_t.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..e94e3323c9 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/hit_t.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT float payload; + +void main() +{ + payload = gl_RayTmaxEXT; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/incoming_ray_flags.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/incoming_ray_flags.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..a013baa11d --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/incoming_ray_flags.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT uint payload; + +void main() +{ + payload = gl_IncomingRayFlagsEXT; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/instance_custom_id.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/instance_custom_id.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..e28af5d252 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/instance_custom_id.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT uint payload; + +void main() +{ + payload = uint(gl_InstanceCustomIndexEXT); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/instance_id.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/instance_id.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..0413e0d234 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/instance_id.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT uint payload; + +void main() +{ + payload = uint(gl_InstanceID); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/object_ray_direction.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/object_ray_direction.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..237d4790e5 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/object_ray_direction.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT vec3 payload; + +void main() +{ + payload = gl_ObjectRayDirectionEXT; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/object_ray_origin.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/object_ray_origin.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..5739ac09ff --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/object_ray_origin.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT vec3 payload; + +void main() +{ + payload = gl_ObjectRayOriginEXT; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/object_to_world.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/object_to_world.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..7922e1efbf --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/object_to_world.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT vec3 payload; + +void main() +{ + payload = gl_ObjectToWorldEXT * vec4(payload, 1.0); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/payloads.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/payloads.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..0bde78724c --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/payloads.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,15 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +struct Payload +{ + vec4 a; +}; + +layout(location = 0) rayPayloadInEXT Payload payload; + +void main() +{ + payload.a = vec4(10.0); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/primitive_id.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/primitive_id.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..667c015e8d --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/primitive_id.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT uint payload; + +void main() +{ + payload = uint(gl_PrimitiveID); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/ray_tmax.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/ray_tmax.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..e94e3323c9 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/ray_tmax.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT float payload; + +void main() +{ + payload = gl_RayTmaxEXT; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/ray_tmin.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/ray_tmin.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..04b8954950 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/ray_tmin.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT float payload; + +void main() +{ + payload = gl_RayTminEXT; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/ray_tracing.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/ray_tracing.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..05af948b37 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/ray_tracing.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT float payload; + +void main() +{ + payload = 1.0 + float(gl_InstanceID); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/world_ray_direction.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/world_ray_direction.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..68ba2bafa5 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/world_ray_direction.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT vec3 payload; + +void main() +{ + payload = gl_WorldRayDirectionEXT; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/world_ray_origin.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/world_ray_origin.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..a5c6766e05 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/world_ray_origin.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT vec3 payload; + +void main() +{ + payload = gl_WorldRayOriginEXT; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/world_to_object.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/world_to_object.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..309ca4c6f1 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rchit/world_to_object.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT vec3 payload; + +void main() +{ + payload = gl_WorldToObjectEXT * vec4(payload, 1.0); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rgen/convert-u-to-as.spv14.vk.nocompat.rgen.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rgen/convert-u-to-as.spv14.vk.nocompat.rgen.vk new file mode 100644 index 0000000000..335f476dc5 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rgen/convert-u-to-as.spv14.vk.nocompat.rgen.vk @@ -0,0 +1,15 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(push_constant, std430) uniform Registers +{ + uvec2 ptr; +} _19; + +layout(location = 0) rayPayloadEXT vec4 payload; + +void main() +{ + traceRayEXT(accelerationStructureEXT(_19.ptr), 1u, 255u, 0u, 0u, 0u, vec3(0.0), 0.0, vec3(0.0, 0.0, -1.0), 100.0, 0); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rgen/execute_callable.nocompat.khr.spv14.vk.rgen.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rgen/execute_callable.nocompat.khr.spv14.vk.rgen.vk new file mode 100644 index 0000000000..2cb00f26f1 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rgen/execute_callable.nocompat.khr.spv14.vk.rgen.vk @@ -0,0 +1,15 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(set = 0, binding = 0) uniform accelerationStructureEXT as; +layout(location = 0) rayPayloadEXT vec4 payload; +layout(location = 1) callableDataEXT float blend; +layout(set = 0, binding = 1, rgba32f) uniform writeonly image2D image; + +void main() +{ + traceRayEXT(as, 1u, 255u, 0u, 0u, 0u, vec3(0.0), 0.0, vec3(0.0, 0.0, -1.0), 100.0, 0); + executeCallableEXT(0u, 1); + imageStore(image, ivec2(gl_LaunchIDEXT.xy), payload + vec4(blend)); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rgen/launch_id.khr.spv14.nocompat.vk.rgen.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rgen/launch_id.khr.spv14.nocompat.vk.rgen.vk new file mode 100644 index 0000000000..1614c49626 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rgen/launch_id.khr.spv14.nocompat.vk.rgen.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(set = 0, binding = 0) uniform writeonly image2D uImage; + +void main() +{ + imageStore(uImage, ivec2(gl_LaunchIDEXT.xy), vec4(1.0)); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rgen/launch_size.khr.spv14.nocompat.vk.rgen.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rgen/launch_size.khr.spv14.nocompat.vk.rgen.vk new file mode 100644 index 0000000000..240e93daa4 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rgen/launch_size.khr.spv14.nocompat.vk.rgen.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(set = 0, binding = 0) uniform writeonly image2D uImage; + +void main() +{ + imageStore(uImage, ivec2(gl_LaunchSizeEXT.xy) - ivec2(1), vec4(1.0)); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rgen/payloads.khr.spv14.nocompat.vk.rgen.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rgen/payloads.khr.spv14.nocompat.vk.rgen.vk new file mode 100644 index 0000000000..434eadf216 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rgen/payloads.khr.spv14.nocompat.vk.rgen.vk @@ -0,0 +1,31 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +struct Payload +{ + float a; + float b; +}; + +struct Block +{ + float a; + float b; + Payload c; + Payload d; +}; + +layout(set = 0, binding = 1) uniform accelerationStructureEXT as; +layout(location = 0) rayPayloadEXT Payload payload2; +layout(location = 1) rayPayloadEXT float payload1; +layout(location = 2) rayPayloadEXT Block _71; +layout(set = 0, binding = 0, rgba8) uniform writeonly image2D image; + +void main() +{ + traceRayEXT(as, 0u, 255u, 0u, 1u, 0u, vec3(1.0, 0.0, 0.0), 0.0, vec3(0.0, 1.0, 0.0), 1000.0, 1); + traceRayEXT(as, 0u, 255u, 0u, 1u, 0u, vec3(1.0, 0.0, 0.0), 0.0, vec3(0.0, 1.0, 0.0), 1000.0, 0); + traceRayEXT(as, 0u, 255u, 0u, 1u, 0u, vec3(1.0, 0.0, 0.0), 0.0, vec3(0.0, 1.0, 0.0), 1000.0, 2); + imageStore(image, ivec2(gl_LaunchIDEXT.xy), (vec4(payload1) + (vec4(payload2.a) + vec4(payload2.b))) + vec4(((((_71.a + _71.b) + _71.c.a) + _71.c.b) + _71.d.a) + _71.d.b)); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rgen/pure_call.khr.spv14.nocompat.vk.rgen.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rgen/pure_call.khr.spv14.nocompat.vk.rgen.vk new file mode 100644 index 0000000000..25b8f2877a --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rgen/pure_call.khr.spv14.nocompat.vk.rgen.vk @@ -0,0 +1,13 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(set = 0, binding = 1) uniform accelerationStructureEXT as; +layout(location = 0) rayPayloadEXT float payload; + +void main() +{ + vec2 _57 = vec2(gl_LaunchIDEXT.xy); + vec2 _61 = vec2(gl_LaunchSizeEXT.xy); + traceRayEXT(as, 0u, 255u, 0u, 1u, 0u, vec3(_57.x / _61.x, _57.y / _61.y, 1.0), 0.0, vec3(0.0, 0.0, -1.0), 1000.0, 0); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rgen/ray_tracing.khr.spv14.nocompat.vk.rgen.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rgen/ray_tracing.khr.spv14.nocompat.vk.rgen.vk new file mode 100644 index 0000000000..d881446595 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rgen/ray_tracing.khr.spv14.nocompat.vk.rgen.vk @@ -0,0 +1,15 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(set = 0, binding = 1) uniform accelerationStructureEXT as; +layout(location = 0) rayPayloadEXT float payload; +layout(set = 0, binding = 0, rgba8) uniform writeonly image2D image; + +void main() +{ + traceRayEXT(as, 0u, 255u, 0u, 1u, 0u, vec3(float(gl_LaunchIDEXT.x) / float(gl_LaunchSizeEXT.x), float(gl_LaunchIDEXT.y) / float(gl_LaunchSizeEXT.y), 1.0), 0.0, vec3(0.0, 0.0, -1.0), 1000.0, 0); + vec4 _68 = vec4(0.0, 0.0, 0.0, 1.0); + _68.y = payload; + imageStore(image, ivec2(gl_LaunchIDEXT.xy), _68); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rgen/shader_record_buffer.khr.spv14.nocompat.vk.rgen.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rgen/shader_record_buffer.khr.spv14.nocompat.vk.rgen.vk new file mode 100644 index 0000000000..3056e8ad28 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rgen/shader_record_buffer.khr.spv14.nocompat.vk.rgen.vk @@ -0,0 +1,17 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(shaderRecordEXT, std430) buffer sbt +{ + vec3 direction; + float tmax; +} _20; + +layout(set = 0, binding = 0) uniform accelerationStructureEXT as; +layout(location = 0) rayPayloadEXT float payload; + +void main() +{ + traceRayEXT(as, 0u, 255u, 0u, 1u, 0u, vec3(0.0), 0.0, _20.direction, _20.tmax, 0); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rint/report-intersection.khr.spv14.nocompat.vk.rint.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rint/report-intersection.khr.spv14.nocompat.vk.rint.vk new file mode 100644 index 0000000000..f9eb7335d8 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rint/report-intersection.khr.spv14.nocompat.vk.rint.vk @@ -0,0 +1,8 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +void main() +{ + bool _16 = reportIntersectionEXT(0.5, 10u); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rint/report-intersection.nocompat.vk.rint.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rint/report-intersection.nocompat.vk.rint.vk new file mode 100644 index 0000000000..56873aff06 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rint/report-intersection.nocompat.vk.rint.vk @@ -0,0 +1,8 @@ +#version 460 +#extension GL_NV_ray_tracing : require + +void main() +{ + bool _16 = reportIntersectionNV(0.5, 10u); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rmiss/ray_tracing.khr.spv14.nocompat.vk.rmiss.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rmiss/ray_tracing.khr.spv14.nocompat.vk.rmiss.vk new file mode 100644 index 0000000000..c055a26814 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rmiss/ray_tracing.khr.spv14.nocompat.vk.rmiss.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT float payload; + +void main() +{ + payload = 0.0; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/rmiss/ray_tracing_trace_incoming.khr.spv14.nocompat.vk.rmiss.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/rmiss/ray_tracing_trace_incoming.khr.spv14.nocompat.vk.rmiss.vk new file mode 100644 index 0000000000..7e79126616 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/rmiss/ray_tracing_trace_incoming.khr.spv14.nocompat.vk.rmiss.vk @@ -0,0 +1,11 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(set = 0, binding = 0) uniform accelerationStructureEXT as; +layout(location = 0) rayPayloadInEXT float p; + +void main() +{ + traceRayEXT(as, 0u, 255u, 0u, 1u, 0u, vec3(float(gl_LaunchIDEXT.x) / float(gl_LaunchSizeEXT.x), float(gl_LaunchIDEXT.y) / float(gl_LaunchSizeEXT.y), 1.0), 0.0, vec3(0.0, 0.0, -1.0), 1000.0, 0); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/vert/small-storage.vk.vert b/third_party/spirv-cross/reference/opt/shaders/vulkan/vert/small-storage.vk.vert index b3aafc8d8c..610618d5b9 100644 --- a/third_party/spirv-cross/reference/opt/shaders/vulkan/vert/small-storage.vk.vert +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/vert/small-storage.vk.vert @@ -1,6 +1,8 @@ #version 450 #if defined(GL_AMD_gpu_shader_int16) #extension GL_AMD_gpu_shader_int16 : require +#elif defined(GL_NV_gpu_shader5) +#extension GL_NV_gpu_shader5 : require #else #error No extension available for Int16. #endif diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/bitfield-signed-operations.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/bitfield-signed-operations.asm.comp index ae5fe5adbc..ebc431b3ed 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/bitfield-signed-operations.asm.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/bitfield-signed-operations.asm.comp @@ -1,54 +1,54 @@ RWByteAddressBuffer _3 : register(u0); -uint SPIRV_Cross_bitfieldInsert(uint Base, uint Insert, uint Offset, uint Count) +uint spvBitfieldInsert(uint Base, uint Insert, uint Offset, uint Count) { uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31)); return (Base & ~Mask) | ((Insert << Offset) & Mask); } -uint2 SPIRV_Cross_bitfieldInsert(uint2 Base, uint2 Insert, uint Offset, uint Count) +uint2 spvBitfieldInsert(uint2 Base, uint2 Insert, uint Offset, uint Count) { uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31)); return (Base & ~Mask) | ((Insert << Offset) & Mask); } -uint3 SPIRV_Cross_bitfieldInsert(uint3 Base, uint3 Insert, uint Offset, uint Count) +uint3 spvBitfieldInsert(uint3 Base, uint3 Insert, uint Offset, uint Count) { uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31)); return (Base & ~Mask) | ((Insert << Offset) & Mask); } -uint4 SPIRV_Cross_bitfieldInsert(uint4 Base, uint4 Insert, uint Offset, uint Count) +uint4 spvBitfieldInsert(uint4 Base, uint4 Insert, uint Offset, uint Count) { uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31)); return (Base & ~Mask) | ((Insert << Offset) & Mask); } -uint SPIRV_Cross_bitfieldUExtract(uint Base, uint Offset, uint Count) +uint spvBitfieldUExtract(uint Base, uint Offset, uint Count) { uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1); return (Base >> Offset) & Mask; } -uint2 SPIRV_Cross_bitfieldUExtract(uint2 Base, uint Offset, uint Count) +uint2 spvBitfieldUExtract(uint2 Base, uint Offset, uint Count) { uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1); return (Base >> Offset) & Mask; } -uint3 SPIRV_Cross_bitfieldUExtract(uint3 Base, uint Offset, uint Count) +uint3 spvBitfieldUExtract(uint3 Base, uint Offset, uint Count) { uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1); return (Base >> Offset) & Mask; } -uint4 SPIRV_Cross_bitfieldUExtract(uint4 Base, uint Offset, uint Count) +uint4 spvBitfieldUExtract(uint4 Base, uint Offset, uint Count) { uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1); return (Base >> Offset) & Mask; } -int SPIRV_Cross_bitfieldSExtract(int Base, int Offset, int Count) +int spvBitfieldSExtract(int Base, int Offset, int Count) { int Mask = Count == 32 ? -1 : ((1 << Count) - 1); int Masked = (Base >> Offset) & Mask; @@ -56,7 +56,7 @@ int SPIRV_Cross_bitfieldSExtract(int Base, int Offset, int Count) return (Masked << ExtendShift) >> ExtendShift; } -int2 SPIRV_Cross_bitfieldSExtract(int2 Base, int Offset, int Count) +int2 spvBitfieldSExtract(int2 Base, int Offset, int Count) { int Mask = Count == 32 ? -1 : ((1 << Count) - 1); int2 Masked = (Base >> Offset) & Mask; @@ -64,7 +64,7 @@ int2 SPIRV_Cross_bitfieldSExtract(int2 Base, int Offset, int Count) return (Masked << ExtendShift) >> ExtendShift; } -int3 SPIRV_Cross_bitfieldSExtract(int3 Base, int Offset, int Count) +int3 spvBitfieldSExtract(int3 Base, int Offset, int Count) { int Mask = Count == 32 ? -1 : ((1 << Count) - 1); int3 Masked = (Base >> Offset) & Mask; @@ -72,7 +72,7 @@ int3 SPIRV_Cross_bitfieldSExtract(int3 Base, int Offset, int Count) return (Masked << ExtendShift) >> ExtendShift; } -int4 SPIRV_Cross_bitfieldSExtract(int4 Base, int Offset, int Count) +int4 spvBitfieldSExtract(int4 Base, int Offset, int Count) { int Mask = Count == 32 ? -1 : ((1 << Count) - 1); int4 Masked = (Base >> Offset) & Mask; @@ -90,12 +90,12 @@ void comp_main() _3.Store4(16, countbits(_20)); _3.Store4(0, uint4(reversebits(_19))); _3.Store4(16, reversebits(_20)); - _3.Store4(0, uint4(SPIRV_Cross_bitfieldSExtract(_19, 1, 11u))); - _3.Store4(16, SPIRV_Cross_bitfieldSExtract(_20, 11u, 1)); - _3.Store4(0, uint4(SPIRV_Cross_bitfieldUExtract(_19, 1, 11u))); - _3.Store4(16, SPIRV_Cross_bitfieldUExtract(_20, 11u, 1)); - _3.Store4(0, uint4(int4(SPIRV_Cross_bitfieldInsert(_19, _19.wzyx, 1, 11u)))); - _3.Store4(16, SPIRV_Cross_bitfieldInsert(_20, _20.wzyx, 11u, 1)); + _3.Store4(0, uint4(spvBitfieldSExtract(_19, 1, 11u))); + _3.Store4(16, spvBitfieldSExtract(_20, 11u, 1)); + _3.Store4(0, uint4(spvBitfieldUExtract(_19, 1, 11u))); + _3.Store4(16, spvBitfieldUExtract(_20, 11u, 1)); + _3.Store4(0, uint4(int4(spvBitfieldInsert(_19, _19.wzyx, 1, 11u)))); + _3.Store4(16, spvBitfieldInsert(_20, _20.wzyx, 11u, 1)); } [numthreads(1, 1, 1)] diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/eliminate-globals-not-in-entry-point.noeliminate.spv14.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/eliminate-globals-not-in-entry-point.noeliminate.spv14.asm.comp new file mode 100644 index 0000000000..a53efc4f7f --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/eliminate-globals-not-in-entry-point.noeliminate.spv14.asm.comp @@ -0,0 +1,11 @@ +static const uint3 gl_WorkGroupSize = uint3(64u, 1u, 1u); + +void comp_main() +{ +} + +[numthreads(64, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.invalid.nofxc.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.nofxc.asm.comp similarity index 100% rename from third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.invalid.nofxc.asm.comp rename to third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.nofxc.asm.comp diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-bracket-handling-2.nonuniformresource.sm51.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-bracket-handling-2.nonuniformresource.sm51.asm.frag index b7e67dda28..fd758b17d7 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-bracket-handling-2.nonuniformresource.sm51.asm.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-bracket-handling-2.nonuniformresource.sm51.asm.frag @@ -1,8 +1,8 @@ -ByteAddressBuffer _8 : register(t0, space0); +ByteAddressBuffer _8 : register(t0, space2); Texture2D uSamplers[] : register(t0, space0); SamplerState _uSamplers_sampler[] : register(s0, space0); -Texture2D uSampler : register(t0, space1); -SamplerState _uSampler_sampler : register(s0, space1); +Texture2D uSampler : register(t1, space1); +SamplerState _uSampler_sampler : register(s1, space1); static float4 gl_FragCoord; static float4 FragColor; diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-qualifier-propagation.nonuniformresource.sm51.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-qualifier-propagation.nonuniformresource.sm51.asm.frag index 44cc8ab221..0356cf58d9 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-qualifier-propagation.nonuniformresource.sm51.asm.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-qualifier-propagation.nonuniformresource.sm51.asm.frag @@ -1,9 +1,9 @@ -struct UBO_1_1 +struct UBO_1 { float4 v[64]; }; -ConstantBuffer ubos[] : register(b0, space2); +ConstantBuffer ubos[] : register(b0, space2); ByteAddressBuffer ssbos[] : register(t0, space3); Texture2D uSamplers[] : register(t0, space0); SamplerState uSamps[] : register(s0, space1); diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-ssbo.sm51.nonuniformresource.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-ssbo.sm51.nonuniformresource.asm.frag new file mode 100644 index 0000000000..a692cdcf40 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/nonuniform-ssbo.sm51.nonuniformresource.asm.frag @@ -0,0 +1,39 @@ +RWByteAddressBuffer ssbos[] : register(u3, space0); + +static int vIndex; +static float4 FragColor; + +struct SPIRV_Cross_Input +{ + nointerpolation int vIndex : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + int i = vIndex; + int _42 = i + 60; + int _45 = i + 70; + ssbos[NonUniformResourceIndex(_42)].Store4(_45 * 16 + 16, asuint(20.0f.xxxx)); + int _48 = i + 100; + uint _49; + ssbos[NonUniformResourceIndex(_48)].InterlockedAdd(0, 100u, _49); + int _51 = i; + uint _52; + ssbos[NonUniformResourceIndex(_51)].GetDimensions(_52); + _52 = (_52 - 16) / 16; + FragColor.z += float(int(_52)); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vIndex = stage_input.vIndex; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/only-initializer-frag-depth.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/only-initializer-frag-depth.asm.frag new file mode 100644 index 0000000000..dcbe5d134f --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/only-initializer-frag-depth.asm.frag @@ -0,0 +1,17 @@ +static float gl_FragDepth = 0.5f; +struct SPIRV_Cross_Output +{ + float gl_FragDepth : SV_Depth; +}; + +void frag_main() +{ +} + +SPIRV_Cross_Output main() +{ + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_FragDepth = gl_FragDepth; + return stage_output; +} diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/reserved-function-identifier.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/reserved-function-identifier.asm.frag new file mode 100644 index 0000000000..1f1f6fac10 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/frag/reserved-function-identifier.asm.frag @@ -0,0 +1,31 @@ +static float FragColor; + +struct SPIRV_Cross_Output +{ + float FragColor : SV_Target0; +}; + +float _mat3(float a) +{ + return a + 1.0f; +} + +float _RESERVED_IDENTIFIER_FIXUP_gl_Foo(int a) +{ + return float(a) + 1.0f; +} + +void frag_main() +{ + float param = 2.0f; + int param_1 = 4; + FragColor = _mat3(param) + _RESERVED_IDENTIFIER_FIXUP_gl_Foo(param_1); +} + +SPIRV_Cross_Output main() +{ + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/vert/block-struct-initializer.asm.vert b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/vert/block-struct-initializer.asm.vert new file mode 100644 index 0000000000..a2b5ea718c --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/vert/block-struct-initializer.asm.vert @@ -0,0 +1,35 @@ +struct Foo +{ + float c; + float d; +}; + +static const Foo _13 = { 0.0f, 0.0f }; + +static Foo foo = _13; + +struct Vert +{ + float a : TEXCOORD0; + float b : TEXCOORD1; +}; + +static Vert _3 = { 0.0f, 0.0f }; + +struct SPIRV_Cross_Output +{ + Foo foo : TEXCOORD2; +}; + +void vert_main() +{ +} + +SPIRV_Cross_Output main(out Vert stage_output_3) +{ + vert_main(); + stage_output_3 = _3; + SPIRV_Cross_Output stage_output; + stage_output.foo = foo; + return stage_output; +} diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/vert/builtin-output-initializer.asm.vert b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/vert/builtin-output-initializer.asm.vert new file mode 100644 index 0000000000..ee30c1783e --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/vert/builtin-output-initializer.asm.vert @@ -0,0 +1,28 @@ +static const float _23[1] = { 0.0f }; +static const float _24[1] = { 0.0f }; + +static float4 gl_Position = 0.0f.xxxx; +static float gl_PointSize = 0.0f; +static float gl_ClipDistance[1] = _23; +static float gl_CullDistance[1] = _24; +struct SPIRV_Cross_Output +{ + float4 gl_Position : SV_Position; + float gl_ClipDistance0 : SV_ClipDistance0; + float gl_CullDistance0 : SV_CullDistance0; +}; + +void vert_main() +{ + gl_Position = 1.0f.xxxx; +} + +SPIRV_Cross_Output main() +{ + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + stage_output.gl_ClipDistance0.x = gl_ClipDistance[0]; + stage_output.gl_CullDistance0.x = gl_CullDistance[0]; + return stage_output; +} diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/bitfield.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/bitfield.comp index 0dc089c1de..be287c4174 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/bitfield.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/bitfield.comp @@ -1,52 +1,52 @@ -uint SPIRV_Cross_bitfieldInsert(uint Base, uint Insert, uint Offset, uint Count) +uint spvBitfieldInsert(uint Base, uint Insert, uint Offset, uint Count) { uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31)); return (Base & ~Mask) | ((Insert << Offset) & Mask); } -uint2 SPIRV_Cross_bitfieldInsert(uint2 Base, uint2 Insert, uint Offset, uint Count) +uint2 spvBitfieldInsert(uint2 Base, uint2 Insert, uint Offset, uint Count) { uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31)); return (Base & ~Mask) | ((Insert << Offset) & Mask); } -uint3 SPIRV_Cross_bitfieldInsert(uint3 Base, uint3 Insert, uint Offset, uint Count) +uint3 spvBitfieldInsert(uint3 Base, uint3 Insert, uint Offset, uint Count) { uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31)); return (Base & ~Mask) | ((Insert << Offset) & Mask); } -uint4 SPIRV_Cross_bitfieldInsert(uint4 Base, uint4 Insert, uint Offset, uint Count) +uint4 spvBitfieldInsert(uint4 Base, uint4 Insert, uint Offset, uint Count) { uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31)); return (Base & ~Mask) | ((Insert << Offset) & Mask); } -uint SPIRV_Cross_bitfieldUExtract(uint Base, uint Offset, uint Count) +uint spvBitfieldUExtract(uint Base, uint Offset, uint Count) { uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1); return (Base >> Offset) & Mask; } -uint2 SPIRV_Cross_bitfieldUExtract(uint2 Base, uint Offset, uint Count) +uint2 spvBitfieldUExtract(uint2 Base, uint Offset, uint Count) { uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1); return (Base >> Offset) & Mask; } -uint3 SPIRV_Cross_bitfieldUExtract(uint3 Base, uint Offset, uint Count) +uint3 spvBitfieldUExtract(uint3 Base, uint Offset, uint Count) { uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1); return (Base >> Offset) & Mask; } -uint4 SPIRV_Cross_bitfieldUExtract(uint4 Base, uint Offset, uint Count) +uint4 spvBitfieldUExtract(uint4 Base, uint Offset, uint Count) { uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1); return (Base >> Offset) & Mask; } -int SPIRV_Cross_bitfieldSExtract(int Base, int Offset, int Count) +int spvBitfieldSExtract(int Base, int Offset, int Count) { int Mask = Count == 32 ? -1 : ((1 << Count) - 1); int Masked = (Base >> Offset) & Mask; @@ -54,7 +54,7 @@ int SPIRV_Cross_bitfieldSExtract(int Base, int Offset, int Count) return (Masked << ExtendShift) >> ExtendShift; } -int2 SPIRV_Cross_bitfieldSExtract(int2 Base, int Offset, int Count) +int2 spvBitfieldSExtract(int2 Base, int Offset, int Count) { int Mask = Count == 32 ? -1 : ((1 << Count) - 1); int2 Masked = (Base >> Offset) & Mask; @@ -62,7 +62,7 @@ int2 SPIRV_Cross_bitfieldSExtract(int2 Base, int Offset, int Count) return (Masked << ExtendShift) >> ExtendShift; } -int3 SPIRV_Cross_bitfieldSExtract(int3 Base, int Offset, int Count) +int3 spvBitfieldSExtract(int3 Base, int Offset, int Count) { int Mask = Count == 32 ? -1 : ((1 << Count) - 1); int3 Masked = (Base >> Offset) & Mask; @@ -70,7 +70,7 @@ int3 SPIRV_Cross_bitfieldSExtract(int3 Base, int Offset, int Count) return (Masked << ExtendShift) >> ExtendShift; } -int4 SPIRV_Cross_bitfieldSExtract(int4 Base, int Offset, int Count) +int4 spvBitfieldSExtract(int4 Base, int Offset, int Count) { int Mask = Count == 32 ? -1 : ((1 << Count) - 1); int4 Masked = (Base >> Offset) & Mask; @@ -84,20 +84,20 @@ void comp_main() uint unsigned_value = 0u; int3 signed_values = int3(0, 0, 0); uint3 unsigned_values = uint3(0u, 0u, 0u); - int s = SPIRV_Cross_bitfieldSExtract(signed_value, 5, 20); - uint u = SPIRV_Cross_bitfieldUExtract(unsigned_value, 6, 21); - s = int(SPIRV_Cross_bitfieldInsert(s, 40, 5, 4)); - u = SPIRV_Cross_bitfieldInsert(u, 60u, 5, 4); + int s = spvBitfieldSExtract(signed_value, 5, 20); + uint u = spvBitfieldUExtract(unsigned_value, 6, 21); + s = int(spvBitfieldInsert(s, 40, 5, 4)); + u = spvBitfieldInsert(u, 60u, 5, 4); u = reversebits(u); s = reversebits(s); int v0 = int(countbits(u)); int v1 = countbits(s); int v2 = int(firstbithigh(u)); int v3 = firstbitlow(s); - int3 s_1 = SPIRV_Cross_bitfieldSExtract(signed_values, 5, 20); - uint3 u_1 = SPIRV_Cross_bitfieldUExtract(unsigned_values, 6, 21); - s_1 = int3(SPIRV_Cross_bitfieldInsert(s_1, int3(40, 40, 40), 5, 4)); - u_1 = SPIRV_Cross_bitfieldInsert(u_1, uint3(60u, 60u, 60u), 5, 4); + int3 s_1 = spvBitfieldSExtract(signed_values, 5, 20); + uint3 u_1 = spvBitfieldUExtract(unsigned_values, 6, 21); + s_1 = int3(spvBitfieldInsert(s_1, int3(40, 40, 40), 5, 4)); + u_1 = spvBitfieldInsert(u_1, uint3(60u, 60u, 60u), 5, 4); u_1 = reversebits(u_1); s_1 = reversebits(s_1); int3 v0_1 = int3(countbits(u_1)); diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/glsl.std450.fxconly.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/glsl.std450.fxconly.comp index 7558afaa86..7936bf94d0 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/glsl.std450.fxconly.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/glsl.std450.fxconly.comp @@ -8,61 +8,61 @@ static const uint3 gl_WorkGroupSize = uint3(1u, 1u, 1u); RWByteAddressBuffer _19 : register(u0); -uint SPIRV_Cross_packHalf2x16(float2 value) +uint spvPackHalf2x16(float2 value) { uint2 Packed = f32tof16(value); return Packed.x | (Packed.y << 16); } -float2 SPIRV_Cross_unpackHalf2x16(uint value) +float2 spvUnpackHalf2x16(uint value) { return f16tof32(uint2(value & 0xffff, value >> 16)); } -uint SPIRV_Cross_packUnorm4x8(float4 value) +uint spvPackUnorm4x8(float4 value) { uint4 Packed = uint4(round(saturate(value) * 255.0)); return Packed.x | (Packed.y << 8) | (Packed.z << 16) | (Packed.w << 24); } -float4 SPIRV_Cross_unpackUnorm4x8(uint value) +float4 spvUnpackUnorm4x8(uint value) { uint4 Packed = uint4(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, value >> 24); return float4(Packed) / 255.0; } -uint SPIRV_Cross_packSnorm4x8(float4 value) +uint spvPackSnorm4x8(float4 value) { int4 Packed = int4(round(clamp(value, -1.0, 1.0) * 127.0)) & 0xff; return uint(Packed.x | (Packed.y << 8) | (Packed.z << 16) | (Packed.w << 24)); } -float4 SPIRV_Cross_unpackSnorm4x8(uint value) +float4 spvUnpackSnorm4x8(uint value) { int SignedValue = int(value); int4 Packed = int4(SignedValue << 24, SignedValue << 16, SignedValue << 8, SignedValue) >> 24; return clamp(float4(Packed) / 127.0, -1.0, 1.0); } -uint SPIRV_Cross_packUnorm2x16(float2 value) +uint spvPackUnorm2x16(float2 value) { uint2 Packed = uint2(round(saturate(value) * 65535.0)); return Packed.x | (Packed.y << 16); } -float2 SPIRV_Cross_unpackUnorm2x16(uint value) +float2 spvUnpackUnorm2x16(uint value) { uint2 Packed = uint2(value & 0xffff, value >> 16); return float2(Packed) / 65535.0; } -uint SPIRV_Cross_packSnorm2x16(float2 value) +uint spvPackSnorm2x16(float2 value) { int2 Packed = int2(round(clamp(value, -1.0, 1.0) * 32767.0)) & 0xffff; return uint(Packed.x | (Packed.y << 16)); } -float2 SPIRV_Cross_unpackSnorm2x16(uint value) +float2 spvUnpackSnorm2x16(uint value) { int SignedValue = int(value); int2 Packed = int2(SignedValue << 16, SignedValue) >> 16; @@ -71,7 +71,7 @@ float2 SPIRV_Cross_unpackSnorm2x16(uint value) // Returns the inverse of a matrix, by using the algorithm of calculating the classical // adjoint and dividing by the determinant. The contents of the matrix are changed. -float2x2 SPIRV_Cross_Inverse(float2x2 m) +float2x2 spvInverse(float2x2 m) { float2x2 adj; // The adjoint matrix (inverse after dividing by determinant) @@ -91,29 +91,29 @@ float2x2 SPIRV_Cross_Inverse(float2x2 m) } // Returns the determinant of a 2x2 matrix. -float SPIRV_Cross_Det2x2(float a1, float a2, float b1, float b2) +float spvDet2x2(float a1, float a2, float b1, float b2) { return a1 * b2 - b1 * a2; } // Returns the inverse of a matrix, by using the algorithm of calculating the classical // adjoint and dividing by the determinant. The contents of the matrix are changed. -float3x3 SPIRV_Cross_Inverse(float3x3 m) +float3x3 spvInverse(float3x3 m) { float3x3 adj; // The adjoint matrix (inverse after dividing by determinant) // Create the transpose of the cofactors, as the classical adjoint of the matrix. - adj[0][0] = SPIRV_Cross_Det2x2(m[1][1], m[1][2], m[2][1], m[2][2]); - adj[0][1] = -SPIRV_Cross_Det2x2(m[0][1], m[0][2], m[2][1], m[2][2]); - adj[0][2] = SPIRV_Cross_Det2x2(m[0][1], m[0][2], m[1][1], m[1][2]); + adj[0][0] = spvDet2x2(m[1][1], m[1][2], m[2][1], m[2][2]); + adj[0][1] = -spvDet2x2(m[0][1], m[0][2], m[2][1], m[2][2]); + adj[0][2] = spvDet2x2(m[0][1], m[0][2], m[1][1], m[1][2]); - adj[1][0] = -SPIRV_Cross_Det2x2(m[1][0], m[1][2], m[2][0], m[2][2]); - adj[1][1] = SPIRV_Cross_Det2x2(m[0][0], m[0][2], m[2][0], m[2][2]); - adj[1][2] = -SPIRV_Cross_Det2x2(m[0][0], m[0][2], m[1][0], m[1][2]); + adj[1][0] = -spvDet2x2(m[1][0], m[1][2], m[2][0], m[2][2]); + adj[1][1] = spvDet2x2(m[0][0], m[0][2], m[2][0], m[2][2]); + adj[1][2] = -spvDet2x2(m[0][0], m[0][2], m[1][0], m[1][2]); - adj[2][0] = SPIRV_Cross_Det2x2(m[1][0], m[1][1], m[2][0], m[2][1]); - adj[2][1] = -SPIRV_Cross_Det2x2(m[0][0], m[0][1], m[2][0], m[2][1]); - adj[2][2] = SPIRV_Cross_Det2x2(m[0][0], m[0][1], m[1][0], m[1][1]); + adj[2][0] = spvDet2x2(m[1][0], m[1][1], m[2][0], m[2][1]); + adj[2][1] = -spvDet2x2(m[0][0], m[0][1], m[2][0], m[2][1]); + adj[2][2] = spvDet2x2(m[0][0], m[0][1], m[1][0], m[1][1]); // Calculate the determinant as a combination of the cofactors of the first row. float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]) + (adj[0][2] * m[2][0]); @@ -124,37 +124,37 @@ float3x3 SPIRV_Cross_Inverse(float3x3 m) } // Returns the determinant of a 3x3 matrix. -float SPIRV_Cross_Det3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3) +float spvDet3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3) { - return a1 * SPIRV_Cross_Det2x2(b2, b3, c2, c3) - b1 * SPIRV_Cross_Det2x2(a2, a3, c2, c3) + c1 * SPIRV_Cross_Det2x2(a2, a3, b2, b3); + return a1 * spvDet2x2(b2, b3, c2, c3) - b1 * spvDet2x2(a2, a3, c2, c3) + c1 * spvDet2x2(a2, a3, b2, b3); } // Returns the inverse of a matrix, by using the algorithm of calculating the classical // adjoint and dividing by the determinant. The contents of the matrix are changed. -float4x4 SPIRV_Cross_Inverse(float4x4 m) +float4x4 spvInverse(float4x4 m) { float4x4 adj; // The adjoint matrix (inverse after dividing by determinant) // Create the transpose of the cofactors, as the classical adjoint of the matrix. - adj[0][0] = SPIRV_Cross_Det3x3(m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]); - adj[0][1] = -SPIRV_Cross_Det3x3(m[0][1], m[0][2], m[0][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]); - adj[0][2] = SPIRV_Cross_Det3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[3][1], m[3][2], m[3][3]); - adj[0][3] = -SPIRV_Cross_Det3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3]); + adj[0][0] = spvDet3x3(m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]); + adj[0][1] = -spvDet3x3(m[0][1], m[0][2], m[0][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]); + adj[0][2] = spvDet3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[3][1], m[3][2], m[3][3]); + adj[0][3] = -spvDet3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3]); - adj[1][0] = -SPIRV_Cross_Det3x3(m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]); - adj[1][1] = SPIRV_Cross_Det3x3(m[0][0], m[0][2], m[0][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]); - adj[1][2] = -SPIRV_Cross_Det3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[3][0], m[3][2], m[3][3]); - adj[1][3] = SPIRV_Cross_Det3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3]); + adj[1][0] = -spvDet3x3(m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]); + adj[1][1] = spvDet3x3(m[0][0], m[0][2], m[0][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]); + adj[1][2] = -spvDet3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[3][0], m[3][2], m[3][3]); + adj[1][3] = spvDet3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3]); - adj[2][0] = SPIRV_Cross_Det3x3(m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]); - adj[2][1] = -SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]); - adj[2][2] = SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], m[3][3]); - adj[2][3] = -SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3]); + adj[2][0] = spvDet3x3(m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]); + adj[2][1] = -spvDet3x3(m[0][0], m[0][1], m[0][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]); + adj[2][2] = spvDet3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], m[3][3]); + adj[2][3] = -spvDet3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3]); - adj[3][0] = -SPIRV_Cross_Det3x3(m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]); - adj[3][1] = SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]); - adj[3][2] = -SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[3][0], m[3][1], m[3][2]); - adj[3][3] = SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2]); + adj[3][0] = -spvDet3x3(m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]); + adj[3][1] = spvDet3x3(m[0][0], m[0][1], m[0][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]); + adj[3][2] = -spvDet3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[3][0], m[3][1], m[3][2]); + adj[3][3] = spvDet3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2]); // Calculate the determinant as a combination of the cofactors of the first row. float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]) + (adj[0][2] * m[2][0]) + (adj[0][3] * m[3][0]); @@ -164,12 +164,12 @@ float4x4 SPIRV_Cross_Inverse(float4x4 m) return (det != 0.0f) ? (adj * (1.0f / det)) : m; } -float SPIRV_Cross_Reflect(float i, float n) +float spvReflect(float i, float n) { return i - 2.0 * dot(n, i) * n; } -float SPIRV_Cross_Refract(float i, float n, float eta) +float spvRefract(float i, float n, float eta) { float NoI = n * i; float NoI2 = NoI * NoI; @@ -184,7 +184,7 @@ float SPIRV_Cross_Refract(float i, float n, float eta) } } -float SPIRV_Cross_FaceForward(float n, float i, float nref) +float spvFaceForward(float n, float i, float nref) { return i * nref < 0.0 ? n : -n; } @@ -222,9 +222,9 @@ void comp_main() _19.Store(0, asuint(length(asfloat(_19.Load(16))))); _19.Store(0, asuint(distance(asfloat(_19.Load(16)), asfloat(_19.Load(20))))); _19.Store(0, asuint(sign(asfloat(_19.Load(16))))); - _19.Store(0, asuint(SPIRV_Cross_FaceForward(asfloat(_19.Load(16)), asfloat(_19.Load(20)), asfloat(_19.Load(24))))); - _19.Store(0, asuint(SPIRV_Cross_Reflect(asfloat(_19.Load(16)), asfloat(_19.Load(20))))); - _19.Store(0, asuint(SPIRV_Cross_Refract(asfloat(_19.Load(16)), asfloat(_19.Load(20)), asfloat(_19.Load(24))))); + _19.Store(0, asuint(spvFaceForward(asfloat(_19.Load(16)), asfloat(_19.Load(20)), asfloat(_19.Load(24))))); + _19.Store(0, asuint(spvReflect(asfloat(_19.Load(16)), asfloat(_19.Load(20))))); + _19.Store(0, asuint(spvRefract(asfloat(_19.Load(16)), asfloat(_19.Load(20)), asfloat(_19.Load(24))))); _19.Store(0, asuint(length(asfloat(_19.Load4(16)).xy))); _19.Store(0, asuint(distance(asfloat(_19.Load4(16)).xy, asfloat(_19.Load4(16)).zw))); float2 v2 = normalize(asfloat(_19.Load4(16)).xy); @@ -239,16 +239,16 @@ void comp_main() float4x4 _252 = asfloat(uint4x4(_19.Load4(128), _19.Load4(144), _19.Load4(160), _19.Load4(176))); _19.Store(0, asuint(determinant(_252))); float2x2 _256 = asfloat(uint2x2(_19.Load2(64), _19.Load2(72))); - float2x2 _257 = SPIRV_Cross_Inverse(_256); + float2x2 _257 = spvInverse(_256); _19.Store2(64, asuint(_257[0])); _19.Store2(72, asuint(_257[1])); float3x3 _260 = asfloat(uint3x3(_19.Load3(80), _19.Load3(96), _19.Load3(112))); - float3x3 _261 = SPIRV_Cross_Inverse(_260); + float3x3 _261 = spvInverse(_260); _19.Store3(80, asuint(_261[0])); _19.Store3(96, asuint(_261[1])); _19.Store3(112, asuint(_261[2])); float4x4 _264 = asfloat(uint4x4(_19.Load4(128), _19.Load4(144), _19.Load4(160), _19.Load4(176))); - float4x4 _265 = SPIRV_Cross_Inverse(_264); + float4x4 _265 = spvInverse(_264); _19.Store4(128, asuint(_265[0])); _19.Store4(144, asuint(_265[1])); _19.Store4(160, asuint(_265[2])); @@ -274,16 +274,16 @@ void comp_main() int itmp = _371._m1; _19.Store(0, asuint(_371._m0)); _19.Store(0, asuint(ldexp(asfloat(_19.Load(16)), itmp))); - _19.Store(8, SPIRV_Cross_packSnorm4x8(asfloat(_19.Load4(16)))); - _19.Store(8, SPIRV_Cross_packUnorm4x8(asfloat(_19.Load4(16)))); - _19.Store(8, SPIRV_Cross_packSnorm2x16(asfloat(_19.Load4(16)).xy)); - _19.Store(8, SPIRV_Cross_packUnorm2x16(asfloat(_19.Load4(16)).xy)); - _19.Store(8, SPIRV_Cross_packHalf2x16(asfloat(_19.Load4(16)).xy)); - v2 = SPIRV_Cross_unpackSnorm2x16(_19.Load(48)); - v2 = SPIRV_Cross_unpackUnorm2x16(_19.Load(48)); - v2 = SPIRV_Cross_unpackHalf2x16(_19.Load(48)); - float4 v4 = SPIRV_Cross_unpackSnorm4x8(_19.Load(48)); - v4 = SPIRV_Cross_unpackUnorm4x8(_19.Load(48)); + _19.Store(8, spvPackSnorm4x8(asfloat(_19.Load4(16)))); + _19.Store(8, spvPackUnorm4x8(asfloat(_19.Load4(16)))); + _19.Store(8, spvPackSnorm2x16(asfloat(_19.Load4(16)).xy)); + _19.Store(8, spvPackUnorm2x16(asfloat(_19.Load4(16)).xy)); + _19.Store(8, spvPackHalf2x16(asfloat(_19.Load4(16)).xy)); + v2 = spvUnpackSnorm2x16(_19.Load(48)); + v2 = spvUnpackUnorm2x16(_19.Load(48)); + v2 = spvUnpackHalf2x16(_19.Load(48)); + float4 v4 = spvUnpackSnorm4x8(_19.Load(48)); + v4 = spvUnpackUnorm4x8(_19.Load(48)); _19.Store4(32, uint4(firstbitlow(int4(_19.Load4(32))))); _19.Store4(32, uint4(int4(firstbitlow(_19.Load4(48))))); _19.Store4(32, uint4(firstbithigh(int4(_19.Load4(32))))); diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/subgroups-boolean.invalid.nofxc.sm60.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/subgroups-boolean.invalid.nofxc.sm60.comp new file mode 100644 index 0000000000..2d1d2ad039 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/subgroups-boolean.invalid.nofxc.sm60.comp @@ -0,0 +1,28 @@ +static const uint3 gl_WorkGroupSize = uint3(30u, 1u, 1u); + +RWByteAddressBuffer _46 : register(u0, space0); + +static uint3 gl_GlobalInvocationID; +struct SPIRV_Cross_Input +{ + uint3 gl_GlobalInvocationID : SV_DispatchThreadID; +}; + +void comp_main() +{ + bool v = gl_GlobalInvocationID.x != 3u; + bool4 v4; + v4.x = bool(WaveActiveBitOr(uint(v))); + v4.y = bool(WaveActiveBitAnd(uint(v))); + v4.z = bool(WaveActiveBitXor(uint(v))); + v4.w = WaveActiveAllEqual(v); + uint4 w = uint4(v4.x ? uint4(1u, 1u, 1u, 1u).x : uint4(0u, 0u, 0u, 0u).x, v4.y ? uint4(1u, 1u, 1u, 1u).y : uint4(0u, 0u, 0u, 0u).y, v4.z ? uint4(1u, 1u, 1u, 1u).z : uint4(0u, 0u, 0u, 0u).z, v4.w ? uint4(1u, 1u, 1u, 1u).w : uint4(0u, 0u, 0u, 0u).w); + _46.Store(gl_GlobalInvocationID.x * 4 + 0, ((w.x + w.y) + w.z) + w.w); +} + +[numthreads(30, 1, 1)] +void main(SPIRV_Cross_Input stage_input) +{ + gl_GlobalInvocationID = stage_input.gl_GlobalInvocationID; + comp_main(); +} diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/subgroups.invalid.nofxc.sm60.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/subgroups.invalid.nofxc.sm60.comp index 0957a70872..b2f5a5a160 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/subgroups.invalid.nofxc.sm60.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/subgroups.invalid.nofxc.sm60.comp @@ -21,9 +21,13 @@ void comp_main() float3 first = WaveReadLaneFirst(20.0f.xxx); uint4 ballot_value = WaveActiveBallot(true); uint bit_count = countbits(ballot_value.x) + countbits(ballot_value.y) + countbits(ballot_value.z) + countbits(ballot_value.w); + uint shuffled = WaveReadLaneAt(10u, 8u); + uint shuffled_xor = WaveReadLaneAt(30u, WaveGetLaneIndex() ^ 8u); + uint shuffled_up = WaveReadLaneAt(20u, WaveGetLaneIndex() - 4u); + uint shuffled_down = WaveReadLaneAt(20u, WaveGetLaneIndex() + 4u); bool has_all = WaveActiveAllTrue(true); bool has_any = WaveActiveAnyTrue(true); - bool has_equal = WaveActiveAllEqualBool(true); + bool has_equal = WaveActiveAllEqual(true); float4 added = WaveActiveSum(20.0f.xxxx); int4 iadded = WaveActiveSum(int4(20, 20, 20, 20)); float4 multiplied = WaveActiveProduct(20.0f.xxxx); @@ -37,6 +41,9 @@ void comp_main() uint4 anded = WaveActiveBitAnd(ballot_value); uint4 ored = WaveActiveBitOr(ballot_value); uint4 xored = WaveActiveBitXor(ballot_value); + bool4 anded_b = bool4(WaveActiveBitAnd(uint4(bool4(ballot_value.x == uint4(42u, 42u, 42u, 42u).x, ballot_value.y == uint4(42u, 42u, 42u, 42u).y, ballot_value.z == uint4(42u, 42u, 42u, 42u).z, ballot_value.w == uint4(42u, 42u, 42u, 42u).w)))); + bool4 ored_b = bool4(WaveActiveBitOr(uint4(bool4(ballot_value.x == uint4(42u, 42u, 42u, 42u).x, ballot_value.y == uint4(42u, 42u, 42u, 42u).y, ballot_value.z == uint4(42u, 42u, 42u, 42u).z, ballot_value.w == uint4(42u, 42u, 42u, 42u).w)))); + bool4 xored_b = bool4(WaveActiveBitXor(uint4(bool4(ballot_value.x == uint4(42u, 42u, 42u, 42u).x, ballot_value.y == uint4(42u, 42u, 42u, 42u).y, ballot_value.z == uint4(42u, 42u, 42u, 42u).z, ballot_value.w == uint4(42u, 42u, 42u, 42u).w)))); added = WavePrefixSum(added) + added; iadded = WavePrefixSum(iadded) + iadded; multiplied = WavePrefixProduct(multiplied) * multiplied; diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/frag/fp16.invalid.desktop.frag b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/frag/fp16.invalid.desktop.frag index e10d6724e0..f0ed32f342 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/frag/fp16.invalid.desktop.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/frag/fp16.invalid.desktop.frag @@ -43,13 +43,13 @@ float4 mod(float4 x, float4 y) return x - y * floor(x / y); } -uint SPIRV_Cross_packFloat2x16(min16float2 value) +uint spvPackFloat2x16(min16float2 value) { uint2 Packed = f32tof16(value); return Packed.x | (Packed.y << 16); } -min16float2 SPIRV_Cross_unpackFloat2x16(uint value) +min16float2 spvUnpackFloat2x16(uint value) { return min16float2(f16tof32(uint2(value & 0xffff, value >> 16))); } @@ -128,9 +128,9 @@ void test_builtins() bool4 btmp = isnan(v4); btmp = isinf(v4); res = mad(v4, v4, v4); - uint pack0 = SPIRV_Cross_packFloat2x16(v4.xy); - uint pack1 = SPIRV_Cross_packFloat2x16(v4.zw); - res = min16float4(SPIRV_Cross_unpackFloat2x16(pack0), SPIRV_Cross_unpackFloat2x16(pack1)); + uint pack0 = spvPackFloat2x16(v4.xy); + uint pack1 = spvPackFloat2x16(v4.zw); + res = min16float4(spvUnpackFloat2x16(pack0), spvUnpackFloat2x16(pack1)); min16float t0 = length(v4); t0 = distance(v4, v4); t0 = dot(v4, v4); diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/frag/nonuniform-constructor.sm51.nonuniformresource.frag b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/frag/nonuniform-constructor.sm51.nonuniformresource.frag new file mode 100644 index 0000000000..ca9a116fe8 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/frag/nonuniform-constructor.sm51.nonuniformresource.frag @@ -0,0 +1,32 @@ +Texture2D uTex[] : register(t0, space0); +SamplerState Immut : register(s0, space1); + +static float4 FragColor; +static int vIndex; +static float2 vUV; + +struct SPIRV_Cross_Input +{ + float2 vUV : TEXCOORD0; + nointerpolation int vIndex : TEXCOORD1; +}; + +struct SPIRV_Cross_Output +{ + float4 FragColor : SV_Target0; +}; + +void frag_main() +{ + FragColor = uTex[NonUniformResourceIndex(vIndex)].Sample(Immut, vUV); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vIndex = stage_input.vIndex; + vUV = stage_input.vUV; + frag_main(); + SPIRV_Cross_Output stage_output; + stage_output.FragColor = FragColor; + return stage_output; +} diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/vert/block-io-auto-location-assignment.vert b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/vert/block-io-auto-location-assignment.vert new file mode 100644 index 0000000000..d6d64816dc --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/vert/block-io-auto-location-assignment.vert @@ -0,0 +1,37 @@ +struct Bar +{ + float v[2]; + float w; +}; + +struct V +{ + float a : TEXCOORD0; + float b[2] : TEXCOORD1; + Bar c[2] : TEXCOORD3; + Bar d : TEXCOORD9; +}; + +static V _14; + +void vert_main() +{ + _14.a = 1.0f; + _14.b[0] = 2.0f; + _14.b[1] = 3.0f; + _14.c[0].v[0] = 4.0f; + _14.c[0].v[1] = 5.0f; + _14.c[0].w = 6.0f; + _14.c[1].v[0] = 7.0f; + _14.c[1].v[1] = 8.0f; + _14.c[1].w = 9.0f; + _14.d.v[0] = 10.0f; + _14.d.v[1] = 11.0f; + _14.d.w = 12.0f; +} + +void main(out V stage_output_14) +{ + vert_main(); + stage_output_14 = _14; +} diff --git a/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/image-extract-reuse.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/image-extract-reuse.asm.frag index ed53720d94..2527d10fdc 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/image-extract-reuse.asm.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/image-extract-reuse.asm.frag @@ -8,7 +8,7 @@ struct SPIRV_Cross_Output int2 Size : SV_Target0; }; -uint2 SPIRV_Cross_textureSize(Texture2D Tex, uint Level, out uint Param) +uint2 spvTextureSize(Texture2D Tex, uint Level, out uint Param) { uint2 ret; Tex.GetDimensions(Level, ret.x, ret.y, Param); @@ -19,7 +19,7 @@ void frag_main() { uint _19_dummy_parameter; uint _20_dummy_parameter; - Size = int2(SPIRV_Cross_textureSize(uTexture, uint(0), _19_dummy_parameter)) + int2(SPIRV_Cross_textureSize(uTexture, uint(1), _20_dummy_parameter)); + Size = int2(spvTextureSize(uTexture, uint(0), _19_dummy_parameter)) + int2(spvTextureSize(uTexture, uint(1), _20_dummy_parameter)); } SPIRV_Cross_Output main() diff --git a/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/pack-and-unpack-uint2.fxconly.nofxc.sm60.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/pack-and-unpack-uint2.fxconly.nofxc.sm60.asm.frag index 525a9177ff..88fad10ff1 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/pack-and-unpack-uint2.fxconly.nofxc.sm60.asm.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/pack-and-unpack-uint2.fxconly.nofxc.sm60.asm.frag @@ -5,12 +5,12 @@ struct SPIRV_Cross_Output float4 FragColor : SV_Target0; }; -uint64_t SPIRV_Cross_packUint2x32(uint2 value) +uint64_t spvPackUint2x32(uint2 value) { return (uint64_t(value.y) << 32) | uint64_t(value.x); } -uint2 SPIRV_Cross_unpackUint2x32(uint64_t value) +uint2 spvUnpackUint2x32(uint64_t value) { uint2 Unpacked; Unpacked.x = uint(value & 0xffffffff); @@ -20,8 +20,8 @@ uint2 SPIRV_Cross_unpackUint2x32(uint64_t value) void frag_main() { - uint64_t _packed = SPIRV_Cross_packUint2x32(uint2(18u, 52u)); - uint2 unpacked = SPIRV_Cross_unpackUint2x32(_packed); + uint64_t _packed = spvPackUint2x32(uint2(18u, 52u)); + uint2 unpacked = spvUnpackUint2x32(_packed); FragColor = float4(float(unpacked.x), float(unpacked.y), 1.0f, 1.0f); } diff --git a/third_party/spirv-cross/reference/shaders-hlsl/comp/inverse.comp b/third_party/spirv-cross/reference/shaders-hlsl/comp/inverse.comp index f9ec89aa31..698f647cec 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/comp/inverse.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl/comp/inverse.comp @@ -5,7 +5,7 @@ ByteAddressBuffer _20 : register(t1); // Returns the inverse of a matrix, by using the algorithm of calculating the classical // adjoint and dividing by the determinant. The contents of the matrix are changed. -float2x2 SPIRV_Cross_Inverse(float2x2 m) +float2x2 spvInverse(float2x2 m) { float2x2 adj; // The adjoint matrix (inverse after dividing by determinant) @@ -25,29 +25,29 @@ float2x2 SPIRV_Cross_Inverse(float2x2 m) } // Returns the determinant of a 2x2 matrix. -float SPIRV_Cross_Det2x2(float a1, float a2, float b1, float b2) +float spvDet2x2(float a1, float a2, float b1, float b2) { return a1 * b2 - b1 * a2; } // Returns the inverse of a matrix, by using the algorithm of calculating the classical // adjoint and dividing by the determinant. The contents of the matrix are changed. -float3x3 SPIRV_Cross_Inverse(float3x3 m) +float3x3 spvInverse(float3x3 m) { float3x3 adj; // The adjoint matrix (inverse after dividing by determinant) // Create the transpose of the cofactors, as the classical adjoint of the matrix. - adj[0][0] = SPIRV_Cross_Det2x2(m[1][1], m[1][2], m[2][1], m[2][2]); - adj[0][1] = -SPIRV_Cross_Det2x2(m[0][1], m[0][2], m[2][1], m[2][2]); - adj[0][2] = SPIRV_Cross_Det2x2(m[0][1], m[0][2], m[1][1], m[1][2]); + adj[0][0] = spvDet2x2(m[1][1], m[1][2], m[2][1], m[2][2]); + adj[0][1] = -spvDet2x2(m[0][1], m[0][2], m[2][1], m[2][2]); + adj[0][2] = spvDet2x2(m[0][1], m[0][2], m[1][1], m[1][2]); - adj[1][0] = -SPIRV_Cross_Det2x2(m[1][0], m[1][2], m[2][0], m[2][2]); - adj[1][1] = SPIRV_Cross_Det2x2(m[0][0], m[0][2], m[2][0], m[2][2]); - adj[1][2] = -SPIRV_Cross_Det2x2(m[0][0], m[0][2], m[1][0], m[1][2]); + adj[1][0] = -spvDet2x2(m[1][0], m[1][2], m[2][0], m[2][2]); + adj[1][1] = spvDet2x2(m[0][0], m[0][2], m[2][0], m[2][2]); + adj[1][2] = -spvDet2x2(m[0][0], m[0][2], m[1][0], m[1][2]); - adj[2][0] = SPIRV_Cross_Det2x2(m[1][0], m[1][1], m[2][0], m[2][1]); - adj[2][1] = -SPIRV_Cross_Det2x2(m[0][0], m[0][1], m[2][0], m[2][1]); - adj[2][2] = SPIRV_Cross_Det2x2(m[0][0], m[0][1], m[1][0], m[1][1]); + adj[2][0] = spvDet2x2(m[1][0], m[1][1], m[2][0], m[2][1]); + adj[2][1] = -spvDet2x2(m[0][0], m[0][1], m[2][0], m[2][1]); + adj[2][2] = spvDet2x2(m[0][0], m[0][1], m[1][0], m[1][1]); // Calculate the determinant as a combination of the cofactors of the first row. float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]) + (adj[0][2] * m[2][0]); @@ -58,37 +58,37 @@ float3x3 SPIRV_Cross_Inverse(float3x3 m) } // Returns the determinant of a 3x3 matrix. -float SPIRV_Cross_Det3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3) +float spvDet3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3) { - return a1 * SPIRV_Cross_Det2x2(b2, b3, c2, c3) - b1 * SPIRV_Cross_Det2x2(a2, a3, c2, c3) + c1 * SPIRV_Cross_Det2x2(a2, a3, b2, b3); + return a1 * spvDet2x2(b2, b3, c2, c3) - b1 * spvDet2x2(a2, a3, c2, c3) + c1 * spvDet2x2(a2, a3, b2, b3); } // Returns the inverse of a matrix, by using the algorithm of calculating the classical // adjoint and dividing by the determinant. The contents of the matrix are changed. -float4x4 SPIRV_Cross_Inverse(float4x4 m) +float4x4 spvInverse(float4x4 m) { float4x4 adj; // The adjoint matrix (inverse after dividing by determinant) // Create the transpose of the cofactors, as the classical adjoint of the matrix. - adj[0][0] = SPIRV_Cross_Det3x3(m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]); - adj[0][1] = -SPIRV_Cross_Det3x3(m[0][1], m[0][2], m[0][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]); - adj[0][2] = SPIRV_Cross_Det3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[3][1], m[3][2], m[3][3]); - adj[0][3] = -SPIRV_Cross_Det3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3]); + adj[0][0] = spvDet3x3(m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]); + adj[0][1] = -spvDet3x3(m[0][1], m[0][2], m[0][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]); + adj[0][2] = spvDet3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[3][1], m[3][2], m[3][3]); + adj[0][3] = -spvDet3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3]); - adj[1][0] = -SPIRV_Cross_Det3x3(m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]); - adj[1][1] = SPIRV_Cross_Det3x3(m[0][0], m[0][2], m[0][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]); - adj[1][2] = -SPIRV_Cross_Det3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[3][0], m[3][2], m[3][3]); - adj[1][3] = SPIRV_Cross_Det3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3]); + adj[1][0] = -spvDet3x3(m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]); + adj[1][1] = spvDet3x3(m[0][0], m[0][2], m[0][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]); + adj[1][2] = -spvDet3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[3][0], m[3][2], m[3][3]); + adj[1][3] = spvDet3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3]); - adj[2][0] = SPIRV_Cross_Det3x3(m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]); - adj[2][1] = -SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]); - adj[2][2] = SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], m[3][3]); - adj[2][3] = -SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3]); + adj[2][0] = spvDet3x3(m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]); + adj[2][1] = -spvDet3x3(m[0][0], m[0][1], m[0][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]); + adj[2][2] = spvDet3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], m[3][3]); + adj[2][3] = -spvDet3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3]); - adj[3][0] = -SPIRV_Cross_Det3x3(m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]); - adj[3][1] = SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]); - adj[3][2] = -SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[3][0], m[3][1], m[3][2]); - adj[3][3] = SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2]); + adj[3][0] = -spvDet3x3(m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]); + adj[3][1] = spvDet3x3(m[0][0], m[0][1], m[0][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]); + adj[3][2] = -spvDet3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[3][0], m[3][1], m[3][2]); + adj[3][3] = spvDet3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2]); // Calculate the determinant as a combination of the cofactors of the first row. float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]) + (adj[0][2] * m[2][0]) + (adj[0][3] * m[3][0]); @@ -101,16 +101,16 @@ float4x4 SPIRV_Cross_Inverse(float4x4 m) void comp_main() { float2x2 _23 = asfloat(uint2x2(_20.Load2(0), _20.Load2(8))); - float2x2 _24 = SPIRV_Cross_Inverse(_23); + float2x2 _24 = spvInverse(_23); _15.Store2(0, asuint(_24[0])); _15.Store2(8, asuint(_24[1])); float3x3 _29 = asfloat(uint3x3(_20.Load3(16), _20.Load3(32), _20.Load3(48))); - float3x3 _30 = SPIRV_Cross_Inverse(_29); + float3x3 _30 = spvInverse(_29); _15.Store3(16, asuint(_30[0])); _15.Store3(32, asuint(_30[1])); _15.Store3(48, asuint(_30[2])); float4x4 _35 = asfloat(uint4x4(_20.Load4(64), _20.Load4(80), _20.Load4(96), _20.Load4(112))); - float4x4 _36 = SPIRV_Cross_Inverse(_35); + float4x4 _36 = spvInverse(_35); _15.Store4(64, asuint(_36[0])); _15.Store4(80, asuint(_36[1])); _15.Store4(96, asuint(_36[2])); diff --git a/third_party/spirv-cross/reference/shaders-hlsl/frag/combined-texture-sampler-parameter.frag b/third_party/spirv-cross/reference/shaders-hlsl/frag/combined-texture-sampler-parameter.frag index 7fcff423b3..66330805f1 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/frag/combined-texture-sampler-parameter.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl/frag/combined-texture-sampler-parameter.frag @@ -22,7 +22,7 @@ float4 samp3(Texture2D s, SamplerState _s_sampler) float samp4(Texture2D s, SamplerComparisonState _s_sampler) { - return s.SampleCmp(_s_sampler, 1.0f.xxx.xy, 1.0f.xxx.z); + return s.SampleCmp(_s_sampler, 1.0f.xxx.xy, 1.0f); } float samp(Texture2D s0, SamplerState _s0_sampler, Texture2D s1, SamplerComparisonState _s1_sampler) diff --git a/third_party/spirv-cross/reference/shaders-hlsl/frag/combined-texture-sampler-shadow.frag b/third_party/spirv-cross/reference/shaders-hlsl/frag/combined-texture-sampler-shadow.frag index af5b0b5579..8d48008d38 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/frag/combined-texture-sampler-shadow.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl/frag/combined-texture-sampler-shadow.frag @@ -11,7 +11,7 @@ struct SPIRV_Cross_Output float samp2(Texture2D t, SamplerComparisonState s) { - return t.SampleCmp(s, 1.0f.xxx.xy, 1.0f.xxx.z); + return t.SampleCmp(s, 1.0f.xxx.xy, 1.0f); } float samp3(Texture2D t, SamplerState s) diff --git a/third_party/spirv-cross/reference/shaders-hlsl/frag/fp16-packing.frag b/third_party/spirv-cross/reference/shaders-hlsl/frag/fp16-packing.frag index d87828225f..54b91e2aa5 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/frag/fp16-packing.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl/frag/fp16-packing.frag @@ -15,21 +15,21 @@ struct SPIRV_Cross_Output uint FP16Out : SV_Target1; }; -uint SPIRV_Cross_packHalf2x16(float2 value) +uint spvPackHalf2x16(float2 value) { uint2 Packed = f32tof16(value); return Packed.x | (Packed.y << 16); } -float2 SPIRV_Cross_unpackHalf2x16(uint value) +float2 spvUnpackHalf2x16(uint value) { return f16tof32(uint2(value & 0xffff, value >> 16)); } void frag_main() { - FP32Out = SPIRV_Cross_unpackHalf2x16(FP16); - FP16Out = SPIRV_Cross_packHalf2x16(FP32); + FP32Out = spvUnpackHalf2x16(FP16); + FP16Out = spvPackHalf2x16(FP32); } SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) diff --git a/third_party/spirv-cross/reference/shaders-hlsl/frag/image-query-selective.frag b/third_party/spirv-cross/reference/shaders-hlsl/frag/image-query-selective.frag index 25c12da669..69fe83fd28 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/frag/image-query-selective.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl/frag/image-query-selective.frag @@ -20,49 +20,49 @@ SamplerState _uSamplerMSArray_sampler : register(s8); Texture2D uSampler2D : register(t1); SamplerState _uSampler2D_sampler : register(s1); -uint SPIRV_Cross_textureSize(Texture1D Tex, uint Level, out uint Param) +uint spvTextureSize(Texture1D Tex, uint Level, out uint Param) { uint ret; Tex.GetDimensions(Level, ret.x, Param); return ret; } -uint SPIRV_Cross_textureSize(Texture1D Tex, uint Level, out uint Param) +uint spvTextureSize(Texture1D Tex, uint Level, out uint Param) { uint ret; Tex.GetDimensions(Level, ret.x, Param); return ret; } -uint SPIRV_Cross_textureSize(Texture1D Tex, uint Level, out uint Param) +uint spvTextureSize(Texture1D Tex, uint Level, out uint Param) { uint ret; Tex.GetDimensions(Level, ret.x, Param); return ret; } -uint2 SPIRV_Cross_textureSize(Texture2D Tex, uint Level, out uint Param) +uint2 spvTextureSize(Texture2D Tex, uint Level, out uint Param) { uint2 ret; Tex.GetDimensions(Level, ret.x, ret.y, Param); return ret; } -uint3 SPIRV_Cross_textureSize(Texture2DArray Tex, uint Level, out uint Param) +uint3 spvTextureSize(Texture2DArray Tex, uint Level, out uint Param) { uint3 ret; Tex.GetDimensions(Level, ret.x, ret.y, ret.z, Param); return ret; } -uint3 SPIRV_Cross_textureSize(Texture3D Tex, uint Level, out uint Param) +uint3 spvTextureSize(Texture3D Tex, uint Level, out uint Param) { uint3 ret; Tex.GetDimensions(Level, ret.x, ret.y, ret.z, Param); return ret; } -uint SPIRV_Cross_textureSize(Buffer Tex, uint Level, out uint Param) +uint spvTextureSize(Buffer Tex, uint Level, out uint Param) { uint ret; Tex.GetDimensions(ret.x); @@ -70,28 +70,28 @@ uint SPIRV_Cross_textureSize(Buffer Tex, uint Level, out uint Param) return ret; } -uint2 SPIRV_Cross_textureSize(TextureCube Tex, uint Level, out uint Param) +uint2 spvTextureSize(TextureCube Tex, uint Level, out uint Param) { uint2 ret; Tex.GetDimensions(Level, ret.x, ret.y, Param); return ret; } -uint3 SPIRV_Cross_textureSize(TextureCubeArray Tex, uint Level, out uint Param) +uint3 spvTextureSize(TextureCubeArray Tex, uint Level, out uint Param) { uint3 ret; Tex.GetDimensions(Level, ret.x, ret.y, ret.z, Param); return ret; } -uint2 SPIRV_Cross_textureSize(Texture2DMS Tex, uint Level, out uint Param) +uint2 spvTextureSize(Texture2DMS Tex, uint Level, out uint Param) { uint2 ret; Tex.GetDimensions(ret.x, ret.y, Param); return ret; } -uint3 SPIRV_Cross_textureSize(Texture2DMSArray Tex, uint Level, out uint Param) +uint3 spvTextureSize(Texture2DMSArray Tex, uint Level, out uint Param) { uint3 ret; Tex.GetDimensions(ret.x, ret.y, ret.z, Param); @@ -101,42 +101,42 @@ uint3 SPIRV_Cross_textureSize(Texture2DMSArray Tex, uint Level, out uint void frag_main() { uint _17_dummy_parameter; - int a = int(SPIRV_Cross_textureSize(uSampler1DUint, uint(0), _17_dummy_parameter)); + int a = int(spvTextureSize(uSampler1DUint, uint(0), _17_dummy_parameter)); uint _24_dummy_parameter; - a = int(SPIRV_Cross_textureSize(uSampler1DInt, uint(0), _24_dummy_parameter)); + a = int(spvTextureSize(uSampler1DInt, uint(0), _24_dummy_parameter)); uint _32_dummy_parameter; - a = int(SPIRV_Cross_textureSize(uSampler1DFloat, uint(0), _32_dummy_parameter)); + a = int(spvTextureSize(uSampler1DFloat, uint(0), _32_dummy_parameter)); uint _42_dummy_parameter; - int3 c = int3(SPIRV_Cross_textureSize(uSampler2DArray, uint(0), _42_dummy_parameter)); + int3 c = int3(spvTextureSize(uSampler2DArray, uint(0), _42_dummy_parameter)); uint _50_dummy_parameter; - int3 d = int3(SPIRV_Cross_textureSize(uSampler3D, uint(0), _50_dummy_parameter)); + int3 d = int3(spvTextureSize(uSampler3D, uint(0), _50_dummy_parameter)); uint _60_dummy_parameter; - int2 e = int2(SPIRV_Cross_textureSize(uSamplerCube, uint(0), _60_dummy_parameter)); + int2 e = int2(spvTextureSize(uSamplerCube, uint(0), _60_dummy_parameter)); uint _68_dummy_parameter; - int3 f = int3(SPIRV_Cross_textureSize(uSamplerCubeArray, uint(0), _68_dummy_parameter)); + int3 f = int3(spvTextureSize(uSamplerCubeArray, uint(0), _68_dummy_parameter)); uint _76_dummy_parameter; - int g = int(SPIRV_Cross_textureSize(uSamplerBuffer, 0u, _76_dummy_parameter)); + int g = int(spvTextureSize(uSamplerBuffer, 0u, _76_dummy_parameter)); uint _84_dummy_parameter; - int2 h = int2(SPIRV_Cross_textureSize(uSamplerMS, 0u, _84_dummy_parameter)); + int2 h = int2(spvTextureSize(uSamplerMS, 0u, _84_dummy_parameter)); uint _92_dummy_parameter; - int3 i = int3(SPIRV_Cross_textureSize(uSamplerMSArray, 0u, _92_dummy_parameter)); + int3 i = int3(spvTextureSize(uSamplerMSArray, 0u, _92_dummy_parameter)); int _100; - SPIRV_Cross_textureSize(uSampler2D, 0u, _100); + spvTextureSize(uSampler2D, 0u, _100); int l1 = int(_100); int _104; - SPIRV_Cross_textureSize(uSampler2DArray, 0u, _104); + spvTextureSize(uSampler2DArray, 0u, _104); int l2 = int(_104); int _108; - SPIRV_Cross_textureSize(uSampler3D, 0u, _108); + spvTextureSize(uSampler3D, 0u, _108); int l3 = int(_108); int _112; - SPIRV_Cross_textureSize(uSamplerCube, 0u, _112); + spvTextureSize(uSamplerCube, 0u, _112); int l4 = int(_112); int _116; - SPIRV_Cross_textureSize(uSamplerMS, 0u, _116); + spvTextureSize(uSamplerMS, 0u, _116); int s0 = int(_116); int _120; - SPIRV_Cross_textureSize(uSamplerMSArray, 0u, _120); + spvTextureSize(uSamplerMSArray, 0u, _120); int s1 = int(_120); } diff --git a/third_party/spirv-cross/reference/shaders-hlsl/frag/image-query-uav.frag b/third_party/spirv-cross/reference/shaders-hlsl/frag/image-query-uav.frag index 381a95574d..6626ed2f84 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/frag/image-query-uav.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl/frag/image-query-uav.frag @@ -4,7 +4,7 @@ RWTexture2DArray uImage2DArray : register(u2); RWTexture3D uImage3D : register(u3); RWBuffer uImageBuffer : register(u6); -uint3 SPIRV_Cross_imageSize(RWTexture2DArray Tex, out uint Param) +uint3 spvImageSize(RWTexture2DArray Tex, out uint Param) { uint3 ret; Tex.GetDimensions(ret.x, ret.y, ret.z); @@ -12,7 +12,7 @@ uint3 SPIRV_Cross_imageSize(RWTexture2DArray Tex, out uint Param) return ret; } -uint2 SPIRV_Cross_imageSize(RWTexture2D Tex, out uint Param) +uint2 spvImageSize(RWTexture2D Tex, out uint Param) { uint2 ret; Tex.GetDimensions(ret.x, ret.y); @@ -20,7 +20,7 @@ uint2 SPIRV_Cross_imageSize(RWTexture2D Tex, out uint Param) return ret; } -uint SPIRV_Cross_imageSize(RWTexture1D Tex, out uint Param) +uint spvImageSize(RWTexture1D Tex, out uint Param) { uint ret; Tex.GetDimensions(ret.x); @@ -28,7 +28,7 @@ uint SPIRV_Cross_imageSize(RWTexture1D Tex, out uint Param) return ret; } -uint3 SPIRV_Cross_imageSize(RWTexture3D Tex, out uint Param) +uint3 spvImageSize(RWTexture3D Tex, out uint Param) { uint3 ret; Tex.GetDimensions(ret.x, ret.y, ret.z); @@ -36,7 +36,7 @@ uint3 SPIRV_Cross_imageSize(RWTexture3D Tex, out uint Param) return ret; } -uint SPIRV_Cross_imageSize(RWBuffer Tex, out uint Param) +uint spvImageSize(RWBuffer Tex, out uint Param) { uint ret; Tex.GetDimensions(ret.x); @@ -47,15 +47,15 @@ uint SPIRV_Cross_imageSize(RWBuffer Tex, out uint Param) void frag_main() { uint _14_dummy_parameter; - int a = int(SPIRV_Cross_imageSize(uImage1D, _14_dummy_parameter)); + int a = int(spvImageSize(uImage1D, _14_dummy_parameter)); uint _22_dummy_parameter; - int2 b = int2(SPIRV_Cross_imageSize(uImage2D, _22_dummy_parameter)); + int2 b = int2(spvImageSize(uImage2D, _22_dummy_parameter)); uint _30_dummy_parameter; - int3 c = int3(SPIRV_Cross_imageSize(uImage2DArray, _30_dummy_parameter)); + int3 c = int3(spvImageSize(uImage2DArray, _30_dummy_parameter)); uint _36_dummy_parameter; - int3 d = int3(SPIRV_Cross_imageSize(uImage3D, _36_dummy_parameter)); + int3 d = int3(spvImageSize(uImage3D, _36_dummy_parameter)); uint _42_dummy_parameter; - int e = int(SPIRV_Cross_imageSize(uImageBuffer, _42_dummy_parameter)); + int e = int(spvImageSize(uImageBuffer, _42_dummy_parameter)); } void main() diff --git a/third_party/spirv-cross/reference/shaders-hlsl/frag/image-query-uav.nonwritable-uav-texture.frag b/third_party/spirv-cross/reference/shaders-hlsl/frag/image-query-uav.nonwritable-uav-texture.frag index 5db5d359c1..1e77c2c911 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/frag/image-query-uav.nonwritable-uav-texture.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl/frag/image-query-uav.nonwritable-uav-texture.frag @@ -4,14 +4,14 @@ Texture2DArray uImage2DArray : register(t2); RWTexture3D uImage3D : register(u3); RWBuffer uImageBuffer : register(u6); -uint3 SPIRV_Cross_textureSize(Texture2DArray Tex, uint Level, out uint Param) +uint3 spvTextureSize(Texture2DArray Tex, uint Level, out uint Param) { uint3 ret; Tex.GetDimensions(Level, ret.x, ret.y, ret.z, Param); return ret; } -uint2 SPIRV_Cross_imageSize(RWTexture2D Tex, out uint Param) +uint2 spvImageSize(RWTexture2D Tex, out uint Param) { uint2 ret; Tex.GetDimensions(ret.x, ret.y); @@ -19,7 +19,7 @@ uint2 SPIRV_Cross_imageSize(RWTexture2D Tex, out uint Param) return ret; } -uint SPIRV_Cross_imageSize(RWTexture1D Tex, out uint Param) +uint spvImageSize(RWTexture1D Tex, out uint Param) { uint ret; Tex.GetDimensions(ret.x); @@ -27,7 +27,7 @@ uint SPIRV_Cross_imageSize(RWTexture1D Tex, out uint Param) return ret; } -uint3 SPIRV_Cross_imageSize(RWTexture3D Tex, out uint Param) +uint3 spvImageSize(RWTexture3D Tex, out uint Param) { uint3 ret; Tex.GetDimensions(ret.x, ret.y, ret.z); @@ -35,7 +35,7 @@ uint3 SPIRV_Cross_imageSize(RWTexture3D Tex, out uint Param) return ret; } -uint SPIRV_Cross_imageSize(RWBuffer Tex, out uint Param) +uint spvImageSize(RWBuffer Tex, out uint Param) { uint ret; Tex.GetDimensions(ret.x); @@ -46,15 +46,15 @@ uint SPIRV_Cross_imageSize(RWBuffer Tex, out uint Param) void frag_main() { uint _14_dummy_parameter; - int a = int(SPIRV_Cross_imageSize(uImage1D, _14_dummy_parameter)); + int a = int(spvImageSize(uImage1D, _14_dummy_parameter)); uint _22_dummy_parameter; - int2 b = int2(SPIRV_Cross_imageSize(uImage2D, _22_dummy_parameter)); + int2 b = int2(spvImageSize(uImage2D, _22_dummy_parameter)); uint _30_dummy_parameter; - int3 c = int3(SPIRV_Cross_textureSize(uImage2DArray, 0u, _30_dummy_parameter)); + int3 c = int3(spvTextureSize(uImage2DArray, 0u, _30_dummy_parameter)); uint _36_dummy_parameter; - int3 d = int3(SPIRV_Cross_imageSize(uImage3D, _36_dummy_parameter)); + int3 d = int3(spvImageSize(uImage3D, _36_dummy_parameter)); uint _42_dummy_parameter; - int e = int(SPIRV_Cross_imageSize(uImageBuffer, _42_dummy_parameter)); + int e = int(spvImageSize(uImageBuffer, _42_dummy_parameter)); } void main() diff --git a/third_party/spirv-cross/reference/shaders-hlsl/frag/image-query.frag b/third_party/spirv-cross/reference/shaders-hlsl/frag/image-query.frag index 71cefc1030..0e4b26baca 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/frag/image-query.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl/frag/image-query.frag @@ -16,35 +16,35 @@ SamplerState _uSamplerMS_sampler : register(s7); Texture2DMSArray uSamplerMSArray : register(t8); SamplerState _uSamplerMSArray_sampler : register(s8); -uint SPIRV_Cross_textureSize(Texture1D Tex, uint Level, out uint Param) +uint spvTextureSize(Texture1D Tex, uint Level, out uint Param) { uint ret; Tex.GetDimensions(Level, ret.x, Param); return ret; } -uint2 SPIRV_Cross_textureSize(Texture2D Tex, uint Level, out uint Param) +uint2 spvTextureSize(Texture2D Tex, uint Level, out uint Param) { uint2 ret; Tex.GetDimensions(Level, ret.x, ret.y, Param); return ret; } -uint3 SPIRV_Cross_textureSize(Texture2DArray Tex, uint Level, out uint Param) +uint3 spvTextureSize(Texture2DArray Tex, uint Level, out uint Param) { uint3 ret; Tex.GetDimensions(Level, ret.x, ret.y, ret.z, Param); return ret; } -uint3 SPIRV_Cross_textureSize(Texture3D Tex, uint Level, out uint Param) +uint3 spvTextureSize(Texture3D Tex, uint Level, out uint Param) { uint3 ret; Tex.GetDimensions(Level, ret.x, ret.y, ret.z, Param); return ret; } -uint SPIRV_Cross_textureSize(Buffer Tex, uint Level, out uint Param) +uint spvTextureSize(Buffer Tex, uint Level, out uint Param) { uint ret; Tex.GetDimensions(ret.x); @@ -52,28 +52,28 @@ uint SPIRV_Cross_textureSize(Buffer Tex, uint Level, out uint Param) return ret; } -uint2 SPIRV_Cross_textureSize(TextureCube Tex, uint Level, out uint Param) +uint2 spvTextureSize(TextureCube Tex, uint Level, out uint Param) { uint2 ret; Tex.GetDimensions(Level, ret.x, ret.y, Param); return ret; } -uint3 SPIRV_Cross_textureSize(TextureCubeArray Tex, uint Level, out uint Param) +uint3 spvTextureSize(TextureCubeArray Tex, uint Level, out uint Param) { uint3 ret; Tex.GetDimensions(Level, ret.x, ret.y, ret.z, Param); return ret; } -uint2 SPIRV_Cross_textureSize(Texture2DMS Tex, uint Level, out uint Param) +uint2 spvTextureSize(Texture2DMS Tex, uint Level, out uint Param) { uint2 ret; Tex.GetDimensions(ret.x, ret.y, Param); return ret; } -uint3 SPIRV_Cross_textureSize(Texture2DMSArray Tex, uint Level, out uint Param) +uint3 spvTextureSize(Texture2DMSArray Tex, uint Level, out uint Param) { uint3 ret; Tex.GetDimensions(ret.x, ret.y, ret.z, Param); @@ -83,46 +83,46 @@ uint3 SPIRV_Cross_textureSize(Texture2DMSArray Tex, uint Level, out uint void frag_main() { uint _17_dummy_parameter; - int a = int(SPIRV_Cross_textureSize(uSampler1D, uint(0), _17_dummy_parameter)); + int a = int(spvTextureSize(uSampler1D, uint(0), _17_dummy_parameter)); uint _27_dummy_parameter; - int2 b = int2(SPIRV_Cross_textureSize(uSampler2D, uint(0), _27_dummy_parameter)); + int2 b = int2(spvTextureSize(uSampler2D, uint(0), _27_dummy_parameter)); uint _37_dummy_parameter; - int3 c = int3(SPIRV_Cross_textureSize(uSampler2DArray, uint(0), _37_dummy_parameter)); + int3 c = int3(spvTextureSize(uSampler2DArray, uint(0), _37_dummy_parameter)); uint _45_dummy_parameter; - int3 d = int3(SPIRV_Cross_textureSize(uSampler3D, uint(0), _45_dummy_parameter)); + int3 d = int3(spvTextureSize(uSampler3D, uint(0), _45_dummy_parameter)); uint _53_dummy_parameter; - int2 e = int2(SPIRV_Cross_textureSize(uSamplerCube, uint(0), _53_dummy_parameter)); + int2 e = int2(spvTextureSize(uSamplerCube, uint(0), _53_dummy_parameter)); uint _61_dummy_parameter; - int3 f = int3(SPIRV_Cross_textureSize(uSamplerCubeArray, uint(0), _61_dummy_parameter)); + int3 f = int3(spvTextureSize(uSamplerCubeArray, uint(0), _61_dummy_parameter)); uint _69_dummy_parameter; - int g = int(SPIRV_Cross_textureSize(uSamplerBuffer, 0u, _69_dummy_parameter)); + int g = int(spvTextureSize(uSamplerBuffer, 0u, _69_dummy_parameter)); uint _77_dummy_parameter; - int2 h = int2(SPIRV_Cross_textureSize(uSamplerMS, 0u, _77_dummy_parameter)); + int2 h = int2(spvTextureSize(uSamplerMS, 0u, _77_dummy_parameter)); uint _85_dummy_parameter; - int3 i = int3(SPIRV_Cross_textureSize(uSamplerMSArray, 0u, _85_dummy_parameter)); + int3 i = int3(spvTextureSize(uSamplerMSArray, 0u, _85_dummy_parameter)); int _89; - SPIRV_Cross_textureSize(uSampler1D, 0u, _89); + spvTextureSize(uSampler1D, 0u, _89); int l0 = int(_89); int _93; - SPIRV_Cross_textureSize(uSampler2D, 0u, _93); + spvTextureSize(uSampler2D, 0u, _93); int l1 = int(_93); int _97; - SPIRV_Cross_textureSize(uSampler2DArray, 0u, _97); + spvTextureSize(uSampler2DArray, 0u, _97); int l2 = int(_97); int _101; - SPIRV_Cross_textureSize(uSampler3D, 0u, _101); + spvTextureSize(uSampler3D, 0u, _101); int l3 = int(_101); int _105; - SPIRV_Cross_textureSize(uSamplerCube, 0u, _105); + spvTextureSize(uSamplerCube, 0u, _105); int l4 = int(_105); int _109; - SPIRV_Cross_textureSize(uSamplerCubeArray, 0u, _109); + spvTextureSize(uSamplerCubeArray, 0u, _109); int l5 = int(_109); int _113; - SPIRV_Cross_textureSize(uSamplerMS, 0u, _113); + spvTextureSize(uSamplerMS, 0u, _113); int s0 = int(_113); int _117; - SPIRV_Cross_textureSize(uSamplerMSArray, 0u, _117); + spvTextureSize(uSamplerMSArray, 0u, _117); int s1 = int(_117); } diff --git a/third_party/spirv-cross/reference/shaders-hlsl/frag/nonuniform-qualifier.nonuniformresource.sm51.frag b/third_party/spirv-cross/reference/shaders-hlsl/frag/nonuniform-qualifier.nonuniformresource.sm51.frag index a8594bf299..93f24d9afd 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/frag/nonuniform-qualifier.nonuniformresource.sm51.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl/frag/nonuniform-qualifier.nonuniformresource.sm51.frag @@ -3,12 +3,15 @@ struct UBO_1_1 float4 v[64]; }; -ConstantBuffer ubos[] : register(b0, space3); -ByteAddressBuffer ssbos[] : register(t0, space4); +ConstantBuffer ubos[] : register(b2, space9); +RWByteAddressBuffer ssbos[] : register(u3, space10); Texture2D uSamplers[] : register(t0, space0); -SamplerState uSamps[] : register(s0, space2); -Texture2D uCombinedSamplers[] : register(t0, space1); -SamplerState _uCombinedSamplers_sampler[] : register(s0, space1); +SamplerState uSamps[] : register(s1, space3); +Texture2D uCombinedSamplers[] : register(t4, space2); +SamplerState _uCombinedSamplers_sampler[] : register(s4, space2); +Texture2DMS uSamplersMS[] : register(t0, space1); +RWTexture2D uImages[] : register(u5, space7); +RWTexture2D uImagesU32[] : register(u5, space8); static int vIndex; static float4 FragColor; @@ -25,20 +28,80 @@ struct SPIRV_Cross_Output float4 FragColor : SV_Target0; }; +uint2 spvTextureSize(Texture2D Tex, uint Level, out uint Param) +{ + uint2 ret; + Tex.GetDimensions(Level, ret.x, ret.y, Param); + return ret; +} + +uint2 spvTextureSize(Texture2DMS Tex, uint Level, out uint Param) +{ + uint2 ret; + Tex.GetDimensions(ret.x, ret.y, Param); + return ret; +} + +uint2 spvImageSize(RWTexture2D Tex, out uint Param) +{ + uint2 ret; + Tex.GetDimensions(ret.x, ret.y); + Param = 0u; + return ret; +} + void frag_main() { int i = vIndex; - int _23 = i + 10; - int _34 = i + 40; - FragColor = uSamplers[NonUniformResourceIndex(_23)].Sample(uSamps[NonUniformResourceIndex(_34)], vUV); - int _50 = i + 10; - FragColor = uCombinedSamplers[NonUniformResourceIndex(_50)].Sample(_uCombinedSamplers_sampler[NonUniformResourceIndex(_50)], vUV); - int _66 = i + 20; - int _70 = i + 40; - FragColor += ubos[NonUniformResourceIndex(_66)].v[_70]; - int _84 = i + 50; + FragColor = uSamplers[NonUniformResourceIndex(i + 10)].Sample(uSamps[NonUniformResourceIndex(i + 40)], vUV); + int _49 = i + 10; + FragColor = uCombinedSamplers[NonUniformResourceIndex(_49)].Sample(_uCombinedSamplers_sampler[NonUniformResourceIndex(_49)], vUV); + int _65 = i + 20; + int _69 = i + 40; + FragColor += ubos[NonUniformResourceIndex(_65)].v[_69]; + int _83 = i + 50; int _88 = i + 60; - FragColor += asfloat(ssbos[NonUniformResourceIndex(_84)].Load4(_88 * 16 + 0)); + FragColor += asfloat(ssbos[NonUniformResourceIndex(_83)].Load4(_88 * 16 + 16)); + int _96 = i + 60; + int _100 = i + 70; + ssbos[NonUniformResourceIndex(_96)].Store4(_100 * 16 + 16, asuint(20.0f.xxxx)); + int _106 = i + 10; + FragColor = uSamplers[NonUniformResourceIndex(_106)].Load(int3(int2(vUV), 0)); + int _116 = i + 100; + uint _122; + ssbos[_116].InterlockedAdd(0, 100u, _122); + float _136_tmp = uSamplers[NonUniformResourceIndex(i + 10)].CalculateLevelOfDetail(uSamps[NonUniformResourceIndex(i + 40)], vUV); + float2 _136 = _136_tmp.xx; + float2 queried = _136; + int _139 = i + 10; + float _143_tmp = uCombinedSamplers[NonUniformResourceIndex(_139)].CalculateLevelOfDetail(_uCombinedSamplers_sampler[NonUniformResourceIndex(_139)], vUV); + float2 _143 = _143_tmp.xx; + queried += _143; + float2 _149 = FragColor.xy + queried; + FragColor = float4(_149.x, _149.y, FragColor.z, FragColor.w); + int _154 = i + 20; + int _157; + spvTextureSize(uSamplers[NonUniformResourceIndex(_154)], 0u, _157); + FragColor.x += float(int(_157)); + int _170 = i + 20; + int _174; + spvTextureSize(uSamplersMS[NonUniformResourceIndex(_170)], 0u, _174); + FragColor.y += float(int(_174)); + int _182 = i + 20; + uint _185_dummy_parameter; + float2 _189 = FragColor.xy + float2(int2(spvTextureSize(uSamplers[NonUniformResourceIndex(_182)], uint(0), _185_dummy_parameter))); + FragColor = float4(_189.x, _189.y, FragColor.z, FragColor.w); + int _198 = i + 50; + FragColor += uImages[NonUniformResourceIndex(_198)][int2(vUV)].xxxx; + int _209 = i + 20; + uint _212_dummy_parameter; + float2 _216 = FragColor.xy + float2(int2(spvImageSize(uImages[NonUniformResourceIndex(_209)], _212_dummy_parameter))); + FragColor = float4(_216.x, _216.y, FragColor.z, FragColor.w); + int _221 = i + 60; + uImages[NonUniformResourceIndex(_221)][int2(vUV)] = 50.0f.x; + int _234 = i + 70; + uint _242; + InterlockedAdd(uImagesU32[NonUniformResourceIndex(_234)][int2(vUV)], 40u, _242); } SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) diff --git a/third_party/spirv-cross/reference/shaders-hlsl/frag/scalar-refract-reflect.frag b/third_party/spirv-cross/reference/shaders-hlsl/frag/scalar-refract-reflect.frag index 0fb694c543..6c2d0be4f7 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/frag/scalar-refract-reflect.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl/frag/scalar-refract-reflect.frag @@ -11,12 +11,12 @@ struct SPIRV_Cross_Output float FragColor : SV_Target0; }; -float SPIRV_Cross_Reflect(float i, float n) +float spvReflect(float i, float n) { return i - 2.0 * dot(n, i) * n; } -float SPIRV_Cross_Refract(float i, float n, float eta) +float spvRefract(float i, float n, float eta) { float NoI = n * i; float NoI2 = NoI * NoI; @@ -33,8 +33,8 @@ float SPIRV_Cross_Refract(float i, float n, float eta) void frag_main() { - FragColor = SPIRV_Cross_Refract(vRefract.x, vRefract.y, vRefract.z); - FragColor += SPIRV_Cross_Reflect(vRefract.x, vRefract.y); + FragColor = spvRefract(vRefract.x, vRefract.y, vRefract.z); + FragColor += spvReflect(vRefract.x, vRefract.y); FragColor += refract(vRefract.xy, vRefract.yz, vRefract.z).y; FragColor += reflect(vRefract.xy, vRefract.zy).y; } diff --git a/third_party/spirv-cross/reference/shaders-hlsl/frag/texture-size-combined-image-sampler.frag b/third_party/spirv-cross/reference/shaders-hlsl/frag/texture-size-combined-image-sampler.frag index d5c373746d..dd2eb251fc 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/frag/texture-size-combined-image-sampler.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl/frag/texture-size-combined-image-sampler.frag @@ -8,7 +8,7 @@ struct SPIRV_Cross_Output int2 FooOut : SV_Target0; }; -uint2 SPIRV_Cross_textureSize(Texture2D Tex, uint Level, out uint Param) +uint2 spvTextureSize(Texture2D Tex, uint Level, out uint Param) { uint2 ret; Tex.GetDimensions(Level, ret.x, ret.y, Param); @@ -18,7 +18,7 @@ uint2 SPIRV_Cross_textureSize(Texture2D Tex, uint Level, out uint Param) void frag_main() { uint _23_dummy_parameter; - FooOut = int2(SPIRV_Cross_textureSize(uTex, uint(0), _23_dummy_parameter)); + FooOut = int2(spvTextureSize(uTex, uint(0), _23_dummy_parameter)); } SPIRV_Cross_Output main() diff --git a/third_party/spirv-cross/reference/shaders-hlsl/frag/unorm-snorm-packing.frag b/third_party/spirv-cross/reference/shaders-hlsl/frag/unorm-snorm-packing.frag index 57b5950636..0dd9ed3fa8 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/frag/unorm-snorm-packing.frag +++ b/third_party/spirv-cross/reference/shaders-hlsl/frag/unorm-snorm-packing.frag @@ -27,50 +27,50 @@ struct SPIRV_Cross_Output uint SNORM16Out : SV_Target4; }; -uint SPIRV_Cross_packUnorm4x8(float4 value) +uint spvPackUnorm4x8(float4 value) { uint4 Packed = uint4(round(saturate(value) * 255.0)); return Packed.x | (Packed.y << 8) | (Packed.z << 16) | (Packed.w << 24); } -float4 SPIRV_Cross_unpackUnorm4x8(uint value) +float4 spvUnpackUnorm4x8(uint value) { uint4 Packed = uint4(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, value >> 24); return float4(Packed) / 255.0; } -uint SPIRV_Cross_packSnorm4x8(float4 value) +uint spvPackSnorm4x8(float4 value) { int4 Packed = int4(round(clamp(value, -1.0, 1.0) * 127.0)) & 0xff; return uint(Packed.x | (Packed.y << 8) | (Packed.z << 16) | (Packed.w << 24)); } -float4 SPIRV_Cross_unpackSnorm4x8(uint value) +float4 spvUnpackSnorm4x8(uint value) { int SignedValue = int(value); int4 Packed = int4(SignedValue << 24, SignedValue << 16, SignedValue << 8, SignedValue) >> 24; return clamp(float4(Packed) / 127.0, -1.0, 1.0); } -uint SPIRV_Cross_packUnorm2x16(float2 value) +uint spvPackUnorm2x16(float2 value) { uint2 Packed = uint2(round(saturate(value) * 65535.0)); return Packed.x | (Packed.y << 16); } -float2 SPIRV_Cross_unpackUnorm2x16(uint value) +float2 spvUnpackUnorm2x16(uint value) { uint2 Packed = uint2(value & 0xffff, value >> 16); return float2(Packed) / 65535.0; } -uint SPIRV_Cross_packSnorm2x16(float2 value) +uint spvPackSnorm2x16(float2 value) { int2 Packed = int2(round(clamp(value, -1.0, 1.0) * 32767.0)) & 0xffff; return uint(Packed.x | (Packed.y << 16)); } -float2 SPIRV_Cross_unpackSnorm2x16(uint value) +float2 spvUnpackSnorm2x16(uint value) { int SignedValue = int(value); int2 Packed = int2(SignedValue << 16, SignedValue) >> 16; @@ -79,16 +79,16 @@ float2 SPIRV_Cross_unpackSnorm2x16(uint value) void frag_main() { - FP32Out = SPIRV_Cross_unpackUnorm4x8(UNORM8); - FP32Out = SPIRV_Cross_unpackSnorm4x8(SNORM8); - float2 _21 = SPIRV_Cross_unpackUnorm2x16(UNORM16); + FP32Out = spvUnpackUnorm4x8(UNORM8); + FP32Out = spvUnpackSnorm4x8(SNORM8); + float2 _21 = spvUnpackUnorm2x16(UNORM16); FP32Out = float4(_21.x, _21.y, FP32Out.z, FP32Out.w); - float2 _26 = SPIRV_Cross_unpackSnorm2x16(SNORM16); + float2 _26 = spvUnpackSnorm2x16(SNORM16); FP32Out = float4(_26.x, _26.y, FP32Out.z, FP32Out.w); - UNORM8Out = SPIRV_Cross_packUnorm4x8(FP32); - SNORM8Out = SPIRV_Cross_packSnorm4x8(FP32); - UNORM16Out = SPIRV_Cross_packUnorm2x16(FP32.xy); - SNORM16Out = SPIRV_Cross_packSnorm2x16(FP32.zw); + UNORM8Out = spvPackUnorm4x8(FP32); + SNORM8Out = spvPackSnorm4x8(FP32); + UNORM16Out = spvPackUnorm2x16(FP32.xy); + SNORM16Out = spvPackSnorm2x16(FP32.zw); } SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) diff --git a/third_party/spirv-cross/reference/shaders-hlsl/vert/invariant.vert b/third_party/spirv-cross/reference/shaders-hlsl/vert/invariant.vert new file mode 100644 index 0000000000..5473962686 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl/vert/invariant.vert @@ -0,0 +1,40 @@ +static float4 gl_Position; +static float4 vInput0; +static float4 vInput1; +static float4 vInput2; +static float4 vColor; + +struct SPIRV_Cross_Input +{ + float4 vInput0 : TEXCOORD0; + float4 vInput1 : TEXCOORD1; + float4 vInput2 : TEXCOORD2; +}; + +struct SPIRV_Cross_Output +{ + precise float4 vColor : TEXCOORD0; + precise float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + float4 _20 = vInput1 * vInput2; + float4 _21 = vInput0 + _20; + gl_Position = _21; + float4 _27 = vInput0 - vInput1; + float4 _29 = _27 * vInput2; + vColor = _29; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vInput0 = stage_input.vInput0; + vInput1 = stage_input.vInput1; + vInput2 = stage_input.vInput2; + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + stage_output.vColor = vColor; + return stage_output; +} diff --git a/third_party/spirv-cross/reference/shaders-hlsl/vert/no-contraction.vert b/third_party/spirv-cross/reference/shaders-hlsl/vert/no-contraction.vert new file mode 100644 index 0000000000..ad37dc23f1 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl/vert/no-contraction.vert @@ -0,0 +1,45 @@ +static float4 gl_Position; +static float4 vA; +static float4 vB; +static float4 vC; + +struct SPIRV_Cross_Input +{ + float4 vA : TEXCOORD0; + float4 vB : TEXCOORD1; + float4 vC : TEXCOORD2; +}; + +struct SPIRV_Cross_Output +{ + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + precise float4 _15 = vA * vB; + float4 mul = _15; + precise float4 _19 = vA + vB; + float4 add = _19; + precise float4 _23 = vA - vB; + float4 sub = _23; + precise float4 _27 = vA * vB; + precise float4 _30 = _27 + vC; + float4 mad = _30; + precise float4 _34 = mul + add; + precise float4 _36 = _34 + sub; + precise float4 _38 = _36 + mad; + float4 summed = _38; + gl_Position = summed; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + vA = stage_input.vA; + vB = stage_input.vB; + vC = stage_input.vC; + vert_main(); + SPIRV_Cross_Output stage_output; + stage_output.gl_Position = gl_Position; + return stage_output; +} diff --git a/third_party/spirv-cross/reference/shaders-hlsl/vert/return-array.vert b/third_party/spirv-cross/reference/shaders-hlsl/vert/return-array.vert index 83e3a28123..3e021257bd 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/vert/return-array.vert +++ b/third_party/spirv-cross/reference/shaders-hlsl/vert/return-array.vert @@ -15,17 +15,17 @@ struct SPIRV_Cross_Output float4 gl_Position : SV_Position; }; -void test(out float4 SPIRV_Cross_return_value[2]) +void test(out float4 spvReturnValue[2]) { - SPIRV_Cross_return_value = _20; + spvReturnValue = _20; } -void test2(out float4 SPIRV_Cross_return_value[2]) +void test2(out float4 spvReturnValue[2]) { float4 foobar[2]; foobar[0] = vInput0; foobar[1] = vInput1; - SPIRV_Cross_return_value = foobar; + spvReturnValue = foobar; } void vert_main() diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/eliminate-globals-not-in-entry-point.noeliminate.spv14.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/eliminate-globals-not-in-entry-point.noeliminate.spv14.asm.comp new file mode 100644 index 0000000000..e265f1bd97 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/eliminate-globals-not-in-entry-point.noeliminate.spv14.asm.comp @@ -0,0 +1,23 @@ +#include +#include + +using namespace metal; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(64u, 1u, 1u); + +struct UBO +{ + float v; +}; + +struct SSBO +{ + float v; +}; + +kernel void main0() +{ + threadgroup float w; + float v; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/fixup-entry-point-identifier.nomain.asm.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/fixup-entry-point-identifier.nomain.asm.frag new file mode 100644 index 0000000000..9a5e195b48 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/fixup-entry-point-identifier.nomain.asm.frag @@ -0,0 +1,17 @@ +#include +#include + +using namespace metal; + +struct _5ma_in_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment _5ma_in_out _5ma_in() +{ + _5ma_in_out out = {}; + out.FragColor = float4(1.0); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/only-initializer-frag-depth.asm.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/only-initializer-frag-depth.asm.frag new file mode 100644 index 0000000000..3f552ebbd0 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/only-initializer-frag-depth.asm.frag @@ -0,0 +1,17 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float gl_FragDepth [[depth(any)]]; +}; + +fragment main0_out main0() +{ + main0_out out = {}; + out.gl_FragDepth = 0.5; + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/reserved-function-identifier.asm.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/reserved-function-identifier.asm.frag new file mode 100644 index 0000000000..5c8ec371e3 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/reserved-function-identifier.asm.frag @@ -0,0 +1,33 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_out +{ + float FragColor [[color(0)]]; +}; + +static inline __attribute__((always_inline)) +float _mat3(thread const float& a) +{ + return a + 1.0; +} + +static inline __attribute__((always_inline)) +float _RESERVED_IDENTIFIER_FIXUP_gl_Foo(thread const int& a) +{ + return float(a) + 1.0; +} + +fragment main0_out main0() +{ + main0_out out = {}; + float param = 2.0; + int param_1 = 4; + out.FragColor = _mat3(param) + _RESERVED_IDENTIFIER_FIXUP_gl_Foo(param_1); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/texture-access.swizzle.asm.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/texture-access.swizzle.asm.frag index 9d71a91e43..6c4cc7248b 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/texture-access.swizzle.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/texture-access.swizzle.asm.frag @@ -150,29 +150,29 @@ fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d c = spvTextureSwizzle(texCube.sample(texCubeSamp, float3(0.0)), texCubeSwzl); c = spvTextureSwizzle(tex2dArray.sample(tex2dArraySamp, float3(0.0).xy, uint(round(float3(0.0).z))), tex2dArraySwzl); c = spvTextureSwizzle(texCubeArray.sample(texCubeArraySamp, float4(0.0).xyz, uint(round(float4(0.0).w))), texCubeArraySwzl); - c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSamp, float3(0.0, 0.0, 1.0).xy, float3(0.0, 0.0, 1.0).z), depth2dSwzl); - c.x = spvTextureSwizzle(depthCube.sample_compare(depthCubeSamp, float4(0.0, 0.0, 0.0, 1.0).xyz, float4(0.0, 0.0, 0.0, 1.0).w), depthCubeSwzl); - c.x = spvTextureSwizzle(depth2dArray.sample_compare(depth2dArraySamp, float4(0.0, 0.0, 0.0, 1.0).xy, uint(round(float4(0.0, 0.0, 0.0, 1.0).z)), float4(0.0, 0.0, 0.0, 1.0).w), depth2dArraySwzl); + c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSamp, float3(0.0, 0.0, 1.0).xy, 1.0), depth2dSwzl); + c.x = spvTextureSwizzle(depthCube.sample_compare(depthCubeSamp, float4(0.0, 0.0, 0.0, 1.0).xyz, 1.0), depthCubeSwzl); + c.x = spvTextureSwizzle(depth2dArray.sample_compare(depth2dArraySamp, float4(0.0, 0.0, 0.0, 1.0).xy, uint(round(float4(0.0, 0.0, 0.0, 1.0).z)), 1.0), depth2dArraySwzl); c.x = spvTextureSwizzle(depthCubeArray.sample_compare(depthCubeArraySamp, float4(0.0).xyz, uint(round(float4(0.0).w)), 1.0), depthCubeArraySwzl); c = spvTextureSwizzle(tex1d.sample(tex1dSamp, float2(0.0, 1.0).x / float2(0.0, 1.0).y), tex1dSwzl); c = spvTextureSwizzle(tex2d.sample(tex2dSamp, float3(0.0, 0.0, 1.0).xy / float3(0.0, 0.0, 1.0).z), tex2dSwzl); c = spvTextureSwizzle(tex3d.sample(tex3dSamp, float4(0.0, 0.0, 0.0, 1.0).xyz / float4(0.0, 0.0, 0.0, 1.0).w), tex3dSwzl); float4 _152 = float4(0.0, 0.0, 1.0, 1.0); - _152.z = float4(0.0, 0.0, 1.0, 1.0).w; - c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSamp, _152.xy / _152.z, float4(0.0, 0.0, 1.0, 1.0).z / _152.z), depth2dSwzl); + _152.z = 1.0; + c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSamp, _152.xy / _152.z, 1.0 / _152.z), depth2dSwzl); c = spvTextureSwizzle(tex1d.sample(tex1dSamp, 0.0), tex1dSwzl); c = spvTextureSwizzle(tex2d.sample(tex2dSamp, float2(0.0), level(0.0)), tex2dSwzl); c = spvTextureSwizzle(tex3d.sample(tex3dSamp, float3(0.0), level(0.0)), tex3dSwzl); c = spvTextureSwizzle(texCube.sample(texCubeSamp, float3(0.0), level(0.0)), texCubeSwzl); c = spvTextureSwizzle(tex2dArray.sample(tex2dArraySamp, float3(0.0).xy, uint(round(float3(0.0).z)), level(0.0)), tex2dArraySwzl); c = spvTextureSwizzle(texCubeArray.sample(texCubeArraySamp, float4(0.0).xyz, uint(round(float4(0.0).w)), level(0.0)), texCubeArraySwzl); - c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSamp, float3(0.0, 0.0, 1.0).xy, float3(0.0, 0.0, 1.0).z, level(0.0)), depth2dSwzl); + c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSamp, float3(0.0, 0.0, 1.0).xy, 1.0, level(0.0)), depth2dSwzl); c = spvTextureSwizzle(tex1d.sample(tex1dSamp, float2(0.0, 1.0).x / float2(0.0, 1.0).y), tex1dSwzl); c = spvTextureSwizzle(tex2d.sample(tex2dSamp, float3(0.0, 0.0, 1.0).xy / float3(0.0, 0.0, 1.0).z, level(0.0)), tex2dSwzl); c = spvTextureSwizzle(tex3d.sample(tex3dSamp, float4(0.0, 0.0, 0.0, 1.0).xyz / float4(0.0, 0.0, 0.0, 1.0).w, level(0.0)), tex3dSwzl); float4 _202 = float4(0.0, 0.0, 1.0, 1.0); - _202.z = float4(0.0, 0.0, 1.0, 1.0).w; - c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSamp, _202.xy / _202.z, float4(0.0, 0.0, 1.0, 1.0).z / _202.z, level(0.0)), depth2dSwzl); + _202.z = 1.0; + c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSamp, _202.xy / _202.z, 1.0 / _202.z, level(0.0)), depth2dSwzl); c = spvTextureSwizzle(tex1d.read(uint(0)), tex1dSwzl); c = spvTextureSwizzle(tex2d.read(uint2(int2(0)), 0), tex2dSwzl); c = spvTextureSwizzle(tex3d.read(uint3(int3(0)), 0), tex3dSwzl); diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-0.msl2.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-0.msl2.asm.tesc new file mode 100644 index 0000000000..3bfaf352dc --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-0.msl2.asm.tesc @@ -0,0 +1,82 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct C +{ + float4 v; +}; + +struct P +{ + float4 v; +}; + +struct main0_out +{ + float4 gl_Position; + float gl_PointSize; +}; + +struct main0_patchOut +{ + float4 P_v; +}; + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + spvUnsafeArray _18 = spvUnsafeArray({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); + + threadgroup C c[4]; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + c[gl_InvocationID] = _18[gl_InvocationID]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + patchOut.P_v = float4(0.0); + c[gl_InvocationID].v = float4(1.0); + patchOut.P_v = float4(2.0); + gl_out[gl_InvocationID].gl_Position = float4(3.0); + gl_out[gl_InvocationID].gl_PointSize = 4.0; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-0.multi-patch.msl2.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-0.multi-patch.msl2.asm.tesc new file mode 100644 index 0000000000..874874088f --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-0.multi-patch.msl2.asm.tesc @@ -0,0 +1,85 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct C +{ + float4 v; +}; + +struct P +{ + float4 v; +}; + +struct main0_out +{ + float4 gl_Position; + float gl_PointSize; +}; + +struct main0_patchOut +{ + float4 P_v; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + spvUnsafeArray _18 = spvUnsafeArray({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); + + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + threadgroup C spvStoragec[8][4]; + threadgroup C (&c)[4] = spvStoragec[(gl_GlobalInvocationID.x / 4) % 8]; + c[gl_GlobalInvocationID.x % 4] = _18[gl_GlobalInvocationID.x % 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; + patchOut.P_v = float4(0.0); + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + c[gl_InvocationID].v = float4(1.0); + patchOut.P_v = float4(2.0); + gl_out[gl_InvocationID].gl_Position = float4(3.0); + gl_out[gl_InvocationID].gl_PointSize = 4.0; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-1.msl2.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-1.msl2.asm.tesc new file mode 100644 index 0000000000..6a507dd5c4 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-1.msl2.asm.tesc @@ -0,0 +1,81 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct C +{ + float4 v; +}; + +struct P +{ + float4 v; +}; + +struct main0_out +{ + float4 C_v; + float4 gl_Position; + float gl_PointSize; +}; + +struct main0_patchOut +{ +}; +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + spvUnsafeArray _18 = spvUnsafeArray({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); + + threadgroup P p; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + gl_out[gl_InvocationID].C_v = _18[gl_InvocationID].v; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + p = P{ float4(0.0) }; + gl_out[gl_InvocationID].C_v = float4(1.0); + p.v = float4(2.0); + gl_out[gl_InvocationID].gl_Position = float4(3.0); + gl_out[gl_InvocationID].gl_PointSize = 4.0; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-1.multi-patch.msl2.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-1.multi-patch.msl2.asm.tesc new file mode 100644 index 0000000000..04d19bb869 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-1.multi-patch.msl2.asm.tesc @@ -0,0 +1,84 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct C +{ + float4 v; +}; + +struct P +{ + float4 v; +}; + +struct main0_out +{ + float4 C_v; + float4 gl_Position; + float gl_PointSize; +}; + +struct main0_patchOut +{ +}; +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + spvUnsafeArray _18 = spvUnsafeArray({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); + + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + gl_out[gl_GlobalInvocationID.x % 4].C_v = _18[gl_GlobalInvocationID.x % 4].v; + device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; + threadgroup P spvStoragep[8]; + threadgroup P (&p) = spvStoragep[(gl_GlobalInvocationID.x / 4) % 8]; + p = P{ float4(0.0) }; + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + gl_out[gl_InvocationID].C_v = float4(1.0); + p.v = float4(2.0); + gl_out[gl_InvocationID].gl_Position = float4(3.0); + gl_out[gl_InvocationID].gl_PointSize = 4.0; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-point-size.msl2.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-point-size.msl2.asm.tesc new file mode 100644 index 0000000000..fc872a1a6c --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-point-size.msl2.asm.tesc @@ -0,0 +1,100 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct C +{ + float4 v; +}; + +struct P +{ + float4 v; +}; + +struct gl_PerVertex +{ + float4 gl_Position; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +constant spvUnsafeArray _51 = spvUnsafeArray({ 0.0 }); +constant spvUnsafeArray _52 = spvUnsafeArray({ 0.0 }); + +struct main0_out +{ + float4 C_v; + float4 gl_Position; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +struct main0_patchOut +{ + float4 P_v; +}; + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + spvUnsafeArray _18 = spvUnsafeArray({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); + spvUnsafeArray _33 = spvUnsafeArray({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); + + threadgroup gl_PerVertex gl_out_masked[4]; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + gl_out[gl_InvocationID].C_v = _18[gl_InvocationID].v; + gl_out[gl_InvocationID].gl_Position = _33[gl_InvocationID].gl_Position; + gl_out[gl_InvocationID].gl_ClipDistance = _33[gl_InvocationID].gl_ClipDistance; + gl_out[gl_InvocationID].gl_CullDistance = _33[gl_InvocationID].gl_CullDistance; + gl_out_masked[gl_InvocationID] = _33[gl_InvocationID]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + patchOut.P_v = float4(0.0); + gl_out[gl_InvocationID].C_v = float4(1.0); + patchOut.P_v = float4(2.0); + gl_out[gl_InvocationID].gl_Position = float4(3.0); + gl_out_masked[gl_InvocationID].gl_PointSize = 4.0; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-point-size.multi-patch.msl2.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-point-size.multi-patch.msl2.asm.tesc new file mode 100644 index 0000000000..5394741b1e --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-point-size.multi-patch.msl2.asm.tesc @@ -0,0 +1,103 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct C +{ + float4 v; +}; + +struct P +{ + float4 v; +}; + +struct gl_PerVertex +{ + float4 gl_Position; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +constant spvUnsafeArray _51 = spvUnsafeArray({ 0.0 }); +constant spvUnsafeArray _52 = spvUnsafeArray({ 0.0 }); + +struct main0_out +{ + float4 C_v; + float4 gl_Position; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +struct main0_patchOut +{ + float4 P_v; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + spvUnsafeArray _18 = spvUnsafeArray({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); + spvUnsafeArray _33 = spvUnsafeArray({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); + + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + gl_out[gl_GlobalInvocationID.x % 4].C_v = _18[gl_GlobalInvocationID.x % 4].v; + gl_out[gl_GlobalInvocationID.x % 4].gl_Position = _33[gl_GlobalInvocationID.x % 4].gl_Position; + gl_out[gl_GlobalInvocationID.x % 4].gl_ClipDistance = _33[gl_GlobalInvocationID.x % 4].gl_ClipDistance; + gl_out[gl_GlobalInvocationID.x % 4].gl_CullDistance = _33[gl_GlobalInvocationID.x % 4].gl_CullDistance; + threadgroup gl_PerVertex spvStoragegl_out_masked[8][4]; + threadgroup gl_PerVertex (&gl_out_masked)[4] = spvStoragegl_out_masked[(gl_GlobalInvocationID.x / 4) % 8]; + gl_out_masked[gl_GlobalInvocationID.x % 4] = _33[gl_GlobalInvocationID.x % 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; + patchOut.P_v = float4(0.0); + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + gl_out[gl_InvocationID].C_v = float4(1.0); + patchOut.P_v = float4(2.0); + gl_out[gl_InvocationID].gl_Position = float4(3.0); + gl_out_masked[gl_InvocationID].gl_PointSize = 4.0; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-position.msl2.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-position.msl2.asm.tesc new file mode 100644 index 0000000000..62b528b9fd --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-position.msl2.asm.tesc @@ -0,0 +1,100 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct C +{ + float4 v; +}; + +struct P +{ + float4 v; +}; + +struct gl_PerVertex +{ + float4 gl_Position; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +constant spvUnsafeArray _51 = spvUnsafeArray({ 0.0 }); +constant spvUnsafeArray _52 = spvUnsafeArray({ 0.0 }); + +struct main0_out +{ + float4 C_v; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +struct main0_patchOut +{ + float4 P_v; +}; + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + spvUnsafeArray _18 = spvUnsafeArray({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); + spvUnsafeArray _33 = spvUnsafeArray({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); + + threadgroup gl_PerVertex gl_out_masked[4]; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + gl_out[gl_InvocationID].C_v = _18[gl_InvocationID].v; + gl_out[gl_InvocationID].gl_PointSize = _33[gl_InvocationID].gl_PointSize; + gl_out[gl_InvocationID].gl_ClipDistance = _33[gl_InvocationID].gl_ClipDistance; + gl_out[gl_InvocationID].gl_CullDistance = _33[gl_InvocationID].gl_CullDistance; + gl_out_masked[gl_InvocationID] = _33[gl_InvocationID]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + patchOut.P_v = float4(0.0); + gl_out[gl_InvocationID].C_v = float4(1.0); + patchOut.P_v = float4(2.0); + gl_out_masked[gl_InvocationID].gl_Position = float4(3.0); + gl_out[gl_InvocationID].gl_PointSize = 4.0; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-position.multi-patch.msl2.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-position.multi-patch.msl2.asm.tesc new file mode 100644 index 0000000000..a6790894df --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers-block.mask-position.multi-patch.msl2.asm.tesc @@ -0,0 +1,103 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct C +{ + float4 v; +}; + +struct P +{ + float4 v; +}; + +struct gl_PerVertex +{ + float4 gl_Position; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +constant spvUnsafeArray _51 = spvUnsafeArray({ 0.0 }); +constant spvUnsafeArray _52 = spvUnsafeArray({ 0.0 }); + +struct main0_out +{ + float4 C_v; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +struct main0_patchOut +{ + float4 P_v; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + spvUnsafeArray _18 = spvUnsafeArray({ C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) }, C{ float4(0.0) } }); + spvUnsafeArray _33 = spvUnsafeArray({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); + + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + gl_out[gl_GlobalInvocationID.x % 4].C_v = _18[gl_GlobalInvocationID.x % 4].v; + gl_out[gl_GlobalInvocationID.x % 4].gl_PointSize = _33[gl_GlobalInvocationID.x % 4].gl_PointSize; + gl_out[gl_GlobalInvocationID.x % 4].gl_ClipDistance = _33[gl_GlobalInvocationID.x % 4].gl_ClipDistance; + gl_out[gl_GlobalInvocationID.x % 4].gl_CullDistance = _33[gl_GlobalInvocationID.x % 4].gl_CullDistance; + threadgroup gl_PerVertex spvStoragegl_out_masked[8][4]; + threadgroup gl_PerVertex (&gl_out_masked)[4] = spvStoragegl_out_masked[(gl_GlobalInvocationID.x / 4) % 8]; + gl_out_masked[gl_GlobalInvocationID.x % 4] = _33[gl_GlobalInvocationID.x % 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; + patchOut.P_v = float4(0.0); + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + gl_out[gl_InvocationID].C_v = float4(1.0); + patchOut.P_v = float4(2.0); + gl_out_masked[gl_InvocationID].gl_Position = float4(3.0); + gl_out[gl_InvocationID].gl_PointSize = 4.0; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-0.msl2.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-0.msl2.asm.tesc new file mode 100644 index 0000000000..25fe13bf67 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-0.msl2.asm.tesc @@ -0,0 +1,90 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex +{ + float4 _RESERVED_IDENTIFIER_FIXUP_gl_Position; + float _RESERVED_IDENTIFIER_FIXUP_gl_PointSize; + spvUnsafeArray _RESERVED_IDENTIFIER_FIXUP_gl_ClipDistance; + spvUnsafeArray _RESERVED_IDENTIFIER_FIXUP_gl_CullDistance; +}; + +constant spvUnsafeArray _15 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); +constant spvUnsafeArray _45 = spvUnsafeArray({ 0.0 }); +constant spvUnsafeArray _46 = spvUnsafeArray({ 0.0 }); + +struct main0_out +{ + float4 gl_Position; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +struct main0_patchOut +{ + float4 foo_patch; +}; + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4> _29 = spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4>({ _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); + + threadgroup float4 foo[4]; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + foo[gl_InvocationID] = _15[gl_InvocationID]; + gl_out[gl_InvocationID].gl_Position = _29[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_Position; + gl_out[gl_InvocationID].gl_PointSize = _29[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_PointSize; + gl_out[gl_InvocationID].gl_ClipDistance = _29[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_ClipDistance; + gl_out[gl_InvocationID].gl_CullDistance = _29[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_CullDistance; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + patchOut.foo_patch = float4(0.0); + foo[gl_InvocationID] = float4(1.0); + patchOut.foo_patch = float4(2.0); + gl_out[gl_InvocationID].gl_Position = float4(3.0); + gl_out[gl_InvocationID].gl_PointSize = 4.0; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-0.msl2.multi-patch.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-0.msl2.multi-patch.asm.tesc new file mode 100644 index 0000000000..750ef96d17 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-0.msl2.multi-patch.asm.tesc @@ -0,0 +1,93 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex +{ + float4 _RESERVED_IDENTIFIER_FIXUP_gl_Position; + float _RESERVED_IDENTIFIER_FIXUP_gl_PointSize; + spvUnsafeArray _RESERVED_IDENTIFIER_FIXUP_gl_ClipDistance; + spvUnsafeArray _RESERVED_IDENTIFIER_FIXUP_gl_CullDistance; +}; + +constant spvUnsafeArray _15 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); +constant spvUnsafeArray _45 = spvUnsafeArray({ 0.0 }); +constant spvUnsafeArray _46 = spvUnsafeArray({ 0.0 }); + +struct main0_out +{ + float4 gl_Position; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +struct main0_patchOut +{ + float4 foo_patch; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4> _29 = spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4>({ _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); + + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + threadgroup float4 spvStoragefoo[8][4]; + threadgroup float4 (&foo)[4] = spvStoragefoo[(gl_GlobalInvocationID.x / 4) % 8]; + foo[gl_GlobalInvocationID.x % 4] = _15[gl_GlobalInvocationID.x % 4]; + gl_out[gl_GlobalInvocationID.x % 4].gl_Position = _29[gl_GlobalInvocationID.x % 4]._RESERVED_IDENTIFIER_FIXUP_gl_Position; + gl_out[gl_GlobalInvocationID.x % 4].gl_PointSize = _29[gl_GlobalInvocationID.x % 4]._RESERVED_IDENTIFIER_FIXUP_gl_PointSize; + gl_out[gl_GlobalInvocationID.x % 4].gl_ClipDistance = _29[gl_GlobalInvocationID.x % 4]._RESERVED_IDENTIFIER_FIXUP_gl_ClipDistance; + gl_out[gl_GlobalInvocationID.x % 4].gl_CullDistance = _29[gl_GlobalInvocationID.x % 4]._RESERVED_IDENTIFIER_FIXUP_gl_CullDistance; + device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; + patchOut.foo_patch = float4(0.0); + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + foo[gl_InvocationID] = float4(1.0); + patchOut.foo_patch = float4(2.0); + gl_out[gl_InvocationID].gl_Position = float4(3.0); + gl_out[gl_InvocationID].gl_PointSize = 4.0; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-1.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-1.asm.tesc new file mode 100644 index 0000000000..e8f1146b42 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-1.asm.tesc @@ -0,0 +1,89 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex +{ + float4 _RESERVED_IDENTIFIER_FIXUP_gl_Position; + float _RESERVED_IDENTIFIER_FIXUP_gl_PointSize; + spvUnsafeArray _RESERVED_IDENTIFIER_FIXUP_gl_ClipDistance; + spvUnsafeArray _RESERVED_IDENTIFIER_FIXUP_gl_CullDistance; +}; + +constant spvUnsafeArray _15 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); +constant spvUnsafeArray _45 = spvUnsafeArray({ 0.0 }); +constant spvUnsafeArray _46 = spvUnsafeArray({ 0.0 }); + +struct main0_out +{ + float4 foo; + float4 gl_Position; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +struct main0_patchOut +{ +}; +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4> _29 = spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4>({ _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); + + threadgroup float4 foo_patch; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + gl_out[gl_InvocationID].foo = _15[gl_InvocationID]; + gl_out[gl_InvocationID].gl_Position = _29[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_Position; + gl_out[gl_InvocationID].gl_PointSize = _29[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_PointSize; + gl_out[gl_InvocationID].gl_ClipDistance = _29[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_ClipDistance; + gl_out[gl_InvocationID].gl_CullDistance = _29[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_CullDistance; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + foo_patch = float4(0.0); + gl_out[gl_InvocationID].foo = float4(1.0); + foo_patch = float4(2.0); + gl_out[gl_InvocationID].gl_Position = float4(3.0); + gl_out[gl_InvocationID].gl_PointSize = 4.0; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-1.multi-patch.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-1.multi-patch.asm.tesc new file mode 100644 index 0000000000..a7c1e5d617 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-location-1.multi-patch.asm.tesc @@ -0,0 +1,92 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex +{ + float4 _RESERVED_IDENTIFIER_FIXUP_gl_Position; + float _RESERVED_IDENTIFIER_FIXUP_gl_PointSize; + spvUnsafeArray _RESERVED_IDENTIFIER_FIXUP_gl_ClipDistance; + spvUnsafeArray _RESERVED_IDENTIFIER_FIXUP_gl_CullDistance; +}; + +constant spvUnsafeArray _15 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); +constant spvUnsafeArray _45 = spvUnsafeArray({ 0.0 }); +constant spvUnsafeArray _46 = spvUnsafeArray({ 0.0 }); + +struct main0_out +{ + float4 foo; + float4 gl_Position; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +struct main0_patchOut +{ +}; +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4> _29 = spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4>({ _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); + + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + gl_out[gl_GlobalInvocationID.x % 4].foo = _15[gl_GlobalInvocationID.x % 4]; + gl_out[gl_GlobalInvocationID.x % 4].gl_Position = _29[gl_GlobalInvocationID.x % 4]._RESERVED_IDENTIFIER_FIXUP_gl_Position; + gl_out[gl_GlobalInvocationID.x % 4].gl_PointSize = _29[gl_GlobalInvocationID.x % 4]._RESERVED_IDENTIFIER_FIXUP_gl_PointSize; + gl_out[gl_GlobalInvocationID.x % 4].gl_ClipDistance = _29[gl_GlobalInvocationID.x % 4]._RESERVED_IDENTIFIER_FIXUP_gl_ClipDistance; + gl_out[gl_GlobalInvocationID.x % 4].gl_CullDistance = _29[gl_GlobalInvocationID.x % 4]._RESERVED_IDENTIFIER_FIXUP_gl_CullDistance; + device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; + threadgroup float4 spvStoragefoo_patch[8]; + threadgroup float4 (&foo_patch) = spvStoragefoo_patch[(gl_GlobalInvocationID.x / 4) % 8]; + foo_patch = float4(0.0); + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + gl_out[gl_InvocationID].foo = float4(1.0); + foo_patch = float4(2.0); + gl_out[gl_InvocationID].gl_Position = float4(3.0); + gl_out[gl_InvocationID].gl_PointSize = 4.0; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-point-size.msl2.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-point-size.msl2.asm.tesc new file mode 100644 index 0000000000..344751b04c --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-point-size.msl2.asm.tesc @@ -0,0 +1,90 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct gl_PerVertex +{ + float4 gl_Position; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +constant spvUnsafeArray _15 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); +constant spvUnsafeArray _45 = spvUnsafeArray({ 0.0 }); +constant spvUnsafeArray _46 = spvUnsafeArray({ 0.0 }); + +struct main0_out +{ + float4 foo; + float4 gl_Position; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +struct main0_patchOut +{ + float4 foo_patch; +}; + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + spvUnsafeArray _29 = spvUnsafeArray({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); + + threadgroup gl_PerVertex gl_out_masked[4]; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + gl_out[gl_InvocationID].foo = _15[gl_InvocationID]; + gl_out[gl_InvocationID].gl_Position = _29[gl_InvocationID].gl_Position; + gl_out[gl_InvocationID].gl_ClipDistance = _29[gl_InvocationID].gl_ClipDistance; + gl_out[gl_InvocationID].gl_CullDistance = _29[gl_InvocationID].gl_CullDistance; + gl_out_masked[gl_InvocationID] = _29[gl_InvocationID]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + patchOut.foo_patch = float4(0.0); + gl_out[gl_InvocationID].foo = float4(1.0); + patchOut.foo_patch = float4(2.0); + gl_out[gl_InvocationID].gl_Position = float4(3.0); + gl_out_masked[gl_InvocationID].gl_PointSize = 4.0; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-point-size.msl2.multi-patch.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-point-size.msl2.multi-patch.asm.tesc new file mode 100644 index 0000000000..92731ec03a --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-point-size.msl2.multi-patch.asm.tesc @@ -0,0 +1,93 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct gl_PerVertex +{ + float4 gl_Position; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +constant spvUnsafeArray _15 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); +constant spvUnsafeArray _45 = spvUnsafeArray({ 0.0 }); +constant spvUnsafeArray _46 = spvUnsafeArray({ 0.0 }); + +struct main0_out +{ + float4 foo; + float4 gl_Position; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +struct main0_patchOut +{ + float4 foo_patch; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + spvUnsafeArray _29 = spvUnsafeArray({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); + + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + gl_out[gl_GlobalInvocationID.x % 4].foo = _15[gl_GlobalInvocationID.x % 4]; + gl_out[gl_GlobalInvocationID.x % 4].gl_Position = _29[gl_GlobalInvocationID.x % 4].gl_Position; + gl_out[gl_GlobalInvocationID.x % 4].gl_ClipDistance = _29[gl_GlobalInvocationID.x % 4].gl_ClipDistance; + gl_out[gl_GlobalInvocationID.x % 4].gl_CullDistance = _29[gl_GlobalInvocationID.x % 4].gl_CullDistance; + threadgroup gl_PerVertex spvStoragegl_out_masked[8][4]; + threadgroup gl_PerVertex (&gl_out_masked)[4] = spvStoragegl_out_masked[(gl_GlobalInvocationID.x / 4) % 8]; + gl_out_masked[gl_GlobalInvocationID.x % 4] = _29[gl_GlobalInvocationID.x % 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; + patchOut.foo_patch = float4(0.0); + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + gl_out[gl_InvocationID].foo = float4(1.0); + patchOut.foo_patch = float4(2.0); + gl_out[gl_InvocationID].gl_Position = float4(3.0); + gl_out_masked[gl_InvocationID].gl_PointSize = 4.0; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-position.msl2.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-position.msl2.asm.tesc new file mode 100644 index 0000000000..2f11636a0c --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-position.msl2.asm.tesc @@ -0,0 +1,90 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct gl_PerVertex +{ + float4 gl_Position; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +constant spvUnsafeArray _15 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); +constant spvUnsafeArray _45 = spvUnsafeArray({ 0.0 }); +constant spvUnsafeArray _46 = spvUnsafeArray({ 0.0 }); + +struct main0_out +{ + float4 foo; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +struct main0_patchOut +{ + float4 foo_patch; +}; + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + spvUnsafeArray _29 = spvUnsafeArray({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); + + threadgroup gl_PerVertex gl_out_masked[4]; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + gl_out[gl_InvocationID].foo = _15[gl_InvocationID]; + gl_out[gl_InvocationID].gl_PointSize = _29[gl_InvocationID].gl_PointSize; + gl_out[gl_InvocationID].gl_ClipDistance = _29[gl_InvocationID].gl_ClipDistance; + gl_out[gl_InvocationID].gl_CullDistance = _29[gl_InvocationID].gl_CullDistance; + gl_out_masked[gl_InvocationID] = _29[gl_InvocationID]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + patchOut.foo_patch = float4(0.0); + gl_out[gl_InvocationID].foo = float4(1.0); + patchOut.foo_patch = float4(2.0); + gl_out_masked[gl_InvocationID].gl_Position = float4(3.0); + gl_out[gl_InvocationID].gl_PointSize = 4.0; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-position.msl2.multi-patch.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-position.msl2.multi-patch.asm.tesc new file mode 100644 index 0000000000..7283eddb1f --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/masking/initializers.mask-position.msl2.multi-patch.asm.tesc @@ -0,0 +1,93 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct gl_PerVertex +{ + float4 gl_Position; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +constant spvUnsafeArray _15 = spvUnsafeArray({ float4(0.0), float4(0.0), float4(0.0), float4(0.0) }); +constant spvUnsafeArray _45 = spvUnsafeArray({ 0.0 }); +constant spvUnsafeArray _46 = spvUnsafeArray({ 0.0 }); + +struct main0_out +{ + float4 foo; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +struct main0_patchOut +{ + float4 foo_patch; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + spvUnsafeArray _29 = spvUnsafeArray({ gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) }, gl_PerVertex{ float4(0.0), 0.0, spvUnsafeArray({ 0.0 }), spvUnsafeArray({ 0.0 }) } }); + + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + gl_out[gl_GlobalInvocationID.x % 4].foo = _15[gl_GlobalInvocationID.x % 4]; + gl_out[gl_GlobalInvocationID.x % 4].gl_PointSize = _29[gl_GlobalInvocationID.x % 4].gl_PointSize; + gl_out[gl_GlobalInvocationID.x % 4].gl_ClipDistance = _29[gl_GlobalInvocationID.x % 4].gl_ClipDistance; + gl_out[gl_GlobalInvocationID.x % 4].gl_CullDistance = _29[gl_GlobalInvocationID.x % 4].gl_CullDistance; + threadgroup gl_PerVertex spvStoragegl_out_masked[8][4]; + threadgroup gl_PerVertex (&gl_out_masked)[4] = spvStoragegl_out_masked[(gl_GlobalInvocationID.x / 4) % 8]; + gl_out_masked[gl_GlobalInvocationID.x % 4] = _29[gl_GlobalInvocationID.x % 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; + patchOut.foo_patch = float4(0.0); + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + gl_out[gl_InvocationID].foo = float4(1.0); + patchOut.foo_patch = float4(2.0); + gl_out_masked[gl_InvocationID].gl_Position = float4(3.0); + gl_out[gl_InvocationID].gl_PointSize = 4.0; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/array-control-point-initializer.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/array-control-point-initializer.asm.tesc new file mode 100644 index 0000000000..5c30e05a4b --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/array-control-point-initializer.asm.tesc @@ -0,0 +1,65 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +constant spvUnsafeArray _49 = spvUnsafeArray({ 0.0, 0.0, 0.0 }); +constant spvUnsafeArray, 4> _27 = spvUnsafeArray, 4>({ spvUnsafeArray({ 0.0, 0.0, 0.0 }), spvUnsafeArray({ 0.0, 0.0, 0.0 }), spvUnsafeArray({ 0.0, 0.0, 0.0 }), spvUnsafeArray({ 0.0, 0.0, 0.0 }) }); + +struct main0_out +{ + spvUnsafeArray foo; + float4 gl_Position; +}; + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + gl_out[gl_InvocationID].foo = _27[gl_InvocationID]; + gl_out[gl_InvocationID].gl_Position = float4(1.0); + gl_out[gl_InvocationID].foo[0] = float(gl_InvocationID); + gl_out[gl_InvocationID].foo[1] = float(gl_InvocationID) + 1.0; + gl_out[gl_InvocationID].foo[2] = float(gl_InvocationID) + 2.0; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/block-control-point-initializer.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/block-control-point-initializer.asm.tesc new file mode 100644 index 0000000000..0efeb36ecf --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/block-control-point-initializer.asm.tesc @@ -0,0 +1,70 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct Verts +{ + float a; + float2 b; +}; + +struct main0_out +{ + float Verts_a; + float2 Verts_b; + float4 gl_Position; +}; + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + spvUnsafeArray _27 = spvUnsafeArray({ Verts{ 0.0, float2(0.0) }, Verts{ 0.0, float2(0.0) }, Verts{ 0.0, float2(0.0) }, Verts{ 0.0, float2(0.0) } }); + + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + gl_out[gl_InvocationID].Verts_a = _27[gl_InvocationID].a; + gl_out[gl_InvocationID].Verts_b = _27[gl_InvocationID].b; + gl_out[gl_InvocationID].gl_Position = float4(1.0); + gl_out[gl_InvocationID].Verts_a = float(gl_InvocationID); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/builtin-control-point-initializer.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/builtin-control-point-initializer.asm.tesc new file mode 100644 index 0000000000..8777212b46 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/builtin-control-point-initializer.asm.tesc @@ -0,0 +1,80 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex +{ + float4 _RESERVED_IDENTIFIER_FIXUP_gl_Position; + float _RESERVED_IDENTIFIER_FIXUP_gl_PointSize; +}; + +struct Verts +{ + float a; + float2 b; +}; + +struct main0_out +{ + float Verts_a; + float2 Verts_b; + float4 gl_Position; + float gl_PointSize; +}; + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4> _17 = spvUnsafeArray<_RESERVED_IDENTIFIER_FIXUP_gl_PerVertex, 4>({ _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0 }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0 }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0 }, _RESERVED_IDENTIFIER_FIXUP_gl_PerVertex{ float4(0.0), 0.0 } }); + spvUnsafeArray _27 = spvUnsafeArray({ Verts{ 0.0, float2(0.0) }, Verts{ 0.0, float2(0.0) }, Verts{ 0.0, float2(0.0) }, Verts{ 0.0, float2(0.0) } }); + + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + gl_out[gl_InvocationID].gl_Position = _17[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_Position; + gl_out[gl_InvocationID].gl_PointSize = _17[gl_InvocationID]._RESERVED_IDENTIFIER_FIXUP_gl_PointSize; + gl_out[gl_InvocationID].Verts_a = _27[gl_InvocationID].a; + gl_out[gl_InvocationID].Verts_b = _27[gl_InvocationID].b; + gl_out[gl_InvocationID].gl_Position = float4(1.0); + gl_out[gl_InvocationID].Verts_a = float(gl_InvocationID); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/composite-control-point-initializer.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/composite-control-point-initializer.asm.tesc new file mode 100644 index 0000000000..a10731bb28 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/composite-control-point-initializer.asm.tesc @@ -0,0 +1,69 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct Foo +{ + float a; + float2 b; + float4 c; +}; + +struct main0_out +{ + Foo foo; + float4 gl_Position; +}; + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + spvUnsafeArray _27 = spvUnsafeArray({ Foo{ 0.0, float2(0.0), float4(0.0) }, Foo{ 0.0, float2(0.0), float4(0.0) }, Foo{ 0.0, float2(0.0), float4(0.0) }, Foo{ 0.0, float2(0.0), float4(0.0) } }); + + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + gl_out[gl_InvocationID].foo = _27[gl_InvocationID]; + gl_out[gl_InvocationID].gl_Position = float4(1.0); + gl_out[gl_InvocationID].foo.a = float(gl_InvocationID); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/copy-memory-control-point.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/copy-memory-control-point.asm.tesc new file mode 100644 index 0000000000..b7246ac570 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/copy-memory-control-point.asm.tesc @@ -0,0 +1,125 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct cb1_struct +{ + float4 _m0[1]; +}; + +struct main0_out +{ + float3 vocp0; + float4 vocp1; +}; + +struct main0_in +{ + float4 v0 [[attribute(0)]]; + float4 v1 [[attribute(1)]]; + float3 vicp0 [[attribute(2)]]; + float4 vicp1 [[attribute(4)]]; +}; + +static inline __attribute__((always_inline)) +void fork0_epilogue(thread const float4& _87, thread const float4& _88, thread const float4& _89, device half (&gl_TessLevelOuter)[3]) +{ + gl_TessLevelOuter[0u] = half(_87.x); + gl_TessLevelOuter[1u] = half(_88.x); + gl_TessLevelOuter[2u] = half(_89.x); +} + +static inline __attribute__((always_inline)) +void fork0(uint vForkInstanceId, device half (&gl_TessLevelOuter)[3], thread spvUnsafeArray& opc, constant cb1_struct& cb0_0, thread float4& v_48, thread float4& v_49, thread float4& v_50) +{ + float4 r0; + r0.x = as_type(vForkInstanceId); + opc[as_type(r0.x)].x = cb0_0._m0[0u].x; + v_48 = opc[0u]; + v_49 = opc[1u]; + v_50 = opc[2u]; + fork0_epilogue(v_48, v_49, v_50, gl_TessLevelOuter); +} + +static inline __attribute__((always_inline)) +void fork1_epilogue(thread const float4& _109, device half &gl_TessLevelInner) +{ + gl_TessLevelInner = half(_109.x); +} + +static inline __attribute__((always_inline)) +void fork1(device half &gl_TessLevelInner, thread spvUnsafeArray& opc, constant cb1_struct& cb0_0, thread float4& v_56) +{ + opc[3u].x = cb0_0._m0[0u].x; + v_56 = opc[3u]; + fork1_epilogue(v_56, gl_TessLevelInner); +} + +kernel void main0(main0_in in [[stage_in]], constant cb1_struct& cb0_0 [[buffer(0)]], uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLTriangleTessellationFactorsHalf* spvTessLevel [[buffer(26)]], threadgroup main0_in* gl_in [[threadgroup(0)]]) +{ + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 3]; + if (gl_InvocationID < spvIndirectParams[0]) + gl_in[gl_InvocationID] = in; + threadgroup_barrier(mem_flags::mem_threadgroup); + if (gl_InvocationID >= 3) + return; + spvUnsafeArray, 2> vicp; + spvUnsafeArray _153 = spvUnsafeArray({ gl_in[0].v0, gl_in[1].v0, gl_in[2].v0 }); + vicp[0u] = _153; + spvUnsafeArray _154 = spvUnsafeArray({ gl_in[0].v1, gl_in[1].v1, gl_in[2].v1 }); + vicp[1u] = _154; + gl_out[gl_InvocationID].vocp0 = gl_in[gl_InvocationID].vicp0; + gl_out[gl_InvocationID].vocp1 = gl_in[gl_InvocationID].vicp1; + spvUnsafeArray opc; + float4 v_48; + float4 v_49; + float4 v_50; + fork0(0u, spvTessLevel[gl_PrimitiveID].edgeTessellationFactor, opc, cb0_0, v_48, v_49, v_50); + fork0(1u, spvTessLevel[gl_PrimitiveID].edgeTessellationFactor, opc, cb0_0, v_48, v_49, v_50); + fork0(2u, spvTessLevel[gl_PrimitiveID].edgeTessellationFactor, opc, cb0_0, v_48, v_49, v_50); + float4 v_56; + fork1(spvTessLevel[gl_PrimitiveID].insideTessellationFactor, opc, cb0_0, v_56); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/copy-tess-level-tri.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/copy-tess-level-tri.asm.tesc new file mode 100644 index 0000000000..a492cb829c --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/copy-tess-level-tri.asm.tesc @@ -0,0 +1,68 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +constant spvUnsafeArray _19 = spvUnsafeArray({ 1.0, 2.0 }); +constant spvUnsafeArray _25 = spvUnsafeArray({ 1.0, 2.0, 3.0, 4.0 }); + +struct main0_out +{ + float4 gl_Position; +}; + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLTriangleTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 1]; + spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(_19[0]); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(_25[0]); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1] = half(_25[1]); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2] = half(_25[2]); + spvUnsafeArray inner; + inner = spvUnsafeArray({ float(spvTessLevel[gl_PrimitiveID].insideTessellationFactor), 0.0 }); + spvUnsafeArray outer; + outer = spvUnsafeArray({ float(spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0]), float(spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1]), float(spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2]), 0.0 }); + gl_out[gl_InvocationID].gl_Position = float4(1.0); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/plain-control-point-initializer.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/plain-control-point-initializer.asm.tesc new file mode 100644 index 0000000000..0c6c1dc813 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/plain-control-point-initializer.asm.tesc @@ -0,0 +1,62 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +constant spvUnsafeArray _25 = spvUnsafeArray({ 0.0, 0.0, 0.0, 0.0 }); + +struct main0_out +{ + float v; + float4 gl_Position; +}; + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + gl_out[gl_InvocationID].v = _25[gl_InvocationID]; + gl_out[gl_InvocationID].gl_Position = float4(1.0); + gl_out[gl_InvocationID].v = float(gl_InvocationID); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-fixed-input-array-builtin-array.invalid.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-fixed-input-array-builtin-array.invalid.asm.tesc index 2c83e9e420..32b9e4a9fa 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-fixed-input-array-builtin-array.invalid.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-fixed-input-array-builtin-array.invalid.asm.tesc @@ -85,7 +85,7 @@ struct main0_in }; static inline __attribute__((always_inline)) -HSOut _hs_main(thread const spvUnsafeArray (&p), thread const uint& i) +HSOut _hs_main(thread const spvUnsafeArray& p, thread const uint& i) { HSOut _output; _output.pos = p[i].pos; @@ -94,7 +94,7 @@ HSOut _hs_main(thread const spvUnsafeArray (&p), thread const u } static inline __attribute__((always_inline)) -HSConstantOut PatchHS(thread const spvUnsafeArray (&_patch)) +HSConstantOut PatchHS(thread const spvUnsafeArray& _patch) { HSConstantOut _output; _output.EdgeTess[0] = (float2(1.0) + _patch[0].uv).x; diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-fixed-input-array-builtin-array.invalid.multi-patch.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-fixed-input-array-builtin-array.invalid.multi-patch.asm.tesc index 0d8a50012e..dabe1b3857 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-fixed-input-array-builtin-array.invalid.multi-patch.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-fixed-input-array-builtin-array.invalid.multi-patch.asm.tesc @@ -64,7 +64,7 @@ struct HSConstantOut struct VertexOutput_1 { - float3 uv; + float2 uv; }; struct HSOut_1 @@ -80,13 +80,13 @@ struct main0_out struct main0_in { - float3 VertexOutput_uv; - ushort2 m_172; + VertexOutput_1 p; + ushort2 m_171; float4 gl_Position; }; static inline __attribute__((always_inline)) -HSOut _hs_main(thread const spvUnsafeArray (&p), thread const uint& i) +HSOut _hs_main(thread const spvUnsafeArray& p, thread const uint& i) { HSOut _output; _output.pos = p[i].pos; @@ -95,7 +95,7 @@ HSOut _hs_main(thread const spvUnsafeArray (&p), thread const u } static inline __attribute__((always_inline)) -HSConstantOut PatchHS(thread const spvUnsafeArray (&_patch)) +HSConstantOut PatchHS(thread const spvUnsafeArray& _patch) { HSConstantOut _output; _output.EdgeTess[0] = (float2(1.0) + _patch[0].uv).x; @@ -110,14 +110,14 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 3]; device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 3, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; uint gl_InvocationID = gl_GlobalInvocationID.x % 3; - uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 3, spvIndirectParams[1]); + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 3, spvIndirectParams[1] - 1); spvUnsafeArray p; p[0].pos = gl_in[0].gl_Position; - p[0].uv = gl_in[0].VertexOutput_uv.xy; + p[0].uv = gl_in[0].p.uv; p[1].pos = gl_in[1].gl_Position; - p[1].uv = gl_in[1].VertexOutput_uv.xy; + p[1].uv = gl_in[1].p.uv; p[2].pos = gl_in[2].gl_Position; - p[2].uv = gl_in[2].VertexOutput_uv.xy; + p[2].uv = gl_in[2].p.uv; uint i = gl_InvocationID; spvUnsafeArray param; param = p; diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-level-initializer-quad.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-level-initializer-quad.asm.tesc new file mode 100644 index 0000000000..d6d0bc0149 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-level-initializer-quad.asm.tesc @@ -0,0 +1,78 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +constant spvUnsafeArray _27 = spvUnsafeArray({ 0.0, 0.0 }); +constant spvUnsafeArray _33 = spvUnsafeArray({ 0.0, 0.0, 0.0, 0.0 }); + +struct main0_out +{ + float4 gl_Position; +}; + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(0.0); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1] = half(0.0); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2] = half(0.0); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[3] = half(0.0); + spvTessLevel[gl_PrimitiveID].insideTessellationFactor[0] = half(0.0); + spvTessLevel[gl_PrimitiveID].insideTessellationFactor[1] = half(0.0); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(0.0); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1] = half(0.0); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2] = half(0.0); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[3] = half(0.0); + spvTessLevel[gl_PrimitiveID].insideTessellationFactor[0] = half(0.0); + spvTessLevel[gl_PrimitiveID].insideTessellationFactor[1] = half(0.0); + gl_out[gl_InvocationID].gl_Position = float4(1.0); + spvTessLevel[gl_PrimitiveID].insideTessellationFactor[0] = half(1.0); + spvTessLevel[gl_PrimitiveID].insideTessellationFactor[1] = half(2.0); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(3.0); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1] = half(4.0); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2] = half(5.0); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[3] = half(6.0); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-level-initializer-triangle.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-level-initializer-triangle.asm.tesc new file mode 100644 index 0000000000..979f4329f5 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-level-initializer-triangle.asm.tesc @@ -0,0 +1,72 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +constant spvUnsafeArray _27 = spvUnsafeArray({ 0.0, 0.0 }); +constant spvUnsafeArray _33 = spvUnsafeArray({ 0.0, 0.0, 0.0, 0.0 }); + +struct main0_out +{ + float4 gl_Position; +}; + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLTriangleTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(0.0); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1] = half(0.0); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2] = half(0.0); + spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(0.0); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(0.0); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1] = half(0.0); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2] = half(0.0); + spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(0.0); + gl_out[gl_InvocationID].gl_Position = float4(1.0); + spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(1.0); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(3.0); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1] = half(4.0); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2] = half(5.0); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-level-read-write-in-function-tri.asm.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-level-read-write-in-function-tri.asm.tesc new file mode 100644 index 0000000000..b6e40bc835 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tesc/tess-level-read-write-in-function-tri.asm.tesc @@ -0,0 +1,35 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 gl_Position; +}; + +static inline __attribute__((always_inline)) +void store_tess_level_in_func(device half &gl_TessLevelInner, device half (&gl_TessLevelOuter)[3]) +{ + gl_TessLevelInner = half(1.0); + gl_TessLevelOuter[0] = half(3.0); + gl_TessLevelOuter[1] = half(4.0); + gl_TessLevelOuter[2] = half(5.0); +} + +static inline __attribute__((always_inline)) +float load_tess_level_in_func(device half &gl_TessLevelInner, device half (&gl_TessLevelOuter)[3]) +{ + return float(gl_TessLevelInner) + float(gl_TessLevelOuter[1]); +} + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLTriangleTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 1]; + store_tess_level_in_func(spvTessLevel[gl_PrimitiveID].insideTessellationFactor, spvTessLevel[gl_PrimitiveID].edgeTessellationFactor); + float v = load_tess_level_in_func(spvTessLevel[gl_PrimitiveID].insideTessellationFactor, spvTessLevel[gl_PrimitiveID].edgeTessellationFactor); + gl_out[gl_InvocationID].gl_Position = float4(v); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tese/copy-tess-level.asm.msl2.tese b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tese/copy-tess-level.asm.msl2.tese new file mode 100644 index 0000000000..e34fd66eed --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tese/copy-tess-level.asm.msl2.tese @@ -0,0 +1,73 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 out_var_CUSTOM_VALUE [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_patchIn +{ + float4 gl_TessLevelOuter [[attribute(0)]]; + float2 gl_TessLevelInner [[attribute(1)]]; +}; + +[[ patch(quad, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]]) +{ + main0_out out = {}; + spvUnsafeArray gl_TessLevelOuter = {}; + spvUnsafeArray gl_TessLevelInner = {}; + gl_TessLevelOuter[0] = patchIn.gl_TessLevelOuter.x; + gl_TessLevelOuter[1] = patchIn.gl_TessLevelOuter.y; + gl_TessLevelOuter[2] = patchIn.gl_TessLevelOuter.z; + gl_TessLevelOuter[3] = patchIn.gl_TessLevelOuter.w; + gl_TessLevelInner[0] = patchIn.gl_TessLevelInner.x; + gl_TessLevelInner[1] = patchIn.gl_TessLevelInner.y; + out.out_var_CUSTOM_VALUE = float4(gl_TessLevelOuter[0] + gl_TessLevelInner[0], gl_TessLevelOuter[1] + gl_TessLevelInner[1], gl_TessLevelOuter[2], gl_TessLevelOuter[3]); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tese/split-access-chain.asm.tese b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tese/split-access-chain.asm.tese new file mode 100644 index 0000000000..05a8113331 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/tese/split-access-chain.asm.tese @@ -0,0 +1,28 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float o0 [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 in0 [[attribute(0)]]; +}; + +struct main0_patchIn +{ + patch_control_point gl_in; +}; + +[[ patch(quad, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]]) +{ + main0_out out = {}; + out.o0 = patchIn.gl_in[0u].in0.z; + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/block-struct-initializer.asm.vert b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/block-struct-initializer.asm.vert new file mode 100644 index 0000000000..f2d813a3f7 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/block-struct-initializer.asm.vert @@ -0,0 +1,39 @@ +#include +#include + +using namespace metal; + +struct Vert +{ + float a; + float b; +}; + +struct Foo +{ + float c; + float d; +}; + +struct main0_out +{ + float Vert_a [[user(locn0)]]; + float Vert_b [[user(locn1)]]; + float Foo_c [[user(locn2)]]; + float Foo_d [[user(locn3)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0() +{ + main0_out out = {}; + Vert _3 = Vert{ 0.0, 0.0 }; + Foo foo = Foo{ 0.0, 0.0 }; + out.gl_Position = float4(0.0); + out.Vert_a = _3.a; + out.Vert_b = _3.b; + out.Foo_c = foo.c; + out.Foo_d = foo.d; + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/builtin-output-initializer.asm.vert b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/builtin-output-initializer.asm.vert new file mode 100644 index 0000000000..54b88ba9c6 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/builtin-output-initializer.asm.vert @@ -0,0 +1,20 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 gl_Position [[position]]; + float gl_PointSize [[point_size]]; +}; + +vertex main0_out main0() +{ + main0_out out = {}; + out.gl_Position = float4(0.0); + out.gl_PointSize = 0.0; + out.gl_Position = float4(1.0); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/duplicate-view-index.asm.vert b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/duplicate-view-index.asm.vert new file mode 100644 index 0000000000..f007a67f22 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/duplicate-view-index.asm.vert @@ -0,0 +1,19 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 gl_Position [[position]]; + uint gl_Layer [[render_target_array_index]]; +}; + +vertex main0_out main0(uint gl_InstanceIndex [[instance_id]], uint gl_BaseInstance [[base_instance]]) +{ + main0_out out = {}; + const uint gl_ViewIndex = 0; + out.gl_Position = float4(float(int(gl_ViewIndex))); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/pointer-to-pointer.asm.vert b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/pointer-to-pointer.asm.vert new file mode 100644 index 0000000000..750afcf25b --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/pointer-to-pointer.asm.vert @@ -0,0 +1,20 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +device float* thread * constant _9 = {}; + +static inline __attribute__((always_inline)) +void _10(device float* thread * const thread & _11) +{ +} + +vertex void main0() +{ + device float* thread * _14 = _9; + _10(_14); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl12.emulate-subgroup.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl12.emulate-subgroup.comp new file mode 100644 index 0000000000..651991e351 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl12.emulate-subgroup.comp @@ -0,0 +1,30 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + float FragColor; +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); + +kernel void main0(device SSBO& _9 [[buffer(0)]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], unsupported-built-in-type gl_WorkGroupSize [[unsupported-built-in]]) +{ + uint gl_NumSubgroups = gl_WorkGroupSize.x * gl_WorkGroupSize.y * gl_WorkGroupSize.z; + uint gl_SubgroupID = gl_LocalInvocationIndex; + uint gl_SubgroupSize = 1; + uint gl_SubgroupInvocationID = 0; + _9.FragColor = float(gl_NumSubgroups); + _9.FragColor = float(gl_SubgroupID); + _9.FragColor = float(gl_SubgroupSize); + _9.FragColor = float(gl_SubgroupInvocationID); + threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture); + threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture); + threadgroup_barrier(mem_flags::mem_device); + threadgroup_barrier(mem_flags::mem_threadgroup); + threadgroup_barrier(mem_flags::mem_texture); + bool elected = true; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl21.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl21.comp index 6ad48b485e..b7f2ed5888 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl21.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl21.comp @@ -242,7 +242,8 @@ kernel void main0(device SSBO& _9 [[buffer(0)]], uint gl_NumSubgroups [[simdgrou simdgroup_barrier(mem_flags::mem_device); simdgroup_barrier(mem_flags::mem_threadgroup); simdgroup_barrier(mem_flags::mem_texture); - bool elected = simd_is_first(); + bool _39 = simd_is_first(); + bool elected = _39; _9.FragColor = float4(gl_SubgroupEqMask).x; _9.FragColor = float4(gl_SubgroupGeMask).x; _9.FragColor = float4(gl_SubgroupGtMask).x; @@ -287,6 +288,9 @@ kernel void main0(device SSBO& _9 [[buffer(0)]], uint gl_NumSubgroups [[simdgrou uint4 anded = simd_and(ballot_value); uint4 ored = simd_or(ballot_value); uint4 xored = simd_xor(ballot_value); + bool4 anded_b = simd_and(ballot_value == uint4(42u)); + bool4 ored_b = simd_or(ballot_value == uint4(42u)); + bool4 xored_b = simd_xor(ballot_value == uint4(42u)); added = simd_prefix_inclusive_sum(added); iadded = simd_prefix_inclusive_sum(iadded); multiplied = simd_prefix_inclusive_product(multiplied); @@ -308,6 +312,9 @@ kernel void main0(device SSBO& _9 [[buffer(0)]], uint gl_NumSubgroups [[simdgrou anded = quad_and(anded); ored = quad_or(ored); xored = quad_xor(xored); + anded_b = quad_and(anded == uint4(2u)); + ored_b = quad_or(ored == uint4(3u)); + xored_b = quad_xor(xored == uint4(4u)); float4 swap_horiz = spvQuadSwap(float4(20.0), 0u); bool4 swap_horiz_bool = spvQuadSwap(bool4(true), 0u); float4 swap_vertical = spvQuadSwap(float4(20.0), 1u); diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl21.fixed-subgroup.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl21.fixed-subgroup.comp new file mode 100644 index 0000000000..0f6cbfe41b --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl21.fixed-subgroup.comp @@ -0,0 +1,322 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct SSBO +{ + float FragColor; +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); + +template +inline T spvSubgroupBroadcast(T value, ushort lane) +{ + return simd_broadcast(value, lane); +} + +template<> +inline bool spvSubgroupBroadcast(bool value, ushort lane) +{ + return !!simd_broadcast((ushort)value, lane); +} + +template +inline vec spvSubgroupBroadcast(vec value, ushort lane) +{ + return (vec)simd_broadcast((vec)value, lane); +} + +template +inline T spvSubgroupBroadcastFirst(T value) +{ + return simd_broadcast_first(value); +} + +template<> +inline bool spvSubgroupBroadcastFirst(bool value) +{ + return !!simd_broadcast_first((ushort)value); +} + +template +inline vec spvSubgroupBroadcastFirst(vec value) +{ + return (vec)simd_broadcast_first((vec)value); +} + +inline uint4 spvSubgroupBallot(bool value) +{ + simd_vote vote = simd_ballot(value); + // simd_ballot() returns a 64-bit integer-like object, but + // SPIR-V callers expect a uint4. We must convert. + // FIXME: This won't include higher bits if Apple ever supports + // 128 lanes in an SIMD-group. + return uint4((uint)((simd_vote::vote_t)vote & 0xFFFFFFFF), (uint)(((simd_vote::vote_t)vote >> 32) & 0xFFFFFFFF), 0, 0); +} + +inline bool spvSubgroupBallotBitExtract(uint4 ballot, uint bit) +{ + return !!extract_bits(ballot[bit / 32], bit % 32, 1); +} + +inline uint spvSubgroupBallotFindLSB(uint4 ballot, uint gl_SubgroupSize) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupSize, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupSize - 32, 0)), uint2(0)); + ballot &= mask; + return select(ctz(ballot.x), select(32 + ctz(ballot.y), select(64 + ctz(ballot.z), select(96 + ctz(ballot.w), uint(-1), ballot.w == 0), ballot.z == 0), ballot.y == 0), ballot.x == 0); +} + +inline uint spvSubgroupBallotFindMSB(uint4 ballot, uint gl_SubgroupSize) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupSize, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupSize - 32, 0)), uint2(0)); + ballot &= mask; + return select(128 - (clz(ballot.w) + 1), select(96 - (clz(ballot.z) + 1), select(64 - (clz(ballot.y) + 1), select(32 - (clz(ballot.x) + 1), uint(-1), ballot.x == 0), ballot.y == 0), ballot.z == 0), ballot.w == 0); +} + +inline uint spvPopCount4(uint4 ballot) +{ + return popcount(ballot.x) + popcount(ballot.y) + popcount(ballot.z) + popcount(ballot.w); +} + +inline uint spvSubgroupBallotBitCount(uint4 ballot, uint gl_SubgroupSize) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupSize, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupSize - 32, 0)), uint2(0)); + return spvPopCount4(ballot & mask); +} + +inline uint spvSubgroupBallotInclusiveBitCount(uint4 ballot, uint gl_SubgroupInvocationID) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID + 1, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID + 1 - 32, 0)), uint2(0)); + return spvPopCount4(ballot & mask); +} + +inline uint spvSubgroupBallotExclusiveBitCount(uint4 ballot, uint gl_SubgroupInvocationID) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID - 32, 0)), uint2(0)); + return spvPopCount4(ballot & mask); +} + +template +inline bool spvSubgroupAllEqual(T value) +{ + return simd_all(all(value == simd_broadcast_first(value))); +} + +template<> +inline bool spvSubgroupAllEqual(bool value) +{ + return simd_all(value) || !simd_any(value); +} + +template +inline bool spvSubgroupAllEqual(vec value) +{ + return simd_all(all(value == (vec)simd_broadcast_first((vec)value))); +} + +template +inline T spvSubgroupShuffle(T value, ushort lane) +{ + return simd_shuffle(value, lane); +} + +template<> +inline bool spvSubgroupShuffle(bool value, ushort lane) +{ + return !!simd_shuffle((ushort)value, lane); +} + +template +inline vec spvSubgroupShuffle(vec value, ushort lane) +{ + return (vec)simd_shuffle((vec)value, lane); +} + +template +inline T spvSubgroupShuffleXor(T value, ushort mask) +{ + return simd_shuffle_xor(value, mask); +} + +template<> +inline bool spvSubgroupShuffleXor(bool value, ushort mask) +{ + return !!simd_shuffle_xor((ushort)value, mask); +} + +template +inline vec spvSubgroupShuffleXor(vec value, ushort mask) +{ + return (vec)simd_shuffle_xor((vec)value, mask); +} + +template +inline T spvSubgroupShuffleUp(T value, ushort delta) +{ + return simd_shuffle_up(value, delta); +} + +template<> +inline bool spvSubgroupShuffleUp(bool value, ushort delta) +{ + return !!simd_shuffle_up((ushort)value, delta); +} + +template +inline vec spvSubgroupShuffleUp(vec value, ushort delta) +{ + return (vec)simd_shuffle_up((vec)value, delta); +} + +template +inline T spvSubgroupShuffleDown(T value, ushort delta) +{ + return simd_shuffle_down(value, delta); +} + +template<> +inline bool spvSubgroupShuffleDown(bool value, ushort delta) +{ + return !!simd_shuffle_down((ushort)value, delta); +} + +template +inline vec spvSubgroupShuffleDown(vec value, ushort delta) +{ + return (vec)simd_shuffle_down((vec)value, delta); +} + +template +inline T spvQuadBroadcast(T value, uint lane) +{ + return quad_broadcast(value, lane); +} + +template<> +inline bool spvQuadBroadcast(bool value, uint lane) +{ + return !!quad_broadcast((ushort)value, lane); +} + +template +inline vec spvQuadBroadcast(vec value, uint lane) +{ + return (vec)quad_broadcast((vec)value, lane); +} + +template +inline T spvQuadSwap(T value, uint dir) +{ + return quad_shuffle_xor(value, dir + 1); +} + +template<> +inline bool spvQuadSwap(bool value, uint dir) +{ + return !!quad_shuffle_xor((ushort)value, dir + 1); +} + +template +inline vec spvQuadSwap(vec value, uint dir) +{ + return (vec)quad_shuffle_xor((vec)value, dir + 1); +} + +kernel void main0(device SSBO& _9 [[buffer(0)]], uint gl_NumSubgroups [[simdgroups_per_threadgroup]], uint gl_SubgroupID [[simdgroup_index_in_threadgroup]], uint gl_SubgroupInvocationID [[thread_index_in_simdgroup]]) +{ + uint gl_SubgroupSize = 32; + uint4 gl_SubgroupEqMask = gl_SubgroupInvocationID >= 32 ? uint4(0, (1 << (gl_SubgroupInvocationID - 32)), uint2(0)) : uint4(1 << gl_SubgroupInvocationID, uint3(0)); + uint4 gl_SubgroupGeMask = uint4(insert_bits(0u, 0xFFFFFFFF, gl_SubgroupInvocationID, 32 - gl_SubgroupInvocationID), uint3(0)); + uint4 gl_SubgroupGtMask = uint4(insert_bits(0u, 0xFFFFFFFF, gl_SubgroupInvocationID + 1, 32 - gl_SubgroupInvocationID - 1), uint3(0)); + uint4 gl_SubgroupLeMask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID + 1, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID + 1 - 32, 0)), uint2(0)); + uint4 gl_SubgroupLtMask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID - 32, 0)), uint2(0)); + _9.FragColor = float(gl_NumSubgroups); + _9.FragColor = float(gl_SubgroupID); + _9.FragColor = float(gl_SubgroupSize); + _9.FragColor = float(gl_SubgroupInvocationID); + simdgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture); + simdgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture); + simdgroup_barrier(mem_flags::mem_device); + simdgroup_barrier(mem_flags::mem_threadgroup); + simdgroup_barrier(mem_flags::mem_texture); + bool _39 = simd_is_first(); + bool elected = _39; + _9.FragColor = float4(gl_SubgroupEqMask).x; + _9.FragColor = float4(gl_SubgroupGeMask).x; + _9.FragColor = float4(gl_SubgroupGtMask).x; + _9.FragColor = float4(gl_SubgroupLeMask).x; + _9.FragColor = float4(gl_SubgroupLtMask).x; + float4 broadcasted = spvSubgroupBroadcast(float4(10.0), 8u); + bool2 broadcasted_bool = spvSubgroupBroadcast(bool2(true), 8u); + float3 first = spvSubgroupBroadcastFirst(float3(20.0)); + bool4 first_bool = spvSubgroupBroadcastFirst(bool4(false)); + uint4 ballot_value = spvSubgroupBallot(true); + bool inverse_ballot_value = spvSubgroupBallotBitExtract(ballot_value, gl_SubgroupInvocationID); + bool bit_extracted = spvSubgroupBallotBitExtract(uint4(10u), 8u); + uint bit_count = spvSubgroupBallotBitCount(ballot_value, gl_SubgroupSize); + uint inclusive_bit_count = spvSubgroupBallotInclusiveBitCount(ballot_value, gl_SubgroupInvocationID); + uint exclusive_bit_count = spvSubgroupBallotExclusiveBitCount(ballot_value, gl_SubgroupInvocationID); + uint lsb = spvSubgroupBallotFindLSB(ballot_value, gl_SubgroupSize); + uint msb = spvSubgroupBallotFindMSB(ballot_value, gl_SubgroupSize); + uint shuffled = spvSubgroupShuffle(10u, 8u); + bool shuffled_bool = spvSubgroupShuffle(true, 9u); + uint shuffled_xor = spvSubgroupShuffleXor(30u, 8u); + bool shuffled_xor_bool = spvSubgroupShuffleXor(false, 9u); + uint shuffled_up = spvSubgroupShuffleUp(20u, 4u); + bool shuffled_up_bool = spvSubgroupShuffleUp(true, 4u); + uint shuffled_down = spvSubgroupShuffleDown(20u, 4u); + bool shuffled_down_bool = spvSubgroupShuffleDown(false, 4u); + bool has_all = simd_all(true); + bool has_any = simd_any(true); + bool has_equal = spvSubgroupAllEqual(0); + has_equal = spvSubgroupAllEqual(true); + has_equal = spvSubgroupAllEqual(float3(0.0, 1.0, 2.0)); + has_equal = spvSubgroupAllEqual(bool4(true, true, false, true)); + float4 added = simd_sum(float4(20.0)); + int4 iadded = simd_sum(int4(20)); + float4 multiplied = simd_product(float4(20.0)); + int4 imultiplied = simd_product(int4(20)); + float4 lo = simd_min(float4(20.0)); + float4 hi = simd_max(float4(20.0)); + int4 slo = simd_min(int4(20)); + int4 shi = simd_max(int4(20)); + uint4 ulo = simd_min(uint4(20u)); + uint4 uhi = simd_max(uint4(20u)); + uint4 anded = simd_and(ballot_value); + uint4 ored = simd_or(ballot_value); + uint4 xored = simd_xor(ballot_value); + added = simd_prefix_inclusive_sum(added); + iadded = simd_prefix_inclusive_sum(iadded); + multiplied = simd_prefix_inclusive_product(multiplied); + imultiplied = simd_prefix_inclusive_product(imultiplied); + added = simd_prefix_exclusive_sum(multiplied); + multiplied = simd_prefix_exclusive_product(multiplied); + iadded = simd_prefix_exclusive_sum(imultiplied); + imultiplied = simd_prefix_exclusive_product(imultiplied); + added = quad_sum(added); + multiplied = quad_product(multiplied); + iadded = quad_sum(iadded); + imultiplied = quad_product(imultiplied); + lo = quad_min(lo); + hi = quad_max(hi); + ulo = quad_min(ulo); + uhi = quad_max(uhi); + slo = quad_min(slo); + shi = quad_max(shi); + anded = quad_and(anded); + ored = quad_or(ored); + xored = quad_xor(xored); + float4 swap_horiz = spvQuadSwap(float4(20.0), 0u); + bool4 swap_horiz_bool = spvQuadSwap(bool4(true), 0u); + float4 swap_vertical = spvQuadSwap(float4(20.0), 1u); + bool4 swap_vertical_bool = spvQuadSwap(bool4(true), 1u); + float4 swap_diagonal = spvQuadSwap(float4(20.0), 2u); + bool4 swap_diagonal_bool = spvQuadSwap(bool4(true), 2u); + float4 quad_broadcast0 = spvQuadBroadcast(float4(20.0), 3u); + bool4 quad_broadcast_bool = spvQuadBroadcast(bool4(true), 3u); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl22.ios.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl22.ios.comp new file mode 100644 index 0000000000..bb319a3fc8 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl22.ios.comp @@ -0,0 +1,282 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct SSBO +{ + float FragColor; +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); + +template +inline T spvSubgroupBroadcast(T value, ushort lane) +{ + return quad_broadcast(value, lane); +} + +template<> +inline bool spvSubgroupBroadcast(bool value, ushort lane) +{ + return !!quad_broadcast((ushort)value, lane); +} + +template +inline vec spvSubgroupBroadcast(vec value, ushort lane) +{ + return (vec)quad_broadcast((vec)value, lane); +} + +template +inline T spvSubgroupBroadcastFirst(T value) +{ + return quad_broadcast_first(value); +} + +template<> +inline bool spvSubgroupBroadcastFirst(bool value) +{ + return !!quad_broadcast_first((ushort)value); +} + +template +inline vec spvSubgroupBroadcastFirst(vec value) +{ + return (vec)quad_broadcast_first((vec)value); +} + +inline uint4 spvSubgroupBallot(bool value) +{ + return uint4((quad_vote::vote_t)quad_ballot(value), 0, 0, 0); +} + +inline bool spvSubgroupBallotBitExtract(uint4 ballot, uint bit) +{ + return !!extract_bits(ballot[bit / 32], bit % 32, 1); +} + +inline uint spvSubgroupBallotFindLSB(uint4 ballot, uint gl_SubgroupSize) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, gl_SubgroupSize), uint3(0)); + ballot &= mask; + return select(ctz(ballot.x), select(32 + ctz(ballot.y), select(64 + ctz(ballot.z), select(96 + ctz(ballot.w), uint(-1), ballot.w == 0), ballot.z == 0), ballot.y == 0), ballot.x == 0); +} + +inline uint spvSubgroupBallotFindMSB(uint4 ballot, uint gl_SubgroupSize) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, gl_SubgroupSize), uint3(0)); + ballot &= mask; + return select(128 - (clz(ballot.w) + 1), select(96 - (clz(ballot.z) + 1), select(64 - (clz(ballot.y) + 1), select(32 - (clz(ballot.x) + 1), uint(-1), ballot.x == 0), ballot.y == 0), ballot.z == 0), ballot.w == 0); +} + +inline uint spvPopCount4(uint4 ballot) +{ + return popcount(ballot.x) + popcount(ballot.y) + popcount(ballot.z) + popcount(ballot.w); +} + +inline uint spvSubgroupBallotBitCount(uint4 ballot, uint gl_SubgroupSize) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, gl_SubgroupSize), uint3(0)); + return spvPopCount4(ballot & mask); +} + +inline uint spvSubgroupBallotInclusiveBitCount(uint4 ballot, uint gl_SubgroupInvocationID) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, gl_SubgroupInvocationID + 1), uint3(0)); + return spvPopCount4(ballot & mask); +} + +inline uint spvSubgroupBallotExclusiveBitCount(uint4 ballot, uint gl_SubgroupInvocationID) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, gl_SubgroupInvocationID), uint2(0)); + return spvPopCount4(ballot & mask); +} + +template +inline bool spvSubgroupAllEqual(T value) +{ + return quad_all(all(value == quad_broadcast_first(value))); +} + +template<> +inline bool spvSubgroupAllEqual(bool value) +{ + return quad_all(value) || !quad_any(value); +} + +template +inline bool spvSubgroupAllEqual(vec value) +{ + return quad_all(all(value == (vec)quad_broadcast_first((vec)value))); +} + +template +inline T spvSubgroupShuffle(T value, ushort lane) +{ + return quad_shuffle(value, lane); +} + +template<> +inline bool spvSubgroupShuffle(bool value, ushort lane) +{ + return !!quad_shuffle((ushort)value, lane); +} + +template +inline vec spvSubgroupShuffle(vec value, ushort lane) +{ + return (vec)quad_shuffle((vec)value, lane); +} + +template +inline T spvSubgroupShuffleXor(T value, ushort mask) +{ + return quad_shuffle_xor(value, mask); +} + +template<> +inline bool spvSubgroupShuffleXor(bool value, ushort mask) +{ + return !!quad_shuffle_xor((ushort)value, mask); +} + +template +inline vec spvSubgroupShuffleXor(vec value, ushort mask) +{ + return (vec)quad_shuffle_xor((vec)value, mask); +} + +template +inline T spvSubgroupShuffleUp(T value, ushort delta) +{ + return quad_shuffle_up(value, delta); +} + +template<> +inline bool spvSubgroupShuffleUp(bool value, ushort delta) +{ + return !!quad_shuffle_up((ushort)value, delta); +} + +template +inline vec spvSubgroupShuffleUp(vec value, ushort delta) +{ + return (vec)quad_shuffle_up((vec)value, delta); +} + +template +inline T spvSubgroupShuffleDown(T value, ushort delta) +{ + return quad_shuffle_down(value, delta); +} + +template<> +inline bool spvSubgroupShuffleDown(bool value, ushort delta) +{ + return !!quad_shuffle_down((ushort)value, delta); +} + +template +inline vec spvSubgroupShuffleDown(vec value, ushort delta) +{ + return (vec)quad_shuffle_down((vec)value, delta); +} + +template +inline T spvQuadBroadcast(T value, uint lane) +{ + return quad_broadcast(value, lane); +} + +template<> +inline bool spvQuadBroadcast(bool value, uint lane) +{ + return !!quad_broadcast((ushort)value, lane); +} + +template +inline vec spvQuadBroadcast(vec value, uint lane) +{ + return (vec)quad_broadcast((vec)value, lane); +} + +template +inline T spvQuadSwap(T value, uint dir) +{ + return quad_shuffle_xor(value, dir + 1); +} + +template<> +inline bool spvQuadSwap(bool value, uint dir) +{ + return !!quad_shuffle_xor((ushort)value, dir + 1); +} + +template +inline vec spvQuadSwap(vec value, uint dir) +{ + return (vec)quad_shuffle_xor((vec)value, dir + 1); +} + +kernel void main0(device SSBO& _9 [[buffer(0)]], uint gl_NumSubgroups [[quadgroups_per_threadgroup]], uint gl_SubgroupID [[quadgroup_index_in_threadgroup]], uint gl_SubgroupSize [[thread_execution_width]], uint gl_SubgroupInvocationID [[thread_index_in_quadgroup]]) +{ + uint4 gl_SubgroupEqMask = uint4(1 << gl_SubgroupInvocationID, uint3(0)); + uint4 gl_SubgroupGeMask = uint4(insert_bits(0u, 0xFFFFFFFF, gl_SubgroupInvocationID, gl_SubgroupSize - gl_SubgroupInvocationID), uint3(0)); + uint4 gl_SubgroupGtMask = uint4(insert_bits(0u, 0xFFFFFFFF, gl_SubgroupInvocationID + 1, gl_SubgroupSize - gl_SubgroupInvocationID - 1), uint3(0)); + uint4 gl_SubgroupLeMask = uint4(extract_bits(0xFFFFFFFF, 0, gl_SubgroupInvocationID + 1), uint3(0)); + uint4 gl_SubgroupLtMask = uint4(extract_bits(0xFFFFFFFF, 0, gl_SubgroupInvocationID), uint3(0)); + _9.FragColor = float(gl_NumSubgroups); + _9.FragColor = float(gl_SubgroupID); + _9.FragColor = float(gl_SubgroupSize); + _9.FragColor = float(gl_SubgroupInvocationID); + simdgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture); + simdgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture); + simdgroup_barrier(mem_flags::mem_device); + simdgroup_barrier(mem_flags::mem_threadgroup); + simdgroup_barrier(mem_flags::mem_texture); + bool _39 = quad_is_first(); + bool elected = _39; + _9.FragColor = float4(gl_SubgroupEqMask).x; + _9.FragColor = float4(gl_SubgroupGeMask).x; + _9.FragColor = float4(gl_SubgroupGtMask).x; + _9.FragColor = float4(gl_SubgroupLeMask).x; + _9.FragColor = float4(gl_SubgroupLtMask).x; + float4 broadcasted = spvSubgroupBroadcast(float4(10.0), 8u); + bool2 broadcasted_bool = spvSubgroupBroadcast(bool2(true), 8u); + float3 first = spvSubgroupBroadcastFirst(float3(20.0)); + bool4 first_bool = spvSubgroupBroadcastFirst(bool4(false)); + uint4 ballot_value = spvSubgroupBallot(true); + bool inverse_ballot_value = spvSubgroupBallotBitExtract(ballot_value, gl_SubgroupInvocationID); + bool bit_extracted = spvSubgroupBallotBitExtract(uint4(10u), 8u); + uint bit_count = spvSubgroupBallotBitCount(ballot_value, gl_SubgroupSize); + uint inclusive_bit_count = spvSubgroupBallotInclusiveBitCount(ballot_value, gl_SubgroupInvocationID); + uint exclusive_bit_count = spvSubgroupBallotExclusiveBitCount(ballot_value, gl_SubgroupInvocationID); + uint lsb = spvSubgroupBallotFindLSB(ballot_value, gl_SubgroupSize); + uint msb = spvSubgroupBallotFindMSB(ballot_value, gl_SubgroupSize); + uint shuffled = spvSubgroupShuffle(10u, 8u); + bool shuffled_bool = spvSubgroupShuffle(true, 9u); + uint shuffled_xor = spvSubgroupShuffleXor(30u, 8u); + bool shuffled_xor_bool = spvSubgroupShuffleXor(false, 9u); + uint shuffled_up = spvSubgroupShuffleUp(20u, 4u); + bool shuffled_up_bool = spvSubgroupShuffleUp(true, 4u); + uint shuffled_down = spvSubgroupShuffleDown(20u, 4u); + bool shuffled_down_bool = spvSubgroupShuffleDown(false, 4u); + bool has_all = quad_all(true); + bool has_any = quad_any(true); + bool has_equal = spvSubgroupAllEqual(0); + has_equal = spvSubgroupAllEqual(true); + has_equal = spvSubgroupAllEqual(float3(0.0, 1.0, 2.0)); + has_equal = spvSubgroupAllEqual(bool4(true, true, false, true)); + float4 swap_horiz = spvQuadSwap(float4(20.0), 0u); + bool4 swap_horiz_bool = spvQuadSwap(bool4(true), 0u); + float4 swap_vertical = spvQuadSwap(float4(20.0), 1u); + bool4 swap_vertical_bool = spvQuadSwap(bool4(true), 1u); + float4 swap_diagonal = spvQuadSwap(float4(20.0), 2u); + bool4 swap_diagonal_bool = spvQuadSwap(bool4(true), 2u); + float4 quad_broadcast0 = spvQuadBroadcast(float4(20.0), 3u); + bool4 quad_broadcast_bool = spvQuadBroadcast(bool4(true), 3u); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl23.ios.simd.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl23.ios.simd.comp new file mode 100644 index 0000000000..9c1d9ae213 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl23.ios.simd.comp @@ -0,0 +1,316 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct SSBO +{ + float FragColor; +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); + +template +inline T spvSubgroupBroadcast(T value, ushort lane) +{ + return simd_broadcast(value, lane); +} + +template<> +inline bool spvSubgroupBroadcast(bool value, ushort lane) +{ + return !!simd_broadcast((ushort)value, lane); +} + +template +inline vec spvSubgroupBroadcast(vec value, ushort lane) +{ + return (vec)simd_broadcast((vec)value, lane); +} + +template +inline T spvSubgroupBroadcastFirst(T value) +{ + return simd_broadcast_first(value); +} + +template<> +inline bool spvSubgroupBroadcastFirst(bool value) +{ + return !!simd_broadcast_first((ushort)value); +} + +template +inline vec spvSubgroupBroadcastFirst(vec value) +{ + return (vec)simd_broadcast_first((vec)value); +} + +inline uint4 spvSubgroupBallot(bool value) +{ + return uint4((simd_vote::vote_t)simd_ballot(value), 0, 0, 0); +} + +inline bool spvSubgroupBallotBitExtract(uint4 ballot, uint bit) +{ + return !!extract_bits(ballot[bit / 32], bit % 32, 1); +} + +inline uint spvSubgroupBallotFindLSB(uint4 ballot, uint gl_SubgroupSize) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, gl_SubgroupSize), uint3(0)); + ballot &= mask; + return select(ctz(ballot.x), select(32 + ctz(ballot.y), select(64 + ctz(ballot.z), select(96 + ctz(ballot.w), uint(-1), ballot.w == 0), ballot.z == 0), ballot.y == 0), ballot.x == 0); +} + +inline uint spvSubgroupBallotFindMSB(uint4 ballot, uint gl_SubgroupSize) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, gl_SubgroupSize), uint3(0)); + ballot &= mask; + return select(128 - (clz(ballot.w) + 1), select(96 - (clz(ballot.z) + 1), select(64 - (clz(ballot.y) + 1), select(32 - (clz(ballot.x) + 1), uint(-1), ballot.x == 0), ballot.y == 0), ballot.z == 0), ballot.w == 0); +} + +inline uint spvPopCount4(uint4 ballot) +{ + return popcount(ballot.x) + popcount(ballot.y) + popcount(ballot.z) + popcount(ballot.w); +} + +inline uint spvSubgroupBallotBitCount(uint4 ballot, uint gl_SubgroupSize) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, gl_SubgroupSize), uint3(0)); + return spvPopCount4(ballot & mask); +} + +inline uint spvSubgroupBallotInclusiveBitCount(uint4 ballot, uint gl_SubgroupInvocationID) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, gl_SubgroupInvocationID + 1), uint3(0)); + return spvPopCount4(ballot & mask); +} + +inline uint spvSubgroupBallotExclusiveBitCount(uint4 ballot, uint gl_SubgroupInvocationID) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, gl_SubgroupInvocationID), uint2(0)); + return spvPopCount4(ballot & mask); +} + +template +inline bool spvSubgroupAllEqual(T value) +{ + return simd_all(all(value == simd_broadcast_first(value))); +} + +template<> +inline bool spvSubgroupAllEqual(bool value) +{ + return simd_all(value) || !simd_any(value); +} + +template +inline bool spvSubgroupAllEqual(vec value) +{ + return simd_all(all(value == (vec)simd_broadcast_first((vec)value))); +} + +template +inline T spvSubgroupShuffle(T value, ushort lane) +{ + return simd_shuffle(value, lane); +} + +template<> +inline bool spvSubgroupShuffle(bool value, ushort lane) +{ + return !!simd_shuffle((ushort)value, lane); +} + +template +inline vec spvSubgroupShuffle(vec value, ushort lane) +{ + return (vec)simd_shuffle((vec)value, lane); +} + +template +inline T spvSubgroupShuffleXor(T value, ushort mask) +{ + return simd_shuffle_xor(value, mask); +} + +template<> +inline bool spvSubgroupShuffleXor(bool value, ushort mask) +{ + return !!simd_shuffle_xor((ushort)value, mask); +} + +template +inline vec spvSubgroupShuffleXor(vec value, ushort mask) +{ + return (vec)simd_shuffle_xor((vec)value, mask); +} + +template +inline T spvSubgroupShuffleUp(T value, ushort delta) +{ + return simd_shuffle_up(value, delta); +} + +template<> +inline bool spvSubgroupShuffleUp(bool value, ushort delta) +{ + return !!simd_shuffle_up((ushort)value, delta); +} + +template +inline vec spvSubgroupShuffleUp(vec value, ushort delta) +{ + return (vec)simd_shuffle_up((vec)value, delta); +} + +template +inline T spvSubgroupShuffleDown(T value, ushort delta) +{ + return simd_shuffle_down(value, delta); +} + +template<> +inline bool spvSubgroupShuffleDown(bool value, ushort delta) +{ + return !!simd_shuffle_down((ushort)value, delta); +} + +template +inline vec spvSubgroupShuffleDown(vec value, ushort delta) +{ + return (vec)simd_shuffle_down((vec)value, delta); +} + +template +inline T spvQuadBroadcast(T value, uint lane) +{ + return quad_broadcast(value, lane); +} + +template<> +inline bool spvQuadBroadcast(bool value, uint lane) +{ + return !!quad_broadcast((ushort)value, lane); +} + +template +inline vec spvQuadBroadcast(vec value, uint lane) +{ + return (vec)quad_broadcast((vec)value, lane); +} + +template +inline T spvQuadSwap(T value, uint dir) +{ + return quad_shuffle_xor(value, dir + 1); +} + +template<> +inline bool spvQuadSwap(bool value, uint dir) +{ + return !!quad_shuffle_xor((ushort)value, dir + 1); +} + +template +inline vec spvQuadSwap(vec value, uint dir) +{ + return (vec)quad_shuffle_xor((vec)value, dir + 1); +} + +kernel void main0(device SSBO& _9 [[buffer(0)]], uint gl_NumSubgroups [[quadgroups_per_threadgroup]], uint gl_SubgroupID [[quadgroup_index_in_threadgroup]], uint gl_SubgroupSize [[thread_execution_width]], uint gl_SubgroupInvocationID [[thread_index_in_quadgroup]]) +{ + uint4 gl_SubgroupEqMask = uint4(1 << gl_SubgroupInvocationID, uint3(0)); + uint4 gl_SubgroupGeMask = uint4(insert_bits(0u, 0xFFFFFFFF, gl_SubgroupInvocationID, gl_SubgroupSize - gl_SubgroupInvocationID), uint3(0)); + uint4 gl_SubgroupGtMask = uint4(insert_bits(0u, 0xFFFFFFFF, gl_SubgroupInvocationID + 1, gl_SubgroupSize - gl_SubgroupInvocationID - 1), uint3(0)); + uint4 gl_SubgroupLeMask = uint4(extract_bits(0xFFFFFFFF, 0, gl_SubgroupInvocationID + 1), uint3(0)); + uint4 gl_SubgroupLtMask = uint4(extract_bits(0xFFFFFFFF, 0, gl_SubgroupInvocationID), uint3(0)); + _9.FragColor = float(gl_NumSubgroups); + _9.FragColor = float(gl_SubgroupID); + _9.FragColor = float(gl_SubgroupSize); + _9.FragColor = float(gl_SubgroupInvocationID); + simdgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture); + simdgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture); + simdgroup_barrier(mem_flags::mem_device); + simdgroup_barrier(mem_flags::mem_threadgroup); + simdgroup_barrier(mem_flags::mem_texture); + bool _39 = simd_is_first(); + bool elected = _39; + _9.FragColor = float4(gl_SubgroupEqMask).x; + _9.FragColor = float4(gl_SubgroupGeMask).x; + _9.FragColor = float4(gl_SubgroupGtMask).x; + _9.FragColor = float4(gl_SubgroupLeMask).x; + _9.FragColor = float4(gl_SubgroupLtMask).x; + float4 broadcasted = spvSubgroupBroadcast(float4(10.0), 8u); + bool2 broadcasted_bool = spvSubgroupBroadcast(bool2(true), 8u); + float3 first = spvSubgroupBroadcastFirst(float3(20.0)); + bool4 first_bool = spvSubgroupBroadcastFirst(bool4(false)); + uint4 ballot_value = spvSubgroupBallot(true); + bool inverse_ballot_value = spvSubgroupBallotBitExtract(ballot_value, gl_SubgroupInvocationID); + bool bit_extracted = spvSubgroupBallotBitExtract(uint4(10u), 8u); + uint bit_count = spvSubgroupBallotBitCount(ballot_value, gl_SubgroupSize); + uint inclusive_bit_count = spvSubgroupBallotInclusiveBitCount(ballot_value, gl_SubgroupInvocationID); + uint exclusive_bit_count = spvSubgroupBallotExclusiveBitCount(ballot_value, gl_SubgroupInvocationID); + uint lsb = spvSubgroupBallotFindLSB(ballot_value, gl_SubgroupSize); + uint msb = spvSubgroupBallotFindMSB(ballot_value, gl_SubgroupSize); + uint shuffled = spvSubgroupShuffle(10u, 8u); + bool shuffled_bool = spvSubgroupShuffle(true, 9u); + uint shuffled_xor = spvSubgroupShuffleXor(30u, 8u); + bool shuffled_xor_bool = spvSubgroupShuffleXor(false, 9u); + uint shuffled_up = spvSubgroupShuffleUp(20u, 4u); + bool shuffled_up_bool = spvSubgroupShuffleUp(true, 4u); + uint shuffled_down = spvSubgroupShuffleDown(20u, 4u); + bool shuffled_down_bool = spvSubgroupShuffleDown(false, 4u); + bool has_all = simd_all(true); + bool has_any = simd_any(true); + bool has_equal = spvSubgroupAllEqual(0); + has_equal = spvSubgroupAllEqual(true); + has_equal = spvSubgroupAllEqual(float3(0.0, 1.0, 2.0)); + has_equal = spvSubgroupAllEqual(bool4(true, true, false, true)); + float4 added = simd_sum(float4(20.0)); + int4 iadded = simd_sum(int4(20)); + float4 multiplied = simd_product(float4(20.0)); + int4 imultiplied = simd_product(int4(20)); + float4 lo = simd_min(float4(20.0)); + float4 hi = simd_max(float4(20.0)); + int4 slo = simd_min(int4(20)); + int4 shi = simd_max(int4(20)); + uint4 ulo = simd_min(uint4(20u)); + uint4 uhi = simd_max(uint4(20u)); + uint4 anded = simd_and(ballot_value); + uint4 ored = simd_or(ballot_value); + uint4 xored = simd_xor(ballot_value); + added = simd_prefix_inclusive_sum(added); + iadded = simd_prefix_inclusive_sum(iadded); + multiplied = simd_prefix_inclusive_product(multiplied); + imultiplied = simd_prefix_inclusive_product(imultiplied); + added = simd_prefix_exclusive_sum(multiplied); + multiplied = simd_prefix_exclusive_product(multiplied); + iadded = simd_prefix_exclusive_sum(imultiplied); + imultiplied = simd_prefix_exclusive_product(imultiplied); + added = quad_sum(added); + multiplied = quad_product(multiplied); + iadded = quad_sum(iadded); + imultiplied = quad_product(imultiplied); + lo = quad_min(lo); + hi = quad_max(hi); + ulo = quad_min(ulo); + uhi = quad_max(uhi); + slo = quad_min(slo); + shi = quad_max(shi); + anded = quad_and(anded); + ored = quad_or(ored); + xored = quad_xor(xored); + float4 swap_horiz = spvQuadSwap(float4(20.0), 0u); + bool4 swap_horiz_bool = spvQuadSwap(bool4(true), 0u); + float4 swap_vertical = spvQuadSwap(float4(20.0), 1u); + bool4 swap_vertical_bool = spvQuadSwap(bool4(true), 1u); + float4 swap_diagonal = spvQuadSwap(float4(20.0), 2u); + bool4 swap_diagonal_bool = spvQuadSwap(bool4(true), 2u); + float4 quad_broadcast0 = spvQuadBroadcast(float4(20.0), 3u); + bool4 quad_broadcast_bool = spvQuadBroadcast(bool4(true), 3u); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/components/fragment-output-component.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/components/fragment-output-component.frag index 7e030aa1ed..45b05b9dba 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/components/fragment-output-component.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/components/fragment-output-component.frag @@ -5,7 +5,7 @@ using namespace metal; struct main0_out { - float4 FragColor0 [[color(0)]]; + float4 m_location_0 [[color(0)]]; }; fragment main0_out main0() @@ -17,9 +17,9 @@ fragment main0_out main0() FragColor0 = 1.0; FragColor1 = float2(2.0, 3.0); FragColor3 = 4.0; - out.FragColor0.x = FragColor0; - out.FragColor0.yz = FragColor1; - out.FragColor0.w = FragColor3; + out.m_location_0.x = FragColor0; + out.m_location_0.yz = FragColor1; + out.m_location_0.w = FragColor3; return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/components/fragment-output-component.pad-fragment.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/components/fragment-output-component.pad-fragment.frag index 13eb7d5769..0e4bee12f6 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/components/fragment-output-component.pad-fragment.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/components/fragment-output-component.pad-fragment.frag @@ -5,7 +5,7 @@ using namespace metal; struct main0_out { - float4 FragColor0 [[color(0)]]; + float3 m_location_0 [[color(0)]]; }; fragment main0_out main0() @@ -15,8 +15,8 @@ fragment main0_out main0() float2 FragColor1 = {}; FragColor0 = 1.0; FragColor1 = float2(2.0, 3.0); - out.FragColor0.x = FragColor0; - out.FragColor0.yz = FragColor1; + out.m_location_0.x = FragColor0; + out.m_location_0.yz = FragColor1; return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/components/vertex-input-component.vert b/third_party/spirv-cross/reference/shaders-msl-no-opt/components/vertex-input-component.vert index 1aae280d08..7a099f503b 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/components/vertex-input-component.vert +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/components/vertex-input-component.vert @@ -11,7 +11,7 @@ struct main0_out struct main0_in { - float4 Foo3 [[attribute(0)]]; + float4 m_location_0 [[attribute(0)]]; }; vertex main0_out main0(main0_in in [[stage_in]]) @@ -19,8 +19,8 @@ vertex main0_out main0(main0_in in [[stage_in]]) main0_out out = {}; float3 Foo3 = {}; float Foo1 = {}; - Foo3 = in.Foo3.xyz; - Foo1 = in.Foo3.w; + Foo3 = in.m_location_0.xyz; + Foo1 = in.m_location_0.w; out.gl_Position = float4(Foo3, Foo1); out.Foo = Foo3 + float3(Foo1); return out; diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/nonuniform-constructor.msl2.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/nonuniform-constructor.msl2.frag new file mode 100644 index 0000000000..f1ad5c5fb2 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/nonuniform-constructor.msl2.frag @@ -0,0 +1,23 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 vUV [[user(locn0)]]; + int vIndex [[user(locn1)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], array, 10> uTex [[texture(0)]], sampler Immut [[sampler(0)]]) +{ + main0_out out = {}; + out.FragColor = uTex[in.vIndex].sample(Immut, in.vUV); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/subgroups.nocompat.invalid.vk.msl21.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/subgroups.nocompat.invalid.vk.msl22.frag similarity index 98% rename from third_party/spirv-cross/reference/shaders-msl-no-opt/frag/subgroups.nocompat.invalid.vk.msl21.frag rename to third_party/spirv-cross/reference/shaders-msl-no-opt/frag/subgroups.nocompat.invalid.vk.msl22.frag index 021ce825ca..2243190da0 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/subgroups.nocompat.invalid.vk.msl21.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/subgroups.nocompat.invalid.vk.msl22.frag @@ -224,11 +224,9 @@ inline vec spvQuadSwap(vec value, uint dir) return (vec)quad_shuffle_xor((vec)value, dir + 1); } -fragment main0_out main0() +fragment main0_out main0(uint gl_SubgroupSize [[threads_per_simdgroup]], uint gl_SubgroupInvocationID [[thread_index_in_simdgroup]]) { main0_out out = {}; - uint gl_SubgroupSize = simd_sum(1); - uint gl_SubgroupInvocationID = simd_prefix_exclusive_sum(1); uint4 gl_SubgroupEqMask = gl_SubgroupInvocationID >= 32 ? uint4(0, (1 << (gl_SubgroupInvocationID - 32)), uint2(0)) : uint4(1 << gl_SubgroupInvocationID, uint3(0)); uint4 gl_SubgroupGeMask = uint4(insert_bits(0u, 0xFFFFFFFF, min(gl_SubgroupInvocationID, 32u), (uint)max(min((int)gl_SubgroupSize, 32) - (int)gl_SubgroupInvocationID, 0)), insert_bits(0u, 0xFFFFFFFF, (uint)max((int)gl_SubgroupInvocationID - 32, 0), (uint)max((int)gl_SubgroupSize - (int)max(gl_SubgroupInvocationID, 32u), 0)), uint2(0)); uint4 gl_SubgroupGtMask = uint4(insert_bits(0u, 0xFFFFFFFF, min(gl_SubgroupInvocationID + 1, 32u), (uint)max(min((int)gl_SubgroupSize, 32) - (int)gl_SubgroupInvocationID - 1, 0)), insert_bits(0u, 0xFFFFFFFF, (uint)max((int)gl_SubgroupInvocationID + 1 - 32, 0), (uint)max((int)gl_SubgroupSize - (int)max(gl_SubgroupInvocationID + 1, 32u), 0)), uint2(0)); @@ -236,7 +234,8 @@ fragment main0_out main0() uint4 gl_SubgroupLtMask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID - 32, 0)), uint2(0)); out.FragColor = float(gl_SubgroupSize); out.FragColor = float(gl_SubgroupInvocationID); - bool elected = simd_is_first(); + bool _24 = simd_is_first(); + bool elected = _24; out.FragColor = float4(gl_SubgroupEqMask).x; out.FragColor = float4(gl_SubgroupGeMask).x; out.FragColor = float4(gl_SubgroupGtMask).x; diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/subpass-input.decoration-binding.framebuffer-fetch.msl23.argument.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/subpass-input.decoration-binding.framebuffer-fetch.msl23.argument.frag new file mode 100644 index 0000000000..8c7f67b68b --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/subpass-input.decoration-binding.framebuffer-fetch.msl23.argument.frag @@ -0,0 +1,23 @@ +#include +#include + +using namespace metal; + +struct spvDescriptorSetBuffer0 +{ + sampler uSampler [[id(8)]]; + texture2d uTex [[id(9)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], float4 uSub [[color(1)]]) +{ + main0_out out = {}; + out.FragColor = uSub + spvDescriptorSet0.uTex.sample(spvDescriptorSet0.uSampler, float2(0.5)); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/subpass-input.decoration-binding.framebuffer-fetch.msl23.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/subpass-input.decoration-binding.framebuffer-fetch.msl23.frag new file mode 100644 index 0000000000..9108927ee4 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/subpass-input.decoration-binding.framebuffer-fetch.msl23.frag @@ -0,0 +1,17 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(float4 uSub [[color(1)]], texture2d uTex [[texture(9)]], sampler uSampler [[sampler(8)]]) +{ + main0_out out = {}; + out.FragColor = uSub + uTex.sample(uSampler, float2(0.5)); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/subpass-input.decoration-binding.ios.framebuffer-fetch.msl2.argument.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/subpass-input.decoration-binding.ios.framebuffer-fetch.msl2.argument.frag new file mode 100644 index 0000000000..8c7f67b68b --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/subpass-input.decoration-binding.ios.framebuffer-fetch.msl2.argument.frag @@ -0,0 +1,23 @@ +#include +#include + +using namespace metal; + +struct spvDescriptorSetBuffer0 +{ + sampler uSampler [[id(8)]]; + texture2d uTex [[id(9)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0)]], float4 uSub [[color(1)]]) +{ + main0_out out = {}; + out.FragColor = uSub + spvDescriptorSet0.uTex.sample(spvDescriptorSet0.uSampler, float2(0.5)); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/subpass-input.decoration-binding.ios.framebuffer-fetch.msl2.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/subpass-input.decoration-binding.ios.framebuffer-fetch.msl2.frag new file mode 100644 index 0000000000..9108927ee4 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/subpass-input.decoration-binding.ios.framebuffer-fetch.msl2.frag @@ -0,0 +1,17 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(float4 uSub [[color(1)]], texture2d uTex [[texture(9)]], sampler uSampler [[sampler(8)]]) +{ + main0_out out = {}; + out.FragColor = uSub + uTex.sample(uSampler, float2(0.5)); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/texture-access-leaf.swizzle.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/texture-access-leaf.swizzle.frag index 730728c1aa..fabf6c5779 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/texture-access-leaf.swizzle.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/texture-access-leaf.swizzle.frag @@ -141,29 +141,29 @@ float4 doSwizzle(thread texture1d tex1d, thread const sampler tex1dSmplr, c = spvTextureSwizzle(texCube.sample(texCubeSmplr, float3(0.0)), texCubeSwzl); c = spvTextureSwizzle(tex2dArray.sample(tex2dArraySmplr, float3(0.0).xy, uint(round(float3(0.0).z))), tex2dArraySwzl); c = spvTextureSwizzle(texCubeArray.sample(texCubeArraySmplr, float4(0.0).xyz, uint(round(float4(0.0).w))), texCubeArraySwzl); - c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, float3(0.0, 0.0, 1.0).xy, float3(0.0, 0.0, 1.0).z), depth2dSwzl); - c.x = spvTextureSwizzle(depthCube.sample_compare(depthCubeSmplr, float4(0.0, 0.0, 0.0, 1.0).xyz, float4(0.0, 0.0, 0.0, 1.0).w), depthCubeSwzl); - c.x = spvTextureSwizzle(depth2dArray.sample_compare(depth2dArraySmplr, float4(0.0, 0.0, 0.0, 1.0).xy, uint(round(float4(0.0, 0.0, 0.0, 1.0).z)), float4(0.0, 0.0, 0.0, 1.0).w), depth2dArraySwzl); + c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, float3(0.0, 0.0, 1.0).xy, 1.0), depth2dSwzl); + c.x = spvTextureSwizzle(depthCube.sample_compare(depthCubeSmplr, float4(0.0, 0.0, 0.0, 1.0).xyz, 1.0), depthCubeSwzl); + c.x = spvTextureSwizzle(depth2dArray.sample_compare(depth2dArraySmplr, float4(0.0, 0.0, 0.0, 1.0).xy, uint(round(float4(0.0, 0.0, 0.0, 1.0).z)), 1.0), depth2dArraySwzl); c.x = spvTextureSwizzle(depthCubeArray.sample_compare(depthCubeArraySmplr, float4(0.0).xyz, uint(round(float4(0.0).w)), 1.0), depthCubeArraySwzl); c = spvTextureSwizzle(tex1d.sample(tex1dSmplr, float2(0.0, 1.0).x / float2(0.0, 1.0).y), tex1dSwzl); c = spvTextureSwizzle(tex2d.sample(tex2dSmplr, float3(0.0, 0.0, 1.0).xy / float3(0.0, 0.0, 1.0).z), tex2dSwzl); c = spvTextureSwizzle(tex3d.sample(tex3dSmplr, float4(0.0, 0.0, 0.0, 1.0).xyz / float4(0.0, 0.0, 0.0, 1.0).w), tex3dSwzl); float4 _103 = float4(0.0, 0.0, 1.0, 1.0); - _103.z = float4(0.0, 0.0, 1.0, 1.0).w; - c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, _103.xy / _103.z, float4(0.0, 0.0, 1.0, 1.0).z / _103.z), depth2dSwzl); + _103.z = 1.0; + c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, _103.xy / _103.z, 1.0 / _103.z), depth2dSwzl); c = spvTextureSwizzle(tex1d.sample(tex1dSmplr, 0.0), tex1dSwzl); c = spvTextureSwizzle(tex2d.sample(tex2dSmplr, float2(0.0), level(0.0)), tex2dSwzl); c = spvTextureSwizzle(tex3d.sample(tex3dSmplr, float3(0.0), level(0.0)), tex3dSwzl); c = spvTextureSwizzle(texCube.sample(texCubeSmplr, float3(0.0), level(0.0)), texCubeSwzl); c = spvTextureSwizzle(tex2dArray.sample(tex2dArraySmplr, float3(0.0).xy, uint(round(float3(0.0).z)), level(0.0)), tex2dArraySwzl); c = spvTextureSwizzle(texCubeArray.sample(texCubeArraySmplr, float4(0.0).xyz, uint(round(float4(0.0).w)), level(0.0)), texCubeArraySwzl); - c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, float3(0.0, 0.0, 1.0).xy, float3(0.0, 0.0, 1.0).z, level(0.0)), depth2dSwzl); + c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, float3(0.0, 0.0, 1.0).xy, 1.0, level(0.0)), depth2dSwzl); c = spvTextureSwizzle(tex1d.sample(tex1dSmplr, float2(0.0, 1.0).x / float2(0.0, 1.0).y), tex1dSwzl); c = spvTextureSwizzle(tex2d.sample(tex2dSmplr, float3(0.0, 0.0, 1.0).xy / float3(0.0, 0.0, 1.0).z, level(0.0)), tex2dSwzl); c = spvTextureSwizzle(tex3d.sample(tex3dSmplr, float4(0.0, 0.0, 0.0, 1.0).xyz / float4(0.0, 0.0, 0.0, 1.0).w, level(0.0)), tex3dSwzl); float4 _131 = float4(0.0, 0.0, 1.0, 1.0); - _131.z = float4(0.0, 0.0, 1.0, 1.0).w; - c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, _131.xy / _131.z, float4(0.0, 0.0, 1.0, 1.0).z / _131.z, level(0.0)), depth2dSwzl); + _131.z = 1.0; + c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, _131.xy / _131.z, 1.0 / _131.z, level(0.0)), depth2dSwzl); c = spvTextureSwizzle(tex1d.read(uint(0)), tex1dSwzl); c = spvTextureSwizzle(tex2d.read(uint2(int2(0)), 0), tex2dSwzl); c = spvTextureSwizzle(tex3d.read(uint3(int3(0)), 0), tex3dSwzl); diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/texture-access.swizzle.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/texture-access.swizzle.frag index c31d5d7dca..9366eeab58 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/texture-access.swizzle.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/texture-access.swizzle.frag @@ -150,29 +150,29 @@ fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d c = spvTextureSwizzle(texCube.sample(texCubeSmplr, float3(0.0)), texCubeSwzl); c = spvTextureSwizzle(tex2dArray.sample(tex2dArraySmplr, float3(0.0).xy, uint(round(float3(0.0).z))), tex2dArraySwzl); c = spvTextureSwizzle(texCubeArray.sample(texCubeArraySmplr, float4(0.0).xyz, uint(round(float4(0.0).w))), texCubeArraySwzl); - c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, float3(0.0, 0.0, 1.0).xy, float3(0.0, 0.0, 1.0).z), depth2dSwzl); - c.x = spvTextureSwizzle(depthCube.sample_compare(depthCubeSmplr, float4(0.0, 0.0, 0.0, 1.0).xyz, float4(0.0, 0.0, 0.0, 1.0).w), depthCubeSwzl); - c.x = spvTextureSwizzle(depth2dArray.sample_compare(depth2dArraySmplr, float4(0.0, 0.0, 0.0, 1.0).xy, uint(round(float4(0.0, 0.0, 0.0, 1.0).z)), float4(0.0, 0.0, 0.0, 1.0).w), depth2dArraySwzl); + c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, float3(0.0, 0.0, 1.0).xy, 1.0), depth2dSwzl); + c.x = spvTextureSwizzle(depthCube.sample_compare(depthCubeSmplr, float4(0.0, 0.0, 0.0, 1.0).xyz, 1.0), depthCubeSwzl); + c.x = spvTextureSwizzle(depth2dArray.sample_compare(depth2dArraySmplr, float4(0.0, 0.0, 0.0, 1.0).xy, uint(round(float4(0.0, 0.0, 0.0, 1.0).z)), 1.0), depth2dArraySwzl); c.x = spvTextureSwizzle(depthCubeArray.sample_compare(depthCubeArraySmplr, float4(0.0).xyz, uint(round(float4(0.0).w)), 1.0), depthCubeArraySwzl); c = spvTextureSwizzle(tex1d.sample(tex1dSmplr, float2(0.0, 1.0).x / float2(0.0, 1.0).y), tex1dSwzl); c = spvTextureSwizzle(tex2d.sample(tex2dSmplr, float3(0.0, 0.0, 1.0).xy / float3(0.0, 0.0, 1.0).z), tex2dSwzl); c = spvTextureSwizzle(tex3d.sample(tex3dSmplr, float4(0.0, 0.0, 0.0, 1.0).xyz / float4(0.0, 0.0, 0.0, 1.0).w), tex3dSwzl); float4 _100 = float4(0.0, 0.0, 1.0, 1.0); - _100.z = float4(0.0, 0.0, 1.0, 1.0).w; - c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, _100.xy / _100.z, float4(0.0, 0.0, 1.0, 1.0).z / _100.z), depth2dSwzl); + _100.z = 1.0; + c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, _100.xy / _100.z, 1.0 / _100.z), depth2dSwzl); c = spvTextureSwizzle(tex1d.sample(tex1dSmplr, 0.0), tex1dSwzl); c = spvTextureSwizzle(tex2d.sample(tex2dSmplr, float2(0.0), level(0.0)), tex2dSwzl); c = spvTextureSwizzle(tex3d.sample(tex3dSmplr, float3(0.0), level(0.0)), tex3dSwzl); c = spvTextureSwizzle(texCube.sample(texCubeSmplr, float3(0.0), level(0.0)), texCubeSwzl); c = spvTextureSwizzle(tex2dArray.sample(tex2dArraySmplr, float3(0.0).xy, uint(round(float3(0.0).z)), level(0.0)), tex2dArraySwzl); c = spvTextureSwizzle(texCubeArray.sample(texCubeArraySmplr, float4(0.0).xyz, uint(round(float4(0.0).w)), level(0.0)), texCubeArraySwzl); - c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, float3(0.0, 0.0, 1.0).xy, float3(0.0, 0.0, 1.0).z, level(0.0)), depth2dSwzl); + c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, float3(0.0, 0.0, 1.0).xy, 1.0, level(0.0)), depth2dSwzl); c = spvTextureSwizzle(tex1d.sample(tex1dSmplr, float2(0.0, 1.0).x / float2(0.0, 1.0).y), tex1dSwzl); c = spvTextureSwizzle(tex2d.sample(tex2dSmplr, float3(0.0, 0.0, 1.0).xy / float3(0.0, 0.0, 1.0).z, level(0.0)), tex2dSwzl); c = spvTextureSwizzle(tex3d.sample(tex3dSmplr, float4(0.0, 0.0, 0.0, 1.0).xyz / float4(0.0, 0.0, 0.0, 1.0).w, level(0.0)), tex3dSwzl); float4 _128 = float4(0.0, 0.0, 1.0, 1.0); - _128.z = float4(0.0, 0.0, 1.0, 1.0).w; - c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, _128.xy / _128.z, float4(0.0, 0.0, 1.0, 1.0).z / _128.z, level(0.0)), depth2dSwzl); + _128.z = 1.0; + c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, _128.xy / _128.z, 1.0 / _128.z, level(0.0)), depth2dSwzl); c = spvTextureSwizzle(tex1d.read(uint(0)), tex1dSwzl); c = spvTextureSwizzle(tex2d.read(uint2(int2(0)), 0), tex2dSwzl); c = spvTextureSwizzle(tex3d.read(uint3(int3(0)), 0), tex3dSwzl); diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/tesc/copy-tess-level.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/tesc/copy-tess-level.tesc new file mode 100644 index 0000000000..3bb5419795 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/tesc/copy-tess-level.tesc @@ -0,0 +1,70 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +constant spvUnsafeArray _14 = spvUnsafeArray({ 1.0, 2.0 }); +constant spvUnsafeArray _21 = spvUnsafeArray({ 1.0, 2.0, 3.0, 4.0 }); + +struct main0_out +{ + float4 gl_Position; +}; + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 1]; + spvTessLevel[gl_PrimitiveID].insideTessellationFactor[0] = half(_14[0]); + spvTessLevel[gl_PrimitiveID].insideTessellationFactor[1] = half(_14[1]); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(_21[0]); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1] = half(_21[1]); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2] = half(_21[2]); + spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[3] = half(_21[3]); + spvUnsafeArray inner; + inner = spvUnsafeArray({ float(spvTessLevel[gl_PrimitiveID].insideTessellationFactor[0]), float(spvTessLevel[gl_PrimitiveID].insideTessellationFactor[1]) }); + spvUnsafeArray outer; + outer = spvUnsafeArray({ float(spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0]), float(spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1]), float(spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2]), float(spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[3]) }); + gl_out[gl_InvocationID].gl_Position = float4(1.0); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/tesc/passthrough-clip-cull.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/tesc/passthrough-clip-cull.multi-patch.tesc new file mode 100644 index 0000000000..f55e47baf0 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/tesc/passthrough-clip-cull.multi-patch.tesc @@ -0,0 +1,71 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +struct main0_in +{ + uint3 m_57; + ushort2 m_61; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]]) +{ + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + gl_out[gl_InvocationID].gl_ClipDistance[0] = gl_in[gl_InvocationID].gl_ClipDistance[0]; + gl_out[gl_InvocationID].gl_ClipDistance[1] = gl_in[gl_InvocationID].gl_ClipDistance[1]; + gl_out[gl_InvocationID].gl_CullDistance[0] = gl_in[gl_InvocationID].gl_CullDistance[0]; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/tesc/tess-level-read-write-in-function-quad.tesc b/third_party/spirv-cross/reference/shaders-msl-no-opt/tesc/tess-level-read-write-in-function-quad.tesc new file mode 100644 index 0000000000..c76da101bc --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/tesc/tess-level-read-write-in-function-quad.tesc @@ -0,0 +1,37 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 gl_Position; +}; + +static inline __attribute__((always_inline)) +void store_tess_level_in_func(device half (&gl_TessLevelInner)[2], device half (&gl_TessLevelOuter)[4]) +{ + gl_TessLevelInner[0] = half(1.0); + gl_TessLevelInner[1] = half(2.0); + gl_TessLevelOuter[0] = half(3.0); + gl_TessLevelOuter[1] = half(4.0); + gl_TessLevelOuter[2] = half(5.0); + gl_TessLevelOuter[3] = half(6.0); +} + +static inline __attribute__((always_inline)) +float load_tess_level_in_func(device half (&gl_TessLevelInner)[2], device half (&gl_TessLevelOuter)[4]) +{ + return float(gl_TessLevelInner[0]) + float(gl_TessLevelOuter[1]); +} + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 1]; + store_tess_level_in_func(spvTessLevel[gl_PrimitiveID].insideTessellationFactor, spvTessLevel[gl_PrimitiveID].edgeTessellationFactor); + float v = load_tess_level_in_func(spvTessLevel[gl_PrimitiveID].insideTessellationFactor, spvTessLevel[gl_PrimitiveID].edgeTessellationFactor); + gl_out[gl_InvocationID].gl_Position = float4(v); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/tese/builtin-input-automatic-attribute-assignment.tese b/third_party/spirv-cross/reference/shaders-msl-no-opt/tese/builtin-input-automatic-attribute-assignment.tese new file mode 100644 index 0000000000..02581a3e9f --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/tese/builtin-input-automatic-attribute-assignment.tese @@ -0,0 +1,80 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 FragColors [[attribute(2)]]; + float4 gl_Position [[attribute(1)]]; +}; + +struct main0_patchIn +{ + float4 FragColor [[attribute(0)]]; + float4 gl_TessLevelOuter [[attribute(3)]]; + float2 gl_TessLevelInner [[attribute(4)]]; + patch_control_point gl_in; +}; + +[[ patch(quad, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]], uint gl_PrimitiveID [[patch_id]]) +{ + main0_out out = {}; + spvUnsafeArray gl_TessLevelInner = {}; + spvUnsafeArray gl_TessLevelOuter = {}; + gl_TessLevelInner[0] = patchIn.gl_TessLevelInner.x; + gl_TessLevelInner[1] = patchIn.gl_TessLevelInner.y; + gl_TessLevelOuter[0] = patchIn.gl_TessLevelOuter.x; + gl_TessLevelOuter[1] = patchIn.gl_TessLevelOuter.y; + gl_TessLevelOuter[2] = patchIn.gl_TessLevelOuter.z; + gl_TessLevelOuter[3] = patchIn.gl_TessLevelOuter.w; + out.gl_Position = (((((float4(1.0) + patchIn.FragColor) + patchIn.gl_in[0].FragColors) + patchIn.gl_in[1].FragColors) + float4(gl_TessLevelInner[0])) + float4(gl_TessLevelOuter[int(gl_PrimitiveID) & 1])) + patchIn.gl_in[0].gl_Position; + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/tese/load-clip-cull.msl2.tese b/third_party/spirv-cross/reference/shaders-msl-no-opt/tese/load-clip-cull.msl2.tese new file mode 100644 index 0000000000..09c5cd7502 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/tese/load-clip-cull.msl2.tese @@ -0,0 +1,37 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 gl_Position [[attribute(0)]]; + float gl_ClipDistance_0 [[attribute(1)]]; + float gl_ClipDistance_1 [[attribute(2)]]; + float gl_CullDistance_0 [[attribute(3)]]; + float gl_CullDistance_1 [[attribute(4)]]; + float gl_CullDistance_2 [[attribute(5)]]; +}; + +struct main0_patchIn +{ + patch_control_point gl_in; +}; + +[[ patch(quad, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]]) +{ + main0_out out = {}; + out.gl_Position.x = patchIn.gl_in[0].gl_ClipDistance_0; + out.gl_Position.y = patchIn.gl_in[1].gl_CullDistance_0; + out.gl_Position.z = patchIn.gl_in[0].gl_ClipDistance_1; + out.gl_Position.w = patchIn.gl_in[1].gl_CullDistance_1; + out.gl_Position += patchIn.gl_in[0].gl_Position; + out.gl_Position += patchIn.gl_in[1].gl_Position; + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/cull-distance.for-tess.vert b/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/cull-distance.for-tess.vert new file mode 100644 index 0000000000..5c2311d741 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/cull-distance.for-tess.vert @@ -0,0 +1,62 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 gl_Position; + spvUnsafeArray gl_CullDistance; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 spvStageInputSize [[grid_size]], device main0_out* spvOut [[buffer(28)]]) +{ + device main0_out& out = spvOut[gl_GlobalInvocationID.y * spvStageInputSize.x + gl_GlobalInvocationID.x]; + if (any(gl_GlobalInvocationID >= spvStageInputSize)) + return; + out.gl_CullDistance[0] = 1.0; + out.gl_CullDistance[1] = 3.0; + out.gl_Position = float4(1.0); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/uninitialized-vertex-output.vert b/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/uninitialized-vertex-output.vert new file mode 100644 index 0000000000..f8209ae6fc --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/uninitialized-vertex-output.vert @@ -0,0 +1,18 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 Pos [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0() +{ + main0_out out = {}; + out.gl_Position = float4(1.0); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/unused-subgroup-builtin.msl22.vert b/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/unused-subgroup-builtin.msl22.vert new file mode 100644 index 0000000000..9e024c2095 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/unused-subgroup-builtin.msl22.vert @@ -0,0 +1,9 @@ +#include +#include + +using namespace metal; + +vertex void main0() +{ +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/vulkan/frag/texture-access-function.swizzle.vk.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/vulkan/frag/texture-access-function.swizzle.vk.frag index d4f70e0e1d..ba31506477 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/vulkan/frag/texture-access-function.swizzle.vk.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/vulkan/frag/texture-access-function.swizzle.vk.frag @@ -146,29 +146,29 @@ float4 do_samples(thread const texture1d t1, thread const sampler t1Smplr c = spvTextureSwizzle(tc.sample(defaultSampler, float3(0.0)), tcSwzl); c = spvTextureSwizzle(t2a.sample(t2aSmplr, float3(0.0).xy, uint(round(float3(0.0).z))), t2aSwzl); c = spvTextureSwizzle(tca.sample(tcaSmplr, float4(0.0).xyz, uint(round(float4(0.0).w))), tcaSwzl); - c.x = spvTextureSwizzle(d2.sample_compare(d2Smplr, float3(0.0, 0.0, 1.0).xy, float3(0.0, 0.0, 1.0).z), d2Swzl); - c.x = spvTextureSwizzle(dc.sample_compare(dcSmplr, float4(0.0, 0.0, 0.0, 1.0).xyz, float4(0.0, 0.0, 0.0, 1.0).w), dcSwzl); - c.x = spvTextureSwizzle(d2a.sample_compare(shadowSampler, float4(0.0, 0.0, 0.0, 1.0).xy, uint(round(float4(0.0, 0.0, 0.0, 1.0).z)), float4(0.0, 0.0, 0.0, 1.0).w), d2aSwzl); + c.x = spvTextureSwizzle(d2.sample_compare(d2Smplr, float3(0.0, 0.0, 1.0).xy, 1.0), d2Swzl); + c.x = spvTextureSwizzle(dc.sample_compare(dcSmplr, float4(0.0, 0.0, 0.0, 1.0).xyz, 1.0), dcSwzl); + c.x = spvTextureSwizzle(d2a.sample_compare(shadowSampler, float4(0.0, 0.0, 0.0, 1.0).xy, uint(round(float4(0.0, 0.0, 0.0, 1.0).z)), 1.0), d2aSwzl); c.x = spvTextureSwizzle(dca.sample_compare(dcaSmplr, float4(0.0).xyz, uint(round(float4(0.0).w)), 1.0), dcaSwzl); c = spvTextureSwizzle(t1.sample(t1Smplr, float2(0.0, 1.0).x / float2(0.0, 1.0).y), t1Swzl); c = spvTextureSwizzle(t2.sample(defaultSampler, float3(0.0, 0.0, 1.0).xy / float3(0.0, 0.0, 1.0).z), t2Swzl); c = spvTextureSwizzle(t3.sample(t3Smplr, float4(0.0, 0.0, 0.0, 1.0).xyz / float4(0.0, 0.0, 0.0, 1.0).w), t3Swzl); float4 _119 = float4(0.0, 0.0, 1.0, 1.0); - _119.z = float4(0.0, 0.0, 1.0, 1.0).w; - c.x = spvTextureSwizzle(d2.sample_compare(d2Smplr, _119.xy / _119.z, float4(0.0, 0.0, 1.0, 1.0).z / _119.z), d2Swzl); + _119.z = 1.0; + c.x = spvTextureSwizzle(d2.sample_compare(d2Smplr, _119.xy / _119.z, 1.0 / _119.z), d2Swzl); c = spvTextureSwizzle(t1.sample(t1Smplr, 0.0), t1Swzl); c = spvTextureSwizzle(t2.sample(defaultSampler, float2(0.0), level(0.0)), t2Swzl); c = spvTextureSwizzle(t3.sample(t3Smplr, float3(0.0), level(0.0)), t3Swzl); c = spvTextureSwizzle(tc.sample(defaultSampler, float3(0.0), level(0.0)), tcSwzl); c = spvTextureSwizzle(t2a.sample(t2aSmplr, float3(0.0).xy, uint(round(float3(0.0).z)), level(0.0)), t2aSwzl); c = spvTextureSwizzle(tca.sample(tcaSmplr, float4(0.0).xyz, uint(round(float4(0.0).w)), level(0.0)), tcaSwzl); - c.x = spvTextureSwizzle(d2.sample_compare(d2Smplr, float3(0.0, 0.0, 1.0).xy, float3(0.0, 0.0, 1.0).z, level(0.0)), d2Swzl); + c.x = spvTextureSwizzle(d2.sample_compare(d2Smplr, float3(0.0, 0.0, 1.0).xy, 1.0, level(0.0)), d2Swzl); c = spvTextureSwizzle(t1.sample(t1Smplr, float2(0.0, 1.0).x / float2(0.0, 1.0).y), t1Swzl); c = spvTextureSwizzle(t2.sample(defaultSampler, float3(0.0, 0.0, 1.0).xy / float3(0.0, 0.0, 1.0).z, level(0.0)), t2Swzl); c = spvTextureSwizzle(t3.sample(t3Smplr, float4(0.0, 0.0, 0.0, 1.0).xyz / float4(0.0, 0.0, 0.0, 1.0).w, level(0.0)), t3Swzl); float4 _153 = float4(0.0, 0.0, 1.0, 1.0); - _153.z = float4(0.0, 0.0, 1.0, 1.0).w; - c.x = spvTextureSwizzle(d2.sample_compare(d2Smplr, _153.xy / _153.z, float4(0.0, 0.0, 1.0, 1.0).z / _153.z, level(0.0)), d2Swzl); + _153.z = 1.0; + c.x = spvTextureSwizzle(d2.sample_compare(d2Smplr, _153.xy / _153.z, 1.0 / _153.z, level(0.0)), d2Swzl); c = spvTextureSwizzle(t1.read(uint(0)), t1Swzl); c = spvTextureSwizzle(t2.read(uint2(int2(0)), 0), t2Swzl); c = spvTextureSwizzle(t3.read(uint3(int3(0)), 0), t3Swzl); diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/comp/image-load-store-short-vector.invalid.asm.comp b/third_party/spirv-cross/reference/shaders-msl/asm/comp/image-load-store-short-vector.invalid.asm.comp new file mode 100644 index 0000000000..fca572e36f --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/asm/comp/image-load-store-short-vector.invalid.asm.comp @@ -0,0 +1,22 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +static inline __attribute__((always_inline)) +void _main(thread const uint3& id, thread texture2d TargetTexture) +{ + float2 loaded = TargetTexture.read(uint2(id.xy)).xy; + float2 storeTemp = loaded + float2(1.0); + TargetTexture.write(storeTemp.xyyy, uint2((id.xy + uint2(1u)))); +} + +kernel void main0(texture2d TargetTexture [[texture(0)]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]]) +{ + uint3 id = gl_WorkGroupID; + uint3 param = id; + _main(param, TargetTexture); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/frag/pull-model-interpolation.asm.msl23.frag b/third_party/spirv-cross/reference/shaders-msl/asm/frag/pull-model-interpolation.asm.msl23.frag index b721eb2281..a8095eeabe 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/frag/pull-model-interpolation.asm.msl23.frag +++ b/third_party/spirv-cross/reference/shaders-msl/asm/frag/pull-model-interpolation.asm.msl23.frag @@ -84,7 +84,7 @@ struct main0_in }; static inline __attribute__((always_inline)) -void func(thread float4& FragColor, thread float2 baz, thread spvUnsafeArray (&a), thread _13& s, thread main0_in& in) +void func(thread float4& FragColor, thread float2 baz, thread spvUnsafeArray& a, thread _13& s, thread main0_in& in) { float2 _237 = FragColor.xy + baz; FragColor = float4(_237.x, _237.y, FragColor.z, FragColor.w); diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/tesc/tess-level-overrun.multi-patch.asm.tesc b/third_party/spirv-cross/reference/shaders-msl/asm/tesc/tess-level-overrun.multi-patch.asm.tesc index a5f316ddfe..79395a4bbb 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/tesc/tess-level-overrun.multi-patch.asm.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/asm/tesc/tess-level-overrun.multi-patch.asm.tesc @@ -15,7 +15,7 @@ struct TessLevels kernel void main0(const device TessLevels& sb_levels [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], constant uint* spvIndirectParams [[buffer(29)]], device MTLTriangleTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { - uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 1, spvIndirectParams[1]); + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 1, spvIndirectParams[1] - 1); spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(sb_levels.inner0); spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(sb_levels.outer0); spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1] = half(sb_levels.outer1); diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/tese/unnamed-builtin-array.asm.tese b/third_party/spirv-cross/reference/shaders-msl/asm/tese/unnamed-builtin-array.asm.tese index 83ef729321..99803754d8 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/tese/unnamed-builtin-array.asm.tese +++ b/third_party/spirv-cross/reference/shaders-msl/asm/tese/unnamed-builtin-array.asm.tese @@ -1,8 +1,49 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct main0_out { float4 gl_Position [[position]]; @@ -10,14 +51,22 @@ struct main0_out struct main0_patchIn { - float2 gl_TessLevelInner [[attribute(0)]]; - float4 gl_TessLevelOuter [[attribute(1)]]; + float4 gl_TessLevelOuter [[attribute(0)]]; + float2 gl_TessLevelInner [[attribute(1)]]; }; [[ patch(quad, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]], float2 gl_TessCoord [[position_in_patch]]) { main0_out out = {}; - out.gl_Position = float4(((gl_TessCoord.x * patchIn.gl_TessLevelInner.x) * patchIn.gl_TessLevelOuter.x) + (((1.0 - gl_TessCoord.x) * patchIn.gl_TessLevelInner.x) * patchIn.gl_TessLevelOuter.z), ((gl_TessCoord.y * patchIn.gl_TessLevelInner.y) * patchIn.gl_TessLevelOuter.y) + (((1.0 - gl_TessCoord.y) * patchIn.gl_TessLevelInner.y) * patchIn.gl_TessLevelOuter.w), 0.0, 1.0); + spvUnsafeArray gl_TessLevelInner = {}; + spvUnsafeArray gl_TessLevelOuter = {}; + gl_TessLevelInner[0] = patchIn.gl_TessLevelInner.x; + gl_TessLevelInner[1] = patchIn.gl_TessLevelInner.y; + gl_TessLevelOuter[0] = patchIn.gl_TessLevelOuter.x; + gl_TessLevelOuter[1] = patchIn.gl_TessLevelOuter.y; + gl_TessLevelOuter[2] = patchIn.gl_TessLevelOuter.z; + gl_TessLevelOuter[3] = patchIn.gl_TessLevelOuter.w; + out.gl_Position = float4(((gl_TessCoord.x * gl_TessLevelInner[0]) * gl_TessLevelOuter[0]) + (((1.0 - gl_TessCoord.x) * gl_TessLevelInner[0]) * gl_TessLevelOuter[2]), ((gl_TessCoord.y * gl_TessLevelInner[1]) * gl_TessLevelOuter[1]) + (((1.0 - gl_TessCoord.y) * gl_TessLevelInner[1]) * gl_TessLevelOuter[3]), 0.0, 1.0); return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/vert/fake-builtin-input.asm.vert b/third_party/spirv-cross/reference/shaders-msl/asm/vert/fake-builtin-input.asm.vert index f9fcbc85c3..3079ae9bcb 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/vert/fake-builtin-input.asm.vert +++ b/third_party/spirv-cross/reference/shaders-msl/asm/vert/fake-builtin-input.asm.vert @@ -5,6 +5,7 @@ using namespace metal; struct main0_out { + half4 out_var_SV_Target [[user(locn0)]]; float4 gl_Position [[position]]; }; diff --git a/third_party/spirv-cross/reference/shaders-msl/desktop-only/tesc/basic.desktop.sso.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/desktop-only/tesc/basic.desktop.sso.multi-patch.tesc index f4b1479b9e..6aca015783 100644 --- a/third_party/spirv-cross/reference/shaders-msl/desktop-only/tesc/basic.desktop.sso.multi-patch.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/desktop-only/tesc/basic.desktop.sso.multi-patch.tesc @@ -34,7 +34,7 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 1]; device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 1, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; uint gl_InvocationID = gl_GlobalInvocationID.x % 1; - uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 1, spvIndirectParams[1]); + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 1, spvIndirectParams[1] - 1); spvTessLevel[gl_PrimitiveID].insideTessellationFactor[0] = half(8.8999996185302734375); spvTessLevel[gl_PrimitiveID].insideTessellationFactor[1] = half(6.900000095367431640625); spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(8.8999996185302734375); diff --git a/third_party/spirv-cross/reference/shaders-msl/desktop-only/tesc/struct-copy.desktop.sso.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/desktop-only/tesc/struct-copy.desktop.sso.multi-patch.tesc index e47d56a202..184a4a6f9b 100644 --- a/third_party/spirv-cross/reference/shaders-msl/desktop-only/tesc/struct-copy.desktop.sso.multi-patch.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/desktop-only/tesc/struct-copy.desktop.sso.multi-patch.tesc @@ -16,8 +16,7 @@ struct main0_out struct main0_in { - float3 Boo_a; - uint3 Boo_b; + Boo vInput; }; kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]]) @@ -25,9 +24,8 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; - uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1]); - Boo _26 = Boo{ gl_in[gl_InvocationID].Boo_a, gl_in[gl_InvocationID].Boo_b }; - gl_out[gl_InvocationID].vVertex = _26; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + gl_out[gl_InvocationID].vVertex = gl_in[gl_InvocationID].vInput; spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(1.0); spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1] = half(2.0); spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2] = half(3.0); diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/array-component-io.frag b/third_party/spirv-cross/reference/shaders-msl/frag/array-component-io.frag new file mode 100644 index 0000000000..9b4c5b5204 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/frag/array-component-io.frag @@ -0,0 +1,99 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 m_location_0 [[color(0)]]; + float4 m_location_1 [[color(1)]]; + float4 m_location_2 [[color(2)]]; +}; + +struct main0_in +{ + float InC_0 [[user(locn0_1), flat]]; + float InA_0 [[user(locn1), flat]]; + float InC_1 [[user(locn1_1), flat]]; + float2 InB_0 [[user(locn1_2), flat]]; + float InA_1 [[user(locn2), flat]]; + float InC_2 [[user(locn2_1), flat]]; + float2 InB_1 [[user(locn2_2), flat]]; + float InD [[user(locn3_1), sample_perspective]]; + float InE [[user(locn4_2), center_no_perspective]]; + float InF [[user(locn5_3), centroid_perspective]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + spvUnsafeArray A = {}; + spvUnsafeArray B = {}; + spvUnsafeArray C = {}; + float D = {}; + spvUnsafeArray InA = {}; + spvUnsafeArray InB = {}; + spvUnsafeArray InC = {}; + InA[0] = in.InA_0; + InA[1] = in.InA_1; + InB[0] = in.InB_0; + InB[1] = in.InB_1; + InC[0] = in.InC_0; + InC[1] = in.InC_1; + InC[2] = in.InC_2; + A = InA; + B = InB; + C = InC; + D = (in.InD + in.InE) + in.InF; + out.m_location_1.x = A[0]; + out.m_location_2.x = A[1]; + out.m_location_1.zw = B[0]; + out.m_location_2.zw = B[1]; + out.m_location_0.y = C[0]; + out.m_location_1.y = C[1]; + out.m_location_2.y = C[2]; + out.m_location_0.w = D; + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/basic.force-sample.frag b/third_party/spirv-cross/reference/shaders-msl/frag/basic.force-sample.frag new file mode 100644 index 0000000000..b9706b73f5 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/frag/basic.force-sample.frag @@ -0,0 +1,23 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +struct main0_in +{ + float4 vColor [[user(locn0)]]; + float2 vTex [[user(locn1)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texture2d uTex [[texture(0)]], sampler uTexSmplr [[sampler(0)]], uint gl_SampleID [[sample_id]]) +{ + main0_out out = {}; + out.FragColor = in.vColor * uTex.sample(uTexSmplr, in.vTex); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/cull-distance-varying.frag b/third_party/spirv-cross/reference/shaders-msl/frag/cull-distance-varying.frag new file mode 100644 index 0000000000..708a295710 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/frag/cull-distance-varying.frag @@ -0,0 +1,67 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +struct main0_in +{ + float gl_CullDistance_0 [[user(cull0)]]; + float gl_CullDistance_1 [[user(cull1)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + spvUnsafeArray gl_CullDistance = {}; + gl_CullDistance[0] = in.gl_CullDistance_0; + gl_CullDistance[1] = in.gl_CullDistance_1; + out.FragColor = float4((1.0 - gl_CullDistance[0]) - gl_CullDistance[1]); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/fragment-component-padding.pad-fragment.frag b/third_party/spirv-cross/reference/shaders-msl/frag/fragment-component-padding.pad-fragment.frag index 9a8e14dd56..6420bb9f4e 100644 --- a/third_party/spirv-cross/reference/shaders-msl/frag/fragment-component-padding.pad-fragment.frag +++ b/third_party/spirv-cross/reference/shaders-msl/frag/fragment-component-padding.pad-fragment.frag @@ -58,7 +58,7 @@ struct main0_in }; static inline __attribute__((always_inline)) -void set_globals(thread spvUnsafeArray (&FragColors), thread float3& vColor, thread float2& FragColor2, thread float3& FragColor3) +void set_globals(thread spvUnsafeArray& FragColors, thread float3& vColor, thread float2& FragColor2, thread float3& FragColor3) { FragColors[0] = vColor.x; FragColors[1] = vColor.y; diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/input-attachment-ms.arrayed-subpass.msl21.frag b/third_party/spirv-cross/reference/shaders-msl/frag/input-attachment-ms.arrayed-subpass.msl21.frag index 30ad95beac..f7b1441fe1 100644 --- a/third_party/spirv-cross/reference/shaders-msl/frag/input-attachment-ms.arrayed-subpass.msl21.frag +++ b/third_party/spirv-cross/reference/shaders-msl/frag/input-attachment-ms.arrayed-subpass.msl21.frag @@ -20,6 +20,7 @@ float4 load_subpasses(thread const texture2d_ms_array uInput, thread uint fragment main0_out main0(texture2d_ms_array uSubpass0 [[texture(0)]], texture2d_ms_array uSubpass1 [[texture(1)]], uint gl_SampleID [[sample_id]], float4 gl_FragCoord [[position]], uint gl_Layer [[render_target_array_index]]) { main0_out out = {}; + gl_FragCoord.xy += get_sample_position(gl_SampleID) - 0.5; out.FragColor = (uSubpass0.read(uint2(gl_FragCoord.xy), gl_Layer, 1) + uSubpass1.read(uint2(gl_FragCoord.xy), gl_Layer, 2)) + load_subpasses(uSubpass0, gl_SampleID, gl_FragCoord, gl_Layer); return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/input-attachment-ms.frag b/third_party/spirv-cross/reference/shaders-msl/frag/input-attachment-ms.frag index 25d2e7d3b2..5e1f504aed 100644 --- a/third_party/spirv-cross/reference/shaders-msl/frag/input-attachment-ms.frag +++ b/third_party/spirv-cross/reference/shaders-msl/frag/input-attachment-ms.frag @@ -20,6 +20,7 @@ float4 load_subpasses(thread const texture2d_ms uInput, thread uint& gl_S fragment main0_out main0(texture2d_ms uSubpass0 [[texture(0)]], texture2d_ms uSubpass1 [[texture(1)]], uint gl_SampleID [[sample_id]], float4 gl_FragCoord [[position]]) { main0_out out = {}; + gl_FragCoord.xy += get_sample_position(gl_SampleID) - 0.5; out.FragColor = (uSubpass0.read(uint2(gl_FragCoord.xy), 1) + uSubpass1.read(uint2(gl_FragCoord.xy), 2)) + load_subpasses(uSubpass0, gl_SampleID, gl_FragCoord); return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/input-attachment-ms.multiview.msl21.frag b/third_party/spirv-cross/reference/shaders-msl/frag/input-attachment-ms.multiview.msl21.frag index a2e5ef7d0c..5e8c5339b8 100644 --- a/third_party/spirv-cross/reference/shaders-msl/frag/input-attachment-ms.multiview.msl21.frag +++ b/third_party/spirv-cross/reference/shaders-msl/frag/input-attachment-ms.multiview.msl21.frag @@ -20,6 +20,7 @@ float4 load_subpasses(thread const texture2d_ms_array uInput, thread uint fragment main0_out main0(constant uint* spvViewMask [[buffer(24)]], texture2d_ms_array uSubpass0 [[texture(0)]], texture2d_ms_array uSubpass1 [[texture(1)]], uint gl_SampleID [[sample_id]], float4 gl_FragCoord [[position]], uint gl_ViewIndex [[render_target_array_index]]) { main0_out out = {}; + gl_FragCoord.xy += get_sample_position(gl_SampleID) - 0.5; gl_ViewIndex += spvViewMask[0]; out.FragColor = (uSubpass0.read(uint2(gl_FragCoord.xy), gl_ViewIndex, 1) + uSubpass1.read(uint2(gl_FragCoord.xy), gl_ViewIndex, 2)) + load_subpasses(uSubpass0, gl_SampleID, gl_FragCoord, gl_ViewIndex); return out; diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/mrt-array.frag b/third_party/spirv-cross/reference/shaders-msl/frag/mrt-array.frag index 2746ad6396..2628fbc930 100644 --- a/third_party/spirv-cross/reference/shaders-msl/frag/mrt-array.frag +++ b/third_party/spirv-cross/reference/shaders-msl/frag/mrt-array.frag @@ -66,13 +66,13 @@ inline Tx mod(Tx x, Ty y) } static inline __attribute__((always_inline)) -void write_deeper_in_function(thread spvUnsafeArray (&FragColor), thread float4& vA, thread float4& vB) +void write_deeper_in_function(thread spvUnsafeArray& FragColor, thread float4& vA, thread float4& vB) { FragColor[3] = vA * vB; } static inline __attribute__((always_inline)) -void write_in_function(thread spvUnsafeArray (&FragColor), thread float4& vA, thread float4& vB) +void write_in_function(thread spvUnsafeArray& FragColor, thread float4& vA, thread float4& vB) { FragColor[2] = vA - vB; write_deeper_in_function(FragColor, vA, vB); diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/nonuniform-qualifier.msl2.frag b/third_party/spirv-cross/reference/shaders-msl/frag/nonuniform-qualifier.msl2.frag index e896c2d067..401703cbaf 100644 --- a/third_party/spirv-cross/reference/shaders-msl/frag/nonuniform-qualifier.msl2.frag +++ b/third_party/spirv-cross/reference/shaders-msl/frag/nonuniform-qualifier.msl2.frag @@ -47,10 +47,10 @@ fragment main0_out main0(main0_in in [[stage_in]], constant UBO* ubos_0 [[buffer out.FragColor = uCombinedSamplers[_53].sample(uCombinedSamplersSmplr[_53], in.vUV); int _69 = i + 20; int _73 = i + 40; - out.FragColor += ubos[(_69)]->v[_73]; + out.FragColor += ubos[_69]->v[_73]; int _87 = i + 50; int _91 = i + 60; - out.FragColor += ssbos[(_87)]->v[_91]; + out.FragColor += ssbos[_87]->v[_91]; return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/read-cull-clip-distance-in-function.frag b/third_party/spirv-cross/reference/shaders-msl/frag/read-cull-clip-distance-in-function.frag new file mode 100644 index 0000000000..02d57d9bee --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/frag/read-cull-clip-distance-in-function.frag @@ -0,0 +1,78 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +struct main0_in +{ + float gl_ClipDistance_0 [[user(clip0)]]; + float gl_ClipDistance_1 [[user(clip1)]]; + float gl_CullDistance_0 [[user(cull0)]]; + float gl_CullDistance_1 [[user(cull1)]]; +}; + +static inline __attribute__((always_inline)) +float4 read_in_func(thread spvUnsafeArray& gl_CullDistance, thread spvUnsafeArray& gl_ClipDistance) +{ + return float4(gl_CullDistance[0], gl_CullDistance[1], gl_ClipDistance[0], gl_ClipDistance[1]); +} + +fragment main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + spvUnsafeArray gl_CullDistance = {}; + spvUnsafeArray gl_ClipDistance = {}; + gl_CullDistance[0] = in.gl_CullDistance_0; + gl_CullDistance[1] = in.gl_CullDistance_1; + gl_ClipDistance[0] = in.gl_ClipDistance_0; + gl_ClipDistance[1] = in.gl_ClipDistance_1; + out.FragColor = read_in_func(gl_CullDistance, gl_ClipDistance); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/sample-depth-separate-image-sampler.frag b/third_party/spirv-cross/reference/shaders-msl/frag/sample-depth-separate-image-sampler.frag index d285941d7a..115ed9fa73 100644 --- a/third_party/spirv-cross/reference/shaders-msl/frag/sample-depth-separate-image-sampler.frag +++ b/third_party/spirv-cross/reference/shaders-msl/frag/sample-depth-separate-image-sampler.frag @@ -13,7 +13,7 @@ struct main0_out static inline __attribute__((always_inline)) float sample_depth_from_function(thread const depth2d uT, thread const sampler uS) { - return uT.sample_compare(uS, float3(0.5).xy, float3(0.5).z); + return uT.sample_compare(uS, float3(0.5).xy, 0.5); } static inline __attribute__((always_inline)) diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/sample-rate-frag-coord-sample-id.frag b/third_party/spirv-cross/reference/shaders-msl/frag/sample-rate-frag-coord-sample-id.frag new file mode 100644 index 0000000000..5df60f909e --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/frag/sample-rate-frag-coord-sample-id.frag @@ -0,0 +1,19 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(texture2d_array tex [[texture(0)]], sampler texSmplr [[sampler(0)]], float4 gl_FragCoord [[position]], uint gl_SampleID [[sample_id]]) +{ + main0_out out = {}; + gl_FragCoord.xy += get_sample_position(gl_SampleID) - 0.5; + float3 _28 = float3(gl_FragCoord.xy, float(gl_SampleID)); + out.FragColor = tex.sample(texSmplr, _28.xy, uint(round(_28.z))); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/sample-rate-frag-coord-sample-input.frag b/third_party/spirv-cross/reference/shaders-msl/frag/sample-rate-frag-coord-sample-input.frag new file mode 100644 index 0000000000..386230ef0c --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/frag/sample-rate-frag-coord-sample-input.frag @@ -0,0 +1,24 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +struct main0_in +{ + float foo [[user(locn0), sample_perspective]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texture2d_array tex [[texture(0)]], sampler texSmplr [[sampler(0)]], float4 gl_FragCoord [[position]], uint gl_SampleID [[sample_id]]) +{ + main0_out out = {}; + gl_FragCoord.xy += get_sample_position(gl_SampleID) - 0.5; + float3 _26 = float3(gl_FragCoord.xy, in.foo); + out.FragColor = tex.sample(texSmplr, _26.xy, uint(round(_26.z))); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/sample-rate-frag-coord-sample-pos.frag b/third_party/spirv-cross/reference/shaders-msl/frag/sample-rate-frag-coord-sample-pos.frag new file mode 100644 index 0000000000..f8f357fe7c --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/frag/sample-rate-frag-coord-sample-pos.frag @@ -0,0 +1,19 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(texture2d tex [[texture(0)]], sampler texSmplr [[sampler(0)]], float4 gl_FragCoord [[position]], uint gl_SampleID [[sample_id]]) +{ + main0_out out = {}; + gl_FragCoord.xy += get_sample_position(gl_SampleID) - 0.5; + float2 gl_SamplePosition = get_sample_position(gl_SampleID); + out.FragColor = tex.sample(texSmplr, (gl_FragCoord.xy - gl_SamplePosition)); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/sample-rate-frag-coord.force-sample.frag b/third_party/spirv-cross/reference/shaders-msl/frag/sample-rate-frag-coord.force-sample.frag new file mode 100644 index 0000000000..1ed8148d4c --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/frag/sample-rate-frag-coord.force-sample.frag @@ -0,0 +1,18 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(texture2d tex [[texture(0)]], sampler texSmplr [[sampler(0)]], float4 gl_FragCoord [[position]], uint gl_SampleID [[sample_id]]) +{ + main0_out out = {}; + gl_FragCoord.xy += get_sample_position(gl_SampleID) - 0.5; + out.FragColor = tex.sample(texSmplr, gl_FragCoord.xy); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/subgroup-globals-extract.msl22.frag b/third_party/spirv-cross/reference/shaders-msl/frag/subgroup-globals-extract.msl22.frag new file mode 100644 index 0000000000..ccd83bb50b --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/frag/subgroup-globals-extract.msl22.frag @@ -0,0 +1,86 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_out +{ + uint2 FragColor [[color(0)]]; +}; + +inline uint spvSubgroupBallotFindLSB(uint4 ballot, uint gl_SubgroupSize) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupSize, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupSize - 32, 0)), uint2(0)); + ballot &= mask; + return select(ctz(ballot.x), select(32 + ctz(ballot.y), select(64 + ctz(ballot.z), select(96 + ctz(ballot.w), uint(-1), ballot.w == 0), ballot.z == 0), ballot.y == 0), ballot.x == 0); +} + +inline uint spvSubgroupBallotFindMSB(uint4 ballot, uint gl_SubgroupSize) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupSize, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupSize - 32, 0)), uint2(0)); + ballot &= mask; + return select(128 - (clz(ballot.w) + 1), select(96 - (clz(ballot.z) + 1), select(64 - (clz(ballot.y) + 1), select(32 - (clz(ballot.x) + 1), uint(-1), ballot.x == 0), ballot.y == 0), ballot.z == 0), ballot.w == 0); +} + +inline uint spvPopCount4(uint4 ballot) +{ + return popcount(ballot.x) + popcount(ballot.y) + popcount(ballot.z) + popcount(ballot.w); +} + +inline uint spvSubgroupBallotBitCount(uint4 ballot, uint gl_SubgroupSize) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupSize, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupSize - 32, 0)), uint2(0)); + return spvPopCount4(ballot & mask); +} + +inline uint spvSubgroupBallotInclusiveBitCount(uint4 ballot, uint gl_SubgroupInvocationID) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID + 1, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID + 1 - 32, 0)), uint2(0)); + return spvPopCount4(ballot & mask); +} + +inline uint spvSubgroupBallotExclusiveBitCount(uint4 ballot, uint gl_SubgroupInvocationID) +{ + uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID - 32, 0)), uint2(0)); + return spvPopCount4(ballot & mask); +} + +static inline __attribute__((always_inline)) +uint sub1(thread uint& gl_SubgroupSize) +{ + return spvSubgroupBallotFindLSB(uint4(1u, 2u, 3u, 4u), gl_SubgroupSize); +} + +static inline __attribute__((always_inline)) +uint sub2(thread uint& gl_SubgroupSize) +{ + return spvSubgroupBallotFindMSB(uint4(1u, 2u, 3u, 4u), gl_SubgroupSize); +} + +static inline __attribute__((always_inline)) +uint sub3(thread uint& gl_SubgroupSize) +{ + return spvSubgroupBallotBitCount(uint4(1u, 2u, 3u, 4u), gl_SubgroupSize); +} + +static inline __attribute__((always_inline)) +uint sub4(thread uint& gl_SubgroupInvocationID) +{ + return spvSubgroupBallotInclusiveBitCount(uint4(1u, 2u, 3u, 4u), gl_SubgroupInvocationID); +} + +static inline __attribute__((always_inline)) +uint sub5(thread uint& gl_SubgroupInvocationID) +{ + return spvSubgroupBallotExclusiveBitCount(uint4(1u, 2u, 3u, 4u), gl_SubgroupInvocationID); +} + +fragment main0_out main0(uint gl_SubgroupInvocationID [[thread_index_in_simdgroup]], uint gl_SubgroupSize [[threads_per_simdgroup]]) +{ + main0_out out = {}; + out.FragColor.x = (((sub1(gl_SubgroupSize) + sub2(gl_SubgroupSize)) + sub3(gl_SubgroupSize)) + sub4(gl_SubgroupInvocationID)) + sub5(gl_SubgroupInvocationID); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/copy-arrays.mask-location-0.msl2.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/copy-arrays.mask-location-0.msl2.multi-patch.tesc new file mode 100644 index 0000000000..406feed975 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/copy-arrays.mask-location-0.msl2.multi-patch.tesc @@ -0,0 +1,188 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 gl_Position; +}; + +struct main0_patchOut +{ + spvUnsafeArray pFoo; +}; + +struct main0_in +{ + spvUnsafeArray iFoo; + float4 ipFoo; +}; + +template +inline void spvArrayCopyFromConstantToStack1(thread T (&dst)[A], constant T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromConstantToThreadGroup1(threadgroup T (&dst)[A], constant T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromStackToStack1(thread T (&dst)[A], thread const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromStackToThreadGroup1(threadgroup T (&dst)[A], thread const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromThreadGroupToStack1(thread T (&dst)[A], threadgroup const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromThreadGroupToThreadGroup1(threadgroup T (&dst)[A], threadgroup const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromDeviceToDevice1(device T (&dst)[A], device const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromConstantToDevice1(device T (&dst)[A], constant T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromStackToDevice1(device T (&dst)[A], thread const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromThreadGroupToDevice1(device T (&dst)[A], threadgroup const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromDeviceToStack1(thread T (&dst)[A], device const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromDeviceToThreadGroup1(threadgroup T (&dst)[A], device const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]]) +{ + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + threadgroup float4 spvStorageFoo[8][4][2]; + threadgroup float4 (&Foo)[4][2] = spvStorageFoo[(gl_GlobalInvocationID.x / 4) % 8]; + device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; + device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + gl_out[gl_InvocationID].gl_Position = float4(1.0); + spvArrayCopyFromDeviceToThreadGroup1(Foo[gl_InvocationID], gl_in[gl_InvocationID].iFoo.elements); + if (gl_InvocationID == 0) + { + spvUnsafeArray _56 = spvUnsafeArray({ gl_in[0].ipFoo, gl_in[1].ipFoo }); + patchOut.pFoo = _56; + } +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/copy-arrays.mask-location-0.msl2.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/copy-arrays.mask-location-0.msl2.tesc new file mode 100644 index 0000000000..e9dd68dc37 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/copy-arrays.mask-location-0.msl2.tesc @@ -0,0 +1,191 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 gl_Position; +}; + +struct main0_patchOut +{ + spvUnsafeArray pFoo; +}; + +struct main0_in +{ + float4 iFoo_0 [[attribute(0)]]; + float4 iFoo_1 [[attribute(1)]]; + float4 ipFoo [[attribute(2)]]; +}; + +template +inline void spvArrayCopyFromConstantToStack1(thread T (&dst)[A], constant T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromConstantToThreadGroup1(threadgroup T (&dst)[A], constant T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromStackToStack1(thread T (&dst)[A], thread const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromStackToThreadGroup1(threadgroup T (&dst)[A], thread const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromThreadGroupToStack1(thread T (&dst)[A], threadgroup const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromThreadGroupToThreadGroup1(threadgroup T (&dst)[A], threadgroup const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromDeviceToDevice1(device T (&dst)[A], device const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromConstantToDevice1(device T (&dst)[A], constant T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromStackToDevice1(device T (&dst)[A], thread const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromThreadGroupToDevice1(device T (&dst)[A], threadgroup const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromDeviceToStack1(thread T (&dst)[A], device const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromDeviceToThreadGroup1(threadgroup T (&dst)[A], device const T (&src)[A]) +{ + for (uint i = 0; i < A; i++) + { + dst[i] = src[i]; + } +} + +kernel void main0(main0_in in [[stage_in]], uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], threadgroup main0_in* gl_in [[threadgroup(0)]]) +{ + threadgroup float4 Foo[4][2]; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + if (gl_InvocationID < spvIndirectParams[0]) + gl_in[gl_InvocationID] = in; + threadgroup_barrier(mem_flags::mem_threadgroup); + if (gl_InvocationID >= 4) + return; + gl_out[gl_InvocationID].gl_Position = float4(1.0); + spvUnsafeArray _38 = spvUnsafeArray({ gl_in[gl_InvocationID].iFoo_0, gl_in[gl_InvocationID].iFoo_1 }); + spvArrayCopyFromStackToThreadGroup1(Foo[gl_InvocationID], _38.elements); + if (gl_InvocationID == 0) + { + spvUnsafeArray _56 = spvUnsafeArray({ gl_in[0].ipFoo, gl_in[1].ipFoo }); + patchOut.pFoo = _56; + } +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/copy-arrays.mask-location-1.msl2.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/copy-arrays.mask-location-1.msl2.multi-patch.tesc new file mode 100644 index 0000000000..abc95ca899 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/copy-arrays.mask-location-1.msl2.multi-patch.tesc @@ -0,0 +1,79 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + spvUnsafeArray Foo; + float4 gl_Position; +}; + +struct main0_patchOut +{ + spvUnsafeArray pFoo; +}; + +struct main0_in +{ + spvUnsafeArray iFoo; + float4 ipFoo; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]]) +{ + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; + device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + gl_out[gl_InvocationID].gl_Position = float4(1.0); + gl_out[gl_InvocationID].Foo = gl_in[gl_InvocationID].iFoo; + if (gl_InvocationID == 0) + { + spvUnsafeArray _56 = spvUnsafeArray({ gl_in[0].ipFoo, gl_in[1].ipFoo }); + patchOut.pFoo = _56; + } +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/copy-arrays.mask-location-1.msl2.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/copy-arrays.mask-location-1.msl2.tesc new file mode 100644 index 0000000000..3da1d18c61 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/copy-arrays.mask-location-1.msl2.tesc @@ -0,0 +1,83 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + spvUnsafeArray Foo; + float4 gl_Position; +}; + +struct main0_patchOut +{ + spvUnsafeArray pFoo; +}; + +struct main0_in +{ + float4 iFoo_0 [[attribute(0)]]; + float4 iFoo_1 [[attribute(1)]]; + float4 ipFoo [[attribute(2)]]; +}; + +kernel void main0(main0_in in [[stage_in]], uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], threadgroup main0_in* gl_in [[threadgroup(0)]]) +{ + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + if (gl_InvocationID < spvIndirectParams[0]) + gl_in[gl_InvocationID] = in; + threadgroup_barrier(mem_flags::mem_threadgroup); + if (gl_InvocationID >= 4) + return; + gl_out[gl_InvocationID].gl_Position = float4(1.0); + spvUnsafeArray _38 = spvUnsafeArray({ gl_in[gl_InvocationID].iFoo_0, gl_in[gl_InvocationID].iFoo_1 }); + gl_out[gl_InvocationID].Foo = _38; + if (gl_InvocationID == 0) + { + spvUnsafeArray _56 = spvUnsafeArray({ gl_in[0].ipFoo, gl_in[1].ipFoo }); + patchOut.pFoo = _56; + } +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-0.for-tess.vert b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-0.for-tess.vert new file mode 100644 index 0000000000..f7b1acb576 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-0.for-tess.vert @@ -0,0 +1,35 @@ +#include +#include + +using namespace metal; + +struct V +{ + float4 a; + float4 b; + float4 c; + float4 d; +}; + +struct main0_out +{ + float4 V_b; + float4 V_c; + float4 V_d; + float4 gl_Position; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 spvStageInputSize [[grid_size]], device main0_out* spvOut [[buffer(28)]]) +{ + V _22 = {}; + device main0_out& out = spvOut[gl_GlobalInvocationID.y * spvStageInputSize.x + gl_GlobalInvocationID.x]; + if (any(gl_GlobalInvocationID >= spvStageInputSize)) + return; + out.gl_Position = float4(1.0); + _22.a = float4(2.0); + _22.b = float4(3.0); + out.V_b = _22.b; + out.V_c = _22.c; + out.V_d = _22.d; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-0.msl2.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-0.msl2.tesc new file mode 100644 index 0000000000..e0641663f6 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-0.msl2.tesc @@ -0,0 +1,49 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct P +{ + float a; + float b; +}; + +struct C +{ + float a; + float b; +}; + +struct main0_out +{ + float C_a; + float C_b; + float4 gl_Position; +}; + +struct main0_patchOut +{ + float P_b; +}; + +static inline __attribute__((always_inline)) +void write_in_function(threadgroup P& _11, device main0_patchOut& patchOut, device main0_out* thread & gl_out, thread uint& gl_InvocationID) +{ + _11.a = 1.0; + patchOut.P_b = 2.0; + gl_out[gl_InvocationID].C_a = 3.0; + gl_out[gl_InvocationID].C_b = 4.0; + gl_out[gl_InvocationID].gl_Position = float4(1.0); +} + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + threadgroup P _11; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + write_in_function(_11, patchOut, gl_out, gl_InvocationID); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-0.multi-patch.msl2.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-0.multi-patch.msl2.tesc new file mode 100644 index 0000000000..6ba7a48498 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-0.multi-patch.msl2.tesc @@ -0,0 +1,52 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct P +{ + float a; + float b; +}; + +struct C +{ + float a; + float b; +}; + +struct main0_out +{ + float C_a; + float C_b; + float4 gl_Position; +}; + +struct main0_patchOut +{ + float P_b; +}; + +static inline __attribute__((always_inline)) +void write_in_function(threadgroup P& _11, device main0_patchOut& patchOut, device main0_out* thread & gl_out, thread uint& gl_InvocationID) +{ + _11.a = 1.0; + patchOut.P_b = 2.0; + gl_out[gl_InvocationID].C_a = 3.0; + gl_out[gl_InvocationID].C_b = 4.0; + gl_out[gl_InvocationID].gl_Position = float4(1.0); +} + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; + threadgroup P spvStorage_11[8]; + threadgroup P (&_11) = spvStorage_11[(gl_GlobalInvocationID.x / 4) % 8]; + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + write_in_function(_11, patchOut, gl_out, gl_InvocationID); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-0.vert b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-0.vert new file mode 100644 index 0000000000..648a11adce --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-0.vert @@ -0,0 +1,34 @@ +#include +#include + +using namespace metal; + +struct V +{ + float4 a; + float4 b; + float4 c; + float4 d; +}; + +struct main0_out +{ + float4 V_b [[user(locn1)]]; + float4 V_c [[user(locn2)]]; + float4 V_d [[user(locn3)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0() +{ + main0_out out = {}; + V _22 = {}; + out.gl_Position = float4(1.0); + _22.a = float4(2.0); + _22.b = float4(3.0); + out.V_b = _22.b; + out.V_c = _22.c; + out.V_d = _22.d; + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-1.for-tess.vert b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-1.for-tess.vert new file mode 100644 index 0000000000..25fd5f5089 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-1.for-tess.vert @@ -0,0 +1,35 @@ +#include +#include + +using namespace metal; + +struct V +{ + float4 a; + float4 b; + float4 c; + float4 d; +}; + +struct main0_out +{ + float4 V_a; + float4 V_c; + float4 V_d; + float4 gl_Position; +}; + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 spvStageInputSize [[grid_size]], device main0_out* spvOut [[buffer(28)]]) +{ + V _22 = {}; + device main0_out& out = spvOut[gl_GlobalInvocationID.y * spvStageInputSize.x + gl_GlobalInvocationID.x]; + if (any(gl_GlobalInvocationID >= spvStageInputSize)) + return; + out.gl_Position = float4(1.0); + _22.a = float4(2.0); + _22.b = float4(3.0); + out.V_a = _22.a; + out.V_c = _22.c; + out.V_d = _22.d; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-1.msl2.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-1.msl2.tesc new file mode 100644 index 0000000000..e40fa2d663 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-1.msl2.tesc @@ -0,0 +1,49 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct P +{ + float a; + float b; +}; + +struct C +{ + float a; + float b; +}; + +struct main0_out +{ + float C_b; + float4 gl_Position; +}; + +struct main0_patchOut +{ + float P_a; + float P_b; +}; + +static inline __attribute__((always_inline)) +void write_in_function(device main0_patchOut& patchOut, threadgroup C (&c)[4], device main0_out* thread & gl_out, thread uint& gl_InvocationID) +{ + patchOut.P_a = 1.0; + patchOut.P_b = 2.0; + c[gl_InvocationID].a = 3.0; + gl_out[gl_InvocationID].C_b = 4.0; + gl_out[gl_InvocationID].gl_Position = float4(1.0); +} + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + threadgroup C c[4]; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + write_in_function(patchOut, c, gl_out, gl_InvocationID); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-1.multi-patch.msl2.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-1.multi-patch.msl2.tesc new file mode 100644 index 0000000000..9629253138 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-1.multi-patch.msl2.tesc @@ -0,0 +1,52 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct P +{ + float a; + float b; +}; + +struct C +{ + float a; + float b; +}; + +struct main0_out +{ + float C_b; + float4 gl_Position; +}; + +struct main0_patchOut +{ + float P_a; + float P_b; +}; + +static inline __attribute__((always_inline)) +void write_in_function(device main0_patchOut& patchOut, threadgroup C (&c)[4], device main0_out* thread & gl_out, thread uint& gl_InvocationID) +{ + patchOut.P_a = 1.0; + patchOut.P_b = 2.0; + c[gl_InvocationID].a = 3.0; + gl_out[gl_InvocationID].C_b = 4.0; + gl_out[gl_InvocationID].gl_Position = float4(1.0); +} + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + threadgroup C spvStoragec[8][4]; + threadgroup C (&c)[4] = spvStoragec[(gl_GlobalInvocationID.x / 4) % 8]; + device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + write_in_function(patchOut, c, gl_out, gl_InvocationID); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-1.vert b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-1.vert new file mode 100644 index 0000000000..1a4c18f05b --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs-block.mask-location-1.vert @@ -0,0 +1,34 @@ +#include +#include + +using namespace metal; + +struct V +{ + float4 a; + float4 b; + float4 c; + float4 d; +}; + +struct main0_out +{ + float4 V_a [[user(locn0)]]; + float4 V_c [[user(locn2)]]; + float4 V_d [[user(locn3)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0() +{ + main0_out out = {}; + V _22 = {}; + out.gl_Position = float4(1.0); + _22.a = float4(2.0); + _22.b = float4(3.0); + out.V_a = _22.a; + out.V_c = _22.c; + out.V_d = _22.d; + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-clip-distance.vert b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-clip-distance.vert new file mode 100644 index 0000000000..2a0508361e --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-clip-distance.vert @@ -0,0 +1,73 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 v0 [[user(locn0)]]; + float4 v1 [[user(locn1)]]; + float4 gl_Position [[position]]; + float gl_PointSize [[point_size]]; +}; + +static inline __attribute__((always_inline)) +void write_in_func(thread float4& v0, thread float4& v1, thread float4& gl_Position, thread float& gl_PointSize, thread spvUnsafeArray& gl_ClipDistance) +{ + v0 = float4(1.0); + v1 = float4(2.0); + gl_Position = float4(3.0); + gl_PointSize = 4.0; + gl_ClipDistance[0] = 1.0; + gl_ClipDistance[1] = 0.5; +} + +vertex main0_out main0() +{ + main0_out out = {}; + spvUnsafeArray gl_ClipDistance = {}; + write_in_func(out.v0, out.v1, out.gl_Position, out.gl_PointSize, gl_ClipDistance); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.for-tess.vert b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.for-tess.vert new file mode 100644 index 0000000000..53f76b575e --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.for-tess.vert @@ -0,0 +1,74 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 v1; + float4 gl_Position; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; +}; + +static inline __attribute__((always_inline)) +void write_in_func(thread float4& v0, device float4& v1, device float4& gl_Position, device float& gl_PointSize, device spvUnsafeArray& gl_ClipDistance) +{ + v0 = float4(1.0); + v1 = float4(2.0); + gl_Position = float4(3.0); + gl_PointSize = 4.0; + gl_ClipDistance[0] = 1.0; + gl_ClipDistance[1] = 0.5; +} + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 spvStageInputSize [[grid_size]], device main0_out* spvOut [[buffer(28)]]) +{ + float4 v0 = {}; + device main0_out& out = spvOut[gl_GlobalInvocationID.y * spvStageInputSize.x + gl_GlobalInvocationID.x]; + if (any(gl_GlobalInvocationID >= spvStageInputSize)) + return; + write_in_func(v0, out.v1, out.gl_Position, out.gl_PointSize, out.gl_ClipDistance); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.msl2.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.msl2.tesc new file mode 100644 index 0000000000..e4f047d3e3 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.msl2.tesc @@ -0,0 +1,42 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 gl_Position; + float gl_PointSize; +}; + +struct main0_patchOut +{ + float4 v1; +}; + +static inline __attribute__((always_inline)) +void write_in_func(threadgroup float4 (&v0)[4], thread uint& gl_InvocationID, device float4& v1, device main0_out* thread & gl_out) +{ + v0[gl_InvocationID] = float4(1.0); + v0[gl_InvocationID].x = 2.0; + if (gl_InvocationID == 0) + { + v1 = float4(2.0); + ((device float*)&v1)[3u] = 4.0; + } + gl_out[gl_InvocationID].gl_Position = float4(3.0); + gl_out[gl_InvocationID].gl_PointSize = 4.0; + gl_out[gl_InvocationID].gl_Position.z = 5.0; + gl_out[gl_InvocationID].gl_PointSize = 4.0; +} + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + threadgroup float4 v0[4]; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + write_in_func(v0, gl_InvocationID, patchOut.v1, gl_out); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.multi-patch.tesc new file mode 100644 index 0000000000..7465cc64db --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.multi-patch.tesc @@ -0,0 +1,87 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 gl_Position; + float gl_PointSize; +}; + +struct main0_patchOut +{ + spvUnsafeArray v1; + float4 v3; +}; + +static inline __attribute__((always_inline)) +void write_in_func(threadgroup float4 (&v0)[4], thread uint& gl_InvocationID, device spvUnsafeArray& v1, device float4& v3, device main0_out* thread & gl_out) +{ + v0[gl_InvocationID] = float4(1.0); + v0[gl_InvocationID].z = 3.0; + if (gl_InvocationID == 0) + { + v1[0] = float4(2.0); + ((device float*)&v1[0])[0u] = 3.0; + v1[1] = float4(2.0); + ((device float*)&v1[1])[0u] = 5.0; + } + v3 = float4(5.0); + gl_out[gl_InvocationID].gl_Position = float4(10.0); + gl_out[gl_InvocationID].gl_Position.z = 20.0; + gl_out[gl_InvocationID].gl_PointSize = 40.0; +} + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + threadgroup float4 spvStoragev0[8][4]; + threadgroup float4 (&v0)[4] = spvStoragev0[(gl_GlobalInvocationID.x / 4) % 8]; + device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + write_in_func(v0, gl_InvocationID, patchOut.v1, patchOut.v3, gl_out); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.tesc new file mode 100644 index 0000000000..0ae265e9e7 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.tesc @@ -0,0 +1,84 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 gl_Position; + float gl_PointSize; +}; + +struct main0_patchOut +{ + spvUnsafeArray v1; + float4 v3; +}; + +static inline __attribute__((always_inline)) +void write_in_func(threadgroup float4 (&v0)[4], thread uint& gl_InvocationID, device spvUnsafeArray& v1, device float4& v3, device main0_out* thread & gl_out) +{ + v0[gl_InvocationID] = float4(1.0); + v0[gl_InvocationID].z = 3.0; + if (gl_InvocationID == 0) + { + v1[0] = float4(2.0); + ((device float*)&v1[0])[0u] = 3.0; + v1[1] = float4(2.0); + ((device float*)&v1[1])[0u] = 5.0; + } + v3 = float4(5.0); + gl_out[gl_InvocationID].gl_Position = float4(10.0); + gl_out[gl_InvocationID].gl_Position.z = 20.0; + gl_out[gl_InvocationID].gl_PointSize = 40.0; +} + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + threadgroup float4 v0[4]; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + write_in_func(v0, gl_InvocationID, patchOut.v1, patchOut.v3, gl_out); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.vert b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.vert new file mode 100644 index 0000000000..12c111aef4 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-0.vert @@ -0,0 +1,38 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 v1 [[user(locn1)]]; + float4 gl_Position [[position]]; + float gl_PointSize [[point_size]]; + float gl_ClipDistance [[clip_distance]] [2]; + float gl_ClipDistance_0 [[user(clip0)]]; + float gl_ClipDistance_1 [[user(clip1)]]; +}; + +static inline __attribute__((always_inline)) +void write_in_func(thread float4& v0, thread float4& v1, thread float4& gl_Position, thread float& gl_PointSize, thread float (&gl_ClipDistance)[2]) +{ + v0 = float4(1.0); + v1 = float4(2.0); + gl_Position = float4(3.0); + gl_PointSize = 4.0; + gl_ClipDistance[0] = 1.0; + gl_ClipDistance[1] = 0.5; +} + +vertex main0_out main0() +{ + main0_out out = {}; + float4 v0 = {}; + write_in_func(v0, out.v1, out.gl_Position, out.gl_PointSize, out.gl_ClipDistance); + out.gl_ClipDistance_0 = out.gl_ClipDistance[0]; + out.gl_ClipDistance_1 = out.gl_ClipDistance[1]; + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-1.for-tess.vert b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-1.for-tess.vert new file mode 100644 index 0000000000..8f9cfce536 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-1.for-tess.vert @@ -0,0 +1,74 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 v0; + float4 gl_Position; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; +}; + +static inline __attribute__((always_inline)) +void write_in_func(device float4& v0, thread float4& v1, device float4& gl_Position, device float& gl_PointSize, device spvUnsafeArray& gl_ClipDistance) +{ + v0 = float4(1.0); + v1 = float4(2.0); + gl_Position = float4(3.0); + gl_PointSize = 4.0; + gl_ClipDistance[0] = 1.0; + gl_ClipDistance[1] = 0.5; +} + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 spvStageInputSize [[grid_size]], device main0_out* spvOut [[buffer(28)]]) +{ + float4 v1 = {}; + device main0_out& out = spvOut[gl_GlobalInvocationID.y * spvStageInputSize.x + gl_GlobalInvocationID.x]; + if (any(gl_GlobalInvocationID >= spvStageInputSize)) + return; + write_in_func(out.v0, v1, out.gl_Position, out.gl_PointSize, out.gl_ClipDistance); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-1.msl2.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-1.msl2.tesc new file mode 100644 index 0000000000..85160a9dee --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-1.msl2.tesc @@ -0,0 +1,41 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 v0; + float4 gl_Position; + float gl_PointSize; +}; + +struct main0_patchOut +{ +}; +static inline __attribute__((always_inline)) +void write_in_func(device main0_out* thread & gl_out, thread uint& gl_InvocationID, threadgroup float4& v1) +{ + gl_out[gl_InvocationID].v0 = float4(1.0); + gl_out[gl_InvocationID].v0.x = 2.0; + if (gl_InvocationID == 0) + { + v1 = float4(2.0); + ((threadgroup float*)&v1)[3u] = 4.0; + } + gl_out[gl_InvocationID].gl_Position = float4(3.0); + gl_out[gl_InvocationID].gl_PointSize = 4.0; + gl_out[gl_InvocationID].gl_Position.z = 5.0; + gl_out[gl_InvocationID].gl_PointSize = 4.0; +} + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + threadgroup float4 v1; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + write_in_func(gl_out, gl_InvocationID, v1); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-1.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-1.multi-patch.tesc new file mode 100644 index 0000000000..df057861ee --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-1.multi-patch.tesc @@ -0,0 +1,48 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 v0; + float4 gl_Position; + float gl_PointSize; +}; + +struct main0_patchOut +{ + float4 v3; +}; + +static inline __attribute__((always_inline)) +void write_in_func(device main0_out* thread & gl_out, thread uint& gl_InvocationID, threadgroup float4 (&v1)[2], device float4& v3) +{ + gl_out[gl_InvocationID].v0 = float4(1.0); + gl_out[gl_InvocationID].v0.z = 3.0; + if (gl_InvocationID == 0) + { + v1[0] = float4(2.0); + ((threadgroup float*)&v1[0])[0u] = 3.0; + v1[1] = float4(2.0); + ((threadgroup float*)&v1[1])[0u] = 5.0; + } + v3 = float4(5.0); + gl_out[gl_InvocationID].gl_Position = float4(10.0); + gl_out[gl_InvocationID].gl_Position.z = 20.0; + gl_out[gl_InvocationID].gl_PointSize = 40.0; +} + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; + threadgroup float4 spvStoragev1[8][2]; + threadgroup float4 (&v1)[2] = spvStoragev1[(gl_GlobalInvocationID.x / 4) % 8]; + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + write_in_func(gl_out, gl_InvocationID, v1, patchOut.v3); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-1.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-1.tesc new file mode 100644 index 0000000000..0ad2727673 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-1.tesc @@ -0,0 +1,45 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 v0; + float4 gl_Position; + float gl_PointSize; +}; + +struct main0_patchOut +{ + float4 v3; +}; + +static inline __attribute__((always_inline)) +void write_in_func(device main0_out* thread & gl_out, thread uint& gl_InvocationID, threadgroup float4 (&v1)[2], device float4& v3) +{ + gl_out[gl_InvocationID].v0 = float4(1.0); + gl_out[gl_InvocationID].v0.z = 3.0; + if (gl_InvocationID == 0) + { + v1[0] = float4(2.0); + ((threadgroup float*)&v1[0])[0u] = 3.0; + v1[1] = float4(2.0); + ((threadgroup float*)&v1[1])[0u] = 5.0; + } + v3 = float4(5.0); + gl_out[gl_InvocationID].gl_Position = float4(10.0); + gl_out[gl_InvocationID].gl_Position.z = 20.0; + gl_out[gl_InvocationID].gl_PointSize = 40.0; +} + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + threadgroup float4 v1[2]; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + write_in_func(gl_out, gl_InvocationID, v1, patchOut.v3); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-1.vert b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-1.vert new file mode 100644 index 0000000000..2290e5cca4 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-location-1.vert @@ -0,0 +1,38 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 v0 [[user(locn0)]]; + float4 gl_Position [[position]]; + float gl_PointSize [[point_size]]; + float gl_ClipDistance [[clip_distance]] [2]; + float gl_ClipDistance_0 [[user(clip0)]]; + float gl_ClipDistance_1 [[user(clip1)]]; +}; + +static inline __attribute__((always_inline)) +void write_in_func(thread float4& v0, thread float4& v1, thread float4& gl_Position, thread float& gl_PointSize, thread float (&gl_ClipDistance)[2]) +{ + v0 = float4(1.0); + v1 = float4(2.0); + gl_Position = float4(3.0); + gl_PointSize = 4.0; + gl_ClipDistance[0] = 1.0; + gl_ClipDistance[1] = 0.5; +} + +vertex main0_out main0() +{ + main0_out out = {}; + float4 v1 = {}; + write_in_func(out.v0, v1, out.gl_Position, out.gl_PointSize, out.gl_ClipDistance); + out.gl_ClipDistance_0 = out.gl_ClipDistance[0]; + out.gl_ClipDistance_1 = out.gl_ClipDistance[1]; + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-point-size.for-tess.vert b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-point-size.for-tess.vert new file mode 100644 index 0000000000..07494ea399 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-point-size.for-tess.vert @@ -0,0 +1,74 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 v0; + float4 v1; + float4 gl_Position; + spvUnsafeArray gl_ClipDistance; +}; + +static inline __attribute__((always_inline)) +void write_in_func(device float4& v0, device float4& v1, device float4& gl_Position, thread float& gl_PointSize, device spvUnsafeArray& gl_ClipDistance) +{ + v0 = float4(1.0); + v1 = float4(2.0); + gl_Position = float4(3.0); + gl_PointSize = 4.0; + gl_ClipDistance[0] = 1.0; + gl_ClipDistance[1] = 0.5; +} + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 spvStageInputSize [[grid_size]], device main0_out* spvOut [[buffer(28)]]) +{ + float gl_PointSize = {}; + device main0_out& out = spvOut[gl_GlobalInvocationID.y * spvStageInputSize.x + gl_GlobalInvocationID.x]; + if (any(gl_GlobalInvocationID >= spvStageInputSize)) + return; + write_in_func(out.v0, out.v1, out.gl_Position, gl_PointSize, out.gl_ClipDistance); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-point-size.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-point-size.multi-patch.tesc new file mode 100644 index 0000000000..05d58634ef --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-point-size.multi-patch.tesc @@ -0,0 +1,95 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct gl_PerVertex +{ + float4 gl_Position; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +struct main0_out +{ + float4 v0; + float4 gl_Position; +}; + +struct main0_patchOut +{ + spvUnsafeArray v1; + float4 v3; +}; + +static inline __attribute__((always_inline)) +void write_in_func(device main0_out* thread & gl_out, thread uint& gl_InvocationID, device spvUnsafeArray& v1, device float4& v3, threadgroup gl_PerVertex (&gl_out_masked)[4]) +{ + gl_out[gl_InvocationID].v0 = float4(1.0); + gl_out[gl_InvocationID].v0.z = 3.0; + if (gl_InvocationID == 0) + { + v1[0] = float4(2.0); + ((device float*)&v1[0])[0u] = 3.0; + v1[1] = float4(2.0); + ((device float*)&v1[1])[0u] = 5.0; + } + v3 = float4(5.0); + gl_out[gl_InvocationID].gl_Position = float4(10.0); + gl_out[gl_InvocationID].gl_Position.z = 20.0; + gl_out_masked[gl_InvocationID].gl_PointSize = 40.0; +} + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + threadgroup gl_PerVertex spvStoragegl_out_masked[8][4]; + threadgroup gl_PerVertex (&gl_out_masked)[4] = spvStoragegl_out_masked[(gl_GlobalInvocationID.x / 4) % 8]; + device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + write_in_func(gl_out, gl_InvocationID, patchOut.v1, patchOut.v3, gl_out_masked); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-point-size.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-point-size.tesc new file mode 100644 index 0000000000..8ec2a663b7 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-point-size.tesc @@ -0,0 +1,92 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct gl_PerVertex +{ + float4 gl_Position; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +struct main0_out +{ + float4 v0; + float4 gl_Position; +}; + +struct main0_patchOut +{ + spvUnsafeArray v1; + float4 v3; +}; + +static inline __attribute__((always_inline)) +void write_in_func(device main0_out* thread & gl_out, thread uint& gl_InvocationID, device spvUnsafeArray& v1, device float4& v3, threadgroup gl_PerVertex (&gl_out_masked)[4]) +{ + gl_out[gl_InvocationID].v0 = float4(1.0); + gl_out[gl_InvocationID].v0.z = 3.0; + if (gl_InvocationID == 0) + { + v1[0] = float4(2.0); + ((device float*)&v1[0])[0u] = 3.0; + v1[1] = float4(2.0); + ((device float*)&v1[1])[0u] = 5.0; + } + v3 = float4(5.0); + gl_out[gl_InvocationID].gl_Position = float4(10.0); + gl_out[gl_InvocationID].gl_Position.z = 20.0; + gl_out_masked[gl_InvocationID].gl_PointSize = 40.0; +} + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + threadgroup gl_PerVertex gl_out_masked[4]; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + write_in_func(gl_out, gl_InvocationID, patchOut.v1, patchOut.v3, gl_out_masked); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-point-size.vert b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-point-size.vert new file mode 100644 index 0000000000..b37b92dd4a --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-point-size.vert @@ -0,0 +1,38 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 v0 [[user(locn0)]]; + float4 v1 [[user(locn1)]]; + float4 gl_Position [[position]]; + float gl_ClipDistance [[clip_distance]] [2]; + float gl_ClipDistance_0 [[user(clip0)]]; + float gl_ClipDistance_1 [[user(clip1)]]; +}; + +static inline __attribute__((always_inline)) +void write_in_func(thread float4& v0, thread float4& v1, thread float4& gl_Position, thread float& gl_PointSize, thread float (&gl_ClipDistance)[2]) +{ + v0 = float4(1.0); + v1 = float4(2.0); + gl_Position = float4(3.0); + gl_PointSize = 4.0; + gl_ClipDistance[0] = 1.0; + gl_ClipDistance[1] = 0.5; +} + +vertex main0_out main0() +{ + main0_out out = {}; + float gl_PointSize = {}; + write_in_func(out.v0, out.v1, out.gl_Position, gl_PointSize, out.gl_ClipDistance); + out.gl_ClipDistance_0 = out.gl_ClipDistance[0]; + out.gl_ClipDistance_1 = out.gl_ClipDistance[1]; + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-position.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-position.multi-patch.tesc new file mode 100644 index 0000000000..86bc7d37be --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-position.multi-patch.tesc @@ -0,0 +1,95 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct gl_PerVertex +{ + float4 gl_Position; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +struct main0_out +{ + float4 v0; + float gl_PointSize; +}; + +struct main0_patchOut +{ + spvUnsafeArray v1; + float4 v3; +}; + +static inline __attribute__((always_inline)) +void write_in_func(device main0_out* thread & gl_out, thread uint& gl_InvocationID, device spvUnsafeArray& v1, device float4& v3, threadgroup gl_PerVertex (&gl_out_masked)[4]) +{ + gl_out[gl_InvocationID].v0 = float4(1.0); + gl_out[gl_InvocationID].v0.z = 3.0; + if (gl_InvocationID == 0) + { + v1[0] = float4(2.0); + ((device float*)&v1[0])[0u] = 3.0; + v1[1] = float4(2.0); + ((device float*)&v1[1])[0u] = 5.0; + } + v3 = float4(5.0); + gl_out_masked[gl_InvocationID].gl_Position = float4(10.0); + gl_out_masked[gl_InvocationID].gl_Position.z = 20.0; + gl_out[gl_InvocationID].gl_PointSize = 40.0; +} + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + threadgroup gl_PerVertex spvStoragegl_out_masked[8][4]; + threadgroup gl_PerVertex (&gl_out_masked)[4] = spvStoragegl_out_masked[(gl_GlobalInvocationID.x / 4) % 8]; + device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 4]; + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + write_in_func(gl_out, gl_InvocationID, patchOut.v1, patchOut.v3, gl_out_masked); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-position.tesc b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-position.tesc new file mode 100644 index 0000000000..da0d2a2d10 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/masking/write-outputs.mask-position.tesc @@ -0,0 +1,92 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct gl_PerVertex +{ + float4 gl_Position; + float gl_PointSize; + spvUnsafeArray gl_ClipDistance; + spvUnsafeArray gl_CullDistance; +}; + +struct main0_out +{ + float4 v0; + float gl_PointSize; +}; + +struct main0_patchOut +{ + spvUnsafeArray v1; + float4 v3; +}; + +static inline __attribute__((always_inline)) +void write_in_func(device main0_out* thread & gl_out, thread uint& gl_InvocationID, device spvUnsafeArray& v1, device float4& v3, threadgroup gl_PerVertex (&gl_out_masked)[4]) +{ + gl_out[gl_InvocationID].v0 = float4(1.0); + gl_out[gl_InvocationID].v0.z = 3.0; + if (gl_InvocationID == 0) + { + v1[0] = float4(2.0); + ((device float*)&v1[0])[0u] = 3.0; + v1[1] = float4(2.0); + ((device float*)&v1[1])[0u] = 5.0; + } + v3 = float4(5.0); + gl_out_masked[gl_InvocationID].gl_Position = float4(10.0); + gl_out_masked[gl_InvocationID].gl_Position.z = 20.0; + gl_out[gl_InvocationID].gl_PointSize = 40.0; +} + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + threadgroup gl_PerVertex gl_out_masked[4]; + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + write_in_func(gl_out, gl_InvocationID, patchOut.v1, patchOut.v3, gl_out_masked); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/tesc/basic.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/tesc/basic.multi-patch.tesc index b1403a3fe8..fe26831673 100644 --- a/third_party/spirv-cross/reference/shaders-msl/tesc/basic.multi-patch.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/tesc/basic.multi-patch.tesc @@ -11,7 +11,7 @@ struct main0_patchOut kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) { device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 1]; - uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 1, spvIndirectParams[1]); + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 1, spvIndirectParams[1] - 1); spvTessLevel[gl_PrimitiveID].insideTessellationFactor[0] = half(8.8999996185302734375); spvTessLevel[gl_PrimitiveID].insideTessellationFactor[1] = half(6.900000095367431640625); spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(8.8999996185302734375); diff --git a/third_party/spirv-cross/reference/shaders-msl/tesc/complex-control-point-inout-types.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/tesc/complex-control-point-inout-types.multi-patch.tesc new file mode 100644 index 0000000000..36a630f3a5 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/tesc/complex-control-point-inout-types.multi-patch.tesc @@ -0,0 +1,134 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct Meep +{ + float a; + float b; +}; + +struct Block +{ + spvUnsafeArray a; + float b; + float2x2 m; + Meep meep; + spvUnsafeArray meeps; +}; + +struct Block_1 +{ + spvUnsafeArray a; + float b; + float2x2 m; + Meep meep; + spvUnsafeArray meeps; +}; + +struct main0_out +{ + spvUnsafeArray a; + float b; + float2x2 m; + Meep meep; + spvUnsafeArray meeps; + spvUnsafeArray Block_a; + float Block_b; + float2x2 Block_m; + Meep Block_meep; + spvUnsafeArray Block_meeps; + float4 gl_Position; +}; + +struct main0_in +{ + spvUnsafeArray in_a; + float in_b; + float2x2 in_m; + Meep in_meep; + spvUnsafeArray in_meeps; + spvUnsafeArray Block_a; + float Block_b; + float2x2 Block_m; + Meep Block_meep; + spvUnsafeArray Block_meeps; +}; + +static inline __attribute__((always_inline)) +void write_in_func(device main0_out* thread & gl_out, thread uint& gl_InvocationID, device main0_in* thread & gl_in) +{ + gl_out[gl_InvocationID].gl_Position = float4(1.0); + gl_out[gl_InvocationID].a[0] = gl_in[gl_InvocationID].in_a[0]; + gl_out[gl_InvocationID].a[1] = gl_in[gl_InvocationID].in_a[1]; + gl_out[gl_InvocationID].b = gl_in[gl_InvocationID].in_b; + gl_out[gl_InvocationID].m = gl_in[gl_InvocationID].in_m; + gl_out[gl_InvocationID].meep.a = gl_in[gl_InvocationID].in_meep.a; + gl_out[gl_InvocationID].meep.b = gl_in[gl_InvocationID].in_meep.b; + gl_out[gl_InvocationID].meeps[0].a = gl_in[gl_InvocationID].in_meeps[0].a; + gl_out[gl_InvocationID].meeps[0].b = gl_in[gl_InvocationID].in_meeps[0].b; + gl_out[gl_InvocationID].meeps[1].a = gl_in[gl_InvocationID].in_meeps[1].a; + gl_out[gl_InvocationID].meeps[1].b = gl_in[gl_InvocationID].in_meeps[1].b; + gl_out[gl_InvocationID].Block_a[0] = gl_in[gl_InvocationID].Block_a[0]; + gl_out[gl_InvocationID].Block_a[1] = gl_in[gl_InvocationID].Block_a[1]; + gl_out[gl_InvocationID].Block_b = gl_in[gl_InvocationID].Block_b; + gl_out[gl_InvocationID].Block_m = gl_in[gl_InvocationID].Block_m; + gl_out[gl_InvocationID].Block_meep.a = gl_in[gl_InvocationID].Block_meep.a; + gl_out[gl_InvocationID].Block_meep.b = gl_in[gl_InvocationID].Block_meep.b; + gl_out[gl_InvocationID].Block_meeps[0].a = gl_in[gl_InvocationID].Block_meeps[0].a; + gl_out[gl_InvocationID].Block_meeps[0].b = gl_in[gl_InvocationID].Block_meeps[0].b; + gl_out[gl_InvocationID].Block_meeps[1].a = gl_in[gl_InvocationID].Block_meeps[1].a; + gl_out[gl_InvocationID].Block_meeps[1].b = gl_in[gl_InvocationID].Block_meeps[1].b; +} + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]]) +{ + device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; + device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; + uint gl_InvocationID = gl_GlobalInvocationID.x % 4; + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + write_in_func(gl_out, gl_InvocationID, gl_in); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/tesc/complex-control-point-inout-types.tesc b/third_party/spirv-cross/reference/shaders-msl/tesc/complex-control-point-inout-types.tesc new file mode 100644 index 0000000000..4bfb1a43ed --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/tesc/complex-control-point-inout-types.tesc @@ -0,0 +1,138 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct Meep +{ + float a; + float b; +}; + +struct Block +{ + spvUnsafeArray a; + float b; + float2x2 m; + Meep meep; + spvUnsafeArray meeps; +}; + +struct Block_1 +{ + spvUnsafeArray a; + float b; + float2x2 m; +}; + +struct main0_out +{ + spvUnsafeArray a; + float b; + float2x2 m; + Meep meep; + spvUnsafeArray meeps; + spvUnsafeArray Block_a; + float Block_b; + float2x2 Block_m; + Meep Block_meep; + spvUnsafeArray Block_meeps; + float4 gl_Position; +}; + +struct main0_in +{ + float in_a_0 [[attribute(0)]]; + float in_a_1 [[attribute(1)]]; + float in_b [[attribute(2)]]; + float2 in_m_0 [[attribute(3)]]; + float2 in_m_1 [[attribute(4)]]; + float Meep_a [[attribute(5)]]; + float Meep_b [[attribute(6)]]; + float Block_a_0 [[attribute(11)]]; + float Block_a_1 [[attribute(12)]]; + float Block_b [[attribute(13)]]; + float2 Block_m_0 [[attribute(14)]]; + float2 Block_m_1 [[attribute(15)]]; +}; + +static inline __attribute__((always_inline)) +void write_in_func(device main0_out* thread & gl_out, thread uint& gl_InvocationID, threadgroup main0_in* thread & gl_in) +{ + gl_out[gl_InvocationID].gl_Position = float4(1.0); + gl_out[gl_InvocationID].a[0] = gl_in[gl_InvocationID].in_a_0; + gl_out[gl_InvocationID].a[1] = gl_in[gl_InvocationID].in_a_1; + gl_out[gl_InvocationID].b = gl_in[gl_InvocationID].in_b; + float2x2 _72 = float2x2(gl_in[gl_InvocationID].in_m_0, gl_in[gl_InvocationID].in_m_1); + gl_out[gl_InvocationID].m = _72; + gl_out[gl_InvocationID].meep.a = gl_in[gl_InvocationID].Meep_a; + gl_out[gl_InvocationID].meep.b = gl_in[gl_InvocationID].Meep_b; + gl_out[gl_InvocationID].meeps[0].a = 1.0; + gl_out[gl_InvocationID].meeps[0].b = 2.0; + gl_out[gl_InvocationID].meeps[1].a = 3.0; + gl_out[gl_InvocationID].meeps[1].b = 4.0; + gl_out[gl_InvocationID].Block_a[0] = gl_in[gl_InvocationID].Block_a_0; + gl_out[gl_InvocationID].Block_a[1] = gl_in[gl_InvocationID].Block_a_1; + gl_out[gl_InvocationID].Block_b = gl_in[gl_InvocationID].Block_b; + float2x2 _134 = float2x2(gl_in[gl_InvocationID].Block_m_0, gl_in[gl_InvocationID].Block_m_1); + gl_out[gl_InvocationID].Block_m = _134; + gl_out[gl_InvocationID].Block_meep.a = 10.0; + gl_out[gl_InvocationID].Block_meep.b = 20.0; + gl_out[gl_InvocationID].Block_meeps[0].a = 5.0; + gl_out[gl_InvocationID].Block_meeps[0].b = 6.0; + gl_out[gl_InvocationID].Block_meeps[1].a = 7.0; + gl_out[gl_InvocationID].Block_meeps[1].b = 8.0; +} + +kernel void main0(main0_in in [[stage_in]], uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], threadgroup main0_in* gl_in [[threadgroup(0)]]) +{ + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + if (gl_InvocationID < spvIndirectParams[0]) + gl_in[gl_InvocationID] = in; + threadgroup_barrier(mem_flags::mem_threadgroup); + if (gl_InvocationID >= 4) + return; + write_in_func(gl_out, gl_InvocationID, gl_in); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/tesc/complex-patch-out-types.tesc b/third_party/spirv-cross/reference/shaders-msl/tesc/complex-patch-out-types.tesc new file mode 100644 index 0000000000..b27f8ad956 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/tesc/complex-patch-out-types.tesc @@ -0,0 +1,113 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct Meep +{ + float a; + float b; +}; + +struct Block +{ + spvUnsafeArray a; + float b; + float2x2 m; + Meep meep; + spvUnsafeArray meeps; +}; + +struct main0_out +{ + float4 gl_Position; +}; + +struct main0_patchOut +{ + spvUnsafeArray a; + float b; + float2x2 m; + Meep meep; + spvUnsafeArray meeps; + spvUnsafeArray Block_a; + float Block_b; + float2x2 Block_m; + Meep Block_meep; + spvUnsafeArray Block_meeps; +}; + +static inline __attribute__((always_inline)) +void write_in_func(device main0_out* thread & gl_out, thread uint& gl_InvocationID, device spvUnsafeArray& a, device float& b, device float2x2& m, device Meep& meep, device spvUnsafeArray& meeps, device main0_patchOut& patchOut) +{ + gl_out[gl_InvocationID].gl_Position = float4(1.0); + a[0] = 1.0; + a[1] = 2.0; + b = 3.0; + m = float2x2(float2(2.0, 0.0), float2(0.0, 2.0)); + meep.a = 4.0; + meep.b = 5.0; + meeps[0].a = 6.0; + meeps[0].b = 7.0; + meeps[1].a = 8.0; + meeps[1].b = 9.0; + patchOut.Block_a[0] = 1.0; + patchOut.Block_a[1] = 2.0; + patchOut.Block_b = 3.0; + patchOut.Block_m = float2x2(float2(4.0, 0.0), float2(0.0, 4.0)); + patchOut.Block_meep.a = 4.0; + patchOut.Block_meep.b = 5.0; + patchOut.Block_meeps[0].a = 6.0; + patchOut.Block_meeps[0].b = 7.0; + patchOut.Block_meeps[1].a = 8.0; + patchOut.Block_meeps[1].b = 9.0; +} + +kernel void main0(uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device main0_patchOut* spvPatchOut [[buffer(27)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]]) +{ + device main0_out* gl_out = &spvOut[gl_PrimitiveID * 4]; + device main0_patchOut& patchOut = spvPatchOut[gl_PrimitiveID]; + write_in_func(gl_out, gl_InvocationID, patchOut.a, patchOut.b, patchOut.m, patchOut.meep, patchOut.meeps, patchOut); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/tesc/load-control-point-array-of-matrix.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/tesc/load-control-point-array-of-matrix.multi-patch.tesc index 4f4cf0b012..28effad215 100644 --- a/third_party/spirv-cross/reference/shaders-msl/tesc/load-control-point-array-of-matrix.multi-patch.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/tesc/load-control-point-array-of-matrix.multi-patch.tesc @@ -59,7 +59,7 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; - uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1]); + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); spvUnsafeArray _16 = spvUnsafeArray({ gl_in[0].vInputs, gl_in[1].vInputs, gl_in[2].vInputs, gl_in[3].vInputs, gl_in[4].vInputs, gl_in[5].vInputs, gl_in[6].vInputs, gl_in[7].vInputs, gl_in[8].vInputs, gl_in[9].vInputs, gl_in[10].vInputs, gl_in[11].vInputs, gl_in[12].vInputs, gl_in[13].vInputs, gl_in[14].vInputs, gl_in[15].vInputs, gl_in[16].vInputs, gl_in[17].vInputs, gl_in[18].vInputs, gl_in[19].vInputs, gl_in[20].vInputs, gl_in[21].vInputs, gl_in[22].vInputs, gl_in[23].vInputs, gl_in[24].vInputs, gl_in[25].vInputs, gl_in[26].vInputs, gl_in[27].vInputs, gl_in[28].vInputs, gl_in[29].vInputs, gl_in[30].vInputs, gl_in[31].vInputs }); spvUnsafeArray tmp; tmp = _16; diff --git a/third_party/spirv-cross/reference/shaders-msl/tesc/load-control-point-array-of-struct.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/tesc/load-control-point-array-of-struct.multi-patch.tesc index ad23ea7fd6..d24c271dd4 100644 --- a/third_party/spirv-cross/reference/shaders-msl/tesc/load-control-point-array-of-struct.multi-patch.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/tesc/load-control-point-array-of-struct.multi-patch.tesc @@ -58,9 +58,7 @@ struct main0_out struct main0_in { - float4x4 VertexData_a; - spvUnsafeArray VertexData_b; - float4 VertexData_c; + VertexData vInputs; }; kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLQuadTessellationFactorsHalf* spvTessLevel [[buffer(26)]], device main0_in* spvIn [[buffer(22)]]) @@ -68,13 +66,11 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; - uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1]); - spvUnsafeArray _19 = spvUnsafeArray({ VertexData{ gl_in[0].VertexData_a, spvUnsafeArray({ gl_in[0].VertexData_b[0], gl_in[0].VertexData_b[1] }), gl_in[0].VertexData_c }, VertexData{ gl_in[1].VertexData_a, spvUnsafeArray({ gl_in[1].VertexData_b[0], gl_in[1].VertexData_b[1] }), gl_in[1].VertexData_c }, VertexData{ gl_in[2].VertexData_a, spvUnsafeArray({ gl_in[2].VertexData_b[0], gl_in[2].VertexData_b[1] }), gl_in[2].VertexData_c }, VertexData{ gl_in[3].VertexData_a, spvUnsafeArray({ gl_in[3].VertexData_b[0], gl_in[3].VertexData_b[1] }), gl_in[3].VertexData_c }, VertexData{ gl_in[4].VertexData_a, spvUnsafeArray({ gl_in[4].VertexData_b[0], gl_in[4].VertexData_b[1] }), gl_in[4].VertexData_c }, VertexData{ gl_in[5].VertexData_a, spvUnsafeArray({ gl_in[5].VertexData_b[0], gl_in[5].VertexData_b[1] }), gl_in[5].VertexData_c }, VertexData{ gl_in[6].VertexData_a, spvUnsafeArray({ gl_in[6].VertexData_b[0], gl_in[6].VertexData_b[1] }), gl_in[6].VertexData_c }, VertexData{ gl_in[7].VertexData_a, spvUnsafeArray({ gl_in[7].VertexData_b[0], gl_in[7].VertexData_b[1] }), gl_in[7].VertexData_c }, VertexData{ gl_in[8].VertexData_a, spvUnsafeArray({ gl_in[8].VertexData_b[0], gl_in[8].VertexData_b[1] }), gl_in[8].VertexData_c }, VertexData{ gl_in[9].VertexData_a, spvUnsafeArray({ gl_in[9].VertexData_b[0], gl_in[9].VertexData_b[1] }), gl_in[9].VertexData_c }, VertexData{ gl_in[10].VertexData_a, spvUnsafeArray({ gl_in[10].VertexData_b[0], gl_in[10].VertexData_b[1] }), gl_in[10].VertexData_c }, VertexData{ gl_in[11].VertexData_a, spvUnsafeArray({ gl_in[11].VertexData_b[0], gl_in[11].VertexData_b[1] }), gl_in[11].VertexData_c }, VertexData{ gl_in[12].VertexData_a, spvUnsafeArray({ gl_in[12].VertexData_b[0], gl_in[12].VertexData_b[1] }), gl_in[12].VertexData_c }, VertexData{ gl_in[13].VertexData_a, spvUnsafeArray({ gl_in[13].VertexData_b[0], gl_in[13].VertexData_b[1] }), gl_in[13].VertexData_c }, VertexData{ gl_in[14].VertexData_a, spvUnsafeArray({ gl_in[14].VertexData_b[0], gl_in[14].VertexData_b[1] }), gl_in[14].VertexData_c }, VertexData{ gl_in[15].VertexData_a, spvUnsafeArray({ gl_in[15].VertexData_b[0], gl_in[15].VertexData_b[1] }), gl_in[15].VertexData_c }, VertexData{ gl_in[16].VertexData_a, spvUnsafeArray({ gl_in[16].VertexData_b[0], gl_in[16].VertexData_b[1] }), gl_in[16].VertexData_c }, VertexData{ gl_in[17].VertexData_a, spvUnsafeArray({ gl_in[17].VertexData_b[0], gl_in[17].VertexData_b[1] }), gl_in[17].VertexData_c }, VertexData{ gl_in[18].VertexData_a, spvUnsafeArray({ gl_in[18].VertexData_b[0], gl_in[18].VertexData_b[1] }), gl_in[18].VertexData_c }, VertexData{ gl_in[19].VertexData_a, spvUnsafeArray({ gl_in[19].VertexData_b[0], gl_in[19].VertexData_b[1] }), gl_in[19].VertexData_c }, VertexData{ gl_in[20].VertexData_a, spvUnsafeArray({ gl_in[20].VertexData_b[0], gl_in[20].VertexData_b[1] }), gl_in[20].VertexData_c }, VertexData{ gl_in[21].VertexData_a, spvUnsafeArray({ gl_in[21].VertexData_b[0], gl_in[21].VertexData_b[1] }), gl_in[21].VertexData_c }, VertexData{ gl_in[22].VertexData_a, spvUnsafeArray({ gl_in[22].VertexData_b[0], gl_in[22].VertexData_b[1] }), gl_in[22].VertexData_c }, VertexData{ gl_in[23].VertexData_a, spvUnsafeArray({ gl_in[23].VertexData_b[0], gl_in[23].VertexData_b[1] }), gl_in[23].VertexData_c }, VertexData{ gl_in[24].VertexData_a, spvUnsafeArray({ gl_in[24].VertexData_b[0], gl_in[24].VertexData_b[1] }), gl_in[24].VertexData_c }, VertexData{ gl_in[25].VertexData_a, spvUnsafeArray({ gl_in[25].VertexData_b[0], gl_in[25].VertexData_b[1] }), gl_in[25].VertexData_c }, VertexData{ gl_in[26].VertexData_a, spvUnsafeArray({ gl_in[26].VertexData_b[0], gl_in[26].VertexData_b[1] }), gl_in[26].VertexData_c }, VertexData{ gl_in[27].VertexData_a, spvUnsafeArray({ gl_in[27].VertexData_b[0], gl_in[27].VertexData_b[1] }), gl_in[27].VertexData_c }, VertexData{ gl_in[28].VertexData_a, spvUnsafeArray({ gl_in[28].VertexData_b[0], gl_in[28].VertexData_b[1] }), gl_in[28].VertexData_c }, VertexData{ gl_in[29].VertexData_a, spvUnsafeArray({ gl_in[29].VertexData_b[0], gl_in[29].VertexData_b[1] }), gl_in[29].VertexData_c }, VertexData{ gl_in[30].VertexData_a, spvUnsafeArray({ gl_in[30].VertexData_b[0], gl_in[30].VertexData_b[1] }), gl_in[30].VertexData_c }, VertexData{ gl_in[31].VertexData_a, spvUnsafeArray({ gl_in[31].VertexData_b[0], gl_in[31].VertexData_b[1] }), gl_in[31].VertexData_c } }); + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); + spvUnsafeArray _19 = spvUnsafeArray({ gl_in[0].vInputs, gl_in[1].vInputs, gl_in[2].vInputs, gl_in[3].vInputs, gl_in[4].vInputs, gl_in[5].vInputs, gl_in[6].vInputs, gl_in[7].vInputs, gl_in[8].vInputs, gl_in[9].vInputs, gl_in[10].vInputs, gl_in[11].vInputs, gl_in[12].vInputs, gl_in[13].vInputs, gl_in[14].vInputs, gl_in[15].vInputs, gl_in[16].vInputs, gl_in[17].vInputs, gl_in[18].vInputs, gl_in[19].vInputs, gl_in[20].vInputs, gl_in[21].vInputs, gl_in[22].vInputs, gl_in[23].vInputs, gl_in[24].vInputs, gl_in[25].vInputs, gl_in[26].vInputs, gl_in[27].vInputs, gl_in[28].vInputs, gl_in[29].vInputs, gl_in[30].vInputs, gl_in[31].vInputs }); spvUnsafeArray tmp; tmp = _19; - int _27 = gl_InvocationID ^ 1; - VertexData _30 = VertexData{ gl_in[_27].VertexData_a, spvUnsafeArray({ gl_in[_27].VertexData_b[0], gl_in[_27].VertexData_b[1] }), gl_in[_27].VertexData_c }; - VertexData tmp_single = _30; + VertexData tmp_single = gl_in[gl_InvocationID ^ 1].vInputs; gl_out[gl_InvocationID].vOutputs = ((tmp[gl_InvocationID].a[1] + tmp[gl_InvocationID].b[1]) + tmp[gl_InvocationID].c) + tmp_single.c; } diff --git a/third_party/spirv-cross/reference/shaders-msl/tesc/load-control-point-array.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/tesc/load-control-point-array.multi-patch.tesc index 416bc68172..45baadb6f2 100644 --- a/third_party/spirv-cross/reference/shaders-msl/tesc/load-control-point-array.multi-patch.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/tesc/load-control-point-array.multi-patch.tesc @@ -60,7 +60,7 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; - uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1]); + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); spvUnsafeArray _15 = spvUnsafeArray({ gl_in[0].vInputs, gl_in[1].vInputs, gl_in[2].vInputs, gl_in[3].vInputs, gl_in[4].vInputs, gl_in[5].vInputs, gl_in[6].vInputs, gl_in[7].vInputs, gl_in[8].vInputs, gl_in[9].vInputs, gl_in[10].vInputs, gl_in[11].vInputs, gl_in[12].vInputs, gl_in[13].vInputs, gl_in[14].vInputs, gl_in[15].vInputs, gl_in[16].vInputs, gl_in[17].vInputs, gl_in[18].vInputs, gl_in[19].vInputs, gl_in[20].vInputs, gl_in[21].vInputs, gl_in[22].vInputs, gl_in[23].vInputs, gl_in[24].vInputs, gl_in[25].vInputs, gl_in[26].vInputs, gl_in[27].vInputs, gl_in[28].vInputs, gl_in[29].vInputs, gl_in[30].vInputs, gl_in[31].vInputs }); spvUnsafeArray tmp; tmp = _15; diff --git a/third_party/spirv-cross/reference/shaders-msl/tesc/matrix-output.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/tesc/matrix-output.multi-patch.tesc index 3e045ee84b..98b9dd0524 100644 --- a/third_party/spirv-cross/reference/shaders-msl/tesc/matrix-output.multi-patch.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/tesc/matrix-output.multi-patch.tesc @@ -21,7 +21,7 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 3]; device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 3, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; uint gl_InvocationID = gl_GlobalInvocationID.x % 3; - uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 3, spvIndirectParams[1]); + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 3, spvIndirectParams[1] - 1); float _15 = float(gl_InvocationID); float4x3 d = float4x3(float3(_15, 0.0, 0.0), float3(0.0, _15, 0.0), float3(0.0, 0.0, _15), float3(0.0)); gl_out[gl_InvocationID].in_te_data0 = d; diff --git a/third_party/spirv-cross/reference/shaders-msl/tesc/reload-tess-level.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/tesc/reload-tess-level.multi-patch.tesc index a55755e028..ae33de517a 100644 --- a/third_party/spirv-cross/reference/shaders-msl/tesc/reload-tess-level.multi-patch.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/tesc/reload-tess-level.multi-patch.tesc @@ -20,7 +20,7 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 4]; device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; uint gl_InvocationID = gl_GlobalInvocationID.x % 4; - uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1]); + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 4, spvIndirectParams[1] - 1); if (gl_InvocationID == 0) { spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(2.0); diff --git a/third_party/spirv-cross/reference/shaders-msl/tesc/struct-output.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/tesc/struct-output.multi-patch.tesc index 7b5307b3ff..eaab245c1c 100644 --- a/third_party/spirv-cross/reference/shaders-msl/tesc/struct-output.multi-patch.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/tesc/struct-output.multi-patch.tesc @@ -28,7 +28,7 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic device main0_out* gl_out = &spvOut[gl_GlobalInvocationID.x - gl_GlobalInvocationID.x % 3]; device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 3, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; uint gl_InvocationID = gl_GlobalInvocationID.x % 3; - uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 3, spvIndirectParams[1]); + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 3, spvIndirectParams[1] - 1); te_data d = te_data{ float(gl_InvocationID), float(gl_InvocationID + 1), uint(gl_InvocationID) }; gl_out[gl_InvocationID].in_te_data0 = d; threadgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup); diff --git a/third_party/spirv-cross/reference/shaders-msl/tesc/water_tess.multi-patch.tesc b/third_party/spirv-cross/reference/shaders-msl/tesc/water_tess.multi-patch.tesc index b1fd2edbf0..f302302ae2 100644 --- a/third_party/spirv-cross/reference/shaders-msl/tesc/water_tess.multi-patch.tesc +++ b/third_party/spirv-cross/reference/shaders-msl/tesc/water_tess.multi-patch.tesc @@ -114,7 +114,7 @@ kernel void main0(constant UBO& v_41 [[buffer(0)]], uint3 gl_GlobalInvocationID { device main0_patchOut& patchOut = spvPatchOut[gl_GlobalInvocationID.x / 1]; device main0_in* gl_in = &spvIn[min(gl_GlobalInvocationID.x / 1, spvIndirectParams[1] - 1) * spvIndirectParams[0]]; - uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 1, spvIndirectParams[1]); + uint gl_PrimitiveID = min(gl_GlobalInvocationID.x / 1, spvIndirectParams[1] - 1); float2 p0 = gl_in[0].vPatchPosBase.xy; float2 param = p0; if (!frustum_cull(param, v_41)) diff --git a/third_party/spirv-cross/reference/shaders-msl/tese/quad.domain.tese b/third_party/spirv-cross/reference/shaders-msl/tese/quad.domain.tese index 78b58ab997..9dadebc4e4 100644 --- a/third_party/spirv-cross/reference/shaders-msl/tese/quad.domain.tese +++ b/third_party/spirv-cross/reference/shaders-msl/tese/quad.domain.tese @@ -1,8 +1,49 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct main0_out { float4 gl_Position [[position]]; @@ -10,15 +51,23 @@ struct main0_out struct main0_patchIn { - float2 gl_TessLevelInner [[attribute(0)]]; - float4 gl_TessLevelOuter [[attribute(1)]]; + float4 gl_TessLevelOuter [[attribute(0)]]; + float2 gl_TessLevelInner [[attribute(1)]]; }; [[ patch(quad, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]], float2 gl_TessCoord [[position_in_patch]]) { main0_out out = {}; + spvUnsafeArray gl_TessLevelInner = {}; + spvUnsafeArray gl_TessLevelOuter = {}; + gl_TessLevelInner[0] = patchIn.gl_TessLevelInner.x; + gl_TessLevelInner[1] = patchIn.gl_TessLevelInner.y; + gl_TessLevelOuter[0] = patchIn.gl_TessLevelOuter.x; + gl_TessLevelOuter[1] = patchIn.gl_TessLevelOuter.y; + gl_TessLevelOuter[2] = patchIn.gl_TessLevelOuter.z; + gl_TessLevelOuter[3] = patchIn.gl_TessLevelOuter.w; gl_TessCoord.y = 1.0 - gl_TessCoord.y; - out.gl_Position = float4(((gl_TessCoord.x * patchIn.gl_TessLevelInner.x) * patchIn.gl_TessLevelOuter.x) + (((1.0 - gl_TessCoord.x) * patchIn.gl_TessLevelInner.x) * patchIn.gl_TessLevelOuter.z), ((gl_TessCoord.y * patchIn.gl_TessLevelInner.y) * patchIn.gl_TessLevelOuter.w) + (((1.0 - gl_TessCoord.y) * patchIn.gl_TessLevelInner.y) * patchIn.gl_TessLevelOuter.y), 0.0, 1.0); + out.gl_Position = float4(((gl_TessCoord.x * gl_TessLevelInner[0]) * gl_TessLevelOuter[0]) + (((1.0 - gl_TessCoord.x) * gl_TessLevelInner[0]) * gl_TessLevelOuter[2]), ((gl_TessCoord.y * gl_TessLevelInner[1]) * gl_TessLevelOuter[3]) + (((1.0 - gl_TessCoord.y) * gl_TessLevelInner[1]) * gl_TessLevelOuter[1]), 0.0, 1.0); return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/tese/quad.tese b/third_party/spirv-cross/reference/shaders-msl/tese/quad.tese index 40273582cc..ae320812df 100644 --- a/third_party/spirv-cross/reference/shaders-msl/tese/quad.tese +++ b/third_party/spirv-cross/reference/shaders-msl/tese/quad.tese @@ -1,10 +1,49 @@ #pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" #include #include using namespace metal; +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + struct main0_out { float4 gl_Position [[position]]; @@ -12,20 +51,28 @@ struct main0_out struct main0_patchIn { - float2 gl_TessLevelInner [[attribute(0)]]; - float4 gl_TessLevelOuter [[attribute(1)]]; + float4 gl_TessLevelOuter [[attribute(0)]]; + float2 gl_TessLevelInner [[attribute(1)]]; }; static inline __attribute__((always_inline)) -void set_position(thread float4& gl_Position, thread float2& gl_TessCoord, thread float2& gl_TessLevelInner, thread float4& gl_TessLevelOuter) +void set_position(thread float4& gl_Position, thread float2& gl_TessCoord, thread spvUnsafeArray& gl_TessLevelInner, thread spvUnsafeArray& gl_TessLevelOuter) { - gl_Position = float4(((gl_TessCoord.x * gl_TessLevelInner.x) * gl_TessLevelOuter.x) + (((1.0 - gl_TessCoord.x) * gl_TessLevelInner.x) * gl_TessLevelOuter.z), ((gl_TessCoord.y * gl_TessLevelInner.y) * gl_TessLevelOuter.y) + (((1.0 - gl_TessCoord.y) * gl_TessLevelInner.y) * gl_TessLevelOuter.w), 0.0, 1.0); + gl_Position = float4(((gl_TessCoord.x * gl_TessLevelInner[0]) * gl_TessLevelOuter[0]) + (((1.0 - gl_TessCoord.x) * gl_TessLevelInner[0]) * gl_TessLevelOuter[2]), ((gl_TessCoord.y * gl_TessLevelInner[1]) * gl_TessLevelOuter[1]) + (((1.0 - gl_TessCoord.y) * gl_TessLevelInner[1]) * gl_TessLevelOuter[3]), 0.0, 1.0); } [[ patch(quad, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]], float2 gl_TessCoord [[position_in_patch]]) { main0_out out = {}; - set_position(out.gl_Position, gl_TessCoord, patchIn.gl_TessLevelInner, patchIn.gl_TessLevelOuter); + spvUnsafeArray gl_TessLevelInner = {}; + spvUnsafeArray gl_TessLevelOuter = {}; + gl_TessLevelInner[0] = patchIn.gl_TessLevelInner.x; + gl_TessLevelInner[1] = patchIn.gl_TessLevelInner.y; + gl_TessLevelOuter[0] = patchIn.gl_TessLevelOuter.x; + gl_TessLevelOuter[1] = patchIn.gl_TessLevelOuter.y; + gl_TessLevelOuter[2] = patchIn.gl_TessLevelOuter.z; + gl_TessLevelOuter[3] = patchIn.gl_TessLevelOuter.w; + set_position(out.gl_Position, gl_TessCoord, gl_TessLevelInner, gl_TessLevelOuter); return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/tese/read-tess-level-in-func-quad.msl2.tese b/third_party/spirv-cross/reference/shaders-msl/tese/read-tess-level-in-func-quad.msl2.tese new file mode 100644 index 0000000000..14d2565e01 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/tese/read-tess-level-in-func-quad.msl2.tese @@ -0,0 +1,78 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +struct main0_patchIn +{ + float4 gl_TessLevelOuter [[attribute(0)]]; + float2 gl_TessLevelInner [[attribute(1)]]; +}; + +static inline __attribute__((always_inline)) +float4 read_tess_levels(thread spvUnsafeArray& gl_TessLevelOuter, thread spvUnsafeArray& gl_TessLevelInner) +{ + return float4(gl_TessLevelOuter[0], gl_TessLevelOuter[1], gl_TessLevelOuter[2], gl_TessLevelOuter[3]) + float2(gl_TessLevelInner[0], gl_TessLevelInner[1]).xyxy; +} + +[[ patch(quad, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]]) +{ + main0_out out = {}; + spvUnsafeArray gl_TessLevelOuter = {}; + spvUnsafeArray gl_TessLevelInner = {}; + gl_TessLevelOuter[0] = patchIn.gl_TessLevelOuter.x; + gl_TessLevelOuter[1] = patchIn.gl_TessLevelOuter.y; + gl_TessLevelOuter[2] = patchIn.gl_TessLevelOuter.z; + gl_TessLevelOuter[3] = patchIn.gl_TessLevelOuter.w; + gl_TessLevelInner[0] = patchIn.gl_TessLevelInner.x; + gl_TessLevelInner[1] = patchIn.gl_TessLevelInner.y; + out.gl_Position = read_tess_levels(gl_TessLevelOuter, gl_TessLevelInner); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/tese/read-tess-level-in-func.msl2.tese b/third_party/spirv-cross/reference/shaders-msl/tese/read-tess-level-in-func.msl2.tese new file mode 100644 index 0000000000..f2fd49e9a4 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/tese/read-tess-level-in-func.msl2.tese @@ -0,0 +1,75 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +struct main0_patchIn +{ + float4 gl_TessLevel [[attribute(0)]]; +}; + +static inline __attribute__((always_inline)) +float4 read_tess_levels(thread spvUnsafeArray& gl_TessLevelOuter, thread spvUnsafeArray& gl_TessLevelInner) +{ + return float4(gl_TessLevelOuter[0], gl_TessLevelOuter[1], gl_TessLevelOuter[2], gl_TessLevelOuter[3]) + float2(gl_TessLevelInner[0], gl_TessLevelInner[1]).xyxy; +} + +[[ patch(triangle, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]]) +{ + main0_out out = {}; + spvUnsafeArray gl_TessLevelOuter = {}; + spvUnsafeArray gl_TessLevelInner = {}; + gl_TessLevelOuter[0] = patchIn.gl_TessLevel.x; + gl_TessLevelOuter[1] = patchIn.gl_TessLevel.y; + gl_TessLevelOuter[2] = patchIn.gl_TessLevel.z; + gl_TessLevelInner[0] = patchIn.gl_TessLevel.w; + out.gl_Position = read_tess_levels(gl_TessLevelOuter, gl_TessLevelInner); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/vert/array-component-io.for-tess.vert b/third_party/spirv-cross/reference/shaders-msl/vert/array-component-io.for-tess.vert new file mode 100644 index 0000000000..24958eb50d --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/vert/array-component-io.for-tess.vert @@ -0,0 +1,98 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float4 m_location_0; + float4 m_location_1; + float4 m_location_2; + float4 gl_Position; +}; + +struct main0_in +{ + float4 m_location_0 [[attribute(0)]]; + float4 m_location_1 [[attribute(1)]]; + float4 m_location_2 [[attribute(2)]]; + float4 Pos [[attribute(4)]]; +}; + +kernel void main0(main0_in in [[stage_in]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 spvStageInputSize [[grid_size]], device main0_out* spvOut [[buffer(28)]]) +{ + spvUnsafeArray A = {}; + spvUnsafeArray B = {}; + spvUnsafeArray C = {}; + float D = {}; + spvUnsafeArray InA = {}; + spvUnsafeArray InB = {}; + spvUnsafeArray InC = {}; + float InD = {}; + device main0_out& out = spvOut[gl_GlobalInvocationID.y * spvStageInputSize.x + gl_GlobalInvocationID.x]; + InA[0] = in.m_location_1.x; + InA[1] = in.m_location_2.x; + InB[0] = in.m_location_1.zw; + InB[1] = in.m_location_2.zw; + InC[0] = in.m_location_0.y; + InC[1] = in.m_location_1.y; + InC[2] = in.m_location_2.y; + InD = in.m_location_0.w; + if (any(gl_GlobalInvocationID >= spvStageInputSize)) + return; + out.gl_Position = in.Pos; + A = InA; + B = InB; + C = InC; + D = InD; + out.m_location_1.x = A[0]; + out.m_location_2.x = A[1]; + out.m_location_1.zw = B[0]; + out.m_location_2.zw = B[1]; + out.m_location_0.y = C[0]; + out.m_location_1.y = C[1]; + out.m_location_2.y = C[2]; + out.m_location_0.w = D; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/vert/array-component-io.vert b/third_party/spirv-cross/reference/shaders-msl/vert/array-component-io.vert new file mode 100644 index 0000000000..352c9d2ef0 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/vert/array-component-io.vert @@ -0,0 +1,100 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#include + +using namespace metal; + +template +struct spvUnsafeArray +{ + T elements[Num ? Num : 1]; + + thread T& operator [] (size_t pos) thread + { + return elements[pos]; + } + constexpr const thread T& operator [] (size_t pos) const thread + { + return elements[pos]; + } + + device T& operator [] (size_t pos) device + { + return elements[pos]; + } + constexpr const device T& operator [] (size_t pos) const device + { + return elements[pos]; + } + + constexpr const constant T& operator [] (size_t pos) const constant + { + return elements[pos]; + } + + threadgroup T& operator [] (size_t pos) threadgroup + { + return elements[pos]; + } + constexpr const threadgroup T& operator [] (size_t pos) const threadgroup + { + return elements[pos]; + } +}; + +struct main0_out +{ + float C_0 [[user(locn0_1)]]; + float D [[user(locn0_3)]]; + float A_0 [[user(locn1)]]; + float C_1 [[user(locn1_1)]]; + float2 B_0 [[user(locn1_2)]]; + float A_1 [[user(locn2)]]; + float C_2 [[user(locn2_1)]]; + float2 B_1 [[user(locn2_2)]]; + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 m_location_0 [[attribute(0)]]; + float4 m_location_1 [[attribute(1)]]; + float4 m_location_2 [[attribute(2)]]; + float4 Pos [[attribute(4)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + spvUnsafeArray A = {}; + spvUnsafeArray B = {}; + spvUnsafeArray C = {}; + spvUnsafeArray InA = {}; + spvUnsafeArray InB = {}; + spvUnsafeArray InC = {}; + float InD = {}; + InA[0] = in.m_location_1.x; + InA[1] = in.m_location_2.x; + InB[0] = in.m_location_1.zw; + InB[1] = in.m_location_2.zw; + InC[0] = in.m_location_0.y; + InC[1] = in.m_location_1.y; + InC[2] = in.m_location_2.y; + InD = in.m_location_0.w; + out.gl_Position = in.Pos; + A = InA; + B = InB; + C = InC; + out.D = InD; + out.A_0 = A[0]; + out.A_1 = A[1]; + out.B_0 = B[0]; + out.B_1 = B[1]; + out.C_0 = C[0]; + out.C_1 = C[1]; + out.C_2 = C[2]; + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/vert/implicit-position-1.vert b/third_party/spirv-cross/reference/shaders-msl/vert/implicit-position-1.vert new file mode 100644 index 0000000000..5cea4ee2c2 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/vert/implicit-position-1.vert @@ -0,0 +1,18 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 V [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0() +{ + main0_out out = {}; + out.V = float4(1.0); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/vert/implicit-position-2.vert b/third_party/spirv-cross/reference/shaders-msl/vert/implicit-position-2.vert new file mode 100644 index 0000000000..9e024c2095 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/vert/implicit-position-2.vert @@ -0,0 +1,9 @@ +#include +#include + +using namespace metal; + +vertex void main0() +{ +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/vert/in_out_array_mat.vert b/third_party/spirv-cross/reference/shaders-msl/vert/in_out_array_mat.vert index 4fd1365edc..19bfa7311e 100644 --- a/third_party/spirv-cross/reference/shaders-msl/vert/in_out_array_mat.vert +++ b/third_party/spirv-cross/reference/shaders-msl/vert/in_out_array_mat.vert @@ -78,14 +78,14 @@ struct main0_in }; static inline __attribute__((always_inline)) -void write_deeper_in_function(thread float4x4& outTransModel, constant UBO& ubo, thread float4& color, thread spvUnsafeArray (&colors)) +void write_deeper_in_function(thread float4x4& outTransModel, constant UBO& ubo, thread float4& color, thread spvUnsafeArray& colors) { outTransModel[1].y = ubo.lodBias; color = colors[2]; } static inline __attribute__((always_inline)) -void write_in_function(thread float4x4& outTransModel, constant UBO& ubo, thread float4& color, thread spvUnsafeArray (&colors), thread float3& inNormal) +void write_in_function(thread float4x4& outTransModel, constant UBO& ubo, thread float4& color, thread spvUnsafeArray& colors, thread float3& inNormal) { outTransModel[2] = float4(inNormal, 1.0); write_deeper_in_function(outTransModel, ubo, color, colors); diff --git a/third_party/spirv-cross/reference/shaders-msl/vert/no-contraction.vert b/third_party/spirv-cross/reference/shaders-msl/vert/no-contraction.vert new file mode 100644 index 0000000000..907d9010fa --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/vert/no-contraction.vert @@ -0,0 +1,92 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 vA [[attribute(0)]]; + float4 vB [[attribute(1)]]; + float4 vC [[attribute(2)]]; +}; + +template +T spvFMul(T l, T r) +{ + return fma(l, r, T(0)); +} + +template +vec spvFMulVectorMatrix(vec v, matrix m) +{ + vec res = vec(0); + for (uint i = Rows; i > 0; --i) + { + vec tmp(0); + for (uint j = 0; j < Cols; ++j) + { + tmp[j] = m[j][i - 1]; + } + res = fma(tmp, vec(v[i - 1]), res); + } + return res; +} + +template +vec spvFMulMatrixVector(matrix m, vec v) +{ + vec res = vec(0); + for (uint i = Cols; i > 0; --i) + { + res = fma(m[i - 1], vec(v[i - 1]), res); + } + return res; +} + +template +matrix spvFMulMatrixMatrix(matrix l, matrix r) +{ + matrix res; + for (uint i = 0; i < RCols; i++) + { + vec tmp(0); + for (uint j = 0; j < LCols; j++) + { + tmp = fma(vec(r[i][j]), l[j], tmp); + } + res[i] = tmp; + } + return res; +} + +template +T spvFAdd(T l, T r) +{ + return fma(T(1), l, r); +} + +template +T spvFSub(T l, T r) +{ + return fma(T(-1), r, l); +} + +vertex main0_out main0(main0_in in [[stage_in]]) +{ + main0_out out = {}; + float4 mul = spvFMul(in.vA, in.vB); + float4 add = spvFAdd(in.vA, in.vB); + float4 sub = spvFSub(in.vA, in.vB); + float4 mad = spvFAdd(spvFMul(in.vA, in.vB), in.vC); + float4 summed = spvFAdd(spvFAdd(spvFAdd(mul, add), sub), mad); + out.gl_Position = summed; + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/vert/return-array.force-native-array.vert b/third_party/spirv-cross/reference/shaders-msl/vert/return-array.force-native-array.vert index a3b5f7cd24..bff0ed74af 100644 --- a/third_party/spirv-cross/reference/shaders-msl/vert/return-array.force-native-array.vert +++ b/third_party/spirv-cross/reference/shaders-msl/vert/return-array.force-native-array.vert @@ -127,18 +127,18 @@ inline void spvArrayCopyFromDeviceToThreadGroup1(threadgroup T (&dst)[A], device } static inline __attribute__((always_inline)) -void test(thread float4 (&SPIRV_Cross_return_value)[2]) +void test(thread float4 (&spvReturnValue)[2]) { - spvArrayCopyFromConstantToStack1(SPIRV_Cross_return_value, _20); + spvArrayCopyFromConstantToStack1(spvReturnValue, _20); } static inline __attribute__((always_inline)) -void test2(thread float4 (&SPIRV_Cross_return_value)[2], thread float4& vInput0, thread float4& vInput1) +void test2(thread float4 (&spvReturnValue)[2], thread float4& vInput0, thread float4& vInput1) { float4 foobar[2]; foobar[0] = vInput0; foobar[1] = vInput1; - spvArrayCopyFromStackToStack1(SPIRV_Cross_return_value, foobar); + spvArrayCopyFromStackToStack1(spvReturnValue, foobar); } vertex main0_out main0(main0_in in [[stage_in]]) diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-aliased-block-name.nocompat.vk.asm.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-aliased-block-name.nocompat.vk.asm.comp.vk new file mode 100644 index 0000000000..cabf8352e5 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-aliased-block-name.nocompat.vk.asm.comp.vk @@ -0,0 +1,35 @@ +#version 450 +#extension GL_EXT_buffer_reference : require +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +layout(buffer_reference) buffer Alias; +layout(buffer_reference) buffer _6; +layout(buffer_reference) buffer _7; +layout(buffer_reference, std430) readonly buffer Alias +{ + vec4 v[]; +}; + +layout(buffer_reference, std430) restrict buffer _6 +{ + vec4 v[]; +}; + +layout(buffer_reference, std430) coherent writeonly buffer _7 +{ + vec4 v[]; +}; + +layout(push_constant, std430) uniform Registers +{ + Alias ro; + _6 rw; + _7 wo; +} registers; + +void main() +{ + registers.rw.v[gl_GlobalInvocationID.x] = registers.ro.v[gl_GlobalInvocationID.x]; + registers.wo.v[gl_GlobalInvocationID.x] = registers.ro.v[gl_GlobalInvocationID.x]; +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/eliminate-globals-not-in-entry-point.noeliminate.spv14.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/eliminate-globals-not-in-entry-point.noeliminate.spv14.asm.comp new file mode 100644 index 0000000000..77ea03495f --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/eliminate-globals-not-in-entry-point.noeliminate.spv14.asm.comp @@ -0,0 +1,7 @@ +#version 450 +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +void main() +{ +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/nonuniform-bracket-handling.vk.nocompat.asm.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/nonuniform-bracket-handling.vk.nocompat.asm.comp.vk index 1a093c40c3..9b7de0622f 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/nonuniform-bracket-handling.vk.nocompat.asm.comp.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/nonuniform-bracket-handling.vk.nocompat.asm.comp.vk @@ -27,29 +27,29 @@ layout(set = 4, binding = 0, r32ui) uniform uimageBuffer _10[]; void main() { - uint _60 = registers._m4 + 2u; - uint _63 = subgroupBroadcastFirst(_60); - uint _70 = subgroupBroadcastFirst(registers._m4); - uint _75 = registers._m1 + 1u; - uint _78 = subgroupBroadcastFirst(_75); - uint _87 = gl_GlobalInvocationID.x + 4u; - uint _98 = gl_GlobalInvocationID.x + 1024u; - imageStore(_9[registers._m4], int((_98 < _7._m0[_70].y) ? (_98 + _7._m0[_70].x) : 4294967295u), vec4(imageLoad(_9[registers._m4], int((_87 < _7._m0[_70].y) ? (_87 + _7._m0[_70].x) : 4294967295u)))); - uint _105 = gl_GlobalInvocationID.x + 2u; - uint _116 = gl_GlobalInvocationID.x + 2048u; - imageStore(_9[registers._m4], int((_116 < _7._m0[_70].y) ? (_116 + _7._m0[_70].x) : 4294967295u), vec4(texelFetch(_8[_75], int((_105 < _7._m0[_78].y) ? (_105 + _7._m0[_78].x) : 4294967295u)))); - uint _129 = imageAtomicAdd(_10[_60], int((gl_GlobalInvocationID.x < _7._m0[_63].y) ? (gl_GlobalInvocationID.x + _7._m0[_63].x) : 4294967295u), 40u); - uint _136 = imageAtomicCompSwap(_10[_60], int((gl_GlobalInvocationID.y < _7._m0[_63].y) ? (gl_GlobalInvocationID.y + _7._m0[_63].x) : 4294967295u), 40u, 50u); - imageStore(_9[registers._m4], int((0u < _7._m0[_70].y) ? (0u + _7._m0[_70].x) : 4294967295u), vec4(float(_7._m0[_70].y))); - imageStore(_9[registers._m4], int((1u < _7._m0[_70].y) ? (1u + _7._m0[_70].x) : 4294967295u), vec4(float(_7._m0[_78].y))); + uint _61 = registers._m4 + 2u; + uint _64 = subgroupBroadcastFirst(_61); + uint _71 = subgroupBroadcastFirst(registers._m4); + uint _76 = registers._m1 + 1u; + uint _79 = subgroupBroadcastFirst(_76); + uint _88 = gl_GlobalInvocationID.x + 4u; + uint _99 = gl_GlobalInvocationID.x + 1024u; + imageStore(_9[registers._m4], int((_99 < _7._m0[_71].y) ? (_99 + _7._m0[_71].x) : 4294967295u), vec4(imageLoad(_9[registers._m4], int((_88 < _7._m0[_71].y) ? (_88 + _7._m0[_71].x) : 4294967295u)))); + uint _106 = gl_GlobalInvocationID.x + 2u; + uint _117 = gl_GlobalInvocationID.x + 2048u; + imageStore(_9[registers._m4], int((_117 < _7._m0[_71].y) ? (_117 + _7._m0[_71].x) : 4294967295u), vec4(texelFetch(_8[_76], int((_106 < _7._m0[_79].y) ? (_106 + _7._m0[_79].x) : 4294967295u)))); + uint _130 = imageAtomicAdd(_10[_61], int((gl_GlobalInvocationID.x < _7._m0[_64].y) ? (gl_GlobalInvocationID.x + _7._m0[_64].x) : 4294967295u), 40u); + uint _137 = imageAtomicCompSwap(_10[_61], int((gl_GlobalInvocationID.y < _7._m0[_64].y) ? (gl_GlobalInvocationID.y + _7._m0[_64].x) : 4294967295u), 40u, 50u); + imageStore(_9[registers._m4], int((0u < _7._m0[_71].y) ? (0u + _7._m0[_71].x) : 4294967295u), vec4(float(_7._m0[_71].y))); + imageStore(_9[registers._m4], int((1u < _7._m0[_71].y) ? (1u + _7._m0[_71].x) : 4294967295u), vec4(float(_7._m0[_79].y))); uint _11 = registers._m4 + (gl_GlobalInvocationID.z + 0u); - imageStore(_9[nonuniformEXT(_11)], int((_98 < _7._m0[_11].y) ? (_98 + _7._m0[_11].x) : 4294967295u), vec4(imageLoad(_9[nonuniformEXT(_11)], int((_87 < _7._m0[_11].y) ? (_87 + _7._m0[_11].x) : 4294967295u)))); + imageStore(_9[nonuniformEXT(_11)], int((_99 < _7._m0[_11].y) ? (_99 + _7._m0[_11].x) : 4294967295u), vec4(imageLoad(_9[nonuniformEXT(_11)], int((_88 < _7._m0[_11].y) ? (_88 + _7._m0[_11].x) : 4294967295u)))); uint _13 = registers._m1 + (gl_GlobalInvocationID.z + 0u); - imageStore(_9[nonuniformEXT(_11)], int((_116 < _7._m0[_11].y) ? (_116 + _7._m0[_11].x) : 4294967295u), vec4(texelFetch(_8[nonuniformEXT(_13)], int((_87 < _7._m0[_13].y) ? (_87 + _7._m0[_13].x) : 4294967295u)))); + imageStore(_9[nonuniformEXT(_11)], int((_117 < _7._m0[_11].y) ? (_117 + _7._m0[_11].x) : 4294967295u), vec4(texelFetch(_8[nonuniformEXT(_13)], int((_88 < _7._m0[_13].y) ? (_88 + _7._m0[_13].x) : 4294967295u)))); uint _15 = registers._m4 + (gl_GlobalInvocationID.z + 0u); - uint _208 = imageAtomicAdd(_10[nonuniformEXT(_15)], int((gl_GlobalInvocationID.y < _7._m0[_15].y) ? (gl_GlobalInvocationID.y + _7._m0[_15].x) : 4294967295u), 40u); + uint _209 = imageAtomicAdd(_10[nonuniformEXT(_15)], int((gl_GlobalInvocationID.y < _7._m0[_15].y) ? (gl_GlobalInvocationID.y + _7._m0[_15].x) : 4294967295u), 40u); uint _215 = imageAtomicCompSwap(_10[nonuniformEXT(_15)], int((gl_GlobalInvocationID.y < _7._m0[_15].y) ? (gl_GlobalInvocationID.y + _7._m0[_15].x) : 4294967295u), 40u, 70u); - imageStore(_9[registers._m4], int((2u < _7._m0[_70].y) ? (2u + _7._m0[_70].x) : 4294967295u), vec4(float(_7._m0[_11].y))); - imageStore(_9[registers._m4], int((3u < _7._m0[_70].y) ? (3u + _7._m0[_70].x) : 4294967295u), vec4(float(_7._m0[_13].y))); + imageStore(_9[registers._m4], int((2u < _7._m0[_71].y) ? (2u + _7._m0[_71].x) : 4294967295u), vec4(float(_7._m0[_11].y))); + imageStore(_9[registers._m4], int((3u < _7._m0[_71].y) ? (3u + _7._m0[_71].x) : 4294967295u), vec4(float(_7._m0[_13].y))); } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/storage-buffer-basic.invalid.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/storage-buffer-basic.asm.comp similarity index 100% rename from third_party/spirv-cross/reference/shaders-no-opt/asm/comp/storage-buffer-basic.invalid.asm.comp rename to third_party/spirv-cross/reference/shaders-no-opt/asm/comp/storage-buffer-basic.asm.comp diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/array-builtin-bitcast-load-store.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/array-builtin-bitcast-load-store.asm.frag new file mode 100644 index 0000000000..40f6ee714b --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/array-builtin-bitcast-load-store.asm.frag @@ -0,0 +1,28 @@ +#version 450 + +layout(binding = 0, std140) uniform uBuffer +{ + vec4 color; +} x_12; + +layout(location = 0) out vec4 fragColor; +const vec4 _2_init = vec4(0.0); + +void main() +{ + fragColor = _2_init; + gl_SampleMask[0] = 0; + fragColor = x_12.color; + gl_SampleMask[0] = int(uint(6)); + gl_SampleMask[0] = int(uint(gl_SampleMask[0])); + uint _30_unrolled[1]; + for (int i = 0; i < int(1); i++) + { + _30_unrolled[i] = int(gl_SampleMask[i]); + } + for (int i = 0; i < int(1); i++) + { + gl_SampleMask[i] = int(_30_unrolled[i]); + } +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/nonuniform-qualifier-propagation.vk.nocompat.asm.frag.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/nonuniform-qualifier-propagation.vk.nocompat.asm.frag.vk index 5f7ddeee17..289f576f6d 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/nonuniform-qualifier-propagation.vk.nocompat.asm.frag.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/nonuniform-qualifier-propagation.vk.nocompat.asm.frag.vk @@ -24,7 +24,7 @@ void main() int i = vIndex; int _59 = i + 10; int _64 = i + 40; - FragColor = texture(sampler2D(uSamplers[nonuniformEXT(_59)], uSamps[nonuniformEXT(_64)]), vUV); + FragColor = texture(nonuniformEXT(sampler2D(uSamplers[_59], uSamps[_64])), vUV); int _71 = i + 10; FragColor = texture(uCombinedSamplers[nonuniformEXT(_71)], vUV); int _77 = i + 20; diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/nonuniform-ssbo.nocompat.vk.asm.frag.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/nonuniform-ssbo.nocompat.vk.asm.frag.vk new file mode 100644 index 0000000000..2d98ec5fdf --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/nonuniform-ssbo.nocompat.vk.asm.frag.vk @@ -0,0 +1,24 @@ +#version 450 +#extension GL_EXT_nonuniform_qualifier : require + +layout(set = 0, binding = 3, std430) buffer SSBO +{ + uint counter; + vec4 v[]; +} ssbos[]; + +layout(location = 0) flat in int vIndex; +layout(location = 0) out vec4 FragColor; + +void main() +{ + int i = vIndex; + int _42 = i + 60; + int _45 = i + 70; + ssbos[nonuniformEXT(_42)].v[_45] = vec4(20.0); + int _48 = i + 100; + uint _49 = atomicAdd(ssbos[nonuniformEXT(_48)].counter, 100u); + int _51 = i; + FragColor.z += float(int(uint(ssbos[nonuniformEXT(_51)].v.length()))); +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/only-initializer-frag-depth.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/only-initializer-frag-depth.asm.frag new file mode 100644 index 0000000000..1041f711f8 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/only-initializer-frag-depth.asm.frag @@ -0,0 +1,8 @@ +#version 450 + +const float _3_init = 0.5; +void main() +{ + gl_FragDepth = _3_init; +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/reserved-function-identifier.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/reserved-function-identifier.asm.frag new file mode 100644 index 0000000000..52f0c61661 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/reserved-function-identifier.asm.frag @@ -0,0 +1,21 @@ +#version 450 + +layout(location = 0) out float FragColor; + +float _mat3(float a) +{ + return a + 1.0; +} + +float _RESERVED_IDENTIFIER_FIXUP_gl_Foo(int a) +{ + return float(a) + 1.0; +} + +void main() +{ + float param = 2.0; + int param_1 = 4; + FragColor = _mat3(param) + _RESERVED_IDENTIFIER_FIXUP_gl_Foo(param_1); +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/subgroup-ballot-only.vk.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/subgroup-ballot-only.vk.asm.frag new file mode 100644 index 0000000000..8a918c035c --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/subgroup-ballot-only.vk.asm.frag @@ -0,0 +1,32 @@ +#version 450 + +#if defined(GL_KHR_shader_subgroup_ballot) +#extension GL_KHR_shader_subgroup_ballot : require +#elif defined(GL_NV_shader_thread_group) +#extension GL_NV_shader_thread_group : require +#elif defined(GL_ARB_shader_ballot) && defined(GL_ARB_shader_int64) +#extension GL_ARB_shader_int64 : enable +#extension GL_ARB_shader_ballot : require +#else +#error No extensions available to emulate requested subgroup feature. +#endif + +layout(location = 0) flat in uint INDEX; +layout(location = 0) out uvec4 SV_Target; + +#if defined(GL_KHR_shader_subgroup_ballot) +#elif defined(GL_NV_shader_thread_group) +uvec4 subgroupBallot(bool v) { return uvec4(ballotThreadNV(v), 0u, 0u, 0u); } +#elif defined(GL_ARB_shader_ballot) +uvec4 subgroupBallot(bool v) { return uvec4(unpackUint2x32(ballotARB(v)), 0u, 0u); } +#endif + +void main() +{ + uvec4 _21 = subgroupBallot(INDEX < 100u); + SV_Target.x = _21.x; + SV_Target.y = _21.y; + SV_Target.z = _21.z; + SV_Target.w = _21.w; +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/subgroup-ballot-only.vk.asm.frag.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/subgroup-ballot-only.vk.asm.frag.vk new file mode 100644 index 0000000000..ed5933f312 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/subgroup-ballot-only.vk.asm.frag.vk @@ -0,0 +1,15 @@ +#version 450 +#extension GL_KHR_shader_subgroup_ballot : require + +layout(location = 0) flat in uint INDEX; +layout(location = 0) out uvec4 SV_Target; + +void main() +{ + uvec4 _21 = subgroupBallot(INDEX < 100u); + SV_Target.x = _21.x; + SV_Target.y = _21.y; + SV_Target.z = _21.z; + SV_Target.w = _21.w; +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/rgen/acceleration-nonuniform.spv14.vk.nocompat.asm.rgen.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/rgen/acceleration-nonuniform.spv14.vk.nocompat.asm.rgen.vk new file mode 100644 index 0000000000..a72a7cf48a --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/rgen/acceleration-nonuniform.spv14.vk.nocompat.asm.rgen.vk @@ -0,0 +1,19 @@ +#version 460 +#extension GL_EXT_ray_tracing : require +#extension GL_EXT_nonuniform_qualifier : require + +layout(set = 0, binding = 1) uniform accelerationStructureEXT as[]; +layout(location = 0) rayPayloadEXT float payload; +layout(set = 0, binding = 0, rgba8) uniform writeonly image2D image; + +void main() +{ + vec4 col = vec4(0.0, 0.0, 0.0, 1.0); + vec3 origin = vec3(float(gl_LaunchIDEXT.x) / float(gl_LaunchSizeEXT.x), float(gl_LaunchIDEXT.y) / float(gl_LaunchSizeEXT.y), 1.0); + vec3 direction = vec3(0.0, 0.0, -1.0); + uint _62 = gl_LaunchIDEXT.x; + traceRayEXT(as[nonuniformEXT(_62)], 0u, 255u, 0u, 1u, 0u, origin, 0.0, direction, 1000.0, 0); + col.y = payload; + imageStore(image, ivec2(gl_LaunchIDEXT.xy), col); +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/tesc/array-of-block-output-initializer.asm.tesc b/third_party/spirv-cross/reference/shaders-no-opt/asm/tesc/array-of-block-output-initializer.asm.tesc new file mode 100644 index 0000000000..13e1d3294b --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/tesc/array-of-block-output-initializer.asm.tesc @@ -0,0 +1,82 @@ +#version 450 +layout(vertices = 4) out; + +out gl_PerVertex +{ + vec4 gl_Position; + float gl_PointSize; + float gl_ClipDistance[1]; + float gl_CullDistance[1]; +} gl_out[4]; + +layout(location = 0) patch out vert +{ + float v0; + float v1; +} _5; + +layout(location = 2) patch out vert_patch +{ + float v2; + float v3; +} patches[2]; + +layout(location = 6) patch out float v2; +layout(location = 7) out float v3[4]; +layout(location = 8) out vert2 +{ + float v4; + float v5; +} verts[4]; + +const vec4 _3_0_init[4] = vec4[](vec4(0.0), vec4(0.0), vec4(0.0), vec4(0.0)); +const float _3_1_init[4] = float[](0.0, 0.0, 0.0, 0.0); +const float _3_2_init[4][1] = float[][](float[](0.0), float[](0.0), float[](0.0), float[](0.0)); +const float _3_3_init[4][1] = float[][](float[](0.0), float[](0.0), float[](0.0), float[](0.0)); +const float _6_0_init[2] = float[](0.0, 0.0); +const float _6_1_init[2] = float[](0.0, 0.0); +const float _7_init = 0.0; +const float _8_init[4] = float[](0.0, 0.0, 0.0, 0.0); +const float _9_0_init[4] = float[](0.0, 0.0, 0.0, 0.0); +const float _9_1_init[4] = float[](0.0, 0.0, 0.0, 0.0); + +void main() +{ + gl_out[gl_InvocationID].gl_Position = _3_0_init[gl_InvocationID]; + gl_out[gl_InvocationID].gl_PointSize = _3_1_init[gl_InvocationID]; + gl_out[gl_InvocationID].gl_ClipDistance = _3_2_init[gl_InvocationID]; + gl_out[gl_InvocationID].gl_CullDistance = _3_3_init[gl_InvocationID]; + if (gl_InvocationID == 0) + { + _5.v0 = 0.0; + } + if (gl_InvocationID == 0) + { + _5.v1 = 0.0; + } + if (gl_InvocationID == 0) + { + patches[0].v2 = _6_0_init[0]; + } + if (gl_InvocationID == 0) + { + patches[1].v2 = _6_0_init[1]; + } + if (gl_InvocationID == 0) + { + patches[0].v3 = _6_1_init[0]; + } + if (gl_InvocationID == 0) + { + patches[1].v3 = _6_1_init[1]; + } + if (gl_InvocationID == 0) + { + v2 = _7_init; + } + v3[gl_InvocationID] = _8_init[gl_InvocationID]; + verts[gl_InvocationID].v4 = _9_0_init[gl_InvocationID]; + verts[gl_InvocationID].v5 = _9_1_init[gl_InvocationID]; + gl_out[gl_InvocationID].gl_Position = vec4(1.0); +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/tesc/copy-memory-control-point.asm.tesc b/third_party/spirv-cross/reference/shaders-no-opt/asm/tesc/copy-memory-control-point.asm.tesc new file mode 100644 index 0000000000..3412f1cf5c --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/tesc/copy-memory-control-point.asm.tesc @@ -0,0 +1,73 @@ +#version 450 +layout(vertices = 3) out; + +layout(binding = 0, std140) uniform cb1_struct +{ + vec4 _m0[1]; +} cb0_0; + +layout(location = 0) in vec4 v0[]; +layout(location = 1) in vec4 v1[]; +layout(location = 2) in vec3 vicp0[]; +layout(location = 3) out vec3 vocp0[3]; +layout(location = 4) in vec4 vicp1[]; +layout(location = 5) out vec4 vocp1[3]; +vec4 opc[4]; +vec4 vicp[2][3]; +vec4 _48; +vec4 _49; +vec4 _50; +vec4 _56; + +void fork0_epilogue(vec4 _87, vec4 _88, vec4 _89) +{ + gl_TessLevelOuter[0u] = _87.x; + gl_TessLevelOuter[1u] = _88.x; + gl_TessLevelOuter[2u] = _89.x; +} + +void fork0(uint vForkInstanceId) +{ + vec4 r0; + r0.x = uintBitsToFloat(vForkInstanceId); + opc[floatBitsToInt(r0.x)].x = cb0_0._m0[0u].x; + _48 = opc[0u]; + _49 = opc[1u]; + _50 = opc[2u]; + fork0_epilogue(_48, _49, _50); +} + +void fork1_epilogue(vec4 _109) +{ + gl_TessLevelInner[0u] = _109.x; +} + +void fork1() +{ + opc[3u].x = cb0_0._m0[0u].x; + _56 = opc[3u]; + fork1_epilogue(_56); +} + +void main() +{ + vec4 _126_unrolled[3]; + for (int i = 0; i < int(3); i++) + { + _126_unrolled[i] = v0[i]; + } + vicp[0u] = _126_unrolled; + vec4 _127_unrolled[3]; + for (int i = 0; i < int(3); i++) + { + _127_unrolled[i] = v1[i]; + } + vicp[1u] = _127_unrolled; + vocp0[gl_InvocationID] = vicp0[gl_InvocationID]; + vocp1[gl_InvocationID] = vicp1[gl_InvocationID]; + fork0(0u); + fork0(1u); + fork0(2u); + fork1(); +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/tesc/tess-level-initializer.asm.tesc b/third_party/spirv-cross/reference/shaders-no-opt/asm/tesc/tess-level-initializer.asm.tesc new file mode 100644 index 0000000000..ebd2d8aeac --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/tesc/tess-level-initializer.asm.tesc @@ -0,0 +1,24 @@ +#version 450 +layout(vertices = 4) out; + +const float _5_init[2] = float[](0.0, 0.0); +const float _6_init[4] = float[](0.0, 0.0, 0.0, 0.0); +void main() +{ + if (gl_InvocationID == 0) + { + gl_TessLevelInner = _5_init; + } + if (gl_InvocationID == 0) + { + gl_TessLevelOuter = _6_init; + } + gl_out[gl_InvocationID].gl_Position = vec4(1.0); + gl_TessLevelInner[0] = 1.0; + gl_TessLevelInner[1] = 2.0; + gl_TessLevelOuter[0] = 3.0; + gl_TessLevelOuter[1] = 4.0; + gl_TessLevelOuter[2] = 5.0; + gl_TessLevelOuter[3] = 6.0; +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/vert/block-struct-initializer.asm.vert b/third_party/spirv-cross/reference/shaders-no-opt/asm/vert/block-struct-initializer.asm.vert new file mode 100644 index 0000000000..6060888d81 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/vert/block-struct-initializer.asm.vert @@ -0,0 +1,24 @@ +#version 450 + +struct Foo +{ + float c; + float d; +}; + +layout(location = 0) out Vert +{ + float a; + float b; +} _3; + +layout(location = 2) out Foo foo; +const Foo _4_init = Foo(0.0, 0.0); + +void main() +{ + _3.a = 0.0; + _3.b = 0.0; + foo = _4_init; +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/vert/builtin-output-initializer.asm.vert b/third_party/spirv-cross/reference/shaders-no-opt/asm/vert/builtin-output-initializer.asm.vert new file mode 100644 index 0000000000..b449f08057 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/vert/builtin-output-initializer.asm.vert @@ -0,0 +1,14 @@ +#version 450 + +out float gl_ClipDistance[1]; +out float gl_CullDistance[1]; + +void main() +{ + gl_Position = vec4(0.0); + gl_PointSize = 0.0; + gl_ClipDistance = float[](0.0); + gl_CullDistance = float[](0.0); + gl_Position = vec4(1.0); +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/vert/constant-composite-extract.asm.vert b/third_party/spirv-cross/reference/shaders-no-opt/asm/vert/constant-composite-extract.asm.vert new file mode 100644 index 0000000000..a1fe3e50ac --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/vert/constant-composite-extract.asm.vert @@ -0,0 +1,7 @@ +#version 450 + +void main() +{ + gl_Position = (vec4(1.0, 2.0, 3.0, 4.0) + vec4(5.0, 6.0, 7.0, 8.0)) + (vec4(1.0, 2.0, 3.0, 4.0) + vec4(4.0, 3.0, 8.0, 2.0)); +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/comp/bitcast-16bit-1.invalid.comp b/third_party/spirv-cross/reference/shaders-no-opt/comp/bitcast-16bit-1.invalid.comp index 501f97955f..a570948a85 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/comp/bitcast-16bit-1.invalid.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/comp/bitcast-16bit-1.invalid.comp @@ -8,6 +8,8 @@ #endif #if defined(GL_AMD_gpu_shader_int16) #extension GL_AMD_gpu_shader_int16 : require +#elif defined(GL_NV_gpu_shader5) +#extension GL_NV_gpu_shader5 : require #else #error No extension available for Int16. #endif diff --git a/third_party/spirv-cross/reference/shaders-no-opt/comp/bitcast-16bit-2.invalid.comp b/third_party/spirv-cross/reference/shaders-no-opt/comp/bitcast-16bit-2.invalid.comp index bddc16d62b..78a1255268 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/comp/bitcast-16bit-2.invalid.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/comp/bitcast-16bit-2.invalid.comp @@ -1,6 +1,8 @@ #version 450 #if defined(GL_AMD_gpu_shader_int16) #extension GL_AMD_gpu_shader_int16 : require +#elif defined(GL_NV_gpu_shader5) +#extension GL_NV_gpu_shader5 : require #else #error No extension available for Int16. #endif diff --git a/third_party/spirv-cross/reference/shaders-no-opt/comp/image-load-formatted.comp b/third_party/spirv-cross/reference/shaders-no-opt/comp/image-load-formatted.comp new file mode 100644 index 0000000000..e11b8febfa --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/comp/image-load-formatted.comp @@ -0,0 +1,12 @@ +#version 450 +#extension GL_EXT_shader_image_load_formatted : require +layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; + +layout(binding = 0) uniform image2D img; + +void main() +{ + vec4 v = imageLoad(img, ivec2(gl_GlobalInvocationID.xy)); + imageStore(img, ivec2(gl_GlobalInvocationID.xy), v + vec4(1.0)); +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/comp/subgroups.nocompat.invalid.vk.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/comp/subgroups.nocompat.invalid.vk.comp.vk index 6d288574f7..f3fa6dd00c 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/comp/subgroups.nocompat.invalid.vk.comp.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/comp/subgroups.nocompat.invalid.vk.comp.vk @@ -62,6 +62,9 @@ void main() uvec4 anded = subgroupAnd(ballot_value); uvec4 ored = subgroupOr(ballot_value); uvec4 xored = subgroupXor(ballot_value); + bvec4 anded_b = subgroupAnd(equal(ballot_value, uvec4(42u))); + bvec4 ored_b = subgroupOr(equal(ballot_value, uvec4(42u))); + bvec4 xored_b = subgroupXor(equal(ballot_value, uvec4(42u))); added = subgroupInclusiveAdd(added); iadded = subgroupInclusiveAdd(iadded); multiplied = subgroupInclusiveMul(multiplied); @@ -102,6 +105,9 @@ void main() anded = subgroupClusteredAnd(anded, 4u); ored = subgroupClusteredOr(ored, 4u); xored = subgroupClusteredXor(xored, 4u); + anded_b = subgroupClusteredAnd(equal(anded, uvec4(2u)), 4u); + ored_b = subgroupClusteredOr(equal(ored, uvec4(3u)), 4u); + xored_b = subgroupClusteredXor(equal(xored, uvec4(4u)), 4u); vec4 swap_horiz = subgroupQuadSwapHorizontal(vec4(20.0)); vec4 swap_vertical = subgroupQuadSwapVertical(vec4(20.0)); vec4 swap_diagonal = subgroupQuadSwapDiagonal(vec4(20.0)); diff --git a/third_party/spirv-cross/reference/shaders-no-opt/frag/16bit-constants.invalid.frag b/third_party/spirv-cross/reference/shaders-no-opt/frag/16bit-constants.invalid.frag index 57d8256138..a3037d15ee 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/frag/16bit-constants.invalid.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/frag/16bit-constants.invalid.frag @@ -8,6 +8,8 @@ #endif #if defined(GL_AMD_gpu_shader_int16) #extension GL_AMD_gpu_shader_int16 : require +#elif defined(GL_NV_gpu_shader5) +#extension GL_NV_gpu_shader5 : require #else #error No extension available for Int16. #endif diff --git a/third_party/spirv-cross/reference/shaders-no-opt/frag/frag-fully-covered.frag b/third_party/spirv-cross/reference/shaders-no-opt/frag/frag-fully-covered.frag new file mode 100644 index 0000000000..0f22a7de2a --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/frag/frag-fully-covered.frag @@ -0,0 +1,14 @@ +#version 450 +#extension GL_NV_conservative_raster_underestimation : require + +layout(location = 0) out vec4 FragColor; + +void main() +{ + if (!gl_FragFullyCoveredNV) + { + discard; + } + FragColor = vec4(1.0); +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/frag/nonuniform-constructor.vk.nocompat.frag.vk b/third_party/spirv-cross/reference/shaders-no-opt/frag/nonuniform-constructor.vk.nocompat.frag.vk new file mode 100644 index 0000000000..ab58862ffd --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/frag/nonuniform-constructor.vk.nocompat.frag.vk @@ -0,0 +1,15 @@ +#version 450 +#extension GL_EXT_nonuniform_qualifier : require + +layout(set = 0, binding = 0) uniform texture2D uTex[]; +layout(set = 1, binding = 0) uniform sampler Immut; + +layout(location = 0) out vec4 FragColor; +layout(location = 1) flat in int vIndex; +layout(location = 0) in vec2 vUV; + +void main() +{ + FragColor = texture(nonuniformEXT(sampler2D(uTex[vIndex], Immut)), vUV); +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/frag/subpass-input.framebuffer-fetch.nocompat.framebuffer-fetch-noncoherent.frag b/third_party/spirv-cross/reference/shaders-no-opt/frag/subpass-input.framebuffer-fetch.nocompat.framebuffer-fetch-noncoherent.frag new file mode 100644 index 0000000000..8600549859 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/frag/subpass-input.framebuffer-fetch.nocompat.framebuffer-fetch-noncoherent.frag @@ -0,0 +1,18 @@ +#version 310 es +#extension GL_EXT_shader_framebuffer_fetch_non_coherent : require +precision mediump float; +precision highp int; + +mediump vec4 uSubpass0; +mediump vec4 uSubpass1; + +layout(location = 0, noncoherent) inout vec3 FragColor; +layout(location = 1, noncoherent) inout vec4 FragColor2; + +void main() +{ + uSubpass0.xyz = FragColor; + uSubpass1 = FragColor2; + FragColor = uSubpass0.xyz + uSubpass1.xyz; +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/frag/subpass-input.framebuffer-fetch.nocompat.legacy.framebuffer-fetch-noncoherent.frag b/third_party/spirv-cross/reference/shaders-no-opt/frag/subpass-input.framebuffer-fetch.nocompat.legacy.framebuffer-fetch-noncoherent.frag new file mode 100644 index 0000000000..c0a40571b0 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/frag/subpass-input.framebuffer-fetch.nocompat.legacy.framebuffer-fetch-noncoherent.frag @@ -0,0 +1,16 @@ +#version 100 +#extension GL_EXT_shader_framebuffer_fetch_non_coherent : require +#extension GL_EXT_draw_buffers : require +precision mediump float; +precision highp int; + +mediump vec4 uSubpass0; +mediump vec4 uSubpass1; + +void main() +{ + uSubpass0 = gl_LastFragData[0]; + uSubpass1 = gl_LastFragData[1]; + gl_FragData[0] = uSubpass0.xyz + uSubpass1.xyz; +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/legacy/frag/switch-single-case-multiple-exit-cfg.legacy.asm.frag b/third_party/spirv-cross/reference/shaders-no-opt/legacy/frag/switch-single-case-multiple-exit-cfg.legacy.asm.frag index cc5cb71679..be41ceef0f 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/legacy/frag/switch-single-case-multiple-exit-cfg.legacy.asm.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/legacy/frag/switch-single-case-multiple-exit-cfg.legacy.asm.frag @@ -7,7 +7,7 @@ vec2 _19; void main() { highp vec2 _30; - for (int SPIRV_Cross_Dummy15 = 0; SPIRV_Cross_Dummy15 < 1; SPIRV_Cross_Dummy15++) + for (int spvDummy15 = 0; spvDummy15 < 1; spvDummy15++) { if (gl_FragCoord.x != gl_FragCoord.x) { diff --git a/third_party/spirv-cross/reference/shaders-no-opt/vulkan/frag/shading-rate.vk.nocompat.frag.vk b/third_party/spirv-cross/reference/shaders-no-opt/vulkan/frag/shading-rate.vk.nocompat.frag.vk new file mode 100644 index 0000000000..e5c67115ca --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/vulkan/frag/shading-rate.vk.nocompat.frag.vk @@ -0,0 +1,10 @@ +#version 450 +#extension GL_EXT_fragment_shading_rate : require + +layout(location = 0) out uint FragColor; + +void main() +{ + FragColor = uint(gl_ShadingRateEXT); +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/vulkan/vert/primitive-shading-rate.vk.nocompat.vert.vk b/third_party/spirv-cross/reference/shaders-no-opt/vulkan/vert/primitive-shading-rate.vk.nocompat.vert.vk new file mode 100644 index 0000000000..4736723322 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/vulkan/vert/primitive-shading-rate.vk.nocompat.vert.vk @@ -0,0 +1,9 @@ +#version 450 +#extension GL_EXT_fragment_shading_rate : require + +void main() +{ + gl_PrimitiveShadingRateEXT = 3; + gl_Position = vec4(1.0); +} + diff --git a/third_party/spirv-cross/reference/shaders-ue4/asm/frag/subpass-input.ios.framebuffer-fetch.asm.frag b/third_party/spirv-cross/reference/shaders-ue4/asm/frag/subpass-input.ios.framebuffer-fetch.asm.frag index 817b1cff71..8bffca1733 100644 --- a/third_party/spirv-cross/reference/shaders-ue4/asm/frag/subpass-input.ios.framebuffer-fetch.asm.frag +++ b/third_party/spirv-cross/reference/shaders-ue4/asm/frag/subpass-input.ios.framebuffer-fetch.asm.frag @@ -197,9 +197,10 @@ struct main0_out float4 out_var_SV_Target0 [[color(0)]]; }; -fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_Globals& _Globals [[buffer(1)]], float4 _RESERVED_IDENTIFIER_FIXUP_gl_LastFragData [[color(0)]], texture2d ShadowDepthTexture [[texture(0)]], sampler ShadowDepthTextureSampler [[sampler(0)]], float4 gl_FragCoord [[position]]) +fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_Globals& _Globals [[buffer(1)]], float4 _RESERVED_IDENTIFIER_FIXUP_gl_LastFragData [[color(0)]], texture2d ShadowDepthTexture [[texture(0)]], sampler ShadowDepthTextureSampler [[sampler(0)]], float4 gl_FragCoord [[position]], uint gl_SampleID [[sample_id]]) { main0_out out = {}; + gl_FragCoord.xy += get_sample_position(gl_SampleID) - 0.5; float4 _67 = _RESERVED_IDENTIFIER_FIXUP_gl_LastFragData; float _68 = _67.w; float4 _82 = _Globals.ScreenToShadowMatrix * float4((((gl_FragCoord.xy * View.View_BufferSizeAndInvSize.zw) - View.View_ScreenPositionScaleBias.wz) / View.View_ScreenPositionScaleBias.xy) * float2(_68), _68, 1.0); diff --git a/third_party/spirv-cross/reference/shaders-ue4/asm/frag/subpass-input.msl23.framebuffer-fetch.asm.frag b/third_party/spirv-cross/reference/shaders-ue4/asm/frag/subpass-input.msl23.framebuffer-fetch.asm.frag index 817b1cff71..8bffca1733 100644 --- a/third_party/spirv-cross/reference/shaders-ue4/asm/frag/subpass-input.msl23.framebuffer-fetch.asm.frag +++ b/third_party/spirv-cross/reference/shaders-ue4/asm/frag/subpass-input.msl23.framebuffer-fetch.asm.frag @@ -197,9 +197,10 @@ struct main0_out float4 out_var_SV_Target0 [[color(0)]]; }; -fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_Globals& _Globals [[buffer(1)]], float4 _RESERVED_IDENTIFIER_FIXUP_gl_LastFragData [[color(0)]], texture2d ShadowDepthTexture [[texture(0)]], sampler ShadowDepthTextureSampler [[sampler(0)]], float4 gl_FragCoord [[position]]) +fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_Globals& _Globals [[buffer(1)]], float4 _RESERVED_IDENTIFIER_FIXUP_gl_LastFragData [[color(0)]], texture2d ShadowDepthTexture [[texture(0)]], sampler ShadowDepthTextureSampler [[sampler(0)]], float4 gl_FragCoord [[position]], uint gl_SampleID [[sample_id]]) { main0_out out = {}; + gl_FragCoord.xy += get_sample_position(gl_SampleID) - 0.5; float4 _67 = _RESERVED_IDENTIFIER_FIXUP_gl_LastFragData; float _68 = _67.w; float4 _82 = _Globals.ScreenToShadowMatrix * float4((((gl_FragCoord.xy * View.View_BufferSizeAndInvSize.zw) - View.View_ScreenPositionScaleBias.wz) / View.View_ScreenPositionScaleBias.xy) * float2(_68), _68, 1.0); diff --git a/third_party/spirv-cross/reference/shaders-ue4/asm/tese/ds-patch-input-fixes.asm.tese b/third_party/spirv-cross/reference/shaders-ue4/asm/tese/ds-patch-input-fixes.asm.tese index 738b073a1d..3c063c93b1 100644 --- a/third_party/spirv-cross/reference/shaders-ue4/asm/tese/ds-patch-input-fixes.asm.tese +++ b/third_party/spirv-cross/reference/shaders-ue4/asm/tese/ds-patch-input-fixes.asm.tese @@ -246,9 +246,9 @@ struct main0_out float4 out_var_TEXCOORD7 [[user(locn1)]]; float4 out_var_TEXCOORD10_centroid [[user(locn2)]]; float4 out_var_TEXCOORD11_centroid [[user(locn3)]]; + float4 gl_Position [[position]]; float gl_ClipDistance [[clip_distance]] [1]; float gl_ClipDistance_0 [[user(clip0)]]; - float4 gl_Position [[position]]; }; struct main0_in diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag index 3585285eb6..ec89d44eef 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/hlsl-sample-cmp-level-zero-cube.asm.frag @@ -6,7 +6,7 @@ layout(location = 0) out float _entryPointOutput; float _main() { - vec4 _33 = vec4(vec3(0.100000001490116119384765625), 0.5); + vec4 _33 = vec4(0.100000001490116119384765625, 0.100000001490116119384765625, 0.100000001490116119384765625, 0.5); return textureGrad(SPIRV_Cross_CombinedpointLightShadowMapshadowSamplerPCF, vec4(_33.xyz, _33.w), vec3(0.0), vec3(0.0)); } diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag index 4302113daa..d784c88390 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/loop-body-dominator-continue-access.asm.frag @@ -10,7 +10,7 @@ layout(binding = 0, std140) uniform Foo layout(location = 0) in vec3 fragWorld; layout(location = 0) out int _entryPointOutput; -mat4 SPIRV_Cross_workaround_load_row_major(mat4 wrap) { return wrap; } +mat4 spvWorkaroundRowMajor(mat4 wrap) { return wrap; } mat4 GetClip2TexMatrix() { @@ -25,7 +25,7 @@ int GetCascade(vec3 fragWorldPosition) { for (uint cascadeIndex = 0u; cascadeIndex < _11.shadowCascadesNum; cascadeIndex++) { - mat4 worldToShadowMap = GetClip2TexMatrix() * SPIRV_Cross_workaround_load_row_major(_11.lightVP[cascadeIndex]); + mat4 worldToShadowMap = GetClip2TexMatrix() * spvWorkaroundRowMajor(_11.lightVP[cascadeIndex]); vec4 fragShadowMapPos = worldToShadowMap * vec4(fragWorldPosition, 1.0); if ((((fragShadowMapPos.z >= 0.0) && (fragShadowMapPos.z <= 1.0)) && (max(fragShadowMapPos.x, fragShadowMapPos.y) <= 1.0)) && (min(fragShadowMapPos.x, fragShadowMapPos.y) >= 0.0)) { diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/storage-class-output-initializer.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/storage-class-output-initializer.asm.frag index 229358757a..a5faaefb30 100644 --- a/third_party/spirv-cross/reference/shaders/asm/frag/storage-class-output-initializer.asm.frag +++ b/third_party/spirv-cross/reference/shaders/asm/frag/storage-class-output-initializer.asm.frag @@ -2,10 +2,12 @@ layout(location = 0) out vec4 FragColors[2]; layout(location = 2) out vec4 FragColor; +const vec4 _3_init[2] = vec4[](vec4(1.0, 2.0, 3.0, 4.0), vec4(10.0)); +const vec4 _4_init = vec4(5.0); void main() { - FragColors = vec4[](vec4(1.0, 2.0, 3.0, 4.0), vec4(10.0)); - FragColor = vec4(5.0); + FragColors = _3_init; + FragColor = _4_init; } diff --git a/third_party/spirv-cross/reference/shaders/asm/vert/empty-io.asm.vert b/third_party/spirv-cross/reference/shaders/asm/vert/empty-io.asm.vert index cc432cb890..91e65d6d7a 100644 --- a/third_party/spirv-cross/reference/shaders/asm/vert/empty-io.asm.vert +++ b/third_party/spirv-cross/reference/shaders/asm/vert/empty-io.asm.vert @@ -16,6 +16,7 @@ struct VSOutput_1 }; layout(location = 0) in vec4 position; +layout(location = 0) out VSOutput_1 _entryPointOutput; VSOutput _main(VSInput _input) { diff --git a/third_party/spirv-cross/reference/shaders/frag/ubo-load-row-major-workaround.frag b/third_party/spirv-cross/reference/shaders/frag/ubo-load-row-major-workaround.frag index 95b0eda71d..13049b456b 100644 --- a/third_party/spirv-cross/reference/shaders/frag/ubo-load-row-major-workaround.frag +++ b/third_party/spirv-cross/reference/shaders/frag/ubo-load-row-major-workaround.frag @@ -34,14 +34,14 @@ layout(binding = 3, std140) uniform UBONoWorkaround layout(location = 0) out vec4 FragColor; layout(location = 0) in vec4 Clip; -NestedRowMajor SPIRV_Cross_workaround_load_row_major(NestedRowMajor wrap) { return wrap; } -mat4 SPIRV_Cross_workaround_load_row_major(mat4 wrap) { return wrap; } +NestedRowMajor spvWorkaroundRowMajor(NestedRowMajor wrap) { return wrap; } +mat4 spvWorkaroundRowMajor(mat4 wrap) { return wrap; } void main() { NestedRowMajor rm2_loaded; - rm2_loaded.rm.B = SPIRV_Cross_workaround_load_row_major(_17.rm2).rm.B; - FragColor = (((rm2_loaded.rm.B * SPIRV_Cross_workaround_load_row_major(_35.rm.B)) * SPIRV_Cross_workaround_load_row_major(_42.A)) * SPIRV_Cross_workaround_load_row_major(_42.C)) * Clip; + rm2_loaded.rm.B = spvWorkaroundRowMajor(_17.rm2).rm.B; + FragColor = (((rm2_loaded.rm.B * spvWorkaroundRowMajor(_35.rm.B)) * spvWorkaroundRowMajor(_42.A)) * spvWorkaroundRowMajor(_42.C)) * Clip; FragColor += (_56.D * Clip); FragColor += (_42.A[1] * Clip); } diff --git a/third_party/spirv-cross/reference/shaders/legacy/fragment/switch.legacy.frag b/third_party/spirv-cross/reference/shaders/legacy/fragment/switch.legacy.frag index a70168e6f5..9155d1cdbc 100644 --- a/third_party/spirv-cross/reference/shaders/legacy/fragment/switch.legacy.frag +++ b/third_party/spirv-cross/reference/shaders/legacy/fragment/switch.legacy.frag @@ -8,7 +8,7 @@ void main() { int vIndex = int(vIndexF); highp vec4 v = vec4(0.0); - for (int SPIRV_Cross_Dummy21 = 0; SPIRV_Cross_Dummy21 < 1; SPIRV_Cross_Dummy21++) + for (int spvDummy21 = 0; spvDummy21 < 1; spvDummy21++) { if (vIndex == 2) { @@ -65,7 +65,7 @@ void main() } } highp vec4 w = vec4(20.0); - for (int SPIRV_Cross_Dummy165 = 0; SPIRV_Cross_Dummy165 < 1; SPIRV_Cross_Dummy165++) + for (int spvDummy165 = 0; spvDummy165 < 1; spvDummy165++) { if ((vIndex == 10) || (vIndex == 20)) { diff --git a/third_party/spirv-cross/reference/shaders/legacy/vert/transpose.legacy.vert b/third_party/spirv-cross/reference/shaders/legacy/vert/transpose.legacy.vert index 30700e0b57..8d6ee7c141 100644 --- a/third_party/spirv-cross/reference/shaders/legacy/vert/transpose.legacy.vert +++ b/third_party/spirv-cross/reference/shaders/legacy/vert/transpose.legacy.vert @@ -11,27 +11,27 @@ uniform Buffer _13; attribute vec4 Position; -mat4 SPIRV_Cross_workaround_load_row_major(mat4 wrap) { return wrap; } +mat4 spvWorkaroundRowMajor(mat4 wrap) { return wrap; } -mat4 SPIRV_Cross_Transpose(mat4 m) +mat4 spvTranspose(mat4 m) { return mat4(m[0][0], m[1][0], m[2][0], m[3][0], m[0][1], m[1][1], m[2][1], m[3][1], m[0][2], m[1][2], m[2][2], m[3][2], m[0][3], m[1][3], m[2][3], m[3][3]); } void main() { - vec4 c0 = SPIRV_Cross_workaround_load_row_major(_13.M) * (Position * _13.MVPRowMajor); - vec4 c1 = SPIRV_Cross_workaround_load_row_major(_13.M) * (SPIRV_Cross_workaround_load_row_major(_13.MVPColMajor) * Position); - vec4 c2 = SPIRV_Cross_workaround_load_row_major(_13.M) * (_13.MVPRowMajor * Position); - vec4 c3 = SPIRV_Cross_workaround_load_row_major(_13.M) * (Position * SPIRV_Cross_workaround_load_row_major(_13.MVPColMajor)); + vec4 c0 = spvWorkaroundRowMajor(_13.M) * (Position * _13.MVPRowMajor); + vec4 c1 = spvWorkaroundRowMajor(_13.M) * (spvWorkaroundRowMajor(_13.MVPColMajor) * Position); + vec4 c2 = spvWorkaroundRowMajor(_13.M) * (_13.MVPRowMajor * Position); + vec4 c3 = spvWorkaroundRowMajor(_13.M) * (Position * spvWorkaroundRowMajor(_13.MVPColMajor)); vec4 c4 = _13.MVPRowMajor * Position; - vec4 c5 = Position * SPIRV_Cross_workaround_load_row_major(_13.MVPColMajor); + vec4 c5 = Position * spvWorkaroundRowMajor(_13.MVPColMajor); vec4 c6 = Position * _13.MVPRowMajor; - vec4 c7 = SPIRV_Cross_workaround_load_row_major(_13.MVPColMajor) * Position; - vec4 c8 = (SPIRV_Cross_Transpose(_13.MVPRowMajor) * 2.0) * Position; - vec4 c9 = (SPIRV_Cross_Transpose(SPIRV_Cross_workaround_load_row_major(_13.MVPColMajor)) * 2.0) * Position; - vec4 c10 = Position * (SPIRV_Cross_Transpose(_13.MVPRowMajor) * 2.0); - vec4 c11 = Position * (SPIRV_Cross_Transpose(SPIRV_Cross_workaround_load_row_major(_13.MVPColMajor)) * 2.0); + vec4 c7 = spvWorkaroundRowMajor(_13.MVPColMajor) * Position; + vec4 c8 = (spvTranspose(_13.MVPRowMajor) * 2.0) * Position; + vec4 c9 = (spvTranspose(spvWorkaroundRowMajor(_13.MVPColMajor)) * 2.0) * Position; + vec4 c10 = Position * (spvTranspose(_13.MVPRowMajor) * 2.0); + vec4 c11 = Position * (spvTranspose(spvWorkaroundRowMajor(_13.MVPColMajor)) * 2.0); gl_Position = ((((((((((c0 + c1) + c2) + c3) + c4) + c5) + c6) + c7) + c8) + c9) + c10) + c11; } diff --git a/third_party/spirv-cross/reference/shaders/vert/no-contraction.vert b/third_party/spirv-cross/reference/shaders/vert/no-contraction.vert new file mode 100644 index 0000000000..83e392c6cc --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vert/no-contraction.vert @@ -0,0 +1,24 @@ +#version 450 + +layout(location = 0) in vec4 vA; +layout(location = 1) in vec4 vB; +layout(location = 2) in vec4 vC; + +void main() +{ + precise vec4 _15 = vA * vB; + vec4 mul = _15; + precise vec4 _19 = vA + vB; + vec4 add = _19; + precise vec4 _23 = vA - vB; + vec4 sub = _23; + precise vec4 _27 = vA * vB; + precise vec4 _30 = _27 + vC; + vec4 mad = _30; + precise vec4 _34 = mul + add; + precise vec4 _36 = _34 + sub; + precise vec4 _38 = _36 + mad; + vec4 summed = _38; + gl_Position = summed; +} + diff --git a/third_party/spirv-cross/reference/shaders/vert/read-from-row-major-array.vert b/third_party/spirv-cross/reference/shaders/vert/read-from-row-major-array.vert index 3b77687f0c..b7e66c5468 100644 --- a/third_party/spirv-cross/reference/shaders/vert/read-from-row-major-array.vert +++ b/third_party/spirv-cross/reference/shaders/vert/read-from-row-major-array.vert @@ -8,7 +8,7 @@ layout(binding = 0, std140) uniform Block layout(location = 0) in vec4 a_position; layout(location = 0) out mediump float v_vtxResult; -mat2x3 SPIRV_Cross_workaround_load_row_major(mat2x3 wrap) { return wrap; } +mat2x3 spvWorkaroundRowMajor(mat2x3 wrap) { return wrap; } mediump float compare_float(float a, float b) { @@ -39,7 +39,7 @@ void main() { gl_Position = a_position; mediump float result = 1.0; - mat2x3 param = SPIRV_Cross_workaround_load_row_major(_104.var[0][0]); + mat2x3 param = spvWorkaroundRowMajor(_104.var[0][0]); mat2x3 param_1 = mat2x3(vec3(2.0, 6.0, -6.0), vec3(0.0, 5.0, 5.0)); result *= compare_mat2x3(param, param_1); v_vtxResult = result; diff --git a/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-decorations.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-decorations.nocompat.vk.comp.vk new file mode 100644 index 0000000000..5b3cf49e7a --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/comp/buffer-reference-decorations.nocompat.vk.comp.vk @@ -0,0 +1,35 @@ +#version 450 +#extension GL_EXT_buffer_reference : require +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +layout(buffer_reference) buffer RO; +layout(buffer_reference) buffer RW; +layout(buffer_reference) buffer WO; +layout(buffer_reference, std430) readonly buffer RO +{ + vec4 v[]; +}; + +layout(buffer_reference, std430) restrict buffer RW +{ + vec4 v[]; +}; + +layout(buffer_reference, std430) coherent writeonly buffer WO +{ + vec4 v[]; +}; + +layout(push_constant, std430) uniform Registers +{ + RO ro; + RW rw; + WO wo; +} registers; + +void main() +{ + registers.rw.v[gl_GlobalInvocationID.x] = registers.ro.v[gl_GlobalInvocationID.x]; + registers.wo.v[gl_GlobalInvocationID.x] = registers.ro.v[gl_GlobalInvocationID.x]; +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag b/third_party/spirv-cross/reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag index af64fb87aa..716e283baf 100644 --- a/third_party/spirv-cross/reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag +++ b/third_party/spirv-cross/reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag @@ -9,7 +9,7 @@ layout(location = 0) out float FragColor; float samp2(mediump sampler2DShadow SPIRV_Cross_Combinedts) { - return texture(SPIRV_Cross_Combinedts, vec3(vec3(1.0).xy, vec3(1.0).z)); + return texture(SPIRV_Cross_Combinedts, vec3(vec3(1.0).xy, 1.0)); } float samp3(mediump sampler2D SPIRV_Cross_Combinedts) diff --git a/third_party/spirv-cross/reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag.vk b/third_party/spirv-cross/reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag.vk index f475ae53a9..5ba3bdf35c 100644 --- a/third_party/spirv-cross/reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag.vk +++ b/third_party/spirv-cross/reference/shaders/vulkan/frag/combined-texture-sampler-shadow.vk.frag.vk @@ -10,7 +10,7 @@ layout(location = 0) out float FragColor; float samp2(mediump texture2D t, mediump samplerShadow s) { - return texture(sampler2DShadow(t, s), vec3(vec3(1.0).xy, vec3(1.0).z)); + return texture(sampler2DShadow(t, s), vec3(vec3(1.0).xy, 1.0)); } float samp3(mediump texture2D t, mediump sampler s) diff --git a/third_party/spirv-cross/reference/shaders/vulkan/frag/nonuniform-qualifier.vk.nocompat.frag.vk b/third_party/spirv-cross/reference/shaders/vulkan/frag/nonuniform-qualifier.vk.nocompat.frag.vk index 703c5fd8fa..bd46cb1f26 100644 --- a/third_party/spirv-cross/reference/shaders/vulkan/frag/nonuniform-qualifier.vk.nocompat.frag.vk +++ b/third_party/spirv-cross/reference/shaders/vulkan/frag/nonuniform-qualifier.vk.nocompat.frag.vk @@ -1,19 +1,24 @@ #version 450 #extension GL_EXT_nonuniform_qualifier : require +#extension GL_EXT_samplerless_texture_functions : require layout(set = 0, binding = 2, std140) uniform UBO { vec4 v[64]; } ubos[]; -layout(set = 0, binding = 3, std430) readonly buffer SSBO +layout(set = 0, binding = 3, std430) buffer SSBO { + uint counter; vec4 v[]; } ssbos[]; layout(set = 0, binding = 0) uniform texture2D uSamplers[]; layout(set = 0, binding = 1) uniform sampler uSamps[]; layout(set = 0, binding = 4) uniform sampler2D uCombinedSamplers[]; +layout(set = 0, binding = 0) uniform texture2DMS uSamplersMS[]; +layout(set = 0, binding = 5, r32f) uniform image2D uImages[]; +layout(set = 0, binding = 5, r32ui) uniform uimage2D uImagesU32[]; layout(location = 0) flat in int vIndex; layout(location = 0) out vec4 FragColor; @@ -22,16 +27,42 @@ layout(location = 1) in vec2 vUV; void main() { int i = vIndex; - int _23 = i + 10; - int _34 = i + 40; - FragColor = texture(sampler2D(uSamplers[nonuniformEXT(_23)], uSamps[nonuniformEXT(_34)]), vUV); - int _50 = i + 10; - FragColor = texture(uCombinedSamplers[nonuniformEXT(_50)], vUV); - int _66 = i + 20; - int _70 = i + 40; - FragColor += ubos[nonuniformEXT(_66)].v[_70]; - int _84 = i + 50; + FragColor = texture(nonuniformEXT(sampler2D(uSamplers[i + 10], uSamps[i + 40])), vUV); + int _49 = i + 10; + FragColor = texture(uCombinedSamplers[nonuniformEXT(_49)], vUV); + int _65 = i + 20; + int _69 = i + 40; + FragColor += ubos[nonuniformEXT(_65)].v[_69]; + int _83 = i + 50; int _88 = i + 60; - FragColor += ssbos[nonuniformEXT(_84)].v[_88]; + FragColor += ssbos[nonuniformEXT(_83)].v[_88]; + int _96 = i + 60; + int _100 = i + 70; + ssbos[nonuniformEXT(_96)].v[_100] = vec4(20.0); + int _106 = i + 10; + FragColor = texelFetch(uSamplers[nonuniformEXT(_106)], ivec2(vUV), 0); + int _116 = i + 100; + uint _122 = atomicAdd(ssbos[_116].counter, 100u); + vec2 queried = textureQueryLod(nonuniformEXT(sampler2D(uSamplers[i + 10], uSamps[i + 40])), vUV); + int _139 = i + 10; + queried += textureQueryLod(uCombinedSamplers[nonuniformEXT(_139)], vUV); + vec2 _149 = FragColor.xy + queried; + FragColor = vec4(_149.x, _149.y, FragColor.z, FragColor.w); + int _154 = i + 20; + FragColor.x += float(textureQueryLevels(uSamplers[nonuniformEXT(_154)])); + int _170 = i + 20; + FragColor.y += float(textureSamples(uSamplersMS[nonuniformEXT(_170)])); + int _182 = i + 20; + vec2 _189 = FragColor.xy + vec2(textureSize(uSamplers[nonuniformEXT(_182)], 0)); + FragColor = vec4(_189.x, _189.y, FragColor.z, FragColor.w); + int _198 = i + 50; + FragColor += imageLoad(uImages[nonuniformEXT(_198)], ivec2(vUV)); + int _209 = i + 20; + vec2 _216 = FragColor.xy + vec2(imageSize(uImages[nonuniformEXT(_209)])); + FragColor = vec4(_216.x, _216.y, FragColor.z, FragColor.w); + int _221 = i + 60; + imageStore(uImages[nonuniformEXT(_221)], ivec2(vUV), vec4(50.0)); + int _234 = i + 70; + uint _242 = imageAtomicAdd(uImagesU32[nonuniformEXT(_234)], ivec2(vUV), 40u); } diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rahit/terminators.khr.spv14.nocompat.vk.rahit.vk b/third_party/spirv-cross/reference/shaders/vulkan/rahit/terminators.khr.spv14.nocompat.vk.rahit.vk new file mode 100644 index 0000000000..4cb6bf8d8f --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rahit/terminators.khr.spv14.nocompat.vk.rahit.vk @@ -0,0 +1,22 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT float payload; + +void in_func() +{ + if (payload > 0.0) + { + ignoreIntersectionEXT; + } + else + { + terminateRayEXT; + } +} + +void main() +{ + in_func(); +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rahit/terminators.nocompat.vk.rahit.vk b/third_party/spirv-cross/reference/shaders/vulkan/rahit/terminators.nocompat.vk.rahit.vk new file mode 100644 index 0000000000..cee09bc0ea --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rahit/terminators.nocompat.vk.rahit.vk @@ -0,0 +1,22 @@ +#version 460 +#extension GL_NV_ray_tracing : require + +rayPayloadInNV float payload; + +void in_func() +{ + if (payload > 0.0) + { + ignoreIntersectionNV(); + } + else + { + terminateRayNV(); + } +} + +void main() +{ + in_func(); +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rcall/incoming-callable.khr.spv14.nocompat.vk.rcall.vk b/third_party/spirv-cross/reference/shaders/vulkan/rcall/incoming-callable.khr.spv14.nocompat.vk.rcall.vk new file mode 100644 index 0000000000..5adfac164f --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rcall/incoming-callable.khr.spv14.nocompat.vk.rcall.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) callableDataInEXT float c; + +void main() +{ + executeCallableEXT(10u, 0); +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rchit/hit_attribute_block.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/shaders/vulkan/rchit/hit_attribute_block.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..b6c1876d31 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rchit/hit_attribute_block.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,24 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +struct Foo +{ + float a; + float b; +}; + +struct Foo2 +{ + float a; + float b; +}; + +layout(location = 0) rayPayloadInEXT Foo payload; +hitAttributeEXT Foo2 hit; + +void main() +{ + payload.a = hit.a; + payload.b = hit.b; +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rchit/hit_attribute_block_in_function.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/shaders/vulkan/rchit/hit_attribute_block_in_function.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..56e8ff4aa3 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rchit/hit_attribute_block_in_function.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,29 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +struct Foo +{ + float a; + float b; +}; + +struct Foo2 +{ + float a; + float b; +}; + +layout(location = 0) rayPayloadInEXT Foo payload; +hitAttributeEXT Foo2 hit; + +void in_function() +{ + payload.a = hit.a; + payload.b = hit.b; +} + +void main() +{ + in_function(); +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rchit/hit_attribute_plain.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/shaders/vulkan/rchit/hit_attribute_plain.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..eeccd3bb09 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rchit/hit_attribute_plain.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,11 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT vec2 payload; +hitAttributeEXT vec2 hit; + +void main() +{ + payload = hit; +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rchit/hit_attribute_struct.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/shaders/vulkan/rchit/hit_attribute_struct.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..a51e6b088f --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rchit/hit_attribute_struct.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,17 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +struct Foo +{ + float a; + float b; +}; + +layout(location = 0) rayPayloadInEXT Foo payload; +hitAttributeEXT Foo hit; + +void main() +{ + payload = hit; +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rchit/hit_kind.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/shaders/vulkan/rchit/hit_kind.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..e4e0103ddb --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rchit/hit_kind.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT uint payload; + +void main() +{ + payload = gl_HitKindEXT; +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rchit/hit_t.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/shaders/vulkan/rchit/hit_t.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..e94e3323c9 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rchit/hit_t.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT float payload; + +void main() +{ + payload = gl_RayTmaxEXT; +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rchit/incoming_ray_flags.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/shaders/vulkan/rchit/incoming_ray_flags.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..a013baa11d --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rchit/incoming_ray_flags.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT uint payload; + +void main() +{ + payload = gl_IncomingRayFlagsEXT; +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rchit/instance_custom_id.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/shaders/vulkan/rchit/instance_custom_id.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..e28af5d252 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rchit/instance_custom_id.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT uint payload; + +void main() +{ + payload = uint(gl_InstanceCustomIndexEXT); +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rchit/instance_id.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/shaders/vulkan/rchit/instance_id.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..0413e0d234 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rchit/instance_id.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT uint payload; + +void main() +{ + payload = uint(gl_InstanceID); +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rchit/object_ray_direction.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/shaders/vulkan/rchit/object_ray_direction.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..237d4790e5 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rchit/object_ray_direction.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT vec3 payload; + +void main() +{ + payload = gl_ObjectRayDirectionEXT; +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rchit/object_ray_origin.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/shaders/vulkan/rchit/object_ray_origin.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..5739ac09ff --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rchit/object_ray_origin.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT vec3 payload; + +void main() +{ + payload = gl_ObjectRayOriginEXT; +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rchit/object_to_world.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/shaders/vulkan/rchit/object_to_world.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..7922e1efbf --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rchit/object_to_world.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT vec3 payload; + +void main() +{ + payload = gl_ObjectToWorldEXT * vec4(payload, 1.0); +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rchit/payloads.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/shaders/vulkan/rchit/payloads.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..e896816ec3 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rchit/payloads.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,20 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +struct Payload +{ + vec4 a; +}; + +layout(location = 0) rayPayloadInEXT Payload payload; + +void write_incoming_payload_in_function() +{ + payload.a = vec4(10.0); +} + +void main() +{ + write_incoming_payload_in_function(); +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rchit/primitive_id.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/shaders/vulkan/rchit/primitive_id.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..667c015e8d --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rchit/primitive_id.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT uint payload; + +void main() +{ + payload = uint(gl_PrimitiveID); +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rchit/ray_tmax.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/shaders/vulkan/rchit/ray_tmax.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..e94e3323c9 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rchit/ray_tmax.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT float payload; + +void main() +{ + payload = gl_RayTmaxEXT; +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rchit/ray_tmin.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/shaders/vulkan/rchit/ray_tmin.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..04b8954950 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rchit/ray_tmin.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT float payload; + +void main() +{ + payload = gl_RayTminEXT; +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rchit/ray_tracing.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/shaders/vulkan/rchit/ray_tracing.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..05af948b37 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rchit/ray_tracing.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT float payload; + +void main() +{ + payload = 1.0 + float(gl_InstanceID); +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rchit/world_ray_direction.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/shaders/vulkan/rchit/world_ray_direction.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..68ba2bafa5 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rchit/world_ray_direction.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT vec3 payload; + +void main() +{ + payload = gl_WorldRayDirectionEXT; +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rchit/world_ray_origin.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/shaders/vulkan/rchit/world_ray_origin.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..a5c6766e05 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rchit/world_ray_origin.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT vec3 payload; + +void main() +{ + payload = gl_WorldRayOriginEXT; +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rchit/world_to_object.khr.spv14.nocompat.vk.rchit.vk b/third_party/spirv-cross/reference/shaders/vulkan/rchit/world_to_object.khr.spv14.nocompat.vk.rchit.vk new file mode 100644 index 0000000000..309ca4c6f1 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rchit/world_to_object.khr.spv14.nocompat.vk.rchit.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT vec3 payload; + +void main() +{ + payload = gl_WorldToObjectEXT * vec4(payload, 1.0); +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rgen/convert-u-to-as.spv14.vk.nocompat.rgen.vk b/third_party/spirv-cross/reference/shaders/vulkan/rgen/convert-u-to-as.spv14.vk.nocompat.rgen.vk new file mode 100644 index 0000000000..d131b0aa80 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rgen/convert-u-to-as.spv14.vk.nocompat.rgen.vk @@ -0,0 +1,17 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(push_constant, std430) uniform Registers +{ + uvec2 ptr; +} _19; + +layout(location = 0) rayPayloadEXT vec4 payload; + +void main() +{ + vec3 origin = vec3(0.0); + vec3 direction = vec3(0.0, 0.0, -1.0); + traceRayEXT(accelerationStructureEXT(_19.ptr), 1u, 255u, 0u, 0u, 0u, origin, 0.0, direction, 100.0, 0); +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rgen/execute_callable.nocompat.khr.spv14.vk.rgen.vk b/third_party/spirv-cross/reference/shaders/vulkan/rgen/execute_callable.nocompat.khr.spv14.vk.rgen.vk new file mode 100644 index 0000000000..8bb3d0070b --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rgen/execute_callable.nocompat.khr.spv14.vk.rgen.vk @@ -0,0 +1,17 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(set = 0, binding = 0) uniform accelerationStructureEXT as; +layout(location = 0) rayPayloadEXT vec4 payload; +layout(location = 1) callableDataEXT float blend; +layout(set = 0, binding = 1, rgba32f) uniform writeonly image2D image; + +void main() +{ + vec3 origin = vec3(0.0); + vec3 direction = vec3(0.0, 0.0, -1.0); + traceRayEXT(as, 1u, 255u, 0u, 0u, 0u, origin, 0.0, direction, 100.0, 0); + executeCallableEXT(0u, 1); + imageStore(image, ivec2(gl_LaunchIDEXT.xy), payload + vec4(blend)); +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rgen/launch_id.khr.spv14.nocompat.vk.rgen.vk b/third_party/spirv-cross/reference/shaders/vulkan/rgen/launch_id.khr.spv14.nocompat.vk.rgen.vk new file mode 100644 index 0000000000..1614c49626 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rgen/launch_id.khr.spv14.nocompat.vk.rgen.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(set = 0, binding = 0) uniform writeonly image2D uImage; + +void main() +{ + imageStore(uImage, ivec2(gl_LaunchIDEXT.xy), vec4(1.0)); +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rgen/launch_size.khr.spv14.nocompat.vk.rgen.vk b/third_party/spirv-cross/reference/shaders/vulkan/rgen/launch_size.khr.spv14.nocompat.vk.rgen.vk new file mode 100644 index 0000000000..240e93daa4 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rgen/launch_size.khr.spv14.nocompat.vk.rgen.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(set = 0, binding = 0) uniform writeonly image2D uImage; + +void main() +{ + imageStore(uImage, ivec2(gl_LaunchSizeEXT.xy) - ivec2(1), vec4(1.0)); +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rgen/payloads.khr.spv14.nocompat.vk.rgen.vk b/third_party/spirv-cross/reference/shaders/vulkan/rgen/payloads.khr.spv14.nocompat.vk.rgen.vk new file mode 100644 index 0000000000..7885f4f3d3 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rgen/payloads.khr.spv14.nocompat.vk.rgen.vk @@ -0,0 +1,47 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +struct Payload +{ + float a; + float b; +}; + +struct Block +{ + float a; + float b; + Payload c; + Payload d; +}; + +layout(set = 0, binding = 1) uniform accelerationStructureEXT as; +layout(location = 0) rayPayloadEXT Payload payload2; +layout(location = 1) rayPayloadEXT float payload1; +layout(location = 2) rayPayloadEXT Block _71; +layout(set = 0, binding = 0, rgba8) uniform writeonly image2D image; + +vec4 trace_in_function() +{ + vec4 result = vec4(0.0); + vec3 origin = vec3(1.0, 0.0, 0.0); + vec3 direction = vec3(0.0, 1.0, 0.0); + traceRayEXT(as, 0u, 255u, 0u, 1u, 0u, origin, 0.0, direction, 1000.0, 0); + result += vec4(payload2.a); + result += vec4(payload2.b); + return result; +} + +void main() +{ + vec3 origin = vec3(1.0, 0.0, 0.0); + vec3 direction = vec3(0.0, 1.0, 0.0); + traceRayEXT(as, 0u, 255u, 0u, 1u, 0u, origin, 0.0, direction, 1000.0, 1); + vec4 result = vec4(payload1); + vec4 _62 = trace_in_function(); + result += _62; + traceRayEXT(as, 0u, 255u, 0u, 1u, 0u, origin, 0.0, direction, 1000.0, 2); + result += vec4(((((_71.a + _71.b) + _71.c.a) + _71.c.b) + _71.d.a) + _71.d.b); + imageStore(image, ivec2(gl_LaunchIDEXT.xy), result); +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rgen/pure_call.khr.spv14.nocompat.vk.rgen.vk b/third_party/spirv-cross/reference/shaders/vulkan/rgen/pure_call.khr.spv14.nocompat.vk.rgen.vk new file mode 100644 index 0000000000..71e04d670b --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rgen/pure_call.khr.spv14.nocompat.vk.rgen.vk @@ -0,0 +1,21 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(set = 0, binding = 1) uniform accelerationStructureEXT as; +layout(location = 0) rayPayloadEXT float payload; + +float pure_call(vec2 launchID, vec2 launchSize) +{ + vec3 origin = vec3(launchID.x / launchSize.x, launchID.y / launchSize.y, 1.0); + vec3 direction = vec3(0.0, 0.0, -1.0); + traceRayEXT(as, 0u, 255u, 0u, 1u, 0u, origin, 0.0, direction, 1000.0, 0); + return 0.0; +} + +void main() +{ + vec2 param = vec2(gl_LaunchIDEXT.xy); + vec2 param_1 = vec2(gl_LaunchSizeEXT.xy); + float _64 = pure_call(param, param_1); +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rgen/ray_tracing.khr.spv14.nocompat.vk.rgen.vk b/third_party/spirv-cross/reference/shaders/vulkan/rgen/ray_tracing.khr.spv14.nocompat.vk.rgen.vk new file mode 100644 index 0000000000..67deac226d --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rgen/ray_tracing.khr.spv14.nocompat.vk.rgen.vk @@ -0,0 +1,17 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(set = 0, binding = 1) uniform accelerationStructureEXT as; +layout(location = 0) rayPayloadEXT float payload; +layout(set = 0, binding = 0, rgba8) uniform writeonly image2D image; + +void main() +{ + vec4 col = vec4(0.0, 0.0, 0.0, 1.0); + vec3 origin = vec3(float(gl_LaunchIDEXT.x) / float(gl_LaunchSizeEXT.x), float(gl_LaunchIDEXT.y) / float(gl_LaunchSizeEXT.y), 1.0); + vec3 direction = vec3(0.0, 0.0, -1.0); + traceRayEXT(as, 0u, 255u, 0u, 1u, 0u, origin, 0.0, direction, 1000.0, 0); + col.y = payload; + imageStore(image, ivec2(gl_LaunchIDEXT.xy), col); +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rgen/shader_record_buffer.khr.spv14.nocompat.vk.rgen.vk b/third_party/spirv-cross/reference/shaders/vulkan/rgen/shader_record_buffer.khr.spv14.nocompat.vk.rgen.vk new file mode 100644 index 0000000000..3056e8ad28 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rgen/shader_record_buffer.khr.spv14.nocompat.vk.rgen.vk @@ -0,0 +1,17 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(shaderRecordEXT, std430) buffer sbt +{ + vec3 direction; + float tmax; +} _20; + +layout(set = 0, binding = 0) uniform accelerationStructureEXT as; +layout(location = 0) rayPayloadEXT float payload; + +void main() +{ + traceRayEXT(as, 0u, 255u, 0u, 1u, 0u, vec3(0.0), 0.0, _20.direction, _20.tmax, 0); +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rint/report-intersection.khr.spv14.nocompat.vk.rint.vk b/third_party/spirv-cross/reference/shaders/vulkan/rint/report-intersection.khr.spv14.nocompat.vk.rint.vk new file mode 100644 index 0000000000..761609a812 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rint/report-intersection.khr.spv14.nocompat.vk.rint.vk @@ -0,0 +1,13 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +void in_func() +{ + bool _13 = reportIntersectionEXT(0.5, 10u); +} + +void main() +{ + in_func(); +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rint/report-intersection.nocompat.vk.rint.vk b/third_party/spirv-cross/reference/shaders/vulkan/rint/report-intersection.nocompat.vk.rint.vk new file mode 100644 index 0000000000..c99b78495a --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rint/report-intersection.nocompat.vk.rint.vk @@ -0,0 +1,13 @@ +#version 460 +#extension GL_NV_ray_tracing : require + +void in_func() +{ + bool _13 = reportIntersectionNV(0.5, 10u); +} + +void main() +{ + in_func(); +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rmiss/ray_tracing.khr.spv14.nocompat.vk.rmiss.vk b/third_party/spirv-cross/reference/shaders/vulkan/rmiss/ray_tracing.khr.spv14.nocompat.vk.rmiss.vk new file mode 100644 index 0000000000..c055a26814 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rmiss/ray_tracing.khr.spv14.nocompat.vk.rmiss.vk @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT float payload; + +void main() +{ + payload = 0.0; +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/rmiss/ray_tracing_trace_incoming.khr.spv14.nocompat.vk.rmiss.vk b/third_party/spirv-cross/reference/shaders/vulkan/rmiss/ray_tracing_trace_incoming.khr.spv14.nocompat.vk.rmiss.vk new file mode 100644 index 0000000000..696c998c27 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/vulkan/rmiss/ray_tracing_trace_incoming.khr.spv14.nocompat.vk.rmiss.vk @@ -0,0 +1,13 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(set = 0, binding = 0) uniform accelerationStructureEXT as; +layout(location = 0) rayPayloadInEXT float p; + +void main() +{ + vec3 origin = vec3(float(gl_LaunchIDEXT.x) / float(gl_LaunchSizeEXT.x), float(gl_LaunchIDEXT.y) / float(gl_LaunchSizeEXT.y), 1.0); + vec3 direction = vec3(0.0, 0.0, -1.0); + traceRayEXT(as, 0u, 255u, 0u, 1u, 0u, origin, 0.0, direction, 1000.0, 0); +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/vert/small-storage.vk.vert b/third_party/spirv-cross/reference/shaders/vulkan/vert/small-storage.vk.vert index b3aafc8d8c..610618d5b9 100644 --- a/third_party/spirv-cross/reference/shaders/vulkan/vert/small-storage.vk.vert +++ b/third_party/spirv-cross/reference/shaders/vulkan/vert/small-storage.vk.vert @@ -1,6 +1,8 @@ #version 450 #if defined(GL_AMD_gpu_shader_int16) #extension GL_AMD_gpu_shader_int16 : require +#elif defined(GL_NV_gpu_shader5) +#extension GL_NV_gpu_shader5 : require #else #error No extension available for Int16. #endif diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/asm/comp/eliminate-globals-not-in-entry-point.noeliminate.spv14.asm.comp b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/comp/eliminate-globals-not-in-entry-point.noeliminate.spv14.asm.comp new file mode 100644 index 0000000000..73f3ceee1a --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/comp/eliminate-globals-not-in-entry-point.noeliminate.spv14.asm.comp @@ -0,0 +1,59 @@ +; SPIR-V +; Version: 1.5 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 26 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + ;OpEntryPoint GLCompute %main "main" %Samp %ubo %ssbo %v %w + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 64 1 1 + OpSource GLSL 450 + OpName %main "main" + OpName %Samp "Samp" + OpName %UBO "UBO" + OpMemberName %UBO 0 "v" + OpName %ubo "ubo" + OpName %SSBO "SSBO" + OpMemberName %SSBO 0 "v" + OpName %ssbo "ssbo" + OpName %v "v" + OpName %w "w" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %Samp DescriptorSet 0 + OpDecorate %Samp Binding 0 + OpMemberDecorate %UBO 0 Offset 0 + OpDecorate %UBO Block + OpDecorate %ubo DescriptorSet 0 + OpDecorate %ubo Binding 1 + OpMemberDecorate %SSBO 0 Offset 0 + OpDecorate %SSBO Block + OpDecorate %ssbo DescriptorSet 0 + OpDecorate %ssbo Binding 2 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 + %uint_64 = OpConstant %uint 64 + %uint_1 = OpConstant %uint 1 +%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_64 %uint_1 %uint_1 + %float = OpTypeFloat 32 + %12 = OpTypeImage %float 2D 0 0 0 1 Unknown + %13 = OpTypeSampledImage %12 +%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 + %Samp = OpVariable %_ptr_UniformConstant_13 UniformConstant + %UBO = OpTypeStruct %float +%_ptr_Uniform_UBO = OpTypePointer Uniform %UBO + %ubo = OpVariable %_ptr_Uniform_UBO Uniform + %SSBO = OpTypeStruct %float +%_ptr_StorageBuffer_SSBO = OpTypePointer StorageBuffer %SSBO + %ssbo = OpVariable %_ptr_StorageBuffer_SSBO StorageBuffer +%_ptr_Private_float = OpTypePointer Private %float + %v = OpVariable %_ptr_Private_float Private +%_ptr_Workgroup_float = OpTypePointer Workgroup %float + %w = OpVariable %_ptr_Workgroup_float Workgroup + %main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.invalid.nofxc.asm.comp b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.nofxc.asm.comp similarity index 95% rename from third_party/spirv-cross/shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.invalid.nofxc.asm.comp rename to third_party/spirv-cross/shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.nofxc.asm.comp index edb1a05e54..db9a8490df 100644 --- a/third_party/spirv-cross/shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.invalid.nofxc.asm.comp +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/comp/storage-buffer-basic.nofxc.asm.comp @@ -4,9 +4,9 @@ ; Bound: 31 ; Schema: 0 OpCapability Shader - OpCapability VariablePointers + ;OpCapability VariablePointers OpExtension "SPV_KHR_storage_buffer_storage_class" - OpExtension "SPV_KHR_variable_pointers" + ;OpExtension "SPV_KHR_variable_pointers" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %22 "main" %gl_WorkGroupID OpSource OpenCL_C 120 diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/asm/frag/nonuniform-bracket-handling-2.nonuniformresource.sm51.asm.frag b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/frag/nonuniform-bracket-handling-2.nonuniformresource.sm51.asm.frag index ea85ed0b96..72f6d9d86e 100644 --- a/third_party/spirv-cross/shaders-hlsl-no-opt/asm/frag/nonuniform-bracket-handling-2.nonuniformresource.sm51.asm.frag +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/frag/nonuniform-bracket-handling-2.nonuniformresource.sm51.asm.frag @@ -30,14 +30,14 @@ OpMemberDecorate %SSBO 0 NonWritable OpMemberDecorate %SSBO 0 Offset 0 OpDecorate %SSBO BufferBlock - OpDecorate %_ DescriptorSet 0 + OpDecorate %_ DescriptorSet 2 OpDecorate %_ Binding 0 OpDecorate %26 NonUniform OpDecorate %28 NonUniform OpDecorate %29 NonUniform OpDecorate %vUV Location 0 OpDecorate %uSampler DescriptorSet 1 - OpDecorate %uSampler Binding 0 + OpDecorate %uSampler Binding 1 OpDecorate %38 NonUniform OpDecorate %gl_FragCoord BuiltIn FragCoord %void = OpTypeVoid diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/asm/frag/nonuniform-ssbo.sm51.nonuniformresource.asm.frag b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/frag/nonuniform-ssbo.sm51.nonuniformresource.asm.frag new file mode 100644 index 0000000000..c5428a8bb9 --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/frag/nonuniform-ssbo.sm51.nonuniformresource.asm.frag @@ -0,0 +1,99 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 59 +; Schema: 0 + OpCapability Shader + OpCapability ShaderNonUniform + OpCapability RuntimeDescriptorArray + OpCapability StorageBufferArrayNonUniformIndexing + OpExtension "SPV_EXT_descriptor_indexing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %vIndex %FragColor + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpSourceExtension "GL_EXT_nonuniform_qualifier" + OpSourceExtension "GL_EXT_samplerless_texture_functions" + OpName %main "main" + OpName %i "i" + OpName %vIndex "vIndex" + OpName %SSBO "SSBO" + OpMemberName %SSBO 0 "counter" + OpMemberName %SSBO 1 "v" + OpName %ssbos "ssbos" + OpName %FragColor "FragColor" + OpDecorate %vIndex Flat + OpDecorate %vIndex Location 0 + OpDecorate %_runtimearr_v4float ArrayStride 16 + OpMemberDecorate %SSBO 0 Offset 0 + OpMemberDecorate %SSBO 1 Offset 16 + OpDecorate %SSBO BufferBlock + OpDecorate %ssbos DescriptorSet 0 + OpDecorate %ssbos Binding 3 + OpDecorate %32 NonUniform + OpDecorate %39 NonUniform + OpDecorate %49 NonUniform + OpDecorate %FragColor Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %int = OpTypeInt 32 1 +%_ptr_Function_int = OpTypePointer Function %int +%_ptr_Input_int = OpTypePointer Input %int + %vIndex = OpVariable %_ptr_Input_int Input + %uint = OpTypeInt 32 0 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_runtimearr_v4float = OpTypeRuntimeArray %v4float + %SSBO = OpTypeStruct %uint %_runtimearr_v4float +%_runtimearr_SSBO = OpTypeRuntimeArray %SSBO +%_ptr_Uniform__runtimearr_SSBO = OpTypePointer Uniform %_runtimearr_SSBO + %ssbos = OpVariable %_ptr_Uniform__runtimearr_SSBO Uniform + %int_60 = OpConstant %int 60 + %int_1 = OpConstant %int 1 + %int_70 = OpConstant %int 70 + %float_20 = OpConstant %float 20 + %30 = OpConstantComposite %v4float %float_20 %float_20 %float_20 %float_20 +%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float + %int_100 = OpConstant %int 100 + %int_0 = OpConstant %int 0 +%_ptr_Uniform_uint = OpTypePointer Uniform %uint + %uint_100 = OpConstant %uint 100 + %uint_1 = OpConstant %uint 1 + %uint_0 = OpConstant %uint 0 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %FragColor = OpVariable %_ptr_Output_v4float Output +%_ptr_Uniform_SSBO = OpTypePointer Uniform %SSBO + %uint_2 = OpConstant %uint 2 +%_ptr_Output_float = OpTypePointer Output %float + %main = OpFunction %void None %3 + %5 = OpLabel + %i = OpVariable %_ptr_Function_int Function + %11 = OpLoad %int %vIndex + OpStore %i %11 + %20 = OpLoad %int %i + %22 = OpIAdd %int %20 %int_60 + %23 = OpCopyObject %int %22 + %25 = OpLoad %int %i + %27 = OpIAdd %int %25 %int_70 + %28 = OpCopyObject %int %27 + %32 = OpAccessChain %_ptr_Uniform_v4float %ssbos %23 %int_1 %28 + OpStore %32 %30 + %33 = OpLoad %int %i + %35 = OpIAdd %int %33 %int_100 + %36 = OpCopyObject %int %35 + %39 = OpAccessChain %_ptr_Uniform_uint %ssbos %36 %int_0 + %43 = OpAtomicIAdd %uint %39 %uint_1 %uint_0 %uint_100 + %46 = OpLoad %int %i + %47 = OpCopyObject %int %46 + %49 = OpAccessChain %_ptr_Uniform_SSBO %ssbos %47 + %50 = OpArrayLength %uint %49 1 + %51 = OpBitcast %int %50 + %52 = OpConvertSToF %float %51 + %55 = OpAccessChain %_ptr_Output_float %FragColor %uint_2 + %56 = OpLoad %float %55 + %57 = OpFAdd %float %56 %52 + %58 = OpAccessChain %_ptr_Output_float %FragColor %uint_2 + OpStore %58 %57 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/asm/frag/only-initializer-frag-depth.asm.frag b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/frag/only-initializer-frag-depth.asm.frag new file mode 100644 index 0000000000..17aab1d8f7 --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/frag/only-initializer-frag-depth.asm.frag @@ -0,0 +1,25 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 10 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %gl_FragDepth + OpExecutionMode %main OriginUpperLeft + OpExecutionMode %main DepthReplacing + OpSource GLSL 450 + OpName %main "main" + OpName %gl_FragDepth "gl_FragDepth" + OpDecorate %gl_FragDepth BuiltIn FragDepth + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 +%_ptr_Output_float = OpTypePointer Output %float + %float_0_5 = OpConstant %float 0.5 +%gl_FragDepth = OpVariable %_ptr_Output_float Output %float_0_5 + %main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/asm/frag/reserved-function-identifier.asm.frag b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/frag/reserved-function-identifier.asm.frag new file mode 100644 index 0000000000..a5a16f2873 --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/frag/reserved-function-identifier.asm.frag @@ -0,0 +1,60 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 37 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %FragColor + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpName %main "main" + OpName %ACOS_f1_ "mat3" + OpName %a "a" + OpName %ACOS_i1_ "gl_Foo" + OpName %a_0 "a" + OpName %FragColor "FragColor" + OpName %param "param" + OpName %param_0 "param" + OpDecorate %FragColor Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 +%_ptr_Function_float = OpTypePointer Function %float + %8 = OpTypeFunction %float %_ptr_Function_float + %int = OpTypeInt 32 1 +%_ptr_Function_int = OpTypePointer Function %int + %14 = OpTypeFunction %float %_ptr_Function_int + %float_1 = OpConstant %float 1 +%_ptr_Output_float = OpTypePointer Output %float + %FragColor = OpVariable %_ptr_Output_float Output + %float_2 = OpConstant %float 2 + %int_4 = OpConstant %int 4 + %main = OpFunction %void None %3 + %5 = OpLabel + %param = OpVariable %_ptr_Function_float Function + %param_0 = OpVariable %_ptr_Function_int Function + OpStore %param %float_2 + %32 = OpFunctionCall %float %ACOS_f1_ %param + OpStore %param_0 %int_4 + %35 = OpFunctionCall %float %ACOS_i1_ %param_0 + %36 = OpFAdd %float %32 %35 + OpStore %FragColor %36 + OpReturn + OpFunctionEnd + %ACOS_f1_ = OpFunction %float None %8 + %a = OpFunctionParameter %_ptr_Function_float + %11 = OpLabel + %18 = OpLoad %float %a + %20 = OpFAdd %float %18 %float_1 + OpReturnValue %20 + OpFunctionEnd + %ACOS_i1_ = OpFunction %float None %14 + %a_0 = OpFunctionParameter %_ptr_Function_int + %17 = OpLabel + %23 = OpLoad %int %a_0 + %24 = OpConvertSToF %float %23 + %25 = OpFAdd %float %24 %float_1 + OpReturnValue %25 + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/asm/vert/block-struct-initializer.asm.vert b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/vert/block-struct-initializer.asm.vert new file mode 100644 index 0000000000..a431e6a717 --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/vert/block-struct-initializer.asm.vert @@ -0,0 +1,37 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 13 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %_ %foo + OpSource GLSL 450 + OpName %main "main" + OpName %Vert "Vert" + OpMemberName %Vert 0 "a" + OpMemberName %Vert 1 "b" + OpName %_ "" + OpName %Foo "Foo" + OpMemberName %Foo 0 "c" + OpMemberName %Foo 1 "d" + OpName %foo "foo" + OpDecorate %Vert Block + OpDecorate %_ Location 0 + OpDecorate %foo Location 2 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %Vert = OpTypeStruct %float %float +%_ptr_Output_Vert = OpTypePointer Output %Vert + %zero_vert = OpConstantNull %Vert + %_ = OpVariable %_ptr_Output_Vert Output %zero_vert + %Foo = OpTypeStruct %float %float +%_ptr_Output_Foo = OpTypePointer Output %Foo +%zero_foo = OpConstantNull %Foo + %foo = OpVariable %_ptr_Output_Foo Output %zero_foo + %main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/asm/vert/builtin-output-initializer.asm.vert b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/vert/builtin-output-initializer.asm.vert new file mode 100644 index 0000000000..aaa68662e5 --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/vert/builtin-output-initializer.asm.vert @@ -0,0 +1,44 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 20 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %_ + OpSource GLSL 450 + OpName %main "main" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %_ "" + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex + %zero = OpConstantNull %gl_PerVertex + %_ = OpVariable %_ptr_Output_gl_PerVertex Output %zero + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %float_1 = OpConstant %float 1 + %17 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %main = OpFunction %void None %3 + %5 = OpLabel + %19 = OpAccessChain %_ptr_Output_v4float %_ %int_0 + OpStore %19 %17 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/comp/subgroups-boolean.invalid.nofxc.sm60.comp b/third_party/spirv-cross/shaders-hlsl-no-opt/comp/subgroups-boolean.invalid.nofxc.sm60.comp new file mode 100644 index 0000000000..bc182c5292 --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/comp/subgroups-boolean.invalid.nofxc.sm60.comp @@ -0,0 +1,30 @@ +#version 450 +#extension GL_KHR_shader_subgroup_basic : require +#extension GL_KHR_shader_subgroup_ballot : require +#extension GL_KHR_shader_subgroup_vote : require +#extension GL_KHR_shader_subgroup_shuffle : require +#extension GL_KHR_shader_subgroup_shuffle_relative : require +#extension GL_KHR_shader_subgroup_arithmetic : require +#extension GL_KHR_shader_subgroup_clustered : require +#extension GL_KHR_shader_subgroup_quad : require +layout(local_size_x = 30) in; + +layout(std430, binding = 0) buffer SSBO +{ + uint FragColor[]; +}; + +void main() +{ + bool v = gl_GlobalInvocationID.x != 3; + bvec4 v4; + v4.x = subgroupOr(v); + v4.y = subgroupAnd(v); + v4.z = subgroupXor(v); + v4.w = subgroupAllEqual(v); + + uvec4 w = uvec4(v4); + FragColor[gl_GlobalInvocationID.x] = w.x + w.y + w.z + w.w; +} + + diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/comp/subgroups.invalid.nofxc.sm60.comp b/third_party/spirv-cross/shaders-hlsl-no-opt/comp/subgroups.invalid.nofxc.sm60.comp index 81135e2a93..0f29d445c1 100644 --- a/third_party/spirv-cross/shaders-hlsl-no-opt/comp/subgroups.invalid.nofxc.sm60.comp +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/comp/subgroups.invalid.nofxc.sm60.comp @@ -46,12 +46,12 @@ void main() //uint msb = subgroupBallotFindMSB(ballot_value); // shuffle - //uint shuffled = subgroupShuffle(10u, 8u); - //uint shuffled_xor = subgroupShuffleXor(30u, 8u); + uint shuffled = subgroupShuffle(10u, 8u); + uint shuffled_xor = subgroupShuffleXor(30u, 8u); // shuffle relative - //uint shuffled_up = subgroupShuffleUp(20u, 4u); - //uint shuffled_down = subgroupShuffleDown(20u, 4u); + uint shuffled_up = subgroupShuffleUp(20u, 4u); + uint shuffled_down = subgroupShuffleDown(20u, 4u); // vote bool has_all = subgroupAll(true); @@ -72,6 +72,9 @@ void main() uvec4 anded = subgroupAnd(ballot_value); uvec4 ored = subgroupOr(ballot_value); uvec4 xored = subgroupXor(ballot_value); + bvec4 anded_b = subgroupAnd(equal(ballot_value, uvec4(42))); + bvec4 ored_b = subgroupOr(equal(ballot_value, uvec4(42))); + bvec4 xored_b = subgroupXor(equal(ballot_value, uvec4(42))); added = subgroupInclusiveAdd(added); iadded = subgroupInclusiveAdd(iadded); @@ -121,6 +124,10 @@ void main() anded = subgroupClusteredAnd(anded, 4u); ored = subgroupClusteredOr(ored, 4u); xored = subgroupClusteredXor(xored, 4u); + + anded_b = subgroupClusteredAnd(equal(anded, uvec4(2u)), 4u); + ored_b = subgroupClusteredOr(equal(ored, uvec4(3u)), 4u); + xored_b = subgroupClusteredXor(equal(xored, uvec4(4u)), 4u); #endif // quad diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/frag/nonuniform-constructor.sm51.nonuniformresource.frag b/third_party/spirv-cross/shaders-hlsl-no-opt/frag/nonuniform-constructor.sm51.nonuniformresource.frag new file mode 100644 index 0000000000..452aa953a4 --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/frag/nonuniform-constructor.sm51.nonuniformresource.frag @@ -0,0 +1,14 @@ +#version 450 +#extension GL_EXT_nonuniform_qualifier : require + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec2 vUV; +layout(location = 1) flat in int vIndex; + +layout(set = 0, binding = 0) uniform texture2D uTex[]; +layout(set = 1, binding = 0) uniform sampler Immut; + +void main() +{ + FragColor = texture(nonuniformEXT(sampler2D(uTex[vIndex], Immut)), vUV); +} diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/vert/block-io-auto-location-assignment.vert b/third_party/spirv-cross/shaders-hlsl-no-opt/vert/block-io-auto-location-assignment.vert new file mode 100644 index 0000000000..98c39bd5ef --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/vert/block-io-auto-location-assignment.vert @@ -0,0 +1,31 @@ +#version 450 + +struct Bar +{ + float v[2]; + float w; +}; + +layout(location = 0) out V +{ + float a; + float b[2]; + Bar c[2]; + Bar d; +}; + +void main() +{ + a = 1.0; + b[0] = 2.0; + b[1] = 3.0; + c[0].v[0] = 4.0; + c[0].v[1] = 5.0; + c[0].w = 6.0; + c[1].v[0] = 7.0; + c[1].v[1] = 8.0; + c[1].w = 9.0; + d.v[0] = 10.0; + d.v[1] = 11.0; + d.w = 12.0; +} diff --git a/third_party/spirv-cross/shaders-hlsl/frag/nonuniform-qualifier.nonuniformresource.sm51.frag b/third_party/spirv-cross/shaders-hlsl/frag/nonuniform-qualifier.nonuniformresource.sm51.frag index 0aadd14883..4ab82e9f29 100644 --- a/third_party/spirv-cross/shaders-hlsl/frag/nonuniform-qualifier.nonuniformresource.sm51.frag +++ b/third_party/spirv-cross/shaders-hlsl/frag/nonuniform-qualifier.nonuniformresource.sm51.frag @@ -1,28 +1,52 @@ #version 450 #extension GL_EXT_nonuniform_qualifier : require +#extension GL_EXT_samplerless_texture_functions : require layout(set = 0, binding = 0) uniform texture2D uSamplers[]; -layout(set = 1, binding = 0) uniform sampler2D uCombinedSamplers[]; -layout(set = 2, binding = 0) uniform sampler uSamps[]; -layout(location = 0) flat in int vIndex; -layout(location = 1) in vec2 vUV; -layout(location = 0) out vec4 FragColor; +layout(set = 1, binding = 0) uniform texture2DMS uSamplersMS[]; +layout(set = 2, binding = 4) uniform sampler2D uCombinedSamplers[]; +layout(set = 3, binding = 1) uniform sampler uSamps[]; +layout(set = 4, location = 0) flat in int vIndex; +layout(set = 5, location = 1) in vec2 vUV; +layout(set = 6, location = 0) out vec4 FragColor; -layout(set = 3, binding = 0) uniform UBO +layout(r32f, set = 7, binding = 5) uniform image2D uImages[]; +layout(r32ui, set = 8, binding = 5) uniform uimage2D uImagesU32[]; + +layout(set = 9, binding = 2) uniform UBO { vec4 v[64]; } ubos[]; -layout(set = 4, binding = 0) readonly buffer SSBO +layout(set = 10, binding = 3) buffer SSBO { + uint counter; vec4 v[]; } ssbos[]; void main() { int i = vIndex; - FragColor = texture(sampler2D(uSamplers[nonuniformEXT(i + 10)], uSamps[nonuniformEXT(i + 40)]), vUV); + FragColor = texture(nonuniformEXT(sampler2D(uSamplers[i + 10], uSamps[i + 40])), vUV); FragColor = texture(uCombinedSamplers[nonuniformEXT(i + 10)], vUV); FragColor += ubos[nonuniformEXT(i + 20)].v[nonuniformEXT(i + 40)]; FragColor += ssbos[nonuniformEXT(i + 50)].v[nonuniformEXT(i + 60)]; + ssbos[nonuniformEXT(i + 60)].v[nonuniformEXT(i + 70)] = vec4(20.0); + + FragColor = texelFetch(uSamplers[nonuniformEXT(i + 10)], ivec2(vUV), 0); + atomicAdd(ssbos[nonuniformEXT(i + 100)].counter, 100u); + + vec2 queried = textureQueryLod(nonuniformEXT(sampler2D(uSamplers[i + 10], uSamps[i + 40])), vUV); + queried += textureQueryLod(uCombinedSamplers[nonuniformEXT(i + 10)], vUV); + FragColor.xy += queried; + + FragColor.x += float(textureQueryLevels(uSamplers[nonuniformEXT(i + 20)])); + FragColor.y += float(textureSamples(uSamplersMS[nonuniformEXT(i + 20)])); + FragColor.xy += vec2(textureSize(uSamplers[nonuniformEXT(i + 20)], 0)); + + FragColor += imageLoad(uImages[nonuniformEXT(i + 50)], ivec2(vUV)); + FragColor.xy += vec2(imageSize(uImages[nonuniformEXT(i + 20)])); + imageStore(uImages[nonuniformEXT(i + 60)], ivec2(vUV), vec4(50.0)); + + imageAtomicAdd(uImagesU32[nonuniformEXT(i + 70)], ivec2(vUV), 40u); } diff --git a/third_party/spirv-cross/shaders-hlsl/vert/invariant.vert b/third_party/spirv-cross/shaders-hlsl/vert/invariant.vert new file mode 100644 index 0000000000..239b985da1 --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl/vert/invariant.vert @@ -0,0 +1,13 @@ +#version 310 es + +invariant gl_Position; +layout(location = 0) invariant out vec4 vColor; +layout(location = 0) in vec4 vInput0; +layout(location = 1) in vec4 vInput1; +layout(location = 2) in vec4 vInput2; + +void main() +{ + gl_Position = vInput0 + vInput1 * vInput2; + vColor = (vInput0 - vInput1) * vInput2; +} diff --git a/third_party/spirv-cross/shaders-hlsl/vert/no-contraction.vert b/third_party/spirv-cross/shaders-hlsl/vert/no-contraction.vert new file mode 100644 index 0000000000..206fbf0de8 --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl/vert/no-contraction.vert @@ -0,0 +1,15 @@ +#version 450 + +layout(location = 0) in vec4 vA; +layout(location = 1) in vec4 vB; +layout(location = 2) in vec4 vC; + +void main() +{ + precise vec4 mul = vA * vB; + precise vec4 add = vA + vB; + precise vec4 sub = vA - vB; + precise vec4 mad = vA * vB + vC; + precise vec4 summed = mul + add + sub + mad; + gl_Position = summed; +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/eliminate-globals-not-in-entry-point.noeliminate.spv14.asm.comp b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/eliminate-globals-not-in-entry-point.noeliminate.spv14.asm.comp new file mode 100644 index 0000000000..73f3ceee1a --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/eliminate-globals-not-in-entry-point.noeliminate.spv14.asm.comp @@ -0,0 +1,59 @@ +; SPIR-V +; Version: 1.5 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 26 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + ;OpEntryPoint GLCompute %main "main" %Samp %ubo %ssbo %v %w + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 64 1 1 + OpSource GLSL 450 + OpName %main "main" + OpName %Samp "Samp" + OpName %UBO "UBO" + OpMemberName %UBO 0 "v" + OpName %ubo "ubo" + OpName %SSBO "SSBO" + OpMemberName %SSBO 0 "v" + OpName %ssbo "ssbo" + OpName %v "v" + OpName %w "w" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %Samp DescriptorSet 0 + OpDecorate %Samp Binding 0 + OpMemberDecorate %UBO 0 Offset 0 + OpDecorate %UBO Block + OpDecorate %ubo DescriptorSet 0 + OpDecorate %ubo Binding 1 + OpMemberDecorate %SSBO 0 Offset 0 + OpDecorate %SSBO Block + OpDecorate %ssbo DescriptorSet 0 + OpDecorate %ssbo Binding 2 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 + %uint_64 = OpConstant %uint 64 + %uint_1 = OpConstant %uint 1 +%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_64 %uint_1 %uint_1 + %float = OpTypeFloat 32 + %12 = OpTypeImage %float 2D 0 0 0 1 Unknown + %13 = OpTypeSampledImage %12 +%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 + %Samp = OpVariable %_ptr_UniformConstant_13 UniformConstant + %UBO = OpTypeStruct %float +%_ptr_Uniform_UBO = OpTypePointer Uniform %UBO + %ubo = OpVariable %_ptr_Uniform_UBO Uniform + %SSBO = OpTypeStruct %float +%_ptr_StorageBuffer_SSBO = OpTypePointer StorageBuffer %SSBO + %ssbo = OpVariable %_ptr_StorageBuffer_SSBO StorageBuffer +%_ptr_Private_float = OpTypePointer Private %float + %v = OpVariable %_ptr_Private_float Private +%_ptr_Workgroup_float = OpTypePointer Workgroup %float + %w = OpVariable %_ptr_Workgroup_float Workgroup + %main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/fixup-entry-point-identifier.nomain.asm.frag b/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/fixup-entry-point-identifier.nomain.asm.frag new file mode 100644 index 0000000000..2f522f44b5 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/fixup-entry-point-identifier.nomain.asm.frag @@ -0,0 +1,27 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 12 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %foo "_5ma@@in" %FragColor + OpExecutionMode %foo OriginUpperLeft + OpSource GLSL 450 + OpName %foo "FOO" + OpName %FragColor "FragColor" + OpDecorate %FragColor Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %FragColor = OpVariable %_ptr_Output_v4float Output + %float_1 = OpConstant %float 1 + %11 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 + %foo = OpFunction %void None %3 + %5 = OpLabel + OpStore %FragColor %11 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/only-initializer-frag-depth.asm.frag b/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/only-initializer-frag-depth.asm.frag new file mode 100644 index 0000000000..17aab1d8f7 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/only-initializer-frag-depth.asm.frag @@ -0,0 +1,25 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 10 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %gl_FragDepth + OpExecutionMode %main OriginUpperLeft + OpExecutionMode %main DepthReplacing + OpSource GLSL 450 + OpName %main "main" + OpName %gl_FragDepth "gl_FragDepth" + OpDecorate %gl_FragDepth BuiltIn FragDepth + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 +%_ptr_Output_float = OpTypePointer Output %float + %float_0_5 = OpConstant %float 0.5 +%gl_FragDepth = OpVariable %_ptr_Output_float Output %float_0_5 + %main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/reserved-function-identifier.asm.frag b/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/reserved-function-identifier.asm.frag new file mode 100644 index 0000000000..a5a16f2873 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/reserved-function-identifier.asm.frag @@ -0,0 +1,60 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 37 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %FragColor + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpName %main "main" + OpName %ACOS_f1_ "mat3" + OpName %a "a" + OpName %ACOS_i1_ "gl_Foo" + OpName %a_0 "a" + OpName %FragColor "FragColor" + OpName %param "param" + OpName %param_0 "param" + OpDecorate %FragColor Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 +%_ptr_Function_float = OpTypePointer Function %float + %8 = OpTypeFunction %float %_ptr_Function_float + %int = OpTypeInt 32 1 +%_ptr_Function_int = OpTypePointer Function %int + %14 = OpTypeFunction %float %_ptr_Function_int + %float_1 = OpConstant %float 1 +%_ptr_Output_float = OpTypePointer Output %float + %FragColor = OpVariable %_ptr_Output_float Output + %float_2 = OpConstant %float 2 + %int_4 = OpConstant %int 4 + %main = OpFunction %void None %3 + %5 = OpLabel + %param = OpVariable %_ptr_Function_float Function + %param_0 = OpVariable %_ptr_Function_int Function + OpStore %param %float_2 + %32 = OpFunctionCall %float %ACOS_f1_ %param + OpStore %param_0 %int_4 + %35 = OpFunctionCall %float %ACOS_i1_ %param_0 + %36 = OpFAdd %float %32 %35 + OpStore %FragColor %36 + OpReturn + OpFunctionEnd + %ACOS_f1_ = OpFunction %float None %8 + %a = OpFunctionParameter %_ptr_Function_float + %11 = OpLabel + %18 = OpLoad %float %a + %20 = OpFAdd %float %18 %float_1 + OpReturnValue %20 + OpFunctionEnd + %ACOS_i1_ = OpFunction %float None %14 + %a_0 = OpFunctionParameter %_ptr_Function_int + %17 = OpLabel + %23 = OpLoad %int %a_0 + %24 = OpConvertSToF %float %23 + %25 = OpFAdd %float %24 %float_1 + OpReturnValue %25 + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-0.msl2.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-0.msl2.asm.tesc new file mode 100644 index 0000000000..a3d489941c --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-0.msl2.asm.tesc @@ -0,0 +1,85 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 44 +; Schema: 0 + OpCapability Tessellation + OpCapability TessellationPointSize + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %c %gl_InvocationID %p %gl_out + OpExecutionMode %main OutputVertices 4 + OpSource GLSL 450 + OpName %main "main" + OpName %C "C" + OpMemberName %C 0 "v" + OpName %c "c" + OpName %gl_InvocationID "gl_InvocationID" + OpName %P "P" + OpMemberName %P 0 "v" + OpName %p "p" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpDecorate %C Block + OpDecorate %c Location 0 + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpMemberDecorate %P 0 Patch + OpDecorate %P Block + OpDecorate %p Location 1 + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %C = OpTypeStruct %v4float + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 +%_arr_C_uint_4 = OpTypeArray %C %uint_4 +%_ptr_Output__arr_C_uint_4 = OpTypePointer Output %_arr_C_uint_4 + %zero_c = OpConstantNull %_arr_C_uint_4 + %c = OpVariable %_ptr_Output__arr_C_uint_4 Output %zero_c + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %int_0 = OpConstant %int 0 + %float_1 = OpConstant %float 1 + %20 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %P = OpTypeStruct %v4float +%_ptr_Output_P = OpTypePointer Output %P + %zero_p = OpConstantNull %P + %p = OpVariable %_ptr_Output_P Output %zero_p + %float_2 = OpConstant %float 2 + %27 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output + %float_3 = OpConstant %float 3 + %37 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3 + %int_1 = OpConstant %int 1 + %float_4 = OpConstant %float 4 +%_ptr_Output_float = OpTypePointer Output %float + %main = OpFunction %void None %3 + %5 = OpLabel + %17 = OpLoad %int %gl_InvocationID + %22 = OpAccessChain %_ptr_Output_v4float %c %17 %int_0 + OpStore %22 %20 + %28 = OpAccessChain %_ptr_Output_v4float %p %int_0 + OpStore %28 %27 + %38 = OpAccessChain %_ptr_Output_v4float %gl_out %17 %int_0 + OpStore %38 %37 + %43 = OpAccessChain %_ptr_Output_float %gl_out %17 %int_1 + OpStore %43 %float_4 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-0.multi-patch.msl2.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-0.multi-patch.msl2.asm.tesc new file mode 100644 index 0000000000..a3d489941c --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-0.multi-patch.msl2.asm.tesc @@ -0,0 +1,85 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 44 +; Schema: 0 + OpCapability Tessellation + OpCapability TessellationPointSize + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %c %gl_InvocationID %p %gl_out + OpExecutionMode %main OutputVertices 4 + OpSource GLSL 450 + OpName %main "main" + OpName %C "C" + OpMemberName %C 0 "v" + OpName %c "c" + OpName %gl_InvocationID "gl_InvocationID" + OpName %P "P" + OpMemberName %P 0 "v" + OpName %p "p" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpDecorate %C Block + OpDecorate %c Location 0 + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpMemberDecorate %P 0 Patch + OpDecorate %P Block + OpDecorate %p Location 1 + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %C = OpTypeStruct %v4float + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 +%_arr_C_uint_4 = OpTypeArray %C %uint_4 +%_ptr_Output__arr_C_uint_4 = OpTypePointer Output %_arr_C_uint_4 + %zero_c = OpConstantNull %_arr_C_uint_4 + %c = OpVariable %_ptr_Output__arr_C_uint_4 Output %zero_c + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %int_0 = OpConstant %int 0 + %float_1 = OpConstant %float 1 + %20 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %P = OpTypeStruct %v4float +%_ptr_Output_P = OpTypePointer Output %P + %zero_p = OpConstantNull %P + %p = OpVariable %_ptr_Output_P Output %zero_p + %float_2 = OpConstant %float 2 + %27 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output + %float_3 = OpConstant %float 3 + %37 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3 + %int_1 = OpConstant %int 1 + %float_4 = OpConstant %float 4 +%_ptr_Output_float = OpTypePointer Output %float + %main = OpFunction %void None %3 + %5 = OpLabel + %17 = OpLoad %int %gl_InvocationID + %22 = OpAccessChain %_ptr_Output_v4float %c %17 %int_0 + OpStore %22 %20 + %28 = OpAccessChain %_ptr_Output_v4float %p %int_0 + OpStore %28 %27 + %38 = OpAccessChain %_ptr_Output_v4float %gl_out %17 %int_0 + OpStore %38 %37 + %43 = OpAccessChain %_ptr_Output_float %gl_out %17 %int_1 + OpStore %43 %float_4 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-1.msl2.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-1.msl2.asm.tesc new file mode 100644 index 0000000000..a3d489941c --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-1.msl2.asm.tesc @@ -0,0 +1,85 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 44 +; Schema: 0 + OpCapability Tessellation + OpCapability TessellationPointSize + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %c %gl_InvocationID %p %gl_out + OpExecutionMode %main OutputVertices 4 + OpSource GLSL 450 + OpName %main "main" + OpName %C "C" + OpMemberName %C 0 "v" + OpName %c "c" + OpName %gl_InvocationID "gl_InvocationID" + OpName %P "P" + OpMemberName %P 0 "v" + OpName %p "p" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpDecorate %C Block + OpDecorate %c Location 0 + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpMemberDecorate %P 0 Patch + OpDecorate %P Block + OpDecorate %p Location 1 + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %C = OpTypeStruct %v4float + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 +%_arr_C_uint_4 = OpTypeArray %C %uint_4 +%_ptr_Output__arr_C_uint_4 = OpTypePointer Output %_arr_C_uint_4 + %zero_c = OpConstantNull %_arr_C_uint_4 + %c = OpVariable %_ptr_Output__arr_C_uint_4 Output %zero_c + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %int_0 = OpConstant %int 0 + %float_1 = OpConstant %float 1 + %20 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %P = OpTypeStruct %v4float +%_ptr_Output_P = OpTypePointer Output %P + %zero_p = OpConstantNull %P + %p = OpVariable %_ptr_Output_P Output %zero_p + %float_2 = OpConstant %float 2 + %27 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output + %float_3 = OpConstant %float 3 + %37 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3 + %int_1 = OpConstant %int 1 + %float_4 = OpConstant %float 4 +%_ptr_Output_float = OpTypePointer Output %float + %main = OpFunction %void None %3 + %5 = OpLabel + %17 = OpLoad %int %gl_InvocationID + %22 = OpAccessChain %_ptr_Output_v4float %c %17 %int_0 + OpStore %22 %20 + %28 = OpAccessChain %_ptr_Output_v4float %p %int_0 + OpStore %28 %27 + %38 = OpAccessChain %_ptr_Output_v4float %gl_out %17 %int_0 + OpStore %38 %37 + %43 = OpAccessChain %_ptr_Output_float %gl_out %17 %int_1 + OpStore %43 %float_4 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-1.multi-patch.msl2.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-1.multi-patch.msl2.asm.tesc new file mode 100644 index 0000000000..a3d489941c --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers-block.mask-location-1.multi-patch.msl2.asm.tesc @@ -0,0 +1,85 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 44 +; Schema: 0 + OpCapability Tessellation + OpCapability TessellationPointSize + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %c %gl_InvocationID %p %gl_out + OpExecutionMode %main OutputVertices 4 + OpSource GLSL 450 + OpName %main "main" + OpName %C "C" + OpMemberName %C 0 "v" + OpName %c "c" + OpName %gl_InvocationID "gl_InvocationID" + OpName %P "P" + OpMemberName %P 0 "v" + OpName %p "p" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpDecorate %C Block + OpDecorate %c Location 0 + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpMemberDecorate %P 0 Patch + OpDecorate %P Block + OpDecorate %p Location 1 + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %C = OpTypeStruct %v4float + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 +%_arr_C_uint_4 = OpTypeArray %C %uint_4 +%_ptr_Output__arr_C_uint_4 = OpTypePointer Output %_arr_C_uint_4 + %zero_c = OpConstantNull %_arr_C_uint_4 + %c = OpVariable %_ptr_Output__arr_C_uint_4 Output %zero_c + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %int_0 = OpConstant %int 0 + %float_1 = OpConstant %float 1 + %20 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %P = OpTypeStruct %v4float +%_ptr_Output_P = OpTypePointer Output %P + %zero_p = OpConstantNull %P + %p = OpVariable %_ptr_Output_P Output %zero_p + %float_2 = OpConstant %float 2 + %27 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output + %float_3 = OpConstant %float 3 + %37 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3 + %int_1 = OpConstant %int 1 + %float_4 = OpConstant %float 4 +%_ptr_Output_float = OpTypePointer Output %float + %main = OpFunction %void None %3 + %5 = OpLabel + %17 = OpLoad %int %gl_InvocationID + %22 = OpAccessChain %_ptr_Output_v4float %c %17 %int_0 + OpStore %22 %20 + %28 = OpAccessChain %_ptr_Output_v4float %p %int_0 + OpStore %28 %27 + %38 = OpAccessChain %_ptr_Output_v4float %gl_out %17 %int_0 + OpStore %38 %37 + %43 = OpAccessChain %_ptr_Output_float %gl_out %17 %int_1 + OpStore %43 %float_4 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers-block.mask-point-size.msl2.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers-block.mask-point-size.msl2.asm.tesc new file mode 100644 index 0000000000..23424ff7ba --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers-block.mask-point-size.msl2.asm.tesc @@ -0,0 +1,86 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 44 +; Schema: 0 + OpCapability Tessellation + OpCapability TessellationPointSize + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %c %gl_InvocationID %p %gl_out + OpExecutionMode %main OutputVertices 4 + OpSource GLSL 450 + OpName %main "main" + OpName %C "C" + OpMemberName %C 0 "v" + OpName %c "c" + OpName %gl_InvocationID "gl_InvocationID" + OpName %P "P" + OpMemberName %P 0 "v" + OpName %p "p" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpDecorate %C Block + OpDecorate %c Location 0 + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpMemberDecorate %P 0 Patch + OpDecorate %P Block + OpDecorate %p Location 1 + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %C = OpTypeStruct %v4float + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 +%_arr_C_uint_4 = OpTypeArray %C %uint_4 +%_ptr_Output__arr_C_uint_4 = OpTypePointer Output %_arr_C_uint_4 + %zero_c = OpConstantNull %_arr_C_uint_4 + %c = OpVariable %_ptr_Output__arr_C_uint_4 Output %zero_c + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %int_0 = OpConstant %int 0 + %float_1 = OpConstant %float 1 + %20 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %P = OpTypeStruct %v4float +%_ptr_Output_P = OpTypePointer Output %P + %zero_p = OpConstantNull %P + %p = OpVariable %_ptr_Output_P Output %zero_p + %float_2 = OpConstant %float 2 + %27 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 + %zero_gl_out = OpConstantNull %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output %zero_gl_out + %float_3 = OpConstant %float 3 + %37 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3 + %int_1 = OpConstant %int 1 + %float_4 = OpConstant %float 4 +%_ptr_Output_float = OpTypePointer Output %float + %main = OpFunction %void None %3 + %5 = OpLabel + %17 = OpLoad %int %gl_InvocationID + %22 = OpAccessChain %_ptr_Output_v4float %c %17 %int_0 + OpStore %22 %20 + %28 = OpAccessChain %_ptr_Output_v4float %p %int_0 + OpStore %28 %27 + %38 = OpAccessChain %_ptr_Output_v4float %gl_out %17 %int_0 + OpStore %38 %37 + %43 = OpAccessChain %_ptr_Output_float %gl_out %17 %int_1 + OpStore %43 %float_4 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers-block.mask-point-size.multi-patch.msl2.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers-block.mask-point-size.multi-patch.msl2.asm.tesc new file mode 100644 index 0000000000..23424ff7ba --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers-block.mask-point-size.multi-patch.msl2.asm.tesc @@ -0,0 +1,86 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 44 +; Schema: 0 + OpCapability Tessellation + OpCapability TessellationPointSize + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %c %gl_InvocationID %p %gl_out + OpExecutionMode %main OutputVertices 4 + OpSource GLSL 450 + OpName %main "main" + OpName %C "C" + OpMemberName %C 0 "v" + OpName %c "c" + OpName %gl_InvocationID "gl_InvocationID" + OpName %P "P" + OpMemberName %P 0 "v" + OpName %p "p" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpDecorate %C Block + OpDecorate %c Location 0 + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpMemberDecorate %P 0 Patch + OpDecorate %P Block + OpDecorate %p Location 1 + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %C = OpTypeStruct %v4float + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 +%_arr_C_uint_4 = OpTypeArray %C %uint_4 +%_ptr_Output__arr_C_uint_4 = OpTypePointer Output %_arr_C_uint_4 + %zero_c = OpConstantNull %_arr_C_uint_4 + %c = OpVariable %_ptr_Output__arr_C_uint_4 Output %zero_c + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %int_0 = OpConstant %int 0 + %float_1 = OpConstant %float 1 + %20 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %P = OpTypeStruct %v4float +%_ptr_Output_P = OpTypePointer Output %P + %zero_p = OpConstantNull %P + %p = OpVariable %_ptr_Output_P Output %zero_p + %float_2 = OpConstant %float 2 + %27 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 + %zero_gl_out = OpConstantNull %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output %zero_gl_out + %float_3 = OpConstant %float 3 + %37 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3 + %int_1 = OpConstant %int 1 + %float_4 = OpConstant %float 4 +%_ptr_Output_float = OpTypePointer Output %float + %main = OpFunction %void None %3 + %5 = OpLabel + %17 = OpLoad %int %gl_InvocationID + %22 = OpAccessChain %_ptr_Output_v4float %c %17 %int_0 + OpStore %22 %20 + %28 = OpAccessChain %_ptr_Output_v4float %p %int_0 + OpStore %28 %27 + %38 = OpAccessChain %_ptr_Output_v4float %gl_out %17 %int_0 + OpStore %38 %37 + %43 = OpAccessChain %_ptr_Output_float %gl_out %17 %int_1 + OpStore %43 %float_4 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers-block.mask-position.msl2.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers-block.mask-position.msl2.asm.tesc new file mode 100644 index 0000000000..23424ff7ba --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers-block.mask-position.msl2.asm.tesc @@ -0,0 +1,86 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 44 +; Schema: 0 + OpCapability Tessellation + OpCapability TessellationPointSize + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %c %gl_InvocationID %p %gl_out + OpExecutionMode %main OutputVertices 4 + OpSource GLSL 450 + OpName %main "main" + OpName %C "C" + OpMemberName %C 0 "v" + OpName %c "c" + OpName %gl_InvocationID "gl_InvocationID" + OpName %P "P" + OpMemberName %P 0 "v" + OpName %p "p" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpDecorate %C Block + OpDecorate %c Location 0 + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpMemberDecorate %P 0 Patch + OpDecorate %P Block + OpDecorate %p Location 1 + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %C = OpTypeStruct %v4float + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 +%_arr_C_uint_4 = OpTypeArray %C %uint_4 +%_ptr_Output__arr_C_uint_4 = OpTypePointer Output %_arr_C_uint_4 + %zero_c = OpConstantNull %_arr_C_uint_4 + %c = OpVariable %_ptr_Output__arr_C_uint_4 Output %zero_c + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %int_0 = OpConstant %int 0 + %float_1 = OpConstant %float 1 + %20 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %P = OpTypeStruct %v4float +%_ptr_Output_P = OpTypePointer Output %P + %zero_p = OpConstantNull %P + %p = OpVariable %_ptr_Output_P Output %zero_p + %float_2 = OpConstant %float 2 + %27 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 + %zero_gl_out = OpConstantNull %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output %zero_gl_out + %float_3 = OpConstant %float 3 + %37 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3 + %int_1 = OpConstant %int 1 + %float_4 = OpConstant %float 4 +%_ptr_Output_float = OpTypePointer Output %float + %main = OpFunction %void None %3 + %5 = OpLabel + %17 = OpLoad %int %gl_InvocationID + %22 = OpAccessChain %_ptr_Output_v4float %c %17 %int_0 + OpStore %22 %20 + %28 = OpAccessChain %_ptr_Output_v4float %p %int_0 + OpStore %28 %27 + %38 = OpAccessChain %_ptr_Output_v4float %gl_out %17 %int_0 + OpStore %38 %37 + %43 = OpAccessChain %_ptr_Output_float %gl_out %17 %int_1 + OpStore %43 %float_4 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers-block.mask-position.multi-patch.msl2.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers-block.mask-position.multi-patch.msl2.asm.tesc new file mode 100644 index 0000000000..23424ff7ba --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers-block.mask-position.multi-patch.msl2.asm.tesc @@ -0,0 +1,86 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 44 +; Schema: 0 + OpCapability Tessellation + OpCapability TessellationPointSize + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %c %gl_InvocationID %p %gl_out + OpExecutionMode %main OutputVertices 4 + OpSource GLSL 450 + OpName %main "main" + OpName %C "C" + OpMemberName %C 0 "v" + OpName %c "c" + OpName %gl_InvocationID "gl_InvocationID" + OpName %P "P" + OpMemberName %P 0 "v" + OpName %p "p" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpDecorate %C Block + OpDecorate %c Location 0 + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpMemberDecorate %P 0 Patch + OpDecorate %P Block + OpDecorate %p Location 1 + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %C = OpTypeStruct %v4float + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 +%_arr_C_uint_4 = OpTypeArray %C %uint_4 +%_ptr_Output__arr_C_uint_4 = OpTypePointer Output %_arr_C_uint_4 + %zero_c = OpConstantNull %_arr_C_uint_4 + %c = OpVariable %_ptr_Output__arr_C_uint_4 Output %zero_c + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %int_0 = OpConstant %int 0 + %float_1 = OpConstant %float 1 + %20 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %P = OpTypeStruct %v4float +%_ptr_Output_P = OpTypePointer Output %P + %zero_p = OpConstantNull %P + %p = OpVariable %_ptr_Output_P Output %zero_p + %float_2 = OpConstant %float 2 + %27 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 + %zero_gl_out = OpConstantNull %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output %zero_gl_out + %float_3 = OpConstant %float 3 + %37 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3 + %int_1 = OpConstant %int 1 + %float_4 = OpConstant %float 4 +%_ptr_Output_float = OpTypePointer Output %float + %main = OpFunction %void None %3 + %5 = OpLabel + %17 = OpLoad %int %gl_InvocationID + %22 = OpAccessChain %_ptr_Output_v4float %c %17 %int_0 + OpStore %22 %20 + %28 = OpAccessChain %_ptr_Output_v4float %p %int_0 + OpStore %28 %27 + %38 = OpAccessChain %_ptr_Output_v4float %gl_out %17 %int_0 + OpStore %38 %37 + %43 = OpAccessChain %_ptr_Output_float %gl_out %17 %int_1 + OpStore %43 %float_4 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers.mask-location-0.msl2.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers.mask-location-0.msl2.asm.tesc new file mode 100644 index 0000000000..6b616b0416 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers.mask-location-0.msl2.asm.tesc @@ -0,0 +1,76 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 40 +; Schema: 0 + OpCapability Tessellation + OpCapability TessellationPointSize + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %foo %gl_InvocationID %foo_patch %gl_out + OpExecutionMode %main OutputVertices 4 + OpSource GLSL 450 + OpName %main "main" + OpName %foo "foo" + OpName %gl_InvocationID "gl_InvocationID" + OpName %foo_patch "foo_patch" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpDecorate %foo Location 0 + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpDecorate %foo_patch Patch + OpDecorate %foo_patch Location 1 + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 +%_arr_v4float_uint_4 = OpTypeArray %v4float %uint_4 + %zero_foo = OpConstantNull %_arr_v4float_uint_4 +%_ptr_Output__arr_v4float_uint_4 = OpTypePointer Output %_arr_v4float_uint_4 + %foo = OpVariable %_ptr_Output__arr_v4float_uint_4 Output %zero_foo + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %float_1 = OpConstant %float 1 + %18 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %zero_foo_patch = OpConstantNull %v4float + %foo_patch = OpVariable %_ptr_Output_v4float Output %zero_foo_patch + %float_2 = OpConstant %float 2 + %23 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 + %zero_gl_out = OpConstantNull %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output %zero_gl_out + %int_0 = OpConstant %int 0 + %float_3 = OpConstant %float 3 + %33 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3 + %int_1 = OpConstant %int 1 + %float_4 = OpConstant %float 4 +%_ptr_Output_float = OpTypePointer Output %float + %main = OpFunction %void None %3 + %5 = OpLabel + %16 = OpLoad %int %gl_InvocationID + %20 = OpAccessChain %_ptr_Output_v4float %foo %16 + OpStore %20 %18 + OpStore %foo_patch %23 + %34 = OpAccessChain %_ptr_Output_v4float %gl_out %16 %int_0 + OpStore %34 %33 + %39 = OpAccessChain %_ptr_Output_float %gl_out %16 %int_1 + OpStore %39 %float_4 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers.mask-location-0.msl2.multi-patch.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers.mask-location-0.msl2.multi-patch.asm.tesc new file mode 100644 index 0000000000..6b616b0416 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers.mask-location-0.msl2.multi-patch.asm.tesc @@ -0,0 +1,76 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 40 +; Schema: 0 + OpCapability Tessellation + OpCapability TessellationPointSize + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %foo %gl_InvocationID %foo_patch %gl_out + OpExecutionMode %main OutputVertices 4 + OpSource GLSL 450 + OpName %main "main" + OpName %foo "foo" + OpName %gl_InvocationID "gl_InvocationID" + OpName %foo_patch "foo_patch" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpDecorate %foo Location 0 + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpDecorate %foo_patch Patch + OpDecorate %foo_patch Location 1 + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 +%_arr_v4float_uint_4 = OpTypeArray %v4float %uint_4 + %zero_foo = OpConstantNull %_arr_v4float_uint_4 +%_ptr_Output__arr_v4float_uint_4 = OpTypePointer Output %_arr_v4float_uint_4 + %foo = OpVariable %_ptr_Output__arr_v4float_uint_4 Output %zero_foo + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %float_1 = OpConstant %float 1 + %18 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %zero_foo_patch = OpConstantNull %v4float + %foo_patch = OpVariable %_ptr_Output_v4float Output %zero_foo_patch + %float_2 = OpConstant %float 2 + %23 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 + %zero_gl_out = OpConstantNull %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output %zero_gl_out + %int_0 = OpConstant %int 0 + %float_3 = OpConstant %float 3 + %33 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3 + %int_1 = OpConstant %int 1 + %float_4 = OpConstant %float 4 +%_ptr_Output_float = OpTypePointer Output %float + %main = OpFunction %void None %3 + %5 = OpLabel + %16 = OpLoad %int %gl_InvocationID + %20 = OpAccessChain %_ptr_Output_v4float %foo %16 + OpStore %20 %18 + OpStore %foo_patch %23 + %34 = OpAccessChain %_ptr_Output_v4float %gl_out %16 %int_0 + OpStore %34 %33 + %39 = OpAccessChain %_ptr_Output_float %gl_out %16 %int_1 + OpStore %39 %float_4 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers.mask-location-1.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers.mask-location-1.asm.tesc new file mode 100644 index 0000000000..6b616b0416 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers.mask-location-1.asm.tesc @@ -0,0 +1,76 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 40 +; Schema: 0 + OpCapability Tessellation + OpCapability TessellationPointSize + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %foo %gl_InvocationID %foo_patch %gl_out + OpExecutionMode %main OutputVertices 4 + OpSource GLSL 450 + OpName %main "main" + OpName %foo "foo" + OpName %gl_InvocationID "gl_InvocationID" + OpName %foo_patch "foo_patch" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpDecorate %foo Location 0 + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpDecorate %foo_patch Patch + OpDecorate %foo_patch Location 1 + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 +%_arr_v4float_uint_4 = OpTypeArray %v4float %uint_4 + %zero_foo = OpConstantNull %_arr_v4float_uint_4 +%_ptr_Output__arr_v4float_uint_4 = OpTypePointer Output %_arr_v4float_uint_4 + %foo = OpVariable %_ptr_Output__arr_v4float_uint_4 Output %zero_foo + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %float_1 = OpConstant %float 1 + %18 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %zero_foo_patch = OpConstantNull %v4float + %foo_patch = OpVariable %_ptr_Output_v4float Output %zero_foo_patch + %float_2 = OpConstant %float 2 + %23 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 + %zero_gl_out = OpConstantNull %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output %zero_gl_out + %int_0 = OpConstant %int 0 + %float_3 = OpConstant %float 3 + %33 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3 + %int_1 = OpConstant %int 1 + %float_4 = OpConstant %float 4 +%_ptr_Output_float = OpTypePointer Output %float + %main = OpFunction %void None %3 + %5 = OpLabel + %16 = OpLoad %int %gl_InvocationID + %20 = OpAccessChain %_ptr_Output_v4float %foo %16 + OpStore %20 %18 + OpStore %foo_patch %23 + %34 = OpAccessChain %_ptr_Output_v4float %gl_out %16 %int_0 + OpStore %34 %33 + %39 = OpAccessChain %_ptr_Output_float %gl_out %16 %int_1 + OpStore %39 %float_4 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers.mask-location-1.multi-patch.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers.mask-location-1.multi-patch.asm.tesc new file mode 100644 index 0000000000..6b616b0416 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers.mask-location-1.multi-patch.asm.tesc @@ -0,0 +1,76 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 40 +; Schema: 0 + OpCapability Tessellation + OpCapability TessellationPointSize + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %foo %gl_InvocationID %foo_patch %gl_out + OpExecutionMode %main OutputVertices 4 + OpSource GLSL 450 + OpName %main "main" + OpName %foo "foo" + OpName %gl_InvocationID "gl_InvocationID" + OpName %foo_patch "foo_patch" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpDecorate %foo Location 0 + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpDecorate %foo_patch Patch + OpDecorate %foo_patch Location 1 + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 +%_arr_v4float_uint_4 = OpTypeArray %v4float %uint_4 + %zero_foo = OpConstantNull %_arr_v4float_uint_4 +%_ptr_Output__arr_v4float_uint_4 = OpTypePointer Output %_arr_v4float_uint_4 + %foo = OpVariable %_ptr_Output__arr_v4float_uint_4 Output %zero_foo + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %float_1 = OpConstant %float 1 + %18 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %zero_foo_patch = OpConstantNull %v4float + %foo_patch = OpVariable %_ptr_Output_v4float Output %zero_foo_patch + %float_2 = OpConstant %float 2 + %23 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 + %zero_gl_out = OpConstantNull %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output %zero_gl_out + %int_0 = OpConstant %int 0 + %float_3 = OpConstant %float 3 + %33 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3 + %int_1 = OpConstant %int 1 + %float_4 = OpConstant %float 4 +%_ptr_Output_float = OpTypePointer Output %float + %main = OpFunction %void None %3 + %5 = OpLabel + %16 = OpLoad %int %gl_InvocationID + %20 = OpAccessChain %_ptr_Output_v4float %foo %16 + OpStore %20 %18 + OpStore %foo_patch %23 + %34 = OpAccessChain %_ptr_Output_v4float %gl_out %16 %int_0 + OpStore %34 %33 + %39 = OpAccessChain %_ptr_Output_float %gl_out %16 %int_1 + OpStore %39 %float_4 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers.mask-point-size.msl2.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers.mask-point-size.msl2.asm.tesc new file mode 100644 index 0000000000..6b616b0416 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers.mask-point-size.msl2.asm.tesc @@ -0,0 +1,76 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 40 +; Schema: 0 + OpCapability Tessellation + OpCapability TessellationPointSize + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %foo %gl_InvocationID %foo_patch %gl_out + OpExecutionMode %main OutputVertices 4 + OpSource GLSL 450 + OpName %main "main" + OpName %foo "foo" + OpName %gl_InvocationID "gl_InvocationID" + OpName %foo_patch "foo_patch" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpDecorate %foo Location 0 + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpDecorate %foo_patch Patch + OpDecorate %foo_patch Location 1 + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 +%_arr_v4float_uint_4 = OpTypeArray %v4float %uint_4 + %zero_foo = OpConstantNull %_arr_v4float_uint_4 +%_ptr_Output__arr_v4float_uint_4 = OpTypePointer Output %_arr_v4float_uint_4 + %foo = OpVariable %_ptr_Output__arr_v4float_uint_4 Output %zero_foo + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %float_1 = OpConstant %float 1 + %18 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %zero_foo_patch = OpConstantNull %v4float + %foo_patch = OpVariable %_ptr_Output_v4float Output %zero_foo_patch + %float_2 = OpConstant %float 2 + %23 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 + %zero_gl_out = OpConstantNull %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output %zero_gl_out + %int_0 = OpConstant %int 0 + %float_3 = OpConstant %float 3 + %33 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3 + %int_1 = OpConstant %int 1 + %float_4 = OpConstant %float 4 +%_ptr_Output_float = OpTypePointer Output %float + %main = OpFunction %void None %3 + %5 = OpLabel + %16 = OpLoad %int %gl_InvocationID + %20 = OpAccessChain %_ptr_Output_v4float %foo %16 + OpStore %20 %18 + OpStore %foo_patch %23 + %34 = OpAccessChain %_ptr_Output_v4float %gl_out %16 %int_0 + OpStore %34 %33 + %39 = OpAccessChain %_ptr_Output_float %gl_out %16 %int_1 + OpStore %39 %float_4 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers.mask-point-size.msl2.multi-patch.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers.mask-point-size.msl2.multi-patch.asm.tesc new file mode 100644 index 0000000000..6b616b0416 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers.mask-point-size.msl2.multi-patch.asm.tesc @@ -0,0 +1,76 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 40 +; Schema: 0 + OpCapability Tessellation + OpCapability TessellationPointSize + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %foo %gl_InvocationID %foo_patch %gl_out + OpExecutionMode %main OutputVertices 4 + OpSource GLSL 450 + OpName %main "main" + OpName %foo "foo" + OpName %gl_InvocationID "gl_InvocationID" + OpName %foo_patch "foo_patch" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpDecorate %foo Location 0 + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpDecorate %foo_patch Patch + OpDecorate %foo_patch Location 1 + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 +%_arr_v4float_uint_4 = OpTypeArray %v4float %uint_4 + %zero_foo = OpConstantNull %_arr_v4float_uint_4 +%_ptr_Output__arr_v4float_uint_4 = OpTypePointer Output %_arr_v4float_uint_4 + %foo = OpVariable %_ptr_Output__arr_v4float_uint_4 Output %zero_foo + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %float_1 = OpConstant %float 1 + %18 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %zero_foo_patch = OpConstantNull %v4float + %foo_patch = OpVariable %_ptr_Output_v4float Output %zero_foo_patch + %float_2 = OpConstant %float 2 + %23 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 + %zero_gl_out = OpConstantNull %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output %zero_gl_out + %int_0 = OpConstant %int 0 + %float_3 = OpConstant %float 3 + %33 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3 + %int_1 = OpConstant %int 1 + %float_4 = OpConstant %float 4 +%_ptr_Output_float = OpTypePointer Output %float + %main = OpFunction %void None %3 + %5 = OpLabel + %16 = OpLoad %int %gl_InvocationID + %20 = OpAccessChain %_ptr_Output_v4float %foo %16 + OpStore %20 %18 + OpStore %foo_patch %23 + %34 = OpAccessChain %_ptr_Output_v4float %gl_out %16 %int_0 + OpStore %34 %33 + %39 = OpAccessChain %_ptr_Output_float %gl_out %16 %int_1 + OpStore %39 %float_4 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers.mask-position.msl2.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers.mask-position.msl2.asm.tesc new file mode 100644 index 0000000000..6b616b0416 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers.mask-position.msl2.asm.tesc @@ -0,0 +1,76 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 40 +; Schema: 0 + OpCapability Tessellation + OpCapability TessellationPointSize + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %foo %gl_InvocationID %foo_patch %gl_out + OpExecutionMode %main OutputVertices 4 + OpSource GLSL 450 + OpName %main "main" + OpName %foo "foo" + OpName %gl_InvocationID "gl_InvocationID" + OpName %foo_patch "foo_patch" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpDecorate %foo Location 0 + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpDecorate %foo_patch Patch + OpDecorate %foo_patch Location 1 + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 +%_arr_v4float_uint_4 = OpTypeArray %v4float %uint_4 + %zero_foo = OpConstantNull %_arr_v4float_uint_4 +%_ptr_Output__arr_v4float_uint_4 = OpTypePointer Output %_arr_v4float_uint_4 + %foo = OpVariable %_ptr_Output__arr_v4float_uint_4 Output %zero_foo + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %float_1 = OpConstant %float 1 + %18 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %zero_foo_patch = OpConstantNull %v4float + %foo_patch = OpVariable %_ptr_Output_v4float Output %zero_foo_patch + %float_2 = OpConstant %float 2 + %23 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 + %zero_gl_out = OpConstantNull %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output %zero_gl_out + %int_0 = OpConstant %int 0 + %float_3 = OpConstant %float 3 + %33 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3 + %int_1 = OpConstant %int 1 + %float_4 = OpConstant %float 4 +%_ptr_Output_float = OpTypePointer Output %float + %main = OpFunction %void None %3 + %5 = OpLabel + %16 = OpLoad %int %gl_InvocationID + %20 = OpAccessChain %_ptr_Output_v4float %foo %16 + OpStore %20 %18 + OpStore %foo_patch %23 + %34 = OpAccessChain %_ptr_Output_v4float %gl_out %16 %int_0 + OpStore %34 %33 + %39 = OpAccessChain %_ptr_Output_float %gl_out %16 %int_1 + OpStore %39 %float_4 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers.mask-position.msl2.multi-patch.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers.mask-position.msl2.multi-patch.asm.tesc new file mode 100644 index 0000000000..6b616b0416 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/masking/initializers.mask-position.msl2.multi-patch.asm.tesc @@ -0,0 +1,76 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 40 +; Schema: 0 + OpCapability Tessellation + OpCapability TessellationPointSize + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %foo %gl_InvocationID %foo_patch %gl_out + OpExecutionMode %main OutputVertices 4 + OpSource GLSL 450 + OpName %main "main" + OpName %foo "foo" + OpName %gl_InvocationID "gl_InvocationID" + OpName %foo_patch "foo_patch" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpDecorate %foo Location 0 + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpDecorate %foo_patch Patch + OpDecorate %foo_patch Location 1 + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 +%_arr_v4float_uint_4 = OpTypeArray %v4float %uint_4 + %zero_foo = OpConstantNull %_arr_v4float_uint_4 +%_ptr_Output__arr_v4float_uint_4 = OpTypePointer Output %_arr_v4float_uint_4 + %foo = OpVariable %_ptr_Output__arr_v4float_uint_4 Output %zero_foo + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %float_1 = OpConstant %float 1 + %18 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %zero_foo_patch = OpConstantNull %v4float + %foo_patch = OpVariable %_ptr_Output_v4float Output %zero_foo_patch + %float_2 = OpConstant %float 2 + %23 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 + %zero_gl_out = OpConstantNull %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output %zero_gl_out + %int_0 = OpConstant %int 0 + %float_3 = OpConstant %float 3 + %33 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3 + %int_1 = OpConstant %int 1 + %float_4 = OpConstant %float 4 +%_ptr_Output_float = OpTypePointer Output %float + %main = OpFunction %void None %3 + %5 = OpLabel + %16 = OpLoad %int %gl_InvocationID + %20 = OpAccessChain %_ptr_Output_v4float %foo %16 + OpStore %20 %18 + OpStore %foo_patch %23 + %34 = OpAccessChain %_ptr_Output_v4float %gl_out %16 %int_0 + OpStore %34 %33 + %39 = OpAccessChain %_ptr_Output_float %gl_out %16 %int_1 + OpStore %39 %float_4 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/array-control-point-initializer.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/array-control-point-initializer.asm.tesc new file mode 100644 index 0000000000..5bbe951df4 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/array-control-point-initializer.asm.tesc @@ -0,0 +1,80 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 48 +; Schema: 0 + OpCapability Tessellation + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %gl_out %gl_InvocationID %foo + OpExecutionMode %main OutputVertices 4 + OpSource GLSL 450 + OpName %main "main" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpName %gl_InvocationID "gl_InvocationID" + OpName %foo "foo" + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpDecorate %foo Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 + %uint_4 = OpConstant %uint 4 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %int_0 = OpConstant %int 0 + %float_1 = OpConstant %float 1 + %22 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %uint_3 = OpConstant %uint 3 +%_arr_float_uint_3 = OpTypeArray %float %uint_3 +%_arr__arr_float_uint_3_uint_4 = OpTypeArray %_arr_float_uint_3 %uint_4 +%_ptr_Output__arr__arr_float_uint_3_uint_4 = OpTypePointer Output %_arr__arr_float_uint_3_uint_4 +%foo_zero = OpConstantNull %_arr__arr_float_uint_3_uint_4 + %foo = OpVariable %_ptr_Output__arr__arr_float_uint_3_uint_4 Output %foo_zero +%_ptr_Output_float = OpTypePointer Output %float + %int_1 = OpConstant %int 1 + %int_2 = OpConstant %int 2 + %float_2 = OpConstant %float 2 + %main = OpFunction %void None %3 + %5 = OpLabel + %19 = OpLoad %int %gl_InvocationID + %24 = OpAccessChain %_ptr_Output_v4float %gl_out %19 %int_0 + OpStore %24 %22 + %30 = OpLoad %int %gl_InvocationID + %31 = OpLoad %int %gl_InvocationID + %32 = OpConvertSToF %float %31 + %34 = OpAccessChain %_ptr_Output_float %foo %30 %int_0 + OpStore %34 %32 + %35 = OpLoad %int %gl_InvocationID + %37 = OpLoad %int %gl_InvocationID + %38 = OpConvertSToF %float %37 + %39 = OpFAdd %float %38 %float_1 + %40 = OpAccessChain %_ptr_Output_float %foo %35 %int_1 + OpStore %40 %39 + %41 = OpLoad %int %gl_InvocationID + %43 = OpLoad %int %gl_InvocationID + %44 = OpConvertSToF %float %43 + %46 = OpFAdd %float %44 %float_2 + %47 = OpAccessChain %_ptr_Output_float %foo %41 %int_2 + OpStore %47 %46 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/block-control-point-initializer.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/block-control-point-initializer.asm.tesc new file mode 100644 index 0000000000..d4e14be4ab --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/block-control-point-initializer.asm.tesc @@ -0,0 +1,70 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 35 +; Schema: 0 + OpCapability Tessellation + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %gl_out %gl_InvocationID %verts + OpExecutionMode %main OutputVertices 4 + OpSource GLSL 450 + OpName %main "main" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpName %gl_InvocationID "gl_InvocationID" + OpName %Verts "Verts" + OpMemberName %Verts 0 "a" + OpMemberName %Verts 1 "b" + OpName %verts "verts" + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpDecorate %Verts Block + OpDecorate %verts Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 + %uint_4 = OpConstant %uint 4 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 +;%gl_out_zero = OpConstantNull %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output ;%gl_out_zero + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %int_0 = OpConstant %int 0 + %float_1 = OpConstant %float 1 + %22 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %v2float = OpTypeVector %float 2 + %Verts = OpTypeStruct %float %v2float +%_arr_Verts_uint_4 = OpTypeArray %Verts %uint_4 +%_ptr_Output__arr_Verts_uint_4 = OpTypePointer Output %_arr_Verts_uint_4 + %verts_zero = OpConstantNull %_arr_Verts_uint_4 + %verts = OpVariable %_ptr_Output__arr_Verts_uint_4 Output %verts_zero +%_ptr_Output_float = OpTypePointer Output %float + %main = OpFunction %void None %3 + %5 = OpLabel + %19 = OpLoad %int %gl_InvocationID + %24 = OpAccessChain %_ptr_Output_v4float %gl_out %19 %int_0 + OpStore %24 %22 + %30 = OpLoad %int %gl_InvocationID + %31 = OpLoad %int %gl_InvocationID + %32 = OpConvertSToF %float %31 + %34 = OpAccessChain %_ptr_Output_float %verts %30 %int_0 + OpStore %34 %32 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/builtin-control-point-initializer.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/builtin-control-point-initializer.asm.tesc new file mode 100644 index 0000000000..1219183ca7 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/builtin-control-point-initializer.asm.tesc @@ -0,0 +1,65 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 35 +; Schema: 0 + OpCapability Tessellation + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %gl_out %gl_InvocationID %verts + OpExecutionMode %main OutputVertices 4 + OpSource GLSL 450 + OpName %main "main" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpName %gl_out "gl_out" + OpName %gl_InvocationID "gl_InvocationID" + OpName %Verts "Verts" + OpMemberName %Verts 0 "a" + OpMemberName %Verts 1 "b" + OpName %verts "verts" + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpDecorate %gl_PerVertex Block + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpDecorate %Verts Block + OpDecorate %verts Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%gl_PerVertex = OpTypeStruct %v4float %float + %uint_4 = OpConstant %uint 4 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 +%gl_out_zero = OpConstantNull %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output %gl_out_zero + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %int_0 = OpConstant %int 0 + %float_1 = OpConstant %float 1 + %22 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %v2float = OpTypeVector %float 2 + %Verts = OpTypeStruct %float %v2float +%_arr_Verts_uint_4 = OpTypeArray %Verts %uint_4 +%_ptr_Output__arr_Verts_uint_4 = OpTypePointer Output %_arr_Verts_uint_4 + %verts_zero = OpConstantNull %_arr_Verts_uint_4 + %verts = OpVariable %_ptr_Output__arr_Verts_uint_4 Output %verts_zero +%_ptr_Output_float = OpTypePointer Output %float + %main = OpFunction %void None %3 + %5 = OpLabel + %19 = OpLoad %int %gl_InvocationID + %24 = OpAccessChain %_ptr_Output_v4float %gl_out %19 %int_0 + OpStore %24 %22 + %30 = OpLoad %int %gl_InvocationID + %31 = OpLoad %int %gl_InvocationID + %32 = OpConvertSToF %float %31 + %34 = OpAccessChain %_ptr_Output_float %verts %30 %int_0 + OpStore %34 %32 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/composite-control-point-initializer.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/composite-control-point-initializer.asm.tesc new file mode 100644 index 0000000000..03ac99befb --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/composite-control-point-initializer.asm.tesc @@ -0,0 +1,69 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 35 +; Schema: 0 + OpCapability Tessellation + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %gl_out %gl_InvocationID %foo + OpExecutionMode %main OutputVertices 4 + OpSource GLSL 450 + OpName %main "main" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpName %gl_InvocationID "gl_InvocationID" + OpName %Foo "Foo" + OpMemberName %Foo 0 "a" + OpMemberName %Foo 1 "b" + OpMemberName %Foo 2 "c" + OpName %foo "foo" + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpDecorate %foo Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 + %uint_4 = OpConstant %uint 4 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %int_0 = OpConstant %int 0 + %float_1 = OpConstant %float 1 + %22 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %v2float = OpTypeVector %float 2 + %Foo = OpTypeStruct %float %v2float %v4float +%_arr_Foo_uint_4 = OpTypeArray %Foo %uint_4 +%_ptr_Output__arr_Foo_uint_4 = OpTypePointer Output %_arr_Foo_uint_4 + %foo_zero = OpConstantNull %_arr_Foo_uint_4 + %foo = OpVariable %_ptr_Output__arr_Foo_uint_4 Output %foo_zero +%_ptr_Output_float = OpTypePointer Output %float + %main = OpFunction %void None %3 + %5 = OpLabel + %19 = OpLoad %int %gl_InvocationID + %24 = OpAccessChain %_ptr_Output_v4float %gl_out %19 %int_0 + OpStore %24 %22 + %30 = OpLoad %int %gl_InvocationID + %31 = OpLoad %int %gl_InvocationID + %32 = OpConvertSToF %float %31 + %34 = OpAccessChain %_ptr_Output_float %foo %30 %int_0 + OpStore %34 %32 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/copy-memory-control-point.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/copy-memory-control-point.asm.tesc new file mode 100644 index 0000000000..7c0a638f98 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/copy-memory-control-point.asm.tesc @@ -0,0 +1,199 @@ +; SPIR-V +; Version: 1.0 +; Generator: Wine VKD3D Shader Compiler; 2 +; Bound: 126 +; Schema: 0 + OpCapability Tessellation + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %1 "main" %4 %30 %80 %101 %103 %108 %110 %115 %117 + OpExecutionMode %1 OutputVertices 3 + OpExecutionMode %1 Triangles + OpExecutionMode %1 SpacingEqual + OpExecutionMode %1 VertexOrderCw + OpName %1 "main" + OpName %11 "opc" + OpName %14 "cb1_struct" + OpName %16 "cb0_0" + OpName %22 "vicp" + OpName %23 "fork0" + OpName %26 "vForkInstanceId" + OpName %34 "r0" + OpName %32 "fork0_epilogue" + OpName %75 "fork1" + OpName %81 "fork1_epilogue" + OpName %101 "v0" + OpName %103 "v1" + OpName %108 "vicp0" + OpName %110 "vocp0" + OpName %115 "vicp1" + OpName %117 "vocp1" + OpDecorate %4 BuiltIn InvocationId + OpDecorate %13 ArrayStride 16 + OpDecorate %14 Block + OpMemberDecorate %14 0 Offset 0 + OpDecorate %16 DescriptorSet 0 + OpDecorate %16 Binding 0 + OpDecorate %30 BuiltIn TessLevelOuter + OpDecorate %30 Patch + OpDecorate %30 Patch + OpDecorate %30 Patch + OpDecorate %30 Patch + OpDecorate %80 BuiltIn TessLevelInner + OpDecorate %80 Patch + OpDecorate %80 Patch + OpDecorate %101 Location 0 + OpDecorate %103 Location 1 + OpDecorate %108 Location 2 + OpDecorate %110 Location 3 + OpDecorate %115 Location 4 + OpDecorate %117 Location 5 + %2 = OpTypeInt 32 1 + %3 = OpTypePointer Input %2 + %4 = OpVariable %3 Input + %5 = OpTypeFloat 32 + %6 = OpTypeVector %5 4 + %7 = OpTypeInt 32 0 + %8 = OpConstant %7 4 + %9 = OpTypeArray %6 %8 + %10 = OpTypePointer Private %9 + %11 = OpVariable %10 Private + %12 = OpConstant %7 1 + %13 = OpTypeArray %6 %12 + %14 = OpTypeStruct %13 + %15 = OpTypePointer Uniform %14 + %16 = OpVariable %15 Uniform + %17 = OpConstant %7 3 + %18 = OpTypeArray %6 %17 + %19 = OpConstant %7 2 + %20 = OpTypeArray %18 %19 + %21 = OpTypePointer Private %20 + %22 = OpVariable %21 Private + %24 = OpTypeVoid + %25 = OpTypeFunction %24 %7 + %28 = OpTypeArray %5 %8 + %29 = OpTypePointer Output %28 + %30 = OpVariable %29 Output + %31 = OpConstant %7 0 + %33 = OpTypePointer Function %6 + %36 = OpTypePointer Function %5 + %38 = OpTypePointer Uniform %6 + %40 = OpTypePointer Uniform %5 + %46 = OpTypePointer Private %6 + %48 = OpTypePointer Private %5 + %52 = OpVariable %46 Private + %55 = OpVariable %46 Private + %58 = OpVariable %46 Private + %60 = OpTypeFunction %24 %46 %46 %46 + %69 = OpTypePointer Output %5 + %76 = OpTypeFunction %24 + %78 = OpTypeArray %5 %19 + %79 = OpTypePointer Output %78 + %80 = OpVariable %79 Output + %89 = OpVariable %46 Private + %91 = OpTypeFunction %24 %46 + %98 = OpTypePointer Private %18 + %100 = OpTypePointer Input %18 + %101 = OpVariable %100 Input + %103 = OpVariable %100 Input + %105 = OpTypeVector %5 3 + %106 = OpTypeArray %105 %17 + %107 = OpTypePointer Input %106 + %108 = OpVariable %107 Input + %109 = OpTypePointer Output %106 + %110 = OpVariable %109 Output + %111 = OpTypePointer Output %105 + %112 = OpTypePointer Input %105 + %115 = OpVariable %100 Input + %116 = OpTypePointer Output %18 + %117 = OpVariable %116 Output + %118 = OpTypePointer Output %6 + %119 = OpTypePointer Input %6 + %23 = OpFunction %24 None %25 + %26 = OpFunctionParameter %7 + %27 = OpLabel + %34 = OpVariable %33 Function + %35 = OpBitcast %5 %26 + %37 = OpInBoundsAccessChain %36 %34 %31 + OpStore %37 %35 + %39 = OpAccessChain %38 %16 %31 %31 + %41 = OpInBoundsAccessChain %40 %39 %31 + %42 = OpLoad %5 %41 + %43 = OpInBoundsAccessChain %36 %34 %31 + %44 = OpLoad %5 %43 + %45 = OpBitcast %2 %44 + %47 = OpAccessChain %46 %11 %45 + %49 = OpInBoundsAccessChain %48 %47 %31 + OpStore %49 %42 + %50 = OpAccessChain %46 %11 %31 + %51 = OpLoad %6 %50 + OpStore %52 %51 + %53 = OpAccessChain %46 %11 %12 + %54 = OpLoad %6 %53 + OpStore %55 %54 + %56 = OpAccessChain %46 %11 %19 + %57 = OpLoad %6 %56 + OpStore %58 %57 + %59 = OpFunctionCall %24 %32 %52 %55 %58 + OpReturn + OpFunctionEnd + %32 = OpFunction %24 None %60 + %61 = OpFunctionParameter %46 + %62 = OpFunctionParameter %46 + %63 = OpFunctionParameter %46 + %64 = OpLabel + %65 = OpLoad %6 %61 + %66 = OpLoad %6 %62 + %67 = OpLoad %6 %63 + %68 = OpCompositeExtract %5 %65 0 + %70 = OpAccessChain %69 %30 %31 + OpStore %70 %68 + %71 = OpCompositeExtract %5 %66 0 + %72 = OpAccessChain %69 %30 %12 + OpStore %72 %71 + %73 = OpCompositeExtract %5 %67 0 + %74 = OpAccessChain %69 %30 %19 + OpStore %74 %73 + OpReturn + OpFunctionEnd + %75 = OpFunction %24 None %76 + %77 = OpLabel + %82 = OpAccessChain %38 %16 %31 %31 + %83 = OpInBoundsAccessChain %40 %82 %31 + %84 = OpLoad %5 %83 + %85 = OpAccessChain %46 %11 %17 + %86 = OpInBoundsAccessChain %48 %85 %31 + OpStore %86 %84 + %87 = OpAccessChain %46 %11 %17 + %88 = OpLoad %6 %87 + OpStore %89 %88 + %90 = OpFunctionCall %24 %81 %89 + OpReturn + OpFunctionEnd + %81 = OpFunction %24 None %91 + %92 = OpFunctionParameter %46 + %93 = OpLabel + %94 = OpLoad %6 %92 + %95 = OpCompositeExtract %5 %94 0 + %96 = OpAccessChain %69 %80 %31 + OpStore %96 %95 + OpReturn + OpFunctionEnd + %1 = OpFunction %24 None %76 + %97 = OpLabel + %99 = OpInBoundsAccessChain %98 %22 %31 + OpCopyMemory %99 %101 + %102 = OpInBoundsAccessChain %98 %22 %12 + OpCopyMemory %102 %103 + %104 = OpLoad %2 %4 + %113 = OpAccessChain %111 %110 %104 + %114 = OpAccessChain %112 %108 %104 + OpCopyMemory %113 %114 + %120 = OpAccessChain %118 %117 %104 + %121 = OpAccessChain %119 %115 %104 + OpCopyMemory %120 %121 + %122 = OpFunctionCall %24 %23 %31 + %123 = OpFunctionCall %24 %23 %12 + %124 = OpFunctionCall %24 %23 %19 + %125 = OpFunctionCall %24 %75 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/copy-tess-level-tri.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/copy-tess-level-tri.asm.tesc new file mode 100644 index 0000000000..346466e61f --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/copy-tess-level-tri.asm.tesc @@ -0,0 +1,82 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 43 +; Schema: 0 + OpCapability Tessellation + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %gl_TessLevelInner %gl_TessLevelOuter %gl_out %gl_InvocationID + OpExecutionMode %main OutputVertices 1 + OpExecutionMode %main Triangles + OpSource GLSL 450 + OpName %main "main" + OpName %gl_TessLevelInner "gl_TessLevelInner" + OpName %gl_TessLevelOuter "gl_TessLevelOuter" + OpName %inner "inner" + OpName %outer "outer" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpName %gl_InvocationID "gl_InvocationID" + OpDecorate %gl_TessLevelInner Patch + OpDecorate %gl_TessLevelInner BuiltIn TessLevelInner + OpDecorate %gl_TessLevelOuter Patch + OpDecorate %gl_TessLevelOuter BuiltIn TessLevelOuter + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + OpDecorate %gl_InvocationID BuiltIn InvocationId + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %uint = OpTypeInt 32 0 + %uint_2 = OpConstant %uint 2 +%_arr_float_uint_2 = OpTypeArray %float %uint_2 +%_ptr_Output__arr_float_uint_2 = OpTypePointer Output %_arr_float_uint_2 +%gl_TessLevelInner = OpVariable %_ptr_Output__arr_float_uint_2 Output + %float_1 = OpConstant %float 1 + %float_2 = OpConstant %float 2 + %14 = OpConstantComposite %_arr_float_uint_2 %float_1 %float_2 + %uint_4 = OpConstant %uint 4 +%_arr_float_uint_4 = OpTypeArray %float %uint_4 +%_ptr_Output__arr_float_uint_4 = OpTypePointer Output %_arr_float_uint_4 +%gl_TessLevelOuter = OpVariable %_ptr_Output__arr_float_uint_4 Output + %float_3 = OpConstant %float 3 + %float_4 = OpConstant %float 4 + %21 = OpConstantComposite %_arr_float_uint_4 %float_1 %float_2 %float_3 %float_4 +%_ptr_Function__arr_float_uint_2 = OpTypePointer Function %_arr_float_uint_2 +%_ptr_Function__arr_float_uint_4 = OpTypePointer Function %_arr_float_uint_4 + %v4float = OpTypeVector %float 4 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_arr_gl_PerVertex_uint_1 = OpTypeArray %gl_PerVertex %uint_1 +%_ptr_Output__arr_gl_PerVertex_uint_1 = OpTypePointer Output %_arr_gl_PerVertex_uint_1 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_1 Output + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %int_0 = OpConstant %int 0 + %40 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %main = OpFunction %void None %3 + %5 = OpLabel + %inner = OpVariable %_ptr_Function__arr_float_uint_2 Function + %outer = OpVariable %_ptr_Function__arr_float_uint_4 Function + OpStore %gl_TessLevelInner %14 + OpStore %gl_TessLevelOuter %21 + %24 = OpLoad %_arr_float_uint_2 %gl_TessLevelInner + OpStore %inner %24 + %27 = OpLoad %_arr_float_uint_4 %gl_TessLevelOuter + OpStore %outer %27 + %38 = OpLoad %int %gl_InvocationID + %42 = OpAccessChain %_ptr_Output_v4float %gl_out %38 %int_0 + OpStore %42 %40 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/plain-control-point-initializer.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/plain-control-point-initializer.asm.tesc new file mode 100644 index 0000000000..2a95da04b7 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/plain-control-point-initializer.asm.tesc @@ -0,0 +1,63 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 33 +; Schema: 0 + OpCapability Tessellation + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %gl_out %gl_InvocationID %v + OpExecutionMode %main OutputVertices 4 + OpSource GLSL 450 + OpName %main "main" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpName %gl_InvocationID "gl_InvocationID" + OpName %v "v" + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpDecorate %v Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 + %uint_4 = OpConstant %uint 4 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %int_0 = OpConstant %int 0 + %float_1 = OpConstant %float 1 + %22 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float +%_arr_float_uint_4 = OpTypeArray %float %uint_4 +%_ptr_Output__arr_float_uint_4 = OpTypePointer Output %_arr_float_uint_4 + %v_zero = OpConstantNull %_arr_float_uint_4 + %v = OpVariable %_ptr_Output__arr_float_uint_4 Output %v_zero +%_ptr_Output_float = OpTypePointer Output %float + %main = OpFunction %void None %3 + %5 = OpLabel + %19 = OpLoad %int %gl_InvocationID + %24 = OpAccessChain %_ptr_Output_v4float %gl_out %19 %int_0 + OpStore %24 %22 + %28 = OpLoad %int %gl_InvocationID + %29 = OpLoad %int %gl_InvocationID + %30 = OpConvertSToF %float %29 + %32 = OpAccessChain %_ptr_Output_float %v %28 + OpStore %32 %30 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/tess-level-initializer-quad.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/tess-level-initializer-quad.asm.tesc new file mode 100644 index 0000000000..53248f17e6 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/tess-level-initializer-quad.asm.tesc @@ -0,0 +1,88 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 47 +; Schema: 0 + OpCapability Tessellation + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %gl_out %gl_InvocationID %gl_TessLevelInner %gl_TessLevelOuter + OpExecutionMode %main OutputVertices 4 + OpExecutionMode %main Quads + OpSource GLSL 450 + OpName %main "main" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpName %gl_InvocationID "gl_InvocationID" + OpName %gl_TessLevelInner "gl_TessLevelInner" + OpName %gl_TessLevelOuter "gl_TessLevelOuter" + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpDecorate %gl_TessLevelInner Patch + OpDecorate %gl_TessLevelInner BuiltIn TessLevelInner + OpDecorate %gl_TessLevelOuter Patch + OpDecorate %gl_TessLevelOuter BuiltIn TessLevelOuter + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 + %uint_4 = OpConstant %uint 4 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %int_0 = OpConstant %int 0 + %float_1 = OpConstant %float 1 + %22 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %uint_2 = OpConstant %uint 2 +%_arr_float_uint_2 = OpTypeArray %float %uint_2 +%_ptr_Output__arr_float_uint_2 = OpTypePointer Output %_arr_float_uint_2 + %inner_zero = OpConstantNull %_arr_float_uint_2 +%gl_TessLevelInner = OpVariable %_ptr_Output__arr_float_uint_2 Output %inner_zero +%_ptr_Output_float = OpTypePointer Output %float + %int_1 = OpConstant %int 1 + %float_2 = OpConstant %float 2 +%_arr_float_uint_4 = OpTypeArray %float %uint_4 +%_ptr_Output__arr_float_uint_4 = OpTypePointer Output %_arr_float_uint_4 + %outer_zero = OpConstantNull %_arr_float_uint_4 +%gl_TessLevelOuter = OpVariable %_ptr_Output__arr_float_uint_4 Output %outer_zero + %float_3 = OpConstant %float 3 + %float_4 = OpConstant %float 4 + %int_2 = OpConstant %int 2 + %float_5 = OpConstant %float 5 + %int_3 = OpConstant %int 3 + %float_6 = OpConstant %float 6 + %main = OpFunction %void None %3 + %5 = OpLabel + %19 = OpLoad %int %gl_InvocationID + %24 = OpAccessChain %_ptr_Output_v4float %gl_out %19 %int_0 + OpStore %24 %22 + %30 = OpAccessChain %_ptr_Output_float %gl_TessLevelInner %int_0 + OpStore %30 %float_1 + %33 = OpAccessChain %_ptr_Output_float %gl_TessLevelInner %int_1 + OpStore %33 %float_2 + %38 = OpAccessChain %_ptr_Output_float %gl_TessLevelOuter %int_0 + OpStore %38 %float_3 + %40 = OpAccessChain %_ptr_Output_float %gl_TessLevelOuter %int_1 + OpStore %40 %float_4 + %43 = OpAccessChain %_ptr_Output_float %gl_TessLevelOuter %int_2 + OpStore %43 %float_5 + %46 = OpAccessChain %_ptr_Output_float %gl_TessLevelOuter %int_3 + OpStore %46 %float_6 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/tess-level-initializer-triangle.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/tess-level-initializer-triangle.asm.tesc new file mode 100644 index 0000000000..6fbc33dc22 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/tess-level-initializer-triangle.asm.tesc @@ -0,0 +1,88 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 47 +; Schema: 0 + OpCapability Tessellation + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %gl_out %gl_InvocationID %gl_TessLevelInner %gl_TessLevelOuter + OpExecutionMode %main OutputVertices 4 + OpExecutionMode %main Triangles + OpSource GLSL 450 + OpName %main "main" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpName %gl_InvocationID "gl_InvocationID" + OpName %gl_TessLevelInner "gl_TessLevelInner" + OpName %gl_TessLevelOuter "gl_TessLevelOuter" + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpDecorate %gl_TessLevelInner Patch + OpDecorate %gl_TessLevelInner BuiltIn TessLevelInner + OpDecorate %gl_TessLevelOuter Patch + OpDecorate %gl_TessLevelOuter BuiltIn TessLevelOuter + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 + %uint_4 = OpConstant %uint 4 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %int_0 = OpConstant %int 0 + %float_1 = OpConstant %float 1 + %22 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %uint_2 = OpConstant %uint 2 +%_arr_float_uint_2 = OpTypeArray %float %uint_2 +%_ptr_Output__arr_float_uint_2 = OpTypePointer Output %_arr_float_uint_2 + %inner_zero = OpConstantNull %_arr_float_uint_2 +%gl_TessLevelInner = OpVariable %_ptr_Output__arr_float_uint_2 Output %inner_zero +%_ptr_Output_float = OpTypePointer Output %float + %int_1 = OpConstant %int 1 + %float_2 = OpConstant %float 2 +%_arr_float_uint_4 = OpTypeArray %float %uint_4 +%_ptr_Output__arr_float_uint_4 = OpTypePointer Output %_arr_float_uint_4 + %outer_zero = OpConstantNull %_arr_float_uint_4 +%gl_TessLevelOuter = OpVariable %_ptr_Output__arr_float_uint_4 Output %outer_zero + %float_3 = OpConstant %float 3 + %float_4 = OpConstant %float 4 + %int_2 = OpConstant %int 2 + %float_5 = OpConstant %float 5 + %int_3 = OpConstant %int 3 + %float_6 = OpConstant %float 6 + %main = OpFunction %void None %3 + %5 = OpLabel + %19 = OpLoad %int %gl_InvocationID + %24 = OpAccessChain %_ptr_Output_v4float %gl_out %19 %int_0 + OpStore %24 %22 + %30 = OpAccessChain %_ptr_Output_float %gl_TessLevelInner %int_0 + OpStore %30 %float_1 + %33 = OpAccessChain %_ptr_Output_float %gl_TessLevelInner %int_1 + OpStore %33 %float_2 + %38 = OpAccessChain %_ptr_Output_float %gl_TessLevelOuter %int_0 + OpStore %38 %float_3 + %40 = OpAccessChain %_ptr_Output_float %gl_TessLevelOuter %int_1 + OpStore %40 %float_4 + %43 = OpAccessChain %_ptr_Output_float %gl_TessLevelOuter %int_2 + OpStore %43 %float_5 + %46 = OpAccessChain %_ptr_Output_float %gl_TessLevelOuter %int_3 + OpStore %46 %float_6 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/tess-level-read-write-in-function-tri.asm.tesc b/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/tess-level-read-write-in-function-tri.asm.tesc new file mode 100644 index 0000000000..33b8883cc8 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/tesc/tess-level-read-write-in-function-tri.asm.tesc @@ -0,0 +1,109 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 64 +; Schema: 0 + OpCapability Tessellation + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %gl_TessLevelInner %gl_TessLevelOuter %gl_out %gl_InvocationID + OpExecutionMode %main OutputVertices 1 + OpExecutionMode %main Triangles + OpSource GLSL 450 + OpName %main "main" + OpName %load_tess_level_in_func_ "load_tess_level_in_func(" + OpName %store_tess_level_in_func_ "store_tess_level_in_func(" + OpName %gl_TessLevelInner "gl_TessLevelInner" + OpName %gl_TessLevelOuter "gl_TessLevelOuter" + OpName %v "v" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpName %gl_InvocationID "gl_InvocationID" + OpDecorate %gl_TessLevelInner Patch + OpDecorate %gl_TessLevelInner BuiltIn TessLevelInner + OpDecorate %gl_TessLevelOuter Patch + OpDecorate %gl_TessLevelOuter BuiltIn TessLevelOuter + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + OpDecorate %gl_InvocationID BuiltIn InvocationId + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %7 = OpTypeFunction %float + %uint = OpTypeInt 32 0 + %uint_2 = OpConstant %uint 2 +%_arr_float_uint_2 = OpTypeArray %float %uint_2 +%_ptr_Output__arr_float_uint_2 = OpTypePointer Output %_arr_float_uint_2 +%gl_TessLevelInner = OpVariable %_ptr_Output__arr_float_uint_2 Output + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%_ptr_Output_float = OpTypePointer Output %float + %uint_4 = OpConstant %uint 4 +%_arr_float_uint_4 = OpTypeArray %float %uint_4 +%_ptr_Output__arr_float_uint_4 = OpTypePointer Output %_arr_float_uint_4 +%gl_TessLevelOuter = OpVariable %_ptr_Output__arr_float_uint_4 Output + %int_1 = OpConstant %int 1 + %float_1 = OpConstant %float 1 + %float_2 = OpConstant %float 2 + %float_3 = OpConstant %float 3 + %float_4 = OpConstant %float 4 + %int_2 = OpConstant %int 2 + %float_5 = OpConstant %float 5 + %int_3 = OpConstant %int 3 + %float_6 = OpConstant %float 6 +%_ptr_Function_float = OpTypePointer Function %float + %v4float = OpTypeVector %float 4 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_arr_gl_PerVertex_uint_1 = OpTypeArray %gl_PerVertex %uint_1 +%_ptr_Output__arr_gl_PerVertex_uint_1 = OpTypePointer Output %_arr_gl_PerVertex_uint_1 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_1 Output +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + %main = OpFunction %void None %3 + %5 = OpLabel + %v = OpVariable %_ptr_Function_float Function + %46 = OpFunctionCall %void %store_tess_level_in_func_ + %49 = OpFunctionCall %float %load_tess_level_in_func_ + OpStore %v %49 + %59 = OpLoad %int %gl_InvocationID + %60 = OpLoad %float %v + %61 = OpCompositeConstruct %v4float %60 %60 %60 %60 + %63 = OpAccessChain %_ptr_Output_v4float %gl_out %59 %int_0 + OpStore %63 %61 + OpReturn + OpFunctionEnd +%load_tess_level_in_func_ = OpFunction %float None %7 + %9 = OpLabel + %20 = OpAccessChain %_ptr_Output_float %gl_TessLevelInner %int_0 + %21 = OpLoad %float %20 + %27 = OpAccessChain %_ptr_Output_float %gl_TessLevelOuter %int_1 + %28 = OpLoad %float %27 + %29 = OpFAdd %float %21 %28 + OpReturnValue %29 + OpFunctionEnd +%store_tess_level_in_func_ = OpFunction %void None %3 + %11 = OpLabel + %33 = OpAccessChain %_ptr_Output_float %gl_TessLevelInner %int_0 + OpStore %33 %float_1 + %35 = OpAccessChain %_ptr_Output_float %gl_TessLevelInner %int_1 + OpStore %35 %float_2 + %37 = OpAccessChain %_ptr_Output_float %gl_TessLevelOuter %int_0 + OpStore %37 %float_3 + %39 = OpAccessChain %_ptr_Output_float %gl_TessLevelOuter %int_1 + OpStore %39 %float_4 + %42 = OpAccessChain %_ptr_Output_float %gl_TessLevelOuter %int_2 + OpStore %42 %float_5 + %45 = OpAccessChain %_ptr_Output_float %gl_TessLevelOuter %int_3 + OpStore %45 %float_6 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/tese/copy-tess-level.asm.msl2.tese b/third_party/spirv-cross/shaders-msl-no-opt/asm/tese/copy-tess-level.asm.msl2.tese new file mode 100644 index 0000000000..5a7e730634 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/tese/copy-tess-level.asm.msl2.tese @@ -0,0 +1,58 @@ +; SPIR-V +; Version: 1.0 +; Generator: Google spiregg; 0 +; Bound: 35 +; Schema: 0 + OpCapability Tessellation + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationEvaluation %Domain "main" %gl_TessLevelOuter %gl_TessLevelInner %in_var_CUSTOM_VALUE %gl_TessCoord %out_var_CUSTOM_VALUE + OpExecutionMode %Domain Quads + OpSource HLSL 600 + OpName %in_var_CUSTOM_VALUE "in.var.CUSTOM_VALUE" + OpName %out_var_CUSTOM_VALUE "out.var.CUSTOM_VALUE" + OpName %Domain "Domain" + OpDecorate %gl_TessLevelOuter BuiltIn TessLevelOuter + OpDecorate %gl_TessLevelOuter Patch + OpDecorate %gl_TessLevelInner BuiltIn TessLevelInner + OpDecorate %gl_TessLevelInner Patch + OpDecorate %gl_TessCoord BuiltIn TessCoord + OpDecorate %gl_TessCoord Patch + OpDecorate %in_var_CUSTOM_VALUE Location 0 + OpDecorate %out_var_CUSTOM_VALUE Location 0 + %uint = OpTypeInt 32 0 + %uint_4 = OpConstant %uint 4 + %float = OpTypeFloat 32 +%_arr_float_uint_4 = OpTypeArray %float %uint_4 +%_ptr_Input__arr_float_uint_4 = OpTypePointer Input %_arr_float_uint_4 + %uint_2 = OpConstant %uint 2 +%_arr_float_uint_2 = OpTypeArray %float %uint_2 +%_ptr_Input__arr_float_uint_2 = OpTypePointer Input %_arr_float_uint_2 + %v4float = OpTypeVector %float 4 +%_arr_v4float_uint_4 = OpTypeArray %v4float %uint_4 +%_ptr_Input__arr_v4float_uint_4 = OpTypePointer Input %_arr_v4float_uint_4 + %v3float = OpTypeVector %float 3 +%_ptr_Input_v3float = OpTypePointer Input %v3float +%_ptr_Output_v4float = OpTypePointer Output %v4float + %void = OpTypeVoid + %22 = OpTypeFunction %void +%gl_TessLevelOuter = OpVariable %_ptr_Input__arr_float_uint_4 Input +%gl_TessLevelInner = OpVariable %_ptr_Input__arr_float_uint_2 Input +%in_var_CUSTOM_VALUE = OpVariable %_ptr_Input__arr_v4float_uint_4 Input +%gl_TessCoord = OpVariable %_ptr_Input_v3float Input +%out_var_CUSTOM_VALUE = OpVariable %_ptr_Output_v4float Output + %Domain = OpFunction %void None %22 + %23 = OpLabel + %24 = OpLoad %_arr_float_uint_4 %gl_TessLevelOuter + %25 = OpLoad %_arr_float_uint_2 %gl_TessLevelInner + %26 = OpCompositeExtract %float %24 0 + %27 = OpCompositeExtract %float %24 1 + %28 = OpCompositeExtract %float %24 2 + %29 = OpCompositeExtract %float %24 3 + %30 = OpCompositeExtract %float %25 0 + %31 = OpCompositeExtract %float %25 1 + %32 = OpFAdd %float %26 %30 + %33 = OpFAdd %float %27 %31 + %34 = OpCompositeConstruct %v4float %32 %33 %28 %29 + OpStore %out_var_CUSTOM_VALUE %34 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/tese/split-access-chain.asm.tese b/third_party/spirv-cross/shaders-msl-no-opt/asm/tese/split-access-chain.asm.tese new file mode 100644 index 0000000000..e13064f94f --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/tese/split-access-chain.asm.tese @@ -0,0 +1,35 @@ + OpCapability Tessellation + %94 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationEvaluation %main "main" %in0 %o0 + OpExecutionMode %main Quads + OpName %main "main" + OpName %in0 "in0" + OpName %o0 "o0" + OpDecorate %in0 Location 0 + OpDecorate %o0 Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 +%_arr_v4float_uint_1 = OpTypeArray %v4float %uint_1 +%_ptr_Output_float = OpTypePointer Output %float +%_ptr_Input__arr_v4float_uint_1 = OpTypePointer Input %_arr_v4float_uint_1 + %in0 = OpVariable %_ptr_Input__arr_v4float_uint_1 Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + %o0 = OpVariable %_ptr_Output_float Output +%_ptr_Function_float = OpTypePointer Function %float +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Input_float = OpTypePointer Input %float + %main = OpFunction %void None %3 + %4 = OpLabel + %ac = OpAccessChain %_ptr_Input_v4float %in0 %uint_0 + %bac = OpInBoundsAccessChain %_ptr_Input_float %ac %uint_2 + %loaded = OpLoad %float %bac + OpStore %o0 %loaded + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/vert/block-struct-initializer.asm.vert b/third_party/spirv-cross/shaders-msl-no-opt/asm/vert/block-struct-initializer.asm.vert new file mode 100644 index 0000000000..6ae3b67e59 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/vert/block-struct-initializer.asm.vert @@ -0,0 +1,43 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 13 +; Schema: 0 +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint Vertex %main "main" %_ %foo %gl_Position +OpSource GLSL 450 +OpName %main "main" +OpName %Vert "Vert" +OpMemberName %Vert 0 "a" +OpMemberName %Vert 1 "b" +OpName %_ "" +OpName %Foo "Foo" +OpMemberName %Foo 0 "c" +OpMemberName %Foo 1 "d" +OpName %foo "foo" +OpDecorate %Vert Block +OpDecorate %_ Location 0 +OpDecorate %foo Location 2 +OpDecorate %gl_Position BuiltIn Position +%void = OpTypeVoid +%3 = OpTypeFunction %void +%float = OpTypeFloat 32 +%Vert = OpTypeStruct %float %float +%vec4 = OpTypeVector %float 4 +%ptr_Output_vec4 = OpTypePointer Output %vec4 +%_ptr_Output_Vert = OpTypePointer Output %Vert +%zero_vert = OpConstantNull %Vert +%_ = OpVariable %_ptr_Output_Vert Output %zero_vert +%gl_Position = OpVariable %ptr_Output_vec4 Output +%Foo = OpTypeStruct %float %float +%_ptr_Output_Foo = OpTypePointer Output %Foo +%zero_foo = OpConstantNull %Foo +%blank = OpConstantNull %vec4 +%foo = OpVariable %_ptr_Output_Foo Output %zero_foo +%main = OpFunction %void None %3 +%5 = OpLabel +OpStore %gl_Position %blank +OpReturn +OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/vert/builtin-output-initializer.asm.vert b/third_party/spirv-cross/shaders-msl-no-opt/asm/vert/builtin-output-initializer.asm.vert new file mode 100644 index 0000000000..a00d4b71bb --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/vert/builtin-output-initializer.asm.vert @@ -0,0 +1,39 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 20 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %_ + OpSource GLSL 450 + OpName %main "main" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpName %_ "" + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpDecorate %gl_PerVertex Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%gl_PerVertex = OpTypeStruct %v4float %float +%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex + %zero = OpConstantNull %gl_PerVertex + %_ = OpVariable %_ptr_Output_gl_PerVertex Output %zero + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %float_1 = OpConstant %float 1 + %17 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %main = OpFunction %void None %3 + %5 = OpLabel + %19 = OpAccessChain %_ptr_Output_v4float %_ %int_0 + OpStore %19 %17 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/vert/duplicate-view-index.asm.vert b/third_party/spirv-cross/shaders-msl-no-opt/asm/vert/duplicate-view-index.asm.vert new file mode 100644 index 0000000000..00ad1ee9cb --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/vert/duplicate-view-index.asm.vert @@ -0,0 +1,66 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 23 +; Schema: 0 + OpCapability Shader + OpCapability MultiView + OpExtension "SPV_KHR_multiview" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %_ %gl_ViewIndex + OpEntryPoint Vertex %main2 "main2" %_ %gl_ViewIndex2 + OpSource GLSL 450 + OpSourceExtension "GL_EXT_multiview" + OpName %main "main" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %_ "" + OpName %gl_ViewIndex "gl_ViewIndex" + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + OpDecorate %gl_ViewIndex BuiltIn ViewIndex + OpDecorate %gl_ViewIndex2 BuiltIn ViewIndex + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex + %_ = OpVariable %_ptr_Output_gl_PerVertex Output + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%_ptr_Input_int = OpTypePointer Input %int +%gl_ViewIndex = OpVariable %_ptr_Input_int Input +%gl_ViewIndex2 = OpVariable %_ptr_Input_int Input +%_ptr_Output_v4float = OpTypePointer Output %v4float + + %main = OpFunction %void None %3 + %5 = OpLabel + %18 = OpLoad %int %gl_ViewIndex + %19 = OpConvertSToF %float %18 + %20 = OpCompositeConstruct %v4float %19 %19 %19 %19 + %22 = OpAccessChain %_ptr_Output_v4float %_ %int_0 + OpStore %22 %20 + OpReturn + OpFunctionEnd + + %main2 = OpFunction %void None %3 + %100 = OpLabel + %101 = OpLoad %int %gl_ViewIndex2 + %102 = OpConvertSToF %float %101 + %103 = OpCompositeConstruct %v4float %102 %102 %102 %102 + %104 = OpAccessChain %_ptr_Output_v4float %_ %int_0 + OpStore %104 %103 + + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/vert/pointer-to-pointer.asm.vert b/third_party/spirv-cross/shaders-msl-no-opt/asm/vert/pointer-to-pointer.asm.vert new file mode 100644 index 0000000000..22058d2c8c --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/vert/pointer-to-pointer.asm.vert @@ -0,0 +1,34 @@ +OpCapability Shader +OpCapability VariablePointers +OpCapability VariablePointersStorageBuffer +OpMemoryModel Logical GLSL450 + +OpEntryPoint Vertex %fn_vert "main" + +%F = OpTypeFloat 32 +%PF = OpTypePointer StorageBuffer %F +%PPF = OpTypePointer Private %PF +%PPPF = OpTypePointer Function %PPF + +%V = OpTypeVoid +%Fn0V = OpTypeFunction %V + +%FnArg = OpTypeFunction %V %PPPF + +%uPPF = OpUndef %PPF + +%fn_ptr = OpFunction %V None %FnArg + %arg = OpFunctionParameter %PPPF + %fn_ptr_bb0 = OpLabel + OpReturn +OpFunctionEnd + +%fn_vert = OpFunction %V None %Fn0V + %fn_vert_bb0 = OpLabel + %VPPPF = OpVariable %PPPF Function + OpStore %VPPPF %uPPF + %VV = OpFunctionCall %V %fn_ptr %VPPPF + OpReturn +OpFunctionEnd + + diff --git a/third_party/spirv-cross/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl12.emulate-subgroup.comp b/third_party/spirv-cross/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl12.emulate-subgroup.comp new file mode 100644 index 0000000000..8a0be2269e --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl12.emulate-subgroup.comp @@ -0,0 +1,25 @@ +#version 450 +#extension GL_KHR_shader_subgroup_basic : require +layout(local_size_x = 1) in; + +layout(std430, binding = 0) buffer SSBO +{ + float FragColor; +}; + +// Reduced test for emulated functionality. + +void main() +{ + // basic + FragColor = float(gl_NumSubgroups); + FragColor = float(gl_SubgroupID); + FragColor = float(gl_SubgroupSize); + FragColor = float(gl_SubgroupInvocationID); + subgroupBarrier(); + subgroupMemoryBarrier(); + subgroupMemoryBarrierBuffer(); + subgroupMemoryBarrierShared(); + subgroupMemoryBarrierImage(); + bool elected = subgroupElect(); +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl21.comp b/third_party/spirv-cross/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl21.comp index 28c5d6b34d..f840d2aee8 100644 --- a/third_party/spirv-cross/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl21.comp +++ b/third_party/spirv-cross/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl21.comp @@ -81,6 +81,9 @@ void main() uvec4 anded = subgroupAnd(ballot_value); uvec4 ored = subgroupOr(ballot_value); uvec4 xored = subgroupXor(ballot_value); + bvec4 anded_b = subgroupAnd(equal(ballot_value, uvec4(42))); + bvec4 ored_b = subgroupOr(equal(ballot_value, uvec4(42))); + bvec4 xored_b = subgroupXor(equal(ballot_value, uvec4(42))); added = subgroupInclusiveAdd(added); iadded = subgroupInclusiveAdd(iadded); @@ -126,6 +129,10 @@ void main() ored = subgroupClusteredOr(ored, 4u); xored = subgroupClusteredXor(xored, 4u); + anded_b = subgroupClusteredAnd(equal(anded, uvec4(2u)), 4u); + ored_b = subgroupClusteredOr(equal(ored, uvec4(3u)), 4u); + xored_b = subgroupClusteredXor(equal(xored, uvec4(4u)), 4u); + // quad vec4 swap_horiz = subgroupQuadSwapHorizontal(vec4(20.0)); bvec4 swap_horiz_bool = subgroupQuadSwapHorizontal(bvec4(true)); diff --git a/third_party/spirv-cross/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl21.fixed-subgroup.comp b/third_party/spirv-cross/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl21.fixed-subgroup.comp new file mode 100644 index 0000000000..28c5d6b34d --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl21.fixed-subgroup.comp @@ -0,0 +1,138 @@ +#version 450 +#extension GL_KHR_shader_subgroup_basic : require +#extension GL_KHR_shader_subgroup_ballot : require +#extension GL_KHR_shader_subgroup_vote : require +#extension GL_KHR_shader_subgroup_shuffle : require +#extension GL_KHR_shader_subgroup_shuffle_relative : require +#extension GL_KHR_shader_subgroup_arithmetic : require +#extension GL_KHR_shader_subgroup_clustered : require +#extension GL_KHR_shader_subgroup_quad : require +layout(local_size_x = 1) in; + +layout(std430, binding = 0) buffer SSBO +{ + float FragColor; +}; + +void main() +{ + // basic + FragColor = float(gl_NumSubgroups); + FragColor = float(gl_SubgroupID); + FragColor = float(gl_SubgroupSize); + FragColor = float(gl_SubgroupInvocationID); + subgroupBarrier(); + subgroupMemoryBarrier(); + subgroupMemoryBarrierBuffer(); + subgroupMemoryBarrierShared(); + subgroupMemoryBarrierImage(); + bool elected = subgroupElect(); + + // ballot + FragColor = float(gl_SubgroupEqMask); + FragColor = float(gl_SubgroupGeMask); + FragColor = float(gl_SubgroupGtMask); + FragColor = float(gl_SubgroupLeMask); + FragColor = float(gl_SubgroupLtMask); + vec4 broadcasted = subgroupBroadcast(vec4(10.0), 8u); + bvec2 broadcasted_bool = subgroupBroadcast(bvec2(true), 8u); + vec3 first = subgroupBroadcastFirst(vec3(20.0)); + bvec4 first_bool = subgroupBroadcastFirst(bvec4(false)); + uvec4 ballot_value = subgroupBallot(true); + bool inverse_ballot_value = subgroupInverseBallot(ballot_value); + bool bit_extracted = subgroupBallotBitExtract(uvec4(10u), 8u); + uint bit_count = subgroupBallotBitCount(ballot_value); + uint inclusive_bit_count = subgroupBallotInclusiveBitCount(ballot_value); + uint exclusive_bit_count = subgroupBallotExclusiveBitCount(ballot_value); + uint lsb = subgroupBallotFindLSB(ballot_value); + uint msb = subgroupBallotFindMSB(ballot_value); + + // shuffle + uint shuffled = subgroupShuffle(10u, 8u); + bool shuffled_bool = subgroupShuffle(true, 9u); + uint shuffled_xor = subgroupShuffleXor(30u, 8u); + bool shuffled_xor_bool = subgroupShuffleXor(false, 9u); + + // shuffle relative + uint shuffled_up = subgroupShuffleUp(20u, 4u); + bool shuffled_up_bool = subgroupShuffleUp(true, 4u); + uint shuffled_down = subgroupShuffleDown(20u, 4u); + bool shuffled_down_bool = subgroupShuffleDown(false, 4u); + + // vote + bool has_all = subgroupAll(true); + bool has_any = subgroupAny(true); + bool has_equal = subgroupAllEqual(0); + has_equal = subgroupAllEqual(true); + has_equal = subgroupAllEqual(vec3(0.0, 1.0, 2.0)); + has_equal = subgroupAllEqual(bvec4(true, true, false, true)); + + // arithmetic + vec4 added = subgroupAdd(vec4(20.0)); + ivec4 iadded = subgroupAdd(ivec4(20)); + vec4 multiplied = subgroupMul(vec4(20.0)); + ivec4 imultiplied = subgroupMul(ivec4(20)); + vec4 lo = subgroupMin(vec4(20.0)); + vec4 hi = subgroupMax(vec4(20.0)); + ivec4 slo = subgroupMin(ivec4(20)); + ivec4 shi = subgroupMax(ivec4(20)); + uvec4 ulo = subgroupMin(uvec4(20)); + uvec4 uhi = subgroupMax(uvec4(20)); + uvec4 anded = subgroupAnd(ballot_value); + uvec4 ored = subgroupOr(ballot_value); + uvec4 xored = subgroupXor(ballot_value); + + added = subgroupInclusiveAdd(added); + iadded = subgroupInclusiveAdd(iadded); + multiplied = subgroupInclusiveMul(multiplied); + imultiplied = subgroupInclusiveMul(imultiplied); + //lo = subgroupInclusiveMin(lo); // FIXME: Unsupported by Metal + //hi = subgroupInclusiveMax(hi); + //slo = subgroupInclusiveMin(slo); + //shi = subgroupInclusiveMax(shi); + //ulo = subgroupInclusiveMin(ulo); + //uhi = subgroupInclusiveMax(uhi); + //anded = subgroupInclusiveAnd(anded); + //ored = subgroupInclusiveOr(ored); + //xored = subgroupInclusiveXor(ored); + //added = subgroupExclusiveAdd(lo); + + added = subgroupExclusiveAdd(multiplied); + multiplied = subgroupExclusiveMul(multiplied); + iadded = subgroupExclusiveAdd(imultiplied); + imultiplied = subgroupExclusiveMul(imultiplied); + //lo = subgroupExclusiveMin(lo); // FIXME: Unsupported by Metal + //hi = subgroupExclusiveMax(hi); + //ulo = subgroupExclusiveMin(ulo); + //uhi = subgroupExclusiveMax(uhi); + //slo = subgroupExclusiveMin(slo); + //shi = subgroupExclusiveMax(shi); + //anded = subgroupExclusiveAnd(anded); + //ored = subgroupExclusiveOr(ored); + //xored = subgroupExclusiveXor(ored); + + // clustered + added = subgroupClusteredAdd(added, 4u); + multiplied = subgroupClusteredMul(multiplied, 4u); + iadded = subgroupClusteredAdd(iadded, 4u); + imultiplied = subgroupClusteredMul(imultiplied, 4u); + lo = subgroupClusteredMin(lo, 4u); + hi = subgroupClusteredMax(hi, 4u); + ulo = subgroupClusteredMin(ulo, 4u); + uhi = subgroupClusteredMax(uhi, 4u); + slo = subgroupClusteredMin(slo, 4u); + shi = subgroupClusteredMax(shi, 4u); + anded = subgroupClusteredAnd(anded, 4u); + ored = subgroupClusteredOr(ored, 4u); + xored = subgroupClusteredXor(xored, 4u); + + // quad + vec4 swap_horiz = subgroupQuadSwapHorizontal(vec4(20.0)); + bvec4 swap_horiz_bool = subgroupQuadSwapHorizontal(bvec4(true)); + vec4 swap_vertical = subgroupQuadSwapVertical(vec4(20.0)); + bvec4 swap_vertical_bool = subgroupQuadSwapVertical(bvec4(true)); + vec4 swap_diagonal = subgroupQuadSwapDiagonal(vec4(20.0)); + bvec4 swap_diagonal_bool = subgroupQuadSwapDiagonal(bvec4(true)); + vec4 quad_broadcast = subgroupQuadBroadcast(vec4(20.0), 3u); + bvec4 quad_broadcast_bool = subgroupQuadBroadcast(bvec4(true), 3u); +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl22.ios.comp b/third_party/spirv-cross/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl22.ios.comp new file mode 100644 index 0000000000..bc904a4f75 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl22.ios.comp @@ -0,0 +1,79 @@ +#version 450 +#extension GL_KHR_shader_subgroup_basic : require +#extension GL_KHR_shader_subgroup_ballot : require +#extension GL_KHR_shader_subgroup_vote : require +#extension GL_KHR_shader_subgroup_shuffle : require +#extension GL_KHR_shader_subgroup_shuffle_relative : require +#extension GL_KHR_shader_subgroup_quad : require +layout(local_size_x = 1) in; + +layout(std430, binding = 0) buffer SSBO +{ + float FragColor; +}; + +// Reduced test for functionality exposed on iOS. + +void main() +{ + // basic + FragColor = float(gl_NumSubgroups); + FragColor = float(gl_SubgroupID); + FragColor = float(gl_SubgroupSize); + FragColor = float(gl_SubgroupInvocationID); + subgroupBarrier(); + subgroupMemoryBarrier(); + subgroupMemoryBarrierBuffer(); + subgroupMemoryBarrierShared(); + subgroupMemoryBarrierImage(); + bool elected = subgroupElect(); + + // ballot + FragColor = float(gl_SubgroupEqMask); + FragColor = float(gl_SubgroupGeMask); + FragColor = float(gl_SubgroupGtMask); + FragColor = float(gl_SubgroupLeMask); + FragColor = float(gl_SubgroupLtMask); + vec4 broadcasted = subgroupBroadcast(vec4(10.0), 8u); + bvec2 broadcasted_bool = subgroupBroadcast(bvec2(true), 8u); + vec3 first = subgroupBroadcastFirst(vec3(20.0)); + bvec4 first_bool = subgroupBroadcastFirst(bvec4(false)); + uvec4 ballot_value = subgroupBallot(true); + bool inverse_ballot_value = subgroupInverseBallot(ballot_value); + bool bit_extracted = subgroupBallotBitExtract(uvec4(10u), 8u); + uint bit_count = subgroupBallotBitCount(ballot_value); + uint inclusive_bit_count = subgroupBallotInclusiveBitCount(ballot_value); + uint exclusive_bit_count = subgroupBallotExclusiveBitCount(ballot_value); + uint lsb = subgroupBallotFindLSB(ballot_value); + uint msb = subgroupBallotFindMSB(ballot_value); + + // shuffle + uint shuffled = subgroupShuffle(10u, 8u); + bool shuffled_bool = subgroupShuffle(true, 9u); + uint shuffled_xor = subgroupShuffleXor(30u, 8u); + bool shuffled_xor_bool = subgroupShuffleXor(false, 9u); + + // shuffle relative + uint shuffled_up = subgroupShuffleUp(20u, 4u); + bool shuffled_up_bool = subgroupShuffleUp(true, 4u); + uint shuffled_down = subgroupShuffleDown(20u, 4u); + bool shuffled_down_bool = subgroupShuffleDown(false, 4u); + + // vote + bool has_all = subgroupAll(true); + bool has_any = subgroupAny(true); + bool has_equal = subgroupAllEqual(0); + has_equal = subgroupAllEqual(true); + has_equal = subgroupAllEqual(vec3(0.0, 1.0, 2.0)); + has_equal = subgroupAllEqual(bvec4(true, true, false, true)); + + // quad + vec4 swap_horiz = subgroupQuadSwapHorizontal(vec4(20.0)); + bvec4 swap_horiz_bool = subgroupQuadSwapHorizontal(bvec4(true)); + vec4 swap_vertical = subgroupQuadSwapVertical(vec4(20.0)); + bvec4 swap_vertical_bool = subgroupQuadSwapVertical(bvec4(true)); + vec4 swap_diagonal = subgroupQuadSwapDiagonal(vec4(20.0)); + bvec4 swap_diagonal_bool = subgroupQuadSwapDiagonal(bvec4(true)); + vec4 quad_broadcast = subgroupQuadBroadcast(vec4(20.0), 3u); + bvec4 quad_broadcast_bool = subgroupQuadBroadcast(bvec4(true), 3u); +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl23.ios.simd.comp b/third_party/spirv-cross/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl23.ios.simd.comp new file mode 100644 index 0000000000..28c5d6b34d --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/comp/subgroups.nocompat.invalid.vk.msl23.ios.simd.comp @@ -0,0 +1,138 @@ +#version 450 +#extension GL_KHR_shader_subgroup_basic : require +#extension GL_KHR_shader_subgroup_ballot : require +#extension GL_KHR_shader_subgroup_vote : require +#extension GL_KHR_shader_subgroup_shuffle : require +#extension GL_KHR_shader_subgroup_shuffle_relative : require +#extension GL_KHR_shader_subgroup_arithmetic : require +#extension GL_KHR_shader_subgroup_clustered : require +#extension GL_KHR_shader_subgroup_quad : require +layout(local_size_x = 1) in; + +layout(std430, binding = 0) buffer SSBO +{ + float FragColor; +}; + +void main() +{ + // basic + FragColor = float(gl_NumSubgroups); + FragColor = float(gl_SubgroupID); + FragColor = float(gl_SubgroupSize); + FragColor = float(gl_SubgroupInvocationID); + subgroupBarrier(); + subgroupMemoryBarrier(); + subgroupMemoryBarrierBuffer(); + subgroupMemoryBarrierShared(); + subgroupMemoryBarrierImage(); + bool elected = subgroupElect(); + + // ballot + FragColor = float(gl_SubgroupEqMask); + FragColor = float(gl_SubgroupGeMask); + FragColor = float(gl_SubgroupGtMask); + FragColor = float(gl_SubgroupLeMask); + FragColor = float(gl_SubgroupLtMask); + vec4 broadcasted = subgroupBroadcast(vec4(10.0), 8u); + bvec2 broadcasted_bool = subgroupBroadcast(bvec2(true), 8u); + vec3 first = subgroupBroadcastFirst(vec3(20.0)); + bvec4 first_bool = subgroupBroadcastFirst(bvec4(false)); + uvec4 ballot_value = subgroupBallot(true); + bool inverse_ballot_value = subgroupInverseBallot(ballot_value); + bool bit_extracted = subgroupBallotBitExtract(uvec4(10u), 8u); + uint bit_count = subgroupBallotBitCount(ballot_value); + uint inclusive_bit_count = subgroupBallotInclusiveBitCount(ballot_value); + uint exclusive_bit_count = subgroupBallotExclusiveBitCount(ballot_value); + uint lsb = subgroupBallotFindLSB(ballot_value); + uint msb = subgroupBallotFindMSB(ballot_value); + + // shuffle + uint shuffled = subgroupShuffle(10u, 8u); + bool shuffled_bool = subgroupShuffle(true, 9u); + uint shuffled_xor = subgroupShuffleXor(30u, 8u); + bool shuffled_xor_bool = subgroupShuffleXor(false, 9u); + + // shuffle relative + uint shuffled_up = subgroupShuffleUp(20u, 4u); + bool shuffled_up_bool = subgroupShuffleUp(true, 4u); + uint shuffled_down = subgroupShuffleDown(20u, 4u); + bool shuffled_down_bool = subgroupShuffleDown(false, 4u); + + // vote + bool has_all = subgroupAll(true); + bool has_any = subgroupAny(true); + bool has_equal = subgroupAllEqual(0); + has_equal = subgroupAllEqual(true); + has_equal = subgroupAllEqual(vec3(0.0, 1.0, 2.0)); + has_equal = subgroupAllEqual(bvec4(true, true, false, true)); + + // arithmetic + vec4 added = subgroupAdd(vec4(20.0)); + ivec4 iadded = subgroupAdd(ivec4(20)); + vec4 multiplied = subgroupMul(vec4(20.0)); + ivec4 imultiplied = subgroupMul(ivec4(20)); + vec4 lo = subgroupMin(vec4(20.0)); + vec4 hi = subgroupMax(vec4(20.0)); + ivec4 slo = subgroupMin(ivec4(20)); + ivec4 shi = subgroupMax(ivec4(20)); + uvec4 ulo = subgroupMin(uvec4(20)); + uvec4 uhi = subgroupMax(uvec4(20)); + uvec4 anded = subgroupAnd(ballot_value); + uvec4 ored = subgroupOr(ballot_value); + uvec4 xored = subgroupXor(ballot_value); + + added = subgroupInclusiveAdd(added); + iadded = subgroupInclusiveAdd(iadded); + multiplied = subgroupInclusiveMul(multiplied); + imultiplied = subgroupInclusiveMul(imultiplied); + //lo = subgroupInclusiveMin(lo); // FIXME: Unsupported by Metal + //hi = subgroupInclusiveMax(hi); + //slo = subgroupInclusiveMin(slo); + //shi = subgroupInclusiveMax(shi); + //ulo = subgroupInclusiveMin(ulo); + //uhi = subgroupInclusiveMax(uhi); + //anded = subgroupInclusiveAnd(anded); + //ored = subgroupInclusiveOr(ored); + //xored = subgroupInclusiveXor(ored); + //added = subgroupExclusiveAdd(lo); + + added = subgroupExclusiveAdd(multiplied); + multiplied = subgroupExclusiveMul(multiplied); + iadded = subgroupExclusiveAdd(imultiplied); + imultiplied = subgroupExclusiveMul(imultiplied); + //lo = subgroupExclusiveMin(lo); // FIXME: Unsupported by Metal + //hi = subgroupExclusiveMax(hi); + //ulo = subgroupExclusiveMin(ulo); + //uhi = subgroupExclusiveMax(uhi); + //slo = subgroupExclusiveMin(slo); + //shi = subgroupExclusiveMax(shi); + //anded = subgroupExclusiveAnd(anded); + //ored = subgroupExclusiveOr(ored); + //xored = subgroupExclusiveXor(ored); + + // clustered + added = subgroupClusteredAdd(added, 4u); + multiplied = subgroupClusteredMul(multiplied, 4u); + iadded = subgroupClusteredAdd(iadded, 4u); + imultiplied = subgroupClusteredMul(imultiplied, 4u); + lo = subgroupClusteredMin(lo, 4u); + hi = subgroupClusteredMax(hi, 4u); + ulo = subgroupClusteredMin(ulo, 4u); + uhi = subgroupClusteredMax(uhi, 4u); + slo = subgroupClusteredMin(slo, 4u); + shi = subgroupClusteredMax(shi, 4u); + anded = subgroupClusteredAnd(anded, 4u); + ored = subgroupClusteredOr(ored, 4u); + xored = subgroupClusteredXor(xored, 4u); + + // quad + vec4 swap_horiz = subgroupQuadSwapHorizontal(vec4(20.0)); + bvec4 swap_horiz_bool = subgroupQuadSwapHorizontal(bvec4(true)); + vec4 swap_vertical = subgroupQuadSwapVertical(vec4(20.0)); + bvec4 swap_vertical_bool = subgroupQuadSwapVertical(bvec4(true)); + vec4 swap_diagonal = subgroupQuadSwapDiagonal(vec4(20.0)); + bvec4 swap_diagonal_bool = subgroupQuadSwapDiagonal(bvec4(true)); + vec4 quad_broadcast = subgroupQuadBroadcast(vec4(20.0), 3u); + bvec4 quad_broadcast_bool = subgroupQuadBroadcast(bvec4(true), 3u); +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/frag/nonuniform-constructor.msl2.frag b/third_party/spirv-cross/shaders-msl-no-opt/frag/nonuniform-constructor.msl2.frag new file mode 100644 index 0000000000..4e0460afbb --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/frag/nonuniform-constructor.msl2.frag @@ -0,0 +1,14 @@ +#version 450 +#extension GL_EXT_nonuniform_qualifier : require + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec2 vUV; +layout(location = 1) flat in int vIndex; + +layout(set = 0, binding = 0) uniform texture2D uTex[10]; +layout(set = 1, binding = 0) uniform sampler Immut; + +void main() +{ + FragColor = texture(nonuniformEXT(sampler2D(uTex[vIndex], Immut)), vUV); +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/frag/subgroups.nocompat.invalid.vk.msl21.frag b/third_party/spirv-cross/shaders-msl-no-opt/frag/subgroups.nocompat.invalid.vk.msl22.frag similarity index 100% rename from third_party/spirv-cross/shaders-msl-no-opt/frag/subgroups.nocompat.invalid.vk.msl21.frag rename to third_party/spirv-cross/shaders-msl-no-opt/frag/subgroups.nocompat.invalid.vk.msl22.frag diff --git a/third_party/spirv-cross/shaders-msl-no-opt/frag/subpass-input.decoration-binding.framebuffer-fetch.msl23.argument.frag b/third_party/spirv-cross/shaders-msl-no-opt/frag/subpass-input.decoration-binding.framebuffer-fetch.msl23.argument.frag new file mode 100644 index 0000000000..671a4d1b41 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/frag/subpass-input.decoration-binding.framebuffer-fetch.msl23.argument.frag @@ -0,0 +1,12 @@ +#version 450 + +layout(set = 0, binding = 10, input_attachment_index = 1) uniform subpassInput uSub; +layout(location = 0) out vec4 FragColor; + +layout(set = 0, binding = 9) uniform texture2D uTex; +layout(set = 0, binding = 8) uniform sampler uSampler; + +void main() +{ + FragColor = subpassLoad(uSub) + texture(sampler2D(uTex, uSampler), vec2(0.5)); +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/frag/subpass-input.decoration-binding.framebuffer-fetch.msl23.frag b/third_party/spirv-cross/shaders-msl-no-opt/frag/subpass-input.decoration-binding.framebuffer-fetch.msl23.frag new file mode 100644 index 0000000000..671a4d1b41 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/frag/subpass-input.decoration-binding.framebuffer-fetch.msl23.frag @@ -0,0 +1,12 @@ +#version 450 + +layout(set = 0, binding = 10, input_attachment_index = 1) uniform subpassInput uSub; +layout(location = 0) out vec4 FragColor; + +layout(set = 0, binding = 9) uniform texture2D uTex; +layout(set = 0, binding = 8) uniform sampler uSampler; + +void main() +{ + FragColor = subpassLoad(uSub) + texture(sampler2D(uTex, uSampler), vec2(0.5)); +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/frag/subpass-input.decoration-binding.ios.framebuffer-fetch.msl2.argument.frag b/third_party/spirv-cross/shaders-msl-no-opt/frag/subpass-input.decoration-binding.ios.framebuffer-fetch.msl2.argument.frag new file mode 100644 index 0000000000..671a4d1b41 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/frag/subpass-input.decoration-binding.ios.framebuffer-fetch.msl2.argument.frag @@ -0,0 +1,12 @@ +#version 450 + +layout(set = 0, binding = 10, input_attachment_index = 1) uniform subpassInput uSub; +layout(location = 0) out vec4 FragColor; + +layout(set = 0, binding = 9) uniform texture2D uTex; +layout(set = 0, binding = 8) uniform sampler uSampler; + +void main() +{ + FragColor = subpassLoad(uSub) + texture(sampler2D(uTex, uSampler), vec2(0.5)); +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/frag/subpass-input.decoration-binding.ios.framebuffer-fetch.msl2.frag b/third_party/spirv-cross/shaders-msl-no-opt/frag/subpass-input.decoration-binding.ios.framebuffer-fetch.msl2.frag new file mode 100644 index 0000000000..671a4d1b41 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/frag/subpass-input.decoration-binding.ios.framebuffer-fetch.msl2.frag @@ -0,0 +1,12 @@ +#version 450 + +layout(set = 0, binding = 10, input_attachment_index = 1) uniform subpassInput uSub; +layout(location = 0) out vec4 FragColor; + +layout(set = 0, binding = 9) uniform texture2D uTex; +layout(set = 0, binding = 8) uniform sampler uSampler; + +void main() +{ + FragColor = subpassLoad(uSub) + texture(sampler2D(uTex, uSampler), vec2(0.5)); +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/tesc/copy-tess-level.tesc b/third_party/spirv-cross/shaders-msl-no-opt/tesc/copy-tess-level.tesc new file mode 100644 index 0000000000..7510ff8f67 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/tesc/copy-tess-level.tesc @@ -0,0 +1,12 @@ +#version 450 +layout(vertices = 1) out; + +void main() +{ + gl_TessLevelInner = float[](1.0, 2.0); + gl_TessLevelOuter = float[](1.0, 2.0, 3.0, 4.0); + + float inner[2] = gl_TessLevelInner; + float outer[4] = gl_TessLevelOuter; + gl_out[gl_InvocationID].gl_Position = vec4(1.0); +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/tesc/passthrough-clip-cull.multi-patch.tesc b/third_party/spirv-cross/shaders-msl-no-opt/tesc/passthrough-clip-cull.multi-patch.tesc new file mode 100644 index 0000000000..16b60e495a --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/tesc/passthrough-clip-cull.multi-patch.tesc @@ -0,0 +1,22 @@ +#version 450 + +layout(vertices = 4) out; + +in gl_PerVertex +{ + float gl_ClipDistance[2]; + float gl_CullDistance[1]; +} gl_in[]; + +out gl_PerVertex +{ + float gl_ClipDistance[2]; + float gl_CullDistance[1]; +} gl_out[]; + +void main() +{ + gl_out[gl_InvocationID].gl_ClipDistance[0] = gl_in[gl_InvocationID].gl_ClipDistance[0]; + gl_out[gl_InvocationID].gl_ClipDistance[1] = gl_in[gl_InvocationID].gl_ClipDistance[1]; + gl_out[gl_InvocationID].gl_CullDistance[0] = gl_in[gl_InvocationID].gl_CullDistance[0]; +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/tesc/tess-level-read-write-in-function-quad.tesc b/third_party/spirv-cross/shaders-msl-no-opt/tesc/tess-level-read-write-in-function-quad.tesc new file mode 100644 index 0000000000..4ccfa28267 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/tesc/tess-level-read-write-in-function-quad.tesc @@ -0,0 +1,24 @@ +#version 450 +layout(vertices = 1) out; + +float load_tess_level_in_func() +{ + return gl_TessLevelInner[0] + gl_TessLevelOuter[1]; +} + +void store_tess_level_in_func() +{ + gl_TessLevelInner[0] = 1.0; + gl_TessLevelInner[1] = 2.0; + gl_TessLevelOuter[0] = 3.0; + gl_TessLevelOuter[1] = 4.0; + gl_TessLevelOuter[2] = 5.0; + gl_TessLevelOuter[3] = 6.0; +} + +void main() +{ + store_tess_level_in_func(); + float v = load_tess_level_in_func(); + gl_out[gl_InvocationID].gl_Position = vec4(v); +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/tese/builtin-input-automatic-attribute-assignment.tese b/third_party/spirv-cross/shaders-msl-no-opt/tese/builtin-input-automatic-attribute-assignment.tese new file mode 100644 index 0000000000..1d8a50062e --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/tese/builtin-input-automatic-attribute-assignment.tese @@ -0,0 +1,10 @@ +#version 450 +layout(quads) in; + +layout(location = 0) patch in vec4 FragColor; +layout(location = 2) in vec4 FragColors[]; + +void main() +{ + gl_Position = vec4(1.0) + FragColor + FragColors[0] + FragColors[1] + gl_TessLevelInner[0] + gl_TessLevelOuter[gl_PrimitiveID & 1] + gl_in[0].gl_Position; +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/tese/load-clip-cull.msl2.tese b/third_party/spirv-cross/shaders-msl-no-opt/tese/load-clip-cull.msl2.tese new file mode 100644 index 0000000000..e86619e1a0 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/tese/load-clip-cull.msl2.tese @@ -0,0 +1,19 @@ +#version 450 +layout(quads) in; + +in gl_PerVertex +{ + float gl_ClipDistance[2]; + float gl_CullDistance[3]; + vec4 gl_Position; +} gl_in[]; + +void main() +{ + gl_Position.x = gl_in[0].gl_ClipDistance[0]; + gl_Position.y = gl_in[1].gl_CullDistance[0]; + gl_Position.z = gl_in[0].gl_ClipDistance[1]; + gl_Position.w = gl_in[1].gl_CullDistance[1]; + gl_Position += gl_in[0].gl_Position; + gl_Position += gl_in[1].gl_Position; +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/vert/cull-distance.for-tess.vert b/third_party/spirv-cross/shaders-msl-no-opt/vert/cull-distance.for-tess.vert new file mode 100644 index 0000000000..8df181cdb3 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/vert/cull-distance.for-tess.vert @@ -0,0 +1,10 @@ +#version 450 + +out float gl_CullDistance[2]; + +void main() +{ + gl_CullDistance[0] = 1.0; + gl_CullDistance[1] = 3.0; + gl_Position = vec4(1.0); +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/vert/uninitialized-vertex-output.vert b/third_party/spirv-cross/shaders-msl-no-opt/vert/uninitialized-vertex-output.vert new file mode 100644 index 0000000000..54c7afd07a --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/vert/uninitialized-vertex-output.vert @@ -0,0 +1,8 @@ +#version 450 + +layout(location = 0) out vec4 Pos; + +void main() +{ + gl_Position = vec4(1.0); +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/vert/unused-subgroup-builtin.msl22.vert b/third_party/spirv-cross/shaders-msl-no-opt/vert/unused-subgroup-builtin.msl22.vert new file mode 100644 index 0000000000..4ec228df29 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/vert/unused-subgroup-builtin.msl22.vert @@ -0,0 +1,7 @@ +#version 450 +#extension GL_KHR_shader_subgroup_ballot : require + +void main() +{ + gl_SubgroupEqMask; +} diff --git a/third_party/spirv-cross/shaders-msl/asm/comp/image-load-store-short-vector.asm.comp b/third_party/spirv-cross/shaders-msl/asm/comp/image-load-store-short-vector.invalid.asm.comp similarity index 100% rename from third_party/spirv-cross/shaders-msl/asm/comp/image-load-store-short-vector.asm.comp rename to third_party/spirv-cross/shaders-msl/asm/comp/image-load-store-short-vector.invalid.asm.comp diff --git a/third_party/spirv-cross/shaders-msl/frag/array-component-io.frag b/third_party/spirv-cross/shaders-msl/frag/array-component-io.frag new file mode 100644 index 0000000000..8d88249e78 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/frag/array-component-io.frag @@ -0,0 +1,21 @@ +#version 450 + +layout(location = 1, component = 0) out float A[2]; +layout(location = 1, component = 2) out vec2 B[2]; +layout(location = 0, component = 1) out float C[3]; +layout(location = 0, component = 3) out float D; + +layout(location = 1, component = 0) flat in float InA[2]; +layout(location = 1, component = 2) flat in vec2 InB[2]; +layout(location = 0, component = 1) flat in float InC[3]; +layout(location = 3, component = 1) sample in float InD; +layout(location = 4, component = 2) noperspective in float InE; +layout(location = 5, component = 3) centroid in float InF; + +void main() +{ + A = InA; + B = InB; + C = InC; + D = InD + InE + InF; +} diff --git a/third_party/spirv-cross/shaders-msl/frag/basic.force-sample.frag b/third_party/spirv-cross/shaders-msl/frag/basic.force-sample.frag new file mode 100644 index 0000000000..dd9a8f8507 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/frag/basic.force-sample.frag @@ -0,0 +1,13 @@ +#version 310 es +precision mediump float; + +layout(location = 0) in vec4 vColor; +layout(location = 1) in vec2 vTex; +layout(binding = 0) uniform sampler2D uTex; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vColor * texture(uTex, vTex); +} + diff --git a/third_party/spirv-cross/shaders-msl/frag/cull-distance-varying.frag b/third_party/spirv-cross/shaders-msl/frag/cull-distance-varying.frag new file mode 100644 index 0000000000..8bade07e1d --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/frag/cull-distance-varying.frag @@ -0,0 +1,10 @@ +#version 450 + +in float gl_CullDistance[2]; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vec4(1.0 - gl_CullDistance[0] - gl_CullDistance[1]); +} diff --git a/third_party/spirv-cross/shaders-msl/frag/read-cull-clip-distance-in-function.frag b/third_party/spirv-cross/shaders-msl/frag/read-cull-clip-distance-in-function.frag new file mode 100644 index 0000000000..0b82dc2df9 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/frag/read-cull-clip-distance-in-function.frag @@ -0,0 +1,20 @@ +#version 450 + +layout(location = 0) out vec4 FragColor; + +in float gl_CullDistance[2]; +in float gl_ClipDistance[2]; + +vec4 read_in_func() +{ + return vec4( + gl_CullDistance[0], + gl_CullDistance[1], + gl_ClipDistance[0], + gl_ClipDistance[1]); +} + +void main() +{ + FragColor = read_in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/frag/sample-rate-frag-coord-sample-id.frag b/third_party/spirv-cross/shaders-msl/frag/sample-rate-frag-coord-sample-id.frag new file mode 100644 index 0000000000..202dba0bdf --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/frag/sample-rate-frag-coord-sample-id.frag @@ -0,0 +1,10 @@ +#version 450 + +layout(set = 0, binding = 0) uniform sampler2DArray tex; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = texture(tex, vec3(gl_FragCoord.xy, float(gl_SampleID))); +} diff --git a/third_party/spirv-cross/shaders-msl/frag/sample-rate-frag-coord-sample-input.frag b/third_party/spirv-cross/shaders-msl/frag/sample-rate-frag-coord-sample-input.frag new file mode 100644 index 0000000000..b131fb032c --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/frag/sample-rate-frag-coord-sample-input.frag @@ -0,0 +1,11 @@ +#version 450 + +layout(set = 0, binding = 0) uniform sampler2DArray tex; + +layout(location = 0) sample in float foo; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = texture(tex, vec3(gl_FragCoord.xy, foo)); +} diff --git a/third_party/spirv-cross/shaders-msl/frag/sample-rate-frag-coord-sample-pos.frag b/third_party/spirv-cross/shaders-msl/frag/sample-rate-frag-coord-sample-pos.frag new file mode 100644 index 0000000000..c8c3be96df --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/frag/sample-rate-frag-coord-sample-pos.frag @@ -0,0 +1,10 @@ +#version 450 + +layout(set = 0, binding = 0) uniform sampler2D tex; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = texture(tex, gl_FragCoord.xy - gl_SamplePosition); +} diff --git a/third_party/spirv-cross/shaders-msl/frag/sample-rate-frag-coord.force-sample.frag b/third_party/spirv-cross/shaders-msl/frag/sample-rate-frag-coord.force-sample.frag new file mode 100644 index 0000000000..a6b47e4bbe --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/frag/sample-rate-frag-coord.force-sample.frag @@ -0,0 +1,10 @@ +#version 450 + +layout(set = 0, binding = 0) uniform sampler2D tex; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = texture(tex, gl_FragCoord.xy); +} diff --git a/third_party/spirv-cross/shaders-msl/frag/subgroup-globals-extract.msl22.frag b/third_party/spirv-cross/shaders-msl/frag/subgroup-globals-extract.msl22.frag new file mode 100644 index 0000000000..f763163dc2 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/frag/subgroup-globals-extract.msl22.frag @@ -0,0 +1,30 @@ +#version 450 +#extension GL_KHR_shader_subgroup_basic : require +#extension GL_KHR_shader_subgroup_ballot : require + +layout(location = 0) out uvec2 FragColor; + +uint sub1() { + return subgroupBallotFindLSB(uvec4(1,2,3,4)); +} + +uint sub2() { + return subgroupBallotFindMSB(uvec4(1,2,3,4)); +} + +uint sub3() { + return subgroupBallotBitCount(uvec4(1,2,3,4)); +} + +uint sub4() { + return subgroupBallotInclusiveBitCount(uvec4(1,2,3,4)); +} + +uint sub5() { + return subgroupBallotExclusiveBitCount(uvec4(1,2,3,4)); +} + +void main() +{ + FragColor.x = sub1() + sub2() + sub3() + sub4() + sub5(); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/copy-arrays.mask-location-0.msl2.multi-patch.tesc b/third_party/spirv-cross/shaders-msl/masking/copy-arrays.mask-location-0.msl2.multi-patch.tesc new file mode 100644 index 0000000000..e69a7a1697 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/copy-arrays.mask-location-0.msl2.multi-patch.tesc @@ -0,0 +1,17 @@ +#version 450 + +layout(vertices = 4) out; +layout(location = 0) out vec4 Foo[][2]; +layout(location = 0) in vec4 iFoo[][2]; +layout(location = 2) patch out vec4 pFoo[2]; +layout(location = 2) in vec4 ipFoo[]; + +void main() +{ + gl_out[gl_InvocationID].gl_Position = vec4(1.0); + Foo[gl_InvocationID] = iFoo[gl_InvocationID]; + if (gl_InvocationID == 0) + { + pFoo = vec4[](ipFoo[0], ipFoo[1]); + } +} diff --git a/third_party/spirv-cross/shaders-msl/masking/copy-arrays.mask-location-0.msl2.tesc b/third_party/spirv-cross/shaders-msl/masking/copy-arrays.mask-location-0.msl2.tesc new file mode 100644 index 0000000000..e69a7a1697 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/copy-arrays.mask-location-0.msl2.tesc @@ -0,0 +1,17 @@ +#version 450 + +layout(vertices = 4) out; +layout(location = 0) out vec4 Foo[][2]; +layout(location = 0) in vec4 iFoo[][2]; +layout(location = 2) patch out vec4 pFoo[2]; +layout(location = 2) in vec4 ipFoo[]; + +void main() +{ + gl_out[gl_InvocationID].gl_Position = vec4(1.0); + Foo[gl_InvocationID] = iFoo[gl_InvocationID]; + if (gl_InvocationID == 0) + { + pFoo = vec4[](ipFoo[0], ipFoo[1]); + } +} diff --git a/third_party/spirv-cross/shaders-msl/masking/copy-arrays.mask-location-1.msl2.multi-patch.tesc b/third_party/spirv-cross/shaders-msl/masking/copy-arrays.mask-location-1.msl2.multi-patch.tesc new file mode 100644 index 0000000000..e69a7a1697 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/copy-arrays.mask-location-1.msl2.multi-patch.tesc @@ -0,0 +1,17 @@ +#version 450 + +layout(vertices = 4) out; +layout(location = 0) out vec4 Foo[][2]; +layout(location = 0) in vec4 iFoo[][2]; +layout(location = 2) patch out vec4 pFoo[2]; +layout(location = 2) in vec4 ipFoo[]; + +void main() +{ + gl_out[gl_InvocationID].gl_Position = vec4(1.0); + Foo[gl_InvocationID] = iFoo[gl_InvocationID]; + if (gl_InvocationID == 0) + { + pFoo = vec4[](ipFoo[0], ipFoo[1]); + } +} diff --git a/third_party/spirv-cross/shaders-msl/masking/copy-arrays.mask-location-1.msl2.tesc b/third_party/spirv-cross/shaders-msl/masking/copy-arrays.mask-location-1.msl2.tesc new file mode 100644 index 0000000000..e69a7a1697 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/copy-arrays.mask-location-1.msl2.tesc @@ -0,0 +1,17 @@ +#version 450 + +layout(vertices = 4) out; +layout(location = 0) out vec4 Foo[][2]; +layout(location = 0) in vec4 iFoo[][2]; +layout(location = 2) patch out vec4 pFoo[2]; +layout(location = 2) in vec4 ipFoo[]; + +void main() +{ + gl_out[gl_InvocationID].gl_Position = vec4(1.0); + Foo[gl_InvocationID] = iFoo[gl_InvocationID]; + if (gl_InvocationID == 0) + { + pFoo = vec4[](ipFoo[0], ipFoo[1]); + } +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs-block.mask-location-0.for-tess.vert b/third_party/spirv-cross/shaders-msl/masking/write-outputs-block.mask-location-0.for-tess.vert new file mode 100644 index 0000000000..2d8fdf19a2 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs-block.mask-location-0.for-tess.vert @@ -0,0 +1,16 @@ +#version 450 + +layout(location = 0) out V +{ + vec4 a; + vec4 b; + vec4 c; + vec4 d; +}; + +void main() +{ + gl_Position = vec4(1.0); + a = vec4(2.0); + b = vec4(3.0); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs-block.mask-location-0.msl2.tesc b/third_party/spirv-cross/shaders-msl/masking/write-outputs-block.mask-location-0.msl2.tesc new file mode 100644 index 0000000000..955f2c4187 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs-block.mask-location-0.msl2.tesc @@ -0,0 +1,28 @@ +#version 450 + +layout(vertices = 4) out; +patch out P +{ + layout(location = 0) float a; + layout(location = 2) float b; +}; + +out C +{ + layout(location = 1) float a; + layout(location = 3) float b; +} c[]; + +void write_in_function() +{ + a = 1.0; + b = 2.0; + c[gl_InvocationID].a = 3.0; + c[gl_InvocationID].b = 4.0; + gl_out[gl_InvocationID].gl_Position = vec4(1.0); +} + +void main() +{ + write_in_function(); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs-block.mask-location-0.multi-patch.msl2.tesc b/third_party/spirv-cross/shaders-msl/masking/write-outputs-block.mask-location-0.multi-patch.msl2.tesc new file mode 100644 index 0000000000..955f2c4187 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs-block.mask-location-0.multi-patch.msl2.tesc @@ -0,0 +1,28 @@ +#version 450 + +layout(vertices = 4) out; +patch out P +{ + layout(location = 0) float a; + layout(location = 2) float b; +}; + +out C +{ + layout(location = 1) float a; + layout(location = 3) float b; +} c[]; + +void write_in_function() +{ + a = 1.0; + b = 2.0; + c[gl_InvocationID].a = 3.0; + c[gl_InvocationID].b = 4.0; + gl_out[gl_InvocationID].gl_Position = vec4(1.0); +} + +void main() +{ + write_in_function(); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs-block.mask-location-0.vert b/third_party/spirv-cross/shaders-msl/masking/write-outputs-block.mask-location-0.vert new file mode 100644 index 0000000000..2d8fdf19a2 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs-block.mask-location-0.vert @@ -0,0 +1,16 @@ +#version 450 + +layout(location = 0) out V +{ + vec4 a; + vec4 b; + vec4 c; + vec4 d; +}; + +void main() +{ + gl_Position = vec4(1.0); + a = vec4(2.0); + b = vec4(3.0); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs-block.mask-location-1.for-tess.vert b/third_party/spirv-cross/shaders-msl/masking/write-outputs-block.mask-location-1.for-tess.vert new file mode 100644 index 0000000000..2d8fdf19a2 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs-block.mask-location-1.for-tess.vert @@ -0,0 +1,16 @@ +#version 450 + +layout(location = 0) out V +{ + vec4 a; + vec4 b; + vec4 c; + vec4 d; +}; + +void main() +{ + gl_Position = vec4(1.0); + a = vec4(2.0); + b = vec4(3.0); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs-block.mask-location-1.msl2.tesc b/third_party/spirv-cross/shaders-msl/masking/write-outputs-block.mask-location-1.msl2.tesc new file mode 100644 index 0000000000..955f2c4187 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs-block.mask-location-1.msl2.tesc @@ -0,0 +1,28 @@ +#version 450 + +layout(vertices = 4) out; +patch out P +{ + layout(location = 0) float a; + layout(location = 2) float b; +}; + +out C +{ + layout(location = 1) float a; + layout(location = 3) float b; +} c[]; + +void write_in_function() +{ + a = 1.0; + b = 2.0; + c[gl_InvocationID].a = 3.0; + c[gl_InvocationID].b = 4.0; + gl_out[gl_InvocationID].gl_Position = vec4(1.0); +} + +void main() +{ + write_in_function(); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs-block.mask-location-1.multi-patch.msl2.tesc b/third_party/spirv-cross/shaders-msl/masking/write-outputs-block.mask-location-1.multi-patch.msl2.tesc new file mode 100644 index 0000000000..955f2c4187 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs-block.mask-location-1.multi-patch.msl2.tesc @@ -0,0 +1,28 @@ +#version 450 + +layout(vertices = 4) out; +patch out P +{ + layout(location = 0) float a; + layout(location = 2) float b; +}; + +out C +{ + layout(location = 1) float a; + layout(location = 3) float b; +} c[]; + +void write_in_function() +{ + a = 1.0; + b = 2.0; + c[gl_InvocationID].a = 3.0; + c[gl_InvocationID].b = 4.0; + gl_out[gl_InvocationID].gl_Position = vec4(1.0); +} + +void main() +{ + write_in_function(); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs-block.mask-location-1.vert b/third_party/spirv-cross/shaders-msl/masking/write-outputs-block.mask-location-1.vert new file mode 100644 index 0000000000..2d8fdf19a2 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs-block.mask-location-1.vert @@ -0,0 +1,16 @@ +#version 450 + +layout(location = 0) out V +{ + vec4 a; + vec4 b; + vec4 c; + vec4 d; +}; + +void main() +{ + gl_Position = vec4(1.0); + a = vec4(2.0); + b = vec4(3.0); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-clip-distance.vert b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-clip-distance.vert new file mode 100644 index 0000000000..35b462fdf8 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-clip-distance.vert @@ -0,0 +1,21 @@ +#version 450 + +layout(location = 0) out vec4 v0; +layout(location = 1) out vec4 v1; + +out float gl_ClipDistance[2]; + +void write_in_func() +{ + v0 = vec4(1.0); + v1 = vec4(2.0); + gl_Position = vec4(3.0); + gl_PointSize = 4.0; + gl_ClipDistance[0] = 1.0; + gl_ClipDistance[1] = 0.5; +} + +void main() +{ + write_in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-0.for-tess.vert b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-0.for-tess.vert new file mode 100644 index 0000000000..35b462fdf8 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-0.for-tess.vert @@ -0,0 +1,21 @@ +#version 450 + +layout(location = 0) out vec4 v0; +layout(location = 1) out vec4 v1; + +out float gl_ClipDistance[2]; + +void write_in_func() +{ + v0 = vec4(1.0); + v1 = vec4(2.0); + gl_Position = vec4(3.0); + gl_PointSize = 4.0; + gl_ClipDistance[0] = 1.0; + gl_ClipDistance[1] = 0.5; +} + +void main() +{ + write_in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-0.msl2.tesc b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-0.msl2.tesc new file mode 100644 index 0000000000..c291fef03a --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-0.msl2.tesc @@ -0,0 +1,26 @@ +#version 450 + +layout(vertices = 4) out; + +layout(location = 0) out vec4 v0[]; +layout(location = 1) patch out vec4 v1; + +void write_in_func() +{ + v0[gl_InvocationID] = vec4(1.0); + v0[gl_InvocationID][0] = 2.0; + if (gl_InvocationID == 0) + { + v1 = vec4(2.0); + v1[3] = 4.0; + } + gl_out[gl_InvocationID].gl_Position = vec4(3.0); + gl_out[gl_InvocationID].gl_PointSize = 4.0; + gl_out[gl_InvocationID].gl_Position[2] = 5.0; + gl_out[gl_InvocationID].gl_PointSize = 4.0; +} + +void main() +{ + write_in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-0.multi-patch.tesc b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-0.multi-patch.tesc new file mode 100644 index 0000000000..9f3ca9fcff --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-0.multi-patch.tesc @@ -0,0 +1,29 @@ +#version 450 + +layout(vertices = 4) out; + +layout(location = 0) out vec4 v0[]; +layout(location = 1) patch out vec4 v1[2]; +layout(location = 3) patch out vec4 v3; + +void write_in_func() +{ + v0[gl_InvocationID] = vec4(1.0); + v0[gl_InvocationID].z = 3.0; + if (gl_InvocationID == 0) + { + v1[0] = vec4(2.0); + v1[0].x = 3.0; + v1[1] = vec4(2.0); + v1[1].x = 5.0; + } + v3 = vec4(5.0); + gl_out[gl_InvocationID].gl_Position = vec4(10.0); + gl_out[gl_InvocationID].gl_Position.z = 20.0; + gl_out[gl_InvocationID].gl_PointSize = 40.0; +} + +void main() +{ + write_in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-0.tesc b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-0.tesc new file mode 100644 index 0000000000..9f3ca9fcff --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-0.tesc @@ -0,0 +1,29 @@ +#version 450 + +layout(vertices = 4) out; + +layout(location = 0) out vec4 v0[]; +layout(location = 1) patch out vec4 v1[2]; +layout(location = 3) patch out vec4 v3; + +void write_in_func() +{ + v0[gl_InvocationID] = vec4(1.0); + v0[gl_InvocationID].z = 3.0; + if (gl_InvocationID == 0) + { + v1[0] = vec4(2.0); + v1[0].x = 3.0; + v1[1] = vec4(2.0); + v1[1].x = 5.0; + } + v3 = vec4(5.0); + gl_out[gl_InvocationID].gl_Position = vec4(10.0); + gl_out[gl_InvocationID].gl_Position.z = 20.0; + gl_out[gl_InvocationID].gl_PointSize = 40.0; +} + +void main() +{ + write_in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-0.vert b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-0.vert new file mode 100644 index 0000000000..35b462fdf8 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-0.vert @@ -0,0 +1,21 @@ +#version 450 + +layout(location = 0) out vec4 v0; +layout(location = 1) out vec4 v1; + +out float gl_ClipDistance[2]; + +void write_in_func() +{ + v0 = vec4(1.0); + v1 = vec4(2.0); + gl_Position = vec4(3.0); + gl_PointSize = 4.0; + gl_ClipDistance[0] = 1.0; + gl_ClipDistance[1] = 0.5; +} + +void main() +{ + write_in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-1.for-tess.vert b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-1.for-tess.vert new file mode 100644 index 0000000000..35b462fdf8 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-1.for-tess.vert @@ -0,0 +1,21 @@ +#version 450 + +layout(location = 0) out vec4 v0; +layout(location = 1) out vec4 v1; + +out float gl_ClipDistance[2]; + +void write_in_func() +{ + v0 = vec4(1.0); + v1 = vec4(2.0); + gl_Position = vec4(3.0); + gl_PointSize = 4.0; + gl_ClipDistance[0] = 1.0; + gl_ClipDistance[1] = 0.5; +} + +void main() +{ + write_in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-1.msl2.tesc b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-1.msl2.tesc new file mode 100644 index 0000000000..c291fef03a --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-1.msl2.tesc @@ -0,0 +1,26 @@ +#version 450 + +layout(vertices = 4) out; + +layout(location = 0) out vec4 v0[]; +layout(location = 1) patch out vec4 v1; + +void write_in_func() +{ + v0[gl_InvocationID] = vec4(1.0); + v0[gl_InvocationID][0] = 2.0; + if (gl_InvocationID == 0) + { + v1 = vec4(2.0); + v1[3] = 4.0; + } + gl_out[gl_InvocationID].gl_Position = vec4(3.0); + gl_out[gl_InvocationID].gl_PointSize = 4.0; + gl_out[gl_InvocationID].gl_Position[2] = 5.0; + gl_out[gl_InvocationID].gl_PointSize = 4.0; +} + +void main() +{ + write_in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-1.multi-patch.tesc b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-1.multi-patch.tesc new file mode 100644 index 0000000000..9f3ca9fcff --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-1.multi-patch.tesc @@ -0,0 +1,29 @@ +#version 450 + +layout(vertices = 4) out; + +layout(location = 0) out vec4 v0[]; +layout(location = 1) patch out vec4 v1[2]; +layout(location = 3) patch out vec4 v3; + +void write_in_func() +{ + v0[gl_InvocationID] = vec4(1.0); + v0[gl_InvocationID].z = 3.0; + if (gl_InvocationID == 0) + { + v1[0] = vec4(2.0); + v1[0].x = 3.0; + v1[1] = vec4(2.0); + v1[1].x = 5.0; + } + v3 = vec4(5.0); + gl_out[gl_InvocationID].gl_Position = vec4(10.0); + gl_out[gl_InvocationID].gl_Position.z = 20.0; + gl_out[gl_InvocationID].gl_PointSize = 40.0; +} + +void main() +{ + write_in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-1.tesc b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-1.tesc new file mode 100644 index 0000000000..9f3ca9fcff --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-1.tesc @@ -0,0 +1,29 @@ +#version 450 + +layout(vertices = 4) out; + +layout(location = 0) out vec4 v0[]; +layout(location = 1) patch out vec4 v1[2]; +layout(location = 3) patch out vec4 v3; + +void write_in_func() +{ + v0[gl_InvocationID] = vec4(1.0); + v0[gl_InvocationID].z = 3.0; + if (gl_InvocationID == 0) + { + v1[0] = vec4(2.0); + v1[0].x = 3.0; + v1[1] = vec4(2.0); + v1[1].x = 5.0; + } + v3 = vec4(5.0); + gl_out[gl_InvocationID].gl_Position = vec4(10.0); + gl_out[gl_InvocationID].gl_Position.z = 20.0; + gl_out[gl_InvocationID].gl_PointSize = 40.0; +} + +void main() +{ + write_in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-1.vert b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-1.vert new file mode 100644 index 0000000000..35b462fdf8 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-location-1.vert @@ -0,0 +1,21 @@ +#version 450 + +layout(location = 0) out vec4 v0; +layout(location = 1) out vec4 v1; + +out float gl_ClipDistance[2]; + +void write_in_func() +{ + v0 = vec4(1.0); + v1 = vec4(2.0); + gl_Position = vec4(3.0); + gl_PointSize = 4.0; + gl_ClipDistance[0] = 1.0; + gl_ClipDistance[1] = 0.5; +} + +void main() +{ + write_in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-point-size.for-tess.vert b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-point-size.for-tess.vert new file mode 100644 index 0000000000..35b462fdf8 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-point-size.for-tess.vert @@ -0,0 +1,21 @@ +#version 450 + +layout(location = 0) out vec4 v0; +layout(location = 1) out vec4 v1; + +out float gl_ClipDistance[2]; + +void write_in_func() +{ + v0 = vec4(1.0); + v1 = vec4(2.0); + gl_Position = vec4(3.0); + gl_PointSize = 4.0; + gl_ClipDistance[0] = 1.0; + gl_ClipDistance[1] = 0.5; +} + +void main() +{ + write_in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-point-size.multi-patch.tesc b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-point-size.multi-patch.tesc new file mode 100644 index 0000000000..9f3ca9fcff --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-point-size.multi-patch.tesc @@ -0,0 +1,29 @@ +#version 450 + +layout(vertices = 4) out; + +layout(location = 0) out vec4 v0[]; +layout(location = 1) patch out vec4 v1[2]; +layout(location = 3) patch out vec4 v3; + +void write_in_func() +{ + v0[gl_InvocationID] = vec4(1.0); + v0[gl_InvocationID].z = 3.0; + if (gl_InvocationID == 0) + { + v1[0] = vec4(2.0); + v1[0].x = 3.0; + v1[1] = vec4(2.0); + v1[1].x = 5.0; + } + v3 = vec4(5.0); + gl_out[gl_InvocationID].gl_Position = vec4(10.0); + gl_out[gl_InvocationID].gl_Position.z = 20.0; + gl_out[gl_InvocationID].gl_PointSize = 40.0; +} + +void main() +{ + write_in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-point-size.tesc b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-point-size.tesc new file mode 100644 index 0000000000..9f3ca9fcff --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-point-size.tesc @@ -0,0 +1,29 @@ +#version 450 + +layout(vertices = 4) out; + +layout(location = 0) out vec4 v0[]; +layout(location = 1) patch out vec4 v1[2]; +layout(location = 3) patch out vec4 v3; + +void write_in_func() +{ + v0[gl_InvocationID] = vec4(1.0); + v0[gl_InvocationID].z = 3.0; + if (gl_InvocationID == 0) + { + v1[0] = vec4(2.0); + v1[0].x = 3.0; + v1[1] = vec4(2.0); + v1[1].x = 5.0; + } + v3 = vec4(5.0); + gl_out[gl_InvocationID].gl_Position = vec4(10.0); + gl_out[gl_InvocationID].gl_Position.z = 20.0; + gl_out[gl_InvocationID].gl_PointSize = 40.0; +} + +void main() +{ + write_in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-point-size.vert b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-point-size.vert new file mode 100644 index 0000000000..35b462fdf8 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-point-size.vert @@ -0,0 +1,21 @@ +#version 450 + +layout(location = 0) out vec4 v0; +layout(location = 1) out vec4 v1; + +out float gl_ClipDistance[2]; + +void write_in_func() +{ + v0 = vec4(1.0); + v1 = vec4(2.0); + gl_Position = vec4(3.0); + gl_PointSize = 4.0; + gl_ClipDistance[0] = 1.0; + gl_ClipDistance[1] = 0.5; +} + +void main() +{ + write_in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-position.multi-patch.tesc b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-position.multi-patch.tesc new file mode 100644 index 0000000000..9f3ca9fcff --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-position.multi-patch.tesc @@ -0,0 +1,29 @@ +#version 450 + +layout(vertices = 4) out; + +layout(location = 0) out vec4 v0[]; +layout(location = 1) patch out vec4 v1[2]; +layout(location = 3) patch out vec4 v3; + +void write_in_func() +{ + v0[gl_InvocationID] = vec4(1.0); + v0[gl_InvocationID].z = 3.0; + if (gl_InvocationID == 0) + { + v1[0] = vec4(2.0); + v1[0].x = 3.0; + v1[1] = vec4(2.0); + v1[1].x = 5.0; + } + v3 = vec4(5.0); + gl_out[gl_InvocationID].gl_Position = vec4(10.0); + gl_out[gl_InvocationID].gl_Position.z = 20.0; + gl_out[gl_InvocationID].gl_PointSize = 40.0; +} + +void main() +{ + write_in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-position.tesc b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-position.tesc new file mode 100644 index 0000000000..9f3ca9fcff --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/masking/write-outputs.mask-position.tesc @@ -0,0 +1,29 @@ +#version 450 + +layout(vertices = 4) out; + +layout(location = 0) out vec4 v0[]; +layout(location = 1) patch out vec4 v1[2]; +layout(location = 3) patch out vec4 v3; + +void write_in_func() +{ + v0[gl_InvocationID] = vec4(1.0); + v0[gl_InvocationID].z = 3.0; + if (gl_InvocationID == 0) + { + v1[0] = vec4(2.0); + v1[0].x = 3.0; + v1[1] = vec4(2.0); + v1[1].x = 5.0; + } + v3 = vec4(5.0); + gl_out[gl_InvocationID].gl_Position = vec4(10.0); + gl_out[gl_InvocationID].gl_Position.z = 20.0; + gl_out[gl_InvocationID].gl_PointSize = 40.0; +} + +void main() +{ + write_in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/tesc/complex-control-point-inout-types.multi-patch.tesc b/third_party/spirv-cross/shaders-msl/tesc/complex-control-point-inout-types.multi-patch.tesc new file mode 100644 index 0000000000..aec8db7fac --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/tesc/complex-control-point-inout-types.multi-patch.tesc @@ -0,0 +1,70 @@ +#version 450 +layout(vertices = 4) out; + +struct Meep +{ + float a; + float b; +}; + +layout(location = 0) out float a[][2]; +layout(location = 2) out float b[]; +layout(location = 3) out mat2 m[]; +layout(location = 5) out Meep meep[]; +layout(location = 7) out Meep meeps[][2]; + +layout(location = 11) out Block +{ + float a[2]; + float b; + mat2 m; + Meep meep; + Meep meeps[2]; +} B[]; + +layout(location = 0) in float in_a[][2]; +layout(location = 2) in float in_b[]; +layout(location = 3) in mat2 in_m[]; +layout(location = 5) in Meep in_meep[]; +layout(location = 7) in Meep in_meeps[][2]; + +layout(location = 11) in Block +{ + float a[2]; + float b; + mat2 m; + Meep meep; + Meep meeps[2]; +} in_B[]; + +void write_in_func() +{ + gl_out[gl_InvocationID].gl_Position = vec4(1.0); + + a[gl_InvocationID][0] = in_a[gl_InvocationID][0]; + a[gl_InvocationID][1] = in_a[gl_InvocationID][1]; + b[gl_InvocationID] = in_b[gl_InvocationID]; + m[gl_InvocationID] = in_m[gl_InvocationID]; + meep[gl_InvocationID].a = in_meep[gl_InvocationID].a; + meep[gl_InvocationID].b = in_meep[gl_InvocationID].b; + meeps[gl_InvocationID][0].a = in_meeps[gl_InvocationID][0].a; + meeps[gl_InvocationID][0].b = in_meeps[gl_InvocationID][0].b; + meeps[gl_InvocationID][1].a = in_meeps[gl_InvocationID][1].a; + meeps[gl_InvocationID][1].b = in_meeps[gl_InvocationID][1].b; + + B[gl_InvocationID].a[0] = in_B[gl_InvocationID].a[0]; + B[gl_InvocationID].a[1] = in_B[gl_InvocationID].a[1]; + B[gl_InvocationID].b = in_B[gl_InvocationID].b; + B[gl_InvocationID].m = in_B[gl_InvocationID].m; + B[gl_InvocationID].meep.a = in_B[gl_InvocationID].meep.a; + B[gl_InvocationID].meep.b = in_B[gl_InvocationID].meep.b; + B[gl_InvocationID].meeps[0].a = in_B[gl_InvocationID].meeps[0].a; + B[gl_InvocationID].meeps[0].b = in_B[gl_InvocationID].meeps[0].b; + B[gl_InvocationID].meeps[1].a = in_B[gl_InvocationID].meeps[1].a; + B[gl_InvocationID].meeps[1].b = in_B[gl_InvocationID].meeps[1].b; +} + +void main() +{ + write_in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/tesc/complex-control-point-inout-types.tesc b/third_party/spirv-cross/shaders-msl/tesc/complex-control-point-inout-types.tesc new file mode 100644 index 0000000000..b7bb21d6b3 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/tesc/complex-control-point-inout-types.tesc @@ -0,0 +1,68 @@ +#version 450 +layout(vertices = 4) out; + +struct Meep +{ + float a; + float b; +}; + +layout(location = 0) out float a[][2]; +layout(location = 2) out float b[]; +layout(location = 3) out mat2 m[]; +layout(location = 5) out Meep meep[]; +layout(location = 7) out Meep meeps[][2]; + +layout(location = 11) out Block +{ + float a[2]; + float b; + mat2 m; + Meep meep; + Meep meeps[2]; +} B[]; + +layout(location = 0) in float in_a[][2]; +layout(location = 2) in float in_b[]; +layout(location = 3) in mat2 in_m[]; +layout(location = 5) in Meep in_meep[]; + +layout(location = 11) in Block +{ + float a[2]; + float b; + mat2 m; + // Non-multi-patch path cannot support structs inside structs. +} in_B[]; + +void write_in_func() +{ + gl_out[gl_InvocationID].gl_Position = vec4(1.0); + + a[gl_InvocationID][0] = in_a[gl_InvocationID][0]; + a[gl_InvocationID][1] = in_a[gl_InvocationID][1]; + b[gl_InvocationID] = in_b[gl_InvocationID]; + m[gl_InvocationID] = in_m[gl_InvocationID]; + meep[gl_InvocationID].a = in_meep[gl_InvocationID].a; + meep[gl_InvocationID].b = in_meep[gl_InvocationID].b; + meeps[gl_InvocationID][0].a = 1.0; + meeps[gl_InvocationID][0].b = 2.0; + meeps[gl_InvocationID][1].a = 3.0; + meeps[gl_InvocationID][1].b = 4.0; + + B[gl_InvocationID].a[0] = in_B[gl_InvocationID].a[0]; + B[gl_InvocationID].a[1] = in_B[gl_InvocationID].a[1]; + B[gl_InvocationID].b = in_B[gl_InvocationID].b; + B[gl_InvocationID].m = in_B[gl_InvocationID].m; + B[gl_InvocationID].meep.a = 10.0; + B[gl_InvocationID].meep.b = 20.0; + B[gl_InvocationID].meeps[0].a = 5.0; + B[gl_InvocationID].meeps[0].b = 6.0; + B[gl_InvocationID].meeps[1].a = 7.0; + B[gl_InvocationID].meeps[1].b = 8.0; +} + +void main() +{ + write_in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/tesc/complex-patch-out-types.tesc b/third_party/spirv-cross/shaders-msl/tesc/complex-patch-out-types.tesc new file mode 100644 index 0000000000..fd56ae46bd --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/tesc/complex-patch-out-types.tesc @@ -0,0 +1,55 @@ +#version 450 +layout(vertices = 4) out; + +struct Meep +{ + float a; + float b; +}; + +layout(location = 0) patch out float a[2]; +layout(location = 2) patch out float b; +layout(location = 3) patch out mat2 m; +layout(location = 5) patch out Meep meep; +layout(location = 7) patch out Meep meeps[2]; + +layout(location = 11) patch out Block +{ + float a[2]; + float b; + mat2 m; + Meep meep; + Meep meeps[2]; +} B; + +void write_in_func() +{ + gl_out[gl_InvocationID].gl_Position = vec4(1.0); + + a[0] = 1.0; + a[1] = 2.0; + b = 3.0; + m = mat2(2.0); + meep.a = 4.0; + meep.b = 5.0; + meeps[0].a = 6.0; + meeps[0].b = 7.0; + meeps[1].a = 8.0; + meeps[1].b = 9.0; + + B.a[0] = 1.0; + B.a[1] = 2.0; + B.b = 3.0; + B.m = mat2(4.0); + B.meep.a = 4.0; + B.meep.b = 5.0; + B.meeps[0].a = 6.0; + B.meeps[0].b = 7.0; + B.meeps[1].a = 8.0; + B.meeps[1].b = 9.0; +} + +void main() +{ + write_in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/tese/read-tess-level-in-func-quad.msl2.tese b/third_party/spirv-cross/shaders-msl/tese/read-tess-level-in-func-quad.msl2.tese new file mode 100644 index 0000000000..0c289ac5bd --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/tese/read-tess-level-in-func-quad.msl2.tese @@ -0,0 +1,17 @@ +#version 450 +layout(quads) in; + +vec4 read_tess_levels() +{ + return vec4( + gl_TessLevelOuter[0], + gl_TessLevelOuter[1], + gl_TessLevelOuter[2], + gl_TessLevelOuter[3]) + + vec2(gl_TessLevelInner[0], gl_TessLevelInner[1]).xyxy; +} + +void main() +{ + gl_Position = read_tess_levels(); +} diff --git a/third_party/spirv-cross/shaders-msl/tese/read-tess-level-in-func.msl2.tese b/third_party/spirv-cross/shaders-msl/tese/read-tess-level-in-func.msl2.tese new file mode 100644 index 0000000000..8cf1f1a8f7 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/tese/read-tess-level-in-func.msl2.tese @@ -0,0 +1,17 @@ +#version 450 +layout(triangles) in; + +vec4 read_tess_levels() +{ + return vec4( + gl_TessLevelOuter[0], + gl_TessLevelOuter[1], + gl_TessLevelOuter[2], + gl_TessLevelOuter[3]) + + vec2(gl_TessLevelInner[0], gl_TessLevelInner[1]).xyxy; +} + +void main() +{ + gl_Position = read_tess_levels(); +} diff --git a/third_party/spirv-cross/shaders-msl/vert/array-component-io.for-tess.vert b/third_party/spirv-cross/shaders-msl/vert/array-component-io.for-tess.vert new file mode 100644 index 0000000000..257ac848d1 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/vert/array-component-io.for-tess.vert @@ -0,0 +1,21 @@ +#version 450 + +layout(location = 1, component = 0) out float A[2]; +layout(location = 1, component = 2) out vec2 B[2]; +layout(location = 0, component = 1) out float C[3]; +layout(location = 0, component = 3) out float D; + +layout(location = 1, component = 0) in float InA[2]; +layout(location = 1, component = 2) in vec2 InB[2]; +layout(location = 0, component = 1) in float InC[3]; +layout(location = 0, component = 3) in float InD; +layout(location = 4) in vec4 Pos; + +void main() +{ + gl_Position = Pos; + A = InA; + B = InB; + C = InC; + D = InD; +} diff --git a/third_party/spirv-cross/shaders-msl/vert/array-component-io.vert b/third_party/spirv-cross/shaders-msl/vert/array-component-io.vert new file mode 100644 index 0000000000..257ac848d1 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/vert/array-component-io.vert @@ -0,0 +1,21 @@ +#version 450 + +layout(location = 1, component = 0) out float A[2]; +layout(location = 1, component = 2) out vec2 B[2]; +layout(location = 0, component = 1) out float C[3]; +layout(location = 0, component = 3) out float D; + +layout(location = 1, component = 0) in float InA[2]; +layout(location = 1, component = 2) in vec2 InB[2]; +layout(location = 0, component = 1) in float InC[3]; +layout(location = 0, component = 3) in float InD; +layout(location = 4) in vec4 Pos; + +void main() +{ + gl_Position = Pos; + A = InA; + B = InB; + C = InC; + D = InD; +} diff --git a/third_party/spirv-cross/shaders-msl/vert/implicit-position-1.vert b/third_party/spirv-cross/shaders-msl/vert/implicit-position-1.vert new file mode 100644 index 0000000000..54300d8daa --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/vert/implicit-position-1.vert @@ -0,0 +1,6 @@ +#version 450 +layout(location = 0) out vec4 V; +void main() +{ + V = vec4(1.0); +} diff --git a/third_party/spirv-cross/shaders-msl/vert/implicit-position-2.vert b/third_party/spirv-cross/shaders-msl/vert/implicit-position-2.vert new file mode 100644 index 0000000000..9996ddaad2 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/vert/implicit-position-2.vert @@ -0,0 +1,4 @@ +#version 450 +void main() +{ +} diff --git a/third_party/spirv-cross/shaders-msl/vert/no-contraction.vert b/third_party/spirv-cross/shaders-msl/vert/no-contraction.vert new file mode 100644 index 0000000000..206fbf0de8 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/vert/no-contraction.vert @@ -0,0 +1,15 @@ +#version 450 + +layout(location = 0) in vec4 vA; +layout(location = 1) in vec4 vB; +layout(location = 2) in vec4 vC; + +void main() +{ + precise vec4 mul = vA * vB; + precise vec4 add = vA + vB; + precise vec4 sub = vA - vB; + precise vec4 mad = vA * vB + vC; + precise vec4 summed = mul + add + sub + mad; + gl_Position = summed; +} diff --git a/third_party/spirv-cross/shaders-no-opt/asm/comp/buffer-reference-aliased-block-name.nocompat.vk.asm.comp b/third_party/spirv-cross/shaders-no-opt/asm/comp/buffer-reference-aliased-block-name.nocompat.vk.asm.comp new file mode 100644 index 0000000000..816985a108 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/comp/buffer-reference-aliased-block-name.nocompat.vk.asm.comp @@ -0,0 +1,110 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 59 +; Schema: 0 + OpCapability Shader + OpCapability PhysicalStorageBufferAddresses + OpExtension "SPV_EXT_physical_storage_buffer" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel PhysicalStorageBuffer64 GLSL450 + OpEntryPoint GLCompute %main "main" %gl_GlobalInvocationID + OpExecutionMode %main LocalSize 64 1 1 + OpSource GLSL 450 + OpSourceExtension "GL_EXT_buffer_reference" + OpName %main "main" + OpName %Registers "Registers" + OpMemberName %Registers 0 "ro" + OpMemberName %Registers 1 "rw" + OpMemberName %Registers 2 "wo" + OpName %RO "Alias" + OpMemberName %RO 0 "v" + OpName %RW "Alias" + OpMemberName %RW 0 "v" + OpName %WO "Alias" + OpMemberName %WO 0 "v" + OpName %registers "registers" + OpName %gl_GlobalInvocationID "gl_GlobalInvocationID" + OpMemberDecorate %Registers 0 Offset 0 + OpMemberDecorate %Registers 1 Offset 8 + OpMemberDecorate %Registers 2 Offset 16 + OpDecorate %Registers Block + OpDecorate %_runtimearr_v4float ArrayStride 16 + OpMemberDecorate %RO 0 NonWritable + OpMemberDecorate %RO 0 Offset 0 + OpDecorate %RO Block + OpDecorate %_runtimearr_v4float_0 ArrayStride 16 + OpMemberDecorate %RW 0 Restrict + OpMemberDecorate %RW 0 Offset 0 + OpDecorate %RW Block + OpDecorate %_runtimearr_v4float_1 ArrayStride 16 + OpMemberDecorate %WO 0 Coherent + OpMemberDecorate %WO 0 NonReadable + OpMemberDecorate %WO 0 Offset 0 + OpDecorate %WO Block + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + %void = OpTypeVoid + %3 = OpTypeFunction %void + OpTypeForwardPointer %_ptr_PhysicalStorageBuffer_RO PhysicalStorageBuffer + OpTypeForwardPointer %_ptr_PhysicalStorageBuffer_RW PhysicalStorageBuffer + OpTypeForwardPointer %_ptr_PhysicalStorageBuffer_WO PhysicalStorageBuffer + %Registers = OpTypeStruct %_ptr_PhysicalStorageBuffer_RO %_ptr_PhysicalStorageBuffer_RW %_ptr_PhysicalStorageBuffer_WO + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_runtimearr_v4float = OpTypeRuntimeArray %v4float + %RO = OpTypeStruct %_runtimearr_v4float +%_ptr_PhysicalStorageBuffer_RO = OpTypePointer PhysicalStorageBuffer %RO +%_runtimearr_v4float_0 = OpTypeRuntimeArray %v4float + %RW = OpTypeStruct %_runtimearr_v4float_0 +%_ptr_PhysicalStorageBuffer_RW = OpTypePointer PhysicalStorageBuffer %RW +%_runtimearr_v4float_1 = OpTypeRuntimeArray %v4float + %WO = OpTypeStruct %_runtimearr_v4float_1 +%_ptr_PhysicalStorageBuffer_WO = OpTypePointer PhysicalStorageBuffer %WO +%_ptr_PushConstant_Registers = OpTypePointer PushConstant %Registers + %registers = OpVariable %_ptr_PushConstant_Registers PushConstant + %int = OpTypeInt 32 1 + %int_1 = OpConstant %int 1 +%_ptr_PushConstant__ptr_PhysicalStorageBuffer_RW = OpTypePointer PushConstant %_ptr_PhysicalStorageBuffer_RW + %int_0 = OpConstant %int 0 + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input + %uint_0 = OpConstant %uint 0 +%_ptr_Input_uint = OpTypePointer Input %uint +%_ptr_PushConstant__ptr_PhysicalStorageBuffer_RO = OpTypePointer PushConstant %_ptr_PhysicalStorageBuffer_RO +%_ptr_PhysicalStorageBuffer_v4float = OpTypePointer PhysicalStorageBuffer %v4float + %int_2 = OpConstant %int 2 +%_ptr_PushConstant__ptr_PhysicalStorageBuffer_WO = OpTypePointer PushConstant %_ptr_PhysicalStorageBuffer_WO + %uint_64 = OpConstant %uint 64 + %uint_1 = OpConstant %uint 1 +%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_64 %uint_1 %uint_1 + %main = OpFunction %void None %3 + %5 = OpLabel + %23 = OpAccessChain %_ptr_PushConstant__ptr_PhysicalStorageBuffer_RW %registers %int_1 + %24 = OpLoad %_ptr_PhysicalStorageBuffer_RW %23 + %32 = OpAccessChain %_ptr_Input_uint %gl_GlobalInvocationID %uint_0 + %33 = OpLoad %uint %32 + %35 = OpAccessChain %_ptr_PushConstant__ptr_PhysicalStorageBuffer_RO %registers %int_0 + %36 = OpLoad %_ptr_PhysicalStorageBuffer_RO %35 + %37 = OpAccessChain %_ptr_Input_uint %gl_GlobalInvocationID %uint_0 + %38 = OpLoad %uint %37 + %40 = OpAccessChain %_ptr_PhysicalStorageBuffer_v4float %36 %int_0 %38 + %41 = OpLoad %v4float %40 Aligned 16 + %42 = OpAccessChain %_ptr_PhysicalStorageBuffer_v4float %24 %int_0 %33 + OpStore %42 %41 Aligned 16 + %45 = OpAccessChain %_ptr_PushConstant__ptr_PhysicalStorageBuffer_WO %registers %int_2 + %46 = OpLoad %_ptr_PhysicalStorageBuffer_WO %45 + %47 = OpAccessChain %_ptr_Input_uint %gl_GlobalInvocationID %uint_0 + %48 = OpLoad %uint %47 + %49 = OpAccessChain %_ptr_PushConstant__ptr_PhysicalStorageBuffer_RO %registers %int_0 + %50 = OpLoad %_ptr_PhysicalStorageBuffer_RO %49 + %51 = OpAccessChain %_ptr_Input_uint %gl_GlobalInvocationID %uint_0 + %52 = OpLoad %uint %51 + %53 = OpAccessChain %_ptr_PhysicalStorageBuffer_v4float %50 %int_0 %52 + %54 = OpLoad %v4float %53 Aligned 16 + %55 = OpAccessChain %_ptr_PhysicalStorageBuffer_v4float %46 %int_0 %48 + OpStore %55 %54 Aligned 16 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/comp/eliminate-globals-not-in-entry-point.noeliminate.spv14.asm.comp b/third_party/spirv-cross/shaders-no-opt/asm/comp/eliminate-globals-not-in-entry-point.noeliminate.spv14.asm.comp new file mode 100644 index 0000000000..73f3ceee1a --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/comp/eliminate-globals-not-in-entry-point.noeliminate.spv14.asm.comp @@ -0,0 +1,59 @@ +; SPIR-V +; Version: 1.5 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 26 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + ;OpEntryPoint GLCompute %main "main" %Samp %ubo %ssbo %v %w + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 64 1 1 + OpSource GLSL 450 + OpName %main "main" + OpName %Samp "Samp" + OpName %UBO "UBO" + OpMemberName %UBO 0 "v" + OpName %ubo "ubo" + OpName %SSBO "SSBO" + OpMemberName %SSBO 0 "v" + OpName %ssbo "ssbo" + OpName %v "v" + OpName %w "w" + OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize + OpDecorate %Samp DescriptorSet 0 + OpDecorate %Samp Binding 0 + OpMemberDecorate %UBO 0 Offset 0 + OpDecorate %UBO Block + OpDecorate %ubo DescriptorSet 0 + OpDecorate %ubo Binding 1 + OpMemberDecorate %SSBO 0 Offset 0 + OpDecorate %SSBO Block + OpDecorate %ssbo DescriptorSet 0 + OpDecorate %ssbo Binding 2 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 + %uint_64 = OpConstant %uint 64 + %uint_1 = OpConstant %uint 1 +%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_64 %uint_1 %uint_1 + %float = OpTypeFloat 32 + %12 = OpTypeImage %float 2D 0 0 0 1 Unknown + %13 = OpTypeSampledImage %12 +%_ptr_UniformConstant_13 = OpTypePointer UniformConstant %13 + %Samp = OpVariable %_ptr_UniformConstant_13 UniformConstant + %UBO = OpTypeStruct %float +%_ptr_Uniform_UBO = OpTypePointer Uniform %UBO + %ubo = OpVariable %_ptr_Uniform_UBO Uniform + %SSBO = OpTypeStruct %float +%_ptr_StorageBuffer_SSBO = OpTypePointer StorageBuffer %SSBO + %ssbo = OpVariable %_ptr_StorageBuffer_SSBO StorageBuffer +%_ptr_Private_float = OpTypePointer Private %float + %v = OpVariable %_ptr_Private_float Private +%_ptr_Workgroup_float = OpTypePointer Workgroup %float + %w = OpVariable %_ptr_Workgroup_float Workgroup + %main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/comp/nonuniform-bracket-handling.vk.nocompat.asm.comp b/third_party/spirv-cross/shaders-no-opt/asm/comp/nonuniform-bracket-handling.vk.nocompat.asm.comp index 3e36093e0b..5d5fac622a 100644 --- a/third_party/spirv-cross/shaders-no-opt/asm/comp/nonuniform-bracket-handling.vk.nocompat.asm.comp +++ b/third_party/spirv-cross/shaders-no-opt/asm/comp/nonuniform-bracket-handling.vk.nocompat.asm.comp @@ -54,6 +54,7 @@ OpDecorate %196 NonUniform OpDecorate %197 NonUniform OpDecorate %205 NonUniform + OpDecorate %212 NonUniform %void = OpTypeVoid %2 = OpTypeFunction %void %uint = OpTypeInt 32 0 diff --git a/third_party/spirv-cross/shaders-no-opt/asm/comp/storage-buffer-basic.invalid.asm.comp b/third_party/spirv-cross/shaders-no-opt/asm/comp/storage-buffer-basic.asm.comp similarity index 95% rename from third_party/spirv-cross/shaders-no-opt/asm/comp/storage-buffer-basic.invalid.asm.comp rename to third_party/spirv-cross/shaders-no-opt/asm/comp/storage-buffer-basic.asm.comp index edb1a05e54..db9a8490df 100644 --- a/third_party/spirv-cross/shaders-no-opt/asm/comp/storage-buffer-basic.invalid.asm.comp +++ b/third_party/spirv-cross/shaders-no-opt/asm/comp/storage-buffer-basic.asm.comp @@ -4,9 +4,9 @@ ; Bound: 31 ; Schema: 0 OpCapability Shader - OpCapability VariablePointers + ;OpCapability VariablePointers OpExtension "SPV_KHR_storage_buffer_storage_class" - OpExtension "SPV_KHR_variable_pointers" + ;OpExtension "SPV_KHR_variable_pointers" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %22 "main" %gl_WorkGroupID OpSource OpenCL_C 120 diff --git a/third_party/spirv-cross/shaders-no-opt/asm/frag/array-builtin-bitcast-load-store.asm.frag b/third_party/spirv-cross/shaders-no-opt/asm/frag/array-builtin-bitcast-load-store.asm.frag new file mode 100644 index 0000000000..387764c92c --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/frag/array-builtin-bitcast-load-store.asm.frag @@ -0,0 +1,57 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 29 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %fragColor %gl_SampleMask + OpExecutionMode %main OriginUpperLeft + OpName %fragColor "fragColor" + OpName %uBuffer "uBuffer" + OpMemberName %uBuffer 0 "color" + OpName %x_12 "x_12" + OpName %gl_SampleMask "gl_SampleMask" + OpName %main "main" + OpDecorate %fragColor Location 0 + OpDecorate %uBuffer Block + OpMemberDecorate %uBuffer 0 Offset 0 + OpDecorate %x_12 DescriptorSet 0 + OpDecorate %x_12 Binding 0 + OpDecorate %gl_SampleMask BuiltIn SampleMask + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %_ptr_Output_v4float = OpTypePointer Output %v4float + %5 = OpConstantNull %v4float + %fragColor = OpVariable %_ptr_Output_v4float Output %5 + %uBuffer = OpTypeStruct %v4float + %_ptr_Uniform_uBuffer = OpTypePointer Uniform %uBuffer + %x_12 = OpVariable %_ptr_Uniform_uBuffer Uniform + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 + %_arr_uint_uint_1 = OpTypeArray %uint %uint_1 +%_ptr_Output__arr_uint_uint_1 = OpTypePointer Output %_arr_uint_uint_1 + %14 = OpConstantNull %_arr_uint_uint_1 + %gl_SampleMask = OpVariable %_ptr_Output__arr_uint_uint_1 Output %14 + %void = OpTypeVoid + %15 = OpTypeFunction %void + %uint_0 = OpConstant %uint 0 + %_ptr_Uniform_v4float = OpTypePointer Uniform %v4float + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %_ptr_Output_uint = OpTypePointer Output %uint + %int_6 = OpConstant %int 6 + %main = OpFunction %void None %15 + %18 = OpLabel + %21 = OpAccessChain %_ptr_Uniform_v4float %x_12 %uint_0 + %22 = OpLoad %v4float %21 + OpStore %fragColor %22 + %26 = OpAccessChain %_ptr_Output_uint %gl_SampleMask %int_0 + %27 = OpBitcast %uint %int_6 + OpStore %26 %27 + %loaded_scalar = OpLoad %uint %26 + OpStore %26 %loaded_scalar + %loaded = OpLoad %_arr_uint_uint_1 %gl_SampleMask + OpStore %gl_SampleMask %loaded + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/frag/nonuniform-ssbo.nocompat.vk.asm.frag b/third_party/spirv-cross/shaders-no-opt/asm/frag/nonuniform-ssbo.nocompat.vk.asm.frag new file mode 100644 index 0000000000..c5428a8bb9 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/frag/nonuniform-ssbo.nocompat.vk.asm.frag @@ -0,0 +1,99 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 59 +; Schema: 0 + OpCapability Shader + OpCapability ShaderNonUniform + OpCapability RuntimeDescriptorArray + OpCapability StorageBufferArrayNonUniformIndexing + OpExtension "SPV_EXT_descriptor_indexing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %vIndex %FragColor + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpSourceExtension "GL_EXT_nonuniform_qualifier" + OpSourceExtension "GL_EXT_samplerless_texture_functions" + OpName %main "main" + OpName %i "i" + OpName %vIndex "vIndex" + OpName %SSBO "SSBO" + OpMemberName %SSBO 0 "counter" + OpMemberName %SSBO 1 "v" + OpName %ssbos "ssbos" + OpName %FragColor "FragColor" + OpDecorate %vIndex Flat + OpDecorate %vIndex Location 0 + OpDecorate %_runtimearr_v4float ArrayStride 16 + OpMemberDecorate %SSBO 0 Offset 0 + OpMemberDecorate %SSBO 1 Offset 16 + OpDecorate %SSBO BufferBlock + OpDecorate %ssbos DescriptorSet 0 + OpDecorate %ssbos Binding 3 + OpDecorate %32 NonUniform + OpDecorate %39 NonUniform + OpDecorate %49 NonUniform + OpDecorate %FragColor Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %int = OpTypeInt 32 1 +%_ptr_Function_int = OpTypePointer Function %int +%_ptr_Input_int = OpTypePointer Input %int + %vIndex = OpVariable %_ptr_Input_int Input + %uint = OpTypeInt 32 0 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_runtimearr_v4float = OpTypeRuntimeArray %v4float + %SSBO = OpTypeStruct %uint %_runtimearr_v4float +%_runtimearr_SSBO = OpTypeRuntimeArray %SSBO +%_ptr_Uniform__runtimearr_SSBO = OpTypePointer Uniform %_runtimearr_SSBO + %ssbos = OpVariable %_ptr_Uniform__runtimearr_SSBO Uniform + %int_60 = OpConstant %int 60 + %int_1 = OpConstant %int 1 + %int_70 = OpConstant %int 70 + %float_20 = OpConstant %float 20 + %30 = OpConstantComposite %v4float %float_20 %float_20 %float_20 %float_20 +%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float + %int_100 = OpConstant %int 100 + %int_0 = OpConstant %int 0 +%_ptr_Uniform_uint = OpTypePointer Uniform %uint + %uint_100 = OpConstant %uint 100 + %uint_1 = OpConstant %uint 1 + %uint_0 = OpConstant %uint 0 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %FragColor = OpVariable %_ptr_Output_v4float Output +%_ptr_Uniform_SSBO = OpTypePointer Uniform %SSBO + %uint_2 = OpConstant %uint 2 +%_ptr_Output_float = OpTypePointer Output %float + %main = OpFunction %void None %3 + %5 = OpLabel + %i = OpVariable %_ptr_Function_int Function + %11 = OpLoad %int %vIndex + OpStore %i %11 + %20 = OpLoad %int %i + %22 = OpIAdd %int %20 %int_60 + %23 = OpCopyObject %int %22 + %25 = OpLoad %int %i + %27 = OpIAdd %int %25 %int_70 + %28 = OpCopyObject %int %27 + %32 = OpAccessChain %_ptr_Uniform_v4float %ssbos %23 %int_1 %28 + OpStore %32 %30 + %33 = OpLoad %int %i + %35 = OpIAdd %int %33 %int_100 + %36 = OpCopyObject %int %35 + %39 = OpAccessChain %_ptr_Uniform_uint %ssbos %36 %int_0 + %43 = OpAtomicIAdd %uint %39 %uint_1 %uint_0 %uint_100 + %46 = OpLoad %int %i + %47 = OpCopyObject %int %46 + %49 = OpAccessChain %_ptr_Uniform_SSBO %ssbos %47 + %50 = OpArrayLength %uint %49 1 + %51 = OpBitcast %int %50 + %52 = OpConvertSToF %float %51 + %55 = OpAccessChain %_ptr_Output_float %FragColor %uint_2 + %56 = OpLoad %float %55 + %57 = OpFAdd %float %56 %52 + %58 = OpAccessChain %_ptr_Output_float %FragColor %uint_2 + OpStore %58 %57 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/frag/only-initializer-frag-depth.asm.frag b/third_party/spirv-cross/shaders-no-opt/asm/frag/only-initializer-frag-depth.asm.frag new file mode 100644 index 0000000000..17aab1d8f7 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/frag/only-initializer-frag-depth.asm.frag @@ -0,0 +1,25 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 10 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %gl_FragDepth + OpExecutionMode %main OriginUpperLeft + OpExecutionMode %main DepthReplacing + OpSource GLSL 450 + OpName %main "main" + OpName %gl_FragDepth "gl_FragDepth" + OpDecorate %gl_FragDepth BuiltIn FragDepth + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 +%_ptr_Output_float = OpTypePointer Output %float + %float_0_5 = OpConstant %float 0.5 +%gl_FragDepth = OpVariable %_ptr_Output_float Output %float_0_5 + %main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/frag/reserved-function-identifier.asm.frag b/third_party/spirv-cross/shaders-no-opt/asm/frag/reserved-function-identifier.asm.frag new file mode 100644 index 0000000000..a5a16f2873 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/frag/reserved-function-identifier.asm.frag @@ -0,0 +1,60 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 37 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %FragColor + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpName %main "main" + OpName %ACOS_f1_ "mat3" + OpName %a "a" + OpName %ACOS_i1_ "gl_Foo" + OpName %a_0 "a" + OpName %FragColor "FragColor" + OpName %param "param" + OpName %param_0 "param" + OpDecorate %FragColor Location 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 +%_ptr_Function_float = OpTypePointer Function %float + %8 = OpTypeFunction %float %_ptr_Function_float + %int = OpTypeInt 32 1 +%_ptr_Function_int = OpTypePointer Function %int + %14 = OpTypeFunction %float %_ptr_Function_int + %float_1 = OpConstant %float 1 +%_ptr_Output_float = OpTypePointer Output %float + %FragColor = OpVariable %_ptr_Output_float Output + %float_2 = OpConstant %float 2 + %int_4 = OpConstant %int 4 + %main = OpFunction %void None %3 + %5 = OpLabel + %param = OpVariable %_ptr_Function_float Function + %param_0 = OpVariable %_ptr_Function_int Function + OpStore %param %float_2 + %32 = OpFunctionCall %float %ACOS_f1_ %param + OpStore %param_0 %int_4 + %35 = OpFunctionCall %float %ACOS_i1_ %param_0 + %36 = OpFAdd %float %32 %35 + OpStore %FragColor %36 + OpReturn + OpFunctionEnd + %ACOS_f1_ = OpFunction %float None %8 + %a = OpFunctionParameter %_ptr_Function_float + %11 = OpLabel + %18 = OpLoad %float %a + %20 = OpFAdd %float %18 %float_1 + OpReturnValue %20 + OpFunctionEnd + %ACOS_i1_ = OpFunction %float None %14 + %a_0 = OpFunctionParameter %_ptr_Function_int + %17 = OpLabel + %23 = OpLoad %int %a_0 + %24 = OpConvertSToF %float %23 + %25 = OpFAdd %float %24 %float_1 + OpReturnValue %25 + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/frag/subgroup-ballot-only.vk.asm.frag b/third_party/spirv-cross/shaders-no-opt/asm/frag/subgroup-ballot-only.vk.asm.frag new file mode 100644 index 0000000000..39f4d066db --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/frag/subgroup-ballot-only.vk.asm.frag @@ -0,0 +1,52 @@ +; SPIR-V +; Version: 1.3 +; Generator: Unknown(30017); 21022 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpCapability GroupNonUniformBallot + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %INDEX %SV_Target + OpExecutionMode %main OriginUpperLeft + OpName %main "main" + OpName %INDEX "INDEX" + OpName %SV_Target "SV_Target" + OpDecorate %INDEX Flat + OpDecorate %INDEX Location 0 + OpDecorate %SV_Target Location 0 + %void = OpTypeVoid + %2 = OpTypeFunction %void + %uint = OpTypeInt 32 0 +%_ptr_Input_uint = OpTypePointer Input %uint + %INDEX = OpVariable %_ptr_Input_uint Input + %v4uint = OpTypeVector %uint 4 +%_ptr_Output_v4uint = OpTypePointer Output %v4uint + %SV_Target = OpVariable %_ptr_Output_v4uint Output + %bool = OpTypeBool + %uint_100 = OpConstant %uint 100 + %uint_3 = OpConstant %uint 3 +%_ptr_Output_uint = OpTypePointer Output %uint + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %main = OpFunction %void None %2 + %4 = OpLabel + OpBranch %29 + %29 = OpLabel + %11 = OpLoad %uint %INDEX + %13 = OpULessThan %bool %11 %uint_100 + %15 = OpGroupNonUniformBallot %v4uint %uint_3 %13 + %17 = OpCompositeExtract %uint %15 0 + %18 = OpCompositeExtract %uint %15 1 + %19 = OpCompositeExtract %uint %15 2 + %20 = OpCompositeExtract %uint %15 3 + %22 = OpAccessChain %_ptr_Output_uint %SV_Target %uint_0 + OpStore %22 %17 + %24 = OpAccessChain %_ptr_Output_uint %SV_Target %uint_1 + OpStore %24 %18 + %26 = OpAccessChain %_ptr_Output_uint %SV_Target %uint_2 + OpStore %26 %19 + %28 = OpAccessChain %_ptr_Output_uint %SV_Target %uint_3 + OpStore %28 %20 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/rgen/acceleration-nonuniform.spv14.vk.nocompat.asm.rgen b/third_party/spirv-cross/shaders-no-opt/asm/rgen/acceleration-nonuniform.spv14.vk.nocompat.asm.rgen new file mode 100644 index 0000000000..2178c8af7a --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/rgen/acceleration-nonuniform.spv14.vk.nocompat.asm.rgen @@ -0,0 +1,112 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 73 +; Schema: 0 + OpCapability RayTracingKHR + OpCapability ShaderNonUniform + OpCapability RuntimeDescriptorArray + OpExtension "SPV_EXT_descriptor_indexing" + OpExtension "SPV_KHR_ray_tracing" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint RayGenerationNV %main "main" %gl_LaunchIDEXT %gl_LaunchSizeEXT %as %payload %image + OpSource GLSL 460 + OpSourceExtension "GL_EXT_nonuniform_qualifier" + OpSourceExtension "GL_EXT_ray_tracing" + OpName %main "main" + OpName %col "col" + OpName %origin "origin" + OpName %gl_LaunchIDEXT "gl_LaunchIDEXT" + OpName %gl_LaunchSizeEXT "gl_LaunchSizeEXT" + OpName %direction "direction" + OpName %as "as" + OpName %payload "payload" + OpName %image "image" + OpDecorate %gl_LaunchIDEXT BuiltIn LaunchIdNV + OpDecorate %gl_LaunchSizeEXT BuiltIn LaunchSizeNV + OpDecorate %as DescriptorSet 0 + OpDecorate %as Binding 1 + OpDecorate %51 NonUniform + OpDecorate %payload Location 0 + OpDecorate %image DescriptorSet 0 + OpDecorate %image Binding 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Function_v4float = OpTypePointer Function %v4float + %float_0 = OpConstant %float 0 + %float_1 = OpConstant %float 1 + %12 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_1 + %v3float = OpTypeVector %float 3 +%_ptr_Function_v3float = OpTypePointer Function %v3float + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint +%gl_LaunchIDEXT = OpVariable %_ptr_Input_v3uint Input + %uint_0 = OpConstant %uint 0 +%_ptr_Input_uint = OpTypePointer Input %uint +%gl_LaunchSizeEXT = OpVariable %_ptr_Input_v3uint Input + %uint_1 = OpConstant %uint 1 + %float_n1 = OpConstant %float -1 + %41 = OpConstantComposite %v3float %float_0 %float_0 %float_n1 + %42 = OpTypeAccelerationStructureKHR +%_runtimearr_42 = OpTypeRuntimeArray %42 +%_ptr_UniformConstant__runtimearr_42 = OpTypePointer UniformConstant %_runtimearr_42 + %as = OpVariable %_ptr_UniformConstant__runtimearr_42 UniformConstant +%_ptr_UniformConstant_42 = OpTypePointer UniformConstant %42 + %uint_255 = OpConstant %uint 255 + %float_1000 = OpConstant %float 1000 + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%_ptr_RayPayloadNV_float = OpTypePointer RayPayloadNV %float + %payload = OpVariable %_ptr_RayPayloadNV_float RayPayloadNV +%_ptr_Function_float = OpTypePointer Function %float + %63 = OpTypeImage %float 2D 0 0 0 2 Rgba8 +%_ptr_UniformConstant_63 = OpTypePointer UniformConstant %63 + %image = OpVariable %_ptr_UniformConstant_63 UniformConstant + %v2uint = OpTypeVector %uint 2 + %v2int = OpTypeVector %int 2 + %main = OpFunction %void None %3 + %5 = OpLabel + %col = OpVariable %_ptr_Function_v4float Function + %origin = OpVariable %_ptr_Function_v3float Function + %direction = OpVariable %_ptr_Function_v3float Function + OpStore %col %12 + %22 = OpAccessChain %_ptr_Input_uint %gl_LaunchIDEXT %uint_0 + %23 = OpLoad %uint %22 + %24 = OpConvertUToF %float %23 + %26 = OpAccessChain %_ptr_Input_uint %gl_LaunchSizeEXT %uint_0 + %27 = OpLoad %uint %26 + %28 = OpConvertUToF %float %27 + %29 = OpFDiv %float %24 %28 + %31 = OpAccessChain %_ptr_Input_uint %gl_LaunchIDEXT %uint_1 + %32 = OpLoad %uint %31 + %33 = OpConvertUToF %float %32 + %34 = OpAccessChain %_ptr_Input_uint %gl_LaunchSizeEXT %uint_1 + %35 = OpLoad %uint %34 + %36 = OpConvertUToF %float %35 + %37 = OpFDiv %float %33 %36 + %38 = OpCompositeConstruct %v3float %29 %37 %float_1 + OpStore %origin %38 + OpStore %direction %41 + %46 = OpAccessChain %_ptr_Input_uint %gl_LaunchIDEXT %uint_0 + %47 = OpLoad %uint %46 + %48 = OpCopyObject %uint %47 + %50 = OpAccessChain %_ptr_UniformConstant_42 %as %48 + %51 = OpLoad %42 %50 + %53 = OpLoad %v3float %origin + %54 = OpLoad %v3float %direction + OpTraceRayKHR %51 %uint_0 %uint_255 %uint_0 %uint_1 %uint_0 %53 %float_0 %54 %float_1000 %payload + %60 = OpLoad %float %payload + %62 = OpAccessChain %_ptr_Function_float %col %uint_1 + OpStore %62 %60 + %66 = OpLoad %63 %image + %68 = OpLoad %v3uint %gl_LaunchIDEXT + %69 = OpVectorShuffle %v2uint %68 %68 0 1 + %71 = OpBitcast %v2int %69 + %72 = OpLoad %v4float %col + OpImageWrite %66 %71 %72 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/tesc/array-of-block-output-initializer.asm.tesc b/third_party/spirv-cross/shaders-no-opt/asm/tesc/array-of-block-output-initializer.asm.tesc new file mode 100644 index 0000000000..0ec5fa90a9 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/tesc/array-of-block-output-initializer.asm.tesc @@ -0,0 +1,101 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 42 +; Schema: 0 + OpCapability Tessellation + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %gl_out %gl_InvocationID %_ %patches %v2 %v3 %verts + OpExecutionMode %main OutputVertices 4 + OpSource GLSL 450 + OpName %main "main" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpName %gl_InvocationID "gl_InvocationID" + OpName %vert "vert" + OpMemberName %vert 0 "v0" + OpMemberName %vert 1 "v1" + OpName %_ "" + OpName %vert_patch "vert_patch" + OpMemberName %vert_patch 0 "v2" + OpMemberName %vert_patch 1 "v3" + OpName %patches "patches" + OpName %v2 "v2" + OpName %v3 "v3" + OpName %vert2 "vert2" + OpMemberName %vert2 0 "v4" + OpMemberName %vert2 1 "v5" + OpName %verts "verts" + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpMemberDecorate %vert 0 Patch + OpMemberDecorate %vert 1 Patch + OpDecorate %vert Block + OpDecorate %_ Location 0 + OpMemberDecorate %vert_patch 0 Patch + OpMemberDecorate %vert_patch 1 Patch + OpDecorate %vert_patch Block + OpDecorate %patches Location 2 + OpDecorate %v2 Patch + OpDecorate %v2 Location 6 + OpDecorate %v3 Location 7 + OpDecorate %vert2 Block + OpDecorate %verts Location 8 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 + %uint_4 = OpConstant %uint 4 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 + %gl_out_zero = OpConstantNull %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output %gl_out_zero + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %int_0 = OpConstant %int 0 + %float_1 = OpConstant %float 1 + %22 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %vert = OpTypeStruct %float %float +%_ptr_Output_vert = OpTypePointer Output %vert + %__zero = OpConstantNull %vert + %_ = OpVariable %_ptr_Output_vert Output %__zero + %vert_patch = OpTypeStruct %float %float + %uint_2 = OpConstant %uint 2 +%_arr_vert_patch_uint_2 = OpTypeArray %vert_patch %uint_2 +%_ptr_Output__arr_vert_patch_uint_2 = OpTypePointer Output %_arr_vert_patch_uint_2 + %patches_zero = OpConstantNull %_arr_vert_patch_uint_2 + %patches = OpVariable %_ptr_Output__arr_vert_patch_uint_2 Output %patches_zero +%_ptr_Output_float = OpTypePointer Output %float + %v2_zero = OpConstantNull %float + %v2 = OpVariable %_ptr_Output_float Output %v2_zero +%_arr_float_uint_4 = OpTypeArray %float %uint_4 +%_ptr_Output__arr_float_uint_4 = OpTypePointer Output %_arr_float_uint_4 + %v3_zero = OpConstantNull %_arr_float_uint_4 + %v3 = OpVariable %_ptr_Output__arr_float_uint_4 Output %v3_zero + %vert2 = OpTypeStruct %float %float +%_arr_vert2_uint_4 = OpTypeArray %vert2 %uint_4 +%_ptr_Output__arr_vert2_uint_4 = OpTypePointer Output %_arr_vert2_uint_4 + %verts_zero = OpConstantNull %_arr_vert2_uint_4 + %verts = OpVariable %_ptr_Output__arr_vert2_uint_4 Output %verts_zero + %main = OpFunction %void None %3 + %5 = OpLabel + %19 = OpLoad %int %gl_InvocationID + %24 = OpAccessChain %_ptr_Output_v4float %gl_out %19 %int_0 + OpStore %24 %22 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/tesc/copy-memory-control-point.asm.tesc b/third_party/spirv-cross/shaders-no-opt/asm/tesc/copy-memory-control-point.asm.tesc new file mode 100644 index 0000000000..7c0a638f98 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/tesc/copy-memory-control-point.asm.tesc @@ -0,0 +1,199 @@ +; SPIR-V +; Version: 1.0 +; Generator: Wine VKD3D Shader Compiler; 2 +; Bound: 126 +; Schema: 0 + OpCapability Tessellation + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %1 "main" %4 %30 %80 %101 %103 %108 %110 %115 %117 + OpExecutionMode %1 OutputVertices 3 + OpExecutionMode %1 Triangles + OpExecutionMode %1 SpacingEqual + OpExecutionMode %1 VertexOrderCw + OpName %1 "main" + OpName %11 "opc" + OpName %14 "cb1_struct" + OpName %16 "cb0_0" + OpName %22 "vicp" + OpName %23 "fork0" + OpName %26 "vForkInstanceId" + OpName %34 "r0" + OpName %32 "fork0_epilogue" + OpName %75 "fork1" + OpName %81 "fork1_epilogue" + OpName %101 "v0" + OpName %103 "v1" + OpName %108 "vicp0" + OpName %110 "vocp0" + OpName %115 "vicp1" + OpName %117 "vocp1" + OpDecorate %4 BuiltIn InvocationId + OpDecorate %13 ArrayStride 16 + OpDecorate %14 Block + OpMemberDecorate %14 0 Offset 0 + OpDecorate %16 DescriptorSet 0 + OpDecorate %16 Binding 0 + OpDecorate %30 BuiltIn TessLevelOuter + OpDecorate %30 Patch + OpDecorate %30 Patch + OpDecorate %30 Patch + OpDecorate %30 Patch + OpDecorate %80 BuiltIn TessLevelInner + OpDecorate %80 Patch + OpDecorate %80 Patch + OpDecorate %101 Location 0 + OpDecorate %103 Location 1 + OpDecorate %108 Location 2 + OpDecorate %110 Location 3 + OpDecorate %115 Location 4 + OpDecorate %117 Location 5 + %2 = OpTypeInt 32 1 + %3 = OpTypePointer Input %2 + %4 = OpVariable %3 Input + %5 = OpTypeFloat 32 + %6 = OpTypeVector %5 4 + %7 = OpTypeInt 32 0 + %8 = OpConstant %7 4 + %9 = OpTypeArray %6 %8 + %10 = OpTypePointer Private %9 + %11 = OpVariable %10 Private + %12 = OpConstant %7 1 + %13 = OpTypeArray %6 %12 + %14 = OpTypeStruct %13 + %15 = OpTypePointer Uniform %14 + %16 = OpVariable %15 Uniform + %17 = OpConstant %7 3 + %18 = OpTypeArray %6 %17 + %19 = OpConstant %7 2 + %20 = OpTypeArray %18 %19 + %21 = OpTypePointer Private %20 + %22 = OpVariable %21 Private + %24 = OpTypeVoid + %25 = OpTypeFunction %24 %7 + %28 = OpTypeArray %5 %8 + %29 = OpTypePointer Output %28 + %30 = OpVariable %29 Output + %31 = OpConstant %7 0 + %33 = OpTypePointer Function %6 + %36 = OpTypePointer Function %5 + %38 = OpTypePointer Uniform %6 + %40 = OpTypePointer Uniform %5 + %46 = OpTypePointer Private %6 + %48 = OpTypePointer Private %5 + %52 = OpVariable %46 Private + %55 = OpVariable %46 Private + %58 = OpVariable %46 Private + %60 = OpTypeFunction %24 %46 %46 %46 + %69 = OpTypePointer Output %5 + %76 = OpTypeFunction %24 + %78 = OpTypeArray %5 %19 + %79 = OpTypePointer Output %78 + %80 = OpVariable %79 Output + %89 = OpVariable %46 Private + %91 = OpTypeFunction %24 %46 + %98 = OpTypePointer Private %18 + %100 = OpTypePointer Input %18 + %101 = OpVariable %100 Input + %103 = OpVariable %100 Input + %105 = OpTypeVector %5 3 + %106 = OpTypeArray %105 %17 + %107 = OpTypePointer Input %106 + %108 = OpVariable %107 Input + %109 = OpTypePointer Output %106 + %110 = OpVariable %109 Output + %111 = OpTypePointer Output %105 + %112 = OpTypePointer Input %105 + %115 = OpVariable %100 Input + %116 = OpTypePointer Output %18 + %117 = OpVariable %116 Output + %118 = OpTypePointer Output %6 + %119 = OpTypePointer Input %6 + %23 = OpFunction %24 None %25 + %26 = OpFunctionParameter %7 + %27 = OpLabel + %34 = OpVariable %33 Function + %35 = OpBitcast %5 %26 + %37 = OpInBoundsAccessChain %36 %34 %31 + OpStore %37 %35 + %39 = OpAccessChain %38 %16 %31 %31 + %41 = OpInBoundsAccessChain %40 %39 %31 + %42 = OpLoad %5 %41 + %43 = OpInBoundsAccessChain %36 %34 %31 + %44 = OpLoad %5 %43 + %45 = OpBitcast %2 %44 + %47 = OpAccessChain %46 %11 %45 + %49 = OpInBoundsAccessChain %48 %47 %31 + OpStore %49 %42 + %50 = OpAccessChain %46 %11 %31 + %51 = OpLoad %6 %50 + OpStore %52 %51 + %53 = OpAccessChain %46 %11 %12 + %54 = OpLoad %6 %53 + OpStore %55 %54 + %56 = OpAccessChain %46 %11 %19 + %57 = OpLoad %6 %56 + OpStore %58 %57 + %59 = OpFunctionCall %24 %32 %52 %55 %58 + OpReturn + OpFunctionEnd + %32 = OpFunction %24 None %60 + %61 = OpFunctionParameter %46 + %62 = OpFunctionParameter %46 + %63 = OpFunctionParameter %46 + %64 = OpLabel + %65 = OpLoad %6 %61 + %66 = OpLoad %6 %62 + %67 = OpLoad %6 %63 + %68 = OpCompositeExtract %5 %65 0 + %70 = OpAccessChain %69 %30 %31 + OpStore %70 %68 + %71 = OpCompositeExtract %5 %66 0 + %72 = OpAccessChain %69 %30 %12 + OpStore %72 %71 + %73 = OpCompositeExtract %5 %67 0 + %74 = OpAccessChain %69 %30 %19 + OpStore %74 %73 + OpReturn + OpFunctionEnd + %75 = OpFunction %24 None %76 + %77 = OpLabel + %82 = OpAccessChain %38 %16 %31 %31 + %83 = OpInBoundsAccessChain %40 %82 %31 + %84 = OpLoad %5 %83 + %85 = OpAccessChain %46 %11 %17 + %86 = OpInBoundsAccessChain %48 %85 %31 + OpStore %86 %84 + %87 = OpAccessChain %46 %11 %17 + %88 = OpLoad %6 %87 + OpStore %89 %88 + %90 = OpFunctionCall %24 %81 %89 + OpReturn + OpFunctionEnd + %81 = OpFunction %24 None %91 + %92 = OpFunctionParameter %46 + %93 = OpLabel + %94 = OpLoad %6 %92 + %95 = OpCompositeExtract %5 %94 0 + %96 = OpAccessChain %69 %80 %31 + OpStore %96 %95 + OpReturn + OpFunctionEnd + %1 = OpFunction %24 None %76 + %97 = OpLabel + %99 = OpInBoundsAccessChain %98 %22 %31 + OpCopyMemory %99 %101 + %102 = OpInBoundsAccessChain %98 %22 %12 + OpCopyMemory %102 %103 + %104 = OpLoad %2 %4 + %113 = OpAccessChain %111 %110 %104 + %114 = OpAccessChain %112 %108 %104 + OpCopyMemory %113 %114 + %120 = OpAccessChain %118 %117 %104 + %121 = OpAccessChain %119 %115 %104 + OpCopyMemory %120 %121 + %122 = OpFunctionCall %24 %23 %31 + %123 = OpFunctionCall %24 %23 %12 + %124 = OpFunctionCall %24 %23 %19 + %125 = OpFunctionCall %24 %75 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/tesc/tess-level-initializer.asm.tesc b/third_party/spirv-cross/shaders-no-opt/asm/tesc/tess-level-initializer.asm.tesc new file mode 100644 index 0000000000..95fd147e7b --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/tesc/tess-level-initializer.asm.tesc @@ -0,0 +1,87 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 47 +; Schema: 0 + OpCapability Tessellation + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint TessellationControl %main "main" %gl_out %gl_InvocationID %gl_TessLevelInner %gl_TessLevelOuter + OpExecutionMode %main OutputVertices 4 + OpSource GLSL 450 + OpName %main "main" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %gl_out "gl_out" + OpName %gl_InvocationID "gl_InvocationID" + OpName %gl_TessLevelInner "gl_TessLevelInner" + OpName %gl_TessLevelOuter "gl_TessLevelOuter" + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + OpDecorate %gl_InvocationID BuiltIn InvocationId + OpDecorate %gl_TessLevelInner Patch + OpDecorate %gl_TessLevelInner BuiltIn TessLevelInner + OpDecorate %gl_TessLevelOuter Patch + OpDecorate %gl_TessLevelOuter BuiltIn TessLevelOuter + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 + %uint_4 = OpConstant %uint 4 +%_arr_gl_PerVertex_uint_4 = OpTypeArray %gl_PerVertex %uint_4 +%_ptr_Output__arr_gl_PerVertex_uint_4 = OpTypePointer Output %_arr_gl_PerVertex_uint_4 + %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_4 Output + %int = OpTypeInt 32 1 +%_ptr_Input_int = OpTypePointer Input %int +%gl_InvocationID = OpVariable %_ptr_Input_int Input + %int_0 = OpConstant %int 0 + %float_1 = OpConstant %float 1 + %22 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %uint_2 = OpConstant %uint 2 +%_arr_float_uint_2 = OpTypeArray %float %uint_2 +%_ptr_Output__arr_float_uint_2 = OpTypePointer Output %_arr_float_uint_2 + %inner_zero = OpConstantNull %_arr_float_uint_2 +%gl_TessLevelInner = OpVariable %_ptr_Output__arr_float_uint_2 Output %inner_zero +%_ptr_Output_float = OpTypePointer Output %float + %int_1 = OpConstant %int 1 + %float_2 = OpConstant %float 2 +%_arr_float_uint_4 = OpTypeArray %float %uint_4 +%_ptr_Output__arr_float_uint_4 = OpTypePointer Output %_arr_float_uint_4 + %outer_zero = OpConstantNull %_arr_float_uint_4 +%gl_TessLevelOuter = OpVariable %_ptr_Output__arr_float_uint_4 Output %outer_zero + %float_3 = OpConstant %float 3 + %float_4 = OpConstant %float 4 + %int_2 = OpConstant %int 2 + %float_5 = OpConstant %float 5 + %int_3 = OpConstant %int 3 + %float_6 = OpConstant %float 6 + %main = OpFunction %void None %3 + %5 = OpLabel + %19 = OpLoad %int %gl_InvocationID + %24 = OpAccessChain %_ptr_Output_v4float %gl_out %19 %int_0 + OpStore %24 %22 + %30 = OpAccessChain %_ptr_Output_float %gl_TessLevelInner %int_0 + OpStore %30 %float_1 + %33 = OpAccessChain %_ptr_Output_float %gl_TessLevelInner %int_1 + OpStore %33 %float_2 + %38 = OpAccessChain %_ptr_Output_float %gl_TessLevelOuter %int_0 + OpStore %38 %float_3 + %40 = OpAccessChain %_ptr_Output_float %gl_TessLevelOuter %int_1 + OpStore %40 %float_4 + %43 = OpAccessChain %_ptr_Output_float %gl_TessLevelOuter %int_2 + OpStore %43 %float_5 + %46 = OpAccessChain %_ptr_Output_float %gl_TessLevelOuter %int_3 + OpStore %46 %float_6 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/vert/block-struct-initializer.asm.vert b/third_party/spirv-cross/shaders-no-opt/asm/vert/block-struct-initializer.asm.vert new file mode 100644 index 0000000000..a431e6a717 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/vert/block-struct-initializer.asm.vert @@ -0,0 +1,37 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 13 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %_ %foo + OpSource GLSL 450 + OpName %main "main" + OpName %Vert "Vert" + OpMemberName %Vert 0 "a" + OpMemberName %Vert 1 "b" + OpName %_ "" + OpName %Foo "Foo" + OpMemberName %Foo 0 "c" + OpMemberName %Foo 1 "d" + OpName %foo "foo" + OpDecorate %Vert Block + OpDecorate %_ Location 0 + OpDecorate %foo Location 2 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %Vert = OpTypeStruct %float %float +%_ptr_Output_Vert = OpTypePointer Output %Vert + %zero_vert = OpConstantNull %Vert + %_ = OpVariable %_ptr_Output_Vert Output %zero_vert + %Foo = OpTypeStruct %float %float +%_ptr_Output_Foo = OpTypePointer Output %Foo +%zero_foo = OpConstantNull %Foo + %foo = OpVariable %_ptr_Output_Foo Output %zero_foo + %main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/vert/builtin-output-initializer.asm.vert b/third_party/spirv-cross/shaders-no-opt/asm/vert/builtin-output-initializer.asm.vert new file mode 100644 index 0000000000..aaa68662e5 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/vert/builtin-output-initializer.asm.vert @@ -0,0 +1,44 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 20 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %_ + OpSource GLSL 450 + OpName %main "main" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %_ "" + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex + %zero = OpConstantNull %gl_PerVertex + %_ = OpVariable %_ptr_Output_gl_PerVertex Output %zero + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %float_1 = OpConstant %float 1 + %17 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %main = OpFunction %void None %3 + %5 = OpLabel + %19 = OpAccessChain %_ptr_Output_v4float %_ %int_0 + OpStore %19 %17 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/vert/constant-composite-extract.asm.vert b/third_party/spirv-cross/shaders-no-opt/asm/vert/constant-composite-extract.asm.vert new file mode 100644 index 0000000000..d5a1b41146 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/vert/constant-composite-extract.asm.vert @@ -0,0 +1,66 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 22 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %_ + OpSource GLSL 450 + OpName %main "main" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %_ "" + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 + %m4float = OpTypeMatrix %v4float 4 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex + %_ = OpVariable %_ptr_Output_gl_PerVertex Output + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %float_1 = OpConstant %float 1 + %float_2 = OpConstant %float 2 + %float_3 = OpConstant %float 3 + %float_4 = OpConstant %float 4 + %float_5 = OpConstant %float 5 + %float_6 = OpConstant %float 6 + %float_7 = OpConstant %float 7 + %float_8 = OpConstant %float 8 + %vec0 = OpConstantComposite %v4float %float_1 %float_2 %float_3 %float_4 + %vec1 = OpConstantComposite %v4float %float_5 %float_6 %float_7 %float_8 + %cmat = OpConstantComposite %m4float %vec0 %vec1 %vec0 %vec1 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %main = OpFunction %void None %3 + %5 = OpLabel + %21 = OpAccessChain %_ptr_Output_v4float %_ %int_0 + %e0 = OpCompositeExtract %float %vec0 0 + %e1 = OpCompositeExtract %float %vec0 1 + %e2 = OpCompositeExtract %float %vec0 2 + %e3 = OpCompositeExtract %float %vec0 3 + %m13 = OpCompositeExtract %float %cmat 1 3 + %m21 = OpCompositeExtract %float %cmat 2 1 + %e_front = OpCompositeConstruct %v4float %e0 %e1 %e2 %e3 + %e_back = OpCompositeConstruct %v4float %e3 %e2 %m13 %m21 + %m0 = OpCompositeExtract %v4float %cmat 2 + %m1 = OpCompositeExtract %v4float %cmat 3 + %sum0 = OpFAdd %v4float %m0 %m1 + %sum1 = OpFAdd %v4float %e_front %e_back + %sum = OpFAdd %v4float %sum0 %sum1 + OpStore %21 %sum + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/comp/image-load-formatted.comp b/third_party/spirv-cross/shaders-no-opt/comp/image-load-formatted.comp new file mode 100644 index 0000000000..7fd587d99a --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/comp/image-load-formatted.comp @@ -0,0 +1,11 @@ +#version 450 +#extension GL_EXT_shader_image_load_formatted : require +layout(local_size_x = 8, local_size_y = 8) in; + +layout(binding = 0) uniform image2D img; + +void main() +{ + vec4 v = imageLoad(img, ivec2(gl_GlobalInvocationID.xy)); + imageStore(img, ivec2(gl_GlobalInvocationID.xy), v + 1.0); +} diff --git a/third_party/spirv-cross/shaders-no-opt/comp/subgroups.nocompat.invalid.vk.comp b/third_party/spirv-cross/shaders-no-opt/comp/subgroups.nocompat.invalid.vk.comp index 68fc74f910..a73a231259 100644 --- a/third_party/spirv-cross/shaders-no-opt/comp/subgroups.nocompat.invalid.vk.comp +++ b/third_party/spirv-cross/shaders-no-opt/comp/subgroups.nocompat.invalid.vk.comp @@ -72,6 +72,9 @@ void main() uvec4 anded = subgroupAnd(ballot_value); uvec4 ored = subgroupOr(ballot_value); uvec4 xored = subgroupXor(ballot_value); + bvec4 anded_b = subgroupAnd(equal(ballot_value, uvec4(42))); + bvec4 ored_b = subgroupOr(equal(ballot_value, uvec4(42))); + bvec4 xored_b = subgroupXor(equal(ballot_value, uvec4(42))); added = subgroupInclusiveAdd(added); iadded = subgroupInclusiveAdd(iadded); @@ -117,6 +120,10 @@ void main() ored = subgroupClusteredOr(ored, 4u); xored = subgroupClusteredXor(xored, 4u); + anded_b = subgroupClusteredAnd(equal(anded, uvec4(2u)), 4u); + ored_b = subgroupClusteredOr(equal(ored, uvec4(3u)), 4u); + xored_b = subgroupClusteredXor(equal(xored, uvec4(4u)), 4u); + // quad vec4 swap_horiz = subgroupQuadSwapHorizontal(vec4(20.0)); vec4 swap_vertical = subgroupQuadSwapVertical(vec4(20.0)); diff --git a/third_party/spirv-cross/shaders-no-opt/frag/frag-fully-covered.frag b/third_party/spirv-cross/shaders-no-opt/frag/frag-fully-covered.frag new file mode 100644 index 0000000000..95cc4fc975 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/frag/frag-fully-covered.frag @@ -0,0 +1,11 @@ +#version 450 +#extension GL_NV_conservative_raster_underestimation : require + +layout(location = 0) out vec4 FragColor; + +void main() +{ + if (!gl_FragFullyCoveredNV) + discard; + FragColor = vec4(1.0); +} diff --git a/third_party/spirv-cross/shaders-no-opt/frag/nonuniform-constructor.vk.nocompat.frag b/third_party/spirv-cross/shaders-no-opt/frag/nonuniform-constructor.vk.nocompat.frag new file mode 100644 index 0000000000..452aa953a4 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/frag/nonuniform-constructor.vk.nocompat.frag @@ -0,0 +1,14 @@ +#version 450 +#extension GL_EXT_nonuniform_qualifier : require + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec2 vUV; +layout(location = 1) flat in int vIndex; + +layout(set = 0, binding = 0) uniform texture2D uTex[]; +layout(set = 1, binding = 0) uniform sampler Immut; + +void main() +{ + FragColor = texture(nonuniformEXT(sampler2D(uTex[vIndex], Immut)), vUV); +} diff --git a/third_party/spirv-cross/shaders-no-opt/frag/subpass-input.framebuffer-fetch.nocompat.framebuffer-fetch-noncoherent.frag b/third_party/spirv-cross/shaders-no-opt/frag/subpass-input.framebuffer-fetch.nocompat.framebuffer-fetch-noncoherent.frag new file mode 100644 index 0000000000..621457a14a --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/frag/subpass-input.framebuffer-fetch.nocompat.framebuffer-fetch-noncoherent.frag @@ -0,0 +1,12 @@ +#version 310 es +precision mediump float; + +layout(input_attachment_index = 0, set = 0, binding = 0) uniform mediump subpassInput uSubpass0; +layout(input_attachment_index = 1, set = 0, binding = 1) uniform mediump subpassInput uSubpass1; +layout(location = 0) out vec3 FragColor; +layout(location = 1) out vec4 FragColor2; + +void main() +{ + FragColor.rgb = subpassLoad(uSubpass0).rgb + subpassLoad(uSubpass1).rgb; +} diff --git a/third_party/spirv-cross/shaders-no-opt/frag/subpass-input.framebuffer-fetch.nocompat.legacy.framebuffer-fetch-noncoherent.frag b/third_party/spirv-cross/shaders-no-opt/frag/subpass-input.framebuffer-fetch.nocompat.legacy.framebuffer-fetch-noncoherent.frag new file mode 100644 index 0000000000..621457a14a --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/frag/subpass-input.framebuffer-fetch.nocompat.legacy.framebuffer-fetch-noncoherent.frag @@ -0,0 +1,12 @@ +#version 310 es +precision mediump float; + +layout(input_attachment_index = 0, set = 0, binding = 0) uniform mediump subpassInput uSubpass0; +layout(input_attachment_index = 1, set = 0, binding = 1) uniform mediump subpassInput uSubpass1; +layout(location = 0) out vec3 FragColor; +layout(location = 1) out vec4 FragColor2; + +void main() +{ + FragColor.rgb = subpassLoad(uSubpass0).rgb + subpassLoad(uSubpass1).rgb; +} diff --git a/third_party/spirv-cross/shaders-no-opt/vulkan/frag/shading-rate.vk.nocompat.frag b/third_party/spirv-cross/shaders-no-opt/vulkan/frag/shading-rate.vk.nocompat.frag new file mode 100644 index 0000000000..8aee6d3590 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/vulkan/frag/shading-rate.vk.nocompat.frag @@ -0,0 +1,9 @@ +#version 450 +#extension GL_EXT_fragment_shading_rate : require + +layout(location = 0) out uint FragColor; + +void main() +{ + FragColor = gl_ShadingRateEXT; +} diff --git a/third_party/spirv-cross/shaders-no-opt/vulkan/vert/primitive-shading-rate.vk.nocompat.vert b/third_party/spirv-cross/shaders-no-opt/vulkan/vert/primitive-shading-rate.vk.nocompat.vert new file mode 100644 index 0000000000..95ac8d6445 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/vulkan/vert/primitive-shading-rate.vk.nocompat.vert @@ -0,0 +1,8 @@ +#version 450 +#extension GL_EXT_fragment_shading_rate : require + +void main() +{ + gl_PrimitiveShadingRateEXT = 3; + gl_Position = vec4(1.0); +} diff --git a/third_party/spirv-cross/shaders/vert/no-contraction.vert b/third_party/spirv-cross/shaders/vert/no-contraction.vert new file mode 100644 index 0000000000..206fbf0de8 --- /dev/null +++ b/third_party/spirv-cross/shaders/vert/no-contraction.vert @@ -0,0 +1,15 @@ +#version 450 + +layout(location = 0) in vec4 vA; +layout(location = 1) in vec4 vB; +layout(location = 2) in vec4 vC; + +void main() +{ + precise vec4 mul = vA * vB; + precise vec4 add = vA + vB; + precise vec4 sub = vA - vB; + precise vec4 mad = vA * vB + vC; + precise vec4 summed = mul + add + sub + mad; + gl_Position = summed; +} diff --git a/third_party/spirv-cross/shaders/vulkan/comp/buffer-reference-decorations.nocompat.vk.comp b/third_party/spirv-cross/shaders/vulkan/comp/buffer-reference-decorations.nocompat.vk.comp new file mode 100644 index 0000000000..c65463168a --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/comp/buffer-reference-decorations.nocompat.vk.comp @@ -0,0 +1,31 @@ +#version 450 +#extension GL_EXT_buffer_reference : require +layout(local_size_x = 64) in; + +layout(std430, buffer_reference) readonly buffer RO +{ + vec4 v[]; +}; + +layout(std430, buffer_reference) restrict buffer RW +{ + vec4 v[]; +}; + +layout(std430, buffer_reference) coherent writeonly buffer WO +{ + vec4 v[]; +}; + +layout(push_constant, std430) uniform Registers +{ + RO ro; + RW rw; + WO wo; +} registers; + +void main() +{ + registers.rw.v[gl_GlobalInvocationID.x] = registers.ro.v[gl_GlobalInvocationID.x]; + registers.wo.v[gl_GlobalInvocationID.x] = registers.ro.v[gl_GlobalInvocationID.x]; +} diff --git a/third_party/spirv-cross/shaders/vulkan/frag/nonuniform-qualifier.vk.nocompat.frag b/third_party/spirv-cross/shaders/vulkan/frag/nonuniform-qualifier.vk.nocompat.frag index f59b07c07e..136133eb30 100644 --- a/third_party/spirv-cross/shaders/vulkan/frag/nonuniform-qualifier.vk.nocompat.frag +++ b/third_party/spirv-cross/shaders/vulkan/frag/nonuniform-qualifier.vk.nocompat.frag @@ -1,28 +1,52 @@ #version 450 #extension GL_EXT_nonuniform_qualifier : require +#extension GL_EXT_samplerless_texture_functions : require layout(binding = 0) uniform texture2D uSamplers[]; +layout(binding = 0) uniform texture2DMS uSamplersMS[]; layout(binding = 4) uniform sampler2D uCombinedSamplers[]; layout(binding = 1) uniform sampler uSamps[]; layout(location = 0) flat in int vIndex; layout(location = 1) in vec2 vUV; layout(location = 0) out vec4 FragColor; +layout(r32f, binding = 5) uniform image2D uImages[]; +layout(r32ui, binding = 5) uniform uimage2D uImagesU32[]; + layout(set = 0, binding = 2) uniform UBO { vec4 v[64]; } ubos[]; -layout(set = 0, binding = 3) readonly buffer SSBO +layout(set = 0, binding = 3) buffer SSBO { + uint counter; vec4 v[]; } ssbos[]; void main() { int i = vIndex; - FragColor = texture(sampler2D(uSamplers[nonuniformEXT(i + 10)], uSamps[nonuniformEXT(i + 40)]), vUV); + FragColor = texture(nonuniformEXT(sampler2D(uSamplers[i + 10], uSamps[i + 40])), vUV); FragColor = texture(uCombinedSamplers[nonuniformEXT(i + 10)], vUV); FragColor += ubos[nonuniformEXT(i + 20)].v[nonuniformEXT(i + 40)]; FragColor += ssbos[nonuniformEXT(i + 50)].v[nonuniformEXT(i + 60)]; + ssbos[nonuniformEXT(i + 60)].v[nonuniformEXT(i + 70)] = vec4(20.0); + + FragColor = texelFetch(uSamplers[nonuniformEXT(i + 10)], ivec2(vUV), 0); + atomicAdd(ssbos[nonuniformEXT(i + 100)].counter, 100u); + + vec2 queried = textureQueryLod(nonuniformEXT(sampler2D(uSamplers[i + 10], uSamps[i + 40])), vUV); + queried += textureQueryLod(uCombinedSamplers[nonuniformEXT(i + 10)], vUV); + FragColor.xy += queried; + + FragColor.x += float(textureQueryLevels(uSamplers[nonuniformEXT(i + 20)])); + FragColor.y += float(textureSamples(uSamplersMS[nonuniformEXT(i + 20)])); + FragColor.xy += vec2(textureSize(uSamplers[nonuniformEXT(i + 20)], 0)); + + FragColor += imageLoad(uImages[nonuniformEXT(i + 50)], ivec2(vUV)); + FragColor.xy += vec2(imageSize(uImages[nonuniformEXT(i + 20)])); + imageStore(uImages[nonuniformEXT(i + 60)], ivec2(vUV), vec4(50.0)); + + imageAtomicAdd(uImagesU32[nonuniformEXT(i + 70)], ivec2(vUV), 40u); } diff --git a/third_party/spirv-cross/shaders/vulkan/rahit/terminators.khr.spv14.nocompat.vk.rahit b/third_party/spirv-cross/shaders/vulkan/rahit/terminators.khr.spv14.nocompat.vk.rahit new file mode 100644 index 0000000000..dab437780d --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rahit/terminators.khr.spv14.nocompat.vk.rahit @@ -0,0 +1,17 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +rayPayloadInEXT float payload; + +void in_func() +{ + if (payload > 0.0) + ignoreIntersectionEXT; + else + terminateRayEXT; +} + +void main() +{ + in_func(); +} diff --git a/third_party/spirv-cross/shaders/vulkan/rahit/terminators.nocompat.vk.rahit b/third_party/spirv-cross/shaders/vulkan/rahit/terminators.nocompat.vk.rahit new file mode 100644 index 0000000000..943be33c57 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rahit/terminators.nocompat.vk.rahit @@ -0,0 +1,17 @@ +#version 460 +#extension GL_NV_ray_tracing : require + +rayPayloadInNV float payload; + +void in_func() +{ + if (payload > 0.0) + ignoreIntersectionNV(); + else + terminateRayNV(); +} + +void main() +{ + in_func(); +} diff --git a/third_party/spirv-cross/shaders/vulkan/rcall/incoming-callable.khr.spv14.nocompat.vk.rcall b/third_party/spirv-cross/shaders/vulkan/rcall/incoming-callable.khr.spv14.nocompat.vk.rcall new file mode 100644 index 0000000000..53c594b6a1 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rcall/incoming-callable.khr.spv14.nocompat.vk.rcall @@ -0,0 +1,9 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 4) callableDataInEXT float c; + +void main() +{ + executeCallableEXT(10, 4); +} diff --git a/third_party/spirv-cross/shaders/vulkan/rchit/hit_attribute_block.khr.spv14.nocompat.vk.rchit b/third_party/spirv-cross/shaders/vulkan/rchit/hit_attribute_block.khr.spv14.nocompat.vk.rchit new file mode 100644 index 0000000000..fd82f5bf93 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rchit/hit_attribute_block.khr.spv14.nocompat.vk.rchit @@ -0,0 +1,11 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT Foo { float a; float b; } payload; +hitAttributeEXT Foo2 { float a; float b; } hit; + +void main() +{ + payload.a = hit.a; + payload.b = hit.b; +} diff --git a/third_party/spirv-cross/shaders/vulkan/rchit/hit_attribute_block_in_function.khr.spv14.nocompat.vk.rchit b/third_party/spirv-cross/shaders/vulkan/rchit/hit_attribute_block_in_function.khr.spv14.nocompat.vk.rchit new file mode 100644 index 0000000000..7b8d53dd8b --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rchit/hit_attribute_block_in_function.khr.spv14.nocompat.vk.rchit @@ -0,0 +1,16 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT Foo { float a; float b; } payload; +hitAttributeEXT Foo2 { float a; float b; } hit; + +void in_function() +{ + payload.a = hit.a; + payload.b = hit.b; +} + +void main() +{ + in_function(); +} diff --git a/third_party/spirv-cross/shaders/vulkan/rchit/hit_attribute_plain.khr.spv14.nocompat.vk.rchit b/third_party/spirv-cross/shaders/vulkan/rchit/hit_attribute_plain.khr.spv14.nocompat.vk.rchit new file mode 100644 index 0000000000..145687739f --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rchit/hit_attribute_plain.khr.spv14.nocompat.vk.rchit @@ -0,0 +1,10 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT vec2 payload; +hitAttributeEXT vec2 hit; + +void main() +{ + payload = hit; +} diff --git a/third_party/spirv-cross/shaders/vulkan/rchit/hit_attribute_struct.khr.spv14.nocompat.vk.rchit b/third_party/spirv-cross/shaders/vulkan/rchit/hit_attribute_struct.khr.spv14.nocompat.vk.rchit new file mode 100644 index 0000000000..f391f1ebfc --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rchit/hit_attribute_struct.khr.spv14.nocompat.vk.rchit @@ -0,0 +1,12 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +struct Foo { float a; float b; }; + +layout(location = 0) rayPayloadInEXT Foo payload; +hitAttributeEXT Foo hit; + +void main() +{ + payload = hit; +} diff --git a/third_party/spirv-cross/shaders/vulkan/rchit/hit_kind.khr.spv14.nocompat.vk.rchit b/third_party/spirv-cross/shaders/vulkan/rchit/hit_kind.khr.spv14.nocompat.vk.rchit new file mode 100644 index 0000000000..1bf150000a --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rchit/hit_kind.khr.spv14.nocompat.vk.rchit @@ -0,0 +1,9 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT uint payload; + +void main() +{ + payload = gl_HitKindEXT; +} diff --git a/third_party/spirv-cross/shaders/vulkan/rchit/hit_t.khr.spv14.nocompat.vk.rchit b/third_party/spirv-cross/shaders/vulkan/rchit/hit_t.khr.spv14.nocompat.vk.rchit new file mode 100644 index 0000000000..5b4fc4dd50 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rchit/hit_t.khr.spv14.nocompat.vk.rchit @@ -0,0 +1,9 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT float payload; + +void main() +{ + payload = gl_HitTEXT; +} diff --git a/third_party/spirv-cross/shaders/vulkan/rchit/incoming_ray_flags.khr.spv14.nocompat.vk.rchit b/third_party/spirv-cross/shaders/vulkan/rchit/incoming_ray_flags.khr.spv14.nocompat.vk.rchit new file mode 100644 index 0000000000..2c28646554 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rchit/incoming_ray_flags.khr.spv14.nocompat.vk.rchit @@ -0,0 +1,9 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT uint payload; + +void main() +{ + payload = gl_IncomingRayFlagsEXT; +} diff --git a/third_party/spirv-cross/shaders/vulkan/rchit/instance_custom_id.khr.spv14.nocompat.vk.rchit b/third_party/spirv-cross/shaders/vulkan/rchit/instance_custom_id.khr.spv14.nocompat.vk.rchit new file mode 100644 index 0000000000..330dfcebb5 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rchit/instance_custom_id.khr.spv14.nocompat.vk.rchit @@ -0,0 +1,9 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT uint payload; + +void main() +{ + payload = gl_InstanceCustomIndexEXT; +} diff --git a/third_party/spirv-cross/shaders/vulkan/rchit/instance_id.khr.spv14.nocompat.vk.rchit b/third_party/spirv-cross/shaders/vulkan/rchit/instance_id.khr.spv14.nocompat.vk.rchit new file mode 100644 index 0000000000..23d1e02c75 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rchit/instance_id.khr.spv14.nocompat.vk.rchit @@ -0,0 +1,9 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT uint payload; + +void main() +{ + payload = gl_InstanceID; +} diff --git a/third_party/spirv-cross/shaders/vulkan/rchit/object_ray_direction.khr.spv14.nocompat.vk.rchit b/third_party/spirv-cross/shaders/vulkan/rchit/object_ray_direction.khr.spv14.nocompat.vk.rchit new file mode 100644 index 0000000000..4d45134cb9 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rchit/object_ray_direction.khr.spv14.nocompat.vk.rchit @@ -0,0 +1,9 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT vec3 payload; + +void main() +{ + payload = gl_ObjectRayDirectionEXT; +} diff --git a/third_party/spirv-cross/shaders/vulkan/rchit/object_ray_origin.khr.spv14.nocompat.vk.rchit b/third_party/spirv-cross/shaders/vulkan/rchit/object_ray_origin.khr.spv14.nocompat.vk.rchit new file mode 100644 index 0000000000..0964b7b566 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rchit/object_ray_origin.khr.spv14.nocompat.vk.rchit @@ -0,0 +1,9 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT vec3 payload; + +void main() +{ + payload = gl_ObjectRayOriginEXT; +} diff --git a/third_party/spirv-cross/shaders/vulkan/rchit/object_to_world.khr.spv14.nocompat.vk.rchit b/third_party/spirv-cross/shaders/vulkan/rchit/object_to_world.khr.spv14.nocompat.vk.rchit new file mode 100644 index 0000000000..4377443c2b --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rchit/object_to_world.khr.spv14.nocompat.vk.rchit @@ -0,0 +1,9 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT vec3 payload; + +void main() +{ + payload = gl_ObjectToWorldEXT * vec4(payload, 1.0); +} diff --git a/third_party/spirv-cross/shaders/vulkan/rchit/payloads.khr.spv14.nocompat.vk.rchit b/third_party/spirv-cross/shaders/vulkan/rchit/payloads.khr.spv14.nocompat.vk.rchit new file mode 100644 index 0000000000..12ed5a7d62 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rchit/payloads.khr.spv14.nocompat.vk.rchit @@ -0,0 +1,19 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +struct Payload +{ + vec4 a; +}; + +layout(location = 0) rayPayloadInEXT Payload payload; + +void write_incoming_payload_in_function() +{ + payload.a = vec4(10.0); +} + +void main() +{ + write_incoming_payload_in_function(); +} diff --git a/third_party/spirv-cross/shaders/vulkan/rchit/primitive_id.khr.spv14.nocompat.vk.rchit b/third_party/spirv-cross/shaders/vulkan/rchit/primitive_id.khr.spv14.nocompat.vk.rchit new file mode 100644 index 0000000000..f3798c1f42 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rchit/primitive_id.khr.spv14.nocompat.vk.rchit @@ -0,0 +1,9 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT uint payload; + +void main() +{ + payload = gl_PrimitiveID; +} diff --git a/third_party/spirv-cross/shaders/vulkan/rchit/ray_tmax.khr.spv14.nocompat.vk.rchit b/third_party/spirv-cross/shaders/vulkan/rchit/ray_tmax.khr.spv14.nocompat.vk.rchit new file mode 100644 index 0000000000..2f688baf9e --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rchit/ray_tmax.khr.spv14.nocompat.vk.rchit @@ -0,0 +1,9 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT float payload; + +void main() +{ + payload = gl_RayTmaxEXT; +} diff --git a/third_party/spirv-cross/shaders/vulkan/rchit/ray_tmin.khr.spv14.nocompat.vk.rchit b/third_party/spirv-cross/shaders/vulkan/rchit/ray_tmin.khr.spv14.nocompat.vk.rchit new file mode 100644 index 0000000000..3f8ddf05f6 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rchit/ray_tmin.khr.spv14.nocompat.vk.rchit @@ -0,0 +1,9 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT float payload; + +void main() +{ + payload = gl_RayTminEXT; +} diff --git a/third_party/spirv-cross/shaders/vulkan/rchit/ray_tracing.khr.spv14.nocompat.vk.rchit b/third_party/spirv-cross/shaders/vulkan/rchit/ray_tracing.khr.spv14.nocompat.vk.rchit new file mode 100644 index 0000000000..d48995b821 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rchit/ray_tracing.khr.spv14.nocompat.vk.rchit @@ -0,0 +1,9 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT float payload; + +void main() +{ + payload = 1.0 + float(gl_InstanceID); +} diff --git a/third_party/spirv-cross/shaders/vulkan/rchit/world_ray_direction.khr.spv14.nocompat.vk.rchit b/third_party/spirv-cross/shaders/vulkan/rchit/world_ray_direction.khr.spv14.nocompat.vk.rchit new file mode 100644 index 0000000000..191905a312 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rchit/world_ray_direction.khr.spv14.nocompat.vk.rchit @@ -0,0 +1,9 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT vec3 payload; + +void main() +{ + payload = gl_WorldRayDirectionEXT; +} diff --git a/third_party/spirv-cross/shaders/vulkan/rchit/world_ray_origin.khr.spv14.nocompat.vk.rchit b/third_party/spirv-cross/shaders/vulkan/rchit/world_ray_origin.khr.spv14.nocompat.vk.rchit new file mode 100644 index 0000000000..2c86a7234c --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rchit/world_ray_origin.khr.spv14.nocompat.vk.rchit @@ -0,0 +1,9 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT vec3 payload; + +void main() +{ + payload = gl_WorldRayOriginEXT; +} diff --git a/third_party/spirv-cross/shaders/vulkan/rchit/world_to_object.khr.spv14.nocompat.vk.rchit b/third_party/spirv-cross/shaders/vulkan/rchit/world_to_object.khr.spv14.nocompat.vk.rchit new file mode 100644 index 0000000000..eb64bd0b41 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rchit/world_to_object.khr.spv14.nocompat.vk.rchit @@ -0,0 +1,9 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT vec3 payload; + +void main() +{ + payload = gl_WorldToObjectEXT * vec4(payload, 1.0); +} diff --git a/third_party/spirv-cross/shaders/vulkan/rgen/convert-u-to-as.spv14.vk.nocompat.rgen b/third_party/spirv-cross/shaders/vulkan/rgen/convert-u-to-as.spv14.vk.nocompat.rgen new file mode 100644 index 0000000000..8d6f1f4a93 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rgen/convert-u-to-as.spv14.vk.nocompat.rgen @@ -0,0 +1,16 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 3) rayPayloadEXT vec4 payload; + +layout(push_constant) uniform Registers +{ + uvec2 ptr; +}; + +void main() +{ + vec3 origin = vec3(0.0); + vec3 direction = vec3(0.0, 0.0, -1.0); + traceRayEXT(accelerationStructureEXT(ptr), gl_RayFlagsOpaqueEXT, 0xFF, 0u, 0u, 0u, origin, 0.0, direction, 100.0f, 3); +} diff --git a/third_party/spirv-cross/shaders/vulkan/rgen/execute_callable.nocompat.khr.spv14.vk.rgen b/third_party/spirv-cross/shaders/vulkan/rgen/execute_callable.nocompat.khr.spv14.vk.rgen new file mode 100644 index 0000000000..9a4380e0a6 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rgen/execute_callable.nocompat.khr.spv14.vk.rgen @@ -0,0 +1,16 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(set = 0, binding = 0) uniform accelerationStructureEXT as; +layout(set = 0, binding = 1, rgba32f) uniform writeonly image2D image; +layout(location = 3) rayPayloadEXT vec4 payload; +layout(location = 4) callableDataEXT float blend; + +void main() +{ + vec3 origin = vec3(0.0); + vec3 direction = vec3(0.0, 0.0, -1.0); + traceRayEXT(as, gl_RayFlagsOpaqueEXT, 0xFF, 0u, 0u, 0u, origin, 0.0, direction, 100.0f, 3); + executeCallableEXT(0u, 4); + imageStore(image, ivec2(gl_LaunchIDEXT.xy), payload + vec4(blend)); +} diff --git a/third_party/spirv-cross/shaders/vulkan/rgen/launch_id.khr.spv14.nocompat.vk.rgen b/third_party/spirv-cross/shaders/vulkan/rgen/launch_id.khr.spv14.nocompat.vk.rgen new file mode 100644 index 0000000000..6f9983e97f --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rgen/launch_id.khr.spv14.nocompat.vk.rgen @@ -0,0 +1,9 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(set = 0, binding = 0) uniform writeonly image2D uImage; + +void main() +{ + imageStore(uImage, ivec2(gl_LaunchIDEXT.xy), vec4(1.0)); +} diff --git a/third_party/spirv-cross/shaders/vulkan/rgen/launch_size.khr.spv14.nocompat.vk.rgen b/third_party/spirv-cross/shaders/vulkan/rgen/launch_size.khr.spv14.nocompat.vk.rgen new file mode 100644 index 0000000000..955f57dc40 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rgen/launch_size.khr.spv14.nocompat.vk.rgen @@ -0,0 +1,9 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(set = 0, binding = 0) uniform writeonly image2D uImage; + +void main() +{ + imageStore(uImage, ivec2(gl_LaunchSizeEXT.xy) - 1, vec4(1.0)); +} diff --git a/third_party/spirv-cross/shaders/vulkan/rgen/payloads.khr.spv14.nocompat.vk.rgen b/third_party/spirv-cross/shaders/vulkan/rgen/payloads.khr.spv14.nocompat.vk.rgen new file mode 100644 index 0000000000..b73a2463de --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rgen/payloads.khr.spv14.nocompat.vk.rgen @@ -0,0 +1,49 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(set = 0, binding = 0, rgba8) uniform image2D image; +layout(set = 0, binding = 1) uniform accelerationStructureEXT as; + +struct Payload +{ + float a, b; +}; + +// Plain payload +layout(location = 0) rayPayloadEXT float payload1; +// Struct payload +layout(location = 1) rayPayloadEXT Payload payload2; + +// This is syntactic sugar with the struct formulation (pretty sure), spec is kinda vague. +layout(location = 2) rayPayloadEXT Block +{ + float a, b; + Payload c, d; +}; + +vec4 trace_in_function() +{ + vec4 result = vec4(0.0); + // Test that we can write to a payload in a function. + vec3 origin = vec3(1.0, 0.0, 0.0); + vec3 direction = vec3(0.0, 1.0, 0.0); + traceRayEXT(as, 0u, 255u, 0u, 1u, 0u, origin, 0.0, direction, 1000.0, 1); + result += payload2.a; + result += payload2.b; + return result; +} + +void main() +{ + vec3 origin = vec3(1.0, 0.0, 0.0); + vec3 direction = vec3(0.0, 1.0, 0.0); + traceRayEXT(as, 0u, 255u, 0u, 1u, 0u, origin, 0.0, direction, 1000.0, 0); + vec4 result = vec4(payload1); + + result += trace_in_function(); + + traceRayEXT(as, 0u, 255u, 0u, 1u, 0u, origin, 0.0, direction, 1000.0, 2); + result += a + b + c.a + c.b + d.a + d.b; + + imageStore(image, ivec2(gl_LaunchIDEXT.xy), result); +} diff --git a/third_party/spirv-cross/shaders/vulkan/rgen/pure_call.khr.spv14.nocompat.vk.rgen b/third_party/spirv-cross/shaders/vulkan/rgen/pure_call.khr.spv14.nocompat.vk.rgen new file mode 100644 index 0000000000..6763f55365 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rgen/pure_call.khr.spv14.nocompat.vk.rgen @@ -0,0 +1,18 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(set = 0, binding = 1) uniform accelerationStructureEXT as; +layout(location = 0) rayPayloadEXT float payload; + +float pure_call(vec2 launchID, vec2 launchSize) +{ + vec3 origin = vec3(launchID.x / launchSize.x, launchID.y / launchSize.y, 1.0); + vec3 direction = vec3(0.0, 0.0, -1.0); + traceRayEXT(as, 0u, 255u, 0u, 1u, 0u, origin, 0.0, direction, 1000.0, 0); + return 0.0; +} + +void main() +{ + pure_call(vec2(gl_LaunchIDEXT.xy), vec2(gl_LaunchSizeEXT.xy)); +} diff --git a/third_party/spirv-cross/shaders/vulkan/rgen/ray_tracing.khr.spv14.nocompat.vk.rgen b/third_party/spirv-cross/shaders/vulkan/rgen/ray_tracing.khr.spv14.nocompat.vk.rgen new file mode 100644 index 0000000000..40f1648901 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rgen/ray_tracing.khr.spv14.nocompat.vk.rgen @@ -0,0 +1,16 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(set = 0, binding = 0, rgba8) uniform image2D image; +layout(set = 0, binding = 1) uniform accelerationStructureEXT as; +layout(location = 0) rayPayloadEXT float payload; + +void main() +{ + vec4 col = vec4(0.0, 0.0, 0.0, 1.0); + vec3 origin = vec3(float(gl_LaunchIDEXT.x) / float(gl_LaunchSizeEXT.x), float(gl_LaunchIDEXT.y) / float(gl_LaunchSizeEXT.y), 1.0); + vec3 direction = vec3(0.0, 0.0, -1.0); + traceRayEXT(as, 0u, 255u, 0u, 1u, 0u, origin, 0.0, direction, 1000.0, 0); + col.y = payload; + imageStore(image, ivec2(gl_LaunchIDEXT.xy), col); +} diff --git a/third_party/spirv-cross/shaders/vulkan/rgen/shader_record_buffer.khr.spv14.nocompat.vk.rgen b/third_party/spirv-cross/shaders/vulkan/rgen/shader_record_buffer.khr.spv14.nocompat.vk.rgen new file mode 100644 index 0000000000..39c9bf2786 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rgen/shader_record_buffer.khr.spv14.nocompat.vk.rgen @@ -0,0 +1,16 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(shaderRecordEXT, std430) buffer sbt +{ + vec3 direction; + float tmax; +}; + +layout(set = 0, binding = 0) uniform accelerationStructureEXT as; +layout(location = 0) rayPayloadEXT float payload; + +void main() +{ + traceRayEXT(as, 0u, 255u, 0u, 1u, 0u, vec3(0.0), 0.0, direction, tmax, 0); +} diff --git a/third_party/spirv-cross/shaders/vulkan/rint/report-intersection.khr.spv14.nocompat.vk.rint b/third_party/spirv-cross/shaders/vulkan/rint/report-intersection.khr.spv14.nocompat.vk.rint new file mode 100644 index 0000000000..b930e5c69f --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rint/report-intersection.khr.spv14.nocompat.vk.rint @@ -0,0 +1,12 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +void in_func() +{ + reportIntersectionEXT(0.5, 10); +} + +void main() +{ + in_func(); +} diff --git a/third_party/spirv-cross/shaders/vulkan/rint/report-intersection.nocompat.vk.rint b/third_party/spirv-cross/shaders/vulkan/rint/report-intersection.nocompat.vk.rint new file mode 100644 index 0000000000..ee384fc8da --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rint/report-intersection.nocompat.vk.rint @@ -0,0 +1,12 @@ +#version 460 +#extension GL_NV_ray_tracing : require + +void in_func() +{ + reportIntersectionNV(0.5, 10); +} + +void main() +{ + in_func(); +} diff --git a/third_party/spirv-cross/shaders/vulkan/rmiss/ray_tracing.khr.spv14.nocompat.vk.rmiss b/third_party/spirv-cross/shaders/vulkan/rmiss/ray_tracing.khr.spv14.nocompat.vk.rmiss new file mode 100644 index 0000000000..ee873cb96e --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rmiss/ray_tracing.khr.spv14.nocompat.vk.rmiss @@ -0,0 +1,9 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(location = 0) rayPayloadInEXT float payload; + +void main() +{ + payload = 0.0; +} diff --git a/third_party/spirv-cross/shaders/vulkan/rmiss/ray_tracing_trace_incoming.khr.spv14.nocompat.vk.rmiss b/third_party/spirv-cross/shaders/vulkan/rmiss/ray_tracing_trace_incoming.khr.spv14.nocompat.vk.rmiss new file mode 100644 index 0000000000..265a8f8b21 --- /dev/null +++ b/third_party/spirv-cross/shaders/vulkan/rmiss/ray_tracing_trace_incoming.khr.spv14.nocompat.vk.rmiss @@ -0,0 +1,12 @@ +#version 460 +#extension GL_EXT_ray_tracing : require + +layout(set = 0, binding = 0) uniform accelerationStructureEXT as; +layout(location = 3) rayPayloadInEXT float p; + +void main() +{ + vec3 origin = vec3(float(gl_LaunchIDEXT.x) / float(gl_LaunchSizeEXT.x), float(gl_LaunchIDEXT.y) / float(gl_LaunchSizeEXT.y), 1.0); + vec3 direction = vec3(0.0, 0.0, -1.0); + traceRayEXT(as, 0u, 255u, 0u, 1u, 0u, origin, 0.0, direction, 1000.0, 3); +} diff --git a/third_party/spirv-cross/spirv.h b/third_party/spirv-cross/spirv.h index dd9850dbb0..949f1980e7 100644 --- a/third_party/spirv-cross/spirv.h +++ b/third_party/spirv-cross/spirv.h @@ -54,11 +54,11 @@ typedef unsigned int SpvId; #define SPV_VERSION 0x10500 -#define SPV_REVISION 3 +#define SPV_REVISION 4 static const unsigned int SpvMagicNumber = 0x07230203; static const unsigned int SpvVersion = 0x00010500; -static const unsigned int SpvRevision = 3; +static const unsigned int SpvRevision = 4; static const unsigned int SpvOpCodeMask = 0xffff; static const unsigned int SpvWordCountShift = 16; @@ -172,6 +172,10 @@ typedef enum SpvExecutionMode_ { SpvExecutionModeSampleInterlockUnorderedEXT = 5369, SpvExecutionModeShadingRateInterlockOrderedEXT = 5370, SpvExecutionModeShadingRateInterlockUnorderedEXT = 5371, + SpvExecutionModeMaxWorkgroupSizeINTEL = 5893, + SpvExecutionModeMaxWorkDimINTEL = 5894, + SpvExecutionModeNoGlobalOffsetINTEL = 5895, + SpvExecutionModeNumSIMDWorkitemsINTEL = 5896, SpvExecutionModeMax = 0x7fffffff, } SpvExecutionMode; @@ -203,6 +207,7 @@ typedef enum SpvStorageClass_ { SpvStorageClassShaderRecordBufferNV = 5343, SpvStorageClassPhysicalStorageBuffer = 5349, SpvStorageClassPhysicalStorageBufferEXT = 5349, + SpvStorageClassCodeSectionINTEL = 5605, SpvStorageClassMax = 0x7fffffff, } SpvStorageClass; @@ -273,6 +278,8 @@ typedef enum SpvImageFormat_ { SpvImageFormatRg8ui = 37, SpvImageFormatR16ui = 38, SpvImageFormatR8ui = 39, + SpvImageFormatR64ui = 40, + SpvImageFormatR64i = 41, SpvImageFormatMax = 0x7fffffff, } SpvImageFormat; @@ -481,11 +488,24 @@ typedef enum SpvDecoration_ { SpvDecorationRestrictPointerEXT = 5355, SpvDecorationAliasedPointer = 5356, SpvDecorationAliasedPointerEXT = 5356, + SpvDecorationReferencedIndirectlyINTEL = 5602, SpvDecorationCounterBuffer = 5634, SpvDecorationHlslCounterBufferGOOGLE = 5634, SpvDecorationHlslSemanticGOOGLE = 5635, SpvDecorationUserSemantic = 5635, SpvDecorationUserTypeGOOGLE = 5636, + SpvDecorationRegisterINTEL = 5825, + SpvDecorationMemoryINTEL = 5826, + SpvDecorationNumbanksINTEL = 5827, + SpvDecorationBankwidthINTEL = 5828, + SpvDecorationMaxPrivateCopiesINTEL = 5829, + SpvDecorationSinglepumpINTEL = 5830, + SpvDecorationDoublepumpINTEL = 5831, + SpvDecorationMaxReplicatesINTEL = 5832, + SpvDecorationSimpleDualPortINTEL = 5833, + SpvDecorationMergeINTEL = 5834, + SpvDecorationBankBitsINTEL = 5835, + SpvDecorationForcePow2DepthINTEL = 5836, SpvDecorationMax = 0x7fffffff, } SpvDecoration; @@ -544,8 +564,10 @@ typedef enum SpvBuiltIn_ { SpvBuiltInBaseVertex = 4424, SpvBuiltInBaseInstance = 4425, SpvBuiltInDrawIndex = 4426, + SpvBuiltInPrimitiveShadingRateKHR = 4432, SpvBuiltInDeviceIndex = 4438, SpvBuiltInViewIndex = 4440, + SpvBuiltInShadingRateKHR = 4444, SpvBuiltInBaryCoordNoPerspAMD = 4992, SpvBuiltInBaryCoordNoPerspCentroidAMD = 4993, SpvBuiltInBaryCoordNoPerspSampleAMD = 4994, @@ -596,7 +618,6 @@ typedef enum SpvBuiltIn_ { SpvBuiltInObjectToWorldNV = 5330, SpvBuiltInWorldToObjectKHR = 5331, SpvBuiltInWorldToObjectNV = 5331, - SpvBuiltInHitTKHR = 5332, SpvBuiltInHitTNV = 5332, SpvBuiltInHitKindKHR = 5333, SpvBuiltInHitKindNV = 5333, @@ -632,6 +653,13 @@ typedef enum SpvLoopControlShift_ { SpvLoopControlIterationMultipleShift = 6, SpvLoopControlPeelCountShift = 7, SpvLoopControlPartialCountShift = 8, + SpvLoopControlInitiationIntervalINTELShift = 16, + SpvLoopControlMaxConcurrencyINTELShift = 17, + SpvLoopControlDependencyArrayINTELShift = 18, + SpvLoopControlPipelineEnableINTELShift = 19, + SpvLoopControlLoopCoalesceINTELShift = 20, + SpvLoopControlMaxInterleavingINTELShift = 21, + SpvLoopControlSpeculatedIterationsINTELShift = 22, SpvLoopControlMax = 0x7fffffff, } SpvLoopControlShift; @@ -646,6 +674,13 @@ typedef enum SpvLoopControlMask_ { SpvLoopControlIterationMultipleMask = 0x00000040, SpvLoopControlPeelCountMask = 0x00000080, SpvLoopControlPartialCountMask = 0x00000100, + SpvLoopControlInitiationIntervalINTELMask = 0x00010000, + SpvLoopControlMaxConcurrencyINTELMask = 0x00020000, + SpvLoopControlDependencyArrayINTELMask = 0x00040000, + SpvLoopControlPipelineEnableINTELMask = 0x00080000, + SpvLoopControlLoopCoalesceINTELMask = 0x00100000, + SpvLoopControlMaxInterleavingINTELMask = 0x00200000, + SpvLoopControlSpeculatedIterationsINTELMask = 0x00400000, } SpvLoopControlMask; typedef enum SpvFunctionControlShift_ { @@ -842,6 +877,7 @@ typedef enum SpvCapability_ { SpvCapabilityGroupNonUniformQuad = 68, SpvCapabilityShaderLayer = 69, SpvCapabilityShaderViewportIndex = 70, + SpvCapabilityFragmentShadingRateKHR = 4422, SpvCapabilitySubgroupBallotKHR = 4423, SpvCapabilityDrawParameters = 4427, SpvCapabilitySubgroupVoteKHR = 4431, @@ -866,12 +902,15 @@ typedef enum SpvCapability_ { SpvCapabilityRoundingModeRTE = 4467, SpvCapabilityRoundingModeRTZ = 4468, SpvCapabilityRayQueryProvisionalKHR = 4471, - SpvCapabilityRayTraversalPrimitiveCullingProvisionalKHR = 4478, + SpvCapabilityRayQueryKHR = 4472, + SpvCapabilityRayTraversalPrimitiveCullingKHR = 4478, + SpvCapabilityRayTracingKHR = 4479, SpvCapabilityFloat16ImageAMD = 5008, SpvCapabilityImageGatherBiasLodAMD = 5009, SpvCapabilityFragmentMaskAMD = 5010, SpvCapabilityStencilExportEXT = 5013, SpvCapabilityImageReadWriteLodAMD = 5015, + SpvCapabilityInt64ImageEXT = 5016, SpvCapabilityShaderClockKHR = 5055, SpvCapabilitySampleMaskOverrideCoverageNV = 5249, SpvCapabilityGeometryShaderPassthroughNV = 5251, @@ -932,9 +971,20 @@ typedef enum SpvCapability_ { SpvCapabilitySubgroupImageBlockIOINTEL = 5570, SpvCapabilitySubgroupImageMediaBlockIOINTEL = 5579, SpvCapabilityIntegerFunctions2INTEL = 5584, + SpvCapabilityFunctionPointersINTEL = 5603, + SpvCapabilityIndirectReferencesINTEL = 5604, SpvCapabilitySubgroupAvcMotionEstimationINTEL = 5696, SpvCapabilitySubgroupAvcMotionEstimationIntraINTEL = 5697, SpvCapabilitySubgroupAvcMotionEstimationChromaINTEL = 5698, + SpvCapabilityFPGAMemoryAttributesINTEL = 5824, + SpvCapabilityUnstructuredLoopControlsINTEL = 5886, + SpvCapabilityFPGALoopControlsINTEL = 5888, + SpvCapabilityKernelAttributesINTEL = 5892, + SpvCapabilityFPGAKernelAttributesINTEL = 5897, + SpvCapabilityBlockingPipesINTEL = 5945, + SpvCapabilityFPGARegINTEL = 5948, + SpvCapabilityAtomicFloat32AddEXT = 6033, + SpvCapabilityAtomicFloat64AddEXT = 6034, SpvCapabilityMax = 0x7fffffff, } SpvCapability; @@ -985,6 +1035,22 @@ typedef enum SpvRayQueryCandidateIntersectionType_ { SpvRayQueryCandidateIntersectionTypeMax = 0x7fffffff, } SpvRayQueryCandidateIntersectionType; +typedef enum SpvFragmentShadingRateShift_ { + SpvFragmentShadingRateVertical2PixelsShift = 0, + SpvFragmentShadingRateVertical4PixelsShift = 1, + SpvFragmentShadingRateHorizontal2PixelsShift = 2, + SpvFragmentShadingRateHorizontal4PixelsShift = 3, + SpvFragmentShadingRateMax = 0x7fffffff, +} SpvFragmentShadingRateShift; + +typedef enum SpvFragmentShadingRateMask_ { + SpvFragmentShadingRateMaskNone = 0, + SpvFragmentShadingRateVertical2PixelsMask = 0x00000001, + SpvFragmentShadingRateVertical4PixelsMask = 0x00000002, + SpvFragmentShadingRateHorizontal2PixelsMask = 0x00000004, + SpvFragmentShadingRateHorizontal4PixelsMask = 0x00000008, +} SpvFragmentShadingRateMask; + typedef enum SpvOp_ { SpvOpNop = 0, SpvOpUndef = 1, @@ -1330,13 +1396,19 @@ typedef enum SpvOp_ { SpvOpPtrEqual = 401, SpvOpPtrNotEqual = 402, SpvOpPtrDiff = 403, + SpvOpTerminateInvocation = 4416, SpvOpSubgroupBallotKHR = 4421, SpvOpSubgroupFirstInvocationKHR = 4422, SpvOpSubgroupAllKHR = 4428, SpvOpSubgroupAnyKHR = 4429, SpvOpSubgroupAllEqualKHR = 4430, SpvOpSubgroupReadInvocationKHR = 4432, - SpvOpTypeRayQueryProvisionalKHR = 4472, + SpvOpTraceRayKHR = 4445, + SpvOpExecuteCallableKHR = 4446, + SpvOpConvertUToAccelerationStructureKHR = 4447, + SpvOpIgnoreIntersectionKHR = 4448, + SpvOpTerminateRayKHR = 4449, + SpvOpTypeRayQueryKHR = 4472, SpvOpRayQueryInitializeKHR = 4473, SpvOpRayQueryTerminateKHR = 4474, SpvOpRayQueryGenerateIntersectionKHR = 4475, @@ -1359,15 +1431,11 @@ typedef enum SpvOp_ { SpvOpWritePackedPrimitiveIndices4x8NV = 5299, SpvOpReportIntersectionKHR = 5334, SpvOpReportIntersectionNV = 5334, - SpvOpIgnoreIntersectionKHR = 5335, SpvOpIgnoreIntersectionNV = 5335, - SpvOpTerminateRayKHR = 5336, SpvOpTerminateRayNV = 5336, SpvOpTraceNV = 5337, - SpvOpTraceRayKHR = 5337, SpvOpTypeAccelerationStructureKHR = 5341, SpvOpTypeAccelerationStructureNV = 5341, - SpvOpExecuteCallableKHR = 5344, SpvOpExecuteCallableNV = 5344, SpvOpTypeCooperativeMatrixNV = 5358, SpvOpCooperativeMatrixLoadNV = 5359, @@ -1402,6 +1470,8 @@ typedef enum SpvOp_ { SpvOpUSubSatINTEL = 5596, SpvOpIMul32x16INTEL = 5597, SpvOpUMul32x16INTEL = 5598, + SpvOpFunctionPointerINTEL = 5600, + SpvOpFunctionPointerCallINTEL = 5601, SpvOpDecorateString = 5632, SpvOpDecorateStringGOOGLE = 5632, SpvOpMemberDecorateString = 5633, @@ -1524,6 +1594,10 @@ typedef enum SpvOp_ { SpvOpSubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL = 5814, SpvOpSubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL = 5815, SpvOpSubgroupAvcSicGetInterRawSadsINTEL = 5816, + SpvOpLoopControlINTEL = 5887, + SpvOpReadPipeBlockingINTEL = 5946, + SpvOpWritePipeBlockingINTEL = 5947, + SpvOpFPGARegINTEL = 5949, SpvOpRayQueryGetRayTMinKHR = 6016, SpvOpRayQueryGetRayFlagsKHR = 6017, SpvOpRayQueryGetIntersectionTKHR = 6018, @@ -1541,6 +1615,7 @@ typedef enum SpvOp_ { SpvOpRayQueryGetWorldRayOriginKHR = 6030, SpvOpRayQueryGetIntersectionObjectToWorldKHR = 6031, SpvOpRayQueryGetIntersectionWorldToObjectKHR = 6032, + SpvOpAtomicFAddEXT = 6035, SpvOpMax = 0x7fffffff, } SpvOp; @@ -1893,13 +1968,19 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpPtrEqual: *hasResult = true; *hasResultType = true; break; case SpvOpPtrNotEqual: *hasResult = true; *hasResultType = true; break; case SpvOpPtrDiff: *hasResult = true; *hasResultType = true; break; + case SpvOpTerminateInvocation: *hasResult = false; *hasResultType = false; break; case SpvOpSubgroupBallotKHR: *hasResult = true; *hasResultType = true; break; case SpvOpSubgroupFirstInvocationKHR: *hasResult = true; *hasResultType = true; break; case SpvOpSubgroupAllKHR: *hasResult = true; *hasResultType = true; break; case SpvOpSubgroupAnyKHR: *hasResult = true; *hasResultType = true; break; case SpvOpSubgroupAllEqualKHR: *hasResult = true; *hasResultType = true; break; case SpvOpSubgroupReadInvocationKHR: *hasResult = true; *hasResultType = true; break; - case SpvOpTypeRayQueryProvisionalKHR: *hasResult = true; *hasResultType = false; break; + case SpvOpTraceRayKHR: *hasResult = false; *hasResultType = false; break; + case SpvOpExecuteCallableKHR: *hasResult = false; *hasResultType = false; break; + case SpvOpConvertUToAccelerationStructureKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpIgnoreIntersectionKHR: *hasResult = false; *hasResultType = false; break; + case SpvOpTerminateRayKHR: *hasResult = false; *hasResultType = false; break; + case SpvOpTypeRayQueryKHR: *hasResult = true; *hasResultType = false; break; case SpvOpRayQueryInitializeKHR: *hasResult = false; *hasResultType = false; break; case SpvOpRayQueryTerminateKHR: *hasResult = false; *hasResultType = false; break; case SpvOpRayQueryGenerateIntersectionKHR: *hasResult = false; *hasResultType = false; break; @@ -1959,6 +2040,8 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpUSubSatINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpIMul32x16INTEL: *hasResult = true; *hasResultType = true; break; case SpvOpUMul32x16INTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpFunctionPointerINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpFunctionPointerCallINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpDecorateString: *hasResult = false; *hasResultType = false; break; case SpvOpMemberDecorateString: *hasResult = false; *hasResultType = false; break; case SpvOpVmeImageINTEL: *hasResult = true; *hasResultType = true; break; @@ -2079,6 +2162,10 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpSubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpSubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpSubgroupAvcSicGetInterRawSadsINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpLoopControlINTEL: *hasResult = false; *hasResultType = false; break; + case SpvOpReadPipeBlockingINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpWritePipeBlockingINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpFPGARegINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpRayQueryGetRayTMinKHR: *hasResult = true; *hasResultType = true; break; case SpvOpRayQueryGetRayFlagsKHR: *hasResult = true; *hasResultType = true; break; case SpvOpRayQueryGetIntersectionTKHR: *hasResult = true; *hasResultType = true; break; @@ -2096,6 +2183,7 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpRayQueryGetWorldRayOriginKHR: *hasResult = true; *hasResultType = true; break; case SpvOpRayQueryGetIntersectionObjectToWorldKHR: *hasResult = true; *hasResultType = true; break; case SpvOpRayQueryGetIntersectionWorldToObjectKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpAtomicFAddEXT: *hasResult = true; *hasResultType = true; break; } } #endif /* SPV_ENABLE_UTILITY_CODE */ diff --git a/third_party/spirv-cross/spirv.hpp b/third_party/spirv-cross/spirv.hpp index dae36cf20d..43dd2aaeec 100644 --- a/third_party/spirv-cross/spirv.hpp +++ b/third_party/spirv-cross/spirv.hpp @@ -50,11 +50,11 @@ namespace spv { typedef unsigned int Id; #define SPV_VERSION 0x10500 -#define SPV_REVISION 3 +#define SPV_REVISION 4 static const unsigned int MagicNumber = 0x07230203; static const unsigned int Version = 0x00010500; -static const unsigned int Revision = 3; +static const unsigned int Revision = 4; static const unsigned int OpCodeMask = 0xffff; static const unsigned int WordCountShift = 16; @@ -168,6 +168,10 @@ enum ExecutionMode { ExecutionModeSampleInterlockUnorderedEXT = 5369, ExecutionModeShadingRateInterlockOrderedEXT = 5370, ExecutionModeShadingRateInterlockUnorderedEXT = 5371, + ExecutionModeMaxWorkgroupSizeINTEL = 5893, + ExecutionModeMaxWorkDimINTEL = 5894, + ExecutionModeNoGlobalOffsetINTEL = 5895, + ExecutionModeNumSIMDWorkitemsINTEL = 5896, ExecutionModeMax = 0x7fffffff, }; @@ -199,6 +203,7 @@ enum StorageClass { StorageClassShaderRecordBufferNV = 5343, StorageClassPhysicalStorageBuffer = 5349, StorageClassPhysicalStorageBufferEXT = 5349, + StorageClassCodeSectionINTEL = 5605, StorageClassMax = 0x7fffffff, }; @@ -269,6 +274,8 @@ enum ImageFormat { ImageFormatRg8ui = 37, ImageFormatR16ui = 38, ImageFormatR8ui = 39, + ImageFormatR64ui = 40, + ImageFormatR64i = 41, ImageFormatMax = 0x7fffffff, }; @@ -477,11 +484,24 @@ enum Decoration { DecorationRestrictPointerEXT = 5355, DecorationAliasedPointer = 5356, DecorationAliasedPointerEXT = 5356, + DecorationReferencedIndirectlyINTEL = 5602, DecorationCounterBuffer = 5634, DecorationHlslCounterBufferGOOGLE = 5634, DecorationHlslSemanticGOOGLE = 5635, DecorationUserSemantic = 5635, DecorationUserTypeGOOGLE = 5636, + DecorationRegisterINTEL = 5825, + DecorationMemoryINTEL = 5826, + DecorationNumbanksINTEL = 5827, + DecorationBankwidthINTEL = 5828, + DecorationMaxPrivateCopiesINTEL = 5829, + DecorationSinglepumpINTEL = 5830, + DecorationDoublepumpINTEL = 5831, + DecorationMaxReplicatesINTEL = 5832, + DecorationSimpleDualPortINTEL = 5833, + DecorationMergeINTEL = 5834, + DecorationBankBitsINTEL = 5835, + DecorationForcePow2DepthINTEL = 5836, DecorationMax = 0x7fffffff, }; @@ -540,8 +560,10 @@ enum BuiltIn { BuiltInBaseVertex = 4424, BuiltInBaseInstance = 4425, BuiltInDrawIndex = 4426, + BuiltInPrimitiveShadingRateKHR = 4432, BuiltInDeviceIndex = 4438, BuiltInViewIndex = 4440, + BuiltInShadingRateKHR = 4444, BuiltInBaryCoordNoPerspAMD = 4992, BuiltInBaryCoordNoPerspCentroidAMD = 4993, BuiltInBaryCoordNoPerspSampleAMD = 4994, @@ -592,7 +614,6 @@ enum BuiltIn { BuiltInObjectToWorldNV = 5330, BuiltInWorldToObjectKHR = 5331, BuiltInWorldToObjectNV = 5331, - BuiltInHitTKHR = 5332, BuiltInHitTNV = 5332, BuiltInHitKindKHR = 5333, BuiltInHitKindNV = 5333, @@ -628,6 +649,13 @@ enum LoopControlShift { LoopControlIterationMultipleShift = 6, LoopControlPeelCountShift = 7, LoopControlPartialCountShift = 8, + LoopControlInitiationIntervalINTELShift = 16, + LoopControlMaxConcurrencyINTELShift = 17, + LoopControlDependencyArrayINTELShift = 18, + LoopControlPipelineEnableINTELShift = 19, + LoopControlLoopCoalesceINTELShift = 20, + LoopControlMaxInterleavingINTELShift = 21, + LoopControlSpeculatedIterationsINTELShift = 22, LoopControlMax = 0x7fffffff, }; @@ -642,6 +670,13 @@ enum LoopControlMask { LoopControlIterationMultipleMask = 0x00000040, LoopControlPeelCountMask = 0x00000080, LoopControlPartialCountMask = 0x00000100, + LoopControlInitiationIntervalINTELMask = 0x00010000, + LoopControlMaxConcurrencyINTELMask = 0x00020000, + LoopControlDependencyArrayINTELMask = 0x00040000, + LoopControlPipelineEnableINTELMask = 0x00080000, + LoopControlLoopCoalesceINTELMask = 0x00100000, + LoopControlMaxInterleavingINTELMask = 0x00200000, + LoopControlSpeculatedIterationsINTELMask = 0x00400000, }; enum FunctionControlShift { @@ -838,6 +873,7 @@ enum Capability { CapabilityGroupNonUniformQuad = 68, CapabilityShaderLayer = 69, CapabilityShaderViewportIndex = 70, + CapabilityFragmentShadingRateKHR = 4422, CapabilitySubgroupBallotKHR = 4423, CapabilityDrawParameters = 4427, CapabilitySubgroupVoteKHR = 4431, @@ -862,12 +898,15 @@ enum Capability { CapabilityRoundingModeRTE = 4467, CapabilityRoundingModeRTZ = 4468, CapabilityRayQueryProvisionalKHR = 4471, - CapabilityRayTraversalPrimitiveCullingProvisionalKHR = 4478, + CapabilityRayQueryKHR = 4472, + CapabilityRayTraversalPrimitiveCullingKHR = 4478, + CapabilityRayTracingKHR = 4479, CapabilityFloat16ImageAMD = 5008, CapabilityImageGatherBiasLodAMD = 5009, CapabilityFragmentMaskAMD = 5010, CapabilityStencilExportEXT = 5013, CapabilityImageReadWriteLodAMD = 5015, + CapabilityInt64ImageEXT = 5016, CapabilityShaderClockKHR = 5055, CapabilitySampleMaskOverrideCoverageNV = 5249, CapabilityGeometryShaderPassthroughNV = 5251, @@ -928,9 +967,20 @@ enum Capability { CapabilitySubgroupImageBlockIOINTEL = 5570, CapabilitySubgroupImageMediaBlockIOINTEL = 5579, CapabilityIntegerFunctions2INTEL = 5584, + CapabilityFunctionPointersINTEL = 5603, + CapabilityIndirectReferencesINTEL = 5604, CapabilitySubgroupAvcMotionEstimationINTEL = 5696, CapabilitySubgroupAvcMotionEstimationIntraINTEL = 5697, CapabilitySubgroupAvcMotionEstimationChromaINTEL = 5698, + CapabilityFPGAMemoryAttributesINTEL = 5824, + CapabilityUnstructuredLoopControlsINTEL = 5886, + CapabilityFPGALoopControlsINTEL = 5888, + CapabilityKernelAttributesINTEL = 5892, + CapabilityFPGAKernelAttributesINTEL = 5897, + CapabilityBlockingPipesINTEL = 5945, + CapabilityFPGARegINTEL = 5948, + CapabilityAtomicFloat32AddEXT = 6033, + CapabilityAtomicFloat64AddEXT = 6034, CapabilityMax = 0x7fffffff, }; @@ -981,6 +1031,22 @@ enum RayQueryCandidateIntersectionType { RayQueryCandidateIntersectionTypeMax = 0x7fffffff, }; +enum FragmentShadingRateShift { + FragmentShadingRateVertical2PixelsShift = 0, + FragmentShadingRateVertical4PixelsShift = 1, + FragmentShadingRateHorizontal2PixelsShift = 2, + FragmentShadingRateHorizontal4PixelsShift = 3, + FragmentShadingRateMax = 0x7fffffff, +}; + +enum FragmentShadingRateMask { + FragmentShadingRateMaskNone = 0, + FragmentShadingRateVertical2PixelsMask = 0x00000001, + FragmentShadingRateVertical4PixelsMask = 0x00000002, + FragmentShadingRateHorizontal2PixelsMask = 0x00000004, + FragmentShadingRateHorizontal4PixelsMask = 0x00000008, +}; + enum Op { OpNop = 0, OpUndef = 1, @@ -1326,13 +1392,19 @@ enum Op { OpPtrEqual = 401, OpPtrNotEqual = 402, OpPtrDiff = 403, + OpTerminateInvocation = 4416, OpSubgroupBallotKHR = 4421, OpSubgroupFirstInvocationKHR = 4422, OpSubgroupAllKHR = 4428, OpSubgroupAnyKHR = 4429, OpSubgroupAllEqualKHR = 4430, OpSubgroupReadInvocationKHR = 4432, - OpTypeRayQueryProvisionalKHR = 4472, + OpTraceRayKHR = 4445, + OpExecuteCallableKHR = 4446, + OpConvertUToAccelerationStructureKHR = 4447, + OpIgnoreIntersectionKHR = 4448, + OpTerminateRayKHR = 4449, + OpTypeRayQueryKHR = 4472, OpRayQueryInitializeKHR = 4473, OpRayQueryTerminateKHR = 4474, OpRayQueryGenerateIntersectionKHR = 4475, @@ -1355,15 +1427,11 @@ enum Op { OpWritePackedPrimitiveIndices4x8NV = 5299, OpReportIntersectionKHR = 5334, OpReportIntersectionNV = 5334, - OpIgnoreIntersectionKHR = 5335, OpIgnoreIntersectionNV = 5335, - OpTerminateRayKHR = 5336, OpTerminateRayNV = 5336, OpTraceNV = 5337, - OpTraceRayKHR = 5337, OpTypeAccelerationStructureKHR = 5341, OpTypeAccelerationStructureNV = 5341, - OpExecuteCallableKHR = 5344, OpExecuteCallableNV = 5344, OpTypeCooperativeMatrixNV = 5358, OpCooperativeMatrixLoadNV = 5359, @@ -1398,6 +1466,8 @@ enum Op { OpUSubSatINTEL = 5596, OpIMul32x16INTEL = 5597, OpUMul32x16INTEL = 5598, + OpFunctionPointerINTEL = 5600, + OpFunctionPointerCallINTEL = 5601, OpDecorateString = 5632, OpDecorateStringGOOGLE = 5632, OpMemberDecorateString = 5633, @@ -1520,6 +1590,10 @@ enum Op { OpSubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL = 5814, OpSubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL = 5815, OpSubgroupAvcSicGetInterRawSadsINTEL = 5816, + OpLoopControlINTEL = 5887, + OpReadPipeBlockingINTEL = 5946, + OpWritePipeBlockingINTEL = 5947, + OpFPGARegINTEL = 5949, OpRayQueryGetRayTMinKHR = 6016, OpRayQueryGetRayFlagsKHR = 6017, OpRayQueryGetIntersectionTKHR = 6018, @@ -1537,6 +1611,7 @@ enum Op { OpRayQueryGetWorldRayOriginKHR = 6030, OpRayQueryGetIntersectionObjectToWorldKHR = 6031, OpRayQueryGetIntersectionWorldToObjectKHR = 6032, + OpAtomicFAddEXT = 6035, OpMax = 0x7fffffff, }; @@ -1889,13 +1964,19 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpPtrEqual: *hasResult = true; *hasResultType = true; break; case OpPtrNotEqual: *hasResult = true; *hasResultType = true; break; case OpPtrDiff: *hasResult = true; *hasResultType = true; break; + case OpTerminateInvocation: *hasResult = false; *hasResultType = false; break; case OpSubgroupBallotKHR: *hasResult = true; *hasResultType = true; break; case OpSubgroupFirstInvocationKHR: *hasResult = true; *hasResultType = true; break; case OpSubgroupAllKHR: *hasResult = true; *hasResultType = true; break; case OpSubgroupAnyKHR: *hasResult = true; *hasResultType = true; break; case OpSubgroupAllEqualKHR: *hasResult = true; *hasResultType = true; break; case OpSubgroupReadInvocationKHR: *hasResult = true; *hasResultType = true; break; - case OpTypeRayQueryProvisionalKHR: *hasResult = true; *hasResultType = false; break; + case OpTraceRayKHR: *hasResult = false; *hasResultType = false; break; + case OpExecuteCallableKHR: *hasResult = false; *hasResultType = false; break; + case OpConvertUToAccelerationStructureKHR: *hasResult = true; *hasResultType = true; break; + case OpIgnoreIntersectionKHR: *hasResult = false; *hasResultType = false; break; + case OpTerminateRayKHR: *hasResult = false; *hasResultType = false; break; + case OpTypeRayQueryKHR: *hasResult = true; *hasResultType = false; break; case OpRayQueryInitializeKHR: *hasResult = false; *hasResultType = false; break; case OpRayQueryTerminateKHR: *hasResult = false; *hasResultType = false; break; case OpRayQueryGenerateIntersectionKHR: *hasResult = false; *hasResultType = false; break; @@ -1955,6 +2036,8 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpUSubSatINTEL: *hasResult = true; *hasResultType = true; break; case OpIMul32x16INTEL: *hasResult = true; *hasResultType = true; break; case OpUMul32x16INTEL: *hasResult = true; *hasResultType = true; break; + case OpFunctionPointerINTEL: *hasResult = true; *hasResultType = true; break; + case OpFunctionPointerCallINTEL: *hasResult = true; *hasResultType = true; break; case OpDecorateString: *hasResult = false; *hasResultType = false; break; case OpMemberDecorateString: *hasResult = false; *hasResultType = false; break; case OpVmeImageINTEL: *hasResult = true; *hasResultType = true; break; @@ -2075,6 +2158,10 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpSubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL: *hasResult = true; *hasResultType = true; break; case OpSubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL: *hasResult = true; *hasResultType = true; break; case OpSubgroupAvcSicGetInterRawSadsINTEL: *hasResult = true; *hasResultType = true; break; + case OpLoopControlINTEL: *hasResult = false; *hasResultType = false; break; + case OpReadPipeBlockingINTEL: *hasResult = true; *hasResultType = true; break; + case OpWritePipeBlockingINTEL: *hasResult = true; *hasResultType = true; break; + case OpFPGARegINTEL: *hasResult = true; *hasResultType = true; break; case OpRayQueryGetRayTMinKHR: *hasResult = true; *hasResultType = true; break; case OpRayQueryGetRayFlagsKHR: *hasResult = true; *hasResultType = true; break; case OpRayQueryGetIntersectionTKHR: *hasResult = true; *hasResultType = true; break; @@ -2092,6 +2179,7 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpRayQueryGetWorldRayOriginKHR: *hasResult = true; *hasResultType = true; break; case OpRayQueryGetIntersectionObjectToWorldKHR: *hasResult = true; *hasResultType = true; break; case OpRayQueryGetIntersectionWorldToObjectKHR: *hasResult = true; *hasResultType = true; break; + case OpAtomicFAddEXT: *hasResult = true; *hasResultType = true; break; } } #endif /* SPV_ENABLE_UTILITY_CODE */ @@ -2107,6 +2195,7 @@ inline MemorySemanticsMask operator|(MemorySemanticsMask a, MemorySemanticsMask inline MemoryAccessMask operator|(MemoryAccessMask a, MemoryAccessMask b) { return MemoryAccessMask(unsigned(a) | unsigned(b)); } inline KernelProfilingInfoMask operator|(KernelProfilingInfoMask a, KernelProfilingInfoMask b) { return KernelProfilingInfoMask(unsigned(a) | unsigned(b)); } inline RayFlagsMask operator|(RayFlagsMask a, RayFlagsMask b) { return RayFlagsMask(unsigned(a) | unsigned(b)); } +inline FragmentShadingRateMask operator|(FragmentShadingRateMask a, FragmentShadingRateMask b) { return FragmentShadingRateMask(unsigned(a) | unsigned(b)); } } // end namespace spv diff --git a/third_party/spirv-cross/spirv_cfg.cpp b/third_party/spirv-cross/spirv_cfg.cpp index 9973fbae1f..0a66d60bd2 100644 --- a/third_party/spirv-cross/spirv_cfg.cpp +++ b/third_party/spirv-cross/spirv_cfg.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 Arm Limited + * Copyright 2016-2021 Arm Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #include "spirv_cfg.hpp" #include "spirv_cross.hpp" #include diff --git a/third_party/spirv-cross/spirv_cfg.hpp b/third_party/spirv-cross/spirv_cfg.hpp index 9f3e62a1bf..041526d65f 100644 --- a/third_party/spirv-cross/spirv_cfg.hpp +++ b/third_party/spirv-cross/spirv_cfg.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 Arm Limited + * Copyright 2016-2021 Arm Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #ifndef SPIRV_CROSS_CFG_HPP #define SPIRV_CROSS_CFG_HPP diff --git a/third_party/spirv-cross/spirv_common.hpp b/third_party/spirv-cross/spirv_common.hpp index d13b55e509..f0024d7edd 100644 --- a/third_party/spirv-cross/spirv_common.hpp +++ b/third_party/spirv-cross/spirv_common.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2020 Arm Limited + * Copyright 2015-2021 Arm Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #ifndef SPIRV_CROSS_COMMON_HPP #define SPIRV_CROSS_COMMON_HPP @@ -295,8 +302,20 @@ struct Instruction { uint16_t op = 0; uint16_t count = 0; + // If offset is 0 (not a valid offset into the instruction stream), + // we have an instruction stream which is embedded in the object. uint32_t offset = 0; uint32_t length = 0; + + inline bool is_embedded() const + { + return offset == 0; + } +}; + +struct EmbeddedInstruction : Instruction +{ + SmallVector ops; }; enum Types @@ -722,7 +741,9 @@ struct SPIRBlock : IVariant Return, // Block ends with return. Unreachable, // Noop - Kill // Discard + Kill, // Discard + IgnoreIntersection, // Ray Tracing + TerminateRay // Ray Tracing }; enum Merge @@ -1742,6 +1763,22 @@ struct SetBindingPair } }; +struct LocationComponentPair +{ + uint32_t location; + uint32_t component; + + inline bool operator==(const LocationComponentPair &other) const + { + return location == other.location && component == other.component; + } + + inline bool operator<(const LocationComponentPair &other) const + { + return location < other.location || (location == other.location && component < other.component); + } +}; + struct StageSetBinding { spv::ExecutionModel model; @@ -1764,6 +1801,14 @@ struct InternalHasher return (hash_set * 0x10001b31) ^ hash_binding; } + inline size_t operator()(const LocationComponentPair &value) const + { + // Quality of hash doesn't really matter here. + auto hash_set = std::hash()(value.location); + auto hash_binding = std::hash()(value.component); + return (hash_set * 0x10001b31) ^ hash_binding; + } + inline size_t operator()(const StageSetBinding &value) const { // Quality of hash doesn't really matter here. diff --git a/third_party/spirv-cross/spirv_cpp.cpp b/third_party/spirv-cross/spirv_cpp.cpp index d13d6006a2..e95fe00ee1 100644 --- a/third_party/spirv-cross/spirv_cpp.cpp +++ b/third_party/spirv-cross/spirv_cpp.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2020 Arm Limited + * Copyright 2015-2021 Arm Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #include "spirv_cpp.hpp" using namespace spv; diff --git a/third_party/spirv-cross/spirv_cpp.hpp b/third_party/spirv-cross/spirv_cpp.hpp index e78d0369f1..a3bf0edb38 100644 --- a/third_party/spirv-cross/spirv_cpp.hpp +++ b/third_party/spirv-cross/spirv_cpp.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2020 Arm Limited + * Copyright 2015-2021 Arm Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #ifndef SPIRV_CROSS_CPP_HPP #define SPIRV_CROSS_CPP_HPP diff --git a/third_party/spirv-cross/spirv_cross.cpp b/third_party/spirv-cross/spirv_cross.cpp index 21d2f2fcde..e948820d25 100644 --- a/third_party/spirv-cross/spirv_cross.cpp +++ b/third_party/spirv-cross/spirv_cross.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2020 Arm Limited + * Copyright 2015-2021 Arm Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #include "spirv_cross.hpp" #include "GLSL.std.450.h" #include "spirv_cfg.hpp" @@ -89,7 +96,9 @@ bool Compiler::variable_storage_is_aliased(const SPIRVariable &v) bool Compiler::block_is_pure(const SPIRBlock &block) { // This is a global side effect of the function. - if (block.terminator == SPIRBlock::Kill) + if (block.terminator == SPIRBlock::Kill || + block.terminator == SPIRBlock::TerminateRay || + block.terminator == SPIRBlock::IgnoreIntersection) return false; for (auto &i : block.ops) @@ -151,11 +160,13 @@ bool Compiler::block_is_pure(const SPIRBlock &block) return false; // Ray tracing builtins are impure. - case OpReportIntersectionNV: + case OpReportIntersectionKHR: case OpIgnoreIntersectionNV: case OpTerminateRayNV: case OpTraceNV: + case OpTraceRayKHR: case OpExecuteCallableNV: + case OpExecuteCallableKHR: return false; // OpExtInst is potentially impure depending on extension, but GLSL builtins are at least pure. @@ -273,31 +284,6 @@ SPIRVariable *Compiler::maybe_get_backing_variable(uint32_t chain) return var; } -StorageClass Compiler::get_expression_effective_storage_class(uint32_t ptr) -{ - auto *var = maybe_get_backing_variable(ptr); - - // If the expression has been lowered to a temporary, we need to use the Generic storage class. - // We're looking for the effective storage class of a given expression. - // An access chain or forwarded OpLoads from such access chains - // will generally have the storage class of the underlying variable, but if the load was not forwarded - // we have lost any address space qualifiers. - bool forced_temporary = ir.ids[ptr].get_type() == TypeExpression && !get(ptr).access_chain && - (forced_temporaries.count(ptr) != 0 || forwarded_temporaries.count(ptr) == 0); - - if (var && !forced_temporary) - { - // Normalize SSBOs to StorageBuffer here. - if (var->storage == StorageClassUniform && - has_decoration(get(var->basetype).self, DecorationBufferBlock)) - return StorageClassStorageBuffer; - else - return var->storage; - } - else - return expression_type(ptr).storage; -} - void Compiler::register_read(uint32_t expr, uint32_t chain, bool forwarded) { auto &e = get(expr); @@ -535,10 +521,16 @@ bool Compiler::is_hidden_variable(const SPIRVariable &var, bool include_builtins return false; } - bool hidden = false; - if (check_active_interface_variables && storage_class_is_interface(var.storage)) - hidden = active_interface_variables.find(var.self) == end(active_interface_variables); - return hidden; + // In SPIR-V 1.4 and up we must also use the active variable interface to disable global variables + // which are not part of the entry point. + if (ir.get_spirv_version() >= 0x10400 && var.storage != spv::StorageClassGeneric && + var.storage != spv::StorageClassFunction && !interface_variable_exists_in_entry_point(var.self)) + { + return true; + } + + return check_active_interface_variables && storage_class_is_interface(var.storage) && + active_interface_variables.find(var.self) == end(active_interface_variables); } bool Compiler::is_builtin_type(const SPIRType &type) const @@ -798,9 +790,17 @@ unordered_set Compiler::get_active_interface_variables() const InterfaceVariableAccessHandler handler(*this, variables); traverse_all_reachable_opcodes(get(ir.default_entry_point), handler); - // Make sure we preserve output variables which are only initialized, but never accessed by any code. ir.for_each_typed_id([&](uint32_t, const SPIRVariable &var) { - if (var.storage == StorageClassOutput && var.initializer != ID(0)) + if (var.storage != StorageClassOutput) + return; + if (!interface_variable_exists_in_entry_point(var.self)) + return; + + // An output variable which is just declared (but uninitialized) might be read by subsequent stages + // so we should force-enable these outputs, + // since compilation will fail if a subsequent stage attempts to read from the variable in question. + // Also, make sure we preserve output variables which are only initialized, but never accessed by any code. + if (var.initializer != ID(0) || get_execution_model() != ExecutionModelFragment) variables.insert(var.self); }); @@ -828,19 +828,79 @@ ShaderResources Compiler::get_shader_resources(const unordered_set * // It is possible for uniform storage classes to be passed as function parameters, so detect // that. To detect function parameters, check of StorageClass of variable is function scope. - if (var.storage == StorageClassFunction || !type.pointer || is_builtin_variable(var)) + if (var.storage == StorageClassFunction || !type.pointer) return; if (active_variables && active_variables->find(var.self) == end(*active_variables)) return; + // In SPIR-V 1.4 and up, every global must be present in the entry point interface list, + // not just IO variables. + bool active_in_entry_point = true; + if (ir.get_spirv_version() < 0x10400) + { + if (var.storage == StorageClassInput || var.storage == StorageClassOutput) + active_in_entry_point = interface_variable_exists_in_entry_point(var.self); + } + else + active_in_entry_point = interface_variable_exists_in_entry_point(var.self); + + if (!active_in_entry_point) + return; + + bool is_builtin = is_builtin_variable(var); + + if (is_builtin) + { + if (var.storage != StorageClassInput && var.storage != StorageClassOutput) + return; + + auto &list = var.storage == StorageClassInput ? res.builtin_inputs : res.builtin_outputs; + BuiltInResource resource; + + if (has_decoration(type.self, DecorationBlock)) + { + resource.resource = { var.self, var.basetype, type.self, + get_remapped_declared_block_name(var.self, false) }; + + for (uint32_t i = 0; i < uint32_t(type.member_types.size()); i++) + { + resource.value_type_id = type.member_types[i]; + resource.builtin = BuiltIn(get_member_decoration(type.self, i, DecorationBuiltIn)); + list.push_back(resource); + } + } + else + { + bool strip_array = + !has_decoration(var.self, DecorationPatch) && ( + get_execution_model() == ExecutionModelTessellationControl || + (get_execution_model() == ExecutionModelTessellationEvaluation && + var.storage == StorageClassInput)); + + resource.resource = { var.self, var.basetype, type.self, get_name(var.self) }; + + if (strip_array && !type.array.empty()) + resource.value_type_id = get_variable_data_type(var).parent_type; + else + resource.value_type_id = get_variable_data_type_id(var); + + assert(resource.value_type_id); + + resource.builtin = BuiltIn(get_decoration(var.self, DecorationBuiltIn)); + list.push_back(std::move(resource)); + } + return; + } + // Input - if (var.storage == StorageClassInput && interface_variable_exists_in_entry_point(var.self)) + if (var.storage == StorageClassInput) { if (has_decoration(type.self, DecorationBlock)) { res.stage_inputs.push_back( - { var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self, false) }); + { var.self, var.basetype, type.self, + get_remapped_declared_block_name(var.self, false) }); } else res.stage_inputs.push_back({ var.self, var.basetype, type.self, get_name(var.self) }); @@ -851,12 +911,12 @@ ShaderResources Compiler::get_shader_resources(const unordered_set * res.subpass_inputs.push_back({ var.self, var.basetype, type.self, get_name(var.self) }); } // Outputs - else if (var.storage == StorageClassOutput && interface_variable_exists_in_entry_point(var.self)) + else if (var.storage == StorageClassOutput) { if (has_decoration(type.self, DecorationBlock)) { res.stage_outputs.push_back( - { var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self, false) }); + { var.self, var.basetype, type.self, get_remapped_declared_block_name(var.self, false) }); } else res.stage_outputs.push_back({ var.self, var.basetype, type.self, get_name(var.self) }); @@ -2272,16 +2332,22 @@ SPIREntryPoint &Compiler::get_entry_point() bool Compiler::interface_variable_exists_in_entry_point(uint32_t id) const { auto &var = get(id); - if (var.storage != StorageClassInput && var.storage != StorageClassOutput && - var.storage != StorageClassUniformConstant) - SPIRV_CROSS_THROW("Only Input, Output variables and Uniform constants are part of a shader linking interface."); - // This is to avoid potential problems with very old glslang versions which did - // not emit input/output interfaces properly. - // We can assume they only had a single entry point, and single entry point - // shaders could easily be assumed to use every interface variable anyways. - if (ir.entry_points.size() <= 1) - return true; + if (ir.get_spirv_version() < 0x10400) + { + if (var.storage != StorageClassInput && var.storage != StorageClassOutput && + var.storage != StorageClassUniformConstant) + SPIRV_CROSS_THROW("Only Input, Output variables and Uniform constants are part of a shader linking interface."); + + // This is to avoid potential problems with very old glslang versions which did + // not emit input/output interfaces properly. + // We can assume they only had a single entry point, and single entry point + // shaders could easily be assumed to use every interface variable anyways. + if (ir.entry_points.size() <= 1) + return true; + } + + // In SPIR-V 1.4 and later, all global resource variables must be present. auto &execution = get_entry_point(); return find(begin(execution.interface_variables), end(execution.interface_variables), VariableID(id)) != @@ -2804,7 +2870,8 @@ const SPIRConstant &Compiler::get_constant(ConstantID id) const return get(id); } -static bool exists_unaccessed_path_to_return(const CFG &cfg, uint32_t block, const unordered_set &blocks) +static bool exists_unaccessed_path_to_return(const CFG &cfg, uint32_t block, const unordered_set &blocks, + unordered_set &visit_cache) { // This block accesses the variable. if (blocks.find(block) != end(blocks)) @@ -2816,8 +2883,14 @@ static bool exists_unaccessed_path_to_return(const CFG &cfg, uint32_t block, con // If any of our successors have a path to the end, there exists a path from block. for (auto &succ : cfg.get_succeeding_edges(block)) - if (exists_unaccessed_path_to_return(cfg, succ, blocks)) - return true; + { + if (visit_cache.count(succ) == 0) + { + if (exists_unaccessed_path_to_return(cfg, succ, blocks, visit_cache)) + return true; + visit_cache.insert(succ); + } + } return false; } @@ -2874,7 +2947,8 @@ void Compiler::analyze_parameter_preservation( // void foo(int &var) { if (cond) var = 10; } // Using read/write counts, we will think it's just an out variable, but it really needs to be inout, // because if we don't write anything whatever we put into the function must return back to the caller. - if (exists_unaccessed_path_to_return(cfg, entry.entry_block, itr->second)) + unordered_set visit_cache; + if (exists_unaccessed_path_to_return(cfg, entry.entry_block, itr->second, visit_cache)) arg.read_count++; } } @@ -3146,6 +3220,29 @@ bool Compiler::AnalyzeVariableScopeAccessHandler::handle(spv::Op op, const uint3 break; } + case OpSelect: + { + // In case of variable pointers, we might access a variable here. + // We cannot prove anything about these accesses however. + for (uint32_t i = 1; i < length; i++) + { + if (i >= 3) + { + auto *var = compiler.maybe_get_backing_variable(args[i]); + if (var) + { + accessed_variables_to_block[var->self].insert(current_block->self); + // Assume we can get partial writes to this variable. + partial_write_variables_to_block[var->self].insert(current_block->self); + } + } + + // Might try to copy a Phi variable here. + notify_variable_access(args[i], current_block->self); + } + break; + } + case OpExtInst: { for (uint32_t i = 4; i < length; i++) @@ -3832,23 +3929,55 @@ void Compiler::ActiveBuiltinHandler::handle_builtin(const SPIRType &type, BuiltI } } -bool Compiler::ActiveBuiltinHandler::handle(spv::Op opcode, const uint32_t *args, uint32_t length) +void Compiler::ActiveBuiltinHandler::add_if_builtin(uint32_t id, bool allow_blocks) { - const auto add_if_builtin = [&](uint32_t id) { - // Only handles variables here. - // Builtins which are part of a block are handled in AccessChain. - auto *var = compiler.maybe_get(id); - auto &decorations = compiler.ir.meta[id].decoration; - if (var && decorations.builtin) + // Only handle plain variables here. + // Builtins which are part of a block are handled in AccessChain. + // If allow_blocks is used however, this is to handle initializers of blocks, + // which implies that all members are written to. + + auto *var = compiler.maybe_get(id); + auto *m = compiler.ir.find_meta(id); + if (var && m) + { + auto &type = compiler.get(var->basetype); + auto &decorations = m->decoration; + auto &flags = type.storage == StorageClassInput ? + compiler.active_input_builtins : compiler.active_output_builtins; + if (decorations.builtin) { - auto &type = compiler.get(var->basetype); - auto &flags = - type.storage == StorageClassInput ? compiler.active_input_builtins : compiler.active_output_builtins; flags.set(decorations.builtin_type); handle_builtin(type, decorations.builtin_type, decorations.decoration_flags); } - }; + else if (allow_blocks && compiler.has_decoration(type.self, DecorationBlock)) + { + uint32_t member_count = uint32_t(type.member_types.size()); + for (uint32_t i = 0; i < member_count; i++) + { + if (compiler.has_member_decoration(type.self, i, DecorationBuiltIn)) + { + auto &member_type = compiler.get(type.member_types[i]); + BuiltIn builtin = BuiltIn(compiler.get_member_decoration(type.self, i, DecorationBuiltIn)); + flags.set(builtin); + handle_builtin(member_type, builtin, compiler.get_member_decoration_bitset(type.self, i)); + } + } + } + } +} +void Compiler::ActiveBuiltinHandler::add_if_builtin(uint32_t id) +{ + add_if_builtin(id, false); +} + +void Compiler::ActiveBuiltinHandler::add_if_builtin_or_block(uint32_t id) +{ + add_if_builtin(id, true); +} + +bool Compiler::ActiveBuiltinHandler::handle(spv::Op opcode, const uint32_t *args, uint32_t length) +{ switch (opcode) { case OpStore: @@ -3986,10 +4115,21 @@ void Compiler::update_active_builtins() clip_distance_count = 0; ActiveBuiltinHandler handler(*this); traverse_all_reachable_opcodes(get(ir.default_entry_point), handler); + + ir.for_each_typed_id([&](uint32_t, const SPIRVariable &var) { + if (var.storage != StorageClassOutput) + return; + if (!interface_variable_exists_in_entry_point(var.self)) + return; + + // Also, make sure we preserve output variables which are only initialized, but never accessed by any code. + if (var.initializer != ID(0)) + handler.add_if_builtin_or_block(var.self); + }); } // Returns whether this shader uses a builtin of the storage class -bool Compiler::has_active_builtin(BuiltIn builtin, StorageClass storage) +bool Compiler::has_active_builtin(BuiltIn builtin, StorageClass storage) const { const Bitset *flags; switch (storage) diff --git a/third_party/spirv-cross/spirv_cross.hpp b/third_party/spirv-cross/spirv_cross.hpp index f20ed42696..764c6c47b7 100644 --- a/third_party/spirv-cross/spirv_cross.hpp +++ b/third_party/spirv-cross/spirv_cross.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2020 Arm Limited + * Copyright 2015-2021 Arm Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #ifndef SPIRV_CROSS_HPP #define SPIRV_CROSS_HPP @@ -52,6 +59,27 @@ struct Resource std::string name; }; +struct BuiltInResource +{ + // This is mostly here to support reflection of builtins such as Position/PointSize/CullDistance/ClipDistance. + // This needs to be different from Resource since we can collect builtins from blocks. + // A builtin present here does not necessarily mean it's considered an active builtin, + // since variable ID "activeness" is only tracked on OpVariable level, not Block members. + // For that, update_active_builtins() -> has_active_builtin() can be used to further refine the reflection. + spv::BuiltIn builtin; + + // This is the actual value type of the builtin. + // Typically float4, float, array for the gl_PerVertex builtins. + // If the builtin is a control point, the control point array type will be stripped away here as appropriate. + TypeID value_type_id; + + // This refers to the base resource which contains the builtin. + // If resource is a Block, it can hold multiple builtins, or it might not be a block. + // For advanced reflection scenarios, all information in builtin/value_type_id can be deduced, + // it's just more convenient this way. + Resource resource; +}; + struct ShaderResources { SmallVector uniform_buffers; @@ -72,6 +100,9 @@ struct ShaderResources // these correspond to separate texture2D and samplers respectively. SmallVector separate_images; SmallVector separate_samplers; + + SmallVector builtin_inputs; + SmallVector builtin_outputs; }; struct CombinedImageSampler @@ -317,7 +348,7 @@ public: // Traverses all reachable opcodes and sets active_builtins to a bitmask of all builtin variables which are accessed in the shader. void update_active_builtins(); - bool has_active_builtin(spv::BuiltIn builtin, spv::StorageClass storage); + bool has_active_builtin(spv::BuiltIn builtin, spv::StorageClass storage) const; // Query and modify OpExecutionMode. const Bitset &get_execution_mode_bitset() const; @@ -491,6 +522,12 @@ public: // The most common use here is to check if a buffer is readonly or writeonly. Bitset get_buffer_block_flags(VariableID id) const; + // Returns whether the position output is invariant + bool is_position_invariant() const + { + return position_invariant; + } + protected: const uint32_t *stream(const Instruction &instr) const { @@ -500,9 +537,18 @@ protected: if (!instr.length) return nullptr; - if (instr.offset + instr.length > ir.spirv.size()) - SPIRV_CROSS_THROW("Compiler::stream() out of range."); - return &ir.spirv[instr.offset]; + if (instr.is_embedded()) + { + auto &embedded = static_cast(instr); + assert(embedded.ops.size() == instr.length); + return embedded.ops.data(); + } + else + { + if (instr.offset + instr.length > ir.spirv.size()) + SPIRV_CROSS_THROW("Compiler::stream() out of range."); + return &ir.spirv[instr.offset]; + } } ParsedIR ir; @@ -625,7 +671,6 @@ protected: bool expression_is_lvalue(uint32_t id) const; bool variable_storage_is_aliased(const SPIRVariable &var); SPIRVariable *maybe_get_backing_variable(uint32_t chain); - spv::StorageClass get_expression_effective_storage_class(uint32_t ptr); void register_read(uint32_t expr, uint32_t chain, bool forwarded); void register_write(uint32_t chain); @@ -826,6 +871,9 @@ protected: Compiler &compiler; void handle_builtin(const SPIRType &type, spv::BuiltIn builtin, const Bitset &decoration_flags); + void add_if_builtin(uint32_t id); + void add_if_builtin_or_block(uint32_t id); + void add_if_builtin(uint32_t id, bool allow_blocks); }; bool traverse_all_reachable_opcodes(const SPIRBlock &block, OpcodeHandler &handler) const; diff --git a/third_party/spirv-cross/spirv_cross_c.cpp b/third_party/spirv-cross/spirv_cross_c.cpp index 5506d8d068..866c25d109 100644 --- a/third_party/spirv-cross/spirv_cross_c.cpp +++ b/third_party/spirv-cross/spirv_cross_c.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2019-2020 Hans-Kristian Arntzen + * Copyright 2019-2021 Hans-Kristian Arntzen * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #include "spirv_cross_c.h" #if SPIRV_CROSS_C_API_CPP @@ -190,8 +197,11 @@ struct spvc_resources_s : ScratchMemoryAllocation SmallVector separate_images; SmallVector separate_samplers; SmallVector acceleration_structures; + SmallVector builtin_inputs; + SmallVector builtin_outputs; bool copy_resources(SmallVector &outputs, const SmallVector &inputs); + bool copy_resources(SmallVector &outputs, const SmallVector &inputs); bool copy_resources(const ShaderResources &resources); }; @@ -678,6 +688,26 @@ spvc_result spvc_compiler_options_set_uint(spvc_compiler_options options, spvc_c case SPVC_COMPILER_OPTION_MSL_R32UI_ALIGNMENT_CONSTANT_ID: options->msl.r32ui_alignment_constant_id = value; break; + + case SPVC_COMPILER_OPTION_MSL_IOS_USE_SIMDGROUP_FUNCTIONS: + options->msl.ios_use_simdgroup_functions = value != 0; + break; + + case SPVC_COMPILER_OPTION_MSL_EMULATE_SUBGROUPS: + options->msl.emulate_subgroups = value != 0; + break; + + case SPVC_COMPILER_OPTION_MSL_FIXED_SUBGROUP_SIZE: + options->msl.fixed_subgroup_size = value; + break; + + case SPVC_COMPILER_OPTION_MSL_FORCE_SAMPLE_RATE_SHADING: + options->msl.force_sample_rate_shading = value != 0; + break; + + case SPVC_COMPILER_OPTION_MSL_IOS_SUPPORT_BASE_VERTEX_INSTANCE: + options->msl.ios_support_base_vertex_instance = value != 0; + break; #endif default: @@ -791,6 +821,44 @@ spvc_bool spvc_compiler_variable_is_depth_or_compare(spvc_compiler compiler, spv #endif } +spvc_result spvc_compiler_mask_stage_output_by_location(spvc_compiler compiler, + unsigned location, unsigned component) +{ +#if SPIRV_CROSS_C_API_GLSL + if (compiler->backend == SPVC_BACKEND_NONE) + { + compiler->context->report_error("Cross-compilation related option used on NONE backend which only supports reflection."); + return SPVC_ERROR_INVALID_ARGUMENT; + } + + static_cast(compiler->compiler.get())->mask_stage_output_by_location(location, component); + return SPVC_SUCCESS; +#else + (void)location; + (void)component; + compiler->context->report_error("Cross-compilation related option used on NONE backend which only supports reflection."); + return SPVC_ERROR_INVALID_ARGUMENT; +#endif +} + +spvc_result spvc_compiler_mask_stage_output_by_builtin(spvc_compiler compiler, SpvBuiltIn builtin) +{ +#if SPIRV_CROSS_C_API_GLSL + if (compiler->backend == SPVC_BACKEND_NONE) + { + compiler->context->report_error("Cross-compilation related option used on NONE backend which only supports reflection."); + return SPVC_ERROR_INVALID_ARGUMENT; + } + + static_cast(compiler->compiler.get())->mask_stage_output_by_builtin(spv::BuiltIn(builtin)); + return SPVC_SUCCESS; +#else + (void)builtin; + compiler->context->report_error("Cross-compilation related option used on NONE backend which only supports reflection."); + return SPVC_ERROR_INVALID_ARGUMENT; +#endif +} + spvc_result spvc_compiler_hlsl_set_root_constants_layout(spvc_compiler compiler, const spvc_hlsl_root_constants *constant_info, size_t count) @@ -1524,6 +1592,30 @@ bool spvc_resources_s::copy_resources(SmallVector &outp return true; } +bool spvc_resources_s::copy_resources(SmallVector &outputs, + const SmallVector &inputs) +{ + for (auto &i : inputs) + { + spvc_reflected_builtin_resource br; + + br.value_type_id = i.value_type_id; + br.builtin = SpvBuiltIn(i.builtin); + + auto &r = br.resource; + r.base_type_id = i.resource.base_type_id; + r.type_id = i.resource.type_id; + r.id = i.resource.id; + r.name = context->allocate_name(i.resource.name); + if (!r.name) + return false; + + outputs.push_back(br); + } + + return true; +} + bool spvc_resources_s::copy_resources(const ShaderResources &resources) { if (!copy_resources(uniform_buffers, resources.uniform_buffers)) @@ -1550,6 +1642,10 @@ bool spvc_resources_s::copy_resources(const ShaderResources &resources) return false; if (!copy_resources(acceleration_structures, resources.acceleration_structures)) return false; + if (!copy_resources(builtin_inputs, resources.builtin_inputs)) + return false; + if (!copy_resources(builtin_outputs, resources.builtin_outputs)) + return false; return true; } @@ -1708,6 +1804,37 @@ spvc_result spvc_resources_get_resource_list_for_type(spvc_resources resources, return SPVC_SUCCESS; } +spvc_result spvc_resources_get_builtin_resource_list_for_type( + spvc_resources resources, spvc_builtin_resource_type type, + const spvc_reflected_builtin_resource **resource_list, + size_t *resource_size) +{ + const SmallVector *list = nullptr; + switch (type) + { + case SPVC_BUILTIN_RESOURCE_TYPE_STAGE_INPUT: + list = &resources->builtin_inputs; + break; + + case SPVC_BUILTIN_RESOURCE_TYPE_STAGE_OUTPUT: + list = &resources->builtin_outputs; + break; + + default: + break; + } + + if (!list) + { + resources->context->report_error("Invalid argument."); + return SPVC_ERROR_INVALID_ARGUMENT; + } + + *resource_size = list->size(); + *resource_list = list->data(); + return SPVC_SUCCESS; +} + void spvc_compiler_set_decoration(spvc_compiler compiler, SpvId id, SpvDecoration decoration, unsigned argument) { compiler->compiler->set_decoration(id, static_cast(decoration), argument); @@ -1910,6 +2037,18 @@ SpvExecutionModel spvc_compiler_get_execution_model(spvc_compiler compiler) return static_cast(compiler->compiler->get_execution_model()); } +void spvc_compiler_update_active_builtins(spvc_compiler compiler) +{ + compiler->compiler->update_active_builtins(); +} + +spvc_bool spvc_compiler_has_active_builtin(spvc_compiler compiler, SpvBuiltIn builtin, SpvStorageClass storage) +{ + return compiler->compiler->has_active_builtin(static_cast(builtin), static_cast(storage)) ? + SPVC_TRUE : + SPVC_FALSE; +} + spvc_type spvc_compiler_get_type_handle(spvc_compiler compiler, spvc_type_id id) { // Should only throw if an intentionally garbage ID is passed, but the IDs are not type-safe. diff --git a/third_party/spirv-cross/spirv_cross_c.h b/third_party/spirv-cross/spirv_cross_c.h index 7ccec0aae4..1495a7eac5 100644 --- a/third_party/spirv-cross/spirv_cross_c.h +++ b/third_party/spirv-cross/spirv_cross_c.h @@ -1,5 +1,5 @@ /* - * Copyright 2019-2020 Hans-Kristian Arntzen + * Copyright 2019-2021 Hans-Kristian Arntzen * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #ifndef SPIRV_CROSS_C_API_H #define SPIRV_CROSS_C_API_H @@ -33,7 +40,7 @@ extern "C" { /* Bumped if ABI or API breaks backwards compatibility. */ #define SPVC_C_API_VERSION_MAJOR 0 /* Bumped if APIs or enumerations are added in a backwards compatible way. */ -#define SPVC_C_API_VERSION_MINOR 42 +#define SPVC_C_API_VERSION_MINOR 47 /* Bumped if internal implementation details change. */ #define SPVC_C_API_VERSION_PATCH 0 @@ -92,6 +99,13 @@ typedef struct spvc_reflected_resource const char *name; } spvc_reflected_resource; +typedef struct spvc_reflected_builtin_resource +{ + SpvBuiltIn builtin; + spvc_type_id value_type_id; + spvc_reflected_resource resource; +} spvc_reflected_builtin_resource; + /* See C++ API. */ typedef struct spvc_entry_point { @@ -214,6 +228,14 @@ typedef enum spvc_resource_type SPVC_RESOURCE_TYPE_INT_MAX = 0x7fffffff } spvc_resource_type; +typedef enum spvc_builtin_resource_type +{ + SPVC_BUILTIN_RESOURCE_TYPE_UNKNOWN = 0, + SPVC_BUILTIN_RESOURCE_TYPE_STAGE_INPUT = 1, + SPVC_BUILTIN_RESOURCE_TYPE_STAGE_OUTPUT = 2, + SPVC_BUILTIN_RESOURCE_TYPE_INT_MAX = 0x7fffffff +} spvc_builtin_resource_type; + /* Maps to spirv_cross::SPIRType::BaseType. */ typedef enum spvc_basetype { @@ -647,6 +669,12 @@ typedef enum spvc_compiler_option SPVC_COMPILER_OPTION_HLSL_FLATTEN_MATRIX_VERTEX_INPUT_SEMANTICS = 71 | SPVC_COMPILER_OPTION_HLSL_BIT, + SPVC_COMPILER_OPTION_MSL_IOS_USE_SIMDGROUP_FUNCTIONS = 72 | SPVC_COMPILER_OPTION_MSL_BIT, + SPVC_COMPILER_OPTION_MSL_EMULATE_SUBGROUPS = 73 | SPVC_COMPILER_OPTION_MSL_BIT, + SPVC_COMPILER_OPTION_MSL_FIXED_SUBGROUP_SIZE = 74 | SPVC_COMPILER_OPTION_MSL_BIT, + SPVC_COMPILER_OPTION_MSL_FORCE_SAMPLE_RATE_SHADING = 75 | SPVC_COMPILER_OPTION_MSL_BIT, + SPVC_COMPILER_OPTION_MSL_IOS_SUPPORT_BASE_VERTEX_INSTANCE = 76 | SPVC_COMPILER_OPTION_MSL_BIT, + SPVC_COMPILER_OPTION_INT_MAX = 0x7fffffff } spvc_compiler_option; @@ -709,6 +737,10 @@ SPVC_PUBLIC_API spvc_result spvc_compiler_flatten_buffer_block(spvc_compiler com SPVC_PUBLIC_API spvc_bool spvc_compiler_variable_is_depth_or_compare(spvc_compiler compiler, spvc_variable_id id); +SPVC_PUBLIC_API spvc_result spvc_compiler_mask_stage_output_by_location(spvc_compiler compiler, + unsigned location, unsigned component); +SPVC_PUBLIC_API spvc_result spvc_compiler_mask_stage_output_by_builtin(spvc_compiler compiler, SpvBuiltIn builtin); + /* * HLSL specifics. * Maps to C++ API. @@ -792,6 +824,11 @@ SPVC_PUBLIC_API spvc_result spvc_resources_get_resource_list_for_type(spvc_resou const spvc_reflected_resource **resource_list, size_t *resource_size); +SPVC_PUBLIC_API spvc_result spvc_resources_get_builtin_resource_list_for_type( + spvc_resources resources, spvc_builtin_resource_type type, + const spvc_reflected_builtin_resource **resource_list, + size_t *resource_size); + /* * Decorations. * Maps to C++ API. @@ -848,6 +885,8 @@ SPVC_PUBLIC_API unsigned spvc_compiler_get_execution_mode_argument(spvc_compiler SPVC_PUBLIC_API unsigned spvc_compiler_get_execution_mode_argument_by_index(spvc_compiler compiler, SpvExecutionMode mode, unsigned index); SPVC_PUBLIC_API SpvExecutionModel spvc_compiler_get_execution_model(spvc_compiler compiler); +SPVC_PUBLIC_API void spvc_compiler_update_active_builtins(spvc_compiler compiler); +SPVC_PUBLIC_API spvc_bool spvc_compiler_has_active_builtin(spvc_compiler compiler, SpvBuiltIn builtin, SpvStorageClass storage); /* * Type query interface. diff --git a/third_party/spirv-cross/spirv_cross_containers.hpp b/third_party/spirv-cross/spirv_cross_containers.hpp index 357ae6227a..b9c3737c9d 100644 --- a/third_party/spirv-cross/spirv_cross_containers.hpp +++ b/third_party/spirv-cross/spirv_cross_containers.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2019-2020 Hans-Kristian Arntzen + * Copyright 2019-2021 Hans-Kristian Arntzen * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #ifndef SPIRV_CROSS_CONTAINERS_HPP #define SPIRV_CROSS_CONTAINERS_HPP diff --git a/third_party/spirv-cross/spirv_cross_error_handling.hpp b/third_party/spirv-cross/spirv_cross_error_handling.hpp index fa90610b59..32af107eb1 100644 --- a/third_party/spirv-cross/spirv_cross_error_handling.hpp +++ b/third_party/spirv-cross/spirv_cross_error_handling.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2020 Arm Limited + * Copyright 2015-2021 Arm Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #ifndef SPIRV_CROSS_ERROR_HANDLING #define SPIRV_CROSS_ERROR_HANDLING diff --git a/third_party/spirv-cross/spirv_cross_parsed_ir.cpp b/third_party/spirv-cross/spirv_cross_parsed_ir.cpp index f409d65fb7..e1a13c5e03 100644 --- a/third_party/spirv-cross/spirv_cross_parsed_ir.cpp +++ b/third_party/spirv-cross/spirv_cross_parsed_ir.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2018-2020 Arm Limited + * Copyright 2018-2021 Arm Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #include "spirv_cross_parsed_ir.hpp" #include #include @@ -228,6 +235,11 @@ bool ParsedIR::is_globally_reserved_identifier(std::string &str, bool allow_rese return is_reserved_identifier(str, false, allow_reserved_prefixes); } +uint32_t ParsedIR::get_spirv_version() const +{ + return spirv[1]; +} + static string make_unreserved_identifier(const string &name) { if (is_reserved_prefix(name)) @@ -526,6 +538,17 @@ void ParsedIR::mark_used_as_array_length(ID id) } } +Bitset ParsedIR::get_buffer_block_type_flags(const SPIRType &type) const +{ + if (type.member_types.empty()) + return {}; + + Bitset all_members_flags = get_member_decoration_bitset(type.self, 0); + for (uint32_t i = 1; i < uint32_t(type.member_types.size()); i++) + all_members_flags.merge_and(get_member_decoration_bitset(type.self, i)); + return all_members_flags; +} + Bitset ParsedIR::get_buffer_block_flags(const SPIRVariable &var) const { auto &type = get(var.basetype); @@ -542,10 +565,7 @@ Bitset ParsedIR::get_buffer_block_flags(const SPIRVariable &var) const if (type.member_types.empty()) return base_flags; - Bitset all_members_flags = get_member_decoration_bitset(type.self, 0); - for (uint32_t i = 1; i < uint32_t(type.member_types.size()); i++) - all_members_flags.merge_and(get_member_decoration_bitset(type.self, i)); - + auto all_members_flags = get_buffer_block_type_flags(type); base_flags.merge_or(all_members_flags); return base_flags; } diff --git a/third_party/spirv-cross/spirv_cross_parsed_ir.hpp b/third_party/spirv-cross/spirv_cross_parsed_ir.hpp index 36d6ac7b2c..88a0691964 100644 --- a/third_party/spirv-cross/spirv_cross_parsed_ir.hpp +++ b/third_party/spirv-cross/spirv_cross_parsed_ir.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2018-2020 Arm Limited + * Copyright 2018-2021 Arm Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #ifndef SPIRV_CROSS_PARSED_IR_HPP #define SPIRV_CROSS_PARSED_IR_HPP @@ -139,6 +146,7 @@ public: void mark_used_as_array_length(ID id); uint32_t increase_bound_by(uint32_t count); Bitset get_buffer_block_flags(const SPIRVariable &var) const; + Bitset get_buffer_block_type_flags(const SPIRType &type) const; void add_typed_id(Types type, ID id); void remove_typed_id(Types type, ID id); @@ -214,6 +222,8 @@ public: static void sanitize_identifier(std::string &str, bool member, bool allow_reserved_prefixes); static bool is_globally_reserved_identifier(std::string &str, bool allow_reserved_prefixes); + uint32_t get_spirv_version() const; + private: template T &get(uint32_t id) diff --git a/third_party/spirv-cross/spirv_cross_util.cpp b/third_party/spirv-cross/spirv_cross_util.cpp index cfad676ec1..9ce6d4fb7a 100644 --- a/third_party/spirv-cross/spirv_cross_util.cpp +++ b/third_party/spirv-cross/spirv_cross_util.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2020 Arm Limited + * Copyright 2015-2021 Arm Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #include "spirv_cross_util.hpp" #include "spirv_common.hpp" diff --git a/third_party/spirv-cross/spirv_cross_util.hpp b/third_party/spirv-cross/spirv_cross_util.hpp index 708b7cb568..daa4a7900e 100644 --- a/third_party/spirv-cross/spirv_cross_util.hpp +++ b/third_party/spirv-cross/spirv_cross_util.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2020 Arm Limited + * Copyright 2015-2021 Arm Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #ifndef SPIRV_CROSS_UTIL_HPP #define SPIRV_CROSS_UTIL_HPP diff --git a/third_party/spirv-cross/spirv_glsl.cpp b/third_party/spirv-cross/spirv_glsl.cpp index 79e47b3640..6feac01ad0 100644 --- a/third_party/spirv-cross/spirv_glsl.cpp +++ b/third_party/spirv-cross/spirv_glsl.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2020 Arm Limited + * Copyright 2015-2021 Arm Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #include "spirv_glsl.hpp" #include "GLSL.std.450.h" #include "spirv_common.hpp" @@ -33,6 +40,13 @@ using namespace spv; using namespace SPIRV_CROSS_NAMESPACE; using namespace std; +enum ExtraSubExpressionType +{ + // Create masks above any legal ID range to allow multiple address spaces into the extra_sub_expressions map. + EXTRA_SUB_EXPRESSION_TYPE_STREAM_OFFSET = 0x10000000, + EXTRA_SUB_EXPRESSION_TYPE_AUX = 0x20000000 +}; + static bool is_unsigned_opcode(Op op) { // Don't have to be exhaustive, only relevant for legacy target checking ... @@ -345,10 +359,26 @@ void CompilerGLSL::remap_pls_variables() } } -void CompilerGLSL::remap_ext_framebuffer_fetch(uint32_t input_attachment_index, uint32_t color_location) +void CompilerGLSL::remap_ext_framebuffer_fetch(uint32_t input_attachment_index, uint32_t color_location, bool coherent) { subpass_to_framebuffer_fetch_attachment.push_back({ input_attachment_index, color_location }); - inout_color_attachments.insert(color_location); + inout_color_attachments.push_back({ color_location, coherent }); +} + +bool CompilerGLSL::location_is_framebuffer_fetch(uint32_t location) const +{ + return std::find_if(begin(inout_color_attachments), end(inout_color_attachments), + [&](const std::pair &elem) { + return elem.first == location; + }) != end(inout_color_attachments); +} + +bool CompilerGLSL::location_is_non_coherent_framebuffer_fetch(uint32_t location) const +{ + return std::find_if(begin(inout_color_attachments), end(inout_color_attachments), + [&](const std::pair &elem) { + return elem.first == location && !elem.second; + }) != end(inout_color_attachments); } void CompilerGLSL::find_static_extensions() @@ -420,15 +450,37 @@ void CompilerGLSL::find_static_extensions() require_extension_internal("GL_ARB_tessellation_shader"); break; - case ExecutionModelRayGenerationNV: - case ExecutionModelIntersectionNV: - case ExecutionModelAnyHitNV: - case ExecutionModelClosestHitNV: - case ExecutionModelMissNV: - case ExecutionModelCallableNV: + case ExecutionModelRayGenerationKHR: + case ExecutionModelIntersectionKHR: + case ExecutionModelAnyHitKHR: + case ExecutionModelClosestHitKHR: + case ExecutionModelMissKHR: + case ExecutionModelCallableKHR: + // NV enums are aliases. if (options.es || options.version < 460) SPIRV_CROSS_THROW("Ray tracing shaders require non-es profile with version 460 or above."); - require_extension_internal("GL_NV_ray_tracing"); + if (!options.vulkan_semantics) + SPIRV_CROSS_THROW("Ray tracing requires Vulkan semantics."); + + // Need to figure out if we should target KHR or NV extension based on capabilities. + for (auto &cap : ir.declared_capabilities) + { + if (cap == CapabilityRayTracingKHR || cap == CapabilityRayQueryKHR) + { + ray_tracing_is_khr = true; + break; + } + } + + if (ray_tracing_is_khr) + { + // In KHR ray tracing we pass payloads by pointer instead of location, + // so make sure we assign locations properly. + ray_tracing_khr_fixup_locations(); + require_extension_internal("GL_EXT_ray_tracing"); + } + else + require_extension_internal("GL_NV_ray_tracing"); break; default: @@ -448,7 +500,22 @@ void CompilerGLSL::find_static_extensions() SPIRV_CROSS_THROW("Can only use GL_EXT_shader_framebuffer_fetch in fragment shaders."); if (options.vulkan_semantics) SPIRV_CROSS_THROW("Cannot use EXT_shader_framebuffer_fetch in Vulkan GLSL."); - require_extension_internal("GL_EXT_shader_framebuffer_fetch"); + + bool has_coherent = false; + bool has_incoherent = false; + + for (auto &att : inout_color_attachments) + { + if (att.second) + has_coherent = true; + else + has_incoherent = true; + } + + if (has_coherent) + require_extension_internal("GL_EXT_shader_framebuffer_fetch"); + if (has_incoherent) + require_extension_internal("GL_EXT_shader_framebuffer_fetch_non_coherent"); } if (options.separate_shader_objects && !options.es && options.version < 410) @@ -495,28 +562,47 @@ void CompilerGLSL::find_static_extensions() } break; + case CapabilityVariablePointers: + case CapabilityVariablePointersStorageBuffer: + SPIRV_CROSS_THROW("VariablePointers capability is not supported in GLSL."); + default: break; } } } +void CompilerGLSL::ray_tracing_khr_fixup_locations() +{ + uint32_t location = 0; + ir.for_each_typed_id([&](uint32_t, SPIRVariable &var) { + // Incoming payload storage can also be used for tracing. + if (var.storage != StorageClassRayPayloadKHR && var.storage != StorageClassCallableDataKHR && + var.storage != StorageClassIncomingRayPayloadKHR && var.storage != StorageClassIncomingCallableDataKHR) + return; + if (is_hidden_variable(var)) + return; + set_decoration(var.self, DecorationLocation, location++); + }); +} + string CompilerGLSL::compile() { ir.fixup_reserved_names(); - if (options.vulkan_semantics) - backend.allow_precision_qualifiers = true; - else + if (!options.vulkan_semantics) { // only NV_gpu_shader5 supports divergent indexing on OpenGL, and it does so without extra qualifiers backend.nonuniform_qualifier = ""; backend.needs_row_major_load_workaround = true; } + backend.allow_precision_qualifiers = options.vulkan_semantics || options.es; backend.force_gl_in_out_block = true; backend.supports_extensions = true; backend.use_array_constructor = true; + backend.support_precise_qualifier = (!options.es && options.version >= 400) || (options.es && options.version >= 320); + if (is_legacy_es()) backend.support_case_fallthrough = false; @@ -710,6 +796,8 @@ void CompilerGLSL::emit_header() { statement("#if defined(GL_AMD_gpu_shader_int16)"); statement("#extension GL_AMD_gpu_shader_int16 : require"); + statement("#elif defined(GL_NV_gpu_shader5)"); + statement("#extension GL_NV_gpu_shader5 : require"); statement("#else"); statement("#error No extension available for Int16."); statement("#endif"); @@ -1609,8 +1697,8 @@ string CompilerGLSL::layout_for_variable(const SPIRVariable &var) if (options.vulkan_semantics && var.storage == StorageClassPushConstant) attr.push_back("push_constant"); - else if (var.storage == StorageClassShaderRecordBufferNV) - attr.push_back("shaderRecordNV"); + else if (var.storage == StorageClassShaderRecordBufferKHR) + attr.push_back(ray_tracing_is_khr ? "shaderRecordEXT" : "shaderRecordNV"); if (flags.get(DecorationRowMajor)) attr.push_back("row_major"); @@ -1636,6 +1724,12 @@ string CompilerGLSL::layout_for_variable(const SPIRVariable &var) attr.push_back(join("location = ", get_decoration(var.self, DecorationLocation))); } + if (get_execution_model() == ExecutionModelFragment && var.storage == StorageClassOutput && + location_is_non_coherent_framebuffer_fetch(get_decoration(var.self, DecorationLocation))) + { + attr.push_back("noncoherent"); + } + // Transform feedback bool uses_enhanced_layouts = false; if (is_block && var.storage == StorageClassOutput) @@ -1766,14 +1860,14 @@ string CompilerGLSL::layout_for_variable(const SPIRVariable &var) // Do not emit set = decoration in regular GLSL output, but // we need to preserve it in Vulkan GLSL mode. - if (var.storage != StorageClassPushConstant && var.storage != StorageClassShaderRecordBufferNV) + if (var.storage != StorageClassPushConstant && var.storage != StorageClassShaderRecordBufferKHR) { if (flags.get(DecorationDescriptorSet) && options.vulkan_semantics) attr.push_back(join("set = ", get_decoration(var.self, DecorationDescriptorSet))); } bool push_constant_block = options.vulkan_semantics && var.storage == StorageClassPushConstant; - bool ssbo_block = var.storage == StorageClassStorageBuffer || var.storage == StorageClassShaderRecordBufferNV || + bool ssbo_block = var.storage == StorageClassStorageBuffer || var.storage == StorageClassShaderRecordBufferKHR || (var.storage == StorageClassUniform && typeflags.get(DecorationBufferBlock)); bool emulated_ubo = var.storage == StorageClassPushConstant && options.emit_push_constant_as_uniform_buffer; bool ubo_block = var.storage == StorageClassUniform && typeflags.get(DecorationBlock); @@ -1795,7 +1889,7 @@ string CompilerGLSL::layout_for_variable(const SPIRVariable &var) if (!can_use_buffer_blocks && var.storage == StorageClassUniform) can_use_binding = false; - if (var.storage == StorageClassShaderRecordBufferNV) + if (var.storage == StorageClassShaderRecordBufferKHR) can_use_binding = false; if (can_use_binding && flags.get(DecorationBinding)) @@ -2012,6 +2106,9 @@ void CompilerGLSL::emit_buffer_reference_block(SPIRType &type, bool forward_decl block_names.insert(buffer_name); block_ssbo_names.insert(buffer_name); + + // Ensure we emit the correct name when emitting non-forward pointer type. + ir.meta[type.self].decoration.alias = buffer_name; } else if (type.basetype != SPIRType::Struct) buffer_name = type_to_glsl(type); @@ -2021,7 +2118,20 @@ void CompilerGLSL::emit_buffer_reference_block(SPIRType &type, bool forward_decl if (!forward_declaration) { if (type.basetype == SPIRType::Struct) - statement("layout(buffer_reference, ", buffer_to_packing_standard(type, true), ") buffer ", buffer_name); + { + auto flags = ir.get_buffer_block_type_flags(type); + string decorations; + if (flags.get(DecorationRestrict)) + decorations += " restrict"; + if (flags.get(DecorationCoherent)) + decorations += " coherent"; + if (flags.get(DecorationNonReadable)) + decorations += " writeonly"; + if (flags.get(DecorationNonWritable)) + decorations += " readonly"; + statement("layout(buffer_reference, ", buffer_to_packing_standard(type, true), + ")", decorations, " buffer ", buffer_name); + } else statement("layout(buffer_reference) buffer ", buffer_name); @@ -2059,7 +2169,7 @@ void CompilerGLSL::emit_buffer_block_native(const SPIRVariable &var) auto &type = get(var.basetype); Bitset flags = ir.get_buffer_block_flags(var); - bool ssbo = var.storage == StorageClassStorageBuffer || var.storage == StorageClassShaderRecordBufferNV || + bool ssbo = var.storage == StorageClassStorageBuffer || var.storage == StorageClassShaderRecordBufferKHR || ir.meta[type.self].decoration.decoration_flags.get(DecorationBufferBlock); bool is_restrict = ssbo && flags.get(DecorationRestrict); bool is_writeonly = ssbo && flags.get(DecorationNonReadable); @@ -2161,7 +2271,9 @@ const char *CompilerGLSL::to_storage_qualifiers_glsl(const SPIRVariable &var) return "varying "; // Fragment outputs are renamed so they never hit this case. else if (execution.model == ExecutionModelFragment && var.storage == StorageClassOutput) { - if (inout_color_attachments.count(get_decoration(var.self, DecorationLocation)) != 0) + uint32_t loc = get_decoration(var.self, DecorationLocation); + bool is_inout = location_is_framebuffer_fetch(loc); + if (is_inout) return "inout "; else return "out "; @@ -2174,25 +2286,25 @@ const char *CompilerGLSL::to_storage_qualifiers_glsl(const SPIRVariable &var) { return "uniform "; } - else if (var.storage == StorageClassRayPayloadNV) + else if (var.storage == StorageClassRayPayloadKHR) { - return "rayPayloadNV "; + return ray_tracing_is_khr ? "rayPayloadEXT " : "rayPayloadNV "; } - else if (var.storage == StorageClassIncomingRayPayloadNV) + else if (var.storage == StorageClassIncomingRayPayloadKHR) { - return "rayPayloadInNV "; + return ray_tracing_is_khr ? "rayPayloadInEXT " : "rayPayloadInNV "; } - else if (var.storage == StorageClassHitAttributeNV) + else if (var.storage == StorageClassHitAttributeKHR) { - return "hitAttributeNV "; + return ray_tracing_is_khr ? "hitAttributeEXT " : "hitAttributeNV "; } - else if (var.storage == StorageClassCallableDataNV) + else if (var.storage == StorageClassCallableDataKHR) { - return "callableDataNV "; + return ray_tracing_is_khr ? "callableDataEXT " : "callableDataNV "; } - else if (var.storage == StorageClassIncomingCallableDataNV) + else if (var.storage == StorageClassIncomingCallableDataKHR) { - return "callableDataInNV "; + return ray_tracing_is_khr ? "callableDataInEXT " : "callableDataInNV "; } return ""; @@ -2305,6 +2417,12 @@ void CompilerGLSL::emit_interface_block(const SPIRVariable &var) { auto &type = get(var.basetype); + if (var.storage == StorageClassInput && type.basetype == SPIRType::Double && + !options.es && options.version < 410) + { + require_extension_internal("GL_ARB_vertex_attrib_64bit"); + } + // Either make it plain in/out or in/out blocks depending on what shader is doing ... bool block = ir.meta[type.self].decoration.decoration_flags.get(DecorationBlock); const char *qual = to_storage_qualifiers_glsl(var); @@ -2330,6 +2448,9 @@ void CompilerGLSL::emit_interface_block(const SPIRVariable &var) require_extension_internal("GL_EXT_shader_io_blocks"); } + // Workaround to make sure we can emit "patch in/out" correctly. + fixup_io_block_patch_qualifiers(var); + // Block names should never alias. auto block_name = to_name(type.self, false); @@ -2351,7 +2472,8 @@ void CompilerGLSL::emit_interface_block(const SPIRVariable &var) // Instance names cannot alias block names. resource_names.insert(block_name); - statement(layout_for_variable(var), qual, block_name); + bool is_patch = has_decoration(var.self, DecorationPatch); + statement(layout_for_variable(var), (is_patch ? "patch " : ""), qual, block_name); begin_scope(); type.member_name_cache.clear(); @@ -2408,14 +2530,6 @@ void CompilerGLSL::emit_interface_block(const SPIRVariable &var) swap(type.array.back(), old_array_size); swap(type.array_size_literal.back(), old_array_size_literal); } - - // If a StorageClassOutput variable has an initializer, we need to initialize it in main(). - if (var.storage == StorageClassOutput && var.initializer) - { - auto &entry_func = this->get(ir.default_entry_point); - entry_func.fixup_hooks_in.push_back( - [&]() { statement(to_name(var.self), " = ", to_expression(var.initializer), ";"); }); - } } } } @@ -2518,7 +2632,17 @@ void CompilerGLSL::replace_illegal_names(const unordered_set &keywords) return; auto &m = meta->decoration; - if (m.alias.compare(0, 3, "gl_") == 0 || keywords.find(m.alias) != end(keywords)) + if (keywords.find(m.alias) != end(keywords)) + m.alias = join("_", m.alias); + }); + + ir.for_each_typed_id([&](uint32_t, const SPIRFunction &func) { + auto *meta = ir.find_meta(func.self); + if (!meta) + return; + + auto &m = meta->decoration; + if (keywords.find(m.alias) != end(keywords)) m.alias = join("_", m.alias); }); @@ -2528,11 +2652,11 @@ void CompilerGLSL::replace_illegal_names(const unordered_set &keywords) return; auto &m = meta->decoration; - if (m.alias.compare(0, 3, "gl_") == 0 || keywords.find(m.alias) != end(keywords)) + if (keywords.find(m.alias) != end(keywords)) m.alias = join("_", m.alias); for (auto &memb : meta->members) - if (memb.alias.compare(0, 3, "gl_") == 0 || keywords.find(memb.alias) != end(keywords)) + if (keywords.find(memb.alias) != end(keywords)) memb.alias = join("_", memb.alias); }); } @@ -2762,6 +2886,13 @@ bool CompilerGLSL::should_force_emit_builtin_block(StorageClass storage) } }); + // If we're declaring clip/cull planes with control points we need to force block declaration. + if (get_execution_model() == ExecutionModelTessellationControl && + (clip_distance_count || cull_distance_count)) + { + should_force = true; + } + return should_force; } @@ -3172,8 +3303,8 @@ void CompilerGLSL::emit_resources() // Special case, ray payload and hit attribute blocks are not really blocks, just regular structs. if (type->basetype == SPIRType::Struct && type->pointer && has_decoration(type->self, DecorationBlock) && - (type->storage == StorageClassRayPayloadNV || type->storage == StorageClassIncomingRayPayloadNV || - type->storage == StorageClassHitAttributeNV)) + (type->storage == StorageClassRayPayloadKHR || type->storage == StorageClassIncomingRayPayloadKHR || + type->storage == StorageClassHitAttributeKHR)) { type = &get(type->parent_type); is_natural_struct = true; @@ -3249,7 +3380,7 @@ void CompilerGLSL::emit_resources() auto &type = this->get(var.basetype); bool is_block_storage = type.storage == StorageClassStorageBuffer || type.storage == StorageClassUniform || - type.storage == StorageClassShaderRecordBufferNV; + type.storage == StorageClassShaderRecordBufferKHR; bool has_block_flags = ir.meta[type.self].decoration.decoration_flags.get(DecorationBlock) || ir.meta[type.self].decoration.decoration_flags.get(DecorationBufferBlock); @@ -3289,9 +3420,9 @@ void CompilerGLSL::emit_resources() if (var.storage != StorageClassFunction && type.pointer && (type.storage == StorageClassUniformConstant || type.storage == StorageClassAtomicCounter || - type.storage == StorageClassRayPayloadNV || type.storage == StorageClassIncomingRayPayloadNV || - type.storage == StorageClassCallableDataNV || type.storage == StorageClassIncomingCallableDataNV || - type.storage == StorageClassHitAttributeNV) && + type.storage == StorageClassRayPayloadKHR || type.storage == StorageClassIncomingRayPayloadKHR || + type.storage == StorageClassCallableDataKHR || type.storage == StorageClassIncomingCallableDataKHR || + type.storage == StorageClassHitAttributeKHR) && !is_hidden_variable(var)) { emit_uniform(var); @@ -3313,7 +3444,7 @@ void CompilerGLSL::emit_resources() // Unused output I/O variables might still be required to implement framebuffer fetch. if (var.storage == StorageClassOutput && !is_legacy() && - inout_color_attachments.count(get_decoration(var.self, DecorationLocation)) != 0) + location_is_framebuffer_fetch(get_decoration(var.self, DecorationLocation)) != 0) { is_hidden = false; } @@ -3371,6 +3502,9 @@ void CompilerGLSL::emit_resources() for (auto global : global_variables) { auto &var = get(global); + if (is_hidden_variable(var, true)) + continue; + if (var.storage != StorageClassOutput) { if (!variable_is_lut(var)) @@ -3388,6 +3522,10 @@ void CompilerGLSL::emit_resources() emitted = true; } } + else if (var.initializer && maybe_get(var.initializer) != nullptr) + { + emit_output_variable_initializer(var); + } } if (emitted) @@ -3396,6 +3534,155 @@ void CompilerGLSL::emit_resources() declare_undefined_values(); } +void CompilerGLSL::emit_output_variable_initializer(const SPIRVariable &var) +{ + // If a StorageClassOutput variable has an initializer, we need to initialize it in main(). + auto &entry_func = this->get(ir.default_entry_point); + auto &type = get(var.basetype); + bool is_patch = has_decoration(var.self, DecorationPatch); + bool is_block = has_decoration(type.self, DecorationBlock); + bool is_control_point = get_execution_model() == ExecutionModelTessellationControl && !is_patch; + + if (is_block) + { + uint32_t member_count = uint32_t(type.member_types.size()); + bool type_is_array = type.array.size() == 1; + uint32_t array_size = 1; + if (type_is_array) + array_size = to_array_size_literal(type); + uint32_t iteration_count = is_control_point ? 1 : array_size; + + // If the initializer is a block, we must initialize each block member one at a time. + for (uint32_t i = 0; i < member_count; i++) + { + // These outputs might not have been properly declared, so don't initialize them in that case. + if (has_member_decoration(type.self, i, DecorationBuiltIn)) + { + if (get_member_decoration(type.self, i, DecorationBuiltIn) == BuiltInCullDistance && + !cull_distance_count) + continue; + + if (get_member_decoration(type.self, i, DecorationBuiltIn) == BuiltInClipDistance && + !clip_distance_count) + continue; + } + + // We need to build a per-member array first, essentially transposing from AoS to SoA. + // This code path hits when we have an array of blocks. + string lut_name; + if (type_is_array) + { + lut_name = join("_", var.self, "_", i, "_init"); + uint32_t member_type_id = get(var.basetype).member_types[i]; + auto &member_type = get(member_type_id); + auto array_type = member_type; + array_type.parent_type = member_type_id; + array_type.array.push_back(array_size); + array_type.array_size_literal.push_back(true); + + SmallVector exprs; + exprs.reserve(array_size); + auto &c = get(var.initializer); + for (uint32_t j = 0; j < array_size; j++) + exprs.push_back(to_expression(get(c.subconstants[j]).subconstants[i])); + statement("const ", type_to_glsl(array_type), " ", lut_name, type_to_array_glsl(array_type), " = ", + type_to_glsl_constructor(array_type), "(", merge(exprs, ", "), ");"); + } + + for (uint32_t j = 0; j < iteration_count; j++) + { + entry_func.fixup_hooks_in.push_back([=, &var]() { + AccessChainMeta meta; + auto &c = this->get(var.initializer); + + uint32_t invocation_id = 0; + uint32_t member_index_id = 0; + if (is_control_point) + { + uint32_t ids = ir.increase_bound_by(3); + SPIRType uint_type; + uint_type.basetype = SPIRType::UInt; + uint_type.width = 32; + set(ids, uint_type); + set(ids + 1, builtin_to_glsl(BuiltInInvocationId, StorageClassInput), ids, true); + set(ids + 2, ids, i, false); + invocation_id = ids + 1; + member_index_id = ids + 2; + } + + if (is_patch) + { + statement("if (gl_InvocationID == 0)"); + begin_scope(); + } + + if (type_is_array && !is_control_point) + { + uint32_t indices[2] = { j, i }; + auto chain = access_chain_internal(var.self, indices, 2, ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, &meta); + statement(chain, " = ", lut_name, "[", j, "];"); + } + else if (is_control_point) + { + uint32_t indices[2] = { invocation_id, member_index_id }; + auto chain = access_chain_internal(var.self, indices, 2, 0, &meta); + statement(chain, " = ", lut_name, "[", builtin_to_glsl(BuiltInInvocationId, StorageClassInput), "];"); + } + else + { + auto chain = + access_chain_internal(var.self, &i, 1, ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, &meta); + statement(chain, " = ", to_expression(c.subconstants[i]), ";"); + } + + if (is_patch) + end_scope(); + }); + } + } + } + else if (is_control_point) + { + auto lut_name = join("_", var.self, "_init"); + statement("const ", type_to_glsl(type), " ", lut_name, type_to_array_glsl(type), + " = ", to_expression(var.initializer), ";"); + entry_func.fixup_hooks_in.push_back([&, lut_name]() { + statement(to_expression(var.self), "[gl_InvocationID] = ", lut_name, "[gl_InvocationID];"); + }); + } + else if (has_decoration(var.self, DecorationBuiltIn) && + BuiltIn(get_decoration(var.self, DecorationBuiltIn)) == BuiltInSampleMask) + { + // We cannot copy the array since gl_SampleMask is unsized in GLSL. Unroll time! <_< + entry_func.fixup_hooks_in.push_back([&] { + auto &c = this->get(var.initializer); + uint32_t num_constants = uint32_t(c.subconstants.size()); + for (uint32_t i = 0; i < num_constants; i++) + { + // Don't use to_expression on constant since it might be uint, just fish out the raw int. + statement(to_expression(var.self), "[", i, "] = ", + convert_to_string(this->get(c.subconstants[i]).scalar_i32()), ";"); + } + }); + } + else + { + auto lut_name = join("_", var.self, "_init"); + statement("const ", type_to_glsl(type), " ", lut_name, + type_to_array_glsl(type), " = ", to_expression(var.initializer), ";"); + entry_func.fixup_hooks_in.push_back([&, lut_name, is_patch]() { + if (is_patch) + { + statement("if (gl_InvocationID == 0)"); + begin_scope(); + } + statement(to_expression(var.self), " = ", lut_name, ";"); + if (is_patch) + end_scope(); + }); + } +} + void CompilerGLSL::emit_extension_workarounds(spv::ExecutionModel model) { static const char *workaround_types[] = { "int", "ivec2", "ivec3", "ivec4", "uint", "uvec2", "uvec3", "uvec4", @@ -3536,9 +3823,9 @@ void CompilerGLSL::emit_extension_workarounds(spv::ExecutionModel model) statement(""); } - if (shader_subgroup_supporter.is_feature_requested(Supp::SubgroupBrodcast_First)) + if (shader_subgroup_supporter.is_feature_requested(Supp::SubgroupBroadcast_First)) { - auto exts = Supp::get_candidates_for_feature(Supp::SubgroupBrodcast_First, result); + auto exts = Supp::get_candidates_for_feature(Supp::SubgroupBroadcast_First, result); for (auto &e : exts) { @@ -3806,7 +4093,7 @@ void CompilerGLSL::emit_extension_workarounds(spv::ExecutionModel model) for (auto &type_id : workaround_ubo_load_overload_types) { auto &type = get(type_id); - statement(type_to_glsl(type), " SPIRV_Cross_workaround_load_row_major(", type_to_glsl(type), + statement(type_to_glsl(type), " spvWorkaroundRowMajor(", type_to_glsl(type), " wrap) { return wrap; }"); } statement(""); @@ -3814,7 +4101,7 @@ void CompilerGLSL::emit_extension_workarounds(spv::ExecutionModel model) if (requires_transpose_2x2) { - statement("mat2 SPIRV_Cross_Transpose(mat2 m)"); + statement("mat2 spvTranspose(mat2 m)"); begin_scope(); statement("return mat2(m[0][0], m[1][0], m[0][1], m[1][1]);"); end_scope(); @@ -3823,7 +4110,7 @@ void CompilerGLSL::emit_extension_workarounds(spv::ExecutionModel model) if (requires_transpose_3x3) { - statement("mat3 SPIRV_Cross_Transpose(mat3 m)"); + statement("mat3 spvTranspose(mat3 m)"); begin_scope(); statement("return mat3(m[0][0], m[1][0], m[2][0], m[0][1], m[1][1], m[2][1], m[0][2], m[1][2], m[2][2]);"); end_scope(); @@ -3832,7 +4119,7 @@ void CompilerGLSL::emit_extension_workarounds(spv::ExecutionModel model) if (requires_transpose_4x4) { - statement("mat4 SPIRV_Cross_Transpose(mat4 m)"); + statement("mat4 spvTranspose(mat4 m)"); begin_scope(); statement("return mat4(m[0][0], m[1][0], m[2][0], m[3][0], m[0][1], m[1][1], m[2][1], m[3][1], m[0][2], " "m[1][2], m[2][2], m[3][2], m[0][3], m[1][3], m[2][3], m[3][3]);"); @@ -4065,6 +4352,44 @@ string CompilerGLSL::to_extract_component_expression(uint32_t id, uint32_t index return join(expr, ".", index_to_swizzle(index)); } +string CompilerGLSL::to_extract_constant_composite_expression(uint32_t result_type, const SPIRConstant &c, + const uint32_t *chain, uint32_t length) +{ + // It is kinda silly if application actually enter this path since they know the constant up front. + // It is useful here to extract the plain constant directly. + SPIRConstant tmp; + tmp.constant_type = result_type; + auto &composite_type = get(c.constant_type); + assert(composite_type.basetype != SPIRType::Struct && composite_type.array.empty()); + assert(!c.specialization); + + if (is_matrix(composite_type)) + { + if (length == 2) + { + tmp.m.c[0].vecsize = 1; + tmp.m.columns = 1; + tmp.m.c[0].r[0] = c.m.c[chain[0]].r[chain[1]]; + } + else + { + assert(length == 1); + tmp.m.c[0].vecsize = composite_type.vecsize; + tmp.m.columns = 1; + tmp.m.c[0] = c.m.c[chain[0]]; + } + } + else + { + assert(length == 1); + tmp.m.c[0].vecsize = 1; + tmp.m.columns = 1; + tmp.m.c[0].r[0] = c.m.c[0].r[chain[0]]; + } + + return constant_expression(tmp); +} + string CompilerGLSL::to_rerolled_array_expression(const string &base_expr, const SPIRType &type) { uint32_t size = to_array_size_literal(type); @@ -4112,6 +4437,16 @@ string CompilerGLSL::to_composite_constructor_expression(uint32_t id, bool uses_ return to_unpacked_expression(id); } +string CompilerGLSL::to_non_uniform_aware_expression(uint32_t id) +{ + string expr = to_expression(id); + + if (has_decoration(id, DecorationNonUniform)) + convert_non_uniform_expression(expr, id); + + return expr; +} + string CompilerGLSL::to_expression(uint32_t id, bool register_expression_read) { auto itr = invalid_expressions.find(id); @@ -5250,7 +5585,12 @@ void CompilerGLSL::emit_unary_op(uint32_t result_type, uint32_t result_id, uint3 void CompilerGLSL::emit_binary_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, const char *op) { - bool forward = should_forward(op0) && should_forward(op1); + // Various FP arithmetic opcodes such as add, sub, mul will hit this. + bool force_temporary_precise = backend.support_precise_qualifier && + has_decoration(result_id, DecorationNoContraction) && + type_is_floating_point(get(result_type)); + bool forward = should_forward(op0) && should_forward(op1) && !force_temporary_precise; + emit_op(result_type, result_id, join(to_enclosed_unpacked_expression(op0), " ", op, " ", to_enclosed_unpacked_expression(op1)), forward); @@ -5429,6 +5769,27 @@ void CompilerGLSL::emit_binary_func_op(uint32_t result_type, uint32_t result_id, inherit_expression_dependencies(result_id, op1); } +void CompilerGLSL::emit_atomic_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, + const char *op) +{ + forced_temporaries.insert(result_id); + emit_op(result_type, result_id, + join(op, "(", to_non_uniform_aware_expression(op0), ", ", + to_unpacked_expression(op1), ")"), false); + flush_all_atomic_capable_variables(); +} + +void CompilerGLSL::emit_atomic_func_op(uint32_t result_type, uint32_t result_id, + uint32_t op0, uint32_t op1, uint32_t op2, + const char *op) +{ + forced_temporaries.insert(result_id); + emit_op(result_type, result_id, + join(op, "(", to_non_uniform_aware_expression(op0), ", ", + to_unpacked_expression(op1), ", ", to_unpacked_expression(op2), ")"), false); + flush_all_atomic_capable_variables(); +} + void CompilerGLSL::emit_unary_func_op_cast(uint32_t result_type, uint32_t result_id, uint32_t op0, const char *op, SPIRType::BaseType input_type, SPIRType::BaseType expected_result_type) { @@ -5439,14 +5800,27 @@ void CompilerGLSL::emit_unary_func_op_cast(uint32_t result_type, uint32_t result // Bit-widths might be different in unary cases because we use it for SConvert/UConvert and friends. expected_type.basetype = input_type; expected_type.width = expr_type.width; - string cast_op = expr_type.basetype != input_type ? bitcast_glsl(expected_type, op0) : to_unpacked_expression(op0); + + string cast_op; + if (expr_type.basetype != input_type) + { + if (expr_type.basetype == SPIRType::Boolean) + cast_op = join(type_to_glsl(expected_type), "(", to_unpacked_expression(op0), ")"); + else + cast_op = bitcast_glsl(expected_type, op0); + } + else + cast_op = to_unpacked_expression(op0); string expr; if (out_type.basetype != expected_result_type) { expected_type.basetype = expected_result_type; expected_type.width = out_type.width; - expr = bitcast_glsl_op(out_type, expected_type); + if (out_type.basetype == SPIRType::Boolean) + expr = type_to_glsl(out_type); + else + expr = bitcast_glsl_op(out_type, expected_type); expr += '('; expr += join(op, "(", cast_op, ")"); expr += ')'; @@ -5724,7 +6098,8 @@ string CompilerGLSL::legacy_tex_op(const std::string &op, const SPIRType &imgtyp // GLES has very limited support for shadow samplers. // Basically shadow2D and shadow2DProj work through EXT_shadow_samplers, // everything else can just throw - if (image_is_comparison(imgtype, tex) && is_legacy_es()) + bool is_comparison = image_is_comparison(imgtype, tex); + if (is_comparison && is_legacy_es()) { if (op == "texture" || op == "textureProj") require_extension_internal("GL_EXT_shadow_samplers"); @@ -5732,8 +6107,20 @@ string CompilerGLSL::legacy_tex_op(const std::string &op, const SPIRType &imgtyp SPIRV_CROSS_THROW(join(op, " not allowed on depth samplers in legacy ES")); } - bool is_es_and_depth = is_legacy_es() && image_is_comparison(imgtype, tex); - std::string type_prefix = image_is_comparison(imgtype, tex) ? "shadow" : "texture"; + if (op == "textureSize") + { + if (is_legacy_es()) + SPIRV_CROSS_THROW("textureSize not supported in legacy ES"); + if (is_comparison) + SPIRV_CROSS_THROW("textureSize not supported on shadow sampler in legacy GLSL"); + require_extension_internal("GL_EXT_gpu_shader4"); + } + + if (op == "texelFetch" && is_legacy_es()) + SPIRV_CROSS_THROW("texelFetch not supported in legacy ES"); + + bool is_es_and_depth = is_legacy_es() && is_comparison; + std::string type_prefix = is_comparison ? "shadow" : "texture"; if (op == "texture") return is_es_and_depth ? join(type_prefix, type, "EXT") : join(type_prefix, type); @@ -5752,6 +6139,10 @@ string CompilerGLSL::legacy_tex_op(const std::string &op, const SPIRType &imgtyp is_legacy_es() ? "ProjGradEXT" : is_legacy_desktop() ? "ProjGradARB" : "ProjGrad"); else if (op == "textureProjLodOffset") return join(type_prefix, type, "ProjLodOffset"); + else if (op == "textureSize") + return join("textureSize", type); + else if (op == "texelFetch") + return join("texelFetch", type); else { SPIRV_CROSS_THROW(join("Unsupported legacy texture op: ", op)); @@ -5901,7 +6292,7 @@ string CompilerGLSL::to_combined_image_sampler(VariableID image_id, VariableID s { // Keep track of the array indices we have used to load the image. // We'll need to use the same array index into the combined image sampler array. - auto image_expr = to_expression(image_id); + auto image_expr = to_non_uniform_aware_expression(image_id); string array_expr; auto array_index = image_expr.find_first_of('['); if (array_index != string::npos) @@ -6123,15 +6514,14 @@ std::string CompilerGLSL::to_texture_op(const Instruction &i, bool sparse, bool bool gather = false; bool proj = false; bool fetch = false; + bool nonuniform_expression = false; const uint32_t *opt = nullptr; auto &result_type = get(result_type_id); inherited_expressions.push_back(coord); - - // Make sure non-uniform decoration is back-propagated to where it needs to be. - if (has_decoration(img, DecorationNonUniformEXT)) - propagate_nonuniform_qualifier(img); + if (has_decoration(img, DecorationNonUniform) && !maybe_get_backing_variable(img)) + nonuniform_expression = true; switch (op) { @@ -6316,6 +6706,7 @@ std::string CompilerGLSL::to_texture_op(const Instruction &i, bool sparse, bool args.sample = sample; args.sparse_texel = sparse_texel_id; args.min_lod = minlod; + args.nonuniform_expression = nonuniform_expression; expr += to_function_args(args, forward); expr += ")"; @@ -6469,7 +6860,7 @@ std::string CompilerGLSL::convert_separate_image_to_expression(uint32_t id) // Don't need to consider Shadow state since the dummy sampler is always non-shadow. auto sampled_type = type; sampled_type.basetype = SPIRType::SampledImage; - return join(type_to_glsl(sampled_type), "(", to_expression(id), ", ", + return join(type_to_glsl(sampled_type), "(", to_non_uniform_aware_expression(id), ", ", to_expression(dummy_sampler_id), ")"); } else @@ -6489,7 +6880,7 @@ std::string CompilerGLSL::convert_separate_image_to_expression(uint32_t id) } } - return to_expression(id); + return to_non_uniform_aware_expression(id); } // Returns the function args for a texture sampling function for the specified image and sampling characteristics. @@ -6502,7 +6893,13 @@ string CompilerGLSL::to_function_args(const TextureFunctionArguments &args, bool if (args.base.is_fetch) farg_str = convert_separate_image_to_expression(img); else - farg_str = to_expression(img); + farg_str = to_non_uniform_aware_expression(img); + + if (args.nonuniform_expression && farg_str.find_first_of('[') != string::npos) + { + // Only emit nonuniformEXT() wrapper if the underlying expression is arrayed in some way. + farg_str = join(backend.nonuniform_qualifier, "(", farg_str, ")"); + } bool swizz_func = backend.swizzle_is_function; auto swizzle = [swizz_func](uint32_t comps, uint32_t in_comps) -> const char * { @@ -7068,7 +7465,7 @@ void CompilerGLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, { // Make sure we have a unique ID here to avoid aliasing the extra sub-expressions between clamp and NMin sub-op. // IDs cannot exceed 24 bits, so we can make use of the higher bits for some unique flags. - uint32_t &max_id = extra_sub_expressions[id | 0x80000000u]; + uint32_t &max_id = extra_sub_expressions[id | EXTRA_SUB_EXPRESSION_TYPE_AUX]; if (!max_id) max_id = ir.increase_bound_by(1); @@ -7312,7 +7709,7 @@ void CompilerGLSL::emit_subgroup_op(const Instruction &i) case OpGroupNonUniformBroadcast: case OpGroupNonUniformBroadcastFirst: - request_subgroup_feature(ShaderSubgroupSupportHelper::SubgroupBrodcast_First); + request_subgroup_feature(ShaderSubgroupSupportHelper::SubgroupBroadcast_First); break; case OpGroupNonUniformShuffle: @@ -7350,6 +7747,9 @@ void CompilerGLSL::emit_subgroup_op(const Instruction &i) case OpGroupNonUniformBitwiseAnd: case OpGroupNonUniformBitwiseOr: case OpGroupNonUniformBitwiseXor: + case OpGroupNonUniformLogicalAnd: + case OpGroupNonUniformLogicalOr: + case OpGroupNonUniformLogicalXor: { auto operation = static_cast(ops[3]); if (operation == GroupOperationClusteredReduce) @@ -7506,6 +7906,9 @@ case OpGroupNonUniform##op: \ GLSL_GROUP_OP(BitwiseAnd, And) GLSL_GROUP_OP(BitwiseOr, Or) GLSL_GROUP_OP(BitwiseXor, Xor) + GLSL_GROUP_OP(LogicalAnd, And) + GLSL_GROUP_OP(LogicalOr, Or) + GLSL_GROUP_OP(LogicalXor, Xor) #undef GLSL_GROUP_OP #undef GLSL_GROUP_OP_CAST // clang-format on @@ -7919,34 +8322,35 @@ string CompilerGLSL::builtin_to_glsl(BuiltIn builtin, StorageClass storage) request_subgroup_feature(ShaderSubgroupSupportHelper::SubgroupMask); return "gl_SubgroupLtMask"; - case BuiltInLaunchIdNV: - return "gl_LaunchIDNV"; - case BuiltInLaunchSizeNV: - return "gl_LaunchSizeNV"; - case BuiltInWorldRayOriginNV: - return "gl_WorldRayOriginNV"; - case BuiltInWorldRayDirectionNV: - return "gl_WorldRayDirectionNV"; - case BuiltInObjectRayOriginNV: - return "gl_ObjectRayOriginNV"; - case BuiltInObjectRayDirectionNV: - return "gl_ObjectRayDirectionNV"; - case BuiltInRayTminNV: - return "gl_RayTminNV"; - case BuiltInRayTmaxNV: - return "gl_RayTmaxNV"; - case BuiltInInstanceCustomIndexNV: - return "gl_InstanceCustomIndexNV"; - case BuiltInObjectToWorldNV: - return "gl_ObjectToWorldNV"; - case BuiltInWorldToObjectNV: - return "gl_WorldToObjectNV"; + case BuiltInLaunchIdKHR: + return ray_tracing_is_khr ? "gl_LaunchIDEXT" : "gl_LaunchIDNV"; + case BuiltInLaunchSizeKHR: + return ray_tracing_is_khr ? "gl_LaunchSizeEXT" : "gl_LaunchSizeNV"; + case BuiltInWorldRayOriginKHR: + return ray_tracing_is_khr ? "gl_WorldRayOriginEXT" : "gl_WorldRayOriginNV"; + case BuiltInWorldRayDirectionKHR: + return ray_tracing_is_khr ? "gl_WorldRayDirectionEXT" : "gl_WorldRayDirectionNV"; + case BuiltInObjectRayOriginKHR: + return ray_tracing_is_khr ? "gl_ObjectRayOriginEXT" : "gl_ObjectRayOriginNV"; + case BuiltInObjectRayDirectionKHR: + return ray_tracing_is_khr ? "gl_ObjectRayDirectionEXT" : "gl_ObjectRayDirectionNV"; + case BuiltInRayTminKHR: + return ray_tracing_is_khr ? "gl_RayTminEXT" : "gl_RayTminNV"; + case BuiltInRayTmaxKHR: + return ray_tracing_is_khr ? "gl_RayTmaxEXT" : "gl_RayTmaxNV"; + case BuiltInInstanceCustomIndexKHR: + return ray_tracing_is_khr ? "gl_InstanceCustomIndexEXT" : "gl_InstanceCustomIndexNV"; + case BuiltInObjectToWorldKHR: + return ray_tracing_is_khr ? "gl_ObjectToWorldEXT" : "gl_ObjectToWorldNV"; + case BuiltInWorldToObjectKHR: + return ray_tracing_is_khr ? "gl_WorldToObjectEXT" : "gl_WorldToObjectNV"; case BuiltInHitTNV: + // gl_HitTEXT is an alias of RayTMax in KHR. return "gl_HitTNV"; - case BuiltInHitKindNV: - return "gl_HitKindNV"; - case BuiltInIncomingRayFlagsNV: - return "gl_IncomingRayFlagsNV"; + case BuiltInHitKindKHR: + return ray_tracing_is_khr ? "gl_HitKindEXT" : "gl_HitKindNV"; + case BuiltInIncomingRayFlagsKHR: + return ray_tracing_is_khr ? "gl_IncomingRayFlagsEXT" : "gl_IncomingRayFlagsNV"; case BuiltInBaryCoordNV: { @@ -7979,12 +8383,35 @@ string CompilerGLSL::builtin_to_glsl(BuiltIn builtin, StorageClass storage) SPIRV_CROSS_THROW("Stencil export not supported in GLES."); } + case BuiltInPrimitiveShadingRateKHR: + { + if (!options.vulkan_semantics) + SPIRV_CROSS_THROW("Can only use PrimitiveShadingRateKHR in Vulkan GLSL."); + require_extension_internal("GL_EXT_fragment_shading_rate"); + return "gl_PrimitiveShadingRateEXT"; + } + + case BuiltInShadingRateKHR: + { + if (!options.vulkan_semantics) + SPIRV_CROSS_THROW("Can only use ShadingRateKHR in Vulkan GLSL."); + require_extension_internal("GL_EXT_fragment_shading_rate"); + return "gl_ShadingRateEXT"; + } + case BuiltInDeviceIndex: if (!options.vulkan_semantics) SPIRV_CROSS_THROW("Need Vulkan semantics for device group support."); require_extension_internal("GL_EXT_device_group"); return "gl_DeviceIndex"; + case BuiltInFullyCoveredEXT: + if (!options.es) + require_extension_internal("GL_NV_conservative_raster_underestimation"); + else + SPIRV_CROSS_THROW("Need desktop GL to use GL_NV_conservative_raster_underestimation."); + return "gl_FragFullyCoveredNV"; + default: return join("gl_BuiltIn_", convert_to_string(builtin)); } @@ -8007,7 +8434,7 @@ const char *CompilerGLSL::index_to_swizzle(uint32_t index) } } -void CompilerGLSL::access_chain_internal_append_index(std::string &expr, uint32_t /*base*/, const SPIRType *type, +void CompilerGLSL::access_chain_internal_append_index(std::string &expr, uint32_t /*base*/, const SPIRType * /*type*/, AccessChainFlags flags, bool & /*access_chain_is_arrayed*/, uint32_t index) { @@ -8016,27 +8443,19 @@ void CompilerGLSL::access_chain_internal_append_index(std::string &expr, uint32_ expr += "["; - // If we are indexing into an array of SSBOs or UBOs, we need to index it with a non-uniform qualifier. - bool nonuniform_index = - has_decoration(index, DecorationNonUniformEXT) && - (has_decoration(type->self, DecorationBlock) || has_decoration(type->self, DecorationBufferBlock)); - if (nonuniform_index) - { - expr += backend.nonuniform_qualifier; - expr += "("; - } - if (index_is_literal) expr += convert_to_string(index); else expr += to_expression(index, register_expression_read); - if (nonuniform_index) - expr += ")"; - expr += "]"; } +bool CompilerGLSL::access_chain_needs_stage_io_builtin_translation(uint32_t) +{ + return true; +} + string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indices, uint32_t count, AccessChainFlags flags, AccessChainMeta *meta) { @@ -8246,7 +8665,7 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice SPIRV_CROSS_THROW("Member index is out of bounds!"); BuiltIn builtin; - if (is_member_builtin(*type, index, &builtin)) + if (is_member_builtin(*type, index, &builtin) && access_chain_needs_stage_io_builtin_translation(base)) { if (access_chain_is_arrayed) { @@ -8314,13 +8733,30 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice // Internally, access chain implementation can also be used on composites, // ignore scalar access workarounds in this case. - StorageClass effective_storage; - if (expression_type(base).pointer) - effective_storage = get_expression_effective_storage_class(base); - else - effective_storage = StorageClassGeneric; + StorageClass effective_storage = StorageClassGeneric; + bool ignore_potential_sliced_writes = false; + if ((flags & ACCESS_CHAIN_FORCE_COMPOSITE_BIT) == 0) + { + if (expression_type(base).pointer) + effective_storage = get_expression_effective_storage_class(base); - if (!row_major_matrix_needs_conversion) + // Special consideration for control points. + // Control points can only be written by InvocationID, so there is no need + // to consider scalar access chains here. + // Cleans up some cases where it's very painful to determine the accurate storage class + // since blocks can be partially masked ... + auto *var = maybe_get_backing_variable(base); + if (var && var->storage == StorageClassOutput && + get_execution_model() == ExecutionModelTessellationControl && + !has_decoration(var->self, DecorationPatch)) + { + ignore_potential_sliced_writes = true; + } + } + else + ignore_potential_sliced_writes = true; + + if (!row_major_matrix_needs_conversion && !ignore_potential_sliced_writes) { // On some backends, we might not be able to safely access individual scalars in a vector. // To work around this, we might have to cast the access chain reference to something which can, @@ -8360,7 +8796,7 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice expr += "]"; } - if (row_major_matrix_needs_conversion) + if (row_major_matrix_needs_conversion && !ignore_potential_sliced_writes) { prepare_access_chain_for_scalar_access(expr, get(type->parent_type), effective_storage, is_packed); @@ -9341,17 +9777,22 @@ void CompilerGLSL::emit_store_statement(uint32_t lhs_expression, uint32_t rhs_ex { handle_store_to_invariant_variable(lhs_expression, rhs_expression); - auto lhs = to_dereferenced_expression(lhs_expression); + if (!unroll_array_to_complex_store(lhs_expression, rhs_expression)) + { + auto lhs = to_dereferenced_expression(lhs_expression); + if (has_decoration(lhs_expression, DecorationNonUniform)) + convert_non_uniform_expression(lhs, lhs_expression); - // We might need to cast in order to store to a builtin. - cast_to_builtin_store(lhs_expression, rhs, expression_type(rhs_expression)); + // We might need to cast in order to store to a builtin. + cast_to_builtin_store(lhs_expression, rhs, expression_type(rhs_expression)); - // Tries to optimize assignments like " = op expr". - // While this is purely cosmetic, this is important for legacy ESSL where loop - // variable increments must be in either i++ or i += const-expr. - // Without this, we end up with i = i + 1, which is correct GLSL, but not correct GLES 2.0. - if (!optimize_read_modify_write(expression_type(rhs_expression), lhs, rhs)) - statement(lhs, " = ", rhs, ";"); + // Tries to optimize assignments like " = op expr". + // While this is purely cosmetic, this is important for legacy ESSL where loop + // variable increments must be in either i++ or i += const-expr. + // Without this, we end up with i = i + 1, which is correct GLSL, but not correct GLES 2.0. + if (!optimize_read_modify_write(expression_type(rhs_expression), lhs, rhs)) + statement(lhs, " = ", rhs, ";"); + } register_write(lhs_expression); } } @@ -9513,14 +9954,13 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // We might be trying to load a gl_Position[N], where we should be // doing float4[](gl_in[i].gl_Position, ...) instead. // Similar workarounds are required for input arrays in tessellation. + // Also, loading from gl_SampleMask array needs special unroll. unroll_array_from_complex_load(id, ptr, expr); - // Shouldn't need to check for ID, but current glslang codegen requires it in some cases - // when loading Image/Sampler descriptors. It does not hurt to check ID as well. - if (has_decoration(id, DecorationNonUniformEXT) || has_decoration(ptr, DecorationNonUniformEXT)) + if (!type_is_opaque_value(type) && has_decoration(ptr, DecorationNonUniform)) { - propagate_nonuniform_qualifier(ptr); - convert_non_uniform_expression(type, expr); + // If we're loading something non-opaque, we need to handle non-uniform descriptor access. + convert_non_uniform_expression(expr, ptr); } if (forward && ptr_expression) @@ -9543,7 +9983,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // it is an array, and our backend does not support arrays as value types. // Emit the temporary, and copy it explicitly. e = &emit_uninitialized_temporary_expression(result_type, id); - emit_array_copy(to_expression(id), ptr, StorageClassFunction, get_expression_effective_storage_class(ptr)); + emit_array_copy(to_expression(id), id, ptr, StorageClassFunction, get_expression_effective_storage_class(ptr)); } else e = &emit_op(result_type, id, expr, forward, !usage_tracking); @@ -9624,9 +10064,6 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) if (expr.expression_dependencies.empty()) forwarded_temporaries.erase(ops[1]); - if (has_decoration(ops[1], DecorationNonUniformEXT)) - propagate_nonuniform_qualifier(ops[1]); - break; } @@ -9664,6 +10101,8 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) uint32_t result_type = ops[0]; uint32_t id = ops[1]; auto e = access_chain_internal(ops[2], &ops[3], length - 3, ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, nullptr); + if (has_decoration(ops[2], DecorationNonUniform)) + convert_non_uniform_expression(e, ops[2]); set(id, join(type_to_glsl(get(result_type)), "(", e, ".length())"), result_type, true); break; @@ -9925,7 +10364,8 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // Do not allow base expression for struct members. We risk doing "swizzle" optimizations in this case. auto &composite_type = expression_type(ops[2]); - if (composite_type.basetype == SPIRType::Struct || !composite_type.array.empty()) + bool composite_type_is_complex = composite_type.basetype == SPIRType::Struct || !composite_type.array.empty(); + if (composite_type_is_complex) allow_base_expression = false; // Packed expressions or physical ID mapped expressions cannot be split up. @@ -9940,10 +10380,17 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) AccessChainMeta meta; SPIRExpression *e = nullptr; + auto *c = maybe_get(ops[2]); - // Only apply this optimization if result is scalar. - if (allow_base_expression && should_forward(ops[2]) && type.vecsize == 1 && type.columns == 1 && length == 1) + if (c && !c->specialization && !composite_type_is_complex) { + auto expr = to_extract_constant_composite_expression(result_type, *c, ops + 3, length); + e = &emit_op(result_type, id, expr, true, true); + } + else if (allow_base_expression && should_forward(ops[2]) && type.vecsize == 1 && type.columns == 1 && length == 1) + { + // Only apply this optimization if result is scalar. + // We want to split the access chain from the base. // This is so we can later combine different CompositeExtract results // with CompositeConstruct without emitting code like @@ -9957,14 +10404,16 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // Including the base will prevent this and would trigger multiple reads // from expression causing it to be forced to an actual temporary in GLSL. auto expr = access_chain_internal(ops[2], &ops[3], length, - ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_CHAIN_ONLY_BIT, &meta); + ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_CHAIN_ONLY_BIT | + ACCESS_CHAIN_FORCE_COMPOSITE_BIT, &meta); e = &emit_op(result_type, id, expr, true, should_suppress_usage_tracking(ops[2])); inherit_expression_dependencies(id, ops[2]); e->base_expression = ops[2]; } else { - auto expr = access_chain_internal(ops[2], &ops[3], length, ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, &meta); + auto expr = access_chain_internal(ops[2], &ops[3], length, + ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_FORCE_COMPOSITE_BIT, &meta); e = &emit_op(result_type, id, expr, should_forward(ops[2]), should_suppress_usage_tracking(ops[2])); inherit_expression_dependencies(id, ops[2]); } @@ -10009,10 +10458,27 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) uint32_t rhs = ops[1]; if (lhs != rhs) { - flush_variable_declaration(lhs); - flush_variable_declaration(rhs); - statement(to_expression(lhs), " = ", to_unpacked_expression(rhs), ";"); - register_write(lhs); + uint32_t &tmp_id = extra_sub_expressions[instruction.offset | EXTRA_SUB_EXPRESSION_TYPE_STREAM_OFFSET]; + if (!tmp_id) + tmp_id = ir.increase_bound_by(1); + uint32_t tmp_type_id = expression_type(rhs).parent_type; + + EmbeddedInstruction fake_load, fake_store; + fake_load.op = OpLoad; + fake_load.length = 3; + fake_load.ops.push_back(tmp_type_id); + fake_load.ops.push_back(tmp_id); + fake_load.ops.push_back(rhs); + + fake_store.op = OpStore; + fake_store.length = 2; + fake_store.ops.push_back(lhs); + fake_store.ops.push_back(tmp_id); + + // Load and Store do a *lot* of workarounds, and we'd like to reuse them as much as possible. + // Synthesize a fake Load and Store pair for CopyMemory. + emit_instruction(fake_load); + emit_instruction(fake_store); } break; } @@ -10854,9 +11320,8 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // Ignore semantics for now, probably only relevant to CL. uint32_t val = ops[5]; const char *op = check_atomic_image(ptr) ? "imageAtomicExchange" : "atomicExchange"; - forced_temporaries.insert(id); - emit_binary_func_op(result_type, id, ptr, val, op); - flush_all_atomic_capable_variables(); + + emit_atomic_func_op(result_type, id, ptr, val, op); break; } @@ -10869,9 +11334,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) uint32_t comp = ops[7]; const char *op = check_atomic_image(ptr) ? "imageAtomicCompSwap" : "atomicCompSwap"; - forced_temporaries.insert(id); - emit_trinary_func_op(result_type, id, ptr, comp, val, op); - flush_all_atomic_capable_variables(); + emit_atomic_func_op(result_type, id, ptr, comp, val, op); break; } @@ -10886,7 +11349,9 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) (atomic_image && get(type.image.type).basetype == SPIRType::UInt); const char *op = atomic_image ? "imageAtomicAdd" : "atomicAdd"; const char *increment = unsigned_type ? "0u" : "0"; - emit_op(ops[0], ops[1], join(op, "(", to_expression(ops[2]), ", ", increment, ")"), false); + emit_op(ops[0], ops[1], + join(op, "(", + to_non_uniform_aware_expression(ops[2]), ", ", increment, ")"), false); flush_all_atomic_capable_variables(); break; } @@ -10899,7 +11364,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // Ignore semantics for now, probably only relevant to CL. uint32_t val = ops[3]; const char *op = check_atomic_image(ptr) ? "imageAtomicExchange" : "atomicExchange"; - statement(op, "(", to_expression(ptr), ", ", to_expression(val), ");"); + statement(op, "(", to_non_uniform_aware_expression(ptr), ", ", to_expression(val), ");"); flush_all_atomic_capable_variables(); break; } @@ -10934,7 +11399,8 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) else increment = "-1"; - emit_op(ops[0], ops[1], join(op, "(", to_expression(ops[2]), ", ", increment, ")"), false); + emit_op(ops[0], ops[1], + join(op, "(", to_non_uniform_aware_expression(ops[2]), ", ", increment, ")"), false); } flush_all_atomic_capable_variables(); @@ -10944,9 +11410,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) case OpAtomicIAdd: { const char *op = check_atomic_image(ops[2]) ? "imageAtomicAdd" : "atomicAdd"; - forced_temporaries.insert(ops[1]); - emit_binary_func_op(ops[0], ops[1], ops[2], ops[5], op); - flush_all_atomic_capable_variables(); + emit_atomic_func_op(ops[0], ops[1], ops[2], ops[5], op); break; } @@ -10954,7 +11418,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) { const char *op = check_atomic_image(ops[2]) ? "imageAtomicAdd" : "atomicAdd"; forced_temporaries.insert(ops[1]); - auto expr = join(op, "(", to_expression(ops[2]), ", -", to_enclosed_expression(ops[5]), ")"); + auto expr = join(op, "(", to_non_uniform_aware_expression(ops[2]), ", -", to_enclosed_expression(ops[5]), ")"); emit_op(ops[0], ops[1], expr, should_forward(ops[2]) && should_forward(ops[5])); flush_all_atomic_capable_variables(); break; @@ -10964,9 +11428,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) case OpAtomicUMin: { const char *op = check_atomic_image(ops[2]) ? "imageAtomicMin" : "atomicMin"; - forced_temporaries.insert(ops[1]); - emit_binary_func_op(ops[0], ops[1], ops[2], ops[5], op); - flush_all_atomic_capable_variables(); + emit_atomic_func_op(ops[0], ops[1], ops[2], ops[5], op); break; } @@ -10974,36 +11436,28 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) case OpAtomicUMax: { const char *op = check_atomic_image(ops[2]) ? "imageAtomicMax" : "atomicMax"; - forced_temporaries.insert(ops[1]); - emit_binary_func_op(ops[0], ops[1], ops[2], ops[5], op); - flush_all_atomic_capable_variables(); + emit_atomic_func_op(ops[0], ops[1], ops[2], ops[5], op); break; } case OpAtomicAnd: { const char *op = check_atomic_image(ops[2]) ? "imageAtomicAnd" : "atomicAnd"; - forced_temporaries.insert(ops[1]); - emit_binary_func_op(ops[0], ops[1], ops[2], ops[5], op); - flush_all_atomic_capable_variables(); + emit_atomic_func_op(ops[0], ops[1], ops[2], ops[5], op); break; } case OpAtomicOr: { const char *op = check_atomic_image(ops[2]) ? "imageAtomicOr" : "atomicOr"; - forced_temporaries.insert(ops[1]); - emit_binary_func_op(ops[0], ops[1], ops[2], ops[5], op); - flush_all_atomic_capable_variables(); + emit_atomic_func_op(ops[0], ops[1], ops[2], ops[5], op); break; } case OpAtomicXor: { const char *op = check_atomic_image(ops[2]) ? "imageAtomicXor" : "atomicXor"; - forced_temporaries.insert(ops[1]); - emit_binary_func_op(ops[0], ops[1], ops[2], ops[5], op); - flush_all_atomic_capable_variables(); + emit_atomic_func_op(ops[0], ops[1], ops[2], ops[5], op); break; } @@ -11098,16 +11552,33 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) case OpImageQueryLod: { + const char *op = nullptr; if (!options.es && options.version < 400) { require_extension_internal("GL_ARB_texture_query_lod"); // For some reason, the ARB spec is all-caps. - GLSL_BFOP(textureQueryLOD); + op = "textureQueryLOD"; } else if (options.es) SPIRV_CROSS_THROW("textureQueryLod not supported in ES profile."); else - GLSL_BFOP(textureQueryLod); + op = "textureQueryLod"; + + auto sampler_expr = to_expression(ops[2]); + if (has_decoration(ops[2], DecorationNonUniform)) + { + if (maybe_get_backing_variable(ops[2])) + convert_non_uniform_expression(sampler_expr, ops[2]); + else if (*backend.nonuniform_qualifier != '\0') + sampler_expr = join(backend.nonuniform_qualifier, "(", sampler_expr, ")"); + } + + bool forward = should_forward(ops[3]); + emit_op(ops[0], ops[1], + join(op, "(", sampler_expr, ", ", to_unpacked_expression(ops[3]), ")"), + forward); + inherit_expression_dependencies(ops[1], ops[2]); + inherit_expression_dependencies(ops[1], ops[3]); register_control_dependent_expression(ops[1]); break; } @@ -11137,7 +11608,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) string expr; if (type.image.sampled == 2) - expr = join("imageSamples(", to_expression(ops[2]), ")"); + expr = join("imageSamples(", to_non_uniform_aware_expression(ops[2]), ")"); else expr = join("textureSamples(", convert_separate_image_to_expression(ops[2]), ")"); @@ -11161,8 +11632,19 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) { uint32_t result_type = ops[0]; uint32_t id = ops[1]; + uint32_t img = ops[2]; - auto expr = join("textureSize(", convert_separate_image_to_expression(ops[2]), ", ", + std::string fname = "textureSize"; + if (is_legacy_desktop()) + { + auto &type = expression_type(img); + auto &imgtype = get(type.self); + fname = legacy_tex_op(fname, imgtype, img); + } + else if (is_legacy_es()) + SPIRV_CROSS_THROW("textureSize is not supported in ESSL 100."); + + auto expr = join(fname, "(", convert_separate_image_to_expression(img), ", ", bitcast_expression(SPIRType::Int, ops[3]), ")"); auto &restype = get(ops[0]); expr = bitcast_expression(restype, SPIRType::Int, expr); @@ -11237,10 +11719,10 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) "operand mask was used."); uint32_t samples = ops[5]; - imgexpr = join("subpassLoad(", to_expression(ops[2]), ", ", to_expression(samples), ")"); + imgexpr = join("subpassLoad(", to_non_uniform_aware_expression(ops[2]), ", ", to_expression(samples), ")"); } else - imgexpr = join("subpassLoad(", to_expression(ops[2]), ")"); + imgexpr = join("subpassLoad(", to_non_uniform_aware_expression(ops[2]), ")"); } else { @@ -11252,13 +11734,13 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) "operand mask was used."); uint32_t samples = ops[5]; - imgexpr = join("texelFetch(", to_expression(ops[2]), ", ivec2(gl_FragCoord.xy), ", + imgexpr = join("texelFetch(", to_non_uniform_aware_expression(ops[2]), ", ivec2(gl_FragCoord.xy), ", to_expression(samples), ")"); } else { // Implement subpass loads via texture barrier style sampling. - imgexpr = join("texelFetch(", to_expression(ops[2]), ", ivec2(gl_FragCoord.xy), 0)"); + imgexpr = join("texelFetch(", to_non_uniform_aware_expression(ops[2]), ", ivec2(gl_FragCoord.xy), 0)"); } } imgexpr = remap_swizzle(get(result_type), 4, imgexpr); @@ -11289,12 +11771,12 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) "operand mask was used."); uint32_t samples = ops[5]; - statement(to_expression(sparse_code_id), " = sparseImageLoadARB(", to_expression(ops[2]), ", ", + statement(to_expression(sparse_code_id), " = sparseImageLoadARB(", to_non_uniform_aware_expression(ops[2]), ", ", coord_expr, ", ", to_expression(samples), ", ", to_expression(sparse_texel_id), ");"); } else { - statement(to_expression(sparse_code_id), " = sparseImageLoadARB(", to_expression(ops[2]), ", ", + statement(to_expression(sparse_code_id), " = sparseImageLoadARB(", to_non_uniform_aware_expression(ops[2]), ", ", coord_expr, ", ", to_expression(sparse_texel_id), ");"); } imgexpr = join(type_to_glsl(get(result_type)), "(", to_expression(sparse_code_id), ", ", @@ -11311,10 +11793,10 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) uint32_t samples = ops[5]; imgexpr = - join("imageLoad(", to_expression(ops[2]), ", ", coord_expr, ", ", to_expression(samples), ")"); + join("imageLoad(", to_non_uniform_aware_expression(ops[2]), ", ", coord_expr, ", ", to_expression(samples), ")"); } else - imgexpr = join("imageLoad(", to_expression(ops[2]), ", ", coord_expr, ")"); + imgexpr = join("imageLoad(", to_non_uniform_aware_expression(ops[2]), ", ", coord_expr, ")"); } if (!sparse) @@ -11355,9 +11837,6 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) coord_expr = bitcast_expression(target_coord_type, expression_type(ops[3]).basetype, coord_expr); auto expr = join(to_expression(ops[2]), ", ", coord_expr); - if (has_decoration(id, DecorationNonUniformEXT) || has_decoration(ops[2], DecorationNonUniformEXT)) - convert_non_uniform_expression(expression_type(ops[2]), expr); - auto &e = set(id, expr, result_type, true); // When using the pointer, we need to know which variable it is actually loaded from. @@ -11400,11 +11879,11 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) if (operands != ImageOperandsSampleMask || length != 5) SPIRV_CROSS_THROW("Multisampled image used in OpImageWrite, but unexpected operand mask was used."); uint32_t samples = ops[4]; - statement("imageStore(", to_expression(ops[0]), ", ", coord_expr, ", ", to_expression(samples), ", ", + statement("imageStore(", to_non_uniform_aware_expression(ops[0]), ", ", coord_expr, ", ", to_expression(samples), ", ", remap_swizzle(store_type, value_type.vecsize, to_expression(ops[2])), ");"); } else - statement("imageStore(", to_expression(ops[0]), ", ", coord_expr, ", ", + statement("imageStore(", to_non_uniform_aware_expression(ops[0]), ", ", coord_expr, ", ", remap_swizzle(store_type, value_type.vecsize, to_expression(ops[2])), ");"); if (var && variable_storage_is_aliased(*var)) @@ -11423,13 +11902,24 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) string expr; if (type.image.sampled == 2) { + if (!options.es && options.version < 430) + require_extension_internal("GL_ARB_shader_image_size"); + else if (options.es && options.version < 310) + SPIRV_CROSS_THROW("At least ESSL 3.10 required for imageSize."); + // The size of an image is always constant. - expr = join("imageSize(", to_expression(ops[2]), ")"); + expr = join("imageSize(", to_non_uniform_aware_expression(ops[2]), ")"); } else { // This path is hit for samplerBuffers and multisampled images which do not have LOD. - expr = join("textureSize(", convert_separate_image_to_expression(ops[2]), ")"); + std::string fname = "textureSize"; + if (is_legacy()) + { + auto &imgtype = get(type.self); + fname = legacy_tex_op(fname, imgtype, ops[2]); + } + expr = join(fname, "(", convert_separate_image_to_expression(ops[2]), ")"); } auto &restype = get(ops[0]); @@ -11821,6 +12311,9 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) case OpGroupNonUniformBitwiseAnd: case OpGroupNonUniformBitwiseOr: case OpGroupNonUniformBitwiseXor: + case OpGroupNonUniformLogicalAnd: + case OpGroupNonUniformLogicalOr: + case OpGroupNonUniformLogicalXor: case OpGroupNonUniformQuadSwap: case OpGroupNonUniformQuadBroadcast: emit_subgroup_op(instruction); @@ -11920,29 +12413,55 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) break; } - case OpReportIntersectionNV: - statement("reportIntersectionNV(", to_expression(ops[0]), ", ", to_expression(ops[1]), ");"); + case OpReportIntersectionKHR: + // NV is same opcode. + forced_temporaries.insert(ops[1]); + if (ray_tracing_is_khr) + GLSL_BFOP(reportIntersectionEXT); + else + GLSL_BFOP(reportIntersectionNV); flush_control_dependent_expressions(current_emitting_block->self); break; case OpIgnoreIntersectionNV: + // KHR variant is a terminator. statement("ignoreIntersectionNV();"); flush_control_dependent_expressions(current_emitting_block->self); break; case OpTerminateRayNV: + // KHR variant is a terminator. statement("terminateRayNV();"); flush_control_dependent_expressions(current_emitting_block->self); break; case OpTraceNV: - statement("traceNV(", to_expression(ops[0]), ", ", to_expression(ops[1]), ", ", to_expression(ops[2]), ", ", + statement("traceNV(", to_non_uniform_aware_expression(ops[0]), ", ", to_expression(ops[1]), ", ", to_expression(ops[2]), ", ", to_expression(ops[3]), ", ", to_expression(ops[4]), ", ", to_expression(ops[5]), ", ", to_expression(ops[6]), ", ", to_expression(ops[7]), ", ", to_expression(ops[8]), ", ", to_expression(ops[9]), ", ", to_expression(ops[10]), ");"); flush_control_dependent_expressions(current_emitting_block->self); break; + case OpTraceRayKHR: + if (!has_decoration(ops[10], DecorationLocation)) + SPIRV_CROSS_THROW("A memory declaration object must be used in TraceRayKHR."); + statement("traceRayEXT(", to_non_uniform_aware_expression(ops[0]), ", ", to_expression(ops[1]), ", ", to_expression(ops[2]), ", ", + to_expression(ops[3]), ", ", to_expression(ops[4]), ", ", to_expression(ops[5]), ", ", + to_expression(ops[6]), ", ", to_expression(ops[7]), ", ", to_expression(ops[8]), ", ", + to_expression(ops[9]), ", ", get_decoration(ops[10], DecorationLocation), ");"); + flush_control_dependent_expressions(current_emitting_block->self); + break; case OpExecuteCallableNV: statement("executeCallableNV(", to_expression(ops[0]), ", ", to_expression(ops[1]), ");"); flush_control_dependent_expressions(current_emitting_block->self); break; + case OpExecuteCallableKHR: + if (!has_decoration(ops[1], DecorationLocation)) + SPIRV_CROSS_THROW("A memory declaration object must be used in ExecuteCallableKHR."); + statement("executeCallableEXT(", to_expression(ops[0]), ", ", get_decoration(ops[1], DecorationLocation), ");"); + flush_control_dependent_expressions(current_emitting_block->self); + break; + + case OpConvertUToAccelerationStructureKHR: + GLSL_UFOP(accelerationStructureEXT); + break; case OpConvertUToPtr: { @@ -12209,7 +12728,7 @@ string CompilerGLSL::convert_row_major_matrix(string exp_str, const SPIRType &ex } else SPIRV_CROSS_THROW("Non-square matrices are not supported in legacy GLSL, cannot transpose."); - return join("SPIRV_Cross_Transpose(", exp_str, ")"); + return join("spvTranspose(", exp_str, ")"); } else return join("transpose(", exp_str, ")"); @@ -12222,6 +12741,11 @@ string CompilerGLSL::variable_decl(const SPIRType &type, const string &name, uin return join(type_name, " ", name, type_to_array_glsl(type)); } +bool CompilerGLSL::variable_decl_is_remapped_storage(const SPIRVariable &var, StorageClass storage) const +{ + return var.storage == storage; +} + // Emit a structure member. Subclasses may override to modify output, // or to dynamically add a padding member if needed. void CompilerGLSL::emit_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index, @@ -12249,7 +12773,7 @@ void CompilerGLSL::emit_struct_padding_target(const SPIRType &) { } -const char *CompilerGLSL::flags_to_qualifiers_glsl(const SPIRType &type, const Bitset &flags) +string CompilerGLSL::flags_to_qualifiers_glsl(const SPIRType &type, const Bitset &flags) { // GL_EXT_buffer_reference variables can be marked as restrict. if (flags.get(DecorationRestrictPointerEXT)) @@ -12261,6 +12785,11 @@ const char *CompilerGLSL::flags_to_qualifiers_glsl(const SPIRType &type, const B type.basetype != SPIRType::Sampler) return ""; + string qual; + + if (flags.get(DecorationNoContraction) && backend.support_precise_qualifier) + qual = "precise "; + if (options.es) { auto &execution = get_entry_point(); @@ -12275,7 +12804,7 @@ const char *CompilerGLSL::flags_to_qualifiers_glsl(const SPIRType &type, const B options.fragment.default_int_precision == Options::Mediump && execution.model == ExecutionModelFragment; - return implied_fmediump || implied_imediump ? "" : "mediump "; + qual += (implied_fmediump || implied_imediump) ? "" : "mediump "; } else { @@ -12289,7 +12818,7 @@ const char *CompilerGLSL::flags_to_qualifiers_glsl(const SPIRType &type, const B execution.model == ExecutionModelFragment) || (execution.model != ExecutionModelFragment)); - return implied_fhighp || implied_ihighp ? "" : "highp "; + qual += (implied_fhighp || implied_ihighp) ? "" : "highp "; } } else if (backend.allow_precision_qualifiers) @@ -12297,18 +12826,16 @@ const char *CompilerGLSL::flags_to_qualifiers_glsl(const SPIRType &type, const B // Vulkan GLSL supports precision qualifiers, even in desktop profiles, which is convenient. // The default is highp however, so only emit mediump in the rare case that a shader has these. if (flags.get(DecorationRelaxedPrecision)) - return "mediump "; - else - return ""; + qual += "mediump "; } - else - return ""; + + return qual; } -const char *CompilerGLSL::to_precision_qualifiers_glsl(uint32_t id) +string CompilerGLSL::to_precision_qualifiers_glsl(uint32_t id) { auto &type = expression_type(id); - bool use_precision_qualifiers = backend.allow_precision_qualifiers || options.es; + bool use_precision_qualifiers = backend.allow_precision_qualifiers; if (use_precision_qualifiers && (type.basetype == SPIRType::Image || type.basetype == SPIRType::SampledImage)) { // Force mediump for the sampler type. We cannot declare 16-bit or smaller image types. @@ -12319,6 +12846,31 @@ const char *CompilerGLSL::to_precision_qualifiers_glsl(uint32_t id) return flags_to_qualifiers_glsl(type, ir.meta[id].decoration.decoration_flags); } +void CompilerGLSL::fixup_io_block_patch_qualifiers(const SPIRVariable &var) +{ + // Works around weird behavior in glslangValidator where + // a patch out block is translated to just block members getting the decoration. + // To make glslang not complain when we compile again, we have to transform this back to a case where + // the variable itself has Patch decoration, and not members. + auto &type = get(var.basetype); + if (has_decoration(type.self, DecorationBlock)) + { + uint32_t member_count = uint32_t(type.member_types.size()); + for (uint32_t i = 0; i < member_count; i++) + { + if (has_member_decoration(type.self, i, DecorationPatch)) + { + set_decoration(var.self, DecorationPatch); + break; + } + } + + if (has_decoration(var.self, DecorationPatch)) + for (uint32_t i = 0; i < member_count; i++) + unset_member_decoration(type.self, i, DecorationPatch); + } +} + string CompilerGLSL::to_qualifiers_glsl(uint32_t id) { auto &flags = ir.meta[id].decoration.decoration_flags; @@ -12340,10 +12892,24 @@ string CompilerGLSL::to_qualifiers_glsl(uint32_t id) res += "coherent "; if (flags.get(DecorationRestrict)) res += "restrict "; + if (flags.get(DecorationNonWritable)) res += "readonly "; + + bool formatted_load = type.image.format == ImageFormatUnknown; if (flags.get(DecorationNonReadable)) + { res += "writeonly "; + formatted_load = false; + } + + if (formatted_load) + { + if (!options.es) + require_extension_internal("GL_EXT_shader_image_load_formatted"); + else + SPIRV_CROSS_THROW("Cannot use GL_EXT_shader_image_load_formatted in ESSL."); + } } res += to_precision_qualifiers_glsl(id); @@ -12409,7 +12975,7 @@ string CompilerGLSL::variable_decl(const SPIRVariable &variable) // Ignore the pointer type since GLSL doesn't have pointers. auto &type = get_variable_data_type(variable); - if (type.pointer_depth > 1) + if (type.pointer_depth > 1 && !backend.support_pointer_to_pointer) SPIRV_CROSS_THROW("Cannot declare pointer-to-pointer types."); auto res = join(to_qualifiers_glsl(variable.self), variable_decl(type, to_name(variable.self), variable.self)); @@ -12422,7 +12988,7 @@ string CompilerGLSL::variable_decl(const SPIRVariable &variable) else if (options.force_zero_initialized_variables && type_can_zero_initialize(type)) res += join(" = ", to_zero_initialized_expression(get_variable_data_type_id(variable))); } - else if (variable.initializer) + else if (variable.initializer && !variable_decl_is_remapped_storage(variable, StorageClassWorkgroup)) { uint32_t expr = variable.initializer; if (ir.ids[expr].get_type() != TypeUndef) @@ -12712,7 +13278,7 @@ string CompilerGLSL::type_to_glsl(const SPIRType &type, uint32_t id) return comparison_ids.count(id) ? "samplerShadow" : "sampler"; case SPIRType::AccelerationStructure: - return "accelerationStructureNV"; + return ray_tracing_is_khr ? "accelerationStructureEXT" : "accelerationStructureNV"; case SPIRType::Void: return "void"; @@ -13112,7 +13678,7 @@ void CompilerGLSL::emit_function(SPIRFunction &func, const Bitset &return_flags) auto &var = get(v); var.deferred_declaration = false; - if (var.storage == StorageClassWorkgroup) + if (variable_decl_is_remapped_storage(var, StorageClassWorkgroup)) { // Special variable type which cannot have initializer, // need to be declared as standalone variables. @@ -14187,8 +14753,8 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block) if (is_legacy_es()) { uint32_t counter = statement_count; - statement("for (int SPIRV_Cross_Dummy", counter, " = 0; SPIRV_Cross_Dummy", counter, - " < 1; SPIRV_Cross_Dummy", counter, "++)"); + statement("for (int spvDummy", counter, " = 0; spvDummy", counter, + " < 1; spvDummy", counter, "++)"); } else statement("do"); @@ -14314,7 +14880,7 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block) // The backend is responsible for setting this up, and redirection the return values as appropriate. if (ir.ids[block.return_value].get_type() != TypeUndef) { - emit_array_copy("SPIRV_Cross_return_value", block.return_value, StorageClassFunction, + emit_array_copy("spvReturnValue", 0, block.return_value, StorageClassFunction, get_expression_effective_storage_class(block.return_value)); } @@ -14351,6 +14917,14 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block) emit_next_block = false; break; + case SPIRBlock::IgnoreIntersection: + statement("ignoreIntersectionEXT;"); + break; + + case SPIRBlock::TerminateRay: + statement("terminateRayEXT;"); + break; + default: SPIRV_CROSS_THROW("Unimplemented block terminator."); } @@ -14525,11 +15099,48 @@ uint32_t CompilerGLSL::mask_relevant_memory_semantics(uint32_t semantics) MemorySemanticsCrossWorkgroupMemoryMask | MemorySemanticsSubgroupMemoryMask); } -void CompilerGLSL::emit_array_copy(const string &lhs, uint32_t rhs_id, StorageClass, StorageClass) +void CompilerGLSL::emit_array_copy(const string &lhs, uint32_t, uint32_t rhs_id, StorageClass, StorageClass) { statement(lhs, " = ", to_expression(rhs_id), ";"); } +bool CompilerGLSL::unroll_array_to_complex_store(uint32_t target_id, uint32_t source_id) +{ + if (!backend.force_gl_in_out_block) + return false; + // This path is only relevant for GL backends. + + auto *var = maybe_get(target_id); + if (!var || var->storage != StorageClassOutput) + return false; + + if (!is_builtin_variable(*var) || BuiltIn(get_decoration(var->self, DecorationBuiltIn)) != BuiltInSampleMask) + return false; + + auto &type = expression_type(source_id); + string array_expr; + if (type.array_size_literal.back()) + { + array_expr = convert_to_string(type.array.back()); + if (type.array.back() == 0) + SPIRV_CROSS_THROW("Cannot unroll an array copy from unsized array."); + } + else + array_expr = to_expression(type.array.back()); + + SPIRType target_type; + target_type.basetype = SPIRType::Int; + + statement("for (int i = 0; i < int(", array_expr, "); i++)"); + begin_scope(); + statement(to_expression(target_id), "[i] = ", + bitcast_expression(target_type, type.basetype, join(to_expression(source_id), "[i]")), + ";"); + end_scope(); + + return true; +} + void CompilerGLSL::unroll_array_from_complex_load(uint32_t target_id, uint32_t source_id, std::string &expr) { if (!backend.force_gl_in_out_block) @@ -14540,7 +15151,7 @@ void CompilerGLSL::unroll_array_from_complex_load(uint32_t target_id, uint32_t s if (!var) return; - if (var->storage != StorageClassInput) + if (var->storage != StorageClassInput && var->storage != StorageClassOutput) return; auto &type = get_variable_data_type(*var); @@ -14548,9 +15159,13 @@ void CompilerGLSL::unroll_array_from_complex_load(uint32_t target_id, uint32_t s return; auto builtin = BuiltIn(get_decoration(var->self, DecorationBuiltIn)); - bool is_builtin = is_builtin_variable(*var) && (builtin == BuiltInPointSize || builtin == BuiltInPosition); + bool is_builtin = is_builtin_variable(*var) && + (builtin == BuiltInPointSize || + builtin == BuiltInPosition || + builtin == BuiltInSampleMask); bool is_tess = is_tessellation_shader(); bool is_patch = has_decoration(var->self, DecorationPatch); + bool is_sample_mask = is_builtin && builtin == BuiltInSampleMask; // Tessellation input arrays are special in that they are unsized, so we cannot directly copy from it. // We must unroll the array load. @@ -14574,8 +15189,14 @@ void CompilerGLSL::unroll_array_from_complex_load(uint32_t target_id, uint32_t s // The array size might be a specialization constant, so use a for-loop instead. statement("for (int i = 0; i < int(", array_expr, "); i++)"); begin_scope(); - if (is_builtin) + if (is_builtin && !is_sample_mask) statement(new_expr, "[i] = gl_in[i].", expr, ";"); + else if (is_sample_mask) + { + SPIRType target_type; + target_type.basetype = SPIRType::Int; + statement(new_expr, "[i] = ", bitcast_expression(target_type, type.basetype, join(expr, "[i]")), ";"); + } else statement(new_expr, "[i] = ", expr, "[i];"); end_scope(); @@ -14586,6 +15207,10 @@ void CompilerGLSL::unroll_array_from_complex_load(uint32_t target_id, uint32_t s void CompilerGLSL::cast_from_builtin_load(uint32_t source_id, std::string &expr, const SPIRType &expr_type) { + // We will handle array cases elsewhere. + if (!expr_type.array.empty()) + return; + auto *var = maybe_get_backing_variable(source_id); if (var) source_id = var->self; @@ -14613,6 +15238,9 @@ void CompilerGLSL::cast_from_builtin_load(uint32_t source_id, std::string &expr, case BuiltInDrawIndex: case BuiltInFragStencilRefEXT: case BuiltInInstanceCustomIndexNV: + case BuiltInSampleMask: + case BuiltInPrimitiveShadingRateKHR: + case BuiltInShadingRateKHR: expected_type = SPIRType::Int; break; @@ -14638,6 +15266,10 @@ void CompilerGLSL::cast_from_builtin_load(uint32_t source_id, std::string &expr, void CompilerGLSL::cast_to_builtin_store(uint32_t target_id, std::string &expr, const SPIRType &expr_type) { + auto *var = maybe_get_backing_variable(target_id); + if (var) + target_id = var->self; + // Only interested in standalone builtin variables. if (!has_decoration(target_id, DecorationBuiltIn)) return; @@ -14652,6 +15284,9 @@ void CompilerGLSL::cast_to_builtin_store(uint32_t target_id, std::string &expr, case BuiltInPrimitiveId: case BuiltInViewportIndex: case BuiltInFragStencilRefEXT: + case BuiltInSampleMask: + case BuiltInPrimitiveShadingRateKHR: + case BuiltInShadingRateKHR: expected_type = SPIRType::Int; break; @@ -14667,64 +15302,62 @@ void CompilerGLSL::cast_to_builtin_store(uint32_t target_id, std::string &expr, } } -void CompilerGLSL::convert_non_uniform_expression(const SPIRType &type, std::string &expr) +void CompilerGLSL::convert_non_uniform_expression(string &expr, uint32_t ptr_id) { if (*backend.nonuniform_qualifier == '\0') return; - // Handle SPV_EXT_descriptor_indexing. - if (type.basetype == SPIRType::Sampler || type.basetype == SPIRType::SampledImage || - type.basetype == SPIRType::Image) + auto *var = maybe_get_backing_variable(ptr_id); + if (!var) + return; + + if (var->storage != StorageClassUniformConstant && + var->storage != StorageClassStorageBuffer && + var->storage != StorageClassUniform) + return; + + auto &backing_type = get(var->basetype); + if (backing_type.array.empty()) + return; + + // If we get here, we know we're accessing an arrayed resource which + // might require nonuniform qualifier. + + auto start_array_index = expr.find_first_of('['); + + if (start_array_index == string::npos) + return; + + // We've opened a bracket, track expressions until we can close the bracket. + // This must be our resource index. + size_t end_array_index = string::npos; + unsigned bracket_count = 1; + for (size_t index = start_array_index + 1; index < expr.size(); index++) { - // The image/sampler ID must be declared as non-uniform. - // However, it is not legal GLSL to have - // nonuniformEXT(samplers[index]), so we must move the nonuniform qualifier - // to the array indexing, like - // samplers[nonuniformEXT(index)]. - // While the access chain will generally be nonuniformEXT, it's not necessarily so, - // so we might have to fixup the OpLoad-ed expression late. - - auto start_array_index = expr.find_first_of('['); - - if (start_array_index == string::npos) - return; - - // Check for the edge case that a non-arrayed resource was marked to be nonuniform, - // and the bracket we found is actually part of non-resource related data. - if (expr.find_first_of(',') < start_array_index) - return; - - // We've opened a bracket, track expressions until we can close the bracket. - // This must be our image index. - size_t end_array_index = string::npos; - unsigned bracket_count = 1; - for (size_t index = start_array_index + 1; index < expr.size(); index++) + if (expr[index] == ']') { - if (expr[index] == ']') + if (--bracket_count == 0) { - if (--bracket_count == 0) - { - end_array_index = index; - break; - } + end_array_index = index; + break; } - else if (expr[index] == '[') - bracket_count++; } - - assert(bracket_count == 0); - - // Doesn't really make sense to declare a non-arrayed image with nonuniformEXT, but there's - // nothing we can do here to express that. - if (start_array_index == string::npos || end_array_index == string::npos || end_array_index < start_array_index) - return; - - start_array_index++; - - expr = join(expr.substr(0, start_array_index), backend.nonuniform_qualifier, "(", - expr.substr(start_array_index, end_array_index - start_array_index), ")", - expr.substr(end_array_index, string::npos)); + else if (expr[index] == '[') + bracket_count++; } + + assert(bracket_count == 0); + + // Doesn't really make sense to declare a non-arrayed image with nonuniformEXT, but there's + // nothing we can do here to express that. + if (start_array_index == string::npos || end_array_index == string::npos || end_array_index < start_array_index) + return; + + start_array_index++; + + expr = join(expr.substr(0, start_array_index), backend.nonuniform_qualifier, "(", + expr.substr(start_array_index, end_array_index - start_array_index), ")", + expr.substr(end_array_index, string::npos)); } void CompilerGLSL::emit_block_hints(const SPIRBlock &) @@ -14830,40 +15463,6 @@ void CompilerGLSL::emit_line_directive(uint32_t file_id, uint32_t line_literal) } } -void CompilerGLSL::propagate_nonuniform_qualifier(uint32_t id) -{ - // SPIR-V might only tag the very last ID with NonUniformEXT, but for codegen, - // we need to know NonUniformEXT a little earlier, when the resource is actually loaded. - // Back-propagate the qualifier based on the expression dependency chain. - - if (!has_decoration(id, DecorationNonUniformEXT)) - { - set_decoration(id, DecorationNonUniformEXT); - force_recompile(); - } - - auto *e = maybe_get(id); - auto *combined = maybe_get(id); - auto *chain = maybe_get(id); - if (e) - { - for (auto &expr : e->expression_dependencies) - propagate_nonuniform_qualifier(expr); - for (auto &expr : e->implied_read_expressions) - propagate_nonuniform_qualifier(expr); - } - else if (combined) - { - propagate_nonuniform_qualifier(combined->image); - propagate_nonuniform_qualifier(combined->sampler); - } - else if (chain) - { - for (auto &expr : chain->implied_read_expressions) - propagate_nonuniform_qualifier(expr); - } -} - void CompilerGLSL::emit_copy_logical_type(uint32_t lhs_id, uint32_t lhs_type_id, uint32_t rhs_id, uint32_t rhs_type_id, SmallVector chain) { @@ -15060,7 +15659,7 @@ CompilerGLSL::ShaderSubgroupSupportHelper::FeatureVector CompilerGLSL::ShaderSub switch (feature) { case SubgroupAllEqualT: - return { SubgroupBrodcast_First, SubgroupAll_Any_AllEqualBool }; + return { SubgroupBroadcast_First, SubgroupAll_Any_AllEqualBool }; case SubgroupElect: return { SubgroupBallotFindLSB_MSB, SubgroupBallot, SubgroupInvocationID }; case SubgroupInverseBallot_InclBitCount_ExclBitCout: @@ -15095,8 +15694,8 @@ CompilerGLSL::ShaderSubgroupSupportHelper::Candidate CompilerGLSL::ShaderSubgrou static const Candidate extensions[FeatureCount] = { KHR_shader_subgroup_ballot, KHR_shader_subgroup_basic, KHR_shader_subgroup_basic, KHR_shader_subgroup_basic, KHR_shader_subgroup_basic, KHR_shader_subgroup_ballot, KHR_shader_subgroup_ballot, KHR_shader_subgroup_vote, - KHR_shader_subgroup_vote, KHR_shader_subgroup_basic, KHR_shader_subgroup_ballot, KHR_shader_subgroup_basic, - KHR_shader_subgroup_basic, KHR_shader_subgroup_ballot, KHR_shader_subgroup_ballot, KHR_shader_subgroup_ballot + KHR_shader_subgroup_vote, KHR_shader_subgroup_basic, KHR_shader_subgroup_basic, KHR_shader_subgroup_basic, + KHR_shader_subgroup_ballot, KHR_shader_subgroup_ballot, KHR_shader_subgroup_ballot, KHR_shader_subgroup_ballot }; return extensions[feature]; @@ -15170,7 +15769,7 @@ CompilerGLSL::ShaderSubgroupSupportHelper::CandidateVector CompilerGLSL::ShaderS return { KHR_shader_subgroup_basic, NV_shader_thread_group }; case NumSubgroups: return { KHR_shader_subgroup_basic, NV_shader_thread_group }; - case SubgroupBrodcast_First: + case SubgroupBroadcast_First: return { KHR_shader_subgroup_ballot, NV_shader_thread_shuffle, ARB_shader_ballot }; case SubgroupBallotFindLSB_MSB: return { KHR_shader_subgroup_ballot, NV_shader_thread_group }; @@ -15273,6 +15872,152 @@ void CompilerGLSL::rewrite_load_for_wrapped_row_major(std::string &expr, TypeID if (rewrite) { request_workaround_wrapper_overload(loaded_type); - expr = join("SPIRV_Cross_workaround_load_row_major(", expr, ")"); + expr = join("spvWorkaroundRowMajor(", expr, ")"); } } + +void CompilerGLSL::mask_stage_output_by_location(uint32_t location, uint32_t component) +{ + masked_output_locations.insert({ location, component }); +} + +void CompilerGLSL::mask_stage_output_by_builtin(BuiltIn builtin) +{ + masked_output_builtins.insert(builtin); +} + +bool CompilerGLSL::is_stage_output_variable_masked(const SPIRVariable &var) const +{ + auto &type = get(var.basetype); + bool is_block = has_decoration(type.self, DecorationBlock); + // Blocks by themselves are never masked. Must be masked per-member. + if (is_block) + return false; + + bool is_builtin = has_decoration(var.self, DecorationBuiltIn); + + if (is_builtin) + { + return is_stage_output_builtin_masked(BuiltIn(get_decoration(var.self, DecorationBuiltIn))); + } + else + { + if (!has_decoration(var.self, DecorationLocation)) + return false; + + return is_stage_output_location_masked( + get_decoration(var.self, DecorationLocation), + get_decoration(var.self, DecorationComponent)); + } +} + +bool CompilerGLSL::is_stage_output_block_member_masked(const SPIRVariable &var, uint32_t index, bool strip_array) const +{ + auto &type = get(var.basetype); + bool is_block = has_decoration(type.self, DecorationBlock); + if (!is_block) + return false; + + BuiltIn builtin = BuiltInMax; + if (is_member_builtin(type, index, &builtin)) + { + return is_stage_output_builtin_masked(builtin); + } + else + { + uint32_t location = get_declared_member_location(var, index, strip_array); + uint32_t component = get_member_decoration(type.self, index, DecorationComponent); + return is_stage_output_location_masked(location, component); + } +} + +bool CompilerGLSL::is_stage_output_location_masked(uint32_t location, uint32_t component) const +{ + return masked_output_locations.count({ location, component }) != 0; +} + +bool CompilerGLSL::is_stage_output_builtin_masked(spv::BuiltIn builtin) const +{ + return masked_output_builtins.count(builtin) != 0; +} + +uint32_t CompilerGLSL::get_declared_member_location(const SPIRVariable &var, uint32_t mbr_idx, bool strip_array) const +{ + auto &block_type = get(var.basetype); + if (has_member_decoration(block_type.self, mbr_idx, DecorationLocation)) + return get_member_decoration(block_type.self, mbr_idx, DecorationLocation); + else + return get_accumulated_member_location(var, mbr_idx, strip_array); +} + +uint32_t CompilerGLSL::get_accumulated_member_location(const SPIRVariable &var, uint32_t mbr_idx, bool strip_array) const +{ + auto &type = strip_array ? get_variable_element_type(var) : get_variable_data_type(var); + uint32_t location = get_decoration(var.self, DecorationLocation); + + for (uint32_t i = 0; i < mbr_idx; i++) + { + auto &mbr_type = get(type.member_types[i]); + + // Start counting from any place we have a new location decoration. + if (has_member_decoration(type.self, mbr_idx, DecorationLocation)) + location = get_member_decoration(type.self, mbr_idx, DecorationLocation); + + uint32_t location_count = type_to_location_count(mbr_type); + location += location_count; + } + + return location; +} + +StorageClass CompilerGLSL::get_expression_effective_storage_class(uint32_t ptr) +{ + auto *var = maybe_get_backing_variable(ptr); + + // If the expression has been lowered to a temporary, we need to use the Generic storage class. + // We're looking for the effective storage class of a given expression. + // An access chain or forwarded OpLoads from such access chains + // will generally have the storage class of the underlying variable, but if the load was not forwarded + // we have lost any address space qualifiers. + bool forced_temporary = ir.ids[ptr].get_type() == TypeExpression && !get(ptr).access_chain && + (forced_temporaries.count(ptr) != 0 || forwarded_temporaries.count(ptr) == 0); + + if (var && !forced_temporary) + { + if (variable_decl_is_remapped_storage(*var, StorageClassWorkgroup)) + return StorageClassWorkgroup; + if (variable_decl_is_remapped_storage(*var, StorageClassStorageBuffer)) + return StorageClassStorageBuffer; + + // Normalize SSBOs to StorageBuffer here. + if (var->storage == StorageClassUniform && + has_decoration(get(var->basetype).self, DecorationBufferBlock)) + return StorageClassStorageBuffer; + else + return var->storage; + } + else + return expression_type(ptr).storage; +} + +uint32_t CompilerGLSL::type_to_location_count(const SPIRType &type) const +{ + uint32_t count; + if (type.basetype == SPIRType::Struct) + { + uint32_t mbr_count = uint32_t(type.member_types.size()); + count = 0; + for (uint32_t i = 0; i < mbr_count; i++) + count += type_to_location_count(get(type.member_types[i])); + } + else + { + count = type.columns > 1 ? type.columns : 1; + } + + uint32_t dim_count = uint32_t(type.array.size()); + for (uint32_t i = 0; i < dim_count; i++) + count *= to_array_size_literal(type, i); + + return count; +} diff --git a/third_party/spirv-cross/spirv_glsl.hpp b/third_party/spirv-cross/spirv_glsl.hpp index fe0f76d0ea..20b949351f 100644 --- a/third_party/spirv-cross/spirv_glsl.hpp +++ b/third_party/spirv-cross/spirv_glsl.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2020 Arm Limited + * Copyright 2015-2021 Arm Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #ifndef SPIRV_CROSS_GLSL_HPP #define SPIRV_CROSS_GLSL_HPP @@ -58,7 +65,8 @@ enum AccessChainFlagBits ACCESS_CHAIN_PTR_CHAIN_BIT = 1 << 2, ACCESS_CHAIN_SKIP_REGISTER_EXPRESSION_READ_BIT = 1 << 3, ACCESS_CHAIN_LITERAL_MSB_FORCE_ID = 1 << 4, - ACCESS_CHAIN_FLATTEN_ALL_MEMBERS_BIT = 1 << 5 + ACCESS_CHAIN_FLATTEN_ALL_MEMBERS_BIT = 1 << 5, + ACCESS_CHAIN_FORCE_COMPOSITE_BIT = 1 << 6 }; typedef uint32_t AccessChainFlags; @@ -170,7 +178,8 @@ public: // Redirect a subpassInput reading from input_attachment_index to instead load its value from // the color attachment at location = color_location. Requires ESSL. - void remap_ext_framebuffer_fetch(uint32_t input_attachment_index, uint32_t color_location); + // If coherent, uses GL_EXT_shader_framebuffer_fetch, if not, uses noncoherent variant. + void remap_ext_framebuffer_fetch(uint32_t input_attachment_index, uint32_t color_location, bool coherent); explicit CompilerGLSL(std::vector spirv_) : Compiler(std::move(spirv_)) @@ -243,6 +252,16 @@ public: // - Images which are statically used at least once with Dref opcodes. bool variable_is_depth_or_compare(VariableID id) const; + // If a shader output is active in this stage, but inactive in a subsequent stage, + // this can be signalled here. This can be used to work around certain cross-stage matching problems + // which plagues MSL and HLSL in certain scenarios. + // An output which matches one of these will not be emitted in stage output interfaces, but rather treated as a private + // variable. + // This option is only meaningful for MSL and HLSL, since GLSL matches by location directly. + // Masking builtins only takes effect if the builtin in question is part of the stage output interface. + void mask_stage_output_by_location(uint32_t location, uint32_t component); + void mask_stage_output_by_builtin(spv::BuiltIn builtin); + protected: struct ShaderSubgroupSupportHelper { @@ -268,22 +287,22 @@ protected: enum Feature { - SubgroupMask, - SubgroupSize, - SubgroupInvocationID, - SubgroupID, - NumSubgroups, - SubgroupBrodcast_First, - SubgroupBallotFindLSB_MSB, - SubgroupAll_Any_AllEqualBool, - SubgroupAllEqualT, - SubgroupElect, - SubgroupBarrier, - SubgroupMemBarrier, - SubgroupBallot, - SubgroupInverseBallot_InclBitCount_ExclBitCout, - SubgroupBallotBitExtract, - SubgroupBallotBitCount, + SubgroupMask = 0, + SubgroupSize = 1, + SubgroupInvocationID = 2, + SubgroupID = 3, + NumSubgroups = 4, + SubgroupBroadcast_First = 5, + SubgroupBallotFindLSB_MSB = 6, + SubgroupAll_Any_AllEqualBool = 7, + SubgroupAllEqualT = 8, + SubgroupElect = 9, + SubgroupBarrier = 10, + SubgroupMemBarrier = 11, + SubgroupBallot = 12, + SubgroupInverseBallot_InclBitCount_ExclBitCout = 13, + SubgroupBallotBitExtract = 14, + SubgroupBallotBitCount = 15, FeatureCount }; @@ -368,6 +387,7 @@ protected: virtual std::string constant_expression_vector(const SPIRConstant &c, uint32_t vector); virtual void emit_fixup(); virtual std::string variable_decl(const SPIRType &type, const std::string &name, uint32_t id = 0); + virtual bool variable_decl_is_remapped_storage(const SPIRVariable &var, spv::StorageClass storage) const; virtual std::string to_func_call_arg(const SPIRFunction::Parameter &arg, uint32_t id); struct TextureFunctionBaseArguments @@ -398,6 +418,7 @@ protected: uint32_t coord = 0, coord_components = 0, dref = 0; uint32_t grad_x = 0, grad_y = 0, lod = 0, coffset = 0, offset = 0; uint32_t bias = 0, component = 0, sample = 0, sparse_texel = 0, min_lod = 0; + bool nonuniform_expression = false; }; virtual std::string to_function_args(const TextureFunctionArguments &args, bool *p_forward); @@ -560,6 +581,8 @@ protected: bool support_case_fallthrough = true; bool use_array_constructor = false; bool needs_row_major_load_workaround = false; + bool support_pointer_to_pointer = false; + bool support_precise_qualifier = false; } backend; void emit_struct(SPIRType &type); @@ -607,6 +630,8 @@ protected: void emit_trinary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, uint32_t op2, const char *op); void emit_binary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, const char *op); + void emit_atomic_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, const char *op); + void emit_atomic_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, uint32_t op2, const char *op); void emit_unary_func_op_cast(uint32_t result_type, uint32_t result_id, uint32_t op0, const char *op, SPIRType::BaseType input_type, SPIRType::BaseType expected_result_type); @@ -652,6 +677,9 @@ protected: std::string access_chain_internal(uint32_t base, const uint32_t *indices, uint32_t count, AccessChainFlags flags, AccessChainMeta *meta); + spv::StorageClass get_expression_effective_storage_class(uint32_t ptr); + virtual bool access_chain_needs_stage_io_builtin_translation(uint32_t base); + virtual void prepare_access_chain_for_scalar_access(std::string &expr, const SPIRType &type, spv::StorageClass storage, bool &is_packed); @@ -682,6 +710,7 @@ protected: void emit_uninitialized_temporary(uint32_t type, uint32_t id); SPIRExpression &emit_uninitialized_temporary_expression(uint32_t type, uint32_t id); void append_global_func_args(const SPIRFunction &func, uint32_t index, SmallVector &arglist); + std::string to_non_uniform_aware_expression(uint32_t id); std::string to_expression(uint32_t id, bool register_expression_read = true); std::string to_composite_constructor_expression(uint32_t id, bool uses_buffer_offset); std::string to_rerolled_array_expression(const std::string &expr, const SPIRType &type); @@ -693,6 +722,8 @@ protected: std::string to_pointer_expression(uint32_t id, bool register_expression_read = true); std::string to_enclosed_pointer_expression(uint32_t id, bool register_expression_read = true); std::string to_extract_component_expression(uint32_t id, uint32_t index); + std::string to_extract_constant_composite_expression(uint32_t result_type, const SPIRConstant &c, + const uint32_t *chain, uint32_t length); std::string enclose_expression(const std::string &expr); std::string dereference_expression(const SPIRType &expression_type, const std::string &expr); std::string address_of_expression(const std::string &expr); @@ -703,17 +734,19 @@ protected: std::string type_to_glsl_constructor(const SPIRType &type); std::string argument_decl(const SPIRFunction::Parameter &arg); virtual std::string to_qualifiers_glsl(uint32_t id); - const char *to_precision_qualifiers_glsl(uint32_t id); + void fixup_io_block_patch_qualifiers(const SPIRVariable &var); + void emit_output_variable_initializer(const SPIRVariable &var); + std::string to_precision_qualifiers_glsl(uint32_t id); virtual const char *to_storage_qualifiers_glsl(const SPIRVariable &var); - const char *flags_to_qualifiers_glsl(const SPIRType &type, const Bitset &flags); + std::string flags_to_qualifiers_glsl(const SPIRType &type, const Bitset &flags); const char *format_to_glsl(spv::ImageFormat format); virtual std::string layout_for_member(const SPIRType &type, uint32_t index); virtual std::string to_interpolation_qualifiers(const Bitset &flags); std::string layout_for_variable(const SPIRVariable &variable); std::string to_combined_image_sampler(VariableID image_id, VariableID samp_id); virtual bool skip_argument(uint32_t id) const; - virtual void emit_array_copy(const std::string &lhs, uint32_t rhs_id, spv::StorageClass lhs_storage, - spv::StorageClass rhs_storage); + virtual void emit_array_copy(const std::string &lhs, uint32_t lhs_id, uint32_t rhs_id, + spv::StorageClass lhs_storage, spv::StorageClass rhs_storage); virtual void emit_block_hints(const SPIRBlock &block); virtual std::string to_initializer_expression(const SPIRVariable &var); virtual std::string to_zero_initialized_expression(uint32_t type_id); @@ -728,6 +761,7 @@ protected: uint32_t type_to_packed_alignment(const SPIRType &type, const Bitset &flags, BufferPackingStandard packing); uint32_t type_to_packed_array_stride(const SPIRType &type, const Bitset &flags, BufferPackingStandard packing); uint32_t type_to_packed_size(const SPIRType &type, const Bitset &flags, BufferPackingStandard packing); + uint32_t type_to_location_count(const SPIRType &type) const; std::string bitcast_glsl(const SPIRType &result_type, uint32_t arg); virtual std::string bitcast_glsl_op(const SPIRType &result_type, const SPIRType &argument_type); @@ -807,6 +841,8 @@ protected: bool requires_transpose_2x2 = false; bool requires_transpose_3x3 = false; bool requires_transpose_4x4 = false; + bool ray_tracing_is_khr = false; + void ray_tracing_khr_fixup_locations(); bool args_will_forward(uint32_t id, const uint32_t *args, uint32_t num_args, bool pure); void register_call_out_argument(uint32_t id); @@ -823,7 +859,9 @@ protected: // GL_EXT_shader_framebuffer_fetch support. std::vector> subpass_to_framebuffer_fetch_attachment; - std::unordered_set inout_color_attachments; + std::vector> inout_color_attachments; + bool location_is_framebuffer_fetch(uint32_t location) const; + bool location_is_non_coherent_framebuffer_fetch(uint32_t location) const; bool subpass_input_is_framebuffer_fetch(uint32_t id) const; void emit_inout_fragment_outputs_copy_to_subpass_inputs(); const SPIRVariable *find_subpass_input_by_attachment_index(uint32_t index) const; @@ -865,7 +903,8 @@ protected: virtual void cast_to_builtin_store(uint32_t target_id, std::string &expr, const SPIRType &expr_type); virtual void cast_from_builtin_load(uint32_t source_id, std::string &expr, const SPIRType &expr_type); void unroll_array_from_complex_load(uint32_t target_id, uint32_t source_id, std::string &expr); - void convert_non_uniform_expression(const SPIRType &type, std::string &expr); + bool unroll_array_to_complex_store(uint32_t target_id, uint32_t source_id); + void convert_non_uniform_expression(std::string &expr, uint32_t ptr_id); void handle_store_to_invariant_variable(uint32_t store_id, uint32_t value_id); void disallow_forwarding_in_expression_chain(const SPIRExpression &expr); @@ -884,10 +923,17 @@ protected: void fixup_type_alias(); void reorder_type_alias(); - void propagate_nonuniform_qualifier(uint32_t id); - static const char *vector_swizzle(int vecsize, int index); + bool is_stage_output_location_masked(uint32_t location, uint32_t component) const; + bool is_stage_output_builtin_masked(spv::BuiltIn builtin) const; + bool is_stage_output_variable_masked(const SPIRVariable &var) const; + bool is_stage_output_block_member_masked(const SPIRVariable &var, uint32_t index, bool strip_array) const; + uint32_t get_accumulated_member_location(const SPIRVariable &var, uint32_t mbr_idx, bool strip_array) const; + uint32_t get_declared_member_location(const SPIRVariable &var, uint32_t mbr_idx, bool strip_array) const; + std::unordered_set masked_output_locations; + std::unordered_set masked_output_builtins; + private: void init(); }; diff --git a/third_party/spirv-cross/spirv_hlsl.cpp b/third_party/spirv-cross/spirv_hlsl.cpp index 3c01762a47..9435c4e063 100644 --- a/third_party/spirv-cross/spirv_hlsl.cpp +++ b/third_party/spirv-cross/spirv_hlsl.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 Robert Konrad + * Copyright 2016-2021 Robert Konrad * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -12,6 +12,14 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. */ #include "spirv_hlsl.hpp" @@ -562,7 +570,7 @@ void CompilerHLSL::emit_builtin_outputs_in_struct() switch (builtin) { case BuiltInPosition: - type = "float4"; + type = is_position_invariant() && backend.support_precise_qualifier ? "precise float4" : "float4"; semantic = legacy ? "POSITION" : "SV_Position"; break; @@ -810,8 +818,8 @@ string CompilerHLSL::to_interpolation_qualifiers(const Bitset &flags) res += "patch "; // Seems to be different in actual HLSL. if (flags.get(DecorationSample)) res += "sample "; - if (flags.get(DecorationInvariant)) - res += "invariant "; // Not supported? + if (flags.get(DecorationInvariant) && backend.support_precise_qualifier) + res += "precise "; // Not supported? return res; } @@ -831,6 +839,21 @@ std::string CompilerHLSL::to_semantic(uint32_t location, ExecutionModel em, Stor return join("TEXCOORD", location); } +std::string CompilerHLSL::to_initializer_expression(const SPIRVariable &var) +{ + // We cannot emit static const initializer for block constants for practical reasons, + // so just inline the initializer. + // FIXME: There is a theoretical problem here if someone tries to composite extract + // into this initializer since we don't declare it properly, but that is somewhat non-sensical. + auto &type = get(var.basetype); + bool is_block = has_decoration(type.self, DecorationBlock); + auto *c = maybe_get(var.initializer); + if (is_block && c) + return constant_expression(*c); + else + return CompilerGLSL::to_initializer_expression(var); +} + void CompilerHLSL::emit_io_block(const SPIRVariable &var) { auto &execution = get_entry_point(); @@ -842,24 +865,10 @@ void CompilerHLSL::emit_io_block(const SPIRVariable &var) begin_scope(); type.member_name_cache.clear(); - uint32_t base_location = get_decoration(var.self, DecorationLocation); - for (uint32_t i = 0; i < uint32_t(type.member_types.size()); i++) { - string semantic; - if (has_member_decoration(type.self, i, DecorationLocation)) - { - uint32_t location = get_member_decoration(type.self, i, DecorationLocation); - semantic = join(" : ", to_semantic(location, execution.model, var.storage)); - } - else - { - // If the block itself has a location, but not its members, use the implicit location. - // There could be a conflict if the block members partially specialize the locations. - // It is unclear how SPIR-V deals with this. Assume this does not happen for now. - uint32_t location = base_location + i; - semantic = join(" : ", to_semantic(location, execution.model, var.storage)); - } + uint32_t location = get_accumulated_member_location(var, i, false); + string semantic = join(" : ", to_semantic(location, execution.model, var.storage)); add_member_name(type, i); @@ -1000,12 +1009,43 @@ void CompilerHLSL::emit_builtin_variables() bool need_base_vertex_info = false; + std::unordered_map builtin_to_initializer; + ir.for_each_typed_id([&](uint32_t, SPIRVariable &var) { + if (!is_builtin_variable(var) || var.storage != StorageClassOutput || !var.initializer) + return; + + auto *c = this->maybe_get(var.initializer); + if (!c) + return; + + auto &type = this->get(var.basetype); + if (type.basetype == SPIRType::Struct) + { + uint32_t member_count = uint32_t(type.member_types.size()); + for (uint32_t i = 0; i < member_count; i++) + { + if (has_member_decoration(type.self, i, DecorationBuiltIn)) + { + builtin_to_initializer[get_member_decoration(type.self, i, DecorationBuiltIn)] = + c->subconstants[i]; + } + } + } + else if (has_decoration(var.self, DecorationBuiltIn)) + builtin_to_initializer[get_decoration(var.self, DecorationBuiltIn)] = var.initializer; + }); + // Emit global variables for the interface variables which are statically used by the shader. builtins.for_each_bit([&](uint32_t i) { const char *type = nullptr; auto builtin = static_cast(i); uint32_t array_size = 0; + string init_expr; + auto init_itr = builtin_to_initializer.find(builtin); + if (init_itr != builtin_to_initializer.end()) + init_expr = join(" = ", to_expression(init_itr->second)); + switch (builtin) { case BuiltInFragCoord: @@ -1098,16 +1138,16 @@ void CompilerHLSL::emit_builtin_variables() if (type) { if (array_size) - statement("static ", type, " ", builtin_to_glsl(builtin, storage), "[", array_size, "];"); + statement("static ", type, " ", builtin_to_glsl(builtin, storage), "[", array_size, "]", init_expr, ";"); else - statement("static ", type, " ", builtin_to_glsl(builtin, storage), ";"); + statement("static ", type, " ", builtin_to_glsl(builtin, storage), init_expr, ";"); } // SampleMask can be both in and out with sample builtin, in this case we have already // declared the input variable and we need to add the output one now. if (builtin == BuiltInSampleMask && storage == StorageClassInput && this->active_output_builtins.get(i)) { - statement("static ", type, " ", this->builtin_to_glsl(builtin, StorageClassOutput), ";"); + statement("static ", type, " ", this->builtin_to_glsl(builtin, StorageClassOutput), init_expr, ";"); } }); @@ -1133,7 +1173,11 @@ void CompilerHLSL::emit_composite_constants() return; auto &type = this->get(c.constant_type); - if (type.basetype == SPIRType::Struct || !type.array.empty()) + + // Cannot declare block type constants here. + // We do not have the struct type yet. + bool is_block = has_decoration(type.self, DecorationBlock); + if (!is_block && (type.basetype == SPIRType::Struct || !type.array.empty())) { auto name = to_name(c.self); statement("static const ", variable_decl(type, name), " = ", constant_expression(c), ";"); @@ -1214,7 +1258,7 @@ void CompilerHLSL::replace_illegal_names() { static const unordered_set keywords = { // Additional HLSL specific keywords. - "line", "linear", "matrix", "point", "row_major", "sampler", + "line", "linear", "matrix", "point", "row_major", "sampler", "vector" }; CompilerGLSL::replace_illegal_names(keywords); @@ -1304,7 +1348,8 @@ void CompilerHLSL::emit_resources() } if (var.storage != StorageClassFunction && !is_builtin_variable(var) && !var.remapped_variable && - type.pointer && (type.storage == StorageClassUniformConstant || type.storage == StorageClassAtomicCounter)) + type.pointer && (type.storage == StorageClassUniformConstant || type.storage == StorageClassAtomicCounter) && + !is_hidden_variable(var)) { emit_uniform(var); emitted = true; @@ -1458,6 +1503,9 @@ void CompilerHLSL::emit_resources() for (auto global : global_variables) { auto &var = get(global); + if (is_hidden_variable(var, true)) + continue; + if (var.storage != StorageClassOutput) { if (!variable_is_lut(var)) @@ -1528,14 +1576,14 @@ void CompilerHLSL::emit_resources() if (requires_fp16_packing) { // HLSL does not pack into a single word sadly :( - statement("uint SPIRV_Cross_packHalf2x16(float2 value)"); + statement("uint spvPackHalf2x16(float2 value)"); begin_scope(); statement("uint2 Packed = f32tof16(value);"); statement("return Packed.x | (Packed.y << 16);"); end_scope(); statement(""); - statement("float2 SPIRV_Cross_unpackHalf2x16(uint value)"); + statement("float2 spvUnpackHalf2x16(uint value)"); begin_scope(); statement("return f16tof32(uint2(value & 0xffff, value >> 16));"); end_scope(); @@ -1544,13 +1592,13 @@ void CompilerHLSL::emit_resources() if (requires_uint2_packing) { - statement("uint64_t SPIRV_Cross_packUint2x32(uint2 value)"); + statement("uint64_t spvPackUint2x32(uint2 value)"); begin_scope(); statement("return (uint64_t(value.y) << 32) | uint64_t(value.x);"); end_scope(); statement(""); - statement("uint2 SPIRV_Cross_unpackUint2x32(uint64_t value)"); + statement("uint2 spvUnpackUint2x32(uint64_t value)"); begin_scope(); statement("uint2 Unpacked;"); statement("Unpacked.x = uint(value & 0xffffffff);"); @@ -1563,14 +1611,14 @@ void CompilerHLSL::emit_resources() if (requires_explicit_fp16_packing) { // HLSL does not pack into a single word sadly :( - statement("uint SPIRV_Cross_packFloat2x16(min16float2 value)"); + statement("uint spvPackFloat2x16(min16float2 value)"); begin_scope(); statement("uint2 Packed = f32tof16(value);"); statement("return Packed.x | (Packed.y << 16);"); end_scope(); statement(""); - statement("min16float2 SPIRV_Cross_unpackFloat2x16(uint value)"); + statement("min16float2 spvUnpackFloat2x16(uint value)"); begin_scope(); statement("return min16float2(f16tof32(uint2(value & 0xffff, value >> 16)));"); end_scope(); @@ -1580,14 +1628,14 @@ void CompilerHLSL::emit_resources() // HLSL does not seem to have builtins for these operation, so roll them by hand ... if (requires_unorm8_packing) { - statement("uint SPIRV_Cross_packUnorm4x8(float4 value)"); + statement("uint spvPackUnorm4x8(float4 value)"); begin_scope(); statement("uint4 Packed = uint4(round(saturate(value) * 255.0));"); statement("return Packed.x | (Packed.y << 8) | (Packed.z << 16) | (Packed.w << 24);"); end_scope(); statement(""); - statement("float4 SPIRV_Cross_unpackUnorm4x8(uint value)"); + statement("float4 spvUnpackUnorm4x8(uint value)"); begin_scope(); statement("uint4 Packed = uint4(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, value >> 24);"); statement("return float4(Packed) / 255.0;"); @@ -1597,14 +1645,14 @@ void CompilerHLSL::emit_resources() if (requires_snorm8_packing) { - statement("uint SPIRV_Cross_packSnorm4x8(float4 value)"); + statement("uint spvPackSnorm4x8(float4 value)"); begin_scope(); statement("int4 Packed = int4(round(clamp(value, -1.0, 1.0) * 127.0)) & 0xff;"); statement("return uint(Packed.x | (Packed.y << 8) | (Packed.z << 16) | (Packed.w << 24));"); end_scope(); statement(""); - statement("float4 SPIRV_Cross_unpackSnorm4x8(uint value)"); + statement("float4 spvUnpackSnorm4x8(uint value)"); begin_scope(); statement("int SignedValue = int(value);"); statement("int4 Packed = int4(SignedValue << 24, SignedValue << 16, SignedValue << 8, SignedValue) >> 24;"); @@ -1615,14 +1663,14 @@ void CompilerHLSL::emit_resources() if (requires_unorm16_packing) { - statement("uint SPIRV_Cross_packUnorm2x16(float2 value)"); + statement("uint spvPackUnorm2x16(float2 value)"); begin_scope(); statement("uint2 Packed = uint2(round(saturate(value) * 65535.0));"); statement("return Packed.x | (Packed.y << 16);"); end_scope(); statement(""); - statement("float2 SPIRV_Cross_unpackUnorm2x16(uint value)"); + statement("float2 spvUnpackUnorm2x16(uint value)"); begin_scope(); statement("uint2 Packed = uint2(value & 0xffff, value >> 16);"); statement("return float2(Packed) / 65535.0;"); @@ -1632,14 +1680,14 @@ void CompilerHLSL::emit_resources() if (requires_snorm16_packing) { - statement("uint SPIRV_Cross_packSnorm2x16(float2 value)"); + statement("uint spvPackSnorm2x16(float2 value)"); begin_scope(); statement("int2 Packed = int2(round(clamp(value, -1.0, 1.0) * 32767.0)) & 0xffff;"); statement("return uint(Packed.x | (Packed.y << 16));"); end_scope(); statement(""); - statement("float2 SPIRV_Cross_unpackSnorm2x16(uint value)"); + statement("float2 spvUnpackSnorm2x16(uint value)"); begin_scope(); statement("int SignedValue = int(value);"); statement("int2 Packed = int2(SignedValue << 16, SignedValue) >> 16;"); @@ -1653,7 +1701,7 @@ void CompilerHLSL::emit_resources() static const char *types[] = { "uint", "uint2", "uint3", "uint4" }; for (auto &type : types) { - statement(type, " SPIRV_Cross_bitfieldInsert(", type, " Base, ", type, " Insert, uint Offset, uint Count)"); + statement(type, " spvBitfieldInsert(", type, " Base, ", type, " Insert, uint Offset, uint Count)"); begin_scope(); statement("uint Mask = Count == 32 ? 0xffffffff : (((1u << Count) - 1) << (Offset & 31));"); statement("return (Base & ~Mask) | ((Insert << Offset) & Mask);"); @@ -1667,7 +1715,7 @@ void CompilerHLSL::emit_resources() static const char *unsigned_types[] = { "uint", "uint2", "uint3", "uint4" }; for (auto &type : unsigned_types) { - statement(type, " SPIRV_Cross_bitfieldUExtract(", type, " Base, uint Offset, uint Count)"); + statement(type, " spvBitfieldUExtract(", type, " Base, uint Offset, uint Count)"); begin_scope(); statement("uint Mask = Count == 32 ? 0xffffffff : ((1 << Count) - 1);"); statement("return (Base >> Offset) & Mask;"); @@ -1679,7 +1727,7 @@ void CompilerHLSL::emit_resources() static const char *signed_types[] = { "int", "int2", "int3", "int4" }; for (auto &type : signed_types) { - statement(type, " SPIRV_Cross_bitfieldSExtract(", type, " Base, int Offset, int Count)"); + statement(type, " spvBitfieldSExtract(", type, " Base, int Offset, int Count)"); begin_scope(); statement("int Mask = Count == 32 ? -1 : ((1 << Count) - 1);"); statement(type, " Masked = (Base >> Offset) & Mask;"); @@ -1694,7 +1742,7 @@ void CompilerHLSL::emit_resources() { statement("// Returns the inverse of a matrix, by using the algorithm of calculating the classical"); statement("// adjoint and dividing by the determinant. The contents of the matrix are changed."); - statement("float2x2 SPIRV_Cross_Inverse(float2x2 m)"); + statement("float2x2 spvInverse(float2x2 m)"); begin_scope(); statement("float2x2 adj; // The adjoint matrix (inverse after dividing by determinant)"); statement_no_indent(""); @@ -1718,29 +1766,29 @@ void CompilerHLSL::emit_resources() if (requires_inverse_3x3) { statement("// Returns the determinant of a 2x2 matrix."); - statement("float SPIRV_Cross_Det2x2(float a1, float a2, float b1, float b2)"); + statement("float spvDet2x2(float a1, float a2, float b1, float b2)"); begin_scope(); statement("return a1 * b2 - b1 * a2;"); end_scope(); statement_no_indent(""); statement("// Returns the inverse of a matrix, by using the algorithm of calculating the classical"); statement("// adjoint and dividing by the determinant. The contents of the matrix are changed."); - statement("float3x3 SPIRV_Cross_Inverse(float3x3 m)"); + statement("float3x3 spvInverse(float3x3 m)"); begin_scope(); statement("float3x3 adj; // The adjoint matrix (inverse after dividing by determinant)"); statement_no_indent(""); statement("// Create the transpose of the cofactors, as the classical adjoint of the matrix."); - statement("adj[0][0] = SPIRV_Cross_Det2x2(m[1][1], m[1][2], m[2][1], m[2][2]);"); - statement("adj[0][1] = -SPIRV_Cross_Det2x2(m[0][1], m[0][2], m[2][1], m[2][2]);"); - statement("adj[0][2] = SPIRV_Cross_Det2x2(m[0][1], m[0][2], m[1][1], m[1][2]);"); + statement("adj[0][0] = spvDet2x2(m[1][1], m[1][2], m[2][1], m[2][2]);"); + statement("adj[0][1] = -spvDet2x2(m[0][1], m[0][2], m[2][1], m[2][2]);"); + statement("adj[0][2] = spvDet2x2(m[0][1], m[0][2], m[1][1], m[1][2]);"); statement_no_indent(""); - statement("adj[1][0] = -SPIRV_Cross_Det2x2(m[1][0], m[1][2], m[2][0], m[2][2]);"); - statement("adj[1][1] = SPIRV_Cross_Det2x2(m[0][0], m[0][2], m[2][0], m[2][2]);"); - statement("adj[1][2] = -SPIRV_Cross_Det2x2(m[0][0], m[0][2], m[1][0], m[1][2]);"); + statement("adj[1][0] = -spvDet2x2(m[1][0], m[1][2], m[2][0], m[2][2]);"); + statement("adj[1][1] = spvDet2x2(m[0][0], m[0][2], m[2][0], m[2][2]);"); + statement("adj[1][2] = -spvDet2x2(m[0][0], m[0][2], m[1][0], m[1][2]);"); statement_no_indent(""); - statement("adj[2][0] = SPIRV_Cross_Det2x2(m[1][0], m[1][1], m[2][0], m[2][1]);"); - statement("adj[2][1] = -SPIRV_Cross_Det2x2(m[0][0], m[0][1], m[2][0], m[2][1]);"); - statement("adj[2][2] = SPIRV_Cross_Det2x2(m[0][0], m[0][1], m[1][0], m[1][1]);"); + statement("adj[2][0] = spvDet2x2(m[1][0], m[1][1], m[2][0], m[2][1]);"); + statement("adj[2][1] = -spvDet2x2(m[0][0], m[0][1], m[2][0], m[2][1]);"); + statement("adj[2][2] = spvDet2x2(m[0][0], m[0][1], m[1][0], m[1][1]);"); statement_no_indent(""); statement("// Calculate the determinant as a combination of the cofactors of the first row."); statement("float det = (adj[0][0] * m[0][0]) + (adj[0][1] * m[1][0]) + (adj[0][2] * m[2][0]);"); @@ -1757,7 +1805,7 @@ void CompilerHLSL::emit_resources() if (!requires_inverse_3x3) { statement("// Returns the determinant of a 2x2 matrix."); - statement("float SPIRV_Cross_Det2x2(float a1, float a2, float b1, float b2)"); + statement("float spvDet2x2(float a1, float a2, float b1, float b2)"); begin_scope(); statement("return a1 * b2 - b1 * a2;"); end_scope(); @@ -1765,71 +1813,71 @@ void CompilerHLSL::emit_resources() } statement("// Returns the determinant of a 3x3 matrix."); - statement("float SPIRV_Cross_Det3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, " + statement("float spvDet3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, " "float c2, float c3)"); begin_scope(); - statement("return a1 * SPIRV_Cross_Det2x2(b2, b3, c2, c3) - b1 * SPIRV_Cross_Det2x2(a2, a3, c2, c3) + c1 * " - "SPIRV_Cross_Det2x2(a2, a3, " + statement("return a1 * spvDet2x2(b2, b3, c2, c3) - b1 * spvDet2x2(a2, a3, c2, c3) + c1 * " + "spvDet2x2(a2, a3, " "b2, b3);"); end_scope(); statement_no_indent(""); statement("// Returns the inverse of a matrix, by using the algorithm of calculating the classical"); statement("// adjoint and dividing by the determinant. The contents of the matrix are changed."); - statement("float4x4 SPIRV_Cross_Inverse(float4x4 m)"); + statement("float4x4 spvInverse(float4x4 m)"); begin_scope(); statement("float4x4 adj; // The adjoint matrix (inverse after dividing by determinant)"); statement_no_indent(""); statement("// Create the transpose of the cofactors, as the classical adjoint of the matrix."); statement( - "adj[0][0] = SPIRV_Cross_Det3x3(m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], " + "adj[0][0] = spvDet3x3(m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], " "m[3][3]);"); statement( - "adj[0][1] = -SPIRV_Cross_Det3x3(m[0][1], m[0][2], m[0][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], " + "adj[0][1] = -spvDet3x3(m[0][1], m[0][2], m[0][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], " "m[3][3]);"); statement( - "adj[0][2] = SPIRV_Cross_Det3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[3][1], m[3][2], " + "adj[0][2] = spvDet3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[3][1], m[3][2], " "m[3][3]);"); statement( - "adj[0][3] = -SPIRV_Cross_Det3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], " + "adj[0][3] = -spvDet3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], " "m[2][3]);"); statement_no_indent(""); statement( - "adj[1][0] = -SPIRV_Cross_Det3x3(m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], " + "adj[1][0] = -spvDet3x3(m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], " "m[3][3]);"); statement( - "adj[1][1] = SPIRV_Cross_Det3x3(m[0][0], m[0][2], m[0][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], " + "adj[1][1] = spvDet3x3(m[0][0], m[0][2], m[0][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], " "m[3][3]);"); statement( - "adj[1][2] = -SPIRV_Cross_Det3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[3][0], m[3][2], " + "adj[1][2] = -spvDet3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[3][0], m[3][2], " "m[3][3]);"); statement( - "adj[1][3] = SPIRV_Cross_Det3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], " + "adj[1][3] = spvDet3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], " "m[2][3]);"); statement_no_indent(""); statement( - "adj[2][0] = SPIRV_Cross_Det3x3(m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], " + "adj[2][0] = spvDet3x3(m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], " "m[3][3]);"); statement( - "adj[2][1] = -SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], " + "adj[2][1] = -spvDet3x3(m[0][0], m[0][1], m[0][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], " "m[3][3]);"); statement( - "adj[2][2] = SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], " + "adj[2][2] = spvDet3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], " "m[3][3]);"); statement( - "adj[2][3] = -SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], " + "adj[2][3] = -spvDet3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], " "m[2][3]);"); statement_no_indent(""); statement( - "adj[3][0] = -SPIRV_Cross_Det3x3(m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], " + "adj[3][0] = -spvDet3x3(m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], " "m[3][2]);"); statement( - "adj[3][1] = SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], " + "adj[3][1] = spvDet3x3(m[0][0], m[0][1], m[0][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], " "m[3][2]);"); statement( - "adj[3][2] = -SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[3][0], m[3][1], " + "adj[3][2] = -spvDet3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[3][0], m[3][1], " "m[3][2]);"); statement( - "adj[3][3] = SPIRV_Cross_Det3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], " + "adj[3][3] = spvDet3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], " "m[2][2]);"); statement_no_indent(""); statement("// Calculate the determinant as a combination of the cofactors of the first row."); @@ -1846,7 +1894,7 @@ void CompilerHLSL::emit_resources() if (requires_scalar_reflect) { // FP16/FP64? No templates in HLSL. - statement("float SPIRV_Cross_Reflect(float i, float n)"); + statement("float spvReflect(float i, float n)"); begin_scope(); statement("return i - 2.0 * dot(n, i) * n;"); end_scope(); @@ -1856,7 +1904,7 @@ void CompilerHLSL::emit_resources() if (requires_scalar_refract) { // FP16/FP64? No templates in HLSL. - statement("float SPIRV_Cross_Refract(float i, float n, float eta)"); + statement("float spvRefract(float i, float n, float eta)"); begin_scope(); statement("float NoI = n * i;"); statement("float NoI2 = NoI * NoI;"); @@ -1876,7 +1924,7 @@ void CompilerHLSL::emit_resources() if (requires_scalar_faceforward) { // FP16/FP64? No templates in HLSL. - statement("float SPIRV_Cross_FaceForward(float n, float i, float nref)"); + statement("float spvFaceForward(float n, float i, float nref)"); begin_scope(); statement("return i * nref < 0.0 ? n : -n;"); end_scope(); @@ -1915,7 +1963,7 @@ void CompilerHLSL::emit_texture_size_variants(uint64_t variant_mask, const char if ((variant_mask & mask) == 0) continue; - statement(ret_types[index], " SPIRV_Cross_", (uav ? "image" : "texture"), "Size(", (uav ? "RW" : ""), + statement(ret_types[index], " spv", (uav ? "Image" : "Texture"), "Size(", (uav ? "RW" : ""), dims[index], "<", type_qualifier, types[type_index], vecsize_qualifier, "> Tex, ", (uav ? "" : "uint Level, "), "out uint Param)"); begin_scope(); @@ -2187,7 +2235,7 @@ void CompilerHLSL::emit_push_constant_block(const SPIRVariable &var) string CompilerHLSL::to_sampler_expression(uint32_t id) { - auto expr = join("_", to_expression(id)); + auto expr = join("_", to_non_uniform_aware_expression(id)); auto index = expr.find_first_of('['); if (index == string::npos) { @@ -2281,7 +2329,7 @@ void CompilerHLSL::emit_function_prototype(SPIRFunction &func, const Bitset &ret out_argument += "out "; out_argument += type_to_glsl(type); out_argument += " "; - out_argument += "SPIRV_Cross_return_value"; + out_argument += "spvReturnValue"; out_argument += type_to_array_glsl(type); arglist.push_back(move(out_argument)); } @@ -2692,14 +2740,17 @@ void CompilerHLSL::emit_texture_op(const Instruction &i, bool sparse) bool proj = false; const uint32_t *opt = nullptr; auto *combined_image = maybe_get(img); - auto img_expr = to_expression(combined_image ? combined_image->image : img); + + if (combined_image && has_decoration(img, DecorationNonUniform)) + { + set_decoration(combined_image->image, DecorationNonUniform); + set_decoration(combined_image->sampler, DecorationNonUniform); + } + + auto img_expr = to_non_uniform_aware_expression(combined_image ? combined_image->image : img); inherited_expressions.push_back(coord); - // Make sure non-uniform decoration is back-propagated to where it needs to be. - if (has_decoration(img, DecorationNonUniformEXT)) - propagate_nonuniform_qualifier(img); - switch (op) { case OpImageSampleDrefImplicitLod: @@ -2954,7 +3005,7 @@ void CompilerHLSL::emit_texture_op(const Instruction &i, bool sparse) { string sampler_expr; if (combined_image) - sampler_expr = to_expression(combined_image->sampler); + sampler_expr = to_non_uniform_aware_expression(combined_image->sampler); else sampler_expr = to_sampler_expression(img); expr += sampler_expr; @@ -3410,7 +3461,7 @@ string CompilerHLSL::bitcast_glsl_op(const SPIRType &out_type, const SPIRType &i requires_explicit_fp16_packing = true; force_recompile(); } - return "SPIRV_Cross_unpackFloat2x16"; + return "spvUnpackFloat2x16"; } else if (out_type.basetype == SPIRType::UInt && in_type.basetype == SPIRType::Half && in_type.vecsize == 2) { @@ -3419,7 +3470,7 @@ string CompilerHLSL::bitcast_glsl_op(const SPIRType &out_type, const SPIRType &i requires_explicit_fp16_packing = true; force_recompile(); } - return "SPIRV_Cross_packFloat2x16"; + return "spvPackFloat2x16"; } else return ""; @@ -3484,7 +3535,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, requires_fp16_packing = true; force_recompile(); } - emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packHalf2x16"); + emit_unary_func_op(result_type, id, args[0], "spvPackHalf2x16"); break; case GLSLstd450UnpackHalf2x16: @@ -3493,7 +3544,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, requires_fp16_packing = true; force_recompile(); } - emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackHalf2x16"); + emit_unary_func_op(result_type, id, args[0], "spvUnpackHalf2x16"); break; case GLSLstd450PackSnorm4x8: @@ -3502,7 +3553,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, requires_snorm8_packing = true; force_recompile(); } - emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packSnorm4x8"); + emit_unary_func_op(result_type, id, args[0], "spvPackSnorm4x8"); break; case GLSLstd450UnpackSnorm4x8: @@ -3511,7 +3562,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, requires_snorm8_packing = true; force_recompile(); } - emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackSnorm4x8"); + emit_unary_func_op(result_type, id, args[0], "spvUnpackSnorm4x8"); break; case GLSLstd450PackUnorm4x8: @@ -3520,7 +3571,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, requires_unorm8_packing = true; force_recompile(); } - emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packUnorm4x8"); + emit_unary_func_op(result_type, id, args[0], "spvPackUnorm4x8"); break; case GLSLstd450UnpackUnorm4x8: @@ -3529,7 +3580,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, requires_unorm8_packing = true; force_recompile(); } - emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackUnorm4x8"); + emit_unary_func_op(result_type, id, args[0], "spvUnpackUnorm4x8"); break; case GLSLstd450PackSnorm2x16: @@ -3538,7 +3589,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, requires_snorm16_packing = true; force_recompile(); } - emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packSnorm2x16"); + emit_unary_func_op(result_type, id, args[0], "spvPackSnorm2x16"); break; case GLSLstd450UnpackSnorm2x16: @@ -3547,7 +3598,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, requires_snorm16_packing = true; force_recompile(); } - emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackSnorm2x16"); + emit_unary_func_op(result_type, id, args[0], "spvUnpackSnorm2x16"); break; case GLSLstd450PackUnorm2x16: @@ -3556,7 +3607,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, requires_unorm16_packing = true; force_recompile(); } - emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_packUnorm2x16"); + emit_unary_func_op(result_type, id, args[0], "spvPackUnorm2x16"); break; case GLSLstd450UnpackUnorm2x16: @@ -3565,7 +3616,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, requires_unorm16_packing = true; force_recompile(); } - emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_unpackUnorm2x16"); + emit_unary_func_op(result_type, id, args[0], "spvUnpackUnorm2x16"); break; case GLSLstd450PackDouble2x32: @@ -3614,7 +3665,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, force_recompile(); } } - emit_unary_func_op(result_type, id, args[0], "SPIRV_Cross_Inverse"); + emit_unary_func_op(result_type, id, args[0], "spvInverse"); break; } @@ -3637,7 +3688,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, requires_scalar_reflect = true; force_recompile(); } - emit_binary_func_op(result_type, id, args[0], args[1], "SPIRV_Cross_Reflect"); + emit_binary_func_op(result_type, id, args[0], args[1], "spvReflect"); } else CompilerGLSL::emit_glsl_op(result_type, id, eop, args, count); @@ -3651,7 +3702,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, requires_scalar_refract = true; force_recompile(); } - emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "SPIRV_Cross_Refract"); + emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "spvRefract"); } else CompilerGLSL::emit_glsl_op(result_type, id, eop, args, count); @@ -3665,7 +3716,7 @@ void CompilerHLSL::emit_glsl_op(uint32_t result_type, uint32_t id, uint32_t eop, requires_scalar_faceforward = true; force_recompile(); } - emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "SPIRV_Cross_FaceForward"); + emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "spvFaceForward"); } else CompilerGLSL::emit_glsl_op(result_type, id, eop, args, count); @@ -3750,6 +3801,10 @@ void CompilerHLSL::read_access_chain(string *expr, const string &lhs, const SPIR SPIRV_CROSS_THROW("Reading types other than 32-bit from ByteAddressBuffer not yet supported, unless SM 6.2 and " "native 16-bit types are enabled."); + string base = chain.base; + if (has_decoration(chain.self, DecorationNonUniform)) + convert_non_uniform_expression(base, chain.self); + bool templated_load = hlsl_options.shader_model >= 62; string load_expr; @@ -3782,7 +3837,7 @@ void CompilerHLSL::read_access_chain(string *expr, const string &lhs, const SPIR if (templated_load) load_op = "Load"; - load_expr = join(chain.base, ".", load_op, template_expr, "(", chain.dynamic_index, chain.static_index, ")"); + load_expr = join(base, ".", load_op, template_expr, "(", chain.dynamic_index, chain.static_index, ")"); } else if (type.columns == 1) { @@ -3804,7 +3859,7 @@ void CompilerHLSL::read_access_chain(string *expr, const string &lhs, const SPIR for (uint32_t r = 0; r < type.vecsize; r++) { - load_expr += join(chain.base, ".Load", template_expr, "(", chain.dynamic_index, + load_expr += join(base, ".Load", template_expr, "(", chain.dynamic_index, chain.static_index + r * chain.matrix_stride, ")"); if (r + 1 < type.vecsize) load_expr += ", "; @@ -3853,7 +3908,7 @@ void CompilerHLSL::read_access_chain(string *expr, const string &lhs, const SPIR for (uint32_t c = 0; c < type.columns; c++) { - load_expr += join(chain.base, ".", load_op, template_expr, "(", chain.dynamic_index, + load_expr += join(base, ".", load_op, template_expr, "(", chain.dynamic_index, chain.static_index + c * chain.matrix_stride, ")"); if (c + 1 < type.columns) load_expr += ", "; @@ -3882,7 +3937,7 @@ void CompilerHLSL::read_access_chain(string *expr, const string &lhs, const SPIR { for (uint32_t r = 0; r < type.vecsize; r++) { - load_expr += join(chain.base, ".Load", template_expr, "(", chain.dynamic_index, + load_expr += join(base, ".Load", template_expr, "(", chain.dynamic_index, chain.static_index + c * (type.width / 8) + r * chain.matrix_stride, ")"); if ((r + 1 < type.vecsize) || (c + 1 < type.columns)) @@ -3919,9 +3974,6 @@ void CompilerHLSL::emit_load(const Instruction &instruction) uint32_t id = ops[1]; uint32_t ptr = ops[2]; - if (has_decoration(ptr, DecorationNonUniformEXT)) - propagate_nonuniform_qualifier(ptr); - auto &type = get(result_type); bool composite_load = !type.array.empty() || type.basetype == SPIRType::Struct; @@ -4060,9 +4112,6 @@ void CompilerHLSL::write_access_chain(const SPIRAccessChain &chain, uint32_t val // Make sure we trigger a read of the constituents in the access chain. track_expression_read(chain.self); - if (has_decoration(chain.self, DecorationNonUniformEXT)) - propagate_nonuniform_qualifier(chain.self); - SPIRType target_type; target_type.basetype = SPIRType::UInt; target_type.vecsize = type.vecsize; @@ -4086,6 +4135,10 @@ void CompilerHLSL::write_access_chain(const SPIRAccessChain &chain, uint32_t val bool templated_store = hlsl_options.shader_model >= 62; + auto base = chain.base; + if (has_decoration(chain.self, DecorationNonUniform)) + convert_non_uniform_expression(base, chain.self); + string template_expr; if (templated_store) template_expr = join("<", type_to_glsl(type), ">"); @@ -4121,7 +4174,7 @@ void CompilerHLSL::write_access_chain(const SPIRAccessChain &chain, uint32_t val } else store_op = "Store"; - statement(chain.base, ".", store_op, template_expr, "(", chain.dynamic_index, chain.static_index, ", ", + statement(base, ".", store_op, template_expr, "(", chain.dynamic_index, chain.static_index, ", ", store_expr, ");"); } else if (type.columns == 1) @@ -4152,7 +4205,7 @@ void CompilerHLSL::write_access_chain(const SPIRAccessChain &chain, uint32_t val store_expr = join(bitcast_op, "(", store_expr, ")"); } - statement(chain.base, ".Store", template_expr, "(", chain.dynamic_index, + statement(base, ".Store", template_expr, "(", chain.dynamic_index, chain.static_index + chain.matrix_stride * r, ", ", store_expr, ");"); } } @@ -4196,7 +4249,7 @@ void CompilerHLSL::write_access_chain(const SPIRAccessChain &chain, uint32_t val store_expr = join(bitcast_op, "(", store_expr, ")"); } - statement(chain.base, ".", store_op, template_expr, "(", chain.dynamic_index, + statement(base, ".", store_op, template_expr, "(", chain.dynamic_index, chain.static_index + c * chain.matrix_stride, ", ", store_expr, ");"); } } @@ -4220,7 +4273,7 @@ void CompilerHLSL::write_access_chain(const SPIRAccessChain &chain, uint32_t val auto bitcast_op = bitcast_glsl_op(target_type, type); if (!bitcast_op.empty()) store_expr = join(bitcast_op, "(", store_expr, ")"); - statement(chain.base, ".Store", template_expr, "(", chain.dynamic_index, + statement(base, ".Store", template_expr, "(", chain.dynamic_index, chain.static_index + c * (type.width / 8) + r * chain.matrix_stride, ", ", store_expr, ");"); } } @@ -4322,9 +4375,6 @@ void CompilerHLSL::emit_access_chain(const Instruction &instruction) inherit_expression_dependencies(ops[1], ops[i]); add_implied_read_expression(e, ops[i]); } - - if (has_decoration(ops[1], DecorationNonUniformEXT)) - propagate_nonuniform_qualifier(ops[1]); } else { @@ -4424,13 +4474,16 @@ void CompilerHLSL::emit_atomic(const uint32_t *ops, uint32_t length, spv::Op op) if (data_type.storage == StorageClassImage || !chain) { - statement(atomic_op, "(", to_expression(ops[0]), ", ", to_expression(ops[3]), ", ", to_expression(tmp_id), - ");"); + statement(atomic_op, "(", to_non_uniform_aware_expression(ops[0]), ", ", + to_expression(ops[3]), ", ", to_expression(tmp_id), ");"); } else { + string base = chain->base; + if (has_decoration(chain->self, DecorationNonUniform)) + convert_non_uniform_expression(base, chain->self); // RWByteAddress buffer is always uint in its underlying type. - statement(chain->base, ".", atomic_op, "(", chain->dynamic_index, chain->static_index, ", ", + statement(base, ".", atomic_op, "(", chain->dynamic_index, chain->static_index, ", ", to_expression(ops[3]), ", ", to_expression(tmp_id), ");"); } } @@ -4448,14 +4501,17 @@ void CompilerHLSL::emit_atomic(const uint32_t *ops, uint32_t length, spv::Op op) SPIRType::BaseType expr_type; if (data_type.storage == StorageClassImage || !chain) { - statement(atomic_op, "(", to_expression(ops[2]), ", ", value_expr, ", ", to_name(id), ");"); + statement(atomic_op, "(", to_non_uniform_aware_expression(ops[2]), ", ", value_expr, ", ", to_name(id), ");"); expr_type = data_type.basetype; } else { // RWByteAddress buffer is always uint in its underlying type. + string base = chain->base; + if (has_decoration(chain->self, DecorationNonUniform)) + convert_non_uniform_expression(base, chain->self); expr_type = SPIRType::UInt; - statement(chain->base, ".", atomic_op, "(", chain->dynamic_index, chain->static_index, ", ", value_expr, + statement(base, ".", atomic_op, "(", chain->dynamic_index, chain->static_index, ", ", value_expr, ", ", to_name(id), ");"); } @@ -4556,13 +4612,35 @@ void CompilerHLSL::emit_subgroup_op(const Instruction &i) } case OpGroupNonUniformShuffle: - SPIRV_CROSS_THROW("Cannot trivially implement Shuffle in HLSL."); + emit_binary_func_op(result_type, id, ops[3], ops[4], "WaveReadLaneAt"); + break; case OpGroupNonUniformShuffleXor: - SPIRV_CROSS_THROW("Cannot trivially implement ShuffleXor in HLSL."); + { + bool forward = should_forward(ops[3]); + emit_op(ops[0], ops[1], + join("WaveReadLaneAt(", to_unpacked_expression(ops[3]), ", ", + "WaveGetLaneIndex() ^ ", to_enclosed_expression(ops[4]), ")"), forward); + inherit_expression_dependencies(ops[1], ops[3]); + break; + } case OpGroupNonUniformShuffleUp: - SPIRV_CROSS_THROW("Cannot trivially implement ShuffleUp in HLSL."); + { + bool forward = should_forward(ops[3]); + emit_op(ops[0], ops[1], + join("WaveReadLaneAt(", to_unpacked_expression(ops[3]), ", ", + "WaveGetLaneIndex() - ", to_enclosed_expression(ops[4]), ")"), forward); + inherit_expression_dependencies(ops[1], ops[3]); + break; + } case OpGroupNonUniformShuffleDown: - SPIRV_CROSS_THROW("Cannot trivially implement ShuffleDown in HLSL."); + { + bool forward = should_forward(ops[3]); + emit_op(ops[0], ops[1], + join("WaveReadLaneAt(", to_unpacked_expression(ops[3]), ", ", + "WaveGetLaneIndex() + ", to_enclosed_expression(ops[4]), ")"), forward); + inherit_expression_dependencies(ops[1], ops[3]); + break; + } case OpGroupNonUniformAll: emit_unary_func_op(result_type, id, ops[3], "WaveActiveAllTrue"); @@ -4573,12 +4651,8 @@ void CompilerHLSL::emit_subgroup_op(const Instruction &i) break; case OpGroupNonUniformAllEqual: - { - auto &type = get(result_type); - emit_unary_func_op(result_type, id, ops[3], - type.basetype == SPIRType::Boolean ? "WaveActiveAllEqualBool" : "WaveActiveAllEqual"); + emit_unary_func_op(result_type, id, ops[3], "WaveActiveAllEqual"); break; - } // clang-format off #define HLSL_GROUP_OP(op, hlsl_op, supports_scan) \ @@ -4626,6 +4700,9 @@ case OpGroupNonUniform##op: \ HLSL_GROUP_OP(BitwiseAnd, BitAnd, false) HLSL_GROUP_OP(BitwiseOr, BitOr, false) HLSL_GROUP_OP(BitwiseXor, BitXor, false) + HLSL_GROUP_OP_CAST(LogicalAnd, BitAnd, uint_type) + HLSL_GROUP_OP_CAST(LogicalOr, BitOr, uint_type) + HLSL_GROUP_OP_CAST(LogicalXor, BitXor, uint_type) #undef HLSL_GROUP_OP #undef HLSL_GROUP_OP_CAST @@ -4702,9 +4779,9 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction) } if (bitcast_type == CompilerHLSL::TypePackUint2x32) - emit_unary_func_op(ops[0], ops[1], ops[2], "SPIRV_Cross_packUint2x32"); + emit_unary_func_op(ops[0], ops[1], ops[2], "spvPackUint2x32"); else - emit_unary_func_op(ops[0], ops[1], ops[2], "SPIRV_Cross_unpackUint2x32"); + emit_unary_func_op(ops[0], ops[1], ops[2], "spvUnpackUint2x32"); } break; @@ -5089,7 +5166,7 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction) auto dummy_samples_levels = join(get_fallback_name(id), "_dummy_parameter"); statement("uint ", dummy_samples_levels, ";"); - auto expr = join("SPIRV_Cross_textureSize(", to_expression(ops[2]), ", ", + auto expr = join("spvTextureSize(", to_non_uniform_aware_expression(ops[2]), ", ", bitcast_expression(SPIRType::UInt, ops[3]), ", ", dummy_samples_levels, ")"); auto &restype = get(ops[0]); @@ -5115,9 +5192,9 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction) string expr; if (uav) - expr = join("SPIRV_Cross_imageSize(", to_expression(ops[2]), ", ", dummy_samples_levels, ")"); + expr = join("spvImageSize(", to_non_uniform_aware_expression(ops[2]), ", ", dummy_samples_levels, ")"); else - expr = join("SPIRV_Cross_textureSize(", to_expression(ops[2]), ", 0u, ", dummy_samples_levels, ")"); + expr = join("spvTextureSize(", to_non_uniform_aware_expression(ops[2]), ", 0u, ", dummy_samples_levels, ")"); auto &restype = get(ops[0]); expr = bitcast_expression(restype, SPIRType::UInt, expr); @@ -5147,9 +5224,9 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction) statement(variable_decl(type, to_name(id)), ";"); if (uav) - statement("SPIRV_Cross_imageSize(", to_expression(ops[2]), ", ", to_name(id), ");"); + statement("spvImageSize(", to_non_uniform_aware_expression(ops[2]), ", ", to_name(id), ");"); else - statement("SPIRV_Cross_textureSize(", to_expression(ops[2]), ", 0u, ", to_name(id), ");"); + statement("spvTextureSize(", to_non_uniform_aware_expression(ops[2]), ", 0u, ", to_name(id), ");"); auto &restype = get(ops[0]); auto expr = bitcast_expression(restype, SPIRType::UInt, to_name(id)); @@ -5180,16 +5257,16 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction) if (operands != ImageOperandsSampleMask || instruction.length != 6) SPIRV_CROSS_THROW("Multisampled image used in OpImageRead, but unexpected operand mask was used."); uint32_t sample = ops[5]; - imgexpr = join(to_expression(ops[2]), ".Load(int2(gl_FragCoord.xy), ", to_expression(sample), ")"); + imgexpr = join(to_non_uniform_aware_expression(ops[2]), ".Load(int2(gl_FragCoord.xy), ", to_expression(sample), ")"); } else - imgexpr = join(to_expression(ops[2]), ".Load(int3(int2(gl_FragCoord.xy), 0))"); + imgexpr = join(to_non_uniform_aware_expression(ops[2]), ".Load(int3(int2(gl_FragCoord.xy), 0))"); pure = true; } else { - imgexpr = join(to_expression(ops[2]), "[", to_expression(ops[3]), "]"); + imgexpr = join(to_non_uniform_aware_expression(ops[2]), "[", to_expression(ops[3]), "]"); // The underlying image type in HLSL depends on the image format, unlike GLSL, where all images are "vec4", // except that the underlying type changes how the data is interpreted. @@ -5238,7 +5315,7 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction) value_expr = remap_swizzle(narrowed_type, expression_type(ops[2]).vecsize, value_expr); } - statement(to_expression(ops[0]), "[", to_expression(ops[1]), "] = ", value_expr, ";"); + statement(to_non_uniform_aware_expression(ops[0]), "[", to_expression(ops[1]), "] = ", value_expr, ";"); if (var && variable_storage_is_aliased(*var)) flush_all_aliased_variables(); break; @@ -5250,10 +5327,7 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction) uint32_t id = ops[1]; auto expr = to_expression(ops[2]); - if (has_decoration(id, DecorationNonUniformEXT) || has_decoration(ops[2], DecorationNonUniformEXT)) - convert_non_uniform_expression(expression_type(ops[2]), expr); expr += join("[", to_expression(ops[3]), "]"); - auto &e = set(id, expr, result_type, true); // When using the pointer, we need to know which variable it is actually loaded from. @@ -5390,7 +5464,7 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction) force_recompile(); } - auto expr = join("SPIRV_Cross_bitfieldInsert(", to_expression(ops[2]), ", ", to_expression(ops[3]), ", ", + auto expr = join("spvBitfieldInsert(", to_expression(ops[2]), ", ", to_expression(ops[3]), ", ", to_expression(ops[4]), ", ", to_expression(ops[5]), ")"); bool forward = @@ -5412,9 +5486,9 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction) } if (opcode == OpBitFieldSExtract) - HLSL_TFOP(SPIRV_Cross_bitfieldSExtract); + HLSL_TFOP(spvBitfieldSExtract); else - HLSL_TFOP(SPIRV_Cross_bitfieldUExtract); + HLSL_TFOP(spvBitfieldUExtract); break; } @@ -5431,7 +5505,7 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction) case OpArrayLength: { - auto *var = maybe_get(ops[2]); + auto *var = maybe_get_backing_variable(ops[2]); if (!var) SPIRV_CROSS_THROW("Array length must point directly to an SSBO block."); @@ -5441,7 +5515,7 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction) // This must be 32-bit uint, so we're good to go. emit_uninitialized_temporary_expression(ops[0], ops[1]); - statement(to_expression(ops[2]), ".GetDimensions(", to_expression(ops[1]), ");"); + statement(to_non_uniform_aware_expression(ops[2]), ".GetDimensions(", to_expression(ops[1]), ");"); uint32_t offset = type_struct_member_offset(type, ops[3]); uint32_t stride = type_struct_member_array_stride(type, ops[3]); statement(to_expression(ops[1]), " = (", to_expression(ops[1]), " - ", offset, ") / ", stride, ";"); @@ -5608,6 +5682,12 @@ void CompilerHLSL::validate_shader_model() if (hlsl_options.shader_model < 51) SPIRV_CROSS_THROW( "Shader model 5.1 or higher is required to use bindless resources or NonUniformResourceIndex."); + break; + + case CapabilityVariablePointers: + case CapabilityVariablePointersStorageBuffer: + SPIRV_CROSS_THROW("VariablePointers capability is not supported in HLSL."); + default: break; } @@ -5651,6 +5731,9 @@ string CompilerHLSL::compile() backend.nonuniform_qualifier = "NonUniformResourceIndex"; backend.support_case_fallthrough = false; + // SM 4.1 does not support precise for some reason. + backend.support_precise_qualifier = hlsl_options.shader_model >= 50 || hlsl_options.shader_model == 40; + fixup_type_alias(); reorder_type_alias(); build_function_control_flow_graphs_and_analyze(); diff --git a/third_party/spirv-cross/spirv_hlsl.hpp b/third_party/spirv-cross/spirv_hlsl.hpp index 4abb203b2a..f46b1868a4 100644 --- a/third_party/spirv-cross/spirv_hlsl.hpp +++ b/third_party/spirv-cross/spirv_hlsl.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 Robert Konrad + * Copyright 2016-2021 Robert Konrad * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #ifndef SPIRV_HLSL_HPP #define SPIRV_HLSL_HPP @@ -237,6 +244,7 @@ private: std::string to_resource_binding(const SPIRVariable &var); std::string to_resource_binding_sampler(const SPIRVariable &var); std::string to_resource_register(HLSLBindingFlagBits flag, char space, uint32_t binding, uint32_t set); + std::string to_initializer_expression(const SPIRVariable &var) override; void emit_sampled_image_op(uint32_t result_type, uint32_t result_id, uint32_t image_id, uint32_t samp_id) override; void emit_access_chain(const Instruction &instruction); void emit_load(const Instruction &instruction); diff --git a/third_party/spirv-cross/spirv_msl.cpp b/third_party/spirv-cross/spirv_msl.cpp index 360c045119..aee52f7dcd 100644 --- a/third_party/spirv-cross/spirv_msl.cpp +++ b/third_party/spirv-cross/spirv_msl.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 The Brenwill Workshop Ltd. + * Copyright 2016-2021 The Brenwill Workshop Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #include "spirv_msl.hpp" #include "GLSL.std.450.h" @@ -60,6 +67,52 @@ void CompilerMSL::add_msl_resource_binding(const MSLResourceBinding &binding) { StageSetBinding tuple = { binding.stage, binding.desc_set, binding.binding }; resource_bindings[tuple] = { binding, false }; + + // If we might need to pad argument buffer members to positionally align + // arg buffer indexes, also maintain a lookup by argument buffer index. + if (msl_options.pad_argument_buffer_resources) + { + StageSetBinding arg_idx_tuple = { binding.stage, binding.desc_set, k_unknown_component }; + +#define ADD_ARG_IDX_TO_BINDING_NUM_LOOKUP(rez) \ + arg_idx_tuple.binding = binding.msl_##rez; \ + resource_arg_buff_idx_to_binding_number[arg_idx_tuple] = binding.binding + + switch (binding.basetype) + { + case SPIRType::Void: + case SPIRType::Boolean: + case SPIRType::SByte: + case SPIRType::UByte: + case SPIRType::Short: + case SPIRType::UShort: + case SPIRType::Int: + case SPIRType::UInt: + case SPIRType::Int64: + case SPIRType::UInt64: + case SPIRType::AtomicCounter: + case SPIRType::Half: + case SPIRType::Float: + case SPIRType::Double: + ADD_ARG_IDX_TO_BINDING_NUM_LOOKUP(buffer); + break; + case SPIRType::Image: + ADD_ARG_IDX_TO_BINDING_NUM_LOOKUP(texture); + break; + case SPIRType::Sampler: + ADD_ARG_IDX_TO_BINDING_NUM_LOOKUP(sampler); + break; + case SPIRType::SampledImage: + ADD_ARG_IDX_TO_BINDING_NUM_LOOKUP(texture); + ADD_ARG_IDX_TO_BINDING_NUM_LOOKUP(sampler); + break; + default: + SPIRV_CROSS_THROW("Unexpected argument buffer resource base type. When padding argument buffer elements, " + "all descriptor set resources must be supplied with a base type by the app."); + break; + } +#undef ADD_ARG_IDX_TO_BINDING_NUM_LOOKUP + } } void CompilerMSL::add_dynamic_buffer(uint32_t desc_set, uint32_t binding, uint32_t index) @@ -93,7 +146,18 @@ void CompilerMSL::set_argument_buffer_device_address_space(uint32_t desc_set, bo bool CompilerMSL::is_msl_shader_input_used(uint32_t location) { - return inputs_in_use.count(location) != 0; + // Don't report internal location allocations to app. + return location_inputs_in_use.count(location) != 0 && + location_inputs_in_use_fallback.count(location) == 0; +} + +uint32_t CompilerMSL::get_automatic_builtin_input_location(spv::BuiltIn builtin) const +{ + auto itr = builtin_to_automatic_input_location.find(builtin); + if (itr == builtin_to_automatic_input_location.end()) + return k_unknown_location; + else + return itr->second; } bool CompilerMSL::is_msl_resource_binding_used(ExecutionModel model, uint32_t desc_set, uint32_t binding) const @@ -168,9 +232,13 @@ void CompilerMSL::build_implicit_builtins() active_input_builtins.get(BuiltInBaseVertex) || active_input_builtins.get(BuiltInInstanceId) || active_input_builtins.get(BuiltInInstanceIndex) || active_input_builtins.get(BuiltInBaseInstance)); bool need_sample_mask = msl_options.additional_fixed_sample_mask != 0xffffffff; + bool need_local_invocation_index = msl_options.emulate_subgroups && active_input_builtins.get(BuiltInSubgroupId); + bool need_workgroup_size = msl_options.emulate_subgroups && active_input_builtins.get(BuiltInNumSubgroups); + if (need_subpass_input || need_sample_pos || need_subgroup_mask || need_vertex_params || need_tesc_params || need_multiview || need_dispatch_base || need_vertex_base_params || need_grid_params || needs_sample_id || - needs_subgroup_invocation_id || needs_subgroup_size || need_sample_mask) + needs_subgroup_invocation_id || needs_subgroup_size || need_sample_mask || need_local_invocation_index || + need_workgroup_size) { bool has_frag_coord = false; bool has_sample_id = false; @@ -184,14 +252,18 @@ void CompilerMSL::build_implicit_builtins() bool has_subgroup_size = false; bool has_view_idx = false; bool has_layer = false; + bool has_local_invocation_index = false; + bool has_workgroup_size = false; uint32_t workgroup_id_type = 0; - // FIXME: Investigate the fact that there are no checks for the entry point interface variables. ir.for_each_typed_id([&](uint32_t, SPIRVariable &var) { - if (!ir.meta[var.self].decoration.builtin) + if (var.storage != StorageClassInput && var.storage != StorageClassOutput) + return; + if (!interface_variable_exists_in_entry_point(var.self)) + return; + if (!has_decoration(var.self, DecorationBuiltIn)) return; - // Use Metal's native frame-buffer fetch API for subpass inputs. BuiltIn builtin = ir.meta[var.self].decoration.builtin_type; if (var.storage == StorageClassOutput) @@ -207,6 +279,7 @@ void CompilerMSL::build_implicit_builtins() if (var.storage != StorageClassInput) return; + // Use Metal's native frame-buffer fetch API for subpass inputs. if (need_subpass_input && (!msl_options.use_framebuffer_fetch_subpasses)) { switch (builtin) @@ -330,6 +403,20 @@ void CompilerMSL::build_implicit_builtins() } } + if (need_local_invocation_index && builtin == BuiltInLocalInvocationIndex) + { + builtin_local_invocation_index_id = var.self; + mark_implicit_builtin(StorageClassInput, BuiltInLocalInvocationIndex, var.self); + has_local_invocation_index = true; + } + + if (need_workgroup_size && builtin == BuiltInLocalInvocationId) + { + builtin_workgroup_size_id = var.self; + mark_implicit_builtin(StorageClassInput, BuiltInWorkgroupSize, var.self); + has_workgroup_size = true; + } + // The base workgroup needs to have the same type and vector size // as the workgroup or invocation ID, so keep track of the type that // was used. @@ -360,6 +447,7 @@ void CompilerMSL::build_implicit_builtins() SPIRType vec4_type_ptr; vec4_type_ptr = vec4_type; vec4_type_ptr.pointer = true; + vec4_type_ptr.pointer_depth++; vec4_type_ptr.parent_type = type_id; vec4_type_ptr.storage = StorageClassInput; auto &ptr_type = set(type_ptr_id, vec4_type_ptr); @@ -381,6 +469,7 @@ void CompilerMSL::build_implicit_builtins() SPIRType uint_type_ptr; uint_type_ptr = get_uint_type(); uint_type_ptr.pointer = true; + uint_type_ptr.pointer_depth++; uint_type_ptr.parent_type = get_uint_type_id(); uint_type_ptr.storage = StorageClassInput; auto &ptr_type = set(type_ptr_id, uint_type_ptr); @@ -402,6 +491,7 @@ void CompilerMSL::build_implicit_builtins() SPIRType uint_type_ptr; uint_type_ptr = get_uint_type(); uint_type_ptr.pointer = true; + uint_type_ptr.pointer_depth++; uint_type_ptr.parent_type = get_uint_type_id(); uint_type_ptr.storage = StorageClassInput; auto &ptr_type = set(type_ptr_id, uint_type_ptr); @@ -424,6 +514,7 @@ void CompilerMSL::build_implicit_builtins() SPIRType uint_type_ptr; uint_type_ptr = get_uint_type(); uint_type_ptr.pointer = true; + uint_type_ptr.pointer_depth++; uint_type_ptr.parent_type = get_uint_type_id(); uint_type_ptr.storage = StorageClassInput; auto &ptr_type = set(type_ptr_id, uint_type_ptr); @@ -443,6 +534,7 @@ void CompilerMSL::build_implicit_builtins() SPIRType uint_type_ptr; uint_type_ptr = get_uint_type(); uint_type_ptr.pointer = true; + uint_type_ptr.pointer_depth++; uint_type_ptr.parent_type = get_uint_type_id(); uint_type_ptr.storage = StorageClassInput; auto &ptr_type = set(type_ptr_id, uint_type_ptr); @@ -502,6 +594,7 @@ void CompilerMSL::build_implicit_builtins() SPIRType uint_type_ptr_out; uint_type_ptr_out = get_uint_type(); uint_type_ptr_out.pointer = true; + uint_type_ptr_out.pointer_depth++; uint_type_ptr_out.parent_type = get_uint_type_id(); uint_type_ptr_out.storage = StorageClassOutput; auto &ptr_out_type = set(type_ptr_out_id, uint_type_ptr_out); @@ -533,6 +626,7 @@ void CompilerMSL::build_implicit_builtins() SPIRType uint_type_ptr; uint_type_ptr = get_uint_type(); uint_type_ptr.pointer = true; + uint_type_ptr.pointer_depth++; uint_type_ptr.parent_type = get_uint_type_id(); uint_type_ptr.storage = StorageClassInput; auto &ptr_type = set(type_ptr_id, uint_type_ptr); @@ -592,6 +686,7 @@ void CompilerMSL::build_implicit_builtins() SPIRType uint_type_ptr; uint_type_ptr = get_uint_type(); uint_type_ptr.pointer = true; + uint_type_ptr.pointer_depth++; uint_type_ptr.parent_type = get_uint_type_id(); uint_type_ptr.storage = StorageClassInput; auto &ptr_type = set(type_ptr_id, uint_type_ptr); @@ -613,6 +708,7 @@ void CompilerMSL::build_implicit_builtins() SPIRType uint_type_ptr; uint_type_ptr = get_uint_type(); uint_type_ptr.pointer = true; + uint_type_ptr.pointer_depth++; uint_type_ptr.parent_type = get_uint_type_id(); uint_type_ptr.storage = StorageClassInput; auto &ptr_type = set(type_ptr_id, uint_type_ptr); @@ -671,6 +767,7 @@ void CompilerMSL::build_implicit_builtins() SPIRType uint_type_ptr_out; uint_type_ptr_out = get_uint_type(); uint_type_ptr_out.pointer = true; + uint_type_ptr_out.pointer_depth++; uint_type_ptr_out.parent_type = get_uint_type_id(); uint_type_ptr_out.storage = StorageClassOutput; @@ -681,6 +778,50 @@ void CompilerMSL::build_implicit_builtins() builtin_sample_mask_id = var_id; mark_implicit_builtin(StorageClassOutput, BuiltInSampleMask, var_id); } + + if (need_local_invocation_index && !has_local_invocation_index) + { + uint32_t offset = ir.increase_bound_by(2); + uint32_t type_ptr_id = offset; + uint32_t var_id = offset + 1; + + // Create gl_LocalInvocationIndex. + SPIRType uint_type_ptr; + uint_type_ptr = get_uint_type(); + uint_type_ptr.pointer = true; + uint_type_ptr.pointer_depth++; + uint_type_ptr.parent_type = get_uint_type_id(); + uint_type_ptr.storage = StorageClassInput; + + auto &ptr_type = set(type_ptr_id, uint_type_ptr); + ptr_type.self = get_uint_type_id(); + set(var_id, type_ptr_id, StorageClassInput); + set_decoration(var_id, DecorationBuiltIn, BuiltInLocalInvocationIndex); + builtin_local_invocation_index_id = var_id; + mark_implicit_builtin(StorageClassInput, BuiltInLocalInvocationIndex, var_id); + } + + if (need_workgroup_size && !has_workgroup_size) + { + uint32_t offset = ir.increase_bound_by(2); + uint32_t type_ptr_id = offset; + uint32_t var_id = offset + 1; + + // Create gl_WorkgroupSize. + uint32_t type_id = build_extended_vector_type(get_uint_type_id(), 3); + SPIRType uint_type_ptr = get(type_id); + uint_type_ptr.pointer = true; + uint_type_ptr.pointer_depth++; + uint_type_ptr.parent_type = type_id; + uint_type_ptr.storage = StorageClassInput; + + auto &ptr_type = set(type_ptr_id, uint_type_ptr); + ptr_type.self = type_id; + set(var_id, type_ptr_id, StorageClassInput); + set_decoration(var_id, DecorationBuiltIn, BuiltInWorkgroupSize); + builtin_workgroup_size_id = var_id; + mark_implicit_builtin(StorageClassInput, BuiltInWorkgroupSize, var_id); + } } if (needs_swizzle_buffer_def) @@ -727,6 +868,52 @@ void CompilerMSL::build_implicit_builtins() msl_options.dynamic_offsets_buffer_index); dynamic_offsets_buffer_id = var_id; } + + // If we're returning a struct from a vertex-like entry point, we must return a position attribute. + bool need_position = + (get_execution_model() == ExecutionModelVertex || + get_execution_model() == ExecutionModelTessellationEvaluation) && + !capture_output_to_buffer && !get_is_rasterization_disabled() && + !active_output_builtins.get(BuiltInPosition); + + if (need_position) + { + // If we can get away with returning void from entry point, we don't need to care. + // If there is at least one other stage output, we need to return [[position]]. + need_position = false; + ir.for_each_typed_id([&](uint32_t, SPIRVariable &var) { + if (var.storage == StorageClassOutput && interface_variable_exists_in_entry_point(var.self)) + need_position = true; + }); + } + + if (need_position) + { + uint32_t offset = ir.increase_bound_by(3); + uint32_t type_id = offset; + uint32_t type_ptr_id = offset + 1; + uint32_t var_id = offset + 2; + + // Create gl_Position. + SPIRType vec4_type; + vec4_type.basetype = SPIRType::Float; + vec4_type.width = 32; + vec4_type.vecsize = 4; + set(type_id, vec4_type); + + SPIRType vec4_type_ptr; + vec4_type_ptr = vec4_type; + vec4_type_ptr.pointer = true; + vec4_type_ptr.pointer_depth++; + vec4_type_ptr.parent_type = type_id; + vec4_type_ptr.storage = StorageClassOutput; + auto &ptr_type = set(type_ptr_id, vec4_type_ptr); + ptr_type.self = type_id; + + set(var_id, type_ptr_id, StorageClassOutput); + set_decoration(var_id, DecorationBuiltIn, BuiltInPosition); + mark_implicit_builtin(StorageClassOutput, BuiltInPosition, var_id); + } } // Checks if the specified builtin variable (e.g. gl_InstanceIndex) is marked as active. @@ -793,7 +980,7 @@ uint32_t CompilerMSL::build_constant_uint_array_pointer() // Create a buffer to hold extra data, including the swizzle constants. SPIRType uint_type_pointer = get_uint_type(); uint_type_pointer.pointer = true; - uint_type_pointer.pointer_depth = 1; + uint_type_pointer.pointer_depth++; uint_type_pointer.parent_type = get_uint_type_id(); uint_type_pointer.storage = StorageClassUniform; set(type_ptr_id, uint_type_pointer); @@ -1112,6 +1299,7 @@ void CompilerMSL::emit_entry_point_declarations() string CompilerMSL::compile() { + replace_illegal_entry_point_names(); ir.fixup_reserved_names(); // Do not deal with GLES-isms like precision, older extensions and such. @@ -1151,6 +1339,7 @@ string CompilerMSL::compile() backend.array_is_value_type = !msl_options.force_native_arrays; // Arrays which are part of buffer objects are never considered to be native arrays. backend.buffer_offset_array_is_value_type = false; + backend.support_pointer_to_pointer = true; capture_output_to_buffer = msl_options.capture_output_to_buffer; is_rasterization_disabled = msl_options.disable_rasterization || capture_output_to_buffer; @@ -1161,6 +1350,7 @@ string CompilerMSL::compile() fixup_type_alias(); replace_illegal_names(); + sync_entry_point_aliases_and_names(); build_function_control_flow_graphs_and_analyze(); update_active_builtins(); @@ -1293,7 +1483,12 @@ void CompilerMSL::preprocess_op_codes() needs_subgroup_invocation_id = true; if (preproc.needs_subgroup_size) needs_subgroup_size = true; - if (preproc.needs_sample_id) + // build_implicit_builtins() hasn't run yet, and in fact, this needs to execute + // before then so that gl_SampleID will get added; so we also need to check if + // that function would add gl_FragCoord. + if (preproc.needs_sample_id || msl_options.force_sample_rate_shading || + (is_sample_rate() && (active_input_builtins.get(BuiltInFragCoord) || + (need_subpass_input && !msl_options.use_framebuffer_fetch_subpasses)))) needs_sample_id = true; } @@ -1489,6 +1684,38 @@ void CompilerMSL::extract_global_variables_from_function(uint32_t func_id, std:: break; } } + break; + } + + case OpGroupNonUniformInverseBallot: + { + added_arg_ids.insert(builtin_subgroup_invocation_id_id); + break; + } + + case OpGroupNonUniformBallotFindLSB: + case OpGroupNonUniformBallotFindMSB: + { + added_arg_ids.insert(builtin_subgroup_size_id); + break; + } + + case OpGroupNonUniformBallotBitCount: + { + auto operation = static_cast(ops[3]); + switch (operation) + { + case GroupOperationReduce: + added_arg_ids.insert(builtin_subgroup_size_id); + break; + case GroupOperationInclusiveScan: + case GroupOperationExclusiveScan: + added_arg_ids.insert(builtin_subgroup_invocation_id_id); + break; + default: + break; + } + break; } default: @@ -1506,8 +1733,11 @@ void CompilerMSL::extract_global_variables_from_function(uint32_t func_id, std:: // Add the global variables as arguments to the function if (func_id != ir.default_entry_point) { - bool added_in = false; - bool added_out = false; + bool control_point_added_in = false; + bool control_point_added_out = false; + bool patch_added_in = false; + bool patch_added_out = false; + for (uint32_t arg_id : added_arg_ids) { auto &var = get(arg_id); @@ -1515,34 +1745,72 @@ void CompilerMSL::extract_global_variables_from_function(uint32_t func_id, std:: auto *p_type = &get(type_id); BuiltIn bi_type = BuiltIn(get_decoration(arg_id, DecorationBuiltIn)); - if (((is_tessellation_shader() && var.storage == StorageClassInput) || - (get_execution_model() == ExecutionModelTessellationControl && var.storage == StorageClassOutput)) && - !(has_decoration(arg_id, DecorationPatch) || is_patch_block(*p_type)) && - (!is_builtin_variable(var) || bi_type == BuiltInPosition || bi_type == BuiltInPointSize || - bi_type == BuiltInClipDistance || bi_type == BuiltInCullDistance || - p_type->basetype == SPIRType::Struct)) + bool is_patch = has_decoration(arg_id, DecorationPatch) || is_patch_block(*p_type); + bool is_block = has_decoration(p_type->self, DecorationBlock); + bool is_control_point_storage = + !is_patch && + ((is_tessellation_shader() && var.storage == StorageClassInput) || + (get_execution_model() == ExecutionModelTessellationControl && var.storage == StorageClassOutput)); + bool is_patch_block_storage = is_patch && is_block && var.storage == StorageClassOutput; + bool is_builtin = is_builtin_variable(var); + bool variable_is_stage_io = + !is_builtin || bi_type == BuiltInPosition || bi_type == BuiltInPointSize || + bi_type == BuiltInClipDistance || bi_type == BuiltInCullDistance || + p_type->basetype == SPIRType::Struct; + bool is_redirected_to_global_stage_io = (is_control_point_storage || is_patch_block_storage) && + variable_is_stage_io; + + // If output is masked it is not considered part of the global stage IO interface. + if (is_redirected_to_global_stage_io && var.storage == StorageClassOutput) + is_redirected_to_global_stage_io = !is_stage_output_variable_masked(var); + + if (is_redirected_to_global_stage_io) { // Tessellation control shaders see inputs and per-vertex outputs as arrays. // Similarly, tessellation evaluation shaders see per-vertex inputs as arrays. // We collected them into a structure; we must pass the array of this // structure to the function. std::string name; + if (is_patch) + name = var.storage == StorageClassInput ? patch_stage_in_var_name : patch_stage_out_var_name; + else + name = var.storage == StorageClassInput ? "gl_in" : "gl_out"; + + if (var.storage == StorageClassOutput && has_decoration(p_type->self, DecorationBlock)) + { + // If we're redirecting a block, we might still need to access the original block + // variable if we're masking some members. + for (uint32_t mbr_idx = 0; mbr_idx < uint32_t(p_type->member_types.size()); mbr_idx++) + { + if (is_stage_output_block_member_masked(var, mbr_idx, true)) + { + func.add_parameter(var.basetype, var.self, true); + break; + } + } + } + + // Tessellation control shaders see inputs and per-vertex outputs as arrays. + // Similarly, tessellation evaluation shaders see per-vertex inputs as arrays. + // We collected them into a structure; we must pass the array of this + // structure to the function. if (var.storage == StorageClassInput) { + auto &added_in = is_patch ? patch_added_in : control_point_added_in; if (added_in) continue; - name = "gl_in"; - arg_id = stage_in_ptr_var_id; + arg_id = is_patch ? patch_stage_in_var_id : stage_in_ptr_var_id; added_in = true; } else if (var.storage == StorageClassOutput) { + auto &added_out = is_patch ? patch_added_out : control_point_added_out; if (added_out) continue; - name = "gl_out"; - arg_id = stage_out_ptr_var_id; + arg_id = is_patch ? patch_stage_out_var_id : stage_out_ptr_var_id; added_out = true; } + type_id = get(arg_id).basetype; uint32_t next_id = ir.increase_bound_by(1); func.add_parameter(type_id, next_id, true); @@ -1550,7 +1818,7 @@ void CompilerMSL::extract_global_variables_from_function(uint32_t func_id, std:: set_name(next_id, name); } - else if (is_builtin_variable(var) && p_type->basetype == SPIRType::Struct) + else if (is_builtin && has_decoration(p_type->self, DecorationBlock)) { // Get the pointee type type_id = get_pointee_type_id(type_id); @@ -1560,7 +1828,7 @@ void CompilerMSL::extract_global_variables_from_function(uint32_t func_id, std:: for (auto &mbr_type_id : p_type->member_types) { BuiltIn builtin = BuiltInMax; - bool is_builtin = is_member_builtin(*p_type, mbr_idx, &builtin); + is_builtin = is_member_builtin(*p_type, mbr_idx, &builtin); if (is_builtin && has_active_builtin(builtin, var.storage)) { // Add a arg variable with the same type and decorations as the member @@ -1574,6 +1842,7 @@ void CompilerMSL::extract_global_variables_from_function(uint32_t func_id, std:: ptr.self = mbr_type_id; ptr.storage = var.storage; ptr.pointer = true; + ptr.pointer_depth++; ptr.parent_type = mbr_type_id; func.add_parameter(mbr_type_id, var_id, true); @@ -1646,33 +1915,19 @@ void CompilerMSL::mark_as_packable(SPIRType &type) } // If a shader input exists at the location, it is marked as being used by this shader -void CompilerMSL::mark_location_as_used_by_shader(uint32_t location, const SPIRType &type, StorageClass storage) +void CompilerMSL::mark_location_as_used_by_shader(uint32_t location, const SPIRType &type, + StorageClass storage, bool fallback) { if (storage != StorageClassInput) return; - if (is_array(type)) + + uint32_t count = type_to_location_count(type); + for (uint32_t i = 0; i < count; i++) { - uint32_t dim = 1; - for (uint32_t i = 0; i < type.array.size(); i++) - dim *= to_array_size_literal(type, i); - for (uint32_t i = 0; i < dim; i++) - { - if (is_matrix(type)) - { - for (uint32_t j = 0; j < type.columns; j++) - inputs_in_use.insert(location++); - } - else - inputs_in_use.insert(location++); - } + location_inputs_in_use.insert(location + i); + if (fallback) + location_inputs_in_use_fallback.insert(location + i); } - else if (is_matrix(type)) - { - for (uint32_t i = 0; i < type.columns; i++) - inputs_in_use.insert(location + i); - } - else - inputs_in_use.insert(location); } uint32_t CompilerMSL::get_target_components_for_fragment_location(uint32_t location) const @@ -1716,6 +1971,7 @@ uint32_t CompilerMSL::build_extended_vector_type(uint32_t type_id, uint32_t comp type->parent_type = new_type_id; type->storage = old_type.storage; type->pointer = true; + type->pointer_depth++; new_type_id = ptr_type_id; } @@ -1735,6 +1991,92 @@ uint32_t CompilerMSL::build_msl_interpolant_type(uint32_t type_id, bool is_noper return new_type_id; } +bool CompilerMSL::add_component_variable_to_interface_block(spv::StorageClass storage, const std::string &ib_var_ref, + SPIRVariable &var, + const SPIRType &type, + InterfaceBlockMeta &meta) +{ + // Deal with Component decorations. + const InterfaceBlockMeta::LocationMeta *location_meta = nullptr; + uint32_t location = ~0u; + if (has_decoration(var.self, DecorationLocation)) + { + location = get_decoration(var.self, DecorationLocation); + auto location_meta_itr = meta.location_meta.find(location); + if (location_meta_itr != end(meta.location_meta)) + location_meta = &location_meta_itr->second; + } + + // Check if we need to pad fragment output to match a certain number of components. + if (location_meta) + { + bool pad_fragment_output = has_decoration(var.self, DecorationLocation) && + msl_options.pad_fragment_output_components && + get_entry_point().model == ExecutionModelFragment && storage == StorageClassOutput; + + auto &entry_func = get(ir.default_entry_point); + uint32_t start_component = get_decoration(var.self, DecorationComponent); + uint32_t type_components = type.vecsize; + uint32_t num_components = location_meta->num_components; + + if (pad_fragment_output) + { + uint32_t locn = get_decoration(var.self, DecorationLocation); + num_components = std::max(num_components, get_target_components_for_fragment_location(locn)); + } + + // We have already declared an IO block member as m_location_N. + // Just emit an early-declared variable and fixup as needed. + // Arrays need to be unrolled here since each location might need a different number of components. + entry_func.add_local_variable(var.self); + vars_needing_early_declaration.push_back(var.self); + + if (var.storage == StorageClassInput) + { + entry_func.fixup_hooks_in.push_back([=, &type, &var]() { + if (!type.array.empty()) + { + uint32_t array_size = to_array_size_literal(type); + for (uint32_t loc_off = 0; loc_off < array_size; loc_off++) + { + statement(to_name(var.self), "[", loc_off, "]", " = ", ib_var_ref, + ".m_location_", location + loc_off, + vector_swizzle(type_components, start_component), ";"); + } + } + else + { + statement(to_name(var.self), " = ", ib_var_ref, ".m_location_", location, + vector_swizzle(type_components, start_component), ";"); + } + }); + } + else + { + entry_func.fixup_hooks_out.push_back([=, &type, &var]() { + if (!type.array.empty()) + { + uint32_t array_size = to_array_size_literal(type); + for (uint32_t loc_off = 0; loc_off < array_size; loc_off++) + { + statement(ib_var_ref, ".m_location_", location + loc_off, + vector_swizzle(type_components, start_component), " = ", + to_name(var.self), "[", loc_off, "];"); + } + } + else + { + statement(ib_var_ref, ".m_location_", location, + vector_swizzle(type_components, start_component), " = ", to_name(var.self), ";"); + } + }); + } + return true; + } + else + return false; +} + void CompilerMSL::add_plain_variable_to_interface_block(StorageClass storage, const string &ib_var_ref, SPIRType &ib_type, SPIRVariable &var, InterfaceBlockMeta &meta) { @@ -1763,65 +2105,14 @@ void CompilerMSL::add_plain_variable_to_interface_block(StorageClass storage, co auto &entry_func = get(ir.default_entry_point); - // Deal with Component decorations. - InterfaceBlockMeta::LocationMeta *location_meta = nullptr; - if (has_decoration(var.self, DecorationLocation)) - { - auto location_meta_itr = meta.location_meta.find(get_decoration(var.self, DecorationLocation)); - if (location_meta_itr != end(meta.location_meta)) - location_meta = &location_meta_itr->second; - } + if (add_component_variable_to_interface_block(storage, ib_var_ref, var, type, meta)) + return; bool pad_fragment_output = has_decoration(var.self, DecorationLocation) && msl_options.pad_fragment_output_components && get_entry_point().model == ExecutionModelFragment && storage == StorageClassOutput; - // Check if we need to pad fragment output to match a certain number of components. - if (location_meta) - { - start_component = get_decoration(var.self, DecorationComponent); - uint32_t num_components = location_meta->num_components; - if (pad_fragment_output) - { - uint32_t locn = get_decoration(var.self, DecorationLocation); - num_components = std::max(num_components, get_target_components_for_fragment_location(locn)); - } - - if (location_meta->ib_index != ~0u) - { - // We have already declared the variable. Just emit an early-declared variable and fixup as needed. - entry_func.add_local_variable(var.self); - vars_needing_early_declaration.push_back(var.self); - - if (var.storage == StorageClassInput) - { - uint32_t ib_index = location_meta->ib_index; - entry_func.fixup_hooks_in.push_back([=, &var]() { - statement(to_name(var.self), " = ", ib_var_ref, ".", to_member_name(ib_type, ib_index), - vector_swizzle(type_components, start_component), ";"); - }); - } - else - { - uint32_t ib_index = location_meta->ib_index; - entry_func.fixup_hooks_out.push_back([=, &var]() { - statement(ib_var_ref, ".", to_member_name(ib_type, ib_index), - vector_swizzle(type_components, start_component), " = ", to_name(var.self), ";"); - }); - } - return; - } - else - { - location_meta->ib_index = uint32_t(ib_type.member_types.size()); - type_id = build_extended_vector_type(type_id, num_components); - if (var.storage == StorageClassInput) - padded_input = true; - else - padded_output = true; - } - } - else if (pad_fragment_output) + if (pad_fragment_output) { uint32_t locn = get_decoration(var.self, DecorationLocation); target_components = get_target_components_for_fragment_location(locn); @@ -1887,8 +2178,23 @@ void CompilerMSL::add_plain_variable_to_interface_block(StorageClass storage, co } else { - entry_func.fixup_hooks_in.push_back( - [=, &var]() { statement(qual_var_name, " = ", to_expression(var.initializer), ";"); }); + if (meta.strip_array) + { + entry_func.fixup_hooks_in.push_back([=, &var]() { + uint32_t index = get_extended_decoration(var.self, SPIRVCrossDecorationInterfaceMemberIndex); + auto invocation = to_tesc_invocation_id(); + statement(to_expression(stage_out_ptr_var_id), "[", + invocation, "].", + to_member_name(ib_type, index), " = ", to_expression(var.initializer), "[", + invocation, "];"); + }); + } + else + { + entry_func.fixup_hooks_in.push_back([=, &var]() { + statement(qual_var_name, " = ", to_expression(var.initializer), ";"); + }); + } } } @@ -1898,9 +2204,8 @@ void CompilerMSL::add_plain_variable_to_interface_block(StorageClass storage, co uint32_t locn = get_decoration(var.self, DecorationLocation); if (storage == StorageClassInput) { - type_id = ensure_correct_input_type(var.basetype, locn, location_meta ? location_meta->num_components : 0); - if (!location_meta) - var.basetype = type_id; + type_id = ensure_correct_input_type(var.basetype, locn, 0, meta.strip_array); + var.basetype = type_id; type_id = get_pointee_type_id(type_id); if (meta.strip_array && is_array(get(type_id))) @@ -1920,13 +2225,10 @@ void CompilerMSL::add_plain_variable_to_interface_block(StorageClass storage, co mark_location_as_used_by_shader(locn, type, storage); } - if (!location_meta) + if (get_decoration_bitset(var.self).get(DecorationComponent)) { - if (get_decoration_bitset(var.self).get(DecorationComponent)) - { - uint32_t component = get_decoration(var.self, DecorationComponent); - set_member_decoration(ib_type.self, ib_mbr_idx, DecorationComponent, component); - } + uint32_t component = get_decoration(var.self, DecorationComponent); + set_member_decoration(ib_type.self, ib_mbr_idx, DecorationComponent, component); } if (get_decoration_bitset(var.self).get(DecorationIndex)) @@ -1956,10 +2258,7 @@ void CompilerMSL::add_plain_variable_to_interface_block(StorageClass storage, co set_member_decoration(ib_type.self, ib_mbr_idx, DecorationSample); } - // If we have location meta, there is no unique OrigID. We won't need it, since we flatten/unflatten - // the variable to stack anyways here. - if (!location_meta) - set_extended_member_decoration(ib_type.self, ib_mbr_idx, SPIRVCrossDecorationInterfaceOrigID, var.self); + set_extended_member_decoration(ib_type.self, ib_mbr_idx, SPIRVCrossDecorationInterfaceOrigID, var.self); } void CompilerMSL::add_composite_variable_to_interface_block(StorageClass storage, const string &ib_var_ref, @@ -1970,6 +2269,9 @@ void CompilerMSL::add_composite_variable_to_interface_block(StorageClass storage auto &var_type = meta.strip_array ? get_variable_element_type(var) : get_variable_data_type(var); uint32_t elem_cnt = 0; + if (add_component_variable_to_interface_block(storage, ib_var_ref, var, var_type, meta)) + return; + if (is_matrix(var_type)) { if (is_array(var_type)) @@ -2066,16 +2368,19 @@ void CompilerMSL::add_composite_variable_to_interface_block(StorageClass storage if (get_decoration_bitset(var.self).get(DecorationLocation)) { uint32_t locn = get_decoration(var.self, DecorationLocation) + i; + uint32_t comp = get_decoration(var.self, DecorationComponent); if (storage == StorageClassInput) { - var.basetype = ensure_correct_input_type(var.basetype, locn); - uint32_t mbr_type_id = ensure_correct_input_type(usable_type->self, locn); + var.basetype = ensure_correct_input_type(var.basetype, locn, 0, meta.strip_array); + uint32_t mbr_type_id = ensure_correct_input_type(usable_type->self, locn, 0, meta.strip_array); if (storage == StorageClassInput && pull_model_inputs.count(var.self)) ib_type.member_types[ib_mbr_idx] = build_msl_interpolant_type(mbr_type_id, is_noperspective); else ib_type.member_types[ib_mbr_idx] = mbr_type_id; } set_member_decoration(ib_type.self, ib_mbr_idx, DecorationLocation, locn); + if (comp) + set_member_decoration(ib_type.self, ib_mbr_idx, DecorationComponent, comp); mark_location_as_used_by_shader(locn, *usable_type, storage); } else if (is_builtin && is_tessellation_shader() && inputs_by_builtin.count(builtin)) @@ -2084,11 +2389,11 @@ void CompilerMSL::add_composite_variable_to_interface_block(StorageClass storage set_member_decoration(ib_type.self, ib_mbr_idx, DecorationLocation, locn); mark_location_as_used_by_shader(locn, *usable_type, storage); } - else if (is_builtin && builtin == BuiltInClipDistance) + else if (is_builtin && (builtin == BuiltInClipDistance || builtin == BuiltInCullDistance)) { - // Declare the ClipDistance as [[user(clipN)]]. - set_member_decoration(ib_type.self, ib_mbr_idx, DecorationBuiltIn, BuiltInClipDistance); - set_member_decoration(ib_type.self, ib_mbr_idx, DecorationLocation, i); + // Declare the Clip/CullDistance as [[user(clip/cullN)]]. + set_member_decoration(ib_type.self, ib_mbr_idx, DecorationBuiltIn, builtin); + set_member_decoration(ib_type.self, ib_mbr_idx, DecorationIndex, i); } if (get_decoration_bitset(var.self).get(DecorationIndex)) @@ -2162,34 +2467,6 @@ void CompilerMSL::add_composite_variable_to_interface_block(StorageClass storage } } -uint32_t CompilerMSL::get_accumulated_member_location(const SPIRVariable &var, uint32_t mbr_idx, bool strip_array) -{ - auto &type = strip_array ? get_variable_element_type(var) : get_variable_data_type(var); - uint32_t location = get_decoration(var.self, DecorationLocation); - - for (uint32_t i = 0; i < mbr_idx; i++) - { - auto &mbr_type = get(type.member_types[i]); - - // Start counting from any place we have a new location decoration. - if (has_member_decoration(type.self, mbr_idx, DecorationLocation)) - location = get_member_decoration(type.self, mbr_idx, DecorationLocation); - - uint32_t location_count = 1; - - if (mbr_type.columns > 1) - location_count = mbr_type.columns; - - if (!mbr_type.array.empty()) - for (uint32_t j = 0; j < uint32_t(mbr_type.array.size()); j++) - location_count *= to_array_size_literal(mbr_type, j); - - location += location_count; - } - - return location; -} - void CompilerMSL::add_composite_member_variable_to_interface_block(StorageClass storage, const string &ib_var_ref, SPIRType &ib_type, SPIRVariable &var, uint32_t mbr_idx, InterfaceBlockMeta &meta) @@ -2285,11 +2562,11 @@ void CompilerMSL::add_composite_member_variable_to_interface_block(StorageClass set_member_decoration(ib_type.self, ib_mbr_idx, DecorationLocation, locn); mark_location_as_used_by_shader(locn, *usable_type, storage); } - else if (is_builtin && builtin == BuiltInClipDistance) + else if (is_builtin && (builtin == BuiltInClipDistance || builtin == BuiltInCullDistance)) { - // Declare the ClipDistance as [[user(clipN)]]. - set_member_decoration(ib_type.self, ib_mbr_idx, DecorationBuiltIn, BuiltInClipDistance); - set_member_decoration(ib_type.self, ib_mbr_idx, DecorationLocation, i); + // Declare the Clip/CullDistance as [[user(clip/cullN)]]. + set_member_decoration(ib_type.self, ib_mbr_idx, DecorationBuiltIn, builtin); + set_member_decoration(ib_type.self, ib_mbr_idx, DecorationIndex, i); } if (has_member_decoration(var_type.self, mbr_idx, DecorationComponent)) @@ -2312,7 +2589,7 @@ void CompilerMSL::add_composite_member_variable_to_interface_block(StorageClass set_extended_member_decoration(ib_type.self, ib_mbr_idx, SPIRVCrossDecorationInterfaceMemberIndex, mbr_idx); // Unflatten or flatten from [[stage_in]] or [[stage_out]] as appropriate. - if (!meta.strip_array) + if (!meta.strip_array && meta.allow_local_declaration) { switch (storage) { @@ -2405,13 +2682,15 @@ void CompilerMSL::add_plain_member_variable_to_interface_block(StorageClass stor qual_var_name += ".interpolate_at_center()"; } + bool flatten_stage_out = false; + if (is_builtin && !meta.strip_array) { // For the builtin gl_PerVertex, we cannot treat it as a block anyways, // so redirect to qualified name. set_member_qualified_name(var_type.self, mbr_idx, qual_var_name); } - else if (!meta.strip_array) + else if (!meta.strip_array && meta.allow_local_declaration) { // Unflatten or flatten from [[stage_in]] or [[stage_out]] as appropriate. switch (storage) @@ -2423,6 +2702,7 @@ void CompilerMSL::add_plain_member_variable_to_interface_block(StorageClass stor break; case StorageClassOutput: + flatten_stage_out = true; entry_func.fixup_hooks_out.push_back([=, &var, &var_type]() { statement(qual_var_name, " = ", to_name(var.self), ".", to_member_name(var_type, mbr_idx), ";"); }); @@ -2439,7 +2719,7 @@ void CompilerMSL::add_plain_member_variable_to_interface_block(StorageClass stor uint32_t locn = get_member_decoration(var_type.self, mbr_idx, DecorationLocation); if (storage == StorageClassInput) { - mbr_type_id = ensure_correct_input_type(mbr_type_id, locn); + mbr_type_id = ensure_correct_input_type(mbr_type_id, locn, 0, meta.strip_array); var_type.member_types[mbr_idx] = mbr_type_id; if (storage == StorageClassInput && pull_model_inputs.count(var.self)) ib_type.member_types[ib_mbr_idx] = build_msl_interpolant_type(mbr_type_id, is_noperspective); @@ -2456,7 +2736,7 @@ void CompilerMSL::add_plain_member_variable_to_interface_block(StorageClass stor uint32_t locn = get_accumulated_member_location(var, mbr_idx, meta.strip_array); if (storage == StorageClassInput) { - mbr_type_id = ensure_correct_input_type(mbr_type_id, locn); + mbr_type_id = ensure_correct_input_type(mbr_type_id, locn, 0, meta.strip_array); var_type.member_types[mbr_idx] = mbr_type_id; if (storage == StorageClassInput && pull_model_inputs.count(var.self)) ib_type.member_types[ib_mbr_idx] = build_msl_interpolant_type(mbr_type_id, is_noperspective); @@ -2491,6 +2771,33 @@ void CompilerMSL::add_plain_member_variable_to_interface_block(StorageClass stor qual_pos_var_name = qual_var_name; } + const SPIRConstant *c = nullptr; + if (!flatten_stage_out && var.storage == StorageClassOutput && + var.initializer != ID(0) && (c = maybe_get(var.initializer))) + { + if (meta.strip_array) + { + entry_func.fixup_hooks_in.push_back([=, &var]() { + auto &type = this->get(var.basetype); + uint32_t index = get_extended_member_decoration(var.self, mbr_idx, SPIRVCrossDecorationInterfaceMemberIndex); + + auto invocation = to_tesc_invocation_id(); + auto constant_chain = join(to_expression(var.initializer), "[", invocation, "]"); + statement(to_expression(stage_out_ptr_var_id), "[", + invocation, "].", + to_member_name(ib_type, index), " = ", + constant_chain, ".", to_member_name(type, mbr_idx), ";"); + }); + } + else + { + entry_func.fixup_hooks_in.push_back([=]() { + statement(qual_var_name, " = ", constant_expression( + this->get(c->subconstants[mbr_idx])), ";"); + }); + } + } + if (storage != StorageClassInput || !pull_model_inputs.count(var.self)) { // Copy interpolation decorations if needed @@ -2522,93 +2829,19 @@ void CompilerMSL::add_tess_level_input_to_interface_block(const std::string &ib_ BuiltIn builtin = BuiltIn(get_decoration(var.self, DecorationBuiltIn)); // Force the variable to have the proper name. - set_name(var.self, builtin_to_glsl(builtin, StorageClassFunction)); + string var_name = builtin_to_glsl(builtin, StorageClassFunction); + set_name(var.self, var_name); - if (get_entry_point().flags.get(ExecutionModeTriangles)) - { - // Triangles are tricky, because we want only one member in the struct. + // We need to declare the variable early and at entry-point scope. + entry_func.add_local_variable(var.self); + vars_needing_early_declaration.push_back(var.self); + bool triangles = get_execution_mode_bitset().get(ExecutionModeTriangles); + string mbr_name; - // We need to declare the variable early and at entry-point scope. - entry_func.add_local_variable(var.self); - vars_needing_early_declaration.push_back(var.self); - - string mbr_name = "gl_TessLevel"; - - // If we already added the other one, we can skip this step. - if (!added_builtin_tess_level) - { - // Add a reference to the variable type to the interface struct. - uint32_t ib_mbr_idx = uint32_t(ib_type.member_types.size()); - - uint32_t type_id = build_extended_vector_type(var_type.self, 4); - - ib_type.member_types.push_back(type_id); - - // Give the member a name - set_member_name(ib_type.self, ib_mbr_idx, mbr_name); - - // There is no qualified alias since we need to flatten the internal array on return. - if (get_decoration_bitset(var.self).get(DecorationLocation)) - { - uint32_t locn = get_decoration(var.self, DecorationLocation); - set_member_decoration(ib_type.self, ib_mbr_idx, DecorationLocation, locn); - mark_location_as_used_by_shader(locn, var_type, StorageClassInput); - } - else if (inputs_by_builtin.count(builtin)) - { - uint32_t locn = inputs_by_builtin[builtin].location; - set_member_decoration(ib_type.self, ib_mbr_idx, DecorationLocation, locn); - mark_location_as_used_by_shader(locn, var_type, StorageClassInput); - } - - added_builtin_tess_level = true; - } - - switch (builtin) - { - case BuiltInTessLevelOuter: - entry_func.fixup_hooks_in.push_back([=, &var]() { - statement(to_name(var.self), "[0] = ", ib_var_ref, ".", mbr_name, ".x;"); - statement(to_name(var.self), "[1] = ", ib_var_ref, ".", mbr_name, ".y;"); - statement(to_name(var.self), "[2] = ", ib_var_ref, ".", mbr_name, ".z;"); - }); - break; - - case BuiltInTessLevelInner: - entry_func.fixup_hooks_in.push_back( - [=, &var]() { statement(to_name(var.self), "[0] = ", ib_var_ref, ".", mbr_name, ".w;"); }); - break; - - default: - assert(false); - break; - } - } - else - { - // Add a reference to the variable type to the interface struct. - uint32_t ib_mbr_idx = uint32_t(ib_type.member_types.size()); - - uint32_t type_id = build_extended_vector_type(var_type.self, builtin == BuiltInTessLevelOuter ? 4 : 2); - // Change the type of the variable, too. - uint32_t ptr_type_id = ir.increase_bound_by(1); - auto &new_var_type = set(ptr_type_id, get(type_id)); - new_var_type.pointer = true; - new_var_type.storage = StorageClassInput; - new_var_type.parent_type = type_id; - var.basetype = ptr_type_id; - - ib_type.member_types.push_back(type_id); - - // Give the member a name - string mbr_name = to_expression(var.self); - set_member_name(ib_type.self, ib_mbr_idx, mbr_name); - - // Since vectors can be indexed like arrays, there is no need to unpack this. We can - // just refer to the vector directly. So give it a qualified alias. - string qual_var_name = ib_var_ref + "." + mbr_name; - ir.meta[var.self].decoration.qualified_alias = qual_var_name; + // Add a reference to the variable type to the interface struct. + uint32_t ib_mbr_idx = uint32_t(ib_type.member_types.size()); + const auto mark_locations = [&](const SPIRType &new_var_type) { if (get_decoration_bitset(var.self).get(DecorationLocation)) { uint32_t locn = get_decoration(var.self, DecorationLocation); @@ -2621,6 +2854,170 @@ void CompilerMSL::add_tess_level_input_to_interface_block(const std::string &ib_ set_member_decoration(ib_type.self, ib_mbr_idx, DecorationLocation, locn); mark_location_as_used_by_shader(locn, new_var_type, StorageClassInput); } + }; + + if (triangles) + { + // Triangles are tricky, because we want only one member in the struct. + mbr_name = "gl_TessLevel"; + + // If we already added the other one, we can skip this step. + if (!added_builtin_tess_level) + { + uint32_t type_id = build_extended_vector_type(var_type.self, 4); + + ib_type.member_types.push_back(type_id); + + // Give the member a name + set_member_name(ib_type.self, ib_mbr_idx, mbr_name); + + // We cannot decorate both, but the important part is that + // it's marked as builtin so we can get automatic attribute assignment if needed. + set_member_decoration(ib_type.self, ib_mbr_idx, DecorationBuiltIn, builtin); + + mark_locations(var_type); + added_builtin_tess_level = true; + } + } + else + { + mbr_name = var_name; + + uint32_t type_id = build_extended_vector_type(var_type.self, builtin == BuiltInTessLevelOuter ? 4 : 2); + + uint32_t ptr_type_id = ir.increase_bound_by(1); + auto &new_var_type = set(ptr_type_id, get(type_id)); + new_var_type.pointer = true; + new_var_type.pointer_depth++; + new_var_type.storage = StorageClassInput; + new_var_type.parent_type = type_id; + + ib_type.member_types.push_back(type_id); + + // Give the member a name + set_member_name(ib_type.self, ib_mbr_idx, mbr_name); + set_member_decoration(ib_type.self, ib_mbr_idx, DecorationBuiltIn, builtin); + + mark_locations(new_var_type); + } + + if (builtin == BuiltInTessLevelOuter) + { + entry_func.fixup_hooks_in.push_back([=]() { + statement(var_name, "[0] = ", ib_var_ref, ".", mbr_name, ".x;"); + statement(var_name, "[1] = ", ib_var_ref, ".", mbr_name, ".y;"); + statement(var_name, "[2] = ", ib_var_ref, ".", mbr_name, ".z;"); + if (!triangles) + statement(var_name, "[3] = ", ib_var_ref, ".", mbr_name, ".w;"); + }); + } + else + { + entry_func.fixup_hooks_in.push_back([=]() { + if (triangles) + { + statement(var_name, "[0] = ", ib_var_ref, ".", mbr_name, ".w;"); + } + else + { + statement(var_name, "[0] = ", ib_var_ref, ".", mbr_name, ".x;"); + statement(var_name, "[1] = ", ib_var_ref, ".", mbr_name, ".y;"); + } + }); + } +} + +bool CompilerMSL::variable_storage_requires_stage_io(spv::StorageClass storage) const +{ + if (storage == StorageClassOutput) + return !capture_output_to_buffer; + else if (storage == StorageClassInput) + return !(get_execution_model() == ExecutionModelTessellationControl && msl_options.multi_patch_workgroup); + else + return false; +} + +string CompilerMSL::to_tesc_invocation_id() +{ + if (msl_options.multi_patch_workgroup) + { + // n.b. builtin_invocation_id_id here is the dispatch global invocation ID, + // not the TC invocation ID. + return join(to_expression(builtin_invocation_id_id), ".x % ", get_entry_point().output_vertices); + } + else + return builtin_to_glsl(BuiltInInvocationId, StorageClassInput); +} + +void CompilerMSL::emit_local_masked_variable(const SPIRVariable &masked_var, bool strip_array) +{ + auto &entry_func = get(ir.default_entry_point); + bool threadgroup_storage = variable_decl_is_remapped_storage(masked_var, StorageClassWorkgroup); + + if (threadgroup_storage && msl_options.multi_patch_workgroup) + { + // We need one threadgroup block per patch, so fake this. + entry_func.fixup_hooks_in.push_back([this, &masked_var]() { + auto &type = get_variable_data_type(masked_var); + add_local_variable_name(masked_var.self); + + bool old_is_builtin = is_using_builtin_array; + is_using_builtin_array = true; + + const uint32_t max_control_points_per_patch = 32u; + uint32_t max_num_instances = + (max_control_points_per_patch + get_entry_point().output_vertices - 1u) / + get_entry_point().output_vertices; + statement("threadgroup ", type_to_glsl(type), " ", + "spvStorage", to_name(masked_var.self), "[", max_num_instances, "]", + type_to_array_glsl(type), ";"); + + // Assign a threadgroup slice to each PrimitiveID. + // We assume here that workgroup size is rounded to 32, + // since that's the maximum number of control points per patch. + // We cannot size the array based on fixed dispatch parameters, + // since Metal does not allow that. :( + // FIXME: We will likely need an option to support passing down target workgroup size, + // so we can emit appropriate size here. + statement("threadgroup ", type_to_glsl(type), " ", + "(&", to_name(masked_var.self), ")", + type_to_array_glsl(type), " = spvStorage", to_name(masked_var.self), "[", + "(", to_expression(builtin_invocation_id_id), ".x / ", + get_entry_point().output_vertices, ") % ", + max_num_instances, "];"); + + is_using_builtin_array = old_is_builtin; + }); + } + else + { + entry_func.add_local_variable(masked_var.self); + } + + if (!threadgroup_storage) + { + vars_needing_early_declaration.push_back(masked_var.self); + } + else if (masked_var.initializer) + { + // Cannot directly initialize threadgroup variables. Need fixup hooks. + ID initializer = masked_var.initializer; + if (strip_array) + { + entry_func.fixup_hooks_in.push_back([this, &masked_var, initializer]() { + auto invocation = to_tesc_invocation_id(); + statement(to_expression(masked_var.self), "[", + invocation, "] = ", + to_expression(initializer), "[", + invocation, "];"); + }); + } + else + { + entry_func.fixup_hooks_in.push_back([this, &masked_var, initializer]() { + statement(to_expression(masked_var.self), " = ", to_expression(initializer), ";"); + }); + } } } @@ -2634,11 +3031,25 @@ void CompilerMSL::add_variable_to_interface_block(StorageClass storage, const st auto &var_type = meta.strip_array ? get_variable_element_type(var) : get_variable_data_type(var); bool is_builtin = is_builtin_variable(var); auto builtin = BuiltIn(get_decoration(var.self, DecorationBuiltIn)); + bool is_block = has_decoration(var_type.self, DecorationBlock); + + // If stage variables are masked out, emit them as plain variables instead. + // For builtins, we query them one by one later. + // IO blocks are not masked here, we need to mask them per-member instead. + if (storage == StorageClassOutput && is_stage_output_variable_masked(var)) + { + // If we ignore an output, we must still emit it, since it might be used by app. + // Instead, just emit it as early declaration. + emit_local_masked_variable(var, meta.strip_array); + return; + } if (var_type.basetype == SPIRType::Struct) { - if (!is_builtin_type(var_type) && (!capture_output_to_buffer || storage == StorageClassInput) && - !meta.strip_array) + bool block_requires_flattening = variable_storage_requires_stage_io(storage) || is_block; + bool needs_local_declaration = !is_builtin && block_requires_flattening && meta.allow_local_declaration; + + if (needs_local_declaration) { // For I/O blocks or structs, we will need to pass the block itself around // to functions if they are used globally in leaf functions. @@ -2646,11 +3057,10 @@ void CompilerMSL::add_variable_to_interface_block(StorageClass storage, const st // we unflatten I/O blocks while running the shader, // and pass the actual struct type down to leaf functions. // We then unflatten inputs, and flatten outputs in the "fixup" stages. - entry_func.add_local_variable(var.self); - vars_needing_early_declaration.push_back(var.self); + emit_local_masked_variable(var, meta.strip_array); } - if (capture_output_to_buffer && storage != StorageClassInput && !has_decoration(var_type.self, DecorationBlock)) + if (!block_requires_flattening) { // In Metal tessellation shaders, the interface block itself is arrayed. This makes things // very complicated, since stage-in structures in MSL don't support nested structures. @@ -2661,6 +3071,8 @@ void CompilerMSL::add_variable_to_interface_block(StorageClass storage, const st } else { + bool masked_block = false; + // Flatten the struct members into the interface struct for (uint32_t mbr_idx = 0; mbr_idx < uint32_t(var_type.member_types.size()); mbr_idx++) { @@ -2668,18 +3080,48 @@ void CompilerMSL::add_variable_to_interface_block(StorageClass storage, const st is_builtin = is_member_builtin(var_type, mbr_idx, &builtin); auto &mbr_type = get(var_type.member_types[mbr_idx]); - if (!is_builtin || has_active_builtin(builtin, storage)) + if (storage == StorageClassOutput && is_stage_output_block_member_masked(var, mbr_idx, meta.strip_array)) + { + if (is_block) + masked_block = true; + + // Non-builtin block output variables are just ignored, since they will still access + // the block variable as-is. They're just not flattened. + if (is_builtin && !meta.strip_array) + { + // Emit a fake variable instead. + uint32_t ids = ir.increase_bound_by(2); + uint32_t ptr_type_id = ids + 0; + uint32_t var_id = ids + 1; + + auto ptr_type = mbr_type; + ptr_type.pointer = true; + ptr_type.pointer_depth++; + ptr_type.parent_type = var_type.member_types[mbr_idx]; + ptr_type.storage = StorageClassOutput; + + uint32_t initializer = 0; + if (var.initializer) + if (auto *c = maybe_get(var.initializer)) + initializer = c->subconstants[mbr_idx]; + + set(ptr_type_id, ptr_type); + set(var_id, ptr_type_id, StorageClassOutput, initializer); + entry_func.add_local_variable(var_id); + vars_needing_early_declaration.push_back(var_id); + set_name(var_id, builtin_to_glsl(builtin, StorageClassOutput)); + set_decoration(var_id, DecorationBuiltIn, builtin); + } + } + else if (!is_builtin || has_active_builtin(builtin, storage)) { bool is_composite_type = is_matrix(mbr_type) || is_array(mbr_type); bool attribute_load_store = storage == StorageClassInput && get_execution_model() != ExecutionModelFragment; - bool storage_is_stage_io = - (storage == StorageClassInput && !(get_execution_model() == ExecutionModelTessellationControl && - msl_options.multi_patch_workgroup)) || - storage == StorageClassOutput; + bool storage_is_stage_io = variable_storage_requires_stage_io(storage); - // ClipDistance always needs to be declared as user attributes. - if (builtin == BuiltInClipDistance) + // Clip/CullDistance always need to be declared as user attributes. + if (builtin == BuiltInClipDistance || builtin == BuiltInCullDistance) is_builtin = false; if ((!is_builtin || attribute_load_store) && storage_is_stage_io && is_composite_type) @@ -2693,6 +3135,29 @@ void CompilerMSL::add_variable_to_interface_block(StorageClass storage, const st } } } + + // If we're redirecting a block, we might still need to access the original block + // variable if we're masking some members. + if (masked_block && !needs_local_declaration && + (!is_builtin_variable(var) || get_execution_model() == ExecutionModelTessellationControl)) + { + if (is_builtin_variable(var)) + { + // Ensure correct names for the block members if we're actually going to + // declare gl_PerVertex. + for (uint32_t mbr_idx = 0; mbr_idx < uint32_t(var_type.member_types.size()); mbr_idx++) + { + set_member_name(var_type.self, mbr_idx, builtin_to_glsl( + BuiltIn(get_member_decoration(var_type.self, mbr_idx, DecorationBuiltIn)), + StorageClassOutput)); + } + + set_name(var_type.self, "gl_PerVertex"); + set_name(var.self, "gl_out_masked"); + stage_out_masked_builtin_type_id = var_type.self; + } + emit_local_masked_variable(var, meta.strip_array); + } } } else if (get_execution_model() == ExecutionModelTessellationEvaluation && storage == StorageClassInput && @@ -2701,19 +3166,16 @@ void CompilerMSL::add_variable_to_interface_block(StorageClass storage, const st add_tess_level_input_to_interface_block(ib_var_ref, ib_type, var); } else if (var_type.basetype == SPIRType::Boolean || var_type.basetype == SPIRType::Char || - type_is_integral(var_type) || type_is_floating_point(var_type) || var_type.basetype == SPIRType::Boolean) + type_is_integral(var_type) || type_is_floating_point(var_type)) { if (!is_builtin || has_active_builtin(builtin, storage)) { bool is_composite_type = is_matrix(var_type) || is_array(var_type); - bool storage_is_stage_io = - (storage == StorageClassInput && - !(get_execution_model() == ExecutionModelTessellationControl && msl_options.multi_patch_workgroup)) || - (storage == StorageClassOutput && !capture_output_to_buffer); + bool storage_is_stage_io = variable_storage_requires_stage_io(storage); bool attribute_load_store = storage == StorageClassInput && get_execution_model() != ExecutionModelFragment; - // ClipDistance always needs to be declared as user attributes. - if (builtin == BuiltInClipDistance) + // Clip/CullDistance always needs to be declared as user attributes. + if (builtin == BuiltInClipDistance || builtin == BuiltInCullDistance) is_builtin = false; // MSL does not allow matrices or arrays in input or output variables, so need to handle it specially. @@ -2751,10 +3213,16 @@ void CompilerMSL::fix_up_interface_member_indices(StorageClass storage, uint32_t auto &var = get(var_id); auto &type = get_variable_element_type(var); - if (storage == StorageClassInput && type.basetype == SPIRType::Struct) - { - uint32_t mbr_idx = get_extended_member_decoration(ib_type_id, i, SPIRVCrossDecorationInterfaceMemberIndex); + bool flatten_composites = variable_storage_requires_stage_io(var.storage); + bool is_block = has_decoration(type.self, DecorationBlock); + + uint32_t mbr_idx = uint32_t(-1); + if (type.basetype == SPIRType::Struct && (flatten_composites || is_block)) + mbr_idx = get_extended_member_decoration(ib_type_id, i, SPIRVCrossDecorationInterfaceMemberIndex); + + if (mbr_idx != uint32_t(-1)) + { // Only set the lowest InterfaceMemberIndex for each variable member. // IB struct members will be emitted in-order w.r.t. interface member index. if (!has_extended_member_decoration(var_id, mbr_idx, SPIRVCrossDecorationInterfaceMemberIndex)) @@ -2796,23 +3264,49 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch) auto &type = this->get(var.basetype); bool is_builtin = is_builtin_variable(var); - auto bi_type = BuiltIn(get_decoration(var_id, DecorationBuiltIn)); + bool is_block = has_decoration(type.self, DecorationBlock); + + auto bi_type = BuiltInMax; + bool builtin_is_gl_in_out = false; + if (is_builtin && !is_block) + { + bi_type = BuiltIn(get_decoration(var_id, DecorationBuiltIn)); + builtin_is_gl_in_out = bi_type == BuiltInPosition || bi_type == BuiltInPointSize || + bi_type == BuiltInClipDistance || bi_type == BuiltInCullDistance; + } + + if (is_builtin && is_block) + builtin_is_gl_in_out = true; + uint32_t location = get_decoration(var_id, DecorationLocation); + bool builtin_is_stage_in_out = builtin_is_gl_in_out || + bi_type == BuiltInLayer || bi_type == BuiltInViewportIndex || + bi_type == BuiltInBaryCoordNV || bi_type == BuiltInBaryCoordNoPerspNV || + bi_type == BuiltInFragDepth || + bi_type == BuiltInFragStencilRefEXT || bi_type == BuiltInSampleMask; + // These builtins are part of the stage in/out structs. bool is_interface_block_builtin = - (bi_type == BuiltInPosition || bi_type == BuiltInPointSize || bi_type == BuiltInClipDistance || - bi_type == BuiltInCullDistance || bi_type == BuiltInLayer || bi_type == BuiltInViewportIndex || - bi_type == BuiltInBaryCoordNV || bi_type == BuiltInBaryCoordNoPerspNV || bi_type == BuiltInFragDepth || - bi_type == BuiltInFragStencilRefEXT || bi_type == BuiltInSampleMask) || - (get_execution_model() == ExecutionModelTessellationEvaluation && - (bi_type == BuiltInTessLevelOuter || bi_type == BuiltInTessLevelInner)); + builtin_is_stage_in_out || + (get_execution_model() == ExecutionModelTessellationEvaluation && + (bi_type == BuiltInTessLevelOuter || bi_type == BuiltInTessLevelInner)); bool is_active = interface_variable_exists_in_entry_point(var.self); if (is_builtin && is_active) { // Only emit the builtin if it's active in this entry point. Interface variable list might lie. - is_active = has_active_builtin(bi_type, storage); + if (is_block) + { + // If any builtin is active, the block is active. + uint32_t mbr_cnt = uint32_t(type.member_types.size()); + for (uint32_t i = 0; !is_active && i < mbr_cnt; i++) + is_active = has_active_builtin(BuiltIn(get_member_decoration(type.self, i, DecorationBuiltIn)), storage); + } + else + { + is_active = has_active_builtin(bi_type, storage); + } } bool filter_patch_decoration = (has_decoration(var_id, DecorationPatch) || is_patch_block(type)) == patch; @@ -2820,7 +3314,7 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch) bool hidden = is_hidden_variable(var, incl_builtins); // ClipDistance is never hidden, we need to emulate it when used as an input. - if (bi_type == BuiltInClipDistance) + if (bi_type == BuiltInClipDistance || bi_type == BuiltInCullDistance) hidden = false; // It's not enough to simply avoid marking fragment outputs if the pipeline won't @@ -2857,7 +3351,6 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch) // Need to deal specially with DecorationComponent. // Multiple variables can alias the same Location, and try to make sure each location is declared only once. // We will swizzle data in and out to make this work. - // We only need to consider plain variables here, not composites. // This is only relevant for vertex inputs and fragment outputs. // Technically tessellation as well, but it is too complicated to support. uint32_t component = get_decoration(var_id, DecorationComponent); @@ -2867,8 +3360,22 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch) SPIRV_CROSS_THROW("Component decoration is not supported in tessellation shaders."); else if (pack_components) { - auto &location_meta = meta.location_meta[location]; - location_meta.num_components = std::max(location_meta.num_components, component + type.vecsize); + uint32_t array_size = 1; + if (!type.array.empty()) + array_size = to_array_size_literal(type); + + for (uint32_t location_offset = 0; location_offset < array_size; location_offset++) + { + auto &location_meta = meta.location_meta[location + location_offset]; + location_meta.num_components = std::max(location_meta.num_components, component + type.vecsize); + + // For variables sharing location, decorations and base type must match. + location_meta.base_type_id = type.self; + location_meta.flat = has_decoration(var.self, DecorationFlat); + location_meta.noperspective = has_decoration(var.self, DecorationNoPerspective); + location_meta.centroid = has_decoration(var.self, DecorationCentroid); + location_meta.sample = has_decoration(var.self, DecorationSample); + } } } } @@ -3055,7 +3562,11 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch) (get_execution_model() == ExecutionModelTessellationEvaluation && storage == StorageClassInput)) && !patch; + // Fixing up flattened stores in TESC is impossible since the memory is group shared either via + // device (not masked) or threadgroup (masked) storage classes and it's race condition city. meta.strip_array = strip_array; + meta.allow_local_declaration = !strip_array && !(get_execution_model() == ExecutionModelTessellationControl && + storage == StorageClassOutput); add_variable_to_interface_block(storage, ib_var_ref, ib_type, *p_var, meta); } @@ -3066,7 +3577,7 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch) // the struct containing them is the correct size and layout. for (auto &input : inputs_by_location) { - if (is_msl_shader_input_used(input.first)) + if (location_inputs_in_use.count(input.first) != 0) continue; // Create a fake variable to put at the location. @@ -3099,6 +3610,7 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch) set(array_type_id, type); type.pointer = true; + type.pointer_depth++; type.parent_type = array_type_id; type.storage = storage; auto &ptr_type = set(ptr_type_id, type); @@ -3107,18 +3619,43 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch) auto &fake_var = set(var_id, ptr_type_id, storage); set_decoration(var_id, DecorationLocation, input.first); meta.strip_array = true; + meta.allow_local_declaration = false; add_variable_to_interface_block(storage, ib_var_ref, ib_type, fake_var, meta); } } + // When multiple variables need to access same location, + // unroll locations one by one and we will flatten output or input as necessary. + for (auto &loc : meta.location_meta) + { + uint32_t location = loc.first; + auto &location_meta = loc.second; + + uint32_t ib_mbr_idx = uint32_t(ib_type.member_types.size()); + uint32_t type_id = build_extended_vector_type(location_meta.base_type_id, location_meta.num_components); + ib_type.member_types.push_back(type_id); + + set_member_name(ib_type.self, ib_mbr_idx, join("m_location_", location)); + set_member_decoration(ib_type.self, ib_mbr_idx, DecorationLocation, location); + mark_location_as_used_by_shader(location, get(type_id), storage); + + if (location_meta.flat) + set_member_decoration(ib_type.self, ib_mbr_idx, DecorationFlat); + if (location_meta.noperspective) + set_member_decoration(ib_type.self, ib_mbr_idx, DecorationNoPerspective); + if (location_meta.centroid) + set_member_decoration(ib_type.self, ib_mbr_idx, DecorationCentroid); + if (location_meta.sample) + set_member_decoration(ib_type.self, ib_mbr_idx, DecorationSample); + } + // Sort the members of the structure by their locations. - MemberSorter member_sorter(ib_type, ir.meta[ib_type_id], MemberSorter::Location); + MemberSorter member_sorter(ib_type, ir.meta[ib_type_id], MemberSorter::LocationThenBuiltInType); member_sorter.sort(); // The member indices were saved to the original variables, but after the members // were sorted, those indices are now likely incorrect. Fix those up now. - if (!patch) - fix_up_interface_member_indices(storage, ib_type_id); + fix_up_interface_member_indices(storage, ib_type_id); // For patch inputs, add one more member, holding the array of control point data. if (get_execution_model() == ExecutionModelTessellationEvaluation && storage == StorageClassInput && patch && @@ -3154,6 +3691,7 @@ uint32_t CompilerMSL::add_interface_block_pointer(uint32_t ib_var_id, StorageCla auto &ib_ptr_type = set(ib_ptr_type_id, ib_type); ib_ptr_type.parent_type = ib_ptr_type.type_alias = ib_type.self; ib_ptr_type.pointer = true; + ib_ptr_type.pointer_depth++; ib_ptr_type.storage = storage == StorageClassInput ? (msl_options.multi_patch_workgroup ? StorageClassStorageBuffer : StorageClassWorkgroup) : @@ -3219,6 +3757,7 @@ uint32_t CompilerMSL::ensure_correct_builtin_type(uint32_t type_id, BuiltIn buil auto &ptr_type = set(ptr_type_id); ptr_type = base_type; ptr_type.pointer = true; + ptr_type.pointer_depth++; ptr_type.storage = type.storage; ptr_type.parent_type = base_type_id; return ptr_type_id; @@ -3230,10 +3769,16 @@ uint32_t CompilerMSL::ensure_correct_builtin_type(uint32_t type_id, BuiltIn buil // Ensure that the type is compatible with the shader input. // If it is, simply return the given type ID. // Otherwise, create a new type, and return its ID. -uint32_t CompilerMSL::ensure_correct_input_type(uint32_t type_id, uint32_t location, uint32_t num_components) +uint32_t CompilerMSL::ensure_correct_input_type(uint32_t type_id, uint32_t location, uint32_t num_components, bool strip_array) { auto &type = get(type_id); + uint32_t max_array_dimensions = strip_array ? 1 : 0; + + // Struct and array types must match exactly. + if (type.basetype == SPIRType::Struct || type.array.size() > max_array_dimensions) + return type_id; + auto p_va = inputs_by_location.find(location); if (p_va == end(inputs_by_location)) { @@ -4368,6 +4913,16 @@ void CompilerMSL::emit_custom_functions() statement(""); break; + // "fsub" intrinsic support + case SPVFuncImplFSub: + statement("template"); + statement("T spvFSub(T l, T r)"); + begin_scope(); + statement("return fma(T(-1), r, l);"); + end_scope(); + statement(""); + break; + // "fmul' intrinsic support case SPVFuncImplFMul: statement("template"); @@ -4755,7 +5310,7 @@ void CompilerMSL::emit_custom_functions() statement("template"); statement("inline T spvSubgroupBroadcast(T value, ushort lane)"); begin_scope(); - if (msl_options.is_ios()) + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) statement("return quad_broadcast(value, lane);"); else statement("return simd_broadcast(value, lane);"); @@ -4764,7 +5319,7 @@ void CompilerMSL::emit_custom_functions() statement("template<>"); statement("inline bool spvSubgroupBroadcast(bool value, ushort lane)"); begin_scope(); - if (msl_options.is_ios()) + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) statement("return !!quad_broadcast((ushort)value, lane);"); else statement("return !!simd_broadcast((ushort)value, lane);"); @@ -4773,7 +5328,7 @@ void CompilerMSL::emit_custom_functions() statement("template"); statement("inline vec spvSubgroupBroadcast(vec value, ushort lane)"); begin_scope(); - if (msl_options.is_ios()) + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) statement("return (vec)quad_broadcast((vec)value, lane);"); else statement("return (vec)simd_broadcast((vec)value, lane);"); @@ -4785,19 +5340,28 @@ void CompilerMSL::emit_custom_functions() statement("template"); statement("inline T spvSubgroupBroadcastFirst(T value)"); begin_scope(); - statement("return simd_broadcast_first(value);"); + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) + statement("return quad_broadcast_first(value);"); + else + statement("return simd_broadcast_first(value);"); end_scope(); statement(""); statement("template<>"); statement("inline bool spvSubgroupBroadcastFirst(bool value)"); begin_scope(); - statement("return !!simd_broadcast_first((ushort)value);"); + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) + statement("return !!quad_broadcast_first((ushort)value);"); + else + statement("return !!simd_broadcast_first((ushort)value);"); end_scope(); statement(""); statement("template"); statement("inline vec spvSubgroupBroadcastFirst(vec value)"); begin_scope(); - statement("return (vec)simd_broadcast_first((vec)value);"); + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) + statement("return (vec)quad_broadcast_first((vec)value);"); + else + statement("return (vec)simd_broadcast_first((vec)value);"); end_scope(); statement(""); break; @@ -4805,13 +5369,26 @@ void CompilerMSL::emit_custom_functions() case SPVFuncImplSubgroupBallot: statement("inline uint4 spvSubgroupBallot(bool value)"); begin_scope(); - statement("simd_vote vote = simd_ballot(value);"); - statement("// simd_ballot() returns a 64-bit integer-like object, but"); - statement("// SPIR-V callers expect a uint4. We must convert."); - statement("// FIXME: This won't include higher bits if Apple ever supports"); - statement("// 128 lanes in an SIMD-group."); - statement("return uint4((uint)((simd_vote::vote_t)vote & 0xFFFFFFFF), (uint)(((simd_vote::vote_t)vote >> " - "32) & 0xFFFFFFFF), 0, 0);"); + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) + { + statement("return uint4((quad_vote::vote_t)quad_ballot(value), 0, 0, 0);"); + } + else if (msl_options.is_ios()) + { + // The current simd_vote on iOS uses a 32-bit integer-like object. + statement("return uint4((simd_vote::vote_t)simd_ballot(value), 0, 0, 0);"); + } + else + { + statement("simd_vote vote = simd_ballot(value);"); + statement("// simd_ballot() returns a 64-bit integer-like object, but"); + statement("// SPIR-V callers expect a uint4. We must convert."); + statement("// FIXME: This won't include higher bits if Apple ever supports"); + statement("// 128 lanes in an SIMD-group."); + statement( + "return uint4((uint)((simd_vote::vote_t)vote & 0xFFFFFFFF), (uint)(((simd_vote::vote_t)vote >> " + "32) & 0xFFFFFFFF), 0, 0);"); + } end_scope(); statement(""); break; @@ -4827,8 +5404,15 @@ void CompilerMSL::emit_custom_functions() case SPVFuncImplSubgroupBallotFindLSB: statement("inline uint spvSubgroupBallotFindLSB(uint4 ballot, uint gl_SubgroupSize)"); begin_scope(); - statement("uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupSize, 32u)), " - "extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupSize - 32, 0)), uint2(0));"); + if (msl_options.is_ios()) + { + statement("uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, gl_SubgroupSize), uint3(0));"); + } + else + { + statement("uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupSize, 32u)), " + "extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupSize - 32, 0)), uint2(0));"); + } statement("ballot &= mask;"); statement("return select(ctz(ballot.x), select(32 + ctz(ballot.y), select(64 + ctz(ballot.z), select(96 + " "ctz(ballot.w), uint(-1), ballot.w == 0), ballot.z == 0), ballot.y == 0), ballot.x == 0);"); @@ -4839,8 +5423,15 @@ void CompilerMSL::emit_custom_functions() case SPVFuncImplSubgroupBallotFindMSB: statement("inline uint spvSubgroupBallotFindMSB(uint4 ballot, uint gl_SubgroupSize)"); begin_scope(); - statement("uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupSize, 32u)), " - "extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupSize - 32, 0)), uint2(0));"); + if (msl_options.is_ios()) + { + statement("uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, gl_SubgroupSize), uint3(0));"); + } + else + { + statement("uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupSize, 32u)), " + "extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupSize - 32, 0)), uint2(0));"); + } statement("ballot &= mask;"); statement("return select(128 - (clz(ballot.w) + 1), select(96 - (clz(ballot.z) + 1), select(64 - " "(clz(ballot.y) + 1), select(32 - (clz(ballot.x) + 1), uint(-1), ballot.x == 0), ballot.y == 0), " @@ -4857,23 +5448,44 @@ void CompilerMSL::emit_custom_functions() statement(""); statement("inline uint spvSubgroupBallotBitCount(uint4 ballot, uint gl_SubgroupSize)"); begin_scope(); - statement("uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupSize, 32u)), " - "extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupSize - 32, 0)), uint2(0));"); + if (msl_options.is_ios()) + { + statement("uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, gl_SubgroupSize), uint3(0));"); + } + else + { + statement("uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupSize, 32u)), " + "extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupSize - 32, 0)), uint2(0));"); + } statement("return spvPopCount4(ballot & mask);"); end_scope(); statement(""); statement("inline uint spvSubgroupBallotInclusiveBitCount(uint4 ballot, uint gl_SubgroupInvocationID)"); begin_scope(); - statement("uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID + 1, 32u)), " - "extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID + 1 - 32, 0)), " - "uint2(0));"); + if (msl_options.is_ios()) + { + statement("uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, gl_SubgroupInvocationID + 1), uint3(0));"); + } + else + { + statement("uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID + 1, 32u)), " + "extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID + 1 - 32, 0)), " + "uint2(0));"); + } statement("return spvPopCount4(ballot & mask);"); end_scope(); statement(""); statement("inline uint spvSubgroupBallotExclusiveBitCount(uint4 ballot, uint gl_SubgroupInvocationID)"); begin_scope(); - statement("uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID, 32u)), " - "extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID - 32, 0)), uint2(0));"); + if (msl_options.is_ios()) + { + statement("uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, gl_SubgroupInvocationID), uint2(0));"); + } + else + { + statement("uint4 mask = uint4(extract_bits(0xFFFFFFFF, 0, min(gl_SubgroupInvocationID, 32u)), " + "extract_bits(0xFFFFFFFF, 0, (uint)max((int)gl_SubgroupInvocationID - 32, 0)), uint2(0));"); + } statement("return spvPopCount4(ballot & mask);"); end_scope(); statement(""); @@ -4887,19 +5499,28 @@ void CompilerMSL::emit_custom_functions() statement("template"); statement("inline bool spvSubgroupAllEqual(T value)"); begin_scope(); - statement("return simd_all(all(value == simd_broadcast_first(value)));"); + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) + statement("return quad_all(all(value == quad_broadcast_first(value)));"); + else + statement("return simd_all(all(value == simd_broadcast_first(value)));"); end_scope(); statement(""); statement("template<>"); statement("inline bool spvSubgroupAllEqual(bool value)"); begin_scope(); - statement("return simd_all(value) || !simd_any(value);"); + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) + statement("return quad_all(value) || !quad_any(value);"); + else + statement("return simd_all(value) || !simd_any(value);"); end_scope(); statement(""); statement("template"); statement("inline bool spvSubgroupAllEqual(vec value)"); begin_scope(); - statement("return simd_all(all(value == (vec)simd_broadcast_first((vec)value)));"); + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) + statement("return quad_all(all(value == (vec)quad_broadcast_first((vec)value)));"); + else + statement("return simd_all(all(value == (vec)simd_broadcast_first((vec)value)));"); end_scope(); statement(""); break; @@ -4908,7 +5529,7 @@ void CompilerMSL::emit_custom_functions() statement("template"); statement("inline T spvSubgroupShuffle(T value, ushort lane)"); begin_scope(); - if (msl_options.is_ios()) + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) statement("return quad_shuffle(value, lane);"); else statement("return simd_shuffle(value, lane);"); @@ -4917,7 +5538,7 @@ void CompilerMSL::emit_custom_functions() statement("template<>"); statement("inline bool spvSubgroupShuffle(bool value, ushort lane)"); begin_scope(); - if (msl_options.is_ios()) + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) statement("return !!quad_shuffle((ushort)value, lane);"); else statement("return !!simd_shuffle((ushort)value, lane);"); @@ -4926,7 +5547,7 @@ void CompilerMSL::emit_custom_functions() statement("template"); statement("inline vec spvSubgroupShuffle(vec value, ushort lane)"); begin_scope(); - if (msl_options.is_ios()) + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) statement("return (vec)quad_shuffle((vec)value, lane);"); else statement("return (vec)simd_shuffle((vec)value, lane);"); @@ -4938,7 +5559,7 @@ void CompilerMSL::emit_custom_functions() statement("template"); statement("inline T spvSubgroupShuffleXor(T value, ushort mask)"); begin_scope(); - if (msl_options.is_ios()) + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) statement("return quad_shuffle_xor(value, mask);"); else statement("return simd_shuffle_xor(value, mask);"); @@ -4947,7 +5568,7 @@ void CompilerMSL::emit_custom_functions() statement("template<>"); statement("inline bool spvSubgroupShuffleXor(bool value, ushort mask)"); begin_scope(); - if (msl_options.is_ios()) + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) statement("return !!quad_shuffle_xor((ushort)value, mask);"); else statement("return !!simd_shuffle_xor((ushort)value, mask);"); @@ -4956,7 +5577,7 @@ void CompilerMSL::emit_custom_functions() statement("template"); statement("inline vec spvSubgroupShuffleXor(vec value, ushort mask)"); begin_scope(); - if (msl_options.is_ios()) + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) statement("return (vec)quad_shuffle_xor((vec)value, mask);"); else statement("return (vec)simd_shuffle_xor((vec)value, mask);"); @@ -4968,7 +5589,7 @@ void CompilerMSL::emit_custom_functions() statement("template"); statement("inline T spvSubgroupShuffleUp(T value, ushort delta)"); begin_scope(); - if (msl_options.is_ios()) + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) statement("return quad_shuffle_up(value, delta);"); else statement("return simd_shuffle_up(value, delta);"); @@ -4977,7 +5598,7 @@ void CompilerMSL::emit_custom_functions() statement("template<>"); statement("inline bool spvSubgroupShuffleUp(bool value, ushort delta)"); begin_scope(); - if (msl_options.is_ios()) + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) statement("return !!quad_shuffle_up((ushort)value, delta);"); else statement("return !!simd_shuffle_up((ushort)value, delta);"); @@ -4986,7 +5607,7 @@ void CompilerMSL::emit_custom_functions() statement("template"); statement("inline vec spvSubgroupShuffleUp(vec value, ushort delta)"); begin_scope(); - if (msl_options.is_ios()) + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) statement("return (vec)quad_shuffle_up((vec)value, delta);"); else statement("return (vec)simd_shuffle_up((vec)value, delta);"); @@ -4998,7 +5619,7 @@ void CompilerMSL::emit_custom_functions() statement("template"); statement("inline T spvSubgroupShuffleDown(T value, ushort delta)"); begin_scope(); - if (msl_options.is_ios()) + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) statement("return quad_shuffle_down(value, delta);"); else statement("return simd_shuffle_down(value, delta);"); @@ -5007,7 +5628,7 @@ void CompilerMSL::emit_custom_functions() statement("template<>"); statement("inline bool spvSubgroupShuffleDown(bool value, ushort delta)"); begin_scope(); - if (msl_options.is_ios()) + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) statement("return !!quad_shuffle_down((ushort)value, delta);"); else statement("return !!simd_shuffle_down((ushort)value, delta);"); @@ -5016,7 +5637,7 @@ void CompilerMSL::emit_custom_functions() statement("template"); statement("inline vec spvSubgroupShuffleDown(vec value, ushort delta)"); begin_scope(); - if (msl_options.is_ios()) + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) statement("return (vec)quad_shuffle_down((vec)value, delta);"); else statement("return (vec)simd_shuffle_down((vec)value, delta);"); @@ -5820,6 +6441,30 @@ void CompilerMSL::emit_custom_functions() } } +static string inject_top_level_storage_qualifier(const string &expr, const string &qualifier) +{ + // Easier to do this through text munging since the qualifier does not exist in the type system at all, + // and plumbing in all that information is not very helpful. + size_t last_reference = expr.find_last_of('&'); + size_t last_pointer = expr.find_last_of('*'); + size_t last_significant = string::npos; + + if (last_reference == string::npos) + last_significant = last_pointer; + else if (last_pointer == string::npos) + last_significant = last_reference; + else + last_significant = std::max(last_reference, last_pointer); + + if (last_significant == string::npos) + return join(qualifier, " ", expr); + else + { + return join(expr.substr(0, last_significant + 1), " ", + qualifier, expr.substr(last_significant + 1, string::npos)); + } +} + // Undefined global memory is not allowed in MSL. // Declare constant and init to zeros. Use {}, as global constructors can break Metal. void CompilerMSL::declare_undefined_values() @@ -5831,7 +6476,10 @@ void CompilerMSL::declare_undefined_values() if (type.basetype == SPIRType::Void) return; - statement("constant ", variable_decl(type, to_name(undef.self), undef.self), " = {};"); + statement(inject_top_level_storage_qualifier( + variable_decl(type, to_name(undef.self), undef.self), + "constant"), + " = {};"); emitted = true; }); @@ -5859,7 +6507,8 @@ void CompilerMSL::declare_constant_arrays() if (!type.array.empty() && (!fully_inlined || is_scalar(type) || is_vector(type))) { auto name = to_name(c.self); - statement("constant ", variable_decl(type, name), " = ", constant_expression(c), ";"); + statement(inject_top_level_storage_qualifier(variable_decl(type, name), "constant"), + " = ", constant_expression(c), ";"); emitted = true; } }); @@ -5931,6 +6580,15 @@ void CompilerMSL::emit_specialization_constants_and_structs() mark_scalar_layout_structs(type); }); + bool builtin_block_type_is_required = false; + // Very special case. If gl_PerVertex is initialized as an array (tessellation) + // we have to potentially emit the gl_PerVertex struct type so that we can emit a constant LUT. + ir.for_each_typed_id([&](uint32_t, SPIRConstant &c) { + auto &type = this->get(c.constant_type); + if (is_array(type) && has_decoration(type.self, DecorationBlock) && is_builtin_type(type)) + builtin_block_type_is_required = true; + }); + // Very particular use of the soft loop lock. // align_struct may need to create custom types on the fly, but we don't care about // these types for purpose of iterating over them in ir.ids_for_type and friends. @@ -6015,7 +6673,7 @@ void CompilerMSL::emit_specialization_constants_and_structs() has_decoration(type.self, DecorationBlock) || has_decoration(type.self, DecorationBufferBlock); bool is_builtin_block = is_block && is_builtin_type(type); - bool is_declarable_struct = is_struct && !is_builtin_block; + bool is_declarable_struct = is_struct && (!is_builtin_block || builtin_block_type_is_required); // We'll declare this later. if (stage_out_var_id && get_stage_out_struct_type().self == type_id) @@ -6027,6 +6685,10 @@ void CompilerMSL::emit_specialization_constants_and_structs() if (patch_stage_in_var_id && get_patch_stage_in_struct_type().self == type_id) is_declarable_struct = false; + // Special case. Declare builtin struct anyways if we need to emit a threadgroup version of it. + if (stage_out_masked_builtin_type_id == type_id) + is_declarable_struct = true; + // Align and emit declarable structs...but avoid declaring each more than once. if (is_declarable_struct && declared_structs.count(type_id) == 0) { @@ -6072,16 +6734,22 @@ bool CompilerMSL::emit_tessellation_io_load(uint32_t result_type_id, uint32_t id if (ptr_type.storage == StorageClassOutput && get_execution_model() == ExecutionModelTessellationEvaluation) return false; - bool multi_patch_tess_ctl = get_execution_model() == ExecutionModelTessellationControl && - msl_options.multi_patch_workgroup && ptr_type.storage == StorageClassInput; - bool flat_matrix = is_matrix(result_type) && ptr_type.storage == StorageClassInput && !multi_patch_tess_ctl; - bool flat_struct = result_type.basetype == SPIRType::Struct && ptr_type.storage == StorageClassInput; - bool flat_data_type = flat_matrix || is_array(result_type) || flat_struct; - if (!flat_data_type) - return false; - if (has_decoration(ptr, DecorationPatch)) return false; + bool ptr_is_io_variable = ir.ids[ptr].get_type() == TypeVariable; + + bool flattened_io = variable_storage_requires_stage_io(ptr_type.storage); + + bool flat_data_type = flattened_io && + (is_matrix(result_type) || is_array(result_type) || result_type.basetype == SPIRType::Struct); + + // Edge case, even with multi-patch workgroups, we still need to unroll load + // if we're loading control points directly. + if (ptr_is_io_variable && is_array(result_type)) + flat_data_type = true; + + if (!flat_data_type) + return false; // Now, we must unflatten a composite type and take care of interleaving array access with gl_in/gl_out. // Lots of painful code duplication since we *really* should not unroll these kinds of loads in entry point fixup @@ -6090,12 +6758,31 @@ bool CompilerMSL::emit_tessellation_io_load(uint32_t result_type_id, uint32_t id uint32_t interface_index = get_extended_decoration(ptr, SPIRVCrossDecorationInterfaceMemberIndex); auto *var = maybe_get_backing_variable(ptr); - bool ptr_is_io_variable = ir.ids[ptr].get_type() == TypeVariable; auto &expr_type = get_pointee_type(ptr_type.self); const auto &iface_type = expression_type(stage_in_ptr_var_id); - if (result_type.array.size() > 2) + if (!flattened_io) + { + // Simplest case for multi-patch workgroups, just unroll array as-is. + if (interface_index == uint32_t(-1)) + return false; + + expr += type_to_glsl(result_type) + "({ "; + uint32_t num_control_points = to_array_size_literal(result_type, uint32_t(result_type.array.size()) - 1); + + for (uint32_t i = 0; i < num_control_points; i++) + { + const uint32_t indices[2] = { i, interface_index }; + AccessChainMeta meta; + expr += access_chain_internal(stage_in_ptr_var_id, indices, 2, + ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_PTR_CHAIN_BIT, &meta); + if (i + 1 < num_control_points) + expr += ", "; + } + expr += " })"; + } + else if (result_type.array.size() > 2) { SPIRV_CROSS_THROW("Cannot load tessellation IO variables with more than 2 dimensions."); } @@ -6105,7 +6792,7 @@ bool CompilerMSL::emit_tessellation_io_load(uint32_t result_type_id, uint32_t id SPIRV_CROSS_THROW("Loading an array-of-array must be loaded directly from an IO variable."); if (interface_index == uint32_t(-1)) SPIRV_CROSS_THROW("Interface index is unknown. Cannot continue."); - if (result_type.basetype == SPIRType::Struct || flat_matrix) + if (result_type.basetype == SPIRType::Struct || is_matrix(result_type)) SPIRV_CROSS_THROW("Cannot load array-of-array of composite type in tessellation IO."); expr += type_to_glsl(result_type) + "({ "; @@ -6119,44 +6806,19 @@ bool CompilerMSL::emit_tessellation_io_load(uint32_t result_type_id, uint32_t id expr += type_to_glsl(sub_type) + "({ "; interface_index = base_interface_index; uint32_t array_size = to_array_size_literal(result_type, 0); - if (multi_patch_tess_ctl) + for (uint32_t j = 0; j < array_size; j++, interface_index++) { - for (uint32_t j = 0; j < array_size; j++) - { - const uint32_t indices[3] = { i, interface_index, j }; + const uint32_t indices[2] = { i, interface_index }; - AccessChainMeta meta; - expr += - access_chain_internal(stage_in_ptr_var_id, indices, 3, - ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_PTR_CHAIN_BIT, &meta); - // If the expression has more vector components than the result type, insert - // a swizzle. This shouldn't happen normally on valid SPIR-V, but it might - // happen if we replace the type of an input variable. - if (!is_matrix(sub_type) && sub_type.basetype != SPIRType::Struct && - expr_type.vecsize > sub_type.vecsize) - expr += vector_swizzle(sub_type.vecsize, 0); + AccessChainMeta meta; + expr += access_chain_internal(stage_in_ptr_var_id, indices, 2, + ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_PTR_CHAIN_BIT, &meta); + if (!is_matrix(sub_type) && sub_type.basetype != SPIRType::Struct && + expr_type.vecsize > sub_type.vecsize) + expr += vector_swizzle(sub_type.vecsize, 0); - if (j + 1 < array_size) - expr += ", "; - } - } - else - { - for (uint32_t j = 0; j < array_size; j++, interface_index++) - { - const uint32_t indices[2] = { i, interface_index }; - - AccessChainMeta meta; - expr += - access_chain_internal(stage_in_ptr_var_id, indices, 2, - ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_PTR_CHAIN_BIT, &meta); - if (!is_matrix(sub_type) && sub_type.basetype != SPIRType::Struct && - expr_type.vecsize > sub_type.vecsize) - expr += vector_swizzle(sub_type.vecsize, 0); - - if (j + 1 < array_size) - expr += ", "; - } + if (j + 1 < array_size) + expr += ", "; } expr += " })"; if (i + 1 < num_control_points) @@ -6164,7 +6826,7 @@ bool CompilerMSL::emit_tessellation_io_load(uint32_t result_type_id, uint32_t id } expr += " })"; } - else if (flat_struct) + else if (result_type.basetype == SPIRType::Struct) { bool is_array_of_struct = is_array(result_type); if (is_array_of_struct && !ptr_is_io_variable) @@ -6197,7 +6859,7 @@ bool CompilerMSL::emit_tessellation_io_load(uint32_t result_type_id, uint32_t id const auto &mbr_type = get(struct_type.member_types[j]); const auto &expr_mbr_type = get(expr_type.member_types[j]); - if (is_matrix(mbr_type) && ptr_type.storage == StorageClassInput && !multi_patch_tess_ctl) + if (is_matrix(mbr_type) && ptr_type.storage == StorageClassInput) { expr += type_to_glsl(mbr_type) + "("; for (uint32_t k = 0; k < mbr_type.columns; k++, interface_index++) @@ -6207,8 +6869,8 @@ bool CompilerMSL::emit_tessellation_io_load(uint32_t result_type_id, uint32_t id const uint32_t indices[2] = { i, interface_index }; AccessChainMeta meta; expr += access_chain_internal( - stage_in_ptr_var_id, indices, 2, - ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_PTR_CHAIN_BIT, &meta); + stage_in_ptr_var_id, indices, 2, + ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_PTR_CHAIN_BIT, &meta); } else expr += to_expression(ptr) + "." + to_member_name(iface_type, interface_index); @@ -6224,48 +6886,23 @@ bool CompilerMSL::emit_tessellation_io_load(uint32_t result_type_id, uint32_t id { expr += type_to_glsl(mbr_type) + "({ "; uint32_t array_size = to_array_size_literal(mbr_type, 0); - if (multi_patch_tess_ctl) + for (uint32_t k = 0; k < array_size; k++, interface_index++) { - for (uint32_t k = 0; k < array_size; k++) + if (is_array_of_struct) { - if (is_array_of_struct) - { - const uint32_t indices[3] = { i, interface_index, k }; - AccessChainMeta meta; - expr += access_chain_internal( - stage_in_ptr_var_id, indices, 3, - ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_PTR_CHAIN_BIT, &meta); - } - else - expr += join(to_expression(ptr), ".", to_member_name(iface_type, interface_index), "[", - k, "]"); - if (expr_mbr_type.vecsize > mbr_type.vecsize) - expr += vector_swizzle(mbr_type.vecsize, 0); - - if (k + 1 < array_size) - expr += ", "; + const uint32_t indices[2] = { i, interface_index }; + AccessChainMeta meta; + expr += access_chain_internal( + stage_in_ptr_var_id, indices, 2, + ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_PTR_CHAIN_BIT, &meta); } - } - else - { - for (uint32_t k = 0; k < array_size; k++, interface_index++) - { - if (is_array_of_struct) - { - const uint32_t indices[2] = { i, interface_index }; - AccessChainMeta meta; - expr += access_chain_internal( - stage_in_ptr_var_id, indices, 2, - ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_PTR_CHAIN_BIT, &meta); - } - else - expr += to_expression(ptr) + "." + to_member_name(iface_type, interface_index); - if (expr_mbr_type.vecsize > mbr_type.vecsize) - expr += vector_swizzle(mbr_type.vecsize, 0); + else + expr += to_expression(ptr) + "." + to_member_name(iface_type, interface_index); + if (expr_mbr_type.vecsize > mbr_type.vecsize) + expr += vector_swizzle(mbr_type.vecsize, 0); - if (k + 1 < array_size) - expr += ", "; - } + if (k + 1 < array_size) + expr += ", "; } expr += " })"; } @@ -6295,7 +6932,7 @@ bool CompilerMSL::emit_tessellation_io_load(uint32_t result_type_id, uint32_t id if (is_array_of_struct) expr += " })"; } - else if (flat_matrix) + else if (is_matrix(result_type)) { bool is_array_of_matrix = is_array(result_type); if (is_array_of_matrix && !ptr_is_io_variable) @@ -6321,9 +6958,8 @@ bool CompilerMSL::emit_tessellation_io_load(uint32_t result_type_id, uint32_t id const uint32_t indices[2] = { i, interface_index }; AccessChainMeta meta; - expr += - access_chain_internal(stage_in_ptr_var_id, indices, 2, - ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_PTR_CHAIN_BIT, &meta); + expr += access_chain_internal(stage_in_ptr_var_id, indices, 2, + ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_PTR_CHAIN_BIT, &meta); if (expr_type.vecsize > result_type.vecsize) expr += vector_swizzle(result_type.vecsize, 0); if (j + 1 < result_type.columns) @@ -6414,48 +7050,112 @@ bool CompilerMSL::emit_tessellation_access_chain(const uint32_t *ops, uint32_t l bool patch = false; bool flat_data = false; bool ptr_is_chain = false; - bool multi_patch = get_execution_model() == ExecutionModelTessellationControl && msl_options.multi_patch_workgroup; + bool flatten_composites = false; + + bool is_block = false; + + if (var) + is_block = has_decoration(get_variable_data_type(*var).self, DecorationBlock); if (var) { + flatten_composites = variable_storage_requires_stage_io(var->storage); patch = has_decoration(ops[2], DecorationPatch) || is_patch_block(get_variable_data_type(*var)); // Should match strip_array in add_interface_block. flat_data = var->storage == StorageClassInput || (var->storage == StorageClassOutput && get_execution_model() == ExecutionModelTessellationControl); + // Patch inputs are treated as normal block IO variables, so they don't deal with this path at all. + if (patch && (!is_block || var->storage == StorageClassInput)) + flat_data = false; + // We might have a chained access chain, where // we first take the access chain to the control point, and then we chain into a member or something similar. // In this case, we need to skip gl_in/gl_out remapping. + // Also, skip ptr chain for patches. ptr_is_chain = var->self != ID(ops[2]); } - BuiltIn bi_type = BuiltIn(get_decoration(ops[2], DecorationBuiltIn)); - if (var && flat_data && !patch && - (!is_builtin_variable(*var) || bi_type == BuiltInPosition || bi_type == BuiltInPointSize || - bi_type == BuiltInClipDistance || bi_type == BuiltInCullDistance || - get_variable_data_type(*var).basetype == SPIRType::Struct)) + bool builtin_variable = false; + bool variable_is_flat = false; + + if (var && flat_data) { + builtin_variable = is_builtin_variable(*var); + + BuiltIn bi_type = BuiltInMax; + if (builtin_variable && !is_block) + bi_type = BuiltIn(get_decoration(var->self, DecorationBuiltIn)); + + variable_is_flat = !builtin_variable || is_block || + bi_type == BuiltInPosition || bi_type == BuiltInPointSize || + bi_type == BuiltInClipDistance || bi_type == BuiltInCullDistance; + } + + if (variable_is_flat) + { + // If output is masked, it is emitted as a "normal" variable, just go through normal code paths. + // Only check this for the first level of access chain. + // Dealing with this for partial access chains should be possible, but awkward. + if (var->storage == StorageClassOutput && !ptr_is_chain) + { + bool masked = false; + if (is_block) + { + uint32_t relevant_member_index = patch ? 3 : 4; + // FIXME: This won't work properly if the application first access chains into gl_out element, + // then access chains into the member. Super weird, but theoretically possible ... + if (length > relevant_member_index) + { + uint32_t mbr_idx = get(ops[relevant_member_index]).scalar(); + masked = is_stage_output_block_member_masked(*var, mbr_idx, true); + } + } + else if (var) + masked = is_stage_output_variable_masked(*var); + + if (masked) + return false; + } + AccessChainMeta meta; SmallVector indices; uint32_t next_id = ir.increase_bound_by(1); indices.reserve(length - 3 + 1); - uint32_t first_non_array_index = ptr_is_chain ? 3 : 4; - VariableID stage_var_id = var->storage == StorageClassInput ? stage_in_ptr_var_id : stage_out_ptr_var_id; + uint32_t first_non_array_index = (ptr_is_chain ? 3 : 4) - (patch ? 1 : 0); + + VariableID stage_var_id; + if (patch) + stage_var_id = var->storage == StorageClassInput ? patch_stage_in_var_id : patch_stage_out_var_id; + else + stage_var_id = var->storage == StorageClassInput ? stage_in_ptr_var_id : stage_out_ptr_var_id; + VariableID ptr = ptr_is_chain ? VariableID(ops[2]) : stage_var_id; - if (!ptr_is_chain) + if (!ptr_is_chain && !patch) { // Index into gl_in/gl_out with first array index. - indices.push_back(ops[3]); + indices.push_back(ops[first_non_array_index - 1]); } auto &result_ptr_type = get(ops[0]); uint32_t const_mbr_id = next_id++; - uint32_t index = get_extended_decoration(var->self, SPIRVCrossDecorationInterfaceMemberIndex); - if (var->storage == StorageClassInput || has_decoration(get_variable_element_type(*var).self, DecorationBlock)) + uint32_t index = get_extended_decoration(ops[2], SPIRVCrossDecorationInterfaceMemberIndex); + + // If we have a pointer chain expression, and we are no longer pointing to a composite + // object, we are in the clear. There is no longer a need to flatten anything. + bool further_access_chain_is_trivial = false; + if (ptr_is_chain && flatten_composites) + { + auto &ptr_type = expression_type(ptr); + if (!is_array(ptr_type) && !is_matrix(ptr_type) && ptr_type.basetype != SPIRType::Struct) + further_access_chain_is_trivial = true; + } + + if (!further_access_chain_is_trivial && (flatten_composites || is_block)) { uint32_t i = first_non_array_index; auto *type = &get_variable_element_type(*var); @@ -6463,19 +7163,20 @@ bool CompilerMSL::emit_tessellation_access_chain(const uint32_t *ops, uint32_t l { // Maybe this is a struct type in the input class, in which case // we put it as a decoration on the corresponding member. - index = get_extended_member_decoration(var->self, get_constant(ops[first_non_array_index]).scalar(), + uint32_t mbr_idx = get_constant(ops[first_non_array_index]).scalar(); + index = get_extended_member_decoration(var->self, mbr_idx, SPIRVCrossDecorationInterfaceMemberIndex); assert(index != uint32_t(-1)); i++; - type = &get(type->member_types[get_constant(ops[first_non_array_index]).scalar()]); + type = &get(type->member_types[mbr_idx]); } // In this case, we're poking into flattened structures and arrays, so now we have to // combine the following indices. If we encounter a non-constant index, // we're hosed. - for (; i < length; ++i) + for (; flatten_composites && i < length; ++i) { - if ((multi_patch || (!is_array(*type) && !is_matrix(*type))) && type->basetype != SPIRType::Struct) + if (!is_array(*type) && !is_matrix(*type) && type->basetype != SPIRType::Struct) break; auto *c = maybe_get(ops[i]); @@ -6486,7 +7187,16 @@ bool CompilerMSL::emit_tessellation_access_chain(const uint32_t *ops, uint32_t l // We're in flattened space, so just increment the member index into IO block. // We can only do this once in the current implementation, so either: // Struct, Matrix or 1-dimensional array for a control point. - index += c->scalar(); + if (type->basetype == SPIRType::Struct && var->storage == StorageClassOutput) + { + // Need to consider holes, since individual block members might be masked away. + uint32_t mbr_idx = c->scalar(); + for (uint32_t j = 0; j < mbr_idx; j++) + if (!is_stage_output_block_member_masked(*var, j, true)) + index++; + } + else + index += c->scalar(); if (type->parent_type) type = &get(type->parent_type); @@ -6494,31 +7204,48 @@ bool CompilerMSL::emit_tessellation_access_chain(const uint32_t *ops, uint32_t l type = &get(type->member_types[c->scalar()]); } - if ((!multi_patch && (is_matrix(result_ptr_type) || is_array(result_ptr_type))) || - result_ptr_type.basetype == SPIRType::Struct) - { - // We're not going to emit the actual member name, we let any further OpLoad take care of that. - // Tag the access chain with the member index we're referencing. - set_extended_decoration(ops[1], SPIRVCrossDecorationInterfaceMemberIndex, index); - } - else + // We're not going to emit the actual member name, we let any further OpLoad take care of that. + // Tag the access chain with the member index we're referencing. + bool defer_access_chain = flatten_composites && (is_matrix(result_ptr_type) || is_array(result_ptr_type) || + result_ptr_type.basetype == SPIRType::Struct); + + if (!defer_access_chain) { // Access the appropriate member of gl_in/gl_out. set(const_mbr_id, get_uint_type_id(), index, false); indices.push_back(const_mbr_id); + // Member index is now irrelevant. + index = uint32_t(-1); + // Append any straggling access chain indices. if (i < length) indices.insert(indices.end(), ops + i, ops + length); } + else + { + // We must have consumed the entire access chain if we're deferring it. + assert(i == length); + } + + if (index != uint32_t(-1)) + set_extended_decoration(ops[1], SPIRVCrossDecorationInterfaceMemberIndex, index); + else + unset_extended_decoration(ops[1], SPIRVCrossDecorationInterfaceMemberIndex); } else { - assert(index != uint32_t(-1)); - set(const_mbr_id, get_uint_type_id(), index, false); - indices.push_back(const_mbr_id); + if (index != uint32_t(-1)) + { + set(const_mbr_id, get_uint_type_id(), index, false); + indices.push_back(const_mbr_id); + } - indices.insert(indices.end(), ops + 4, ops + length); + // Member index is now irrelevant. + index = uint32_t(-1); + unset_extended_decoration(ops[1], SPIRVCrossDecorationInterfaceMemberIndex); + + indices.insert(indices.end(), ops + first_non_array_index, ops + length); } // We use the pointer to the base of the input/output array here, @@ -6528,7 +7255,7 @@ bool CompilerMSL::emit_tessellation_access_chain(const uint32_t *ops, uint32_t l if (!ptr_is_chain) { // This is the start of an access chain, use ptr_chain to index into control point array. - e = access_chain(ptr, indices.data(), uint32_t(indices.size()), result_ptr_type, &meta, true); + e = access_chain(ptr, indices.data(), uint32_t(indices.size()), result_ptr_type, &meta, !patch); } else { @@ -6544,7 +7271,11 @@ bool CompilerMSL::emit_tessellation_access_chain(const uint32_t *ops, uint32_t l // First one is the gl_in/gl_out struct itself, then an index into that array. // If we have traversed further, we use a normal access chain formulation. auto *ptr_expr = maybe_get(ptr); - if (ptr_expr && ptr_expr->implied_read_expressions.size() == 2) + bool split_access_chain_formulation = flatten_composites && ptr_expr && + ptr_expr->implied_read_expressions.size() == 2 && + !further_access_chain_is_trivial; + + if (split_access_chain_formulation) { e = join(to_expression(ptr), access_chain_internal(stage_var_id, indices.data(), uint32_t(indices.size()), @@ -6677,6 +7408,21 @@ void CompilerMSL::prepare_access_chain_for_scalar_access(std::string &expr, cons } } +bool CompilerMSL::access_chain_needs_stage_io_builtin_translation(uint32_t base) +{ + auto *var = maybe_get_backing_variable(base); + if (!var || !is_tessellation_shader()) + return true; + + // We only need to rewrite builtin access chains when accessing flattened builtins like gl_ClipDistance_N. + // Avoid overriding it back to just gl_ClipDistance. + // This can only happen in scenarios where we cannot flatten/unflatten access chains, so, the only case + // where this triggers is evaluation shader inputs. + bool redirect_builtin = get_execution_model() == ExecutionModelTessellationEvaluation ? + var->storage == StorageClassOutput : false; + return redirect_builtin; +} + // Sets the interface member index for an access chain to a pull-model interpolant. void CompilerMSL::fix_up_interpolant_access_chain(const uint32_t *ops, uint32_t length) { @@ -6927,19 +7673,26 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) break; case OpFMul: - if (msl_options.invariant_float_math) + if (msl_options.invariant_float_math || has_decoration(ops[1], DecorationNoContraction)) MSL_BFOP(spvFMul); else MSL_BOP(*); break; case OpFAdd: - if (msl_options.invariant_float_math) + if (msl_options.invariant_float_math || has_decoration(ops[1], DecorationNoContraction)) MSL_BFOP(spvFAdd); else MSL_BOP(+); break; + case OpFSub: + if (msl_options.invariant_float_math || has_decoration(ops[1], DecorationNoContraction)) + MSL_BFOP(spvFSub); + else + MSL_BOP(-); + break; + // Atomics case OpAtomicExchange: { @@ -7381,7 +8134,7 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) case OpVectorTimesMatrix: case OpMatrixTimesVector: { - if (!msl_options.invariant_float_math) + if (!msl_options.invariant_float_math && !has_decoration(ops[1], DecorationNoContraction)) { CompilerGLSL::emit_instruction(instruction); break; @@ -7423,7 +8176,7 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) case OpMatrixTimesMatrix: { - if (!msl_options.invariant_float_math) + if (!msl_options.invariant_float_math && !has_decoration(ops[1], DecorationNoContraction)) { CompilerGLSL::emit_instruction(instruction); break; @@ -7645,6 +8398,10 @@ void CompilerMSL::emit_barrier(uint32_t id_exe_scope, uint32_t id_mem_scope, uin // Use the wider of the two scopes (smaller value) exe_scope = min(exe_scope, mem_scope); + if (msl_options.emulate_subgroups && exe_scope >= ScopeSubgroup && !id_mem_sem) + // In this case, we assume a "subgroup" size of 1. The barrier, then, is a noop. + return; + string bar_stmt; if ((msl_options.is_ios() && msl_options.supports_msl_version(1, 2)) || msl_options.supports_msl_version(2)) bar_stmt = exe_scope < ScopeSubgroup ? "threadgroup_barrier" : "simdgroup_barrier"; @@ -7708,19 +8465,46 @@ void CompilerMSL::emit_barrier(uint32_t id_exe_scope, uint32_t id_mem_scope, uin flush_all_active_variables(); } -void CompilerMSL::emit_array_copy(const string &lhs, uint32_t rhs_id, StorageClass lhs_storage, - StorageClass rhs_storage) +static bool storage_class_array_is_thread(StorageClass storage) +{ + switch (storage) + { + case StorageClassInput: + case StorageClassOutput: + case StorageClassGeneric: + case StorageClassFunction: + case StorageClassPrivate: + return true; + + default: + return false; + } +} + +void CompilerMSL::emit_array_copy(const string &lhs, uint32_t lhs_id, uint32_t rhs_id, + StorageClass lhs_storage, StorageClass rhs_storage) { // Allow Metal to use the array template to make arrays a value type. // This, however, cannot be used for threadgroup address specifiers, so consider the custom array copy as fallback. - bool lhs_thread = (lhs_storage == StorageClassOutput || lhs_storage == StorageClassFunction || - lhs_storage == StorageClassGeneric || lhs_storage == StorageClassPrivate); - bool rhs_thread = (rhs_storage == StorageClassInput || rhs_storage == StorageClassFunction || - rhs_storage == StorageClassGeneric || rhs_storage == StorageClassPrivate); + bool lhs_is_thread_storage = storage_class_array_is_thread(lhs_storage); + bool rhs_is_thread_storage = storage_class_array_is_thread(rhs_storage); + + bool lhs_is_array_template = lhs_is_thread_storage; + bool rhs_is_array_template = rhs_is_thread_storage; + + // Special considerations for stage IO variables. + // If the variable is actually backed by non-user visible device storage, we use array templates for those. + auto *lhs_var = maybe_get_backing_variable(lhs_id); + if (lhs_var && lhs_storage == StorageClassStorageBuffer && storage_class_array_is_thread(lhs_var->storage)) + lhs_is_array_template = true; + + auto *rhs_var = maybe_get_backing_variable(rhs_id); + if (rhs_var && rhs_storage == StorageClassStorageBuffer && storage_class_array_is_thread(rhs_var->storage)) + rhs_is_array_template = true; // If threadgroup storage qualifiers are *not* used: // Avoid spvCopy* wrapper functions; Otherwise, spvUnsafeArray<> template cannot be used with that storage qualifier. - if (lhs_thread && rhs_thread && !using_builtin_array()) + if (lhs_is_array_template && rhs_is_array_template && !using_builtin_array()) { statement(lhs, " = ", to_expression(rhs_id), ";"); } @@ -7762,15 +8546,15 @@ void CompilerMSL::emit_array_copy(const string &lhs, uint32_t rhs_id, StorageCla add_spv_func_and_recompile(SPVFuncImplArrayCopy); const char *tag = nullptr; - if (lhs_thread && is_constant) + if (lhs_is_thread_storage && is_constant) tag = "FromConstantToStack"; else if (lhs_storage == StorageClassWorkgroup && is_constant) tag = "FromConstantToThreadGroup"; - else if (lhs_thread && rhs_thread) + else if (lhs_is_thread_storage && rhs_is_thread_storage) tag = "FromStackToStack"; - else if (lhs_storage == StorageClassWorkgroup && rhs_thread) + else if (lhs_storage == StorageClassWorkgroup && rhs_is_thread_storage) tag = "FromStackToThreadGroup"; - else if (lhs_thread && rhs_storage == StorageClassWorkgroup) + else if (lhs_is_thread_storage && rhs_storage == StorageClassWorkgroup) tag = "FromThreadGroupToStack"; else if (lhs_storage == StorageClassWorkgroup && rhs_storage == StorageClassWorkgroup) tag = "FromThreadGroupToThreadGroup"; @@ -7780,25 +8564,35 @@ void CompilerMSL::emit_array_copy(const string &lhs, uint32_t rhs_id, StorageCla tag = "FromConstantToDevice"; else if (lhs_storage == StorageClassStorageBuffer && rhs_storage == StorageClassWorkgroup) tag = "FromThreadGroupToDevice"; - else if (lhs_storage == StorageClassStorageBuffer && rhs_thread) + else if (lhs_storage == StorageClassStorageBuffer && rhs_is_thread_storage) tag = "FromStackToDevice"; else if (lhs_storage == StorageClassWorkgroup && rhs_storage == StorageClassStorageBuffer) tag = "FromDeviceToThreadGroup"; - else if (lhs_thread && rhs_storage == StorageClassStorageBuffer) + else if (lhs_is_thread_storage && rhs_storage == StorageClassStorageBuffer) tag = "FromDeviceToStack"; else SPIRV_CROSS_THROW("Unknown storage class used for copying arrays."); // Pass internal array of spvUnsafeArray<> into wrapper functions - if (lhs_thread && !msl_options.force_native_arrays) + if (lhs_is_array_template && rhs_is_array_template && !msl_options.force_native_arrays) + statement("spvArrayCopy", tag, type.array.size(), "(", lhs, ".elements, ", to_expression(rhs_id), ".elements);"); + if (lhs_is_array_template && !msl_options.force_native_arrays) statement("spvArrayCopy", tag, type.array.size(), "(", lhs, ".elements, ", to_expression(rhs_id), ");"); - else if (rhs_thread && !msl_options.force_native_arrays) + else if (rhs_is_array_template && !msl_options.force_native_arrays) statement("spvArrayCopy", tag, type.array.size(), "(", lhs, ", ", to_expression(rhs_id), ".elements);"); else statement("spvArrayCopy", tag, type.array.size(), "(", lhs, ", ", to_expression(rhs_id), ");"); } } +uint32_t CompilerMSL::get_physical_tess_level_array_size(spv::BuiltIn builtin) const +{ + if (get_execution_mode_bitset().get(ExecutionModeTriangles)) + return builtin == BuiltInTessLevelInner ? 1 : 3; + else + return builtin == BuiltInTessLevelInner ? 2 : 4; +} + // Since MSL does not allow arrays to be copied via simple variable assignment, // if the LHS and RHS represent an assignment of an entire array, it must be // implemented by calling an array copy function. @@ -7827,13 +8621,33 @@ bool CompilerMSL::maybe_emit_array_assignment(uint32_t id_lhs, uint32_t id_rhs) return true; } + if (get_execution_model() == ExecutionModelTessellationControl && + has_decoration(id_lhs, DecorationBuiltIn)) + { + auto builtin = BuiltIn(get_decoration(id_lhs, DecorationBuiltIn)); + // Need to manually unroll the array store. + if (builtin == BuiltInTessLevelInner || builtin == BuiltInTessLevelOuter) + { + uint32_t array_size = get_physical_tess_level_array_size(builtin); + if (array_size == 1) + statement(to_expression(id_lhs), " = half(", to_expression(id_rhs), "[0]);"); + else + { + for (uint32_t i = 0; i < array_size; i++) + statement(to_expression(id_lhs), "[", i, "] = half(", to_expression(id_rhs), "[", i, "]);"); + } + return true; + } + } + // Ensure the LHS variable has been declared auto *p_v_lhs = maybe_get_backing_variable(id_lhs); if (p_v_lhs) flush_variable_declaration(p_v_lhs->self); - emit_array_copy(to_expression(id_lhs), id_rhs, get_expression_effective_storage_class(id_lhs), - get_expression_effective_storage_class(id_rhs)); + auto lhs_storage = get_expression_effective_storage_class(id_lhs); + auto rhs_storage = get_expression_effective_storage_class(id_rhs); + emit_array_copy(to_expression(id_lhs), id_lhs, id_rhs, lhs_storage, rhs_storage); register_write(id_lhs); return true; @@ -8285,7 +9099,8 @@ void CompilerMSL::emit_interface_block(uint32_t ib_var_id) { auto &ib_var = get(ib_var_id); auto &ib_type = get_variable_data_type(ib_var); - assert(ib_type.basetype == SPIRType::Struct && !ib_type.member_types.empty()); + //assert(ib_type.basetype == SPIRType::Struct && !ib_type.member_types.empty()); + assert(ib_type.basetype == SPIRType::Struct); emit_struct(ib_type); } } @@ -8327,7 +9142,7 @@ void CompilerMSL::emit_function_prototype(SPIRFunction &func, const Bitset &) // Fake arrays returns by writing to an out array instead. decl += "thread "; decl += type_to_glsl(type); - decl += " (&SPIRV_Cross_return_value)"; + decl += " (&spvReturnValue)"; decl += type_to_array_glsl(type); if (!func.arguments.empty()) decl += ", "; @@ -8979,13 +9794,8 @@ string CompilerMSL::to_function_args(const TextureFunctionArguments &args, bool if (args.min_lod) { - if (msl_options.is_macos()) - { - if (!msl_options.supports_msl_version(2, 2)) - SPIRV_CROSS_THROW("min_lod_clamp() is only supported in MSL 2.2+ and up on macOS."); - } - else if (msl_options.is_ios()) - SPIRV_CROSS_THROW("min_lod_clamp() is not supported on iOS."); + if (!msl_options.supports_msl_version(2, 2)) + SPIRV_CROSS_THROW("min_lod_clamp() is only supported in MSL 2.2+ and up."); forward = forward && should_forward(args.min_lod); farg_str += ", min_lod_clamp(" + to_expression(args.min_lod) + ")"; @@ -9679,7 +10489,16 @@ string CompilerMSL::to_struct_member(const SPIRType &type, uint32_t member_type_ physical_type.basetype != SPIRType::SampledImage) { BuiltIn builtin = BuiltInMax; - if (is_member_builtin(type, index, &builtin)) + + // Special handling. In [[stage_out]] or [[stage_in]] blocks, + // we need flat arrays, but if we're somehow declaring gl_PerVertex for constant array reasons, we want + // template array types to be declared. + bool is_ib_in_out = + ((stage_out_var_id && get_stage_out_struct_type().self == type.self && + variable_storage_requires_stage_io(StorageClassOutput)) || + (stage_in_var_id && get_stage_in_struct_type().self == type.self && + variable_storage_requires_stage_io(StorageClassInput))); + if (is_ib_in_out && is_member_builtin(type, index, &builtin)) is_using_builtin_array = true; array_type = type_to_array_glsl(physical_type); } @@ -9764,7 +10583,13 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in return ""; } } - uint32_t locn = get_ordered_member_location(type.self, index); + + uint32_t locn; + if (is_builtin) + locn = get_or_allocate_builtin_input_member_location(builtin, type.self, index); + else + locn = get_member_location(type.self, index); + if (locn != k_unknown_location) return string(" [[attribute(") + convert_to_string(locn) + ")]]"; } @@ -9794,8 +10619,14 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in return string(" [[") + builtin_qualifier(builtin) + "]]" + (mbr_type.array.empty() ? "" : " "); case BuiltInClipDistance: - if (has_member_decoration(type.self, index, DecorationLocation)) - return join(" [[user(clip", get_member_decoration(type.self, index, DecorationLocation), ")]]"); + if (has_member_decoration(type.self, index, DecorationIndex)) + return join(" [[user(clip", get_member_decoration(type.self, index, DecorationIndex), ")]]"); + else + return string(" [[") + builtin_qualifier(builtin) + "]]" + (mbr_type.array.empty() ? "" : " "); + + case BuiltInCullDistance: + if (has_member_decoration(type.self, index, DecorationIndex)) + return join(" [[user(cull", get_member_decoration(type.self, index, DecorationIndex), ")]]"); else return string(" [[") + builtin_qualifier(builtin) + "]]" + (mbr_type.array.empty() ? "" : " "); @@ -9804,7 +10635,7 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in } } uint32_t comp; - uint32_t locn = get_ordered_member_location(type.self, index, &comp); + uint32_t locn = get_member_location(type.self, index, &comp); if (locn != k_unknown_location) { if (comp != k_unknown_component) @@ -9825,9 +10656,11 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in case BuiltInPrimitiveId: if (msl_options.multi_patch_workgroup) return ""; - /* fallthrough */ + return string(" [[") + builtin_qualifier(builtin) + "]]" + (mbr_type.array.empty() ? "" : " "); case BuiltInSubgroupLocalInvocationId: // FIXME: Should work in any stage case BuiltInSubgroupSize: // FIXME: Should work in any stage + if (msl_options.emulate_subgroups) + return ""; return string(" [[") + builtin_qualifier(builtin) + "]]" + (mbr_type.array.empty() ? "" : " "); case BuiltInPatchVertices: return ""; @@ -9838,7 +10671,13 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in } if (msl_options.multi_patch_workgroup) return ""; - uint32_t locn = get_ordered_member_location(type.self, index); + + uint32_t locn; + if (is_builtin) + locn = get_or_allocate_builtin_input_member_location(builtin, type.self, index); + else + locn = get_member_location(type.self, index); + if (locn != k_unknown_location) return string(" [[attribute(") + convert_to_string(locn) + ")]]"; } @@ -9871,7 +10710,13 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in // The special control point array must not be marked with an attribute. if (get_type(type.member_types[index]).basetype == SPIRType::ControlPointArray) return ""; - uint32_t locn = get_ordered_member_location(type.self, index); + + uint32_t locn; + if (is_builtin) + locn = get_or_allocate_builtin_input_member_location(builtin, type.self, index); + else + locn = get_member_location(type.self, index); + if (locn != k_unknown_location) return string(" [[attribute(") + convert_to_string(locn) + ")]]"; } @@ -9902,7 +10747,9 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in break; case BuiltInClipDistance: - return join(" [[user(clip", get_member_decoration(type.self, index, DecorationLocation), ")]]"); + return join(" [[user(clip", get_member_decoration(type.self, index, DecorationIndex), ")]]"); + case BuiltInCullDistance: + return join(" [[user(cull", get_member_decoration(type.self, index, DecorationIndex), ")]]"); default: break; @@ -9911,7 +10758,7 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in else { uint32_t comp; - uint32_t locn = get_ordered_member_location(type.self, index, &comp); + uint32_t locn = get_member_location(type.self, index, &comp); if (locn != k_unknown_location) { // For user-defined attributes, this is fine. From Vulkan spec: @@ -10013,7 +10860,7 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in return ""; } } - uint32_t locn = get_ordered_member_location(type.self, index); + uint32_t locn = get_member_location(type.self, index); // Metal will likely complain about missing color attachments, too. if (locn != k_unknown_location && !(msl_options.enable_frag_output_mask & (1 << locn))) return ""; @@ -10035,15 +10882,18 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in { switch (builtin) { + case BuiltInNumSubgroups: + case BuiltInSubgroupId: + case BuiltInSubgroupLocalInvocationId: // FIXME: Should work in any stage + case BuiltInSubgroupSize: // FIXME: Should work in any stage + if (msl_options.emulate_subgroups) + break; + /* fallthrough */ case BuiltInGlobalInvocationId: case BuiltInWorkgroupId: case BuiltInNumWorkgroups: case BuiltInLocalInvocationId: case BuiltInLocalInvocationIndex: - case BuiltInNumSubgroups: - case BuiltInSubgroupId: - case BuiltInSubgroupLocalInvocationId: // FIXME: Should work in any stage - case BuiltInSubgroupSize: // FIXME: Should work in any stage return string(" [[") + builtin_qualifier(builtin) + "]]"; default: @@ -10059,24 +10909,65 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in // If the location of the member has been explicitly set, that location is used. If not, this // function assumes the members are ordered in their location order, and simply returns the // index as the location. -uint32_t CompilerMSL::get_ordered_member_location(uint32_t type_id, uint32_t index, uint32_t *comp) +uint32_t CompilerMSL::get_member_location(uint32_t type_id, uint32_t index, uint32_t *comp) const { - auto &m = ir.meta[type_id]; - if (index < m.members.size()) + if (comp) { - auto &dec = m.members[index]; - if (comp) - { - if (dec.decoration_flags.get(DecorationComponent)) - *comp = dec.component; - else - *comp = k_unknown_component; - } - if (dec.decoration_flags.get(DecorationLocation)) - return dec.location; + if (has_member_decoration(type_id, index, DecorationComponent)) + *comp = get_member_decoration(type_id, index, DecorationComponent); + else + *comp = k_unknown_component; } - return index; + if (has_member_decoration(type_id, index, DecorationLocation)) + return get_member_decoration(type_id, index, DecorationLocation); + else + return k_unknown_location; +} + +uint32_t CompilerMSL::get_or_allocate_builtin_input_member_location(spv::BuiltIn builtin, + uint32_t type_id, uint32_t index, + uint32_t *comp) +{ + uint32_t loc = get_member_location(type_id, index, comp); + if (loc != k_unknown_location) + return loc; + + if (comp) + *comp = k_unknown_component; + + // Late allocation. Find a location which is unused by the application. + // This can happen for built-in inputs in tessellation which are mixed and matched with user inputs. + auto &mbr_type = get(get(type_id).member_types[index]); + uint32_t count = type_to_location_count(mbr_type); + + loc = 0; + + const auto location_range_in_use = [this](uint32_t location, uint32_t location_count) -> bool { + for (uint32_t i = 0; i < location_count; i++) + if (location_inputs_in_use.count(location + i) != 0) + return true; + return false; + }; + + while (location_range_in_use(loc, count)) + loc++; + + set_member_decoration(type_id, index, DecorationLocation, loc); + + // Triangle tess level inputs are shared in one packed float4, + // mark both builtins as sharing one location. + if (get_execution_mode_bitset().get(ExecutionModeTriangles) && + (builtin == BuiltInTessLevelInner || builtin == BuiltInTessLevelOuter)) + { + builtin_to_automatic_input_location[BuiltInTessLevelInner] = loc; + builtin_to_automatic_input_location[BuiltInTessLevelOuter] = loc; + } + else + builtin_to_automatic_input_location[builtin] = loc; + + mark_location_as_used_by_shader(loc, mbr_type, StorageClassInput, true); + return loc; } // Returns the type declaration for a function, including the @@ -10212,7 +11103,25 @@ string CompilerMSL::get_type_address_space(const SPIRType &type, uint32_t id, bo case StorageClassOutput: if (capture_output_to_buffer) - addr_space = "device"; + { + if (var && type.storage == StorageClassOutput) + { + bool is_masked = is_stage_output_variable_masked(*var); + + if (is_masked) + { + if (is_tessellation_shader()) + addr_space = "threadgroup"; + else + addr_space = "thread"; + } + else if (variable_decl_is_remapped_storage(*var, StorageClassWorkgroup)) + addr_space = "threadgroup"; + } + + if (!addr_space) + addr_space = "device"; + } break; default: @@ -10220,8 +11129,10 @@ string CompilerMSL::get_type_address_space(const SPIRType &type, uint32_t id, bo } if (!addr_space) + { // No address space for plain values. addr_space = type.pointer || (argument && type.basetype == SPIRType::ControlPointArray) ? "thread" : ""; + } return join(flags.get(DecorationVolatile) || flags.get(DecorationCoherent) ? "volatile " : "", addr_space); } @@ -10309,6 +11220,10 @@ bool CompilerMSL::is_direct_input_builtin(BuiltIn bi_type) case BuiltInViewIndex: return get_execution_model() == ExecutionModelFragment && msl_options.multiview && msl_options.multiview_layered_rendering; + // Compute function in + case BuiltInSubgroupId: + case BuiltInNumSubgroups: + return !msl_options.emulate_subgroups; // Any stage function in case BuiltInDeviceIndex: case BuiltInSubgroupEqMask: @@ -10317,25 +11232,40 @@ bool CompilerMSL::is_direct_input_builtin(BuiltIn bi_type) case BuiltInSubgroupLeMask: case BuiltInSubgroupLtMask: return false; - case BuiltInSubgroupLocalInvocationId: case BuiltInSubgroupSize: - return get_execution_model() == ExecutionModelGLCompute || - (get_execution_model() == ExecutionModelFragment && msl_options.supports_msl_version(2, 2)); + if (msl_options.fixed_subgroup_size != 0) + return false; + /* fallthrough */ + case BuiltInSubgroupLocalInvocationId: + return !msl_options.emulate_subgroups; default: return true; } } +// Returns true if this is a fragment shader that runs per sample, and false otherwise. +bool CompilerMSL::is_sample_rate() const +{ + auto &caps = get_declared_capabilities(); + return get_execution_model() == ExecutionModelFragment && + (msl_options.force_sample_rate_shading || + std::find(caps.begin(), caps.end(), CapabilitySampleRateShading) != caps.end() || + (msl_options.use_framebuffer_fetch_subpasses && need_subpass_input)); +} + void CompilerMSL::entry_point_args_builtin(string &ep_args) { // Builtin variables SmallVector, 8> active_builtins; ir.for_each_typed_id([&](uint32_t var_id, SPIRVariable &var) { + if (var.storage != StorageClassInput) + return; + auto bi_type = BuiltIn(get_decoration(var_id, DecorationBuiltIn)); // Don't emit SamplePosition as a separate parameter. In the entry // point, we get that by calling get_sample_position() on the sample ID. - if (var.storage == StorageClassInput && is_builtin_variable(var) && + if (is_builtin_variable(var) && get_variable_data_type(var).basetype != SPIRType::Struct && get_variable_data_type(var).basetype != SPIRType::ControlPointArray) { @@ -10369,8 +11299,7 @@ void CompilerMSL::entry_point_args_builtin(string &ep_args) } } - if (var.storage == StorageClassInput && - has_extended_decoration(var_id, SPIRVCrossDecorationBuiltInDispatchBase)) + if (has_extended_decoration(var_id, SPIRVCrossDecorationBuiltInDispatchBase)) { // This is a special implicit builtin, not corresponding to any SPIR-V builtin, // which holds the base that was passed to vkCmdDispatchBase() or vkCmdDrawIndexed(). If it's present, @@ -10382,8 +11311,7 @@ void CompilerMSL::entry_point_args_builtin(string &ep_args) ep_args += type_to_glsl(get_variable_data_type(var)) + " " + to_expression(var_id) + " [[grid_origin]]"; } - if (var.storage == StorageClassInput && - has_extended_decoration(var_id, SPIRVCrossDecorationBuiltInStageInputSize)) + if (has_extended_decoration(var_id, SPIRVCrossDecorationBuiltInStageInputSize)) { // This is another special implicit builtin, not corresponding to any SPIR-V builtin, // which holds the number of vertices and instances to draw. If it's present, @@ -10477,6 +11405,58 @@ void CompilerMSL::entry_point_args_builtin(string &ep_args) ep_args += ", "; ep_args += join("device ", get_tess_factor_struct_name(), "* ", tess_factor_buffer_var_name, " [[buffer(", convert_to_string(msl_options.shader_tess_factor_buffer_index), ")]]"); + + // Initializer for tess factors must be handled specially since it's never declared as a normal variable. + uint32_t outer_factor_initializer_id = 0; + uint32_t inner_factor_initializer_id = 0; + ir.for_each_typed_id([&](uint32_t, SPIRVariable &var) { + if (!has_decoration(var.self, DecorationBuiltIn) || var.storage != StorageClassOutput || !var.initializer) + return; + + BuiltIn builtin = BuiltIn(get_decoration(var.self, DecorationBuiltIn)); + if (builtin == BuiltInTessLevelInner) + inner_factor_initializer_id = var.initializer; + else if (builtin == BuiltInTessLevelOuter) + outer_factor_initializer_id = var.initializer; + }); + + const SPIRConstant *c = nullptr; + + if (outer_factor_initializer_id && (c = maybe_get(outer_factor_initializer_id))) + { + auto &entry_func = get(ir.default_entry_point); + entry_func.fixup_hooks_in.push_back([=]() { + uint32_t components = get_execution_mode_bitset().get(ExecutionModeTriangles) ? 3 : 4; + for (uint32_t i = 0; i < components; i++) + { + statement(builtin_to_glsl(BuiltInTessLevelOuter, StorageClassOutput), "[", i, "] = ", + "half(", to_expression(c->subconstants[i]), ");"); + } + }); + } + + if (inner_factor_initializer_id && (c = maybe_get(inner_factor_initializer_id))) + { + auto &entry_func = get(ir.default_entry_point); + if (get_execution_mode_bitset().get(ExecutionModeTriangles)) + { + entry_func.fixup_hooks_in.push_back([=]() { + statement(builtin_to_glsl(BuiltInTessLevelInner, StorageClassOutput), " = ", "half(", + to_expression(c->subconstants[0]), ");"); + }); + } + else + { + entry_func.fixup_hooks_in.push_back([=]() { + for (uint32_t i = 0; i < 2; i++) + { + statement(builtin_to_glsl(BuiltInTessLevelInner, StorageClassOutput), "[", i, "] = ", + "half(", to_expression(c->subconstants[i]), ");"); + } + }); + } + } + if (stage_in_var_id) { if (!ep_args.empty()) @@ -10595,12 +11575,7 @@ void CompilerMSL::entry_point_args_discrete_descriptors(string &ep_args) { auto &type = get_variable_data_type(var); - // Very specifically, image load-store in argument buffers are disallowed on MSL on iOS. - // But we won't know when the argument buffer is encoded whether this image will have - // a NonWritable decoration. So just use discrete arguments for all storage images - // on iOS. - if (!(msl_options.is_ios() && type.basetype == SPIRType::Image && type.image.sampled == 2) && - var.storage != StorageClassPushConstant) + if (is_supported_argument_buffer_type(type) && var.storage != StorageClassPushConstant) { uint32_t desc_set = get_decoration(var_id, DecorationDescriptorSet); if (descriptor_set_is_argument_buffer(desc_set)) @@ -10868,7 +11843,12 @@ void CompilerMSL::fix_up_shader_inputs_outputs() uint32_t var_id = var.self; BuiltIn bi_type = ir.meta[var_id].decoration.builtin_type; - if (var.storage == StorageClassInput && is_builtin_variable(var)) + if (var.storage != StorageClassInput && var.storage != StorageClassOutput) + return; + if (!interface_variable_exists_in_entry_point(var.self)) + return; + + if (var.storage == StorageClassInput && is_builtin_variable(var) && active_input_builtins.get(bi_type)) { switch (bi_type) { @@ -10878,9 +11858,18 @@ void CompilerMSL::fix_up_shader_inputs_outputs() to_expression(builtin_sample_id_id), ");"); }); break; + case BuiltInFragCoord: + if (is_sample_rate()) + { + entry_func.fixup_hooks_in.push_back([=]() { + statement(to_expression(var_id), ".xy += get_sample_position(", + to_expression(builtin_sample_id_id), ") - 0.5;"); + }); + } + break; case BuiltInHelperInvocation: - if (msl_options.is_ios()) - SPIRV_CROSS_THROW("simd_is_helper_thread() is only supported on macOS."); + if (msl_options.is_ios() && !msl_options.supports_msl_version(2, 3)) + SPIRV_CROSS_THROW("simd_is_helper_thread() requires version 2.3 on iOS."); else if (msl_options.is_macos() && !msl_options.supports_msl_version(2, 1)) SPIRV_CROSS_THROW("simd_is_helper_thread() requires version 2.1 on macOS."); @@ -10908,7 +11897,7 @@ void CompilerMSL::fix_up_shader_inputs_outputs() entry_func.fixup_hooks_in.push_back([=]() { statement(builtin_type_decl(bi_type), " ", to_expression(var_id), " = min(", to_expression(builtin_invocation_id_id), ".x / ", this->get_entry_point().output_vertices, - ", spvIndirectParams[1]);"); + ", spvIndirectParams[1] - 1);"); }); break; case BuiltInPatchVertices: @@ -10931,67 +11920,78 @@ void CompilerMSL::fix_up_shader_inputs_outputs() entry_func.fixup_hooks_in.push_back([=]() { statement(tc, ".y = 1.0 - ", tc, ".y;"); }); } break; - case BuiltInSubgroupLocalInvocationId: - // This is natively supported in compute shaders. - if (get_execution_model() == ExecutionModelGLCompute) + case BuiltInSubgroupId: + if (!msl_options.emulate_subgroups) break; - - // This is natively supported in fragment shaders in MSL 2.2. - if (get_execution_model() == ExecutionModelFragment && msl_options.supports_msl_version(2, 2)) - break; - - if (msl_options.is_ios()) - SPIRV_CROSS_THROW( - "SubgroupLocalInvocationId cannot be used outside of compute shaders before MSL 2.2 on iOS."); - - if (!msl_options.supports_msl_version(2, 1)) - SPIRV_CROSS_THROW( - "SubgroupLocalInvocationId cannot be used outside of compute shaders before MSL 2.1."); - - // Shaders other than compute shaders don't support the SIMD-group - // builtins directly, but we can emulate them using the SIMD-group - // functions. This might break if some of the subgroup terminated - // before reaching the entry point. + // For subgroup emulation, this is the same as the local invocation index. entry_func.fixup_hooks_in.push_back([=]() { - statement(builtin_type_decl(bi_type), " ", to_expression(var_id), - " = simd_prefix_exclusive_sum(1);"); + statement(builtin_type_decl(bi_type), " ", to_expression(var_id), " = ", + to_expression(builtin_local_invocation_index_id), ";"); }); break; - case BuiltInSubgroupSize: - // This is natively supported in compute shaders. - if (get_execution_model() == ExecutionModelGLCompute) + case BuiltInNumSubgroups: + if (!msl_options.emulate_subgroups) break; - - // This is natively supported in fragment shaders in MSL 2.2. - if (get_execution_model() == ExecutionModelFragment && msl_options.supports_msl_version(2, 2)) + // For subgroup emulation, this is the same as the workgroup size. + entry_func.fixup_hooks_in.push_back([=]() { + auto &type = expression_type(builtin_workgroup_size_id); + string size_expr = to_expression(builtin_workgroup_size_id); + if (type.vecsize >= 3) + size_expr = join(size_expr, ".x * ", size_expr, ".y * ", size_expr, ".z"); + else if (type.vecsize == 2) + size_expr = join(size_expr, ".x * ", size_expr, ".y"); + statement(builtin_type_decl(bi_type), " ", to_expression(var_id), " = ", size_expr, ";"); + }); + break; + case BuiltInSubgroupLocalInvocationId: + if (!msl_options.emulate_subgroups) break; - - if (msl_options.is_ios()) - SPIRV_CROSS_THROW("SubgroupSize cannot be used outside of compute shaders on iOS."); - - if (!msl_options.supports_msl_version(2, 1)) - SPIRV_CROSS_THROW("SubgroupSize cannot be used outside of compute shaders before Metal 2.1."); - + // For subgroup emulation, assume subgroups of size 1. entry_func.fixup_hooks_in.push_back( - [=]() { statement(builtin_type_decl(bi_type), " ", to_expression(var_id), " = simd_sum(1);"); }); + [=]() { statement(builtin_type_decl(bi_type), " ", to_expression(var_id), " = 0;"); }); + break; + case BuiltInSubgroupSize: + if (msl_options.emulate_subgroups) + { + // For subgroup emulation, assume subgroups of size 1. + entry_func.fixup_hooks_in.push_back( + [=]() { statement(builtin_type_decl(bi_type), " ", to_expression(var_id), " = 1;"); }); + } + else if (msl_options.fixed_subgroup_size != 0) + { + entry_func.fixup_hooks_in.push_back([=]() { + statement(builtin_type_decl(bi_type), " ", to_expression(var_id), " = ", + msl_options.fixed_subgroup_size, ";"); + }); + } break; case BuiltInSubgroupEqMask: - if (msl_options.is_ios()) - SPIRV_CROSS_THROW("Subgroup ballot functionality is unavailable on iOS."); + if (msl_options.is_ios() && !msl_options.supports_msl_version(2, 2)) + SPIRV_CROSS_THROW("Subgroup ballot functionality requires Metal 2.2 on iOS."); if (!msl_options.supports_msl_version(2, 1)) SPIRV_CROSS_THROW("Subgroup ballot functionality requires Metal 2.1."); entry_func.fixup_hooks_in.push_back([=]() { - statement(builtin_type_decl(bi_type), " ", to_expression(var_id), " = ", - to_expression(builtin_subgroup_invocation_id_id), " >= 32 ? uint4(0, (1 << (", - to_expression(builtin_subgroup_invocation_id_id), " - 32)), uint2(0)) : uint4(1 << ", - to_expression(builtin_subgroup_invocation_id_id), ", uint3(0));"); + if (msl_options.is_ios()) + { + statement(builtin_type_decl(bi_type), " ", to_expression(var_id), " = ", "uint4(1 << ", + to_expression(builtin_subgroup_invocation_id_id), ", uint3(0));"); + } + else + { + statement(builtin_type_decl(bi_type), " ", to_expression(var_id), " = ", + to_expression(builtin_subgroup_invocation_id_id), " >= 32 ? uint4(0, (1 << (", + to_expression(builtin_subgroup_invocation_id_id), " - 32)), uint2(0)) : uint4(1 << ", + to_expression(builtin_subgroup_invocation_id_id), ", uint3(0));"); + } }); break; case BuiltInSubgroupGeMask: - if (msl_options.is_ios()) - SPIRV_CROSS_THROW("Subgroup ballot functionality is unavailable on iOS."); + if (msl_options.is_ios() && !msl_options.supports_msl_version(2, 2)) + SPIRV_CROSS_THROW("Subgroup ballot functionality requires Metal 2.2 on iOS."); if (!msl_options.supports_msl_version(2, 1)) SPIRV_CROSS_THROW("Subgroup ballot functionality requires Metal 2.1."); + if (msl_options.fixed_subgroup_size != 0) + add_spv_func_and_recompile(SPVFuncImplSubgroupBallot); entry_func.fixup_hooks_in.push_back([=]() { // Case where index < 32, size < 32: // mask0 = bfi(0, 0xFFFFFFFF, index, size - index); @@ -11007,60 +12007,149 @@ void CompilerMSL::fix_up_shader_inputs_outputs() // This is further complicated by the fact that if you attempt // to bfi/bfe out-of-bounds on Metal, undefined behavior is the // result. - statement(builtin_type_decl(bi_type), " ", to_expression(var_id), - " = uint4(insert_bits(0u, 0xFFFFFFFF, min(", - to_expression(builtin_subgroup_invocation_id_id), ", 32u), (uint)max(min((int)", - to_expression(builtin_subgroup_size_id), ", 32) - (int)", - to_expression(builtin_subgroup_invocation_id_id), - ", 0)), insert_bits(0u, 0xFFFFFFFF, (uint)max((int)", - to_expression(builtin_subgroup_invocation_id_id), " - 32, 0), (uint)max((int)", - to_expression(builtin_subgroup_size_id), " - (int)max(", - to_expression(builtin_subgroup_invocation_id_id), ", 32u), 0)), uint2(0));"); + if (msl_options.fixed_subgroup_size > 32) + { + // Don't use the subgroup size variable with fixed subgroup sizes, + // since the variables could be defined in the wrong order. + statement(builtin_type_decl(bi_type), " ", to_expression(var_id), + " = uint4(insert_bits(0u, 0xFFFFFFFF, min(", + to_expression(builtin_subgroup_invocation_id_id), ", 32u), (uint)max(32 - (int)", + to_expression(builtin_subgroup_invocation_id_id), + ", 0)), insert_bits(0u, 0xFFFFFFFF," + " (uint)max((int)", + to_expression(builtin_subgroup_invocation_id_id), " - 32, 0), ", + msl_options.fixed_subgroup_size, " - max(", + to_expression(builtin_subgroup_invocation_id_id), + ", 32u)), uint2(0));"); + } + else if (msl_options.fixed_subgroup_size != 0) + { + statement(builtin_type_decl(bi_type), " ", to_expression(var_id), + " = uint4(insert_bits(0u, 0xFFFFFFFF, ", + to_expression(builtin_subgroup_invocation_id_id), ", ", + msl_options.fixed_subgroup_size, " - ", + to_expression(builtin_subgroup_invocation_id_id), + "), uint3(0));"); + } + else if (msl_options.is_ios()) + { + // On iOS, the SIMD-group size will currently never exceed 32. + statement(builtin_type_decl(bi_type), " ", to_expression(var_id), + " = uint4(insert_bits(0u, 0xFFFFFFFF, ", + to_expression(builtin_subgroup_invocation_id_id), ", ", + to_expression(builtin_subgroup_size_id), " - ", + to_expression(builtin_subgroup_invocation_id_id), "), uint3(0));"); + } + else + { + statement(builtin_type_decl(bi_type), " ", to_expression(var_id), + " = uint4(insert_bits(0u, 0xFFFFFFFF, min(", + to_expression(builtin_subgroup_invocation_id_id), ", 32u), (uint)max(min((int)", + to_expression(builtin_subgroup_size_id), ", 32) - (int)", + to_expression(builtin_subgroup_invocation_id_id), + ", 0)), insert_bits(0u, 0xFFFFFFFF, (uint)max((int)", + to_expression(builtin_subgroup_invocation_id_id), " - 32, 0), (uint)max((int)", + to_expression(builtin_subgroup_size_id), " - (int)max(", + to_expression(builtin_subgroup_invocation_id_id), ", 32u), 0)), uint2(0));"); + } }); break; case BuiltInSubgroupGtMask: - if (msl_options.is_ios()) - SPIRV_CROSS_THROW("Subgroup ballot functionality is unavailable on iOS."); + if (msl_options.is_ios() && !msl_options.supports_msl_version(2, 2)) + SPIRV_CROSS_THROW("Subgroup ballot functionality requires Metal 2.2 on iOS."); if (!msl_options.supports_msl_version(2, 1)) SPIRV_CROSS_THROW("Subgroup ballot functionality requires Metal 2.1."); + add_spv_func_and_recompile(SPVFuncImplSubgroupBallot); entry_func.fixup_hooks_in.push_back([=]() { // The same logic applies here, except now the index is one // more than the subgroup invocation ID. - statement(builtin_type_decl(bi_type), " ", to_expression(var_id), - " = uint4(insert_bits(0u, 0xFFFFFFFF, min(", - to_expression(builtin_subgroup_invocation_id_id), " + 1, 32u), (uint)max(min((int)", - to_expression(builtin_subgroup_size_id), ", 32) - (int)", - to_expression(builtin_subgroup_invocation_id_id), - " - 1, 0)), insert_bits(0u, 0xFFFFFFFF, (uint)max((int)", - to_expression(builtin_subgroup_invocation_id_id), " + 1 - 32, 0), (uint)max((int)", - to_expression(builtin_subgroup_size_id), " - (int)max(", - to_expression(builtin_subgroup_invocation_id_id), " + 1, 32u), 0)), uint2(0));"); + if (msl_options.fixed_subgroup_size > 32) + { + statement(builtin_type_decl(bi_type), " ", to_expression(var_id), + " = uint4(insert_bits(0u, 0xFFFFFFFF, min(", + to_expression(builtin_subgroup_invocation_id_id), " + 1, 32u), (uint)max(32 - (int)", + to_expression(builtin_subgroup_invocation_id_id), + " - 1, 0)), insert_bits(0u, 0xFFFFFFFF, (uint)max((int)", + to_expression(builtin_subgroup_invocation_id_id), " + 1 - 32, 0), ", + msl_options.fixed_subgroup_size, " - max(", + to_expression(builtin_subgroup_invocation_id_id), + " + 1, 32u)), uint2(0));"); + } + else if (msl_options.fixed_subgroup_size != 0) + { + statement(builtin_type_decl(bi_type), " ", to_expression(var_id), + " = uint4(insert_bits(0u, 0xFFFFFFFF, ", + to_expression(builtin_subgroup_invocation_id_id), " + 1, ", + msl_options.fixed_subgroup_size, " - ", + to_expression(builtin_subgroup_invocation_id_id), + " - 1), uint3(0));"); + } + else if (msl_options.is_ios()) + { + statement(builtin_type_decl(bi_type), " ", to_expression(var_id), + " = uint4(insert_bits(0u, 0xFFFFFFFF, ", + to_expression(builtin_subgroup_invocation_id_id), " + 1, ", + to_expression(builtin_subgroup_size_id), " - ", + to_expression(builtin_subgroup_invocation_id_id), " - 1), uint3(0));"); + } + else + { + statement(builtin_type_decl(bi_type), " ", to_expression(var_id), + " = uint4(insert_bits(0u, 0xFFFFFFFF, min(", + to_expression(builtin_subgroup_invocation_id_id), " + 1, 32u), (uint)max(min((int)", + to_expression(builtin_subgroup_size_id), ", 32) - (int)", + to_expression(builtin_subgroup_invocation_id_id), + " - 1, 0)), insert_bits(0u, 0xFFFFFFFF, (uint)max((int)", + to_expression(builtin_subgroup_invocation_id_id), " + 1 - 32, 0), (uint)max((int)", + to_expression(builtin_subgroup_size_id), " - (int)max(", + to_expression(builtin_subgroup_invocation_id_id), " + 1, 32u), 0)), uint2(0));"); + } }); break; case BuiltInSubgroupLeMask: - if (msl_options.is_ios()) - SPIRV_CROSS_THROW("Subgroup ballot functionality is unavailable on iOS."); + if (msl_options.is_ios() && !msl_options.supports_msl_version(2, 2)) + SPIRV_CROSS_THROW("Subgroup ballot functionality requires Metal 2.2 on iOS."); if (!msl_options.supports_msl_version(2, 1)) SPIRV_CROSS_THROW("Subgroup ballot functionality requires Metal 2.1."); + add_spv_func_and_recompile(SPVFuncImplSubgroupBallot); entry_func.fixup_hooks_in.push_back([=]() { - statement(builtin_type_decl(bi_type), " ", to_expression(var_id), - " = uint4(extract_bits(0xFFFFFFFF, 0, min(", - to_expression(builtin_subgroup_invocation_id_id), - " + 1, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)", - to_expression(builtin_subgroup_invocation_id_id), " + 1 - 32, 0)), uint2(0));"); + if (msl_options.is_ios()) + { + statement(builtin_type_decl(bi_type), " ", to_expression(var_id), + " = uint4(extract_bits(0xFFFFFFFF, 0, ", + to_expression(builtin_subgroup_invocation_id_id), " + 1), uint3(0));"); + } + else + { + statement(builtin_type_decl(bi_type), " ", to_expression(var_id), + " = uint4(extract_bits(0xFFFFFFFF, 0, min(", + to_expression(builtin_subgroup_invocation_id_id), + " + 1, 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)", + to_expression(builtin_subgroup_invocation_id_id), " + 1 - 32, 0)), uint2(0));"); + } }); break; case BuiltInSubgroupLtMask: - if (msl_options.is_ios()) - SPIRV_CROSS_THROW("Subgroup ballot functionality is unavailable on iOS."); + if (msl_options.is_ios() && !msl_options.supports_msl_version(2, 2)) + SPIRV_CROSS_THROW("Subgroup ballot functionality requires Metal 2.2 on iOS."); if (!msl_options.supports_msl_version(2, 1)) SPIRV_CROSS_THROW("Subgroup ballot functionality requires Metal 2.1."); + add_spv_func_and_recompile(SPVFuncImplSubgroupBallot); entry_func.fixup_hooks_in.push_back([=]() { - statement(builtin_type_decl(bi_type), " ", to_expression(var_id), - " = uint4(extract_bits(0xFFFFFFFF, 0, min(", - to_expression(builtin_subgroup_invocation_id_id), - ", 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)", - to_expression(builtin_subgroup_invocation_id_id), " - 32, 0)), uint2(0));"); + if (msl_options.is_ios()) + { + statement(builtin_type_decl(bi_type), " ", to_expression(var_id), + " = uint4(extract_bits(0xFFFFFFFF, 0, ", + to_expression(builtin_subgroup_invocation_id_id), "), uint3(0));"); + } + else + { + statement(builtin_type_decl(bi_type), " ", to_expression(var_id), + " = uint4(extract_bits(0xFFFFFFFF, 0, min(", + to_expression(builtin_subgroup_invocation_id_id), + ", 32u)), extract_bits(0xFFFFFFFF, 0, (uint)max((int)", + to_expression(builtin_subgroup_invocation_id_id), " - 32, 0)), uint2(0));"); + } }); break; case BuiltInViewIndex: @@ -11225,7 +12314,7 @@ void CompilerMSL::fix_up_shader_inputs_outputs() break; } } - else if (var.storage == StorageClassOutput && is_builtin_variable(var)) + else if (var.storage == StorageClassOutput && is_builtin_variable(var) && active_output_builtins.get(bi_type)) { if (bi_type == BuiltInSampleMask && get_execution_model() == ExecutionModelFragment && msl_options.additional_fixed_sample_mask != 0xffffffff) @@ -11298,10 +12387,18 @@ uint32_t CompilerMSL::get_metal_resource_index(SPIRVariable &var, SPIRType::Base if (has_extended_decoration(var.self, resource_decoration)) return get_extended_decoration(var.self, resource_decoration); - // Allow user to enable decoration binding - if (msl_options.enable_decoration_binding) + auto &type = get(var.basetype); + + if (type_is_msl_framebuffer_fetch(type)) { - // If there is no explicit mapping of bindings to MSL, use the declared binding. + // Frame-buffer fetch gets its fallback resource index from the input attachment index, + // which is then treated as color index. + return get_decoration(var.self, DecorationInputAttachmentIndex); + } + else if (msl_options.enable_decoration_binding) + { + // Allow user to enable decoration binding. + // If there is no explicit mapping of bindings to MSL, use the declared binding as a fallback. if (has_decoration(var.self, DecorationBinding)) { var_binding = get_decoration(var.self, DecorationBinding); @@ -11320,7 +12417,6 @@ uint32_t CompilerMSL::get_metal_resource_index(SPIRVariable &var, SPIRType::Base allocate_argument_buffer_ids = descriptor_set_is_argument_buffer(var_desc_set); uint32_t binding_stride = 1; - auto &type = get(var.basetype); for (uint32_t i = 0; i < uint32_t(type.array.size()); i++) binding_stride *= to_array_size_literal(type, i); @@ -11329,13 +12425,7 @@ uint32_t CompilerMSL::get_metal_resource_index(SPIRVariable &var, SPIRType::Base // If a binding has not been specified, revert to incrementing resource indices. uint32_t resource_index; - if (type_is_msl_framebuffer_fetch(type)) - { - // Frame-buffer fetch gets its fallback resource index from the input attachment index, - // which is then treated as color index. - resource_index = get_decoration(var.self, DecorationInputAttachmentIndex); - } - else if (allocate_argument_buffer_ids) + if (allocate_argument_buffer_ids) { // Allocate from a flat ID binding space. resource_index = next_metal_resource_ids[var_desc_set]; @@ -11371,12 +12461,30 @@ bool CompilerMSL::type_is_msl_framebuffer_fetch(const SPIRType &type) const msl_options.use_framebuffer_fetch_subpasses; } +bool CompilerMSL::type_is_pointer(const SPIRType &type) const +{ + if (!type.pointer) + return false; + auto &parent_type = get(type.parent_type); + // Safeguards when we forget to set pointer_depth (there is an assert for it in type_to_glsl), + // but the extra check shouldn't hurt. + return (type.pointer_depth > parent_type.pointer_depth) || !parent_type.pointer; +} + +bool CompilerMSL::type_is_pointer_to_pointer(const SPIRType &type) const +{ + if (!type.pointer) + return false; + auto &parent_type = get(type.parent_type); + return type.pointer_depth > parent_type.pointer_depth && type_is_pointer(parent_type); +} + string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg) { auto &var = get(arg.id); auto &type = get_variable_data_type(var); auto &var_type = get(arg.type); - StorageClass storage = var_type.storage; + StorageClass type_storage = var_type.storage; bool is_pointer = var_type.pointer; // If we need to modify the name of the variable, make sure we use the original variable. @@ -11397,9 +12505,8 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg) if (!type.array.empty() && type_is_image) constref = true; + const char *cv_qualifier = constref ? "const " : ""; string decl; - if (constref) - decl += "const "; // If this is a combined image-sampler for a 2D image with floating-point type, // we emitted the 'spvDynamicImageSampler' type, and this is *not* an alias parameter @@ -11412,33 +12519,68 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg) // Allow Metal to use the array template to make arrays a value type string address_space = get_argument_address_space(var); - bool builtin = is_builtin_variable(var); - is_using_builtin_array = builtin; + bool builtin = has_decoration(var.self, DecorationBuiltIn); + auto builtin_type = BuiltIn(get_decoration(arg.id, DecorationBuiltIn)); + if (address_space == "threadgroup") is_using_builtin_array = true; if (var.basevariable && (var.basevariable == stage_in_ptr_var_id || var.basevariable == stage_out_ptr_var_id)) - decl += type_to_glsl(type, arg.id); + decl = join(cv_qualifier, type_to_glsl(type, arg.id)); else if (builtin) - decl += builtin_type_decl(static_cast(get_decoration(arg.id, DecorationBuiltIn)), arg.id); - else if ((storage == StorageClassUniform || storage == StorageClassStorageBuffer) && is_array(type)) + { + // Only use templated array for Clip/Cull distance when feasible. + // In other scenarios, we need need to override array length for tess levels (if used as outputs), + // or we need to emit the expected type for builtins (uint vs int). + auto storage = get(var.basetype).storage; + + if (storage == StorageClassInput && + (builtin_type == BuiltInTessLevelInner || builtin_type == BuiltInTessLevelOuter)) + { + is_using_builtin_array = false; + } + else if (builtin_type != BuiltInClipDistance && builtin_type != BuiltInCullDistance) + { + is_using_builtin_array = true; + } + + if (storage == StorageClassOutput && variable_storage_requires_stage_io(storage) && + !is_stage_output_builtin_masked(builtin_type)) + is_using_builtin_array = true; + + if (is_using_builtin_array) + decl = join(cv_qualifier, builtin_type_decl(builtin_type, arg.id)); + else + decl = join(cv_qualifier, type_to_glsl(type, arg.id)); + } + else if ((type_storage == StorageClassUniform || type_storage == StorageClassStorageBuffer) && is_array(type)) { is_using_builtin_array = true; - decl += join(type_to_glsl(type, arg.id), "*"); + decl += join(cv_qualifier, type_to_glsl(type, arg.id), "*"); } else if (is_dynamic_img_sampler) { - decl += join("spvDynamicImageSampler<", type_to_glsl(get(type.image.type)), ">"); + decl = join(cv_qualifier, "spvDynamicImageSampler<", type_to_glsl(get(type.image.type)), ">"); // Mark the variable so that we can handle passing it to another function. set_extended_decoration(arg.id, SPIRVCrossDecorationDynamicImageSampler); } else - decl += type_to_glsl(type, arg.id); + { + // The type is a pointer type we need to emit cv_qualifier late. + if (type_is_pointer(type)) + { + decl = type_to_glsl(type, arg.id); + if (*cv_qualifier != '\0') + decl += join(" ", cv_qualifier); + } + else + decl = join(cv_qualifier, type_to_glsl(type, arg.id)); + } - bool opaque_handle = storage == StorageClassUniformConstant; + bool opaque_handle = type_storage == StorageClassUniformConstant; if (!builtin && !opaque_handle && !is_pointer && - (storage == StorageClassFunction || storage == StorageClassGeneric)) + (type_storage == StorageClassFunction || type_storage == StorageClassGeneric)) { // If the argument is a pure value and not an opaque type, we will pass by value. if (msl_options.force_native_arrays && is_array(type)) @@ -11479,7 +12621,7 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg) if (msl_options.argument_buffers) { uint32_t desc_set = get_decoration(name_id, DecorationDescriptorSet); - if ((storage == StorageClassUniform || storage == StorageClassStorageBuffer) && + if ((type_storage == StorageClassUniform || type_storage == StorageClassStorageBuffer) && descriptor_set_is_argument_buffer(desc_set)) { // An awkward case where we need to emit *more* address space declarations (yay!). @@ -11501,16 +12643,46 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg) } } - decl += " (&"; - const char *restrict_kw = to_restrict(name_id); - if (*restrict_kw) + // Special case, need to override the array size here if we're using tess level as an argument. + if (get_execution_model() == ExecutionModelTessellationControl && builtin && + (builtin_type == BuiltInTessLevelInner || builtin_type == BuiltInTessLevelOuter)) { - decl += " "; - decl += restrict_kw; + uint32_t array_size = get_physical_tess_level_array_size(builtin_type); + if (array_size == 1) + { + decl += " &"; + decl += to_expression(name_id); + } + else + { + decl += " (&"; + decl += to_expression(name_id); + decl += ")"; + decl += join("[", array_size, "]"); + } + } + else + { + auto array_size_decl = type_to_array_glsl(type); + if (array_size_decl.empty()) + decl += "& "; + else + decl += " (&"; + + const char *restrict_kw = to_restrict(name_id); + if (*restrict_kw) + { + decl += " "; + decl += restrict_kw; + } + decl += to_expression(name_id); + + if (!array_size_decl.empty()) + { + decl += ")"; + decl += array_size_decl; + } } - decl += to_expression(name_id); - decl += ")"; - decl += type_to_array_glsl(type); } else if (!opaque_handle && (!pull_model_inputs.count(var.basevariable) || type.basetype == SPIRType::Struct)) { @@ -11518,8 +12690,12 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg) // for the reference has to go before the '&', but after the '*'. if (!address_space.empty()) { - if (decl.back() == '*') - decl += join(" ", address_space, " "); + if (type_is_pointer(type)) + { + if (*cv_qualifier == '\0') + decl += ' '; + decl += join(address_space, " "); + } else decl = join(address_space, " ", decl); } @@ -11584,11 +12760,8 @@ string CompilerMSL::ensure_valid_name(string name, string pfx) return (name.size() >= 2 && name[0] == '_' && isdigit(name[1])) ? (pfx + name) : name; } -// Replace all names that match MSL keywords or Metal Standard Library functions. -void CompilerMSL::replace_illegal_names() +const std::unordered_set &CompilerMSL::get_reserved_keyword_set() { - // FIXME: MSL and GLSL are doing two different things here. - // Agree on convention and remove this override. static const unordered_set keywords = { "kernel", "vertex", @@ -11722,10 +12895,17 @@ void CompilerMSL::replace_illegal_names() "quad_broadcast", }; + return keywords; +} + +const std::unordered_set &CompilerMSL::get_illegal_func_names() +{ static const unordered_set illegal_func_names = { "main", "saturate", "assert", + "fmin3", + "fmax3", "VARIABLE_TRACEPOINT", "STATIC_DATA_TRACEPOINT", "STATIC_DATA_TRACEPOINT_V", @@ -11846,6 +13026,17 @@ void CompilerMSL::replace_illegal_names() "M_SQRT1_2", }; + return illegal_func_names; +} + +// Replace all names that match MSL keywords or Metal Standard Library functions. +void CompilerMSL::replace_illegal_names() +{ + // FIXME: MSL and GLSL are doing two different things here. + // Agree on convention and remove this override. + auto &keywords = get_reserved_keyword_set(); + auto &illegal_func_names = get_illegal_func_names(); + ir.for_each_typed_id([&](uint32_t self, SPIRVariable &) { auto *meta = ir.find_meta(self); if (!meta) @@ -11876,6 +13067,16 @@ void CompilerMSL::replace_illegal_names() mbr_dec.alias += "0"; }); + CompilerGLSL::replace_illegal_names(); +} + +void CompilerMSL::replace_illegal_entry_point_names() +{ + auto &illegal_func_names = get_illegal_func_names(); + + // It is important to this before we fixup identifiers, + // since if ep_name is reserved, we will need to fix that up, + // and then copy alias back into entry.name after the fixup. for (auto &entry : ir.entry_points) { // Change both the entry point name and the alias, to keep them synced. @@ -11883,11 +13084,14 @@ void CompilerMSL::replace_illegal_names() if (illegal_func_names.find(ep_name) != end(illegal_func_names)) ep_name += "0"; - // Always write this because entry point might have been renamed earlier. ir.meta[entry.first].decoration.alias = ep_name; } +} - CompilerGLSL::replace_illegal_names(); +void CompilerMSL::sync_entry_point_aliases_and_names() +{ + for (auto &entry : ir.entry_points) + entry.second.name = ir.meta[entry.first].decoration.alias; } string CompilerMSL::to_member_reference(uint32_t base, const SPIRType &type, uint32_t index, bool ptr_chain) @@ -11922,8 +13126,10 @@ string CompilerMSL::to_qualifiers_glsl(uint32_t id) { string quals; + auto *var = maybe_get(id); auto &type = expression_type(id); - if (type.storage == StorageClassWorkgroup) + + if (type.storage == StorageClassWorkgroup || (var && variable_decl_is_remapped_storage(*var, StorageClassWorkgroup))) quals += "threadgroup "; return quals; @@ -11939,8 +13145,22 @@ string CompilerMSL::type_to_glsl(const SPIRType &type, uint32_t id) // Pointer? if (type.pointer) { + assert(type.pointer_depth > 0); + const char *restrict_kw; - type_name = join(get_type_address_space(type, id), " ", type_to_glsl(get(type.parent_type), id)); + + auto type_address_space = get_type_address_space(type, id); + auto type_decl = type_to_glsl(get(type.parent_type), id); + + // Work around C pointer qualifier rules. If glsl_type is a pointer type as well + // we'll need to emit the address space to the right. + // We could always go this route, but it makes the code unnatural. + // Prefer emitting thread T *foo over T thread* foo since it's more readable, + // but we'll have to emit thread T * thread * T constant bar; for example. + if (type_is_pointer_to_pointer(type)) + type_name = join(type_decl, " ", type_address_space, " "); + else + type_name = join(type_address_space, " ", type_decl); switch (type.basetype) { @@ -12090,18 +13310,55 @@ string CompilerMSL::type_to_array_glsl(const SPIRType &type) } } -// Threadgroup arrays can't have a wrapper type +bool CompilerMSL::variable_decl_is_remapped_storage(const SPIRVariable &variable, spv::StorageClass storage) const +{ + if (variable.storage == storage) + return true; + + if (storage == StorageClassWorkgroup) + { + auto model = get_execution_model(); + + // Specially masked IO block variable. + // Normally, we will never access IO blocks directly here. + // The only scenario which that should occur is with a masked IO block. + if (model == ExecutionModelTessellationControl && variable.storage == StorageClassOutput && + has_decoration(get(variable.basetype).self, DecorationBlock)) + { + return true; + } + + return variable.storage == StorageClassOutput && + model == ExecutionModelTessellationControl && + is_stage_output_variable_masked(variable); + } + else if (storage == StorageClassStorageBuffer) + { + // We won't be able to catch writes to control point outputs here since variable + // refers to a function local pointer. + // This is fine, as there cannot be concurrent writers to that memory anyways, + // so we just ignore that case. + + return (variable.storage == StorageClassOutput || variable.storage == StorageClassInput) && + !variable_storage_requires_stage_io(variable.storage) && + (variable.storage != StorageClassOutput || !is_stage_output_variable_masked(variable)); + } + else + { + return false; + } +} + std::string CompilerMSL::variable_decl(const SPIRVariable &variable) { - if (variable.storage == StorageClassWorkgroup) - { + bool old_is_using_builtin_array = is_using_builtin_array; + + // Threadgroup arrays can't have a wrapper type. + if (variable_decl_is_remapped_storage(variable, StorageClassWorkgroup)) is_using_builtin_array = true; - } + std::string expr = CompilerGLSL::variable_decl(variable); - if (variable.storage == StorageClassWorkgroup) - { - is_using_builtin_array = false; - } + is_using_builtin_array = old_is_using_builtin_array; return expr; } @@ -12349,10 +13606,23 @@ void CompilerMSL::emit_subgroup_op(const Instruction &i) const uint32_t *ops = stream(i); auto op = static_cast(i.op); - // Metal 2.0 is required. iOS only supports quad ops. macOS only supports - // broadcast and shuffle on 10.13 (2.0), with full support in 10.14 (2.1). - // Note that iOS makes no distinction between a quad-group and a subgroup; - // all subgroups are quad-groups there. + if (msl_options.emulate_subgroups) + { + // In this mode, only the GroupNonUniform cap is supported. The only op + // we need to handle, then, is OpGroupNonUniformElect. + if (op != OpGroupNonUniformElect) + SPIRV_CROSS_THROW("Subgroup emulation does not support operations other than Elect."); + // In this mode, the subgroup size is assumed to be one, so every invocation + // is elected. + emit_op(ops[0], ops[1], "true", true); + return; + } + + // Metal 2.0 is required. iOS only supports quad ops on 11.0 (2.0), with + // full support in 13.0 (2.2). macOS only supports broadcast and shuffle on + // 10.13 (2.0), with full support in 10.14 (2.1). + // Note that Apple GPUs before A13 make no distinction between a quad-group + // and a SIMD-group; all SIMD-groups are quad-groups on those. if (!msl_options.supports_msl_version(2)) SPIRV_CROSS_THROW("Subgroups are only supported in Metal 2.0 and up."); @@ -12361,12 +13631,32 @@ void CompilerMSL::emit_subgroup_op(const Instruction &i) auto int_type = to_signed_basetype(integer_width); auto uint_type = to_unsigned_basetype(integer_width); - if (msl_options.is_ios()) + if (msl_options.is_ios() && (!msl_options.supports_msl_version(2, 3) || !msl_options.ios_use_simdgroup_functions)) { switch (op) { default: - SPIRV_CROSS_THROW("iOS only supports quad-group operations."); + SPIRV_CROSS_THROW("Subgroup ops beyond broadcast, ballot, and shuffle on iOS require Metal 2.3 and up."); + case OpGroupNonUniformBroadcastFirst: + if (!msl_options.supports_msl_version(2, 2)) + SPIRV_CROSS_THROW("BroadcastFirst on iOS requires Metal 2.2 and up."); + break; + case OpGroupNonUniformElect: + if (!msl_options.supports_msl_version(2, 2)) + SPIRV_CROSS_THROW("Elect on iOS requires Metal 2.2 and up."); + break; + case OpGroupNonUniformAny: + case OpGroupNonUniformAll: + case OpGroupNonUniformAllEqual: + case OpGroupNonUniformBallot: + case OpGroupNonUniformInverseBallot: + case OpGroupNonUniformBallotBitExtract: + case OpGroupNonUniformBallotFindLSB: + case OpGroupNonUniformBallotFindMSB: + case OpGroupNonUniformBallotBitCount: + if (!msl_options.supports_msl_version(2, 2)) + SPIRV_CROSS_THROW("Ballot ops on iOS requires Metal 2.2 and up."); + break; case OpGroupNonUniformBroadcast: case OpGroupNonUniformShuffle: case OpGroupNonUniformShuffleXor: @@ -12403,7 +13693,10 @@ void CompilerMSL::emit_subgroup_op(const Instruction &i) switch (op) { case OpGroupNonUniformElect: - emit_op(result_type, id, "simd_is_first()", true); + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) + emit_op(result_type, id, "quad_is_first()", false); + else + emit_op(result_type, id, "simd_is_first()", false); break; case OpGroupNonUniformBroadcast: @@ -12474,11 +13767,17 @@ void CompilerMSL::emit_subgroup_op(const Instruction &i) break; case OpGroupNonUniformAll: - emit_unary_func_op(result_type, id, ops[3], "simd_all"); + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) + emit_unary_func_op(result_type, id, ops[3], "quad_all"); + else + emit_unary_func_op(result_type, id, ops[3], "simd_all"); break; case OpGroupNonUniformAny: - emit_unary_func_op(result_type, id, ops[3], "simd_any"); + if (msl_options.is_ios() && !msl_options.ios_use_simdgroup_functions) + emit_unary_func_op(result_type, id, ops[3], "quad_any"); + else + emit_unary_func_op(result_type, id, ops[3], "simd_any"); break; case OpGroupNonUniformAllEqual: @@ -12626,7 +13925,6 @@ string CompilerMSL::builtin_to_glsl(BuiltIn builtin, StorageClass storage) { switch (builtin) { - // Handle HLSL-style 0-based vertex/instance index. // Override GLSL compiler strictness case BuiltInVertexId: @@ -12759,9 +14057,9 @@ string CompilerMSL::builtin_to_glsl(BuiltIn builtin, StorageClass storage) case BuiltInSampleMask: if (get_execution_model() == ExecutionModelTessellationControl) break; - if (storage != StorageClassInput && current_function && (current_function->self == ir.default_entry_point)) + if (storage != StorageClassInput && current_function && (current_function->self == ir.default_entry_point) && + !is_stage_output_builtin_masked(builtin)) return stage_out_var_name + "." + CompilerGLSL::builtin_to_glsl(builtin, storage); - break; case BuiltInBaryCoordNV: @@ -12771,31 +14069,21 @@ string CompilerMSL::builtin_to_glsl(BuiltIn builtin, StorageClass storage) break; case BuiltInTessLevelOuter: - if (get_execution_model() == ExecutionModelTessellationEvaluation) + if (get_execution_model() == ExecutionModelTessellationControl && + storage != StorageClassInput && current_function && (current_function->self == ir.default_entry_point)) { - if (storage != StorageClassOutput && !get_entry_point().flags.get(ExecutionModeTriangles) && - current_function && (current_function->self == ir.default_entry_point)) - return join(patch_stage_in_var_name, ".", CompilerGLSL::builtin_to_glsl(builtin, storage)); - else - break; - } - if (storage != StorageClassInput && current_function && (current_function->self == ir.default_entry_point)) return join(tess_factor_buffer_var_name, "[", to_expression(builtin_primitive_id_id), "].edgeTessellationFactor"); + } break; case BuiltInTessLevelInner: - if (get_execution_model() == ExecutionModelTessellationEvaluation) + if (get_execution_model() == ExecutionModelTessellationControl && + storage != StorageClassInput && current_function && (current_function->self == ir.default_entry_point)) { - if (storage != StorageClassOutput && !get_entry_point().flags.get(ExecutionModeTriangles) && - current_function && (current_function->self == ir.default_entry_point)) - return join(patch_stage_in_var_name, ".", CompilerGLSL::builtin_to_glsl(builtin, storage)); - else - break; - } - if (storage != StorageClassInput && current_function && (current_function->self == ir.default_entry_point)) return join(tess_factor_buffer_var_name, "[", to_expression(builtin_primitive_id_id), "].insideTessellationFactor"); + } break; default: @@ -12873,8 +14161,8 @@ string CompilerMSL::builtin_qualifier(BuiltIn builtin) case ExecutionModelTessellationEvaluation: return "patch_id"; case ExecutionModelFragment: - if (msl_options.is_ios()) - SPIRV_CROSS_THROW("PrimitiveId is not supported in fragment on iOS."); + if (msl_options.is_ios() && !msl_options.supports_msl_version(2, 3)) + SPIRV_CROSS_THROW("PrimitiveId on iOS requires MSL 2.3."); else if (msl_options.is_macos() && !msl_options.supports_msl_version(2, 2)) SPIRV_CROSS_THROW("PrimitiveId on macOS requires MSL 2.2."); return "primitive_id"; @@ -12942,6 +14230,9 @@ string CompilerMSL::builtin_qualifier(BuiltIn builtin) return "thread_index_in_threadgroup"; case BuiltInSubgroupSize: + if (msl_options.emulate_subgroups || msl_options.fixed_subgroup_size != 0) + // Shouldn't be reached. + SPIRV_CROSS_THROW("Emitting threads_per_simdgroup attribute with fixed subgroup size??"); if (execution.model == ExecutionModelFragment) { if (!msl_options.supports_msl_version(2, 2)) @@ -12956,28 +14247,42 @@ string CompilerMSL::builtin_qualifier(BuiltIn builtin) } case BuiltInNumSubgroups: + if (msl_options.emulate_subgroups) + // Shouldn't be reached. + SPIRV_CROSS_THROW("NumSubgroups is handled specially with emulation."); if (!msl_options.supports_msl_version(2)) SPIRV_CROSS_THROW("Subgroup builtins require Metal 2.0."); return msl_options.is_ios() ? "quadgroups_per_threadgroup" : "simdgroups_per_threadgroup"; case BuiltInSubgroupId: + if (msl_options.emulate_subgroups) + // Shouldn't be reached. + SPIRV_CROSS_THROW("SubgroupId is handled specially with emulation."); if (!msl_options.supports_msl_version(2)) SPIRV_CROSS_THROW("Subgroup builtins require Metal 2.0."); return msl_options.is_ios() ? "quadgroup_index_in_threadgroup" : "simdgroup_index_in_threadgroup"; case BuiltInSubgroupLocalInvocationId: + if (msl_options.emulate_subgroups) + // Shouldn't be reached. + SPIRV_CROSS_THROW("SubgroupLocalInvocationId is handled specially with emulation."); if (execution.model == ExecutionModelFragment) { if (!msl_options.supports_msl_version(2, 2)) SPIRV_CROSS_THROW("thread_index_in_simdgroup requires Metal 2.2 in fragment shaders."); return "thread_index_in_simdgroup"; } - else + else if (execution.model == ExecutionModelKernel || execution.model == ExecutionModelGLCompute || + execution.model == ExecutionModelTessellationControl || + (execution.model == ExecutionModelVertex && msl_options.vertex_for_tessellation)) { + // We are generating a Metal kernel function. if (!msl_options.supports_msl_version(2)) - SPIRV_CROSS_THROW("Subgroup builtins require Metal 2.0."); + SPIRV_CROSS_THROW("Subgroup builtins in kernel functions require Metal 2.0."); return msl_options.is_ios() ? "thread_index_in_quadgroup" : "thread_index_in_simdgroup"; } + else + SPIRV_CROSS_THROW("Subgroup builtins are not available in this type of function."); case BuiltInSubgroupEqMask: case BuiltInSubgroupGeMask: @@ -12989,16 +14294,16 @@ string CompilerMSL::builtin_qualifier(BuiltIn builtin) case BuiltInBaryCoordNV: // TODO: AMD barycentrics as well? Seem to have different swizzle and 2 components rather than 3. - if (msl_options.is_ios()) - SPIRV_CROSS_THROW("Barycentrics not supported on iOS."); + if (msl_options.is_ios() && !msl_options.supports_msl_version(2, 3)) + SPIRV_CROSS_THROW("Barycentrics are only supported in MSL 2.3 and above on iOS."); else if (!msl_options.supports_msl_version(2, 2)) SPIRV_CROSS_THROW("Barycentrics are only supported in MSL 2.2 and above on macOS."); return "barycentric_coord, center_perspective"; case BuiltInBaryCoordNoPerspNV: // TODO: AMD barycentrics as well? Seem to have different swizzle and 2 components rather than 3. - if (msl_options.is_ios()) - SPIRV_CROSS_THROW("Barycentrics not supported on iOS."); + if (msl_options.is_ios() && !msl_options.supports_msl_version(2, 3)) + SPIRV_CROSS_THROW("Barycentrics are only supported in MSL 2.3 and above on iOS."); else if (!msl_options.supports_msl_version(2, 2)) SPIRV_CROSS_THROW("Barycentrics are only supported in MSL 2.2 and above on macOS."); return "barycentric_coord, center_no_perspective"; @@ -13032,6 +14337,7 @@ string CompilerMSL::builtin_type_decl(BuiltIn builtin, uint32_t id) // Vertex function out case BuiltInClipDistance: + case BuiltInCullDistance: return "float"; case BuiltInPointSize: return "float"; @@ -13329,10 +14635,6 @@ uint32_t CompilerMSL::get_declared_type_alignment_msl(const SPIRType &type, bool case SPIRType::Sampler: SPIRV_CROSS_THROW("Querying alignment of opaque object."); - case SPIRType::Int64: - SPIRV_CROSS_THROW("long types are not supported in buffers in MSL."); - case SPIRType::UInt64: - SPIRV_CROSS_THROW("ulong types are not supported in buffers in MSL."); case SPIRType::Double: SPIRV_CROSS_THROW("double types are not supported in buffers in MSL."); @@ -13347,6 +14649,10 @@ uint32_t CompilerMSL::get_declared_type_alignment_msl(const SPIRType &type, bool default: { + if (type.basetype == SPIRType::Int64 && !msl_options.supports_msl_version(2, 3)) + SPIRV_CROSS_THROW("long types in buffers are only supported in MSL 2.3 and above."); + if (type.basetype == SPIRType::UInt64 && !msl_options.supports_msl_version(2, 3)) + SPIRV_CROSS_THROW("ulong types in buffers are only supported in MSL 2.3 and above."); // Alignment of packed type is the same as the underlying component or column size. // Alignment of unpacked type is the same as the vector size. // Alignment of 3-elements vector is the same as 4-elements (including packed using column). @@ -13651,9 +14957,11 @@ CompilerMSL::SPVFuncImpl CompilerMSL::OpCodePreprocessor::get_spv_func_impl(Op o return SPVFuncImplMod; case OpFAdd: - if (compiler.msl_options.invariant_float_math) + case OpFSub: + if (compiler.msl_options.invariant_float_math || + compiler.has_decoration(args[1], DecorationNoContraction)) { - return SPVFuncImplFAdd; + return opcode == OpFAdd ? SPVFuncImplFAdd : SPVFuncImplFSub; } break; @@ -13662,7 +14970,8 @@ CompilerMSL::SPVFuncImpl CompilerMSL::OpCodePreprocessor::get_spv_func_impl(Op o case OpMatrixTimesVector: case OpVectorTimesMatrix: case OpMatrixTimesMatrix: - if (compiler.msl_options.invariant_float_math) + if (compiler.msl_options.invariant_float_math || + compiler.has_decoration(args[1], DecorationNoContraction)) { return SPVFuncImplFMul; } @@ -13875,30 +15184,25 @@ void CompilerMSL::MemberSorter::sort() } } -// Sort first by builtin status (put builtins at end), then by the sorting aspect. bool CompilerMSL::MemberSorter::operator()(uint32_t mbr_idx1, uint32_t mbr_idx2) { auto &mbr_meta1 = meta.members[mbr_idx1]; auto &mbr_meta2 = meta.members[mbr_idx2]; - if (mbr_meta1.builtin != mbr_meta2.builtin) - return mbr_meta2.builtin; - else - switch (sort_aspect) - { - case Location: + + if (sort_aspect == LocationThenBuiltInType) + { + // Sort first by builtin status (put builtins at end), then by the sorting aspect. + if (mbr_meta1.builtin != mbr_meta2.builtin) + return mbr_meta2.builtin; + else if (mbr_meta1.builtin) + return mbr_meta1.builtin_type < mbr_meta2.builtin_type; + else if (mbr_meta1.location == mbr_meta2.location) + return mbr_meta1.component < mbr_meta2.component; + else return mbr_meta1.location < mbr_meta2.location; - case LocationReverse: - return mbr_meta1.location > mbr_meta2.location; - case Offset: - return mbr_meta1.offset < mbr_meta2.offset; - case OffsetThenLocationReverse: - return (mbr_meta1.offset < mbr_meta2.offset) || - ((mbr_meta1.offset == mbr_meta2.offset) && (mbr_meta1.location > mbr_meta2.location)); - case Alphabetical: - return mbr_meta1.alias < mbr_meta2.alias; - default: - return false; - } + } + else + return mbr_meta1.offset < mbr_meta2.offset; } CompilerMSL::MemberSorter::MemberSorter(SPIRType &t, Meta &m, SortAspect sa) @@ -13977,14 +15281,36 @@ void CompilerMSL::cast_from_builtin_load(uint32_t source_id, std::string &expr, if (expected_type != expr_type.basetype) { - if (expected_width != expr_type.width) + if (!expr_type.array.empty() && (builtin == BuiltInTessLevelInner || builtin == BuiltInTessLevelOuter)) { - // These are of different widths, so we cannot do a straight bitcast. - expr = join(type_to_glsl(expr_type), "(", expr, ")"); + // Triggers when loading TessLevel directly as an array. + // Need explicit padding + cast. + auto wrap_expr = join(type_to_glsl(expr_type), "({ "); + + uint32_t array_size = get_physical_tess_level_array_size(builtin); + for (uint32_t i = 0; i < array_size; i++) + { + if (array_size > 1) + wrap_expr += join("float(", expr, "[", i, "])"); + else + wrap_expr += join("float(", expr, ")"); + if (i + 1 < array_size) + wrap_expr += ", "; + } + + if (get_execution_mode_bitset().get(ExecutionModeTriangles)) + wrap_expr += ", 0.0"; + + wrap_expr += " })"; + expr = std::move(wrap_expr); } else { - expr = bitcast_expression(expr_type, expected_type, expr); + // These are of different widths, so we cannot do a straight bitcast. + if (expected_width != expr_type.width) + expr = join(type_to_glsl(expr_type), "(", expr, ")"); + else + expr = bitcast_expression(expr_type, expected_type, expr); } } @@ -14084,6 +15410,17 @@ bool CompilerMSL::descriptor_set_is_argument_buffer(uint32_t desc_set) const return (argument_buffer_discrete_mask & (1u << desc_set)) == 0; } +bool CompilerMSL::is_supported_argument_buffer_type(const SPIRType &type) const +{ + // Very specifically, image load-store in argument buffers are disallowed on MSL on iOS. + // But we won't know when the argument buffer is encoded whether this image will have + // a NonWritable decoration. So just use discrete arguments for all storage images + // on iOS. + bool is_storage_image = type.basetype == SPIRType::Image && type.image.sampled == 2; + bool is_supported_type = !msl_options.is_ios() || !is_storage_image; + return !type_is_msl_framebuffer_fetch(type) && is_supported_type; +} + void CompilerMSL::analyze_argument_buffers() { // Gather all used resources and sort them out into argument buffers. @@ -14166,23 +15503,20 @@ void CompilerMSL::analyze_argument_buffers() { inline_block_vars.push_back(var_id); } - else if (!constexpr_sampler) + else if (!constexpr_sampler && is_supported_argument_buffer_type(type)) { // constexpr samplers are not declared as resources. // Inline uniform blocks are always emitted at the end. - if (!msl_options.is_ios() || type.basetype != SPIRType::Image || type.image.sampled != 2) - { - add_resource_name(var_id); - resources_in_set[desc_set].push_back( - { &var, to_name(var_id), type.basetype, get_metal_resource_index(var, type.basetype), 0 }); + add_resource_name(var_id); + resources_in_set[desc_set].push_back( + { &var, to_name(var_id), type.basetype, get_metal_resource_index(var, type.basetype), 0 }); - // Emulate texture2D atomic operations - if (atomic_image_vars.count(var.self)) - { - uint32_t buffer_resource_index = get_metal_resource_index(var, SPIRType::AtomicCounter, 0); - resources_in_set[desc_set].push_back( - { &var, to_name(var_id) + "_atomic", SPIRType::Struct, buffer_resource_index, 0 }); - } + // Emulate texture2D atomic operations + if (atomic_image_vars.count(var.self)) + { + uint32_t buffer_resource_index = get_metal_resource_index(var, SPIRType::AtomicCounter, 0); + resources_in_set[desc_set].push_back( + { &var, to_name(var_id) + "_atomic", SPIRType::Struct, buffer_resource_index, 0 }); } } @@ -14214,7 +15548,7 @@ void CompilerMSL::analyze_argument_buffers() // Create a buffer to hold extra data, including the swizzle constants. SPIRType uint_type_pointer = get_uint_type(); uint_type_pointer.pointer = true; - uint_type_pointer.pointer_depth = 1; + uint_type_pointer.pointer_depth++; uint_type_pointer.parent_type = get_uint_type_id(); uint_type_pointer.storage = StorageClassUniform; set(uint_ptr_type_id, uint_type_pointer); @@ -14288,7 +15622,7 @@ void CompilerMSL::analyze_argument_buffers() auto &ptr_type = set(ptr_type_id); ptr_type = buffer_type; ptr_type.pointer = true; - ptr_type.pointer_depth = 1; + ptr_type.pointer_depth++; ptr_type.parent_type = type_id; uint32_t buffer_variable_id = next_id; @@ -14301,10 +15635,63 @@ void CompilerMSL::analyze_argument_buffers() }); uint32_t member_index = 0; + uint32_t next_arg_buff_index = 0; for (auto &resource : resources) { auto &var = *resource.var; auto &type = get_variable_data_type(var); + + // If needed, synthesize and add padding members. + // member_index and next_arg_buff_index are incremented when padding members are added. + if (msl_options.pad_argument_buffer_resources) + { + while (resource.index > next_arg_buff_index) + { + auto &rez_bind = get_argument_buffer_resource(desc_set, next_arg_buff_index); + switch (rez_bind.basetype) + { + case SPIRType::Void: + case SPIRType::Boolean: + case SPIRType::SByte: + case SPIRType::UByte: + case SPIRType::Short: + case SPIRType::UShort: + case SPIRType::Int: + case SPIRType::UInt: + case SPIRType::Int64: + case SPIRType::UInt64: + case SPIRType::AtomicCounter: + case SPIRType::Half: + case SPIRType::Float: + case SPIRType::Double: + add_argument_buffer_padding_buffer_type(buffer_type, member_index, next_arg_buff_index, rez_bind); + break; + case SPIRType::Image: + add_argument_buffer_padding_image_type(buffer_type, member_index, next_arg_buff_index, rez_bind); + break; + case SPIRType::Sampler: + add_argument_buffer_padding_sampler_type(buffer_type, member_index, next_arg_buff_index, rez_bind); + break; + case SPIRType::SampledImage: + if (next_arg_buff_index == rez_bind.msl_sampler) + add_argument_buffer_padding_sampler_type(buffer_type, member_index, next_arg_buff_index, rez_bind); + else + add_argument_buffer_padding_image_type(buffer_type, member_index, next_arg_buff_index, rez_bind); + break; + default: + break; + } + } + + // Adjust the number of slots consumed by current member itself. + // If actual member is an array, allow runtime array resolution as well. + uint32_t elem_cnt = type.array.empty() ? 1 : to_array_size_literal(type); + if (elem_cnt == 0) + elem_cnt = get_resource_array_size(var.self); + + next_arg_buff_index += elem_cnt; + } + string mbr_name = ensure_valid_name(resource.name, "m"); if (resource.plane > 0) mbr_name += join(plane_name_suffix, resource.plane); @@ -14375,6 +15762,7 @@ void CompilerMSL::analyze_argument_buffers() set(atomic_type_id, atomic_type); atomic_type.pointer = true; + atomic_type.pointer_depth++; atomic_type.parent_type = atomic_type_id; atomic_type.storage = StorageClassStorageBuffer; auto &atomic_ptr_type = set(type_ptr_id, atomic_type); @@ -14402,6 +15790,125 @@ void CompilerMSL::analyze_argument_buffers() } } +// Return the resource type of the app-provided resources for the descriptor set, +// that matches the resource index of the argument buffer index. +// This is a two-step lookup, first lookup the resource binding number from the argument buffer index, +// then lookup the resource binding using the binding number. +MSLResourceBinding &CompilerMSL::get_argument_buffer_resource(uint32_t desc_set, uint32_t arg_idx) +{ + auto stage = get_entry_point().model; + StageSetBinding arg_idx_tuple = { stage, desc_set, arg_idx }; + auto arg_itr = resource_arg_buff_idx_to_binding_number.find(arg_idx_tuple); + if (arg_itr != end(resource_arg_buff_idx_to_binding_number)) + { + StageSetBinding bind_tuple = { stage, desc_set, arg_itr->second }; + auto bind_itr = resource_bindings.find(bind_tuple); + if (bind_itr != end(resource_bindings)) + return bind_itr->second.first; + } + SPIRV_CROSS_THROW("Argument buffer resource base type could not be determined. When padding argument buffer " + "elements, all descriptor set resources must be supplied with a base type by the app."); +} + +// Adds an argument buffer padding argument buffer type as one or more members of the struct type at the member index. +// Metal does not support arrays of buffers, so these are emitted as multiple struct members. +void CompilerMSL::add_argument_buffer_padding_buffer_type(SPIRType &struct_type, uint32_t &mbr_idx, + uint32_t &arg_buff_index, MSLResourceBinding &rez_bind) +{ + if (!argument_buffer_padding_buffer_type_id) + { + uint32_t buff_type_id = ir.increase_bound_by(2); + auto &buff_type = set(buff_type_id); + buff_type.basetype = rez_bind.basetype; + buff_type.storage = StorageClassUniformConstant; + + uint32_t ptr_type_id = buff_type_id + 1; + auto &ptr_type = set(ptr_type_id); + ptr_type = buff_type; + ptr_type.pointer = true; + ptr_type.pointer_depth++; + ptr_type.parent_type = buff_type_id; + + argument_buffer_padding_buffer_type_id = ptr_type_id; + } + + for (uint32_t rez_idx = 0; rez_idx < rez_bind.count; rez_idx++) + add_argument_buffer_padding_type(argument_buffer_padding_buffer_type_id, struct_type, mbr_idx, arg_buff_index, 1); +} + +// Adds an argument buffer padding argument image type as a member of the struct type at the member index. +void CompilerMSL::add_argument_buffer_padding_image_type(SPIRType &struct_type, uint32_t &mbr_idx, + uint32_t &arg_buff_index, MSLResourceBinding &rez_bind) +{ + if (!argument_buffer_padding_image_type_id) + { + uint32_t base_type_id = ir.increase_bound_by(2); + auto &base_type = set(base_type_id); + base_type.basetype = SPIRType::Float; + base_type.width = 32; + + uint32_t img_type_id = base_type_id + 1; + auto &img_type = set(img_type_id); + img_type.basetype = SPIRType::Image; + img_type.storage = StorageClassUniformConstant; + + img_type.image.type = base_type_id; + img_type.image.dim = Dim2D; + img_type.image.depth = false; + img_type.image.arrayed = false; + img_type.image.ms = false; + img_type.image.sampled = 1; + img_type.image.format = ImageFormatUnknown; + img_type.image.access = AccessQualifierMax; + + argument_buffer_padding_image_type_id = img_type_id; + } + + add_argument_buffer_padding_type(argument_buffer_padding_image_type_id, struct_type, mbr_idx, arg_buff_index, rez_bind.count); +} + +// Adds an argument buffer padding argument sampler type as a member of the struct type at the member index. +void CompilerMSL::add_argument_buffer_padding_sampler_type(SPIRType &struct_type, uint32_t &mbr_idx, + uint32_t &arg_buff_index, MSLResourceBinding &rez_bind) +{ + if (!argument_buffer_padding_sampler_type_id) + { + uint32_t samp_type_id = ir.increase_bound_by(1); + auto &samp_type = set(samp_type_id); + samp_type.basetype = SPIRType::Sampler; + samp_type.storage = StorageClassUniformConstant; + + argument_buffer_padding_sampler_type_id = samp_type_id; + } + + add_argument_buffer_padding_type(argument_buffer_padding_sampler_type_id, struct_type, mbr_idx, arg_buff_index, rez_bind.count); +} + +// Adds the argument buffer padding argument type as a member of the struct type at the member index. +// Advances both arg_buff_index and mbr_idx to next argument slots. +void CompilerMSL::add_argument_buffer_padding_type(uint32_t mbr_type_id, SPIRType &struct_type, uint32_t &mbr_idx, + uint32_t &arg_buff_index, uint32_t count) +{ + uint32_t type_id = mbr_type_id; + if (count > 1) + { + uint32_t ary_type_id = ir.increase_bound_by(1); + auto &ary_type = set(ary_type_id); + ary_type = get(type_id); + ary_type.array.push_back(count); + ary_type.array_size_literal.push_back(true); + ary_type.parent_type = type_id; + type_id = ary_type_id; + } + + set_member_name(struct_type.self, mbr_idx, join("_m", arg_buff_index, "_pad")); + set_extended_member_decoration(struct_type.self, mbr_idx, SPIRVCrossDecorationResourceIndexPrimary, arg_buff_index); + struct_type.member_types.push_back(type_id); + + arg_buff_index += count; + mbr_idx++; +} + void CompilerMSL::activate_argument_buffer_resources() { // For ABI compatibility, force-enable all resources which are part of argument buffers. diff --git a/third_party/spirv-cross/spirv_msl.hpp b/third_party/spirv-cross/spirv_msl.hpp index a26047e041..61f54be1a5 100644 --- a/third_party/spirv-cross/spirv_msl.hpp +++ b/third_party/spirv-cross/spirv_msl.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 The Brenwill Workshop Ltd. + * Copyright 2016-2021 The Brenwill Workshop Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #ifndef SPIRV_CROSS_MSL_HPP #define SPIRV_CROSS_MSL_HPP @@ -64,15 +71,23 @@ struct MSLShaderInput // resources consumed by this binding, if the binding represents an array of resources. // If the resource array is a run-time-sized array, which are legal in GLSL or SPIR-V, this value // will be used to declare the array size in MSL, which does not support run-time-sized arrays. -// For resources that are not held in a run-time-sized array, the count field does not need to be populated. +// If pad_argument_buffer_resources is enabled, the base_type and count values are used to +// specify the base type and array size of the resource in the argument buffer, if that resource +// is not defined and used by the shader. With pad_argument_buffer_resources enabled, this +// information will be used to pad the argument buffer structure, in order to align that +// structure consistently for all uses, across all shaders, of the descriptor set represented +// by the arugment buffer. If pad_argument_buffer_resources is disabled, base_type does not +// need to be populated, and if the resource is also not a run-time sized array, the count +// field does not need to be populated. // If using MSL 2.0 argument buffers, the descriptor set is not marked as a discrete descriptor set, // and (for iOS only) the resource is not a storage image (sampled != 2), the binding reference we // remap to will become an [[id(N)]] attribute within the "descriptor set" argument buffer structure. -// For resources which are bound in the "classic" MSL 1.0 way or discrete descriptors, the remap will become a -// [[buffer(N)]], [[texture(N)]] or [[sampler(N)]] depending on the resource types used. +// For resources which are bound in the "classic" MSL 1.0 way or discrete descriptors, the remap will +// become a [[buffer(N)]], [[texture(N)]] or [[sampler(N)]] depending on the resource types used. struct MSLResourceBinding { spv::ExecutionModel stage = spv::ExecutionModelMax; + SPIRType::BaseType basetype = SPIRType::Unknown; uint32_t desc_set = 0; uint32_t binding = 0; uint32_t count = 0; @@ -339,6 +354,19 @@ public: // and would otherwise declare a different IAB. bool force_active_argument_buffer_resources = false; + // Aligns each resource in an argument buffer to its assigned index value, id(N), + // by adding synthetic padding members in the argument buffer struct for any resources + // in the argument buffer that are not defined and used by the shader. This allows + // the shader to index into the correct argument in a descriptor set argument buffer + // that is shared across shaders, where not all resources in the argument buffer are + // defined in each shader. For this to work, an MSLResourceBinding must be provided for + // all descriptors in any descriptor set held in an argument buffer in the shader, and + // that MSLResourceBinding must have the basetype and count members populated correctly. + // The implementation here assumes any inline blocks in the argument buffer is provided + // in a Metal buffer, and doesn't take into consideration inline blocks that are + // optionally embedded directly into the argument buffer via add_inline_uniform_block(). + bool pad_argument_buffer_resources = false; + // Forces the use of plain arrays, which works around certain driver bugs on certain versions // of Intel Macbooks. See https://github.com/KhronosGroup/SPIRV-Cross/issues/1210. // May reduce performance in scenarios where arrays are copied around as value-types. @@ -364,6 +392,28 @@ public: // and will be addressed using the current ViewIndex. bool arrayed_subpass_input = false; + // Whether to use SIMD-group or quadgroup functions to implement group nnon-uniform + // operations. Some GPUs on iOS do not support the SIMD-group functions, only the + // quadgroup functions. + bool ios_use_simdgroup_functions = false; + + // If set, the subgroup size will be assumed to be one, and subgroup-related + // builtins and operations will be emitted accordingly. This mode is intended to + // be used by MoltenVK on hardware/software configurations which do not provide + // sufficient support for subgroups. + bool emulate_subgroups = false; + + // If nonzero, a fixed subgroup size to assume. Metal, similarly to VK_EXT_subgroup_size_control, + // allows the SIMD-group size (aka thread execution width) to vary depending on + // register usage and requirements. In certain circumstances--for example, a pipeline + // in MoltenVK without VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT-- + // this is undesirable. This fixes the value of the SubgroupSize builtin, instead of + // mapping it to the Metal builtin [[thread_execution_width]]. If the thread + // execution width is reduced, the extra invocations will appear to be inactive. + // If zero, the SubgroupSize will be allowed to vary, and the builtin will be mapped + // to the Metal [[thread_execution_width]] builtin. + uint32_t fixed_subgroup_size = 0; + enum class IndexType { None = 0, @@ -379,6 +429,11 @@ public: // different shaders for these three scenarios. IndexType vertex_index_type = IndexType::None; + // If set, a dummy [[sample_id]] input is added to a fragment shader if none is present. + // This will force the shader to run at sample rate, assuming Metal does not optimize + // the extra threads away. + bool force_sample_rate_shading = false; + bool is_ios() const { return platform == iOS; @@ -516,6 +571,13 @@ public: // Query after compilation is done. This allows you to check if an input location was used by the shader. bool is_msl_shader_input_used(uint32_t location); + // If not using add_msl_shader_input, it's possible + // that certain builtin attributes need to be automatically assigned locations. + // This is typical for tessellation builtin inputs such as tess levels, gl_Position, etc. + // This returns k_unknown_location if the location was explicitly assigned with + // add_msl_shader_input or the builtin is not used, otherwise returns N in [[attribute(N)]]. + uint32_t get_automatic_builtin_input_location(spv::BuiltIn builtin) const; + // NOTE: Only resources which are remapped using add_msl_resource_binding will be reported here. // Constexpr samplers are always assumed to be emitted. // No specific MSLResourceBinding remapping is required for constexpr samplers as long as they are remapped @@ -533,6 +595,7 @@ public: // Same as get_automatic_msl_resource_binding, but should only be used for combined image samplers, in which case the // sampler's binding is returned instead. For any other resource type, -1 is returned. + // Secondary bindings are also used for the auxillary image atomic buffer. uint32_t get_automatic_msl_resource_binding_secondary(uint32_t id) const; // Same as get_automatic_msl_resource_binding, but should only be used for combined image samplers for multiplanar images, @@ -592,6 +655,7 @@ protected: SPVFuncImplImage2DAtomicCoords, // Emulate texture2D atomic operations SPVFuncImplFMul, SPVFuncImplFAdd, + SPVFuncImplFSub, SPVFuncImplCubemapTo2DArrayFace, SPVFuncImplUnsafeArray, // Allow Metal to use the array template to make arrays a value type SPVFuncImplInverse4x4, @@ -673,6 +737,8 @@ protected: // Threadgroup arrays can't have a wrapper type std::string variable_decl(const SPIRVariable &variable) override; + bool variable_decl_is_remapped_storage(const SPIRVariable &variable, spv::StorageClass storage) const override; + // GCC workaround of lambdas calling protected functions (for older GCC versions) std::string variable_decl(const SPIRType &type, const std::string &name, uint32_t id = 0) override; @@ -701,6 +767,12 @@ protected: void declare_undefined_values() override; void declare_constant_arrays(); + void replace_illegal_entry_point_names(); + void sync_entry_point_aliases_and_names(); + + static const std::unordered_set &get_reserved_keyword_set(); + static const std::unordered_set &get_illegal_func_names(); + // Constant arrays of non-primitive types (i.e. matrices) won't link properly into Metal libraries void declare_complex_constant_arrays(); @@ -727,33 +799,44 @@ protected: { struct LocationMeta { + uint32_t base_type_id = 0; uint32_t num_components = 0; - uint32_t ib_index = ~0u; + bool flat = false; + bool noperspective = false; + bool centroid = false; + bool sample = false; }; std::unordered_map location_meta; bool strip_array = false; + bool allow_local_declaration = false; }; + std::string to_tesc_invocation_id(); + void emit_local_masked_variable(const SPIRVariable &masked_var, bool strip_array); void add_variable_to_interface_block(spv::StorageClass storage, const std::string &ib_var_ref, SPIRType &ib_type, SPIRVariable &var, InterfaceBlockMeta &meta); void add_composite_variable_to_interface_block(spv::StorageClass storage, const std::string &ib_var_ref, SPIRType &ib_type, SPIRVariable &var, InterfaceBlockMeta &meta); void add_plain_variable_to_interface_block(spv::StorageClass storage, const std::string &ib_var_ref, SPIRType &ib_type, SPIRVariable &var, InterfaceBlockMeta &meta); + bool add_component_variable_to_interface_block(spv::StorageClass storage, const std::string &ib_var_ref, + SPIRVariable &var, const SPIRType &type, + InterfaceBlockMeta &meta); void add_plain_member_variable_to_interface_block(spv::StorageClass storage, const std::string &ib_var_ref, SPIRType &ib_type, SPIRVariable &var, uint32_t index, InterfaceBlockMeta &meta); void add_composite_member_variable_to_interface_block(spv::StorageClass storage, const std::string &ib_var_ref, SPIRType &ib_type, SPIRVariable &var, uint32_t index, InterfaceBlockMeta &meta); - uint32_t get_accumulated_member_location(const SPIRVariable &var, uint32_t mbr_idx, bool strip_array); void add_tess_level_input_to_interface_block(const std::string &ib_var_ref, SPIRType &ib_type, SPIRVariable &var); void fix_up_interface_member_indices(spv::StorageClass storage, uint32_t ib_type_id); - void mark_location_as_used_by_shader(uint32_t location, const SPIRType &type, spv::StorageClass storage); + void mark_location_as_used_by_shader(uint32_t location, const SPIRType &type, + spv::StorageClass storage, bool fallback = false); uint32_t ensure_correct_builtin_type(uint32_t type_id, spv::BuiltIn builtin); - uint32_t ensure_correct_input_type(uint32_t type_id, uint32_t location, uint32_t num_components = 0); + uint32_t ensure_correct_input_type(uint32_t type_id, uint32_t location, + uint32_t num_components, bool strip_array); void emit_custom_templates(); void emit_custom_functions(); @@ -776,6 +859,7 @@ protected: std::string to_sampler_expression(uint32_t id); std::string to_swizzle_expression(uint32_t id); std::string to_buffer_size_expression(uint32_t id); + bool is_sample_rate() const; bool is_direct_input_builtin(spv::BuiltIn builtin); std::string builtin_qualifier(spv::BuiltIn builtin); std::string builtin_type_decl(spv::BuiltIn builtin, uint32_t id = 0); @@ -784,7 +868,11 @@ protected: std::string argument_decl(const SPIRFunction::Parameter &arg); std::string round_fp_tex_coords(std::string tex_coords, bool coord_is_fp); uint32_t get_metal_resource_index(SPIRVariable &var, SPIRType::BaseType basetype, uint32_t plane = 0); - uint32_t get_ordered_member_location(uint32_t type_id, uint32_t index, uint32_t *comp = nullptr); + uint32_t get_member_location(uint32_t type_id, uint32_t index, uint32_t *comp = nullptr) const; + uint32_t get_or_allocate_builtin_input_member_location(spv::BuiltIn builtin, + uint32_t type_id, uint32_t index, uint32_t *comp = nullptr); + + uint32_t get_physical_tess_level_array_size(spv::BuiltIn builtin) const; // MSL packing rules. These compute the effective packing rules as observed by the MSL compiler in the MSL output. // These values can change depending on various extended decorations which control packing rules. @@ -833,8 +921,8 @@ protected: void add_pragma_line(const std::string &line); void add_typedef_line(const std::string &line); void emit_barrier(uint32_t id_exe_scope, uint32_t id_mem_scope, uint32_t id_mem_sem); - void emit_array_copy(const std::string &lhs, uint32_t rhs_id, spv::StorageClass lhs_storage, - spv::StorageClass rhs_storage) override; + void emit_array_copy(const std::string &lhs, uint32_t lhs_id, uint32_t rhs_id, + spv::StorageClass lhs_storage, spv::StorageClass rhs_storage) override; void build_implicit_builtins(); uint32_t build_constant_uint_array_pointer(); void emit_entry_point_declarations() override; @@ -853,11 +941,16 @@ protected: uint32_t builtin_subgroup_size_id = 0; uint32_t builtin_dispatch_base_id = 0; uint32_t builtin_stage_input_size_id = 0; + uint32_t builtin_local_invocation_index_id = 0; + uint32_t builtin_workgroup_size_id = 0; uint32_t swizzle_buffer_id = 0; uint32_t buffer_size_buffer_id = 0; uint32_t view_mask_buffer_id = 0; uint32_t dynamic_offsets_buffer_id = 0; uint32_t uint_type_id = 0; + uint32_t argument_buffer_padding_buffer_type_id = 0; + uint32_t argument_buffer_padding_image_type_id = 0; + uint32_t argument_buffer_padding_sampler_type_id = 0; bool does_shader_write_sample_mask = false; @@ -867,6 +960,7 @@ protected: void analyze_sampled_image_usage(); + bool access_chain_needs_stage_io_builtin_translation(uint32_t base) override; void prepare_access_chain_for_scalar_access(std::string &expr, const SPIRType &type, spv::StorageClass storage, bool &is_packed) override; void fix_up_interpolant_access_chain(const uint32_t *ops, uint32_t length); @@ -885,13 +979,16 @@ protected: // Must be ordered to ensure declarations are in a specific order. std::map inputs_by_location; std::unordered_map inputs_by_builtin; - std::unordered_set inputs_in_use; + std::unordered_set location_inputs_in_use; + std::unordered_set location_inputs_in_use_fallback; std::unordered_map fragment_output_components; + std::unordered_map builtin_to_automatic_input_location; std::set pragma_lines; std::set typedef_lines; SmallVector vars_needing_early_declaration; std::unordered_map, InternalHasher> resource_bindings; + std::unordered_map resource_arg_buff_idx_to_binding_number; uint32_t next_metal_resource_index_buffer = 0; uint32_t next_metal_resource_index_texture = 0; @@ -905,6 +1002,7 @@ protected: VariableID patch_stage_out_var_id = 0; VariableID stage_in_ptr_var_id = 0; VariableID stage_out_ptr_var_id = 0; + VariableID stage_out_masked_builtin_type_id = 0; // Handle HLSL-style 0-based vertex/instance index. enum class TriState @@ -970,6 +1068,11 @@ protected: void analyze_argument_buffers(); bool descriptor_set_is_argument_buffer(uint32_t desc_set) const; + MSLResourceBinding &get_argument_buffer_resource(uint32_t desc_set, uint32_t arg_idx); + void add_argument_buffer_padding_buffer_type(SPIRType &struct_type, uint32_t &mbr_idx, uint32_t &arg_buff_index, MSLResourceBinding &rez_bind); + void add_argument_buffer_padding_image_type(SPIRType &struct_type, uint32_t &mbr_idx, uint32_t &arg_buff_index, MSLResourceBinding &rez_bind); + void add_argument_buffer_padding_sampler_type(SPIRType &struct_type, uint32_t &mbr_idx, uint32_t &arg_buff_index, MSLResourceBinding &rez_bind); + void add_argument_buffer_padding_type(uint32_t mbr_type_id, SPIRType &struct_type, uint32_t &mbr_idx, uint32_t &arg_buff_index, uint32_t count); uint32_t get_target_components_for_fragment_location(uint32_t location) const; uint32_t build_extended_vector_type(uint32_t type_id, uint32_t components, @@ -983,6 +1086,11 @@ protected: void activate_argument_buffer_resources(); bool type_is_msl_framebuffer_fetch(const SPIRType &type) const; + bool type_is_pointer(const SPIRType &type) const; + bool type_is_pointer_to_pointer(const SPIRType &type) const; + bool is_supported_argument_buffer_type(const SPIRType &type) const; + + bool variable_storage_requires_stage_io(spv::StorageClass storage) const; // OpcodeHandler that handles several MSL preprocessing operations. struct OpCodePreprocessor : OpcodeHandler @@ -1027,11 +1135,8 @@ protected: { enum SortAspect { - Location, - LocationReverse, - Offset, - OffsetThenLocationReverse, - Alphabetical + LocationThenBuiltInType, + Offset }; void sort(); diff --git a/third_party/spirv-cross/spirv_parser.cpp b/third_party/spirv-cross/spirv_parser.cpp index 92db5287ab..86f7fd3500 100644 --- a/third_party/spirv-cross/spirv_parser.cpp +++ b/third_party/spirv-cross/spirv_parser.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2018-2020 Arm Limited + * Copyright 2018-2021 Arm Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #include "spirv_parser.hpp" #include @@ -133,6 +140,8 @@ void Parser::parse() SPIRV_CROSS_THROW("Function was not terminated."); if (current_block) SPIRV_CROSS_THROW("Block was not terminated."); + if (ir.default_entry_point == 0) + SPIRV_CROSS_THROW("There is no entry point in the SPIR-V module."); } const uint32_t *Parser::stream(const Instruction &instr) const @@ -720,7 +729,7 @@ void Parser::parse(const Instruction &instruction) break; } - case OpTypeRayQueryProvisionalKHR: + case OpTypeRayQueryKHR: { uint32_t id = ops[0]; auto &type = set(id); @@ -985,6 +994,22 @@ void Parser::parse(const Instruction &instruction) break; } + case OpTerminateRayKHR: + // NV variant is not a terminator. + if (!current_block) + SPIRV_CROSS_THROW("Trying to end a non-existing block."); + current_block->terminator = SPIRBlock::TerminateRay; + current_block = nullptr; + break; + + case OpIgnoreIntersectionKHR: + // NV variant is not a terminator. + if (!current_block) + SPIRV_CROSS_THROW("Trying to end a non-existing block."); + current_block->terminator = SPIRBlock::IgnoreIntersection; + current_block = nullptr; + break; + case OpReturn: { if (!current_block) diff --git a/third_party/spirv-cross/spirv_parser.hpp b/third_party/spirv-cross/spirv_parser.hpp index 7b3eddeddc..7f4a7d856f 100644 --- a/third_party/spirv-cross/spirv_parser.hpp +++ b/third_party/spirv-cross/spirv_parser.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2018-2020 Arm Limited + * Copyright 2018-2021 Arm Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #ifndef SPIRV_CROSS_PARSER_HPP #define SPIRV_CROSS_PARSER_HPP diff --git a/third_party/spirv-cross/spirv_reflect.cpp b/third_party/spirv-cross/spirv_reflect.cpp index dbe837f2a4..447bff1c9e 100644 --- a/third_party/spirv-cross/spirv_reflect.cpp +++ b/third_party/spirv-cross/spirv_reflect.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2018-2020 Bradley Austin Davis + * Copyright 2018-2021 Bradley Austin Davis * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #include "spirv_reflect.hpp" #include "spirv_glsl.hpp" #include diff --git a/third_party/spirv-cross/spirv_reflect.hpp b/third_party/spirv-cross/spirv_reflect.hpp index 9f60e72ee3..8acbd2804d 100644 --- a/third_party/spirv-cross/spirv_reflect.hpp +++ b/third_party/spirv-cross/spirv_reflect.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2018-2020 Bradley Austin Davis + * Copyright 2018-2021 Bradley Austin Davis * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,13 @@ * 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 . + * SPDX-License-Identifier: Apache-2.0 OR MIT. + */ + #ifndef SPIRV_CROSS_REFLECT_HPP #define SPIRV_CROSS_REFLECT_HPP diff --git a/third_party/spirv-cross/test_shaders.py b/third_party/spirv-cross/test_shaders.py index 119617a76b..9e3b8e4424 100755 --- a/third_party/spirv-cross/test_shaders.py +++ b/third_party/spirv-cross/test_shaders.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Copyright 2015-2020 Arm Limited +# Copyright 2015-2021 Arm Limited # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -100,10 +100,11 @@ def get_shader_stats(shader): def print_msl_compiler_version(): try: subprocess.check_call(['xcrun', '--sdk', 'iphoneos', 'metal', '--version']) - print('...are the Metal compiler characteristics.\n') # display after so xcrun FNF is silent + print('... are the Metal compiler characteristics.\n') # display after so xcrun FNF is silent except OSError as e: if (e.errno != errno.ENOENT): # Ignore xcrun not found error raise + print('Metal SDK is not present.\n') except subprocess.CalledProcessError: pass @@ -203,9 +204,12 @@ def cross_compile_msl(shader, spirv, opt, iterations, paths): spirv_cross_path = paths.spirv_cross - msl_args = [spirv_cross_path, '--entry', 'main', '--output', msl_path, spirv_path, '--msl', '--iterations', str(iterations)] + msl_args = [spirv_cross_path, '--output', msl_path, spirv_path, '--msl', '--iterations', str(iterations)] msl_args.append('--msl-version') msl_args.append(path_to_msl_standard_cli(shader)) + if not '.nomain.' in shader: + msl_args.append('--entry') + msl_args.append('main') if '.swizzle.' in shader: msl_args.append('--msl-swizzle-texture-samples') if '.ios.' in shader: @@ -308,6 +312,35 @@ def cross_compile_msl(shader, spirv, opt, iterations, paths): msl_args.append('--msl-arrayed-subpass-input') if '.1d-as-2d.' in shader: msl_args.append('--msl-texture-1d-as-2d') + if '.simd.' in shader: + msl_args.append('--msl-ios-use-simdgroup-functions') + if '.emulate-subgroup.' in shader: + msl_args.append('--msl-emulate-subgroups') + if '.fixed-subgroup.' in shader: + # Arbitrary for testing purposes. + msl_args.append('--msl-fixed-subgroup-size') + msl_args.append('32') + if '.force-sample.' in shader: + msl_args.append('--msl-force-sample-rate-shading') + if '.decoration-binding.' in shader: + msl_args.append('--msl-decoration-binding') + if '.mask-location-0.' in shader: + msl_args.append('--mask-stage-output-location') + msl_args.append('0') + msl_args.append('0') + if '.mask-location-1.' in shader: + msl_args.append('--mask-stage-output-location') + msl_args.append('1') + msl_args.append('0') + if '.mask-position.' in shader: + msl_args.append('--mask-stage-output-builtin') + msl_args.append('Position') + if '.mask-point-size.' in shader: + msl_args.append('--mask-stage-output-builtin') + msl_args.append('PointSize') + if '.mask-clip-distance.' in shader: + msl_args.append('--mask-stage-output-builtin') + msl_args.append('ClipDistance') subprocess.check_call(msl_args) @@ -398,7 +431,8 @@ def cross_compile_hlsl(shader, spirv, opt, force_no_external_validation, iterati spirv_path = create_temporary() hlsl_path = create_temporary(os.path.basename(shader)) - spirv_cmd = [paths.spirv_as, '--target-env', 'vulkan1.1', '-o', spirv_path, shader] + spirv_env = 'vulkan1.1spv1.4' if '.spv14.' in shader else 'vulkan1.1' + spirv_cmd = [paths.spirv_as, '--target-env', spirv_env, '-o', spirv_path, shader] if '.preserve.' in shader: spirv_cmd.append('--preserve-numeric-ids') @@ -431,7 +465,7 @@ def cross_compile_hlsl(shader, spirv, opt, force_no_external_validation, iterati subprocess.check_call(hlsl_args) if not shader_is_invalid_spirv(hlsl_path): - subprocess.check_call([paths.spirv_val, '--scalar-block-layout', '--target-env', 'vulkan1.1', spirv_path]) + subprocess.check_call([paths.spirv_val, '--scalar-block-layout', '--target-env', spirv_env, spirv_path]) validate_shader_hlsl(hlsl_path, force_no_external_validation, paths) @@ -461,7 +495,9 @@ def cross_compile_reflect(shader, spirv, opt, iterations, paths): def validate_shader(shader, vulkan, paths): if vulkan: - subprocess.check_call([paths.glslang, '--amb', '--target-env', 'vulkan1.1', '-V', shader]) + spirv_14 = '.spv14.' in shader + glslang_env = 'spirv1.4' if spirv_14 else 'vulkan1.1' + subprocess.check_call([paths.glslang, '--amb', '--target-env', glslang_env, '-V', shader]) else: subprocess.check_call([paths.glslang, shader]) @@ -469,7 +505,8 @@ def cross_compile(shader, vulkan, spirv, invalid_spirv, eliminate, is_legacy, fl spirv_path = create_temporary() glsl_path = create_temporary(os.path.basename(shader)) - spirv_env = 'vulkan1.1spv1.4' if ('.spv14.' in shader) else 'vulkan1.1' + spirv_14 = '.spv14.' in shader + spirv_env = 'vulkan1.1spv1.4' if spirv_14 else 'vulkan1.1' if vulkan or spirv: vulkan_glsl_path = create_temporary('vk' + os.path.basename(shader)) @@ -481,7 +518,8 @@ def cross_compile(shader, vulkan, spirv, invalid_spirv, eliminate, is_legacy, fl if spirv: subprocess.check_call(spirv_cmd) else: - subprocess.check_call([paths.glslang, '--amb', '--target-env', 'vulkan1.1', '-V', '-o', spirv_path, shader]) + glslang_env = 'spirv1.4' if spirv_14 else 'vulkan1.1' + subprocess.check_call([paths.glslang, '--amb', '--target-env', glslang_env, '-V', '-o', spirv_path, shader]) if opt and (not invalid_spirv): subprocess.check_call([paths.spirv_opt, '--skip-validation', '-O', '-o', spirv_path, spirv_path]) @@ -513,6 +551,8 @@ def cross_compile(shader, vulkan, spirv, invalid_spirv, eliminate, is_legacy, fl extra_args += ['--glsl-remap-ext-framebuffer-fetch', '1', '1'] extra_args += ['--glsl-remap-ext-framebuffer-fetch', '2', '2'] extra_args += ['--glsl-remap-ext-framebuffer-fetch', '3', '3'] + if '.framebuffer-fetch-noncoherent.' in shader: + extra_args += ['--glsl-ext-framebuffer-fetch-noncoherent'] if '.zero-initialize.' in shader: extra_args += ['--force-zero-initialized-variables'] if '.force-flattened-io.' in shader: @@ -530,7 +570,7 @@ def cross_compile(shader, vulkan, spirv, invalid_spirv, eliminate, is_legacy, fl glsl_path = None if (vulkan or spirv) and (not is_legacy): - subprocess.check_call([spirv_cross_path, '--entry', 'main', '--vulkan-semantics', '--output', vulkan_glsl_path, spirv_path] + extra_args) + subprocess.check_call([spirv_cross_path, '--entry', 'main', '-V', '--output', vulkan_glsl_path, spirv_path] + extra_args) validate_shader(vulkan_glsl_path, True, paths) # SPIR-V shaders might just want to validate Vulkan GLSL output, we don't always care about the output. if not vulkan: diff --git a/third_party/spirv-cross/tests-other/small_vector.cpp b/third_party/spirv-cross/tests-other/small_vector.cpp index 9a3ab79180..e9a3bb0bee 100644 --- a/third_party/spirv-cross/tests-other/small_vector.cpp +++ b/third_party/spirv-cross/tests-other/small_vector.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2019-2020 Hans-Kristian Arntzen + * Copyright 2019-2021 Hans-Kristian Arntzen * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.