diff --git a/README.md b/README.md index 657972b470af..b7d25a426449 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ repositories { } dependencies { - implementation 'com.google.android.filament:filament-android:1.77.0' + implementation 'com.google.android.filament:filament-android:1.77.1' } ``` @@ -50,7 +50,7 @@ Here are all the libraries available in the group `com.google.android.filament`: iOS projects can use CocoaPods to install the latest release: ```shell -pod 'Filament', '~> 1.77.0' +pod 'Filament', '~> 1.77.1' ``` ## Documentation diff --git a/android/gradle.properties b/android/gradle.properties index fc2386d5814d..95de1c186942 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.google.android.filament -VERSION_NAME=1.77.0 +VERSION_NAME=1.77.1 POM_DESCRIPTION=Real-time physically based rendering engine for Android. diff --git a/filament/backend/src/opengl/OpenGLContext.cpp b/filament/backend/src/opengl/OpenGLContext.cpp index a83a846d9aa8..669fd0bf88a6 100644 --- a/filament/backend/src/opengl/OpenGLContext.cpp +++ b/filament/backend/src/opengl/OpenGLContext.cpp @@ -99,8 +99,6 @@ OpenGLContext::OpenGLContext(OpenGLPlatform& platform, initBugs(&bugs, ext, major, minor, vendor, renderer, version, shader); - initWorkarounds(bugs, &ext); - glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &gets.max_renderbuffer_size); glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &gets.max_texture_image_units); glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &gets.max_combined_texture_image_units); @@ -111,6 +109,8 @@ OpenGLContext::OpenGLContext(OpenGLPlatform& platform, mFeatureLevel = resolveFeatureLevel(major, minor, ext, gets, bugs); + initWorkarounds(bugs, &ext, mFeatureLevel); + #ifdef BACKEND_OPENGL_VERSION_GLES mShaderModel = ShaderModel::MOBILE; #else @@ -559,12 +559,22 @@ void OpenGLContext::initBugs(Bugs* bugs, Extensions const& exts, // feedback loops are allowed on GL desktop as long as writes are disabled bugs->allow_read_only_ancillary_feedback_loop = true; #endif + +#ifndef __EMSCRIPTEN__ + // ES 2.0 support for sRGB is buggy on most mobile devices, and so we disable it outside of wasm + // builds. + bugs->disable_es2_srgb_ext = true; +#endif } -void OpenGLContext::initWorkarounds(Bugs const& bugs, Extensions* ext) { +void OpenGLContext::initWorkarounds(Bugs const& bugs, Extensions* ext, + FeatureLevel const featureLevel) { if (bugs.disable_framebuffer_fetch_extension) { ext->EXT_shader_framebuffer_fetch = false; } + if (featureLevel == FeatureLevel::FEATURE_LEVEL_0 && bugs.disable_es2_srgb_ext) { + ext->EXT_texture_sRGB = false; + } } FeatureLevel OpenGLContext::resolveFeatureLevel(GLint major, GLint minor, diff --git a/filament/backend/src/opengl/OpenGLContext.h b/filament/backend/src/opengl/OpenGLContext.h index 7452bf308a7e..fcc78214a8c3 100644 --- a/filament/backend/src/opengl/OpenGLContext.h +++ b/filament/backend/src/opengl/OpenGLContext.h @@ -296,6 +296,9 @@ class OpenGLContext final { // Some Mali drivers also have problems with this (b/445721121) bool disable_framebuffer_fetch_extension; + // Some drivers have issues with GL_EXT_sRGB on ES2.0 + bool disable_es2_srgb_ext; + } bugs = {}; struct Procs { @@ -390,6 +393,9 @@ class OpenGLContext final { { bugs.disable_framebuffer_fetch_extension, "disable_framebuffer_fetch_extension", ""}, + { bugs.disable_es2_srgb_ext, + "disable_es2_srgb_ext", + ""}, }}; // this is chosen to minimize code size @@ -420,7 +426,7 @@ class OpenGLContext final { static void initProcs(Procs* procs, Extensions const& exts, GLint major, GLint minor) noexcept; - static void initWorkarounds(Bugs const& bugs, Extensions* ext); + static void initWorkarounds(Bugs const& bugs, Extensions* ext, FeatureLevel const featureLevel); static FeatureLevel resolveFeatureLevel(GLint major, GLint minor, Extensions const& exts, diff --git a/filament/backend/src/vulkan/VulkanSwapChain.cpp b/filament/backend/src/vulkan/VulkanSwapChain.cpp index 1f0b3ff31653..6591059e6160 100644 --- a/filament/backend/src/vulkan/VulkanSwapChain.cpp +++ b/filament/backend/src/vulkan/VulkanSwapChain.cpp @@ -19,6 +19,7 @@ #include "VulkanCommands.h" #include "VulkanTexture.h" +#include #include #include #include @@ -140,7 +141,7 @@ void VulkanSwapChain::present(DriverBase& driver) { VkResult const result = mPlatform->present(swapChain, mCurrentSwapIndex, finishedDrawing->getVkSemaphore()); FILAMENT_CHECK_POSTCONDITION(result == VK_SUCCESS || result == VK_SUBOPTIMAL_KHR || - result == VK_ERROR_OUT_OF_DATE_KHR) + result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_ERROR_SURFACE_LOST_KHR) << "Cannot present in swapchain. error=" << static_cast(result); } @@ -193,14 +194,24 @@ std::pair VulkanSwapChain::acquire() { if (result == VK_SUBOPTIMAL_KHR || result == VK_ERROR_OUT_OF_DATE_KHR) { // Following recreates the swapchain - // Calling flush multiptle times is ok, since it's no-op if not recording. + // Calling flush multiple times is ok, since it's no-op if not recording. if (mFlushAndWaitOnResize) { mCommands->flush(); mCommands->wait(); } - mPlatform->recreate(swapChain); - update(); - swapchainRecreated = true; + if (UTILS_LIKELY(mPlatform->recreate(swapChain) == VK_SUCCESS)) { + update(); + swapchainRecreated = true; + } else { + // We failed to create the swapchain. We'll wait for the swapchain to be recreated. + // Note that this is different from the resize case. If we're here then probably + // the backing *surface* is in a bad state, and *this* handle needs to be destroyed + // and recreated from the client side. + // + // Break here because we shouldn't attempt to acquire if we don't even have a + // swapchain. + break; + } } result = mPlatform->acquire(swapChain, &imageSyncData); } diff --git a/filament/backend/src/vulkan/platform/VulkanPlatformSwapChainImpl.cpp b/filament/backend/src/vulkan/platform/VulkanPlatformSwapChainImpl.cpp index 7ada36c5874c..7c1e075eed4a 100644 --- a/filament/backend/src/vulkan/platform/VulkanPlatformSwapChainImpl.cpp +++ b/filament/backend/src/vulkan/platform/VulkanPlatformSwapChainImpl.cpp @@ -171,6 +171,10 @@ VulkanPlatformSurfaceSwapChain::~VulkanPlatformSurfaceSwapChain() { } VkResult VulkanPlatformSurfaceSwapChain::create() { + if (UTILS_VERY_UNLIKELY(mSurfaceLost)) { + return VK_ERROR_SURFACE_LOST_KHR; + } + #ifdef __ANDROID__ NativeWindow::enableFrameTimestamps(static_cast(mNativeWindow), true); // on Android, disable producer throttling @@ -204,6 +208,13 @@ VkResult VulkanPlatformSurfaceSwapChain::create() { // Find a suitable surface format. FixedCapacityVector const surfaceFormats = fvkutils::enumerate(vkGetPhysicalDeviceSurfaceFormatsKHR, mPhysicalDevice, mSurface); + + // We could get no surface formats if the we've gotten a VK_ERROR_SURFACE_LOST_KHR. + if (UTILS_VERY_UNLIKELY(surfaceFormats.empty())) { + mSurfaceLost = true; + return VK_ERROR_SURFACE_LOST_KHR; + } + std::array expectedFormats = { VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8A8_UNORM, @@ -230,6 +241,12 @@ VkResult VulkanPlatformSurfaceSwapChain::create() { FixedCapacityVector presentModes = fvkutils::enumerate( vkGetPhysicalDeviceSurfacePresentModesKHR, mPhysicalDevice, mSurface); + // We will have no present modes if the we've gotten a VK_ERROR_SURFACE_LOST_KHR. + if (UTILS_VERY_UNLIKELY(presentModes.empty())) { + mSurfaceLost = true; + return VK_ERROR_SURFACE_LOST_KHR; + } + bool const foundSuitablePresentMode = std::find(presentModes.begin(), presentModes.end(), desiredPresentMode) != presentModes.end(); FILAMENT_CHECK_POSTCONDITION(foundSuitablePresentMode) @@ -278,8 +295,12 @@ VkResult VulkanPlatformSurfaceSwapChain::create() { .oldSwapchain = mSwapchain, }; VkResult result = vkCreateSwapchainKHR(mDevice, &createInfo, VKALLOC, &mSwapchain); - FILAMENT_CHECK_POSTCONDITION(result == VK_SUCCESS) << "vkCreateSwapchainKHR failed." - << " error=" << static_cast(result); + + if (UTILS_VERY_UNLIKELY(result != VK_SUCCESS)) { + mSurfaceLost = true; + LOG(ERROR) << "vkCreateSwapchainKHR failed. error=" << static_cast(result); + return VK_ERROR_SURFACE_LOST_KHR; + } mSwapChainBundle.colors = fvkutils::enumerate(vkGetSwapchainImagesKHR, mDevice, mSwapchain); mSwapChainBundle.colorFormat = surfaceFormat.format; @@ -313,6 +334,10 @@ VkResult VulkanPlatformSurfaceSwapChain::create() { } VkResult VulkanPlatformSurfaceSwapChain::acquire(VulkanPlatform::ImageSyncData* outImageSyncData) { + if (UTILS_VERY_UNLIKELY(mSurfaceLost)) { + return VK_ERROR_SURFACE_LOST_KHR; + } + mCurrentImageReadyIndex = (mCurrentImageReadyIndex + 1) % IMAGE_READY_SEMAPHORE_COUNT; outImageSyncData->imageReadySemaphore = mImageReady[mCurrentImageReadyIndex]; VkResult result = vkAcquireNextImageKHR(mDevice, mSwapchain, UINT64_MAX, @@ -324,10 +349,19 @@ VkResult VulkanPlatformSurfaceSwapChain::acquire(VulkanPlatform::ImageSyncData* FVK_LOGW << "Vulkan Driver: Suboptimal swap chain."; mSuboptimal = true; } + + if (UTILS_VERY_UNLIKELY(result == VK_ERROR_SURFACE_LOST_KHR)) { + mSurfaceLost = true; + } + return result; } VkResult VulkanPlatformSurfaceSwapChain::present(uint32_t index, VkSemaphore finished) { + if (UTILS_VERY_UNLIKELY(mSurfaceLost)) { + return VK_ERROR_SURFACE_LOST_KHR; + } + uint32_t currentIndex = index; VkSemaphore finishedDrawing = finished; @@ -363,12 +397,28 @@ VkResult VulkanPlatformSurfaceSwapChain::present(uint32_t index, VkSemaphore fin FVK_LOGW << "Vulkan Driver: Suboptimal swap chain."; mSuboptimal = true; } + if (UTILS_VERY_UNLIKELY(result == VK_ERROR_SURFACE_LOST_KHR)) { + mSurfaceLost = true; + } + return result; } bool VulkanPlatformSurfaceSwapChain::hasResized() const { + if (UTILS_VERY_UNLIKELY(mSurfaceLost)) { + // We return "false" here to indicate that we're in a bad state and will not trigger the + // recreate path. + return false; + } + VkSurfaceCapabilitiesKHR caps; - vkGetPhysicalDeviceSurfaceCapabilitiesKHR(mPhysicalDevice, mSurface, &caps); + VkResult result = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(mPhysicalDevice, mSurface, &caps); + + if (UTILS_VERY_UNLIKELY(result == VK_ERROR_SURFACE_LOST_KHR)) { + mSurfaceLost = true; + return false; + } + VkExtent2D perceivedExtent = caps.currentExtent; // Create the low-level swap chain. if (perceivedExtent.width == VULKAN_UNDEFINED_EXTENT diff --git a/filament/backend/src/vulkan/platform/VulkanPlatformSwapChainImpl.h b/filament/backend/src/vulkan/platform/VulkanPlatformSwapChainImpl.h index 658dfffe7634..a44c62e75d0c 100644 --- a/filament/backend/src/vulkan/platform/VulkanPlatformSwapChainImpl.h +++ b/filament/backend/src/vulkan/platform/VulkanPlatformSwapChainImpl.h @@ -138,6 +138,7 @@ struct VulkanPlatformSurfaceSwapChain : public VulkanPlatformSwapChainBase { uint32_t mArbitraryFrameId = 0; int64_t mPresentationTime = 0; + mutable bool mSurfaceLost = false; #ifdef __ANDROID__ AndroidSwapChainHelper mImpl{}; diff --git a/filament/backend/src/vulkan/utils/Helper.h b/filament/backend/src/vulkan/utils/Helper.h index 99ff301e4bc5..4568b9e0bc4e 100644 --- a/filament/backend/src/vulkan/utils/Helper.h +++ b/filament/backend/src/vulkan/utils/Helper.h @@ -25,8 +25,6 @@ #include #include -#include - namespace filament::backend::fvkutils { inline bool equivalent(const VkRect2D& a, const VkRect2D& b) { @@ -46,13 +44,19 @@ inline bool equivalent(const VkExtent2D& a, const VkExtent2D& b) { // considered, but because the "variadic" part of the vk methods (i.e. the inputs) are before the // non-variadic parts, this breaks the template type matching logic. Hence, we use a macro approach // here. -#define EXPAND_ENUM(...) \ - uint32_t size = 0; \ - VkResult result = func(__VA_ARGS__, nullptr); \ - FILAMENT_CHECK_POSTCONDITION(result == VK_SUCCESS) << "enumerate size error"; \ - utils::FixedCapacityVector ret(size); \ - result = func(__VA_ARGS__, ret.data()); \ - FILAMENT_CHECK_POSTCONDITION(result == VK_SUCCESS) << "enumerate error"; \ +#define EXPAND_ENUM(...) \ + uint32_t size = 0; \ + VkResult result = func(__VA_ARGS__, nullptr); \ + if (result != VK_SUCCESS) { \ + FVK_LOGE << "enumerate size error=" << static_cast(result); \ + return {}; \ + } \ + utils::FixedCapacityVector ret(size); \ + result = func(__VA_ARGS__, ret.data()); \ + if (result != VK_SUCCESS) { \ + FVK_LOGE << "enumerate error=" << static_cast(result); \ + return {}; \ + } \ return std::move(ret); #define EXPAND_ENUM_NO_ARGS() EXPAND_ENUM(&size) diff --git a/ios/CocoaPods/Filament.podspec b/ios/CocoaPods/Filament.podspec index 8d25d719c1e8..c577c778bdc9 100644 --- a/ios/CocoaPods/Filament.podspec +++ b/ios/CocoaPods/Filament.podspec @@ -1,12 +1,12 @@ Pod::Spec.new do |spec| spec.name = "Filament" - spec.version = "1.77.0" + spec.version = "1.77.1" spec.license = { :type => "Apache 2.0", :file => "LICENSE" } spec.homepage = "https://google.github.io/filament" spec.authors = "Google LLC." spec.summary = "Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WASM/WebGL." spec.platform = :ios, "11.0" - spec.source = { :http => "https://github.com/google/filament/releases/download/v1.77.0/filament-v1.77.0-ios.tgz" } + spec.source = { :http => "https://github.com/google/filament/releases/download/v1.77.1/filament-v1.77.1-ios.tgz" } spec.libraries = 'c++' diff --git a/libs/filabridge/include/filament/MaterialEnums.h b/libs/filabridge/include/filament/MaterialEnums.h index f1ae115f49d3..6ab83be293ac 100644 --- a/libs/filabridge/include/filament/MaterialEnums.h +++ b/libs/filabridge/include/filament/MaterialEnums.h @@ -30,7 +30,7 @@ namespace filament { // update this when a new version of filament wouldn't work with older materials -static constexpr size_t MATERIAL_VERSION = 76; +static constexpr size_t MATERIAL_VERSION = 77; // Those are the api levels that are used in the source material file (.mat) // diff --git a/libs/filamat/src/MetalArgumentBuffer.cpp b/libs/filamat/src/MetalArgumentBuffer.cpp index ffe1aa1568dd..1f211047df50 100644 --- a/libs/filamat/src/MetalArgumentBuffer.cpp +++ b/libs/filamat/src/MetalArgumentBuffer.cpp @@ -65,14 +65,17 @@ MetalArgumentBuffer* MetalArgumentBuffer::Builder::build() { } std::ostream& MetalArgumentBuffer::Builder::TextureArgument::write(std::ostream& os) const { + // SHADOW samplers are deliberately written as "texture", not "depth". SPIRV-Cross no longer + // types Dref-sampled resources as depthXd, because the same resource may legally be sampled + // both with and without a depth comparison. It instead declares them as plain textureXd and + // casts to the depth type at each sample_compare() call site via its spvDepthCast() helper. + // The types we emit here are spliced into that same MSL, so they must match. switch (format) { case filament::backend::SamplerFormat::INT: case filament::backend::SamplerFormat::UINT: case filament::backend::SamplerFormat::FLOAT: - os << "texture"; - break; case filament::backend::SamplerFormat::SHADOW: - os << "depth"; + os << "texture"; break; } diff --git a/libs/filamat/tests/test_argBufferFixup.cpp b/libs/filamat/tests/test_argBufferFixup.cpp index 0300f00a439b..ccfdba53dcd0 100644 --- a/libs/filamat/tests/test_argBufferFixup.cpp +++ b/libs/filamat/tests/test_argBufferFixup.cpp @@ -196,7 +196,7 @@ TEST(ArgBufferFixup, TextureTypes) { "texturecube textureC [[id(2)]];\n" "texture2d textureD [[id(3)]];\n" "texture3d textureE [[id(4)]];\n" - "depthcube_array textureF [[id(5)]];\n" + "texturecube_array textureF [[id(5)]];\n" "}"; EXPECT_EQ(argBuffer->getMsl(), expected); diff --git a/shaders/src/surface_material_inputs.vs b/shaders/src/surface_material_inputs.vs index 45f4d009c034..0f5f5d9a28b5 100644 --- a/shaders/src/surface_material_inputs.vs +++ b/shaders/src/surface_material_inputs.vs @@ -86,7 +86,11 @@ void initMaterialVertex(out MaterialVertexInputs material) { #if defined(VARIABLE_CUSTOM4) && !defined(HAS_ATTRIBUTE_COLOR) material.VARIABLE_CUSTOM4 = vec4(0.0); #endif +#if defined(VERTEX_DOMAIN_DEVICE) && defined(MATERIAL_HAS_CLIP_SPACE_POSITION) && CLIENT_MATERIAL_API_LEVEL >= UNSTABLE_MATERIAL_API_LEVEL + material.worldPosition = vec4(0.0); +#else material.worldPosition = computeWorldPosition(); +#endif #ifdef VERTEX_DOMAIN_DEVICE #ifdef MATERIAL_HAS_CLIP_SPACE_TRANSFORM material.clipSpaceTransform = mat4(1.0); diff --git a/third_party/spirv-cross/checkout_glslang_spirv_tools.sh b/third_party/spirv-cross/checkout_glslang_spirv_tools.sh index 7f084fcf2ca6..cdfae9bf624f 100755 --- a/third_party/spirv-cross/checkout_glslang_spirv_tools.sh +++ b/third_party/spirv-cross/checkout_glslang_spirv_tools.sh @@ -2,9 +2,9 @@ # Copyright 2016-2021 The Khronos Group Inc. # SPDX-License-Identifier: Apache-2.0 -GLSLANG_REV=5f6c7176c5483da9af6432afb3dd962e4f8873a1 -SPIRV_TOOLS_REV=021f92a757002fcdba6a73154ed46a203d3a56b8 -SPIRV_HEADERS_REV=9268f3057354a2cb65991ba5f38b16d81e803692 +GLSLANG_REV=31b9aacfaf3adf9c514f53d0f43f390a578f00f1 +SPIRV_TOOLS_REV=ef96ed763b43b59b33b31b362f09a02b729fa1c9 +SPIRV_HEADERS_REV=04fd3caa1e8267e4d95c806cad901181728e1006 PROTOCOL=https if [ -d external/glslang ]; then diff --git a/third_party/spirv-cross/main.cpp b/third_party/spirv-cross/main.cpp index b48c1c3cdffa..c7cef8319c87 100644 --- a/third_party/spirv-cross/main.cpp +++ b/third_party/spirv-cross/main.cpp @@ -677,6 +677,8 @@ struct CLIArguments bool msl_manual_helper_invocation_updates = true; bool msl_check_discarded_frag_stores = false; bool msl_force_fragment_with_side_effects_execution = false; + bool msl_emulate_reversed_depth_viewport = false; + bool msl_emulate_depth_clip_enable = false; bool msl_sample_dref_lod_array_as_grad = false; bool msl_runtime_array_rich_descriptor = false; bool msl_replace_recursive_inputs = false; @@ -694,6 +696,8 @@ struct CLIArguments uint32_t glsl_ovr_multiview_view_count = 0; SmallVector> glsl_ext_framebuffer_fetch; bool glsl_ext_framebuffer_fetch_noncoherent = false; + uint32_t glsl_descriptor_heap_set = UINT32_MAX; + uint32_t glsl_descriptor_heap_binding = UINT32_MAX; bool vulkan_glsl_disable_ext_samplerless_texture_functions = false; bool emit_line_directives = false; bool enable_storage_image_qualifier_deduction = true; @@ -821,6 +825,7 @@ static void print_help_glsl() "\t\tPrimary use case is supporting external samplers in ESSL for video rendering on Android where you could remap a texture to a YUV one.\n" "\t[--glsl-force-flattened-io-blocks]:\n\t\tAlways flatten I/O blocks and structs.\n" "\t[--glsl-ovr-multiview-view-count count]:\n\t\tIn GL_OVR_multiview2, specify layout(num_views).\n" + "\t[--glsl-descriptor-heap-set-binding desc_set binding]:\n\t\tInstead of layout(descriptor_heap), emit layout(set = desc_set, binding = binding) instead for compatibility with mapping API.\n" ); // clang-format on } @@ -978,6 +983,8 @@ static void print_help_msl() "\t\t\t4. Fragment is always discarded in fragment execution.\n" "\t\tHowever, Vulkan expects fragment shader to be executed since it cannot be discarded until the discard\n" "\t\tpresent in the fragment execution, which would also execute the operations with side effects.\n" + "\t[--msl-emulate-reversed-depth-viewport]:\n\t\tEmulate reversed-depth viewports by inverting clip-space Z.\n" + "\t[--msl-emulate-depth-clip-enable]:\n\t\tEmulate Vulkan depth clip and clamp combinations unsupported by Metal.\n" "\t[--msl-sample-dref-lod-array-as-grad]:\n\t\tUse a gradient instead of a level argument.\n" "\t\tSome Metal devices have a bug where the level() argument to\n" "\t\tdepth2d_array::sample_compare() in a fragment shader is biased by some\n" @@ -1044,17 +1051,17 @@ static void print_help_obscure() // clang-format on } -static void print_help() +static void print_help_all() { print_version(); // clang-format off - fprintf(stderr, "Usage: spirv-cross <...>\n" + fprintf(stderr, "Usage: spirv-cross [SPIR-V file] [options]\n" "\nBasic:\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" + "\t[--help]:\n\t\tPrints a summary help message.\n" ); // clang-format on @@ -1066,6 +1073,33 @@ static void print_help() print_help_obscure(); } +static void print_help() +{ + print_version(); + + // clang-format off + fprintf(stderr, "Usage: spirv-cross [SPIR-V file] [options]\n" + "\nBasic:\n" + "\t[SPIR-V file] (- is stdin)\n" + "\t[--output ]: If not provided, prints output to stdout.\n" + "\t[--help]:\n\t\tPrints this summary help message.\n" + "\t[--help-all]:\n\t\tPrints all available help options.\n" + ); + // clang-format on + + print_help_backend(); + print_help_common(); + + // clang-format off + fprintf(stderr, "\nHelp Categories:\n" + "\t[--help-glsl]\n" + "\t[--help-msl]\n" + "\t[--help-hlsl]\n" + "\t[--help-obscure]\n" + ); + // clang-format on +} + static bool remap_generic(Compiler &compiler, const SmallVector &resources, const Remap &remap) { auto itr = @@ -1268,6 +1302,8 @@ static string compile_iteration(const CLIArguments &args, std::vector msl_opts.manual_helper_invocation_updates = args.msl_manual_helper_invocation_updates; msl_opts.check_discarded_frag_stores = args.msl_check_discarded_frag_stores; msl_opts.force_fragment_with_side_effects_execution = args.msl_force_fragment_with_side_effects_execution; + msl_opts.emulate_reversed_depth_viewport = args.msl_emulate_reversed_depth_viewport; + msl_opts.emulate_depth_clip_enable = args.msl_emulate_depth_clip_enable; msl_opts.sample_dref_lod_array_as_grad = args.msl_sample_dref_lod_array_as_grad; msl_opts.ios_support_base_vertex_instance = true; msl_opts.runtime_array_rich_descriptor = args.msl_runtime_array_rich_descriptor; @@ -1431,6 +1467,10 @@ static string compile_iteration(const CLIArguments &args, std::vector opts.force_recompile_max_debug_iterations = args.force_recompile_max_debug_iterations; compiler->set_common_options(opts); + // This is enough for Vulkan mapping API. + if (args.glsl_descriptor_heap_set != UINT32_MAX) + compiler->remap_descriptor_heap(ResourceTypeUnknown, args.glsl_descriptor_heap_set, args.glsl_descriptor_heap_binding); + for (auto &fetch : args.glsl_ext_framebuffer_fetch) compiler->remap_ext_framebuffer_fetch(fetch.first, fetch.second, !args.glsl_ext_framebuffer_fetch_noncoherent); @@ -1610,6 +1650,34 @@ static int main_inner(int argc, char *argv[]) print_help(); parser.end(); }); + cbs.add("--help-all", [](CLIParser &parser) { + print_help_all(); + parser.end(); + }); + cbs.add("--help-backend", [](CLIParser &parser) { + print_help_backend(); + parser.end(); + }); + cbs.add("--help-common", [](CLIParser &parser) { + print_help_common(); + parser.end(); + }); + cbs.add("--help-glsl", [](CLIParser &parser) { + print_help_glsl(); + parser.end(); + }); + cbs.add("--help-msl", [](CLIParser &parser) { + print_help_msl(); + parser.end(); + }); + cbs.add("--help-hlsl", [](CLIParser &parser) { + print_help_hlsl(); + parser.end(); + }); + cbs.add("--help-obscure", [](CLIParser &parser) { + print_help_obscure(); + parser.end(); + }); cbs.add("--revision", [](CLIParser &parser) { print_version(); parser.end(); @@ -1649,6 +1717,11 @@ static int main_inner(int argc, char *argv[]) cbs.add("--glsl-ext-framebuffer-fetch-noncoherent", [&args](CLIParser &) { args.glsl_ext_framebuffer_fetch_noncoherent = true; }); + cbs.add("--glsl-descriptor-heap-set-binding", [&args](CLIParser &parser) + { + args.glsl_descriptor_heap_set = parser.next_uint(); + args.glsl_descriptor_heap_binding = parser.next_uint(); + }); 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", @@ -1834,6 +1907,8 @@ static int main_inner(int argc, char *argv[]) [&args](CLIParser &) { args.msl_manual_helper_invocation_updates = false; }); cbs.add("--msl-check-discarded-frag-stores", [&args](CLIParser &) { args.msl_check_discarded_frag_stores = true; }); cbs.add("--msl-force-frag-with-side-effects-execution", [&args](CLIParser &) { args.msl_force_fragment_with_side_effects_execution = true; }); + cbs.add("--msl-emulate-reversed-depth-viewport", [&args](CLIParser &) { args.msl_emulate_reversed_depth_viewport = true; }); + cbs.add("--msl-emulate-depth-clip-enable", [&args](CLIParser &) { args.msl_emulate_depth_clip_enable = true; }); cbs.add("--msl-sample-dref-lod-array-as-grad", [&args](CLIParser &) { args.msl_sample_dref_lod_array_as_grad = true; }); cbs.add("--msl-no-readwrite-texture-fences", [&args](CLIParser &) { args.msl_readwrite_texture_fences = false; }); diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/comp/atomic-decrement.asm.comp b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/comp/atomic-decrement.asm.comp index 0f56123d87e7..c0004920b1e7 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/comp/atomic-decrement.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/comp/atomic-decrement.asm.comp @@ -11,7 +11,7 @@ void comp_main() { uint _24; u0_counter.InterlockedAdd(0, -1, _24); - u0[asint(asfloat(_24))] = uint(int(gl_GlobalInvocationID.x)).x; + u0[int(_24)] = uint(int(gl_GlobalInvocationID.x)).x; } [numthreads(4, 1, 1)] diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/comp/atomic-increment.asm.comp b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/comp/atomic-increment.asm.comp index bf1fdebe55e1..054a18ea6d62 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/comp/atomic-increment.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/comp/atomic-increment.asm.comp @@ -11,7 +11,7 @@ void comp_main() { uint _24; u0_counter.InterlockedAdd(0, 1, _24); - u0[asint(asfloat(_24))] = uint(int(gl_GlobalInvocationID.x)).x; + u0[int(_24)] = uint(int(gl_GlobalInvocationID.x)).x; } [numthreads(4, 1, 1)] diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/comp/replicated-composites.spv16.vk.asm.comp b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/comp/replicated-composites.spv16.vk.asm.comp index 23f0f5093585..c01b291e85de 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/comp/replicated-composites.spv16.vk.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/comp/replicated-composites.spv16.vk.asm.comp @@ -2,7 +2,7 @@ #define SPIRV_CROSS_CONSTANT_ID_0 0.0f #endif static const float spec_const = SPIRV_CROSS_CONSTANT_ID_0; -static const float4 _20 = float4(spec_const); +static const float4 _20 = (float4)spec_const; static float _42; static const float _26[8] = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }; @@ -15,10 +15,10 @@ cbuffer UBO : register(b0) void comp_main() { - float4 a = float4(0.0f); - float4x4 b = float4x4(float4(1.0f), float4(1.0f), float4(1.0f), float4(1.0f)); + float4 a = (float4)0.0f; + float4x4 b = float4x4((float4)1.0f, (float4)1.0f, (float4)1.0f, (float4)1.0f); float4 c = _20; - float4 _36 = float4(ubo_uniform_float); + float4 _36 = (float4)ubo_uniform_float; float4 d = _36; float4x4 e = float4x4(_36, _36, _36, _36); } diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/implicit-read-dep-phi.asm.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/implicit-read-dep-phi.asm.frag index a991b64cd8dd..389041d48bbb 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/implicit-read-dep-phi.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/implicit-read-dep-phi.asm.frag @@ -25,7 +25,8 @@ void frag_main() for (;;) { FragColor = _45; - if (_57 < 4) + bool _22 = _57 < 4; + if (_22) { if (v0[_57] > 0.0f) { diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/texture-sampling-fp16.asm.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/texture-sampling-fp16.asm.invalid.frag similarity index 100% rename from third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/texture-sampling-fp16.asm.frag rename to third_party/spirv-cross/reference/opt/shaders-hlsl/asm/frag/texture-sampling-fp16.asm.invalid.frag diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/lib/export-calls-export.asm.lib b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/lib/export-calls-export.asm.lib new file mode 100644 index 000000000000..6358636ca963 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/lib/export-calls-export.asm.lib @@ -0,0 +1,15 @@ +uint add_one(uint x) +{ + return x + 1u; +} + +uint add_two(uint y) +{ + return y + 5u; +} + +uint add_three(uint z) +{ + return z + 3u; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/lib/global-array.asm.lib b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/lib/global-array.asm.lib new file mode 100644 index 000000000000..5502301c7d00 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/lib/global-array.asm.lib @@ -0,0 +1,7 @@ +static const uint _15[4] = { 10u, 20u, 30u, 40u }; + +uint lookup(uint i) +{ + return _15[i]; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/lib/multi-export.asm.lib b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/lib/multi-export.asm.lib new file mode 100644 index 000000000000..5ce3017a00ee --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/asm/lib/multi-export.asm.lib @@ -0,0 +1,10 @@ +uint add_one(uint x) +{ + return x + 1u; +} + +uint add_two(uint y) +{ + return y + 2u; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/comp/access-chain-load-composite.comp b/third_party/spirv-cross/reference/opt/shaders-hlsl/comp/access-chain-load-composite.comp index 778f62e83c88..a93be7ba4d26 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/comp/access-chain-load-composite.comp +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/comp/access-chain-load-composite.comp @@ -22,83 +22,114 @@ RWByteAddressBuffer _31 : register(u0); void comp_main() { - Foo _36; - _36.a = asfloat(uint2x2(_31.Load(0), _31.Load(8), _31.Load(4), _31.Load(12))); - _36.b = asfloat(_31.Load2(16)); - [unroll] - for (int _4ident = 0; _4ident < 5; _4ident++) - { - [unroll] - for (int _5ident = 0; _5ident < 2; _5ident++) - { - [unroll] - for (int _6ident = 0; _6ident < 4; _6ident++) - { - _36.c[_4ident].d[_5ident][_6ident] = asfloat(_31.Load(_6ident * 4 + _5ident * 16 + _4ident * 40 + 24)); - } - } - [unroll] - for (int _7ident = 0; _7ident < 2; _7ident++) - { - _36.c[_4ident].baz[_7ident].c = asfloat(_31.Load(_7ident * 4 + _4ident * 40 + 56)); - } - } - float2x2 _234 = float2x2(_36.a[0] + 1.0f.xx, _36.a[1] + 1.0f.xx); + float2x2 _662 = asfloat(uint2x2(_31.Load(0), _31.Load(8), _31.Load(4), _31.Load(12))); + float2 _664 = asfloat(_31.Load2(16)); + float _674 = asfloat(_31.Load(24)); + float _676 = asfloat(_31.Load(28)); + float _678 = asfloat(_31.Load(32)); + float _681 = asfloat(_31.Load(36)); + float _685 = asfloat(_31.Load(40)); + float _687 = asfloat(_31.Load(44)); + float _689 = asfloat(_31.Load(48)); + float _691 = asfloat(_31.Load(52)); + float _697 = asfloat(_31.Load(56)); + float _701 = asfloat(_31.Load(60)); + float _709 = asfloat(_31.Load(64)); + float _711 = asfloat(_31.Load(68)); + float _713 = asfloat(_31.Load(72)); + float _715 = asfloat(_31.Load(76)); + float _719 = asfloat(_31.Load(80)); + float _721 = asfloat(_31.Load(84)); + float _723 = asfloat(_31.Load(88)); + float _725 = asfloat(_31.Load(92)); + float _731 = asfloat(_31.Load(96)); + float _735 = asfloat(_31.Load(100)); + float _743 = asfloat(_31.Load(104)); + float _745 = asfloat(_31.Load(108)); + float _747 = asfloat(_31.Load(112)); + float _749 = asfloat(_31.Load(116)); + float _753 = asfloat(_31.Load(120)); + float _755 = asfloat(_31.Load(124)); + float _757 = asfloat(_31.Load(128)); + float _759 = asfloat(_31.Load(132)); + float _765 = asfloat(_31.Load(136)); + float _769 = asfloat(_31.Load(140)); + float _777 = asfloat(_31.Load(144)); + float _779 = asfloat(_31.Load(148)); + float _781 = asfloat(_31.Load(152)); + float _783 = asfloat(_31.Load(156)); + float _787 = asfloat(_31.Load(160)); + float _789 = asfloat(_31.Load(164)); + float _791 = asfloat(_31.Load(168)); + float _793 = asfloat(_31.Load(172)); + float _799 = asfloat(_31.Load(176)); + float _803 = asfloat(_31.Load(180)); + float _811 = asfloat(_31.Load(184)); + float _813 = asfloat(_31.Load(188)); + float _815 = asfloat(_31.Load(192)); + float _817 = asfloat(_31.Load(196)); + float _821 = asfloat(_31.Load(200)); + float _823 = asfloat(_31.Load(204)); + float _825 = asfloat(_31.Load(208)); + float _827 = asfloat(_31.Load(212)); + float _833 = asfloat(_31.Load(216)); + float _837 = asfloat(_31.Load(220)); + float2x2 _234 = float2x2(_662[0] + 1.0f.xx, _662[1] + 1.0f.xx); _31.Store(224, asuint(_234[0].x)); _31.Store(228, asuint(_234[1].x)); _31.Store(232, asuint(_234[0].y)); _31.Store(236, asuint(_234[1].y)); - _31.Store2(240, asuint(_36.b + 2.0f.xx)); - _31.Store(248, asuint(_36.c[0].d[0][0])); - _31.Store(252, asuint(_36.c[0].d[0][1])); - _31.Store(256, asuint(_36.c[0].d[0][2])); - _31.Store(260, asuint(_36.c[0].d[0][3])); - _31.Store(264, asuint(_36.c[0].d[1][0])); - _31.Store(268, asuint(_36.c[0].d[1][1])); - _31.Store(272, asuint(_36.c[0].d[1][2])); - _31.Store(276, asuint(_36.c[0].d[1][3])); - _31.Store(280, asuint(_36.c[0].baz[0].c)); - _31.Store(284, asuint(_36.c[0].baz[1].c)); - _31.Store(288, asuint(_36.c[1].d[0][0])); - _31.Store(292, asuint(_36.c[1].d[0][1])); - _31.Store(296, asuint(_36.c[1].d[0][2])); - _31.Store(300, asuint(_36.c[1].d[0][3])); - _31.Store(304, asuint(_36.c[1].d[1][0])); - _31.Store(308, asuint(_36.c[1].d[1][1])); - _31.Store(312, asuint(_36.c[1].d[1][2])); - _31.Store(316, asuint(_36.c[1].d[1][3])); - _31.Store(320, asuint(_36.c[1].baz[0].c)); - _31.Store(324, asuint(_36.c[1].baz[1].c)); - _31.Store(328, asuint(_36.c[2].d[0][0])); - _31.Store(332, asuint(_36.c[2].d[0][1])); - _31.Store(336, asuint(_36.c[2].d[0][2])); - _31.Store(340, asuint(_36.c[2].d[0][3])); - _31.Store(344, asuint(_36.c[2].d[1][0])); - _31.Store(348, asuint(_36.c[2].d[1][1])); - _31.Store(352, asuint(_36.c[2].d[1][2])); - _31.Store(356, asuint(_36.c[2].d[1][3])); - _31.Store(360, asuint(_36.c[2].baz[0].c)); - _31.Store(364, asuint(_36.c[2].baz[1].c)); - _31.Store(368, asuint(_36.c[3].d[0][0])); - _31.Store(372, asuint(_36.c[3].d[0][1])); - _31.Store(376, asuint(_36.c[3].d[0][2])); - _31.Store(380, asuint(_36.c[3].d[0][3])); - _31.Store(384, asuint(_36.c[3].d[1][0])); - _31.Store(388, asuint(_36.c[3].d[1][1] + 5.0f)); - _31.Store(392, asuint(_36.c[3].d[1][2])); - _31.Store(396, asuint(_36.c[3].d[1][3])); - _31.Store(400, asuint(_36.c[3].baz[0].c)); - _31.Store(404, asuint(_36.c[3].baz[1].c)); - _31.Store(408, asuint(_36.c[4].d[0][0])); - _31.Store(412, asuint(_36.c[4].d[0][1])); - _31.Store(416, asuint(_36.c[4].d[0][2])); - _31.Store(420, asuint(_36.c[4].d[0][3])); - _31.Store(424, asuint(_36.c[4].d[1][0])); - _31.Store(428, asuint(_36.c[4].d[1][1])); - _31.Store(432, asuint(_36.c[4].d[1][2])); - _31.Store(436, asuint(_36.c[4].d[1][3])); - _31.Store(440, asuint(_36.c[4].baz[0].c)); - _31.Store(444, asuint(_36.c[4].baz[1].c)); + _31.Store2(240, asuint(_664 + 2.0f.xx)); + _31.Store(248, asuint(_674)); + _31.Store(252, asuint(_676)); + _31.Store(256, asuint(_678)); + _31.Store(260, asuint(_681)); + _31.Store(264, asuint(_685)); + _31.Store(268, asuint(_687)); + _31.Store(272, asuint(_689)); + _31.Store(276, asuint(_691)); + _31.Store(280, asuint(_697)); + _31.Store(284, asuint(_701)); + _31.Store(288, asuint(_709)); + _31.Store(292, asuint(_711)); + _31.Store(296, asuint(_713)); + _31.Store(300, asuint(_715)); + _31.Store(304, asuint(_719)); + _31.Store(308, asuint(_721)); + _31.Store(312, asuint(_723)); + _31.Store(316, asuint(_725)); + _31.Store(320, asuint(_731)); + _31.Store(324, asuint(_735)); + _31.Store(328, asuint(_743)); + _31.Store(332, asuint(_745)); + _31.Store(336, asuint(_747)); + _31.Store(340, asuint(_749)); + _31.Store(344, asuint(_753)); + _31.Store(348, asuint(_755)); + _31.Store(352, asuint(_757)); + _31.Store(356, asuint(_759)); + _31.Store(360, asuint(_765)); + _31.Store(364, asuint(_769)); + _31.Store(368, asuint(_777)); + _31.Store(372, asuint(_779)); + _31.Store(376, asuint(_781)); + _31.Store(380, asuint(_783)); + _31.Store(384, asuint(_787)); + _31.Store(388, asuint(_789 + 5.0f)); + _31.Store(392, asuint(_791)); + _31.Store(396, asuint(_793)); + _31.Store(400, asuint(_799)); + _31.Store(404, asuint(_803)); + _31.Store(408, asuint(_811)); + _31.Store(412, asuint(_813)); + _31.Store(416, asuint(_815)); + _31.Store(420, asuint(_817)); + _31.Store(424, asuint(_821)); + _31.Store(428, asuint(_823)); + _31.Store(432, asuint(_825)); + _31.Store(436, asuint(_827)); + _31.Store(440, asuint(_833)); + _31.Store(444, asuint(_837)); } [numthreads(1, 1, 1)] diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/comp/ssbo-array-length.comp b/third_party/spirv-cross/reference/opt/shaders-hlsl/comp/ssbo-array-length.comp index 82657cacfcba..e6f1820b660c 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/comp/ssbo-array-length.comp +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/comp/ssbo-array-length.comp @@ -7,7 +7,7 @@ void comp_main() uint _14; _11.GetDimensions(_14); _14 = (_14 - 16) / 16; - _11.Store(0, uint(int(_14))); + _11.Store(0, _14); } [numthreads(1, 1, 1)] diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/comp/ssbo-store-array.comp b/third_party/spirv-cross/reference/opt/shaders-hlsl/comp/ssbo-store-array.comp index d8bce8d54b7a..7244b0e77055 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/comp/ssbo-store-array.comp +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/comp/ssbo-store-array.comp @@ -1,5 +1,15 @@ +struct Data +{ + uint arr[3]; +}; + +RWByteAddressBuffer _21 : register(u0); + void comp_main() { + _21.Store(0, 1u); + _21.Store(4, 2u); + _21.Store(8, 3u); } [numthreads(1, 1, 1)] diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/flatten/struct.rowmajor.flatten.vert b/third_party/spirv-cross/reference/opt/shaders-hlsl/flatten/struct.rowmajor.flatten.vert index bb702907a72d..b4969cba6b6e 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/flatten/struct.rowmajor.flatten.vert +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/flatten/struct.rowmajor.flatten.vert @@ -26,9 +26,8 @@ struct SPIRV_Cross_Output void vert_main() { Foo _19 = {transpose(float4x3(UBO[0].xyz, UBO[1].xyz, UBO[2].xyz, UBO[3].xyz)), transpose(float4x3(UBO[4].xyz, UBO[5].xyz, UBO[6].xyz, UBO[7].xyz))}; - Foo _20 = _19; - V0 = mul(_20.MVP0, v0); - V1 = mul(_20.MVP1, v1); + V0 = mul(_19.MVP0, v0); + V1 = mul(_19.MVP1, v1); } SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/array-lut-no-loop-variable.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/array-lut-no-loop-variable.frag index 3adf7d9852e7..38f416fbfad1 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/array-lut-no-loop-variable.frag +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/array-lut-no-loop-variable.frag @@ -1,12 +1,6 @@ static const float _17[5] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f }; static float4 FragColor; -static float4 v0; - -struct SPIRV_Cross_Input -{ - float4 v0 : TEXCOORD0; -}; struct SPIRV_Cross_Output { @@ -24,9 +18,8 @@ void frag_main() } } -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +SPIRV_Cross_Output main() { - v0 = stage_input.v0; frag_main(); SPIRV_Cross_Output stage_output; stage_output.FragColor = FragColor; diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/bit-conversions.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/bit-conversions.frag index b60b2ebb4a57..32891b10b0b8 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/bit-conversions.frag +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/bit-conversions.frag @@ -13,7 +13,7 @@ struct SPIRV_Cross_Output void frag_main() { - FragColor = float4(1.0f, 0.0f, asfloat(asint(value.x)), 1.0f); + FragColor = float4(1.0f, 0.0f, value.x, 1.0f); } SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/no-return2.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/no-return2.frag index e9d7bbc8f97d..3b50282fe07b 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/no-return2.frag +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/no-return2.frag @@ -1,16 +1,8 @@ -static float4 vColor; - -struct SPIRV_Cross_Input -{ - float4 vColor : TEXCOORD0; -}; - void frag_main() { } -void main(SPIRV_Cross_Input stage_input) +void main() { - vColor = stage_input.vColor; frag_main(); } diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/shader-debug-info-line-directives.line.gV.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/shader-debug-info-line-directives.line.gV.frag index f5c46558f68d..4877d2de5316 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/shader-debug-info-line-directives.line.gV.frag +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/shader-debug-info-line-directives.line.gV.frag @@ -15,8 +15,8 @@ void frag_main() { #line 137 "test.frag" #line 106 "test.frag" - bool _288 = iv.x < 0.0f; - if (_288) + bool _298 = iv.x < 0.0f; + if (_298) { #line 107 "test.frag" ov.x = 50.0f; @@ -27,10 +27,10 @@ void frag_main() ov.x = 60.0f; } #line 114 "test.frag" - for (int _519 = 0; _519 < 4; _519++) + for (int _529 = 0; _529 < 4; _529++) { #line 106 "test.frag" - if (_288) + if (_298) { #line 107 "test.frag" ov.x = 50.0f; @@ -53,10 +53,10 @@ void frag_main() } } #line 126 "test.frag" - for (int _523 = 0; _523 < 4; _523++) + for (int _533 = 0; _533 < 4; _533++) { #line 106 "test.frag" - if (_288) + if (_298) { #line 107 "test.frag" ov.x = 50.0f; @@ -67,10 +67,10 @@ void frag_main() ov.x = 60.0f; } #line 114 "test.frag" - for (int _527 = 0; _527 < 4; _527++) + for (int _537 = 0; _537 < 4; _537++) { #line 106 "test.frag" - if (_288) + if (_298) { #line 107 "test.frag" ov.x = 50.0f; diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/switch-unreachable-break.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/switch-unreachable-break.frag index de30994b9d43..f25b768b9e5e 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/switch-unreachable-break.frag +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/switch-unreachable-break.frag @@ -6,12 +6,6 @@ cbuffer UBO : register(b0) static float4 FragColor; -static float4 vInput; - -struct SPIRV_Cross_Input -{ - float4 vInput : TEXCOORD0; -}; struct SPIRV_Cross_Output { @@ -46,9 +40,8 @@ void frag_main() FragColor = float4(_45.x ? 10.0f.xxxx.x : 20.0f.xxxx.x, _45.y ? 10.0f.xxxx.y : 20.0f.xxxx.y, _45.z ? 10.0f.xxxx.z : 20.0f.xxxx.z, _45.w ? 10.0f.xxxx.w : 20.0f.xxxx.w); } -SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +SPIRV_Cross_Output main() { - vInput = stage_input.vInput; frag_main(); SPIRV_Cross_Output stage_output; stage_output.FragColor = FragColor; diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/unary-enclose.frag b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/unary-enclose.frag index 348b91c17279..85419ef14ad3 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/unary-enclose.frag +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/frag/unary-enclose.frag @@ -1,11 +1,9 @@ static float4 FragColor; static float4 vIn; -static int4 vIn1; struct SPIRV_Cross_Input { float4 vIn : TEXCOORD0; - nointerpolation int4 vIn1 : TEXCOORD1; }; struct SPIRV_Cross_Output @@ -21,7 +19,6 @@ void frag_main() SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) { vIn = stage_input.vIn; - vIn1 = stage_input.vIn1; frag_main(); SPIRV_Cross_Output stage_output; stage_output.FragColor = FragColor; diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/mesh/mesh-shader-basic-lines.spv14.vk.nocompat.mesh b/third_party/spirv-cross/reference/opt/shaders-hlsl/mesh/mesh-shader-basic-lines.spv14.vk.nocompat.mesh index 066f023c66f6..bb056f0aba87 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/mesh/mesh-shader-basic-lines.spv14.vk.nocompat.mesh +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/mesh/mesh-shader-basic-lines.spv14.vk.nocompat.mesh @@ -49,8 +49,6 @@ struct gl_MeshPerPrimitiveEXT bool gl_CullPrimitiveEXT : SV_CullPrimitive; }; -groupshared float shared_float[16]; - void mesh_main(out gl_MeshPerVertexEXT gl_MeshVerticesEXT[24], out gl_MeshPerPrimitiveEXT gl_MeshPrimitivesEXT[22], TaskPayload _payload, inout uint2 gl_PrimitiveLineIndicesEXT[22]) { SetMeshOutputCounts(24u, 22u); diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.mesh b/third_party/spirv-cross/reference/opt/shaders-hlsl/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.mesh index 7d07322fe421..6633654ab70d 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.mesh +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.mesh @@ -49,8 +49,6 @@ struct gl_MeshPerPrimitiveEXT bool gl_CullPrimitiveEXT : SV_CullPrimitive; }; -groupshared float shared_float[16]; - void mesh_main(out gl_MeshPerVertexEXT gl_MeshVerticesEXT[24], out gl_MeshPerPrimitiveEXT gl_MeshPrimitivesEXT[22], TaskPayload _payload, inout uint3 gl_PrimitiveTriangleIndicesEXT[22]) { SetMeshOutputCounts(24u, 22u); diff --git a/third_party/spirv-cross/reference/opt/shaders-hlsl/vert/return-array.vert b/third_party/spirv-cross/reference/opt/shaders-hlsl/vert/return-array.vert index bd1575563380..be11c3f1a559 100644 --- a/third_party/spirv-cross/reference/opt/shaders-hlsl/vert/return-array.vert +++ b/third_party/spirv-cross/reference/opt/shaders-hlsl/vert/return-array.vert @@ -1,10 +1,8 @@ static float4 gl_Position; -static float4 vInput0; static float4 vInput1; struct SPIRV_Cross_Input { - float4 vInput0 : TEXCOORD0; float4 vInput1 : TEXCOORD1; }; @@ -20,7 +18,6 @@ void vert_main() SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) { - vInput0 = stage_input.vInput0; vInput1 = stage_input.vInput1; vert_main(); SPIRV_Cross_Output stage_output; diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/atomic-decrement.asm.comp b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/atomic-decrement.asm.comp index f7d18c1293e5..52a7484ef382 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/atomic-decrement.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/atomic-decrement.asm.comp @@ -22,6 +22,6 @@ struct u0_counters kernel void main0(device u0_counters& u0_counter [[buffer(0)]], texture2d u0 [[texture(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { uint _24 = atomic_fetch_sub_explicit((device atomic_uint*)&u0_counter.c, 1, memory_order_relaxed); - u0.write(uint4(uint(int(gl_GlobalInvocationID.x))), spvTexelBufferCoord(as_type(as_type(_24)))); + u0.write(uint4(uint(int(gl_GlobalInvocationID.x))), spvTexelBufferCoord(int(_24))); } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/atomic-increment.asm.comp b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/atomic-increment.asm.comp index 0bff619f40b2..0299189be3cf 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/atomic-increment.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/atomic-increment.asm.comp @@ -22,6 +22,6 @@ struct u0_counters kernel void main0(device u0_counters& u0_counter [[buffer(0)]], texture2d u0 [[texture(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { uint _24 = atomic_fetch_add_explicit((device atomic_uint*)&u0_counter.c, 1, memory_order_relaxed); - u0.write(uint4(uint(int(gl_GlobalInvocationID.x))), spvTexelBufferCoord(as_type(as_type(_24)))); + u0.write(uint4(uint(int(gl_GlobalInvocationID.x))), spvTexelBufferCoord(int(_24))); } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/bitcast_iadd.asm.comp b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/bitcast_iadd.asm.comp index cbbf27d65da1..78f17b676ae6 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/bitcast_iadd.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/bitcast_iadd.asm.comp @@ -17,13 +17,15 @@ struct _4 kernel void main0(device _3& __restrict _5 [[buffer(0)]], device _4& __restrict _6 [[buffer(1)]]) { - _6._m0 = _5._m1 + uint4(_5._m0); - _6._m0 = uint4(_5._m0) + _5._m1; + uint4 _26 = _5._m1 + uint4(_5._m0); + int4 _32 = int4(_5._m1) + _5._m0; + _6._m0 = _26; + _6._m0 = _26; _6._m0 = _5._m1 + _5._m1; _6._m0 = uint4(_5._m0 + _5._m0); _6._m1 = int4(_5._m1 + _5._m1); _6._m1 = _5._m0 + _5._m0; - _6._m1 = int4(_5._m1) + _5._m0; - _6._m1 = _5._m0 + int4(_5._m1); + _6._m1 = _32; + _6._m1 = _32; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/bitcast_sdiv.asm.comp b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/bitcast_sdiv.asm.comp index 6b80dff3106b..0fb3509d4b1d 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/bitcast_sdiv.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/bitcast_sdiv.asm.comp @@ -21,10 +21,10 @@ kernel void main0(device _3& _5 [[buffer(0)]], device _4& _6 [[buffer(1)]]) uint4 _23 = _5._m1; _6._m0 = uint4(int4(_23) / _22); _6._m0 = uint4(_22 / int4(_23)); - _6._m0 = uint4(int4(_23) / int4(_23)); - _6._m0 = uint4(_22 / _22); - _6._m1 = int4(_23) / int4(_23); - _6._m1 = _22 / _22; + _6._m0 = uint4(1u); + _6._m0 = uint4(1u); + _6._m1 = int4(1); + _6._m1 = int4(1); _6._m1 = int4(_23) / _22; _6._m1 = _22 / int4(_23); } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/block-name-alias-global.asm.comp b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/block-name-alias-global.asm.comp index 6dcc14ea8d5b..0136d13b34d8 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/block-name-alias-global.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/block-name-alias-global.asm.comp @@ -1,8 +1,13 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +struct spvPaddedArrayElement { T data; char padding[stride - sizeof(T)]; }; + struct A { int a; @@ -18,12 +23,11 @@ struct A_2 { int a; int b; - char _m0_final_padding[8]; }; struct A_3 { - A_2 Data[1024]; + spvPaddedArrayElement Data[1024]; }; struct B @@ -33,14 +37,14 @@ struct B struct B_1 { - A_2 Data[1024]; + spvPaddedArrayElement Data[1024]; }; kernel void main0(device A_1& C1 [[buffer(0)]], constant A_3& C2 [[buffer(1)]], device B& C3 [[buffer(2)]], constant B_1& C4 [[buffer(3)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { - C1.Data[gl_GlobalInvocationID.x].a = C2.Data[gl_GlobalInvocationID.x].a; - C1.Data[gl_GlobalInvocationID.x].b = C2.Data[gl_GlobalInvocationID.x].b; - C3.Data[gl_GlobalInvocationID.x].a = C4.Data[gl_GlobalInvocationID.x].a; - C3.Data[gl_GlobalInvocationID.x].b = C4.Data[gl_GlobalInvocationID.x].b; + C1.Data[gl_GlobalInvocationID.x].a = C2.Data[gl_GlobalInvocationID.x].data.a; + C1.Data[gl_GlobalInvocationID.x].b = C2.Data[gl_GlobalInvocationID.x].data.b; + C3.Data[gl_GlobalInvocationID.x].a = C4.Data[gl_GlobalInvocationID.x].data.a; + C3.Data[gl_GlobalInvocationID.x].b = C4.Data[gl_GlobalInvocationID.x].data.b; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp index 3935486a04fe..45ea886ce1c8 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp @@ -19,8 +19,8 @@ struct cb5_struct kernel void main0(constant cb5_struct& cb0_5 [[buffer(0)]], texture2d u0 [[texture(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) { - uint _41 = as_type(as_type(int(gl_LocalInvocationID.x) << 4)) >> 2u; - uint4 _50 = as_type(cb0_5._m0[uint(as_type(as_type(int(gl_LocalInvocationID.x)))) + 1u]); + uint _41 = uint(int(gl_LocalInvocationID.x) << 4) >> 2u; + uint4 _50 = as_type(cb0_5._m0[uint(int(gl_LocalInvocationID.x)) + 1u]); u0.write(_50.xxxx, spvTexelBufferCoord(_41)); u0.write(_50.yyyy, spvTexelBufferCoord((_41 + 1u))); u0.write(_50.zzzz, spvTexelBufferCoord((_41 + 2u))); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/multiple-entry.asm.comp b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/multiple-entry.asm.comp index 358437337901..ed5dc1e77f38 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/multiple-entry.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/multiple-entry.asm.comp @@ -17,13 +17,15 @@ struct _7 kernel void main0(device _6& __restrict _8 [[buffer(0)]], device _7& __restrict _9 [[buffer(1)]]) { - _9._m0 = _8._m1 + uint4(_8._m0); - _9._m0 = uint4(_8._m0) + _8._m1; + uint4 _33 = _8._m1 + uint4(_8._m0); + int4 _39 = int4(_8._m1) + _8._m0; + _9._m0 = _33; + _9._m0 = _33; _9._m0 = _8._m1 + _8._m1; _9._m0 = uint4(_8._m0 + _8._m0); _9._m1 = int4(_8._m1 + _8._m1); _9._m1 = _8._m0 + _8._m0; - _9._m1 = int4(_8._m1) + _8._m0; - _9._m1 = _8._m0 + int4(_8._m1); + _9._m1 = _39; + _9._m1 = _39; } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/comp/variable-pointers-2.asm.comp b/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/variable-pointers-2.asm.invalid.comp similarity index 100% rename from third_party/spirv-cross/reference/shaders-msl/asm/comp/variable-pointers-2.asm.comp rename to third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/variable-pointers-2.asm.invalid.comp diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/bitcast-ptr-vec.argument-tier-1.msl23.asm.frag b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/bitcast-ptr-vec.argument-tier-1.msl23.asm.frag index 48c72019ee24..26387bde01ad 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/bitcast-ptr-vec.argument-tier-1.msl23.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/bitcast-ptr-vec.argument-tier-1.msl23.asm.frag @@ -37,11 +37,14 @@ fragment main0_out main0(constant type_ConstantBuffer_PushConstants& g_PushConst spvDescriptorArray> g_Texture2DDescriptorHeap {spvDescriptorSet0Binding0}; main0_out out = {}; - int2 _55 = int2(gl_FragCoord.xy) - (*(reinterpret_cast(g_PushConstants.SharedConstants + 16ul))); + uint _47 = *(reinterpret_cast(g_PushConstants.SharedConstants + 12ul)); + int2 _54 = *(reinterpret_cast(g_PushConstants.SharedConstants + 16ul)); + int2 _55 = int2(gl_FragCoord.xy) - _54; bool _66; if (!any(_55 < int2(0))) { - _66 = any(_55 >= (*(reinterpret_cast(g_PushConstants.SharedConstants + 24ul)))); + int2 _63 = *(reinterpret_cast(g_PushConstants.SharedConstants + 24ul)); + _66 = any(_55 >= _63); } else { @@ -54,7 +57,7 @@ fragment main0_out main0(constant type_ConstantBuffer_PushConstants& g_PushConst } else { - _77 = g_Texture2DDescriptorHeap[*(reinterpret_cast(g_PushConstants.SharedConstants + 12ul))].read(uint2(int3(select(_55, int2(0), bool2(_66)), 0).xy), 0); + _77 = g_Texture2DDescriptorHeap[_47].read(uint2(int3(select(_55, int2(0), bool2(_66)), 0).xy), 0); } float3 _81 = powr(_77.xyz, *(reinterpret_cast(g_PushConstants.SharedConstants))); out.out_var_SV_Target = float4(_81.x, _81.y, _81.z, _77.w); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.agx-cube-grad.msl23.asm.frag b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.agx-cube-grad.msl23.asm.frag index 090df2b2f3d5..8eb54127a23d 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.agx-cube-grad.msl23.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.agx-cube-grad.msl23.asm.frag @@ -25,6 +25,30 @@ static inline gradientcube spvGradientCube(float3 P, float3 dPdx, float3 dPdy) return gradientcube(xMajor ? d.xxy : d.xyx, xMajor ? d.zzw : d.zwz); } +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float4 o_color [[color(0)]]; @@ -36,10 +60,10 @@ struct main0_in float2 v_drefLodBias [[user(locn1)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depthcube_array u_sampler [[texture(0)]], sampler u_samplerSmplr [[sampler(0)]]) +fragment main0_out main0(main0_in in [[stage_in]], texturecube_array u_sampler [[texture(0)]], sampler u_samplerSmplr [[sampler(0)]]) { main0_out out = {}; - out.o_color = float4(u_sampler.sample_compare(u_samplerSmplr, in.v_texCoord.xyz, uint(rint(in.v_texCoord.w)), in.v_drefLodBias.x, spvGradientCube(in.v_texCoord.xyz, exp2(in.v_drefLodBias.y - 0.5) / float3(u_sampler.get_width()), exp2(in.v_drefLodBias.y - 0.5) / float3(u_sampler.get_width()))), 0.0, 0.0, 1.0); + out.o_color = float4(spvDepthCast(u_sampler).sample_compare(u_samplerSmplr, in.v_texCoord.xyz, uint(rint(in.v_texCoord.w)), in.v_drefLodBias.x, spvGradientCube(in.v_texCoord.xyz, exp2(in.v_drefLodBias.y - 0.5) / float3(u_sampler.get_width()), exp2(in.v_drefLodBias.y - 0.5) / float3(u_sampler.get_width()))), 0.0, 0.0, 1.0); return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/implicit-read-dep-phi.asm.frag b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/implicit-read-dep-phi.asm.frag index b72c12f8bda6..39d82b7a13d6 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/implicit-read-dep-phi.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/implicit-read-dep-phi.asm.frag @@ -25,7 +25,8 @@ fragment main0_out main0(main0_in in [[stage_in]], texture2d uImage [[tex for (;;) { out.FragColor = _45; - if (_57 < 4) + bool _22 = _57 < 4; + if (_22) { if (in.v0[_57] > 0.0) { diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/locations-components.asm.frag b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/locations-components.asm.frag index 191adb4972fb..d298c122dcec 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/locations-components.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/locations-components.asm.frag @@ -27,7 +27,7 @@ fragment main0_out main0(main0_in in [[stage_in]]) v2.x = in.m_22; v2.y = as_type(in.m_28); v2.z = as_type(in.m_33); - out.o0.y = float(as_type(as_type(as_type(v2.y) + as_type(v2.z)))); + out.o0.y = float(uint(as_type(v2.y) + as_type(v2.z))); out.o0.x = v1.y + v2.x; out.o0 = float4(out.o0.x, out.o0.y, v1.z, v1.x); return out; diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/reserved-msl-type-names.asm.frag b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/reserved-msl-type-names.asm.frag new file mode 100644 index 000000000000..0f4710ba13f9 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/reserved-msl-type-names.asm.frag @@ -0,0 +1,22 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 vUV [[user(locn0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texture2d sampler0 [[texture(0)]], texture2d depth2d0 [[texture(1)]], sampler sampler0Smplr [[sampler(0)]], sampler depth2d0Smplr [[sampler(1)]]) +{ + main0_out out = {}; + out.FragColor = sampler0.sample(sampler0Smplr, in.vUV) + depth2d0.sample(depth2d0Smplr, in.vUV); + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/sample-and-compare.asm.frag b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/sample-and-compare.asm.frag index aed8fd382a3d..99949f268e75 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/sample-and-compare.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/sample-and-compare.asm.frag @@ -1,8 +1,34 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float out_var_SV_Target [[color(0)]]; @@ -13,10 +39,10 @@ struct main0_in float2 in_var_TEXCOORD0 [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d g_Texture [[texture(0)]], sampler g_Sampler [[sampler(0)]], sampler g_CompareSampler [[sampler(1)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d g_Texture [[texture(0)]], sampler g_Sampler [[sampler(0)]], sampler g_CompareSampler [[sampler(1)]]) { main0_out out = {}; - out.out_var_SV_Target = float4(g_Texture.sample(g_Sampler, in.in_var_TEXCOORD0)).x + g_Texture.sample_compare(g_CompareSampler, in.in_var_TEXCOORD0, 0.5, level(0.0)); + out.out_var_SV_Target = float4(g_Texture.sample(g_Sampler, in.in_var_TEXCOORD0)).x + spvDepthCast(g_Texture).sample_compare(g_CompareSampler, in.in_var_TEXCOORD0, 0.5, level(0.0)); return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/texture-sampling-fp16.asm.frag b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/texture-sampling-fp16.asm.invalid.frag similarity index 100% rename from third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/texture-sampling-fp16.asm.frag rename to third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/texture-sampling-fp16.asm.invalid.frag diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/unknown-depth-state.asm.frag b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/unknown-depth-state.asm.frag index dc8740653869..fd59ae57c67e 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/unknown-depth-state.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/asm/frag/unknown-depth-state.asm.frag @@ -1,8 +1,34 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float FragColor [[color(0)]]; @@ -13,10 +39,10 @@ struct main0_in float3 vUV [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d uShadow [[texture(0)]], depth2d uTexture [[texture(1)]], sampler uShadowSmplr [[sampler(0)]], sampler uSampler [[sampler(1)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d uShadow [[texture(0)]], texture2d uTexture [[texture(1)]], sampler uShadowSmplr [[sampler(0)]], sampler uSampler [[sampler(1)]]) { main0_out out = {}; - out.FragColor = uShadow.sample_compare(uShadowSmplr, in.vUV.xy, in.vUV.z) + uTexture.sample_compare(uSampler, in.vUV.xy, in.vUV.z); + out.FragColor = spvDepthCast(uShadow).sample_compare(uShadowSmplr, in.vUV.xy, in.vUV.z) + spvDepthCast(uTexture).sample_compare(uSampler, in.vUV.xy, in.vUV.z); return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/array-length.msl2.argument.discrete.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/array-length.msl2.argument.discrete.comp index d804e1876794..54fad7b1911f 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/comp/array-length.msl2.argument.discrete.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/array-length.msl2.argument.discrete.comp @@ -51,6 +51,6 @@ kernel void main0(constant spvDescriptorSetBuffer0& spvDescriptorSet0 [[buffer(0 constant uint* spvDescriptorSet1_ssbosBufferSize = &spvDescriptorSet1.spvBufferSizeConstants[0]; constant uint& _38BufferSize = spvBufferSizeConstants[2]; constant uint* ssbos2BufferSize = &spvBufferSizeConstants[3]; - (*spvDescriptorSet0.m_16).size = ((uint(int((spvDescriptorSet0_m_16BufferSize - 16) / 16)) + uint(int((spvDescriptorSet1_ssbosBufferSize[1] - 0) / 4))) + uint(int((_38BufferSize - 16) / 16))) + uint(int((ssbos2BufferSize[0] - 0) / 4)); + (*spvDescriptorSet0.m_16).size = ((((spvDescriptorSet0_m_16BufferSize - 16) / 16) + ((spvDescriptorSet1_ssbosBufferSize[1] - 0) / 4)) + ((_38BufferSize - 16) / 16)) + ((ssbos2BufferSize[0] - 0) / 4); } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/buffer_device_address-packed-vec-and-cast-to-and-from-uvec2.msl23.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/buffer_device_address-packed-vec-and-cast-to-and-from-uvec2.msl23.comp index 30e89455d7fd..9d2d761a7462 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/comp/buffer_device_address-packed-vec-and-cast-to-and-from-uvec2.msl23.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/buffer_device_address-packed-vec-and-cast-to-and-from-uvec2.msl23.comp @@ -19,7 +19,8 @@ struct SSBO kernel void main0(constant UBO& _10 [[buffer(0)]]) { (reinterpret_cast(as_type(_10.b)))->a1 = float3(1.0, 2.0, 3.0); - device SSBO* _39 = reinterpret_cast(as_type(as_type(reinterpret_cast(reinterpret_cast(as_type(_10.b + uint2(32u))))))); - _39->a1 = float3(_39->a1) + float3(1.0); + device SSBO* _39 = reinterpret_cast(as_type(_10.b + uint2(32u))); + float3 _41 = float3(_39->a1); + _39->a1 = _41 + float3(1.0); } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/ray-query.spv14.vk.ios.msl24..invalid.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/ray-query.spv14.vk.ios.msl24..invalid.comp index 09802dd26280..0a39993cee0b 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/comp/ray-query.spv14.vk.ios.msl24..invalid.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/ray-query.spv14.vk.ios.msl24..invalid.comp @@ -66,7 +66,7 @@ kernel void main0(constant Params& _18 [[buffer(1)]], raytracing::acceleration_s uint type = _80; uint _83 = uint(q2[0].get_candidate_intersection_type()) - 1; type = _83; - bool _85 = q2[1].is_candidate_non_opaque_bounding_box(); + bool _85 = (!q2[1].is_candidate_non_opaque_bounding_box()); res = _85; float _87 = q2[1].get_committed_distance(); fval = _87; diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/shader_ballot.msl22.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/shader_ballot.msl22.comp index a1bd55247de5..394dfbf86388 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/comp/shader_ballot.msl22.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/shader_ballot.msl22.comp @@ -68,7 +68,7 @@ kernel void main0(device inputData& _12 [[buffer(0)]], device outputData& _87 [[ 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)); bool _31 = _12.inputDataArray[gl_LocalInvocationID.x] > 0.0; uint4 _52 = spvSubgroupBallot(_31); - uint4 _66 = uint4(int4(popcount(uint4(as_type(as_type(uint2(gl_SubgroupLtMask.xy))), 0u, 0u) & uint4(as_type(as_type(uint2(_52.xy))), 0u, 0u)))); + uint4 _66 = uint4(int4(popcount(uint4(gl_SubgroupLtMask.xy, 0u, 0u) & uint4(_52.xy, 0u, 0u)))); if (_31) { _87.outputDataArray[_66.x + _66.y] = _12.inputDataArray[gl_LocalInvocationID.x]; diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/shared-matrix-array-of-array.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/shared-matrix-array-of-array.comp index 0e17f95cb85b..4c03f071b5f9 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/comp/shared-matrix-array-of-array.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/shared-matrix-array-of-array.comp @@ -1267,7 +1267,7 @@ kernel void main0(device block& _383 [[buffer(0)]]) bool _305; if (_296) { - _305 = true == bool(s2.b[0][0][0]); + _305 = bool(s2.b[0][0][0]); } else { @@ -1276,7 +1276,7 @@ kernel void main0(device block& _383 [[buffer(0)]]) bool _314; if (_305) { - _314 = false == bool(s2.b[0][0][1]); + _314 = !bool(s2.b[0][0][1]); } else { @@ -1285,7 +1285,7 @@ kernel void main0(device block& _383 [[buffer(0)]]) bool _323; if (_314) { - _323 = false == bool(s2.b[0][0][2]); + _323 = !bool(s2.b[0][0][2]); } else { @@ -1294,7 +1294,7 @@ kernel void main0(device block& _383 [[buffer(0)]]) bool _332; if (_323) { - _332 = true == bool(s2.b[1][0][0]); + _332 = bool(s2.b[1][0][0]); } else { @@ -1303,7 +1303,7 @@ kernel void main0(device block& _383 [[buffer(0)]]) bool _341; if (_332) { - _341 = false == bool(s2.b[1][0][1]); + _341 = !bool(s2.b[1][0][1]); } else { @@ -1312,7 +1312,7 @@ kernel void main0(device block& _383 [[buffer(0)]]) bool _350; if (_341) { - _350 = true == bool(s2.b[1][0][2]); + _350 = bool(s2.b[1][0][2]); } else { @@ -1321,7 +1321,7 @@ kernel void main0(device block& _383 [[buffer(0)]]) bool _359; if (_350) { - _359 = false == bool(s2.b[2][0][0]); + _359 = !bool(s2.b[2][0][0]); } else { @@ -1330,7 +1330,7 @@ kernel void main0(device block& _383 [[buffer(0)]]) bool _368; if (_359) { - _368 = true == bool(s2.b[2][0][1]); + _368 = bool(s2.b[2][0][1]); } else { @@ -1339,7 +1339,7 @@ kernel void main0(device block& _383 [[buffer(0)]]) bool _377; if (_368) { - _377 = true == bool(s2.b[2][0][2]); + _377 = bool(s2.b[2][0][2]); } else { diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/shared-matrix-nested-struct-array.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/shared-matrix-nested-struct-array.comp index dfbd7a76664b..03b3d0dbc502 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/comp/shared-matrix-nested-struct-array.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/shared-matrix-nested-struct-array.comp @@ -1346,7 +1346,7 @@ kernel void main0(device block& _424 [[buffer(0)]]) bool _409; if (_400) { - _409 = all(bool3(false) == bool3(s1.c[1].mA[0])); + _409 = all(not(bool3(s1.c[1].mA[0]))); } else { @@ -1355,7 +1355,7 @@ kernel void main0(device block& _424 [[buffer(0)]]) bool _418; if (_409) { - _418 = all(bool3(false) == bool3(s1.c[1].mA[1])); + _418 = all(not(bool3(s1.c[1].mA[1]))); } else { diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/shared-matrix-nested-struct.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/shared-matrix-nested-struct.comp index 6565536651d6..12b6b2a30145 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/comp/shared-matrix-nested-struct.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/shared-matrix-nested-struct.comp @@ -1216,7 +1216,7 @@ kernel void main0(device block& _612 [[buffer(0)]]) bool _480; if (_471) { - _480 = all(bool2(true) == bool2(s2.a.mA.mB.mA)); + _480 = all(bool2(s2.a.mA.mB.mA)); } else { @@ -1270,7 +1270,7 @@ kernel void main0(device block& _612 [[buffer(0)]]) bool _534; if (_525) { - _534 = false == bool(s2.c.mA.mA.mB); + _534 = !bool(s2.c.mA.mA.mB); } else { @@ -1402,7 +1402,7 @@ kernel void main0(device block& _612 [[buffer(0)]]) bool _579; if (_570) { - _579 = all(bool3(false) == bool3(s2.d.mB.mA.mB)); + _579 = all(not(bool3(s2.d.mB.mA.mB))); } else { diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/storage-buffer-std140-vector-array.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/storage-buffer-std140-vector-array.comp index b584f307ef29..2f3149344e33 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/comp/storage-buffer-std140-vector-array.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/storage-buffer-std140-vector-array.comp @@ -62,17 +62,17 @@ constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); kernel void main0(device SSBO& _27 [[buffer(0)]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { spvUnsafeArray _155; - _155[0] = _27.sub[gl_WorkGroupID.x].f[0].x; - _155[1] = _27.sub[gl_WorkGroupID.x].f[1].x; + _155[0] = _27.sub[gl_WorkGroupID.x].f[0u].x; + _155[1] = _27.sub[gl_WorkGroupID.x].f[1u].x; spvUnsafeArray _156; - _156[0] = _27.sub[gl_WorkGroupID.x].f2[0].xy; - _156[1] = _27.sub[gl_WorkGroupID.x].f2[1].xy; + _156[0] = _27.sub[gl_WorkGroupID.x].f2[0u].xy; + _156[1] = _27.sub[gl_WorkGroupID.x].f2[1u].xy; spvUnsafeArray _157; - _157[0] = _27.sub[gl_WorkGroupID.x].f3[0]; - _157[1] = _27.sub[gl_WorkGroupID.x].f3[1]; + _157[0] = _27.sub[gl_WorkGroupID.x].f3[0u]; + _157[1] = _27.sub[gl_WorkGroupID.x].f3[1u]; spvUnsafeArray _158; - _158[0] = _27.sub[gl_WorkGroupID.x].f4[0]; - _158[1] = _27.sub[gl_WorkGroupID.x].f4[1]; + _158[0] = _27.sub[gl_WorkGroupID.x].f4[0u]; + _158[1] = _27.sub[gl_WorkGroupID.x].f4[1u]; _155[gl_GlobalInvocationID.x] += 1.0; _156[gl_GlobalInvocationID.x] += float2(2.0); _157[gl_GlobalInvocationID.x] += float3(3.0); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/comp/struct-packing.comp b/third_party/spirv-cross/reference/opt/shaders-msl/comp/struct-packing.comp index dc1654399d3a..dc2894e54998 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/comp/struct-packing.comp +++ b/third_party/spirv-cross/reference/opt/shaders-msl/comp/struct-packing.comp @@ -1,13 +1,17 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +struct spvPaddedArrayElement { T data; char padding[stride - sizeof(T)]; }; + struct S0 { float2 a[1]; float b; - char _m0_final_padding[4]; }; struct S1 @@ -20,7 +24,6 @@ struct S2 { float3 a[1]; float b; - char _m0_final_padding[12]; }; struct S3 @@ -45,7 +48,6 @@ struct Content S3 m3; float m4; S4 m3s[8]; - char _m0_final_padding[8]; }; struct SSBO1 @@ -69,7 +71,6 @@ struct S0_1 float2 a[1]; char _m1_pad[8]; float b; - char _m0_final_padding[12]; }; struct S1_1 @@ -82,7 +83,6 @@ struct S2_1 { float3 a[1]; float b; - char _m0_final_padding[12]; }; struct S3_1 @@ -94,21 +94,21 @@ struct S3_1 struct S4_1 { float2 c; - char _m0_final_padding[8]; }; struct Content_1 { - S0_1 m0s[1]; + spvPaddedArrayElement m0s[1]; S1_1 m1s[1]; S2_1 m2s[1]; S0_1 m0; + char _m4_pad[8]; S1_1 m1; S2_1 m2; S3_1 m3; float m4; char _m8_pad[8]; - S4_1 m3s[8]; + spvPaddedArrayElement m3s[8]; }; struct SSBO0 @@ -123,30 +123,51 @@ constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); kernel void main0(device SSBO1& ssbo_430 [[buffer(0)]], device SSBO0& ssbo_140 [[buffer(1)]]) { - Content_1 _60 = ssbo_140.content; - ssbo_430.content.m0s[0].a[0] = _60.m0s[0].a[0]; - ssbo_430.content.m0s[0].b = _60.m0s[0].b; - ssbo_430.content.m1s[0].a = float3(_60.m1s[0].a); - ssbo_430.content.m1s[0].b = _60.m1s[0].b; - ssbo_430.content.m2s[0].a[0] = _60.m2s[0].a[0]; - ssbo_430.content.m2s[0].b = _60.m2s[0].b; - ssbo_430.content.m0.a[0] = _60.m0.a[0]; - ssbo_430.content.m0.b = _60.m0.b; - ssbo_430.content.m1.a = float3(_60.m1.a); - ssbo_430.content.m1.b = _60.m1.b; - ssbo_430.content.m2.a[0] = _60.m2.a[0]; - ssbo_430.content.m2.b = _60.m2.b; - ssbo_430.content.m3.a = _60.m3.a; - ssbo_430.content.m3.b = _60.m3.b; - ssbo_430.content.m4 = _60.m4; - ssbo_430.content.m3s[0].c = _60.m3s[0].c; - ssbo_430.content.m3s[1].c = _60.m3s[1].c; - ssbo_430.content.m3s[2].c = _60.m3s[2].c; - ssbo_430.content.m3s[3].c = _60.m3s[3].c; - ssbo_430.content.m3s[4].c = _60.m3s[4].c; - ssbo_430.content.m3s[5].c = _60.m3s[5].c; - ssbo_430.content.m3s[6].c = _60.m3s[6].c; - ssbo_430.content.m3s[7].c = _60.m3s[7].c; + float _200 = ssbo_140.content.m0s[0u].data.b; + float3 _208 = float3(ssbo_140.content.m1s[0u].a); + float _210 = ssbo_140.content.m1s[0u].b; + float3 _221 = ssbo_140.content.m2s[0u].a[0u]; + float _223 = ssbo_140.content.m2s[0u].b; + float2 _230 = ssbo_140.content.m0.a[0u]; + float _232 = ssbo_140.content.m0.b; + float3 _236 = float3(ssbo_140.content.m1.a); + float _238 = ssbo_140.content.m1.b; + float3 _245 = ssbo_140.content.m2.a[0u]; + float _247 = ssbo_140.content.m2.b; + float2 _253 = ssbo_140.content.m3.a; + float _255 = ssbo_140.content.m3.b; + float _258 = ssbo_140.content.m4; + float2 _266 = ssbo_140.content.m3s[0u].data.c; + float2 _270 = ssbo_140.content.m3s[1u].data.c; + float2 _274 = ssbo_140.content.m3s[2u].data.c; + float2 _278 = ssbo_140.content.m3s[3u].data.c; + float2 _282 = ssbo_140.content.m3s[4u].data.c; + float2 _286 = ssbo_140.content.m3s[5u].data.c; + float2 _290 = ssbo_140.content.m3s[6u].data.c; + float2 _294 = ssbo_140.content.m3s[7u].data.c; + ssbo_430.content.m0s[0].a[0] = ssbo_140.content.m0s[0u].data.a[0u]; + ssbo_430.content.m0s[0].b = _200; + ssbo_430.content.m1s[0].a = _208; + ssbo_430.content.m1s[0].b = _210; + ssbo_430.content.m2s[0].a[0] = _221; + ssbo_430.content.m2s[0].b = _223; + ssbo_430.content.m0.a[0] = _230; + ssbo_430.content.m0.b = _232; + ssbo_430.content.m1.a = _236; + ssbo_430.content.m1.b = _238; + ssbo_430.content.m2.a[0] = _245; + ssbo_430.content.m2.b = _247; + ssbo_430.content.m3.a = _253; + ssbo_430.content.m3.b = _255; + ssbo_430.content.m4 = _258; + ssbo_430.content.m3s[0].c = _266; + ssbo_430.content.m3s[1].c = _270; + ssbo_430.content.m3s[2].c = _274; + ssbo_430.content.m3s[3].c = _278; + ssbo_430.content.m3s[4].c = _282; + ssbo_430.content.m3s[5].c = _286; + ssbo_430.content.m3s[6].c = _290; + ssbo_430.content.m3s[7].c = _294; ssbo_430.content.m1.a = ssbo_430.content.m3.a * ssbo_430.m6[1][1]; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/desktop-only/vert/shader-draw-parameters.desktop.for-tess.vert b/third_party/spirv-cross/reference/opt/shaders-msl/desktop-only/vert/shader-draw-parameters.desktop.for-tess.vert index b3c8b6bb2789..d5ca47be7143 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/desktop-only/vert/shader-draw-parameters.desktop.for-tess.vert +++ b/third_party/spirv-cross/reference/opt/shaders-msl/desktop-only/vert/shader-draw-parameters.desktop.for-tess.vert @@ -8,13 +8,14 @@ struct main0_out float4 gl_Position; }; -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 spvStageInputSize [[grid_size]], uint3 spvDispatchBase [[grid_origin]], device main0_out* spvOut [[buffer(28)]]) +kernel void main0(constant uint* spvDrawIndex [[buffer(19)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 spvStageInputSize [[grid_size]], uint3 spvDispatchBase [[grid_origin]], 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; uint gl_BaseVertex = spvDispatchBase.x; uint gl_BaseInstance = spvDispatchBase.y; - out.gl_Position = float4(float(int(gl_BaseVertex)), float(int(gl_BaseInstance)), 0.0, 1.0); + uint gl_DrawID = *spvDrawIndex; + out.gl_Position = float4(float(int(gl_BaseVertex)), float(int(gl_BaseInstance)), float(int(gl_DrawID)), 1.0); } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/desktop-only/vert/shader-draw-parameters.desktop.vert b/third_party/spirv-cross/reference/opt/shaders-msl/desktop-only/vert/shader-draw-parameters.desktop.vert index a32c1948f880..a6d42a021e63 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/desktop-only/vert/shader-draw-parameters.desktop.vert +++ b/third_party/spirv-cross/reference/opt/shaders-msl/desktop-only/vert/shader-draw-parameters.desktop.vert @@ -8,10 +8,11 @@ struct main0_out float4 gl_Position [[position]]; }; -vertex main0_out main0(uint gl_BaseVertex [[base_vertex]], uint gl_BaseInstance [[base_instance]]) +vertex main0_out main0(constant uint* spvDrawIndex [[buffer(19)]], uint gl_BaseVertex [[base_vertex]], uint gl_BaseInstance [[base_instance]]) { main0_out out = {}; - out.gl_Position = float4(float(int(gl_BaseVertex)), float(int(gl_BaseInstance)), 0.0, 1.0); + uint gl_DrawID = *spvDrawIndex; + out.gl_Position = float4(float(int(gl_BaseVertex)), float(int(gl_BaseInstance)), float(int(gl_DrawID)), 1.0); return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/bitcasting.1d-as-2d.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/bitcasting.1d-as-2d.frag index d341397f4c0b..5c01143cf921 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/frag/bitcasting.1d-as-2d.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/bitcasting.1d-as-2d.frag @@ -17,10 +17,9 @@ struct main0_in fragment main0_out main0(main0_in in [[stage_in]], texture2d TextureBase [[texture(0)]], texture2d TextureDetail [[texture(1)]], sampler TextureBaseSmplr [[sampler(0)]], sampler TextureDetailSmplr [[sampler(1)]]) { main0_out out = {}; - float4 _22 = TextureBase.sample(TextureBaseSmplr, float2(in.VertGeom.x, 0.5)); - float4 _30 = TextureDetail.sample(TextureDetailSmplr, float2(in.VertGeom.x, 0.5), int2(3, 0)); - out.FragColor0 = as_type(as_type(_22)) * as_type(as_type(_30)); - out.FragColor1 = as_type(as_type(_22)) * as_type(as_type(_30)); + float4 _45 = TextureBase.sample(TextureBaseSmplr, float2(in.VertGeom.x, 0.5)) * TextureDetail.sample(TextureDetailSmplr, float2(in.VertGeom.x, 0.5), int2(3, 0)); + out.FragColor0 = _45; + out.FragColor1 = _45; return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/bitcasting.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/bitcasting.frag index ae6d45e013ee..acb3d9df24a6 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/frag/bitcasting.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/bitcasting.frag @@ -17,10 +17,9 @@ struct main0_in fragment main0_out main0(main0_in in [[stage_in]], texture2d TextureBase [[texture(0)]], texture2d TextureDetail [[texture(1)]], sampler TextureBaseSmplr [[sampler(0)]], sampler TextureDetailSmplr [[sampler(1)]]) { main0_out out = {}; - float4 _20 = TextureBase.sample(TextureBaseSmplr, in.VertGeom.xy); - float4 _31 = TextureDetail.sample(TextureDetailSmplr, in.VertGeom.xy, int2(3, 2)); - out.FragColor0 = as_type(as_type(_20)) * as_type(as_type(_31)); - out.FragColor1 = as_type(as_type(_20)) * as_type(as_type(_31)); + float4 _46 = TextureBase.sample(TextureBaseSmplr, in.VertGeom.xy) * TextureDetail.sample(TextureDetailSmplr, in.VertGeom.xy, int2(3, 2)); + out.FragColor0 = _46; + out.FragColor1 = _46; return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.msl23.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.msl23.frag index f6751a42d3bf..4e7b1b31cbc5 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.msl23.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.msl23.frag @@ -1,8 +1,34 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float4 o_color [[color(0)]]; @@ -14,10 +40,10 @@ struct main0_in float v_lodBias [[user(locn1)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d_array u_sampler [[texture(0)]], sampler u_samplerSmplr [[sampler(0)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d_array u_sampler [[texture(0)]], sampler u_samplerSmplr [[sampler(0)]]) { main0_out out = {}; - out.o_color = float4(u_sampler.sample_compare(u_samplerSmplr, float2(in.v_texCoord.x, 0.5), uint(rint(in.v_texCoord.y)), in.v_texCoord.z, gradient2d(exp2(in.v_lodBias - 0.5) / float2(u_sampler.get_width(), 1.0), exp2(in.v_lodBias - 0.5) / float2(u_sampler.get_width(), 1.0))), 0.0, 0.0, 1.0); + out.o_color = float4(spvDepthCast(u_sampler).sample_compare(u_samplerSmplr, float2(in.v_texCoord.x, 0.5), uint(rint(in.v_texCoord.y)), in.v_texCoord.z, gradient2d(exp2(in.v_lodBias - 0.5) / float2(u_sampler.get_width(), 1.0), exp2(in.v_lodBias - 0.5) / float2(u_sampler.get_width(), 1.0))), 0.0, 0.0, 1.0); return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/gather-compare-const-offsets.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/gather-compare-const-offsets.frag index 600fb1747208..9aa28ce5be40 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/frag/gather-compare-const-offsets.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/gather-compare-const-offsets.frag @@ -83,6 +83,30 @@ inline spvGatherCompareReturn spvGatherCompareConstOffsets(const thr return spvGatherCompareReturn(rslts[0].w, rslts[1].w, rslts[2].w, rslts[3].w); } +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + constant spvUnsafeArray _38 = spvUnsafeArray({ int2(-8, 3), int2(-4, 7), int2(0, 3), int2(3, 0) }); struct main0_out @@ -96,10 +120,10 @@ struct main0_in float2 compare_value [[user(locn1)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d tex [[texture(0)]], sampler texSmplr [[sampler(0)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d tex [[texture(0)]], sampler texSmplr [[sampler(0)]]) { main0_out out = {}; - out.FragColor = spvGatherCompareConstOffsets(tex, texSmplr, _38, in.coord, in.compare_value.x); + out.FragColor = spvGatherCompareConstOffsets(spvDepthCast(tex), texSmplr, _38, in.coord, in.compare_value.x); return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/gather-dref.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/gather-dref.frag index c5c5ccf0bbbc..19e345b315c6 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/frag/gather-dref.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/gather-dref.frag @@ -1,8 +1,34 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float4 FragColor [[color(0)]]; @@ -13,10 +39,10 @@ struct main0_in float3 vUV [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d uT [[texture(0)]], sampler uTSmplr [[sampler(0)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d uT [[texture(0)]], sampler uTSmplr [[sampler(0)]]) { main0_out out = {}; - out.FragColor = uT.gather_compare(uTSmplr, in.vUV.xy, in.vUV.z); + out.FragColor = spvDepthCast(uT).gather_compare(uTSmplr, in.vUV.xy, in.vUV.z); return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-depth-propagate-state-from-resource.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-depth-propagate-state-from-resource.frag index 4f7e9b53b24f..afa848cd0d16 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-depth-propagate-state-from-resource.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-depth-propagate-state-from-resource.frag @@ -1,8 +1,34 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float FragColor [[color(0)]]; @@ -13,11 +39,11 @@ struct main0_in float3 vUV [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d uTexture [[texture(0)]], sampler uSampler [[sampler(0)]], sampler uSamplerShadow [[sampler(1)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d uTexture [[texture(0)]], sampler uSampler [[sampler(0)]], sampler uSamplerShadow [[sampler(1)]]) { main0_out out = {}; out.FragColor = float4(uTexture.sample(uSampler, in.vUV.xy)).x; - out.FragColor += uTexture.sample_compare(uSamplerShadow, in.vUV.xy, in.vUV.z); + out.FragColor += spvDepthCast(uTexture).sample_compare(uSamplerShadow, in.vUV.xy, in.vUV.z); return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-depth-separate-image-sampler.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-depth-separate-image-sampler.frag index 6626946c4506..e3be6af2c794 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-depth-separate-image-sampler.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sample-depth-separate-image-sampler.frag @@ -1,17 +1,43 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float FragColor [[color(0)]]; }; -fragment main0_out main0(depth2d uDepth [[texture(0)]], texture2d uColor [[texture(1)]], sampler uSamplerShadow [[sampler(0)]], sampler uSampler [[sampler(1)]]) +fragment main0_out main0(texture2d uDepth [[texture(0)]], texture2d uColor [[texture(1)]], sampler uSamplerShadow [[sampler(0)]], sampler uSampler [[sampler(1)]]) { main0_out out = {}; - out.FragColor = uDepth.sample_compare(uSamplerShadow, float3(0.5).xy, 0.5) + uColor.sample(uSampler, float2(0.5)).x; + out.FragColor = spvDepthCast(uDepth).sample_compare(uSamplerShadow, float3(0.5).xy, 0.5) + uColor.sample(uSampler, float2(0.5)).x; return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/sampler-compare-bias.msl23.1d-as-2d.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sampler-compare-bias.msl23.1d-as-2d.frag index 924736ebb0ac..16a579d874df 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/frag/sampler-compare-bias.msl23.1d-as-2d.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sampler-compare-bias.msl23.1d-as-2d.frag @@ -1,8 +1,34 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float FragColor [[color(0)]]; @@ -13,10 +39,10 @@ struct main0_in float3 vUV [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d_array uTex [[texture(0)]], sampler uShadow [[sampler(0)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d_array uTex [[texture(0)]], sampler uShadow [[sampler(0)]]) { main0_out out = {}; - out.FragColor = uTex.sample_compare(uShadow, float2(in.vUV.x, 0.5), uint(rint(in.vUV.y)), in.vUV.z, bias(1.0)); + out.FragColor = spvDepthCast(uTex).sample_compare(uShadow, float2(in.vUV.x, 0.5), uint(rint(in.vUV.y)), in.vUV.z, bias(1.0)); return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/sampler-compare-cascade-gradient.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sampler-compare-cascade-gradient.frag index 092b11d18aa7..890804cf7af3 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/frag/sampler-compare-cascade-gradient.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sampler-compare-cascade-gradient.frag @@ -1,8 +1,34 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float FragColor [[color(0)]]; @@ -13,10 +39,10 @@ struct main0_in float4 vUV [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d_array uTex [[texture(0)]], sampler uShadow [[sampler(0)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d_array uTex [[texture(0)]], sampler uShadow [[sampler(0)]]) { main0_out out = {}; - out.FragColor = uTex.sample_compare(uShadow, in.vUV.xy, uint(rint(in.vUV.z)), in.vUV.w, level(0)); + out.FragColor = spvDepthCast(uTex).sample_compare(uShadow, in.vUV.xy, uint(rint(in.vUV.z)), in.vUV.w, level(0)); return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/sampler-compare-cascade-gradient.ios.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sampler-compare-cascade-gradient.ios.frag index fdd4d1644263..c672a95e85f8 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/frag/sampler-compare-cascade-gradient.ios.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sampler-compare-cascade-gradient.ios.frag @@ -1,8 +1,28 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float FragColor [[color(0)]]; @@ -13,10 +33,10 @@ struct main0_in float4 vUV [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d_array uTex [[texture(0)]], sampler uShadow [[sampler(0)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d_array uTex [[texture(0)]], sampler uShadow [[sampler(0)]]) { main0_out out = {}; - out.FragColor = uTex.sample_compare(uShadow, in.vUV.xy, uint(rint(in.vUV.z)), in.vUV.w, gradient2d(float2(0.0), float2(0.0))); + out.FragColor = spvDepthCast(uTex).sample_compare(uShadow, in.vUV.xy, uint(rint(in.vUV.z)), in.vUV.w, gradient2d(float2(0.0), float2(0.0))); return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/sampler-compare-cascade-gradient.msl23.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sampler-compare-cascade-gradient.msl23.frag index f66f5d38c151..5b93c0976676 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/frag/sampler-compare-cascade-gradient.msl23.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/sampler-compare-cascade-gradient.msl23.frag @@ -1,8 +1,34 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float FragColor [[color(0)]]; @@ -13,10 +39,10 @@ struct main0_in float4 vUV [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d_array uTex [[texture(0)]], sampler uShadow [[sampler(0)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d_array uTex [[texture(0)]], sampler uShadow [[sampler(0)]]) { main0_out out = {}; - out.FragColor = uTex.sample_compare(uShadow, in.vUV.xy, uint(rint(in.vUV.z)), in.vUV.w, level(0)) + uTex.sample_compare(uShadow, in.vUV.xy, uint(rint(in.vUV.z)), in.vUV.w, gradient2d(float2(1.0), float2(1.0))); + out.FragColor = spvDepthCast(uTex).sample_compare(uShadow, in.vUV.xy, uint(rint(in.vUV.z)), in.vUV.w, level(0)) + spvDepthCast(uTex).sample_compare(uShadow, in.vUV.xy, uint(rint(in.vUV.z)), in.vUV.w, gradient2d(float2(1.0), float2(1.0))); return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/shader-debug-info-line-directives.line.gV.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/shader-debug-info-line-directives.line.gV.frag index c62e16fd4f8d..589b21257b9b 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/frag/shader-debug-info-line-directives.line.gV.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/shader-debug-info-line-directives.line.gV.frag @@ -18,8 +18,8 @@ fragment main0_out main0(main0_in in [[stage_in]]) main0_out out = {}; #line 137 "test.frag" #line 106 "test.frag" - bool _288 = in.iv.x < 0.0; - if (_288) + bool _298 = in.iv.x < 0.0; + if (_298) { #line 107 "test.frag" out.ov.x = 50.0; @@ -30,10 +30,10 @@ fragment main0_out main0(main0_in in [[stage_in]]) out.ov.x = 60.0; } #line 114 "test.frag" - for (int _519 = 0; _519 < 4; _519++) + for (int _529 = 0; _529 < 4; _529++) { #line 106 "test.frag" - if (_288) + if (_298) { #line 107 "test.frag" out.ov.x = 50.0; @@ -56,10 +56,10 @@ fragment main0_out main0(main0_in in [[stage_in]]) } } #line 126 "test.frag" - for (int _523 = 0; _523 < 4; _523++) + for (int _533 = 0; _533 < 4; _533++) { #line 106 "test.frag" - if (_288) + if (_298) { #line 107 "test.frag" out.ov.x = 50.0; @@ -70,10 +70,10 @@ fragment main0_out main0(main0_in in [[stage_in]]) out.ov.x = 60.0; } #line 114 "test.frag" - for (int _527 = 0; _527 < 4; _527++) + for (int _537 = 0; _537 < 4; _537++) { #line 106 "test.frag" - if (_288) + if (_298) { #line 107 "test.frag" out.ov.x = 50.0; diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/struct-array-stride-padded-element.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/struct-array-stride-padded-element.frag new file mode 100644 index 000000000000..decfed02929f --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/struct-array-stride-padded-element.frag @@ -0,0 +1,52 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +template +struct spvPaddedArrayElement { T data; char padding[stride - sizeof(T)]; }; + +struct SpotLight +{ + packed_float3 position; + float range; + packed_float3 direction; + float angle; + packed_float3 color; + float intensity; + float penumbra; +}; + +struct UBO +{ + spvPaddedArrayElement spot_lights[4]; + int spot_light_count; + char _m2_pad[12]; + packed_float3 albedo; + float roughness; + float alpha; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(constant UBO& ubo [[buffer(0)]]) +{ + main0_out out = {}; + int _27 = min(ubo.spot_light_count, 4); + float3 _79; + _79 = float3(0.0); + for (int _78 = 0; _78 < _27; ) + { + _79 += ((float3(ubo.spot_lights[_78].data.color) * ubo.spot_lights[_78].data.intensity) * ubo.spot_lights[_78].data.penumbra); + _78++; + continue; + } + out.FragColor = float4(ubo.albedo[0u], ubo.roughness, ubo.alpha * _79.z, 1.0); + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/frag/texture-proj-shadow.frag b/third_party/spirv-cross/reference/opt/shaders-msl/frag/texture-proj-shadow.frag index 6d465ce9f9fd..347e1fbc8299 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/frag/texture-proj-shadow.frag +++ b/third_party/spirv-cross/reference/opt/shaders-msl/frag/texture-proj-shadow.frag @@ -1,8 +1,34 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float FragColor [[color(0)]]; @@ -15,13 +41,13 @@ struct main0_in float2 vClip2 [[user(locn2)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d uShadow2D [[texture(0)]], texture1d uSampler1D [[texture(1)]], texture2d uSampler2D [[texture(2)]], texture3d uSampler3D [[texture(3)]], sampler uShadow2DSmplr [[sampler(0)]], sampler uSampler1DSmplr [[sampler(1)]], sampler uSampler2DSmplr [[sampler(2)]], sampler uSampler3DSmplr [[sampler(3)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d uShadow2D [[texture(0)]], texture1d uSampler1D [[texture(1)]], texture2d uSampler2D [[texture(2)]], texture3d uSampler3D [[texture(3)]], sampler uShadow2DSmplr [[sampler(0)]], sampler uSampler1DSmplr [[sampler(1)]], sampler uSampler2DSmplr [[sampler(2)]], sampler uSampler3DSmplr [[sampler(3)]]) { main0_out out = {}; float4 _17 = in.vClip4; float4 _20 = _17; _20.z = _17.w; - out.FragColor = uShadow2D.sample_compare(uShadow2DSmplr, _20.xy / _20.z, _17.z / _20.z); + out.FragColor = spvDepthCast(uShadow2D).sample_compare(uShadow2DSmplr, _20.xy / _20.z, _17.z / _20.z); out.FragColor = uSampler1D.sample(uSampler1DSmplr, in.vClip2.x / in.vClip2.y).x; out.FragColor = uSampler2D.sample(uSampler2DSmplr, in.vClip3.xy / in.vClip3.z).x; out.FragColor = uSampler3D.sample(uSampler3DSmplr, _17.xyz / _17.w).x; diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/mesh/mesh-shader-basic-lines.msl3.spv14.vk.nocompat.mesh b/third_party/spirv-cross/reference/opt/shaders-msl/mesh/mesh-shader-basic-lines.msl3.spv14.vk.nocompat.mesh index d7c4871b9100..3ec35ae2e347 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/mesh/mesh-shader-basic-lines.msl3.spv14.vk.nocompat.mesh +++ b/third_party/spirv-cross/reference/opt/shaders-msl/mesh/mesh-shader-basic-lines.msl3.spv14.vk.nocompat.mesh @@ -159,7 +159,6 @@ void _4(threadgroup spvUnsafeArray& gl_PrimitiveLineIndicesEXT, threa threadgroup spvUnsafeArray outputs; threadgroup spvUnsafeArray vPrim; threadgroup spvUnsafeArray prim_outputs; - threadgroup spvUnsafeArray shared_float; if (gl_LocalInvocationIndex == 0) spvMeshSizes.y = 0u; _4(gl_PrimitiveLineIndicesEXT, gl_LocalInvocationIndex, gl_MeshPrimitivesEXT, gl_GlobalInvocationID, gl_MeshVerticesEXT, vOut, outputs, vPrim, gl_WorkGroupID, prim_outputs, payload, spvMeshSizes); threadgroup_barrier(mem_flags::mem_threadgroup); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/mesh/mesh-shader-basic-triangle.msl3.spv14.vk.nocompat.mesh b/third_party/spirv-cross/reference/opt/shaders-msl/mesh/mesh-shader-basic-triangle.msl3.spv14.vk.nocompat.mesh index f94a68b1618b..666eacbeff4a 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/mesh/mesh-shader-basic-triangle.msl3.spv14.vk.nocompat.mesh +++ b/third_party/spirv-cross/reference/opt/shaders-msl/mesh/mesh-shader-basic-triangle.msl3.spv14.vk.nocompat.mesh @@ -159,7 +159,6 @@ void _4(threadgroup spvUnsafeArray& gl_MeshVerticesEXT, threadgroup spvUnsafeArray prim_outputs; threadgroup spvUnsafeArray gl_PrimitiveTriangleIndicesEXT; threadgroup spvUnsafeArray gl_MeshPrimitivesEXT; - threadgroup spvUnsafeArray shared_float; if (gl_LocalInvocationIndex == 0) spvMeshSizes.y = 0u; _4(gl_MeshVerticesEXT, gl_LocalInvocationIndex, gl_GlobalInvocationID, vOut, outputs, vPrim, gl_WorkGroupID, prim_outputs, payload, gl_PrimitiveTriangleIndicesEXT, gl_MeshPrimitivesEXT, spvMeshSizes); threadgroup_barrier(mem_flags::mem_threadgroup); 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 de6ba1780756..5f6ac6572255 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 @@ -67,7 +67,6 @@ kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], devic 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); - int _27 = gl_InvocationID ^ 1; - gl_out[gl_InvocationID].vOutputs = ((gl_in[gl_InvocationID].vInputs.a[1] + gl_in[gl_InvocationID].vInputs.b[1]) + gl_in[gl_InvocationID].vInputs.c) + gl_in[_27].vInputs.c; + gl_out[gl_InvocationID].vOutputs = ((gl_in[gl_InvocationID].vInputs.a[1] + gl_in[gl_InvocationID].vInputs.b[1]) + gl_in[gl_InvocationID].vInputs.c) + gl_in[gl_InvocationID ^ 1].vInputs.c; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/load-control-point-array-of-struct.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/load-control-point-array-of-struct.tesc index 9eaaa2e6d501..d6d629045de8 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/load-control-point-array-of-struct.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/load-control-point-array-of-struct.tesc @@ -75,7 +75,6 @@ kernel void main0(main0_in in [[stage_in]], uint gl_InvocationID [[thread_index_ threadgroup_barrier(mem_flags::mem_threadgroup); if (gl_InvocationID >= 4) return; - int _27 = gl_InvocationID ^ 1; - gl_out[gl_InvocationID].vOutputs = ((gl_in[gl_InvocationID].vInputs_a_1 + gl_in[gl_InvocationID].vInputs_b_1) + gl_in[gl_InvocationID].vInputs_c) + gl_in[_27].vInputs_c; + gl_out[gl_InvocationID].vOutputs = ((gl_in[gl_InvocationID].vInputs_a_1 + gl_in[gl_InvocationID].vInputs_b_1) + gl_in[gl_InvocationID].vInputs_c) + gl_in[gl_InvocationID ^ 1].vInputs_c; } 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 aabcb75f41a8..00ffb8c06fcd 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 @@ -30,7 +30,7 @@ struct main0_out struct main0_in { float3 in_tc_attr; - ushort2 m_120; + ushort2 m_128; }; 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)]]) 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 095202eee92a..a869cf15ba3a 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 @@ -46,7 +46,7 @@ kernel void main0(constant UBO& _41 [[buffer(0)]], uint3 gl_GlobalInvocationID [ { _526 = _516; } - if (!(!_526)) + if (_526) { spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(-1.0); spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1] = half(-1.0); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/water_tess.tesc b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/water_tess.tesc index 18484190bfd7..adf12b04431d 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/tesc/water_tess.tesc +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tesc/water_tess.tesc @@ -48,7 +48,7 @@ kernel void main0(main0_in in [[stage_in]], constant UBO& _41 [[buffer(0)]], uin { _526 = _516; } - if (!(!_526)) + if (_526) { spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(-1.0); spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1] = half(-1.0); diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/tese/input-types.tese b/third_party/spirv-cross/reference/opt/shaders-msl/tese/input-types.tese index 25b25ff94e13..fe9617e34db0 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/tese/input-types.tese +++ b/third_party/spirv-cross/reference/opt/shaders-msl/tese/input-types.tese @@ -65,12 +65,10 @@ struct main0_patchIn out.gl_Position += patchIn.vColors; out.gl_Position += vFoo.a; out.gl_Position += vFoo.b; - Foo _204 = Foo{ patchIn.gl_in[0].vFoos_a, patchIn.gl_in[0].vFoos_b }; - out.gl_Position += _204.a; - out.gl_Position += _204.b; - Foo _218 = Foo{ patchIn.gl_in[1].vFoos_a, patchIn.gl_in[1].vFoos_b }; - out.gl_Position += _218.a; - out.gl_Position += _218.b; + out.gl_Position += patchIn.gl_in[0].vFoos_a; + out.gl_Position += patchIn.gl_in[0].vFoos_b; + out.gl_Position += patchIn.gl_in[1].vFoos_a; + out.gl_Position += patchIn.gl_in[1].vFoos_b; return out; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/vert/clip-copy.for-tess.vert b/third_party/spirv-cross/reference/opt/shaders-msl/vert/clip-copy.for-tess.vert new file mode 100644 index 000000000000..5c7b75455218 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/vert/clip-copy.for-tess.vert @@ -0,0 +1,76 @@ +#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 Block +{ + spvUnsafeArray block0; +}; + +constant spvUnsafeArray _30 = spvUnsafeArray({ 1.0, 2.0, -1.0, -2.0 }); + +struct main0_out +{ + spvUnsafeArray F_array; + spvUnsafeArray m_43_block0; + 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)]]) +{ + Block _43 = {}; + 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, 2.0, 3.0, 4.0); + out.gl_ClipDistance = _30; + spvUnsafeArray _51 = out.gl_ClipDistance; + out.gl_ClipDistance = _51; + out.F_array = _51; + _43.block0 = _30; + out.m_43_block0 = _43.block0; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/vert/clip-copy.vert b/third_party/spirv-cross/reference/opt/shaders-msl/vert/clip-copy.vert new file mode 100644 index 000000000000..71be6fe0a675 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders-msl/vert/clip-copy.vert @@ -0,0 +1,209 @@ +#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]; + } +}; + +template +inline void spvArrayCopyFromConstantToStack(thread T (&dst)[N], constant T (&src)[N]) +{ + for (uint i = 0; i < N; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromConstantToThreadGroup(threadgroup T (&dst)[N], constant T (&src)[N]) +{ + for (uint i = 0; i < N; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromStackToStack(thread T (&dst)[N], thread const T (&src)[N]) +{ + for (uint i = 0; i < N; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromStackToThreadGroup(threadgroup T (&dst)[N], thread const T (&src)[N]) +{ + for (uint i = 0; i < N; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromThreadGroupToStack(thread T (&dst)[N], threadgroup const T (&src)[N]) +{ + for (uint i = 0; i < N; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromThreadGroupToThreadGroup(threadgroup T (&dst)[N], threadgroup const T (&src)[N]) +{ + for (uint i = 0; i < N; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromDeviceToDevice(device T (&dst)[N], device const T (&src)[N]) +{ + for (uint i = 0; i < N; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromConstantToDevice(device T (&dst)[N], constant T (&src)[N]) +{ + for (uint i = 0; i < N; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromStackToDevice(device T (&dst)[N], thread const T (&src)[N]) +{ + for (uint i = 0; i < N; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromThreadGroupToDevice(device T (&dst)[N], threadgroup const T (&src)[N]) +{ + for (uint i = 0; i < N; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromDeviceToStack(thread T (&dst)[N], device const T (&src)[N]) +{ + for (uint i = 0; i < N; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromDeviceToThreadGroup(threadgroup T (&dst)[N], device const T (&src)[N]) +{ + for (uint i = 0; i < N; i++) + { + dst[i] = src[i]; + } +} + +struct Block +{ + spvUnsafeArray block0; +}; + +constant spvUnsafeArray _30 = spvUnsafeArray({ 1.0, 2.0, -1.0, -2.0 }); + +struct main0_out +{ + float F_array_0 [[user(locn0)]]; + float F_array_1 [[user(locn1)]]; + float F_array_2 [[user(locn2)]]; + float F_array_3 [[user(locn3)]]; + float m_43_block0_0 [[user(locn4)]]; + float m_43_block0_1 [[user(locn5)]]; + float m_43_block0_2 [[user(locn6)]]; + float m_43_block0_3 [[user(locn7)]]; + float4 gl_Position [[position]]; + float gl_ClipDistance [[clip_distance]] [4]; + float gl_ClipDistance_0 [[user(clip0)]]; + float gl_ClipDistance_1 [[user(clip1)]]; + float gl_ClipDistance_2 [[user(clip2)]]; + float gl_ClipDistance_3 [[user(clip3)]]; +}; + +vertex main0_out main0() +{ + main0_out out = {}; + spvUnsafeArray F_array = {}; + Block _43 = {}; + out.gl_Position = float4(1.0, 2.0, 3.0, 4.0); + spvArrayCopyFromConstantToStack(out.gl_ClipDistance, _30.elements); + spvUnsafeArray _51; + _51[0] = out.gl_ClipDistance[0]; + _51[1] = out.gl_ClipDistance[1]; + _51[2] = out.gl_ClipDistance[2]; + _51[3] = out.gl_ClipDistance[3]; + spvArrayCopyFromStackToStack(out.gl_ClipDistance, _51.elements); + F_array = _51; + _43.block0 = _30; + out.gl_ClipDistance_0 = out.gl_ClipDistance[0]; + out.gl_ClipDistance_1 = out.gl_ClipDistance[1]; + out.gl_ClipDistance_2 = out.gl_ClipDistance[2]; + out.gl_ClipDistance_3 = out.gl_ClipDistance[3]; + out.F_array_0 = F_array[0]; + out.F_array_1 = F_array[1]; + out.F_array_2 = F_array[2]; + out.F_array_3 = F_array[3]; + out.m_43_block0_0 = _43.block0[0]; + out.m_43_block0_1 = _43.block0[1]; + out.m_43_block0_2 = _43.block0[2]; + out.m_43_block0_3 = _43.block0[3]; + return out; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/vert/float-math.invariant-float-math.vert b/third_party/spirv-cross/reference/opt/shaders-msl/vert/float-math.invariant-float-math.vert index 0fddcdf4d33c..974d5844c0b5 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/vert/float-math.invariant-float-math.vert +++ b/third_party/spirv-cross/reference/opt/shaders-msl/vert/float-math.invariant-float-math.vert @@ -80,13 +80,14 @@ template template [[clang::optnone]] matrix spvFMulMatrixMatrix(matrix l, matrix r) { + static_assert(LCols == RRows, "column-row configuration mismatch"); matrix res; for (uint i = 0; i < RCols; i++) { - vec tmp(0); + vec tmp(0); for (uint j = 0; j < LCols; j++) { - tmp = fma(vec(r[i][j]), l[j], tmp); + tmp = fma(vec(r[i][j]), l[j], tmp); } res[i] = tmp; } 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 index f4df5506ae45..d8698aa606ab 100644 --- 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 @@ -41,13 +41,14 @@ template template [[clang::optnone]] matrix spvFMulMatrixMatrix(matrix l, matrix r) { + static_assert(LCols == RRows, "column-row configuration mismatch"); matrix res; for (uint i = 0; i < RCols; i++) { - vec tmp(0); + vec tmp(0); for (uint j = 0; j < LCols; j++) { - tmp = fma(vec(r[i][j]), l[j], tmp); + tmp = fma(vec(r[i][j]), l[j], tmp); } res[i] = tmp; } diff --git a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/depth-compare.asm.frag b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/depth-compare.asm.frag index e769a70d80e8..137f5886ddb9 100644 --- a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/depth-compare.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/depth-compare.asm.frag @@ -1,8 +1,34 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct type_View { float4x4 View_TranslatedWorldToClip; @@ -189,14 +215,14 @@ struct type_Globals float4 PointLightDepthBiasAndProjParameters; }; -constant float4 _453 = {}; +constant float4 _459 = {}; 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)]], texture2d SceneTexturesStruct_SceneDepthTexture [[texture(0)]], texture2d SceneTexturesStruct_GBufferATexture [[texture(1)]], texture2d SceneTexturesStruct_GBufferBTexture [[texture(2)]], texture2d SceneTexturesStruct_GBufferDTexture [[texture(3)]], depthcube ShadowDepthCubeTexture [[texture(4)]], texture2d SSProfilesTexture [[texture(5)]], sampler SceneTexturesStruct_SceneDepthTextureSampler [[sampler(0)]], sampler SceneTexturesStruct_GBufferATextureSampler [[sampler(1)]], sampler SceneTexturesStruct_GBufferBTextureSampler [[sampler(2)]], sampler SceneTexturesStruct_GBufferDTextureSampler [[sampler(3)]], sampler ShadowDepthTextureSampler [[sampler(4)]], sampler ShadowDepthCubeTextureSampler [[sampler(5)]], float4 gl_FragCoord [[position]]) +fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_Globals& _Globals [[buffer(1)]], texture2d SceneTexturesStruct_SceneDepthTexture [[texture(0)]], texture2d SceneTexturesStruct_GBufferATexture [[texture(1)]], texture2d SceneTexturesStruct_GBufferBTexture [[texture(2)]], texture2d SceneTexturesStruct_GBufferDTexture [[texture(3)]], texturecube ShadowDepthCubeTexture [[texture(4)]], texture2d SSProfilesTexture [[texture(5)]], sampler SceneTexturesStruct_SceneDepthTextureSampler [[sampler(0)]], sampler SceneTexturesStruct_GBufferATextureSampler [[sampler(1)]], sampler SceneTexturesStruct_GBufferBTextureSampler [[sampler(2)]], sampler SceneTexturesStruct_GBufferDTextureSampler [[sampler(3)]], sampler ShadowDepthTextureSampler [[sampler(4)]], sampler ShadowDepthCubeTextureSampler [[sampler(5)]], float4 gl_FragCoord [[position]]) { main0_out out = {}; float2 _114 = gl_FragCoord.xy * View.View_BufferSizeAndInvSize.zw; @@ -236,7 +262,7 @@ fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_G } float4 _196 = _Globals.ShadowViewProjectionMatrices[_189] * float4(_147.xyz, 1.0); float _198 = _196.w; - _207 = ShadowDepthCubeTexture.sample_compare(ShadowDepthCubeTextureSampler, (_152 / float3(_158)), (_196.z / _198) + ((-_Globals.PointLightDepthBiasAndProjParameters.x) / _198), level(0.0)); + _207 = spvDepthCast(ShadowDepthCubeTexture).sample_compare(ShadowDepthCubeTextureSampler, (_152 / float3(_158)), (_196.z / _198) + ((-_Globals.PointLightDepthBiasAndProjParameters.x) / _198), level(0.0)); } else { @@ -253,7 +279,7 @@ fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_G float _448; if (_248) { - float4 _260 = SSProfilesTexture.read(uint2(int3(1, int(uint((select(float4(0.0), SceneTexturesStruct_GBufferDTexture.sample(SceneTexturesStruct_GBufferDTextureSampler, _114, level(0.0)), bool4(!((_240 & 16u) != 0u))).x * 255.0) + 0.5)), 0).xy), 0); + float4 _260 = SSProfilesTexture.read(uint2(int3(1, int(uint((select(float4(0.0), SceneTexturesStruct_GBufferDTexture.sample(SceneTexturesStruct_GBufferDTextureSampler, _114, level(0.0)), bool4((_240 & 16u) == 0u)).x * 255.0) + 0.5)), 0).xy), 0); float _263 = _260.y * 0.5; float3 _266 = _148 - (_236 * float3(_263)); float _274 = powr(fast::clamp(dot(-(_152 * float3(rsqrt(dot(_152, _152)))), _236), 0.0, 1.0), 1.0); @@ -296,7 +322,7 @@ fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_G float _387 = (_329 - ((1.0 / ((float4(ShadowDepthCubeTexture.sample(ShadowDepthTextureSampler, ((_278 + (_285 * float3(1.46946299076080322265625))) + (_286 * float3(-2.0225429534912109375))), level(0.0))).x * _Globals.PointLightDepthBiasAndProjParameters.z) - _Globals.PointLightDepthBiasAndProjParameters.w)) * _Globals.LightPositionAndInvRadius.w)) * _323; float _410 = (_329 - ((1.0 / ((float4(ShadowDepthCubeTexture.sample(ShadowDepthTextureSampler, ((_278 + (_285 * float3(-1.46946299076080322265625))) + (_286 * float3(-2.02254199981689453125))), level(0.0))).x * _Globals.PointLightDepthBiasAndProjParameters.z) - _Globals.PointLightDepthBiasAndProjParameters.w)) * _Globals.LightPositionAndInvRadius.w)) * _323; float _433 = (_329 - ((1.0 / ((float4(ShadowDepthCubeTexture.sample(ShadowDepthTextureSampler, ((_278 + (_285 * float3(-2.3776409626007080078125))) + (_286 * float3(0.772543013095855712890625))), level(0.0))).x * _Globals.PointLightDepthBiasAndProjParameters.z) - _Globals.PointLightDepthBiasAndProjParameters.w)) * _Globals.LightPositionAndInvRadius.w)) * _323; - _445 = (((((fast::clamp(abs((_342 > 0.0) ? (_342 + _263) : fast::max(0.0, (_342 * _274) + _263)), 0.1500000059604644775390625, 5.0) + 0.25) + (fast::clamp(abs((_364 > 0.0) ? (_364 + _263) : fast::max(0.0, (_364 * _274) + _263)), 0.1500000059604644775390625, 5.0) + 0.25)) + (fast::clamp(abs((_387 > 0.0) ? (_387 + _263) : fast::max(0.0, (_387 * _274) + _263)), 0.1500000059604644775390625, 5.0) + 0.25)) + (fast::clamp(abs((_410 > 0.0) ? (_410 + _263) : fast::max(0.0, (_410 * _274) + _263)), 0.1500000059604644775390625, 5.0) + 0.25)) + (fast::clamp(abs((_433 > 0.0) ? (_433 + _263) : fast::max(0.0, (_433 * _274) + _263)), 0.1500000059604644775390625, 5.0) + 0.25)) * 0.20000000298023223876953125; + _445 = (1.25 + ((((fast::clamp(abs((_342 > 0.0) ? (_342 + _263) : fast::max(0.0, (_342 * _274) + _263)), 0.1500000059604644775390625, 5.0) + fast::clamp(abs((_364 > 0.0) ? (_364 + _263) : fast::max(0.0, (_364 * _274) + _263)), 0.1500000059604644775390625, 5.0)) + fast::clamp(abs((_387 > 0.0) ? (_387 + _263) : fast::max(0.0, (_387 * _274) + _263)), 0.1500000059604644775390625, 5.0)) + fast::clamp(abs((_410 > 0.0) ? (_410 + _263) : fast::max(0.0, (_410 * _274) + _263)), 0.1500000059604644775390625, 5.0)) + fast::clamp(abs((_433 > 0.0) ? (_433 + _263) : fast::max(0.0, (_433 * _274) + _263)), 0.1500000059604644775390625, 5.0))) * 0.20000000298023223876953125; } else { diff --git a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/sample-mask-not-array.asm.frag b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/sample-mask-not-array.asm.frag index 2972ba09059d..210aee9b0284 100644 --- a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/sample-mask-not-array.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/frag/sample-mask-not-array.asm.frag @@ -1,49 +1,8 @@ -#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 type_View { float4x4 View_TranslatedWorldToClip; @@ -530,12 +489,12 @@ fragment main0_out main0(main0_in in [[stage_in]], constant type_View& View [[bu if (View.View_NumSceneColorMSAASamples > 1) { _268 = _255 * float4(float(View.View_NumSceneColorMSAASamples) * 0.25); - _269 = (spvUnsafeArray({ uint(gl_SampleMaskIn) }))[0] & 15u; + _269 = gl_SampleMaskIn & 15u; } else { _268 = _255; - _269 = (spvUnsafeArray({ uint(gl_SampleMaskIn) }))[0]; + _269 = gl_SampleMaskIn; } out.out_var_SV_Target0 = _268; out.gl_SampleMask = _269; diff --git a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tese/ds-double-gl-in-deref.asm.tese b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tese/ds-double-gl-in-deref.asm.tese index 7d4ec2c5a416..e4b45a230111 100644 --- a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tese/ds-double-gl-in-deref.asm.tese +++ b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tese/ds-double-gl-in-deref.asm.tese @@ -366,12 +366,6 @@ struct main0_patchIn { main0_out out = {}; spvUnsafeArray out_var_TEXCOORD0 = {}; - spvUnsafeArray _117 = spvUnsafeArray({ patchIn.gl_in[0].in_var_TEXCOORD10_centroid, patchIn.gl_in[1].in_var_TEXCOORD10_centroid, patchIn.gl_in[2].in_var_TEXCOORD10_centroid }); - spvUnsafeArray _118 = spvUnsafeArray({ patchIn.gl_in[0].in_var_TEXCOORD11_centroid, patchIn.gl_in[1].in_var_TEXCOORD11_centroid, patchIn.gl_in[2].in_var_TEXCOORD11_centroid }); - spvUnsafeArray _119 = spvUnsafeArray({ patchIn.gl_in[0].in_var_COLOR0, patchIn.gl_in[1].in_var_COLOR0, patchIn.gl_in[2].in_var_COLOR0 }); - spvUnsafeArray, 3> _120 = spvUnsafeArray, 3>({ spvUnsafeArray({ patchIn.gl_in[0].in_var_TEXCOORD0_0 }), spvUnsafeArray({ patchIn.gl_in[1].in_var_TEXCOORD0_0 }), spvUnsafeArray({ patchIn.gl_in[2].in_var_TEXCOORD0_0 }) }); - spvUnsafeArray, 3> _135 = spvUnsafeArray, 3>({ spvUnsafeArray({ patchIn.gl_in[0].in_var_PN_POSITION_0, patchIn.gl_in[0].in_var_PN_POSITION_1, patchIn.gl_in[0].in_var_PN_POSITION_2 }), spvUnsafeArray({ patchIn.gl_in[1].in_var_PN_POSITION_0, patchIn.gl_in[1].in_var_PN_POSITION_1, patchIn.gl_in[1].in_var_PN_POSITION_2 }), spvUnsafeArray({ patchIn.gl_in[2].in_var_PN_POSITION_0, patchIn.gl_in[2].in_var_PN_POSITION_1, patchIn.gl_in[2].in_var_PN_POSITION_2 }) }); - spvUnsafeArray _136 = spvUnsafeArray({ patchIn.gl_in[0].in_var_PN_WorldDisplacementMultiplier, patchIn.gl_in[1].in_var_PN_WorldDisplacementMultiplier, patchIn.gl_in[2].in_var_PN_WorldDisplacementMultiplier }); float _157 = gl_TessCoord.x * gl_TessCoord.x; float _158 = gl_TessCoord.y * gl_TessCoord.y; float _159 = gl_TessCoord.z * gl_TessCoord.z; @@ -381,14 +375,14 @@ struct main0_patchIn float4 _177 = float4(_157 * 3.0); float4 _181 = float4(_158 * 3.0); float4 _188 = float4(_159 * 3.0); - float4 _202 = ((((((((((_135[0][0] * float4(_157)) * _165) + ((_135[1][0] * float4(_158)) * _169)) + ((_135[2][0] * float4(_159)) * _174)) + ((_135[0][1] * _177) * _169)) + ((_135[0][2] * _181) * _165)) + ((_135[1][1] * _181) * _174)) + ((_135[1][2] * _188) * _169)) + ((_135[2][1] * _188) * _165)) + ((_135[2][2] * _177) * _174)) + ((((patchIn.in_var_PN_POSITION9 * float4(6.0)) * _174) * _165) * _169); - float3 _226 = ((_117[0].xyz * float3(gl_TessCoord.x)) + (_117[1].xyz * float3(gl_TessCoord.y))).xyz + (_117[2].xyz * float3(gl_TessCoord.z)); - float4 _229 = ((_118[0] * _165) + (_118[1] * _169)) + (_118[2] * _174); - float4 _231 = ((_119[0] * _165) + (_119[1] * _169)) + (_119[2] * _174); - float4 _233 = ((_120[0][0] * _165) + (_120[1][0] * _169)) + (_120[2][0] * _174); + float4 _202 = ((((((((((patchIn.gl_in[0u].in_var_PN_POSITION_0 * float4(_157)) * _165) + ((patchIn.gl_in[1u].in_var_PN_POSITION_0 * float4(_158)) * _169)) + ((patchIn.gl_in[2u].in_var_PN_POSITION_0 * float4(_159)) * _174)) + ((patchIn.gl_in[0u].in_var_PN_POSITION_1 * _177) * _169)) + ((patchIn.gl_in[0u].in_var_PN_POSITION_2 * _181) * _165)) + ((patchIn.gl_in[1u].in_var_PN_POSITION_1 * _181) * _174)) + ((patchIn.gl_in[1u].in_var_PN_POSITION_2 * _188) * _169)) + ((patchIn.gl_in[2u].in_var_PN_POSITION_1 * _188) * _165)) + ((patchIn.gl_in[2u].in_var_PN_POSITION_2 * _177) * _174)) + ((((patchIn.in_var_PN_POSITION9 * float4(6.0)) * _174) * _165) * _169); + float3 _226 = ((patchIn.gl_in[0u].in_var_TEXCOORD10_centroid.xyz * float3(gl_TessCoord.x)) + (patchIn.gl_in[1u].in_var_TEXCOORD10_centroid.xyz * float3(gl_TessCoord.y))).xyz + (patchIn.gl_in[2u].in_var_TEXCOORD10_centroid.xyz * float3(gl_TessCoord.z)); + float4 _229 = ((patchIn.gl_in[0u].in_var_TEXCOORD11_centroid * _165) + (patchIn.gl_in[1u].in_var_TEXCOORD11_centroid * _169)) + (patchIn.gl_in[2u].in_var_TEXCOORD11_centroid * _174); + float4 _231 = ((patchIn.gl_in[0u].in_var_COLOR0 * _165) + (patchIn.gl_in[1u].in_var_COLOR0 * _169)) + (patchIn.gl_in[2u].in_var_COLOR0 * _174); + float4 _233 = ((patchIn.gl_in[0u].in_var_TEXCOORD0_0 * _165) + (patchIn.gl_in[1u].in_var_TEXCOORD0_0 * _169)) + (patchIn.gl_in[2u].in_var_TEXCOORD0_0 * _174); spvUnsafeArray _234 = spvUnsafeArray({ _233 }); float3 _236 = _229.xyz; - float3 _264 = _202.xyz + (((float3((Material_Texture2D_3.sample(Material_Texture2D_3Sampler, (float2(View.View_GameTime * 0.20000000298023223876953125, View.View_GameTime * (-0.699999988079071044921875)) + (_233.zw * float2(1.0, 2.0))), level(-1.0)).x * 10.0) * (1.0 - _231.x)) * _236) * float3(0.5)) * float3(((_136[0] * gl_TessCoord.x) + (_136[1] * gl_TessCoord.y)) + (_136[2] * gl_TessCoord.z))); + float3 _264 = _202.xyz + (((float3((Material_Texture2D_3.sample(Material_Texture2D_3Sampler, (float2(View.View_GameTime * 0.20000000298023223876953125, View.View_GameTime * (-0.699999988079071044921875)) + (_233.zw * float2(1.0, 2.0))), level(-1.0)).x * 10.0) * (1.0 - _231.x)) * _236) * float3(0.5)) * float3(((patchIn.gl_in[0u].in_var_PN_WorldDisplacementMultiplier * gl_TessCoord.x) + (patchIn.gl_in[1u].in_var_PN_WorldDisplacementMultiplier * gl_TessCoord.y)) + (patchIn.gl_in[2u].in_var_PN_WorldDisplacementMultiplier * gl_TessCoord.z))); float4 _270 = ShadowDepthPass.ShadowDepthPass_ProjectionMatrix * float4(_264.x, _264.y, _264.z, _202.w); float4 _281; if ((ShadowDepthPass.ShadowDepthPass_bClampToNearPlane > 0.0) && (_270.z < 0.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 f1b74aacbbcd..481c16ed1f6d 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 @@ -1,49 +1,8 @@ -#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 type_View { float4x4 View_TranslatedWorldToClip; @@ -278,18 +237,6 @@ struct main0_patchIn [[ patch(triangle, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]], constant type_View& View [[buffer(0)]], constant type_Material& Material [[buffer(1)]], texture3d View_GlobalDistanceFieldTexture0 [[texture(0)]], texture3d View_GlobalDistanceFieldTexture1 [[texture(1)]], texture3d View_GlobalDistanceFieldTexture2 [[texture(2)]], texture3d View_GlobalDistanceFieldTexture3 [[texture(3)]], sampler View_GlobalDistanceFieldSampler0 [[sampler(0)]], float3 gl_TessCoord [[position_in_patch]]) { main0_out out = {}; - spvUnsafeArray _120 = spvUnsafeArray({ patchIn.gl_in[0].in_var_TEXCOORD6, patchIn.gl_in[1].in_var_TEXCOORD6, patchIn.gl_in[2].in_var_TEXCOORD6 }); - spvUnsafeArray _121 = spvUnsafeArray({ patchIn.gl_in[0].in_var_TEXCOORD8, patchIn.gl_in[1].in_var_TEXCOORD8, patchIn.gl_in[2].in_var_TEXCOORD8 }); - spvUnsafeArray _128 = spvUnsafeArray({ patchIn.gl_in[0].in_var_TEXCOORD10_centroid, patchIn.gl_in[1].in_var_TEXCOORD10_centroid, patchIn.gl_in[2].in_var_TEXCOORD10_centroid }); - spvUnsafeArray _129 = spvUnsafeArray({ patchIn.gl_in[0].in_var_TEXCOORD11_centroid, patchIn.gl_in[1].in_var_TEXCOORD11_centroid, patchIn.gl_in[2].in_var_TEXCOORD11_centroid }); - spvUnsafeArray, 3> _136 = spvUnsafeArray, 3>({ spvUnsafeArray({ patchIn.gl_in[0].in_var_PN_POSITION_0, patchIn.gl_in[0].in_var_PN_POSITION_1, patchIn.gl_in[0].in_var_PN_POSITION_2 }), spvUnsafeArray({ patchIn.gl_in[1].in_var_PN_POSITION_0, patchIn.gl_in[1].in_var_PN_POSITION_1, patchIn.gl_in[1].in_var_PN_POSITION_2 }), spvUnsafeArray({ patchIn.gl_in[2].in_var_PN_POSITION_0, patchIn.gl_in[2].in_var_PN_POSITION_1, patchIn.gl_in[2].in_var_PN_POSITION_2 }) }); - spvUnsafeArray _137 = spvUnsafeArray({ patchIn.gl_in[0].in_var_PN_WorldDisplacementMultiplier, patchIn.gl_in[1].in_var_PN_WorldDisplacementMultiplier, patchIn.gl_in[2].in_var_PN_WorldDisplacementMultiplier }); - spvUnsafeArray _138 = spvUnsafeArray({ patchIn.gl_in[0].in_var_PN_DominantVertex1, patchIn.gl_in[1].in_var_PN_DominantVertex1, patchIn.gl_in[2].in_var_PN_DominantVertex1 }); - spvUnsafeArray _139 = spvUnsafeArray({ patchIn.gl_in[0].in_var_PN_DominantVertex2, patchIn.gl_in[1].in_var_PN_DominantVertex2, patchIn.gl_in[2].in_var_PN_DominantVertex2 }); - spvUnsafeArray _146 = spvUnsafeArray({ patchIn.gl_in[0].in_var_PN_DominantEdge2, patchIn.gl_in[1].in_var_PN_DominantEdge2, patchIn.gl_in[2].in_var_PN_DominantEdge2 }); - spvUnsafeArray _147 = spvUnsafeArray({ patchIn.gl_in[0].in_var_PN_DominantEdge3, patchIn.gl_in[1].in_var_PN_DominantEdge3, patchIn.gl_in[2].in_var_PN_DominantEdge3 }); - spvUnsafeArray _148 = spvUnsafeArray({ patchIn.gl_in[0].in_var_PN_DominantEdge4, patchIn.gl_in[1].in_var_PN_DominantEdge4, patchIn.gl_in[2].in_var_PN_DominantEdge4 }); - spvUnsafeArray _149 = spvUnsafeArray({ patchIn.gl_in[0].in_var_PN_DominantEdge5, patchIn.gl_in[1].in_var_PN_DominantEdge5, patchIn.gl_in[2].in_var_PN_DominantEdge5 }); float _190 = gl_TessCoord.x * gl_TessCoord.x; float _191 = gl_TessCoord.y * gl_TessCoord.y; float _192 = gl_TessCoord.z * gl_TessCoord.z; @@ -299,16 +246,15 @@ struct main0_patchIn float4 _210 = float4(_190 * 3.0); float4 _214 = float4(_191 * 3.0); float4 _221 = float4(_192 * 3.0); - float4 _235 = ((((((((((_136[0][0] * float4(_190)) * _198) + ((_136[1][0] * float4(_191)) * _202)) + ((_136[2][0] * float4(_192)) * _207)) + ((_136[0][1] * _210) * _202)) + ((_136[0][2] * _214) * _198)) + ((_136[1][1] * _214) * _207)) + ((_136[1][2] * _221) * _202)) + ((_136[2][1] * _221) * _198)) + ((_136[2][2] * _210) * _207)) + ((((patchIn.in_var_PN_POSITION9 * float4(6.0)) * _207) * _198) * _202); + float4 _235 = ((((((((((patchIn.gl_in[0u].in_var_PN_POSITION_0 * float4(_190)) * _198) + ((patchIn.gl_in[1u].in_var_PN_POSITION_0 * float4(_191)) * _202)) + ((patchIn.gl_in[2u].in_var_PN_POSITION_0 * float4(_192)) * _207)) + ((patchIn.gl_in[0u].in_var_PN_POSITION_1 * _210) * _202)) + ((patchIn.gl_in[0u].in_var_PN_POSITION_2 * _214) * _198)) + ((patchIn.gl_in[1u].in_var_PN_POSITION_1 * _214) * _207)) + ((patchIn.gl_in[1u].in_var_PN_POSITION_2 * _221) * _202)) + ((patchIn.gl_in[2u].in_var_PN_POSITION_1 * _221) * _198)) + ((patchIn.gl_in[2u].in_var_PN_POSITION_2 * _210) * _207)) + ((((patchIn.in_var_PN_POSITION9 * float4(6.0)) * _207) * _198) * _202); float3 _237 = float3(gl_TessCoord.x); float3 _240 = float3(gl_TessCoord.y); float3 _254 = float3(gl_TessCoord.z); - float3 _256 = ((_128[0].xyz * _237) + (_128[1].xyz * _240)).xyz + (_128[2].xyz * _254); - float4 _259 = ((_129[0] * _198) + (_129[1] * _202)) + (_129[2] * _207); - float3 _264 = _235.xyz; + float3 _256 = ((patchIn.gl_in[0u].in_var_TEXCOORD10_centroid.xyz * _237) + (patchIn.gl_in[1u].in_var_TEXCOORD10_centroid.xyz * _240)).xyz + (patchIn.gl_in[2u].in_var_TEXCOORD10_centroid.xyz * _254); + float4 _259 = ((patchIn.gl_in[0u].in_var_TEXCOORD11_centroid * _198) + (patchIn.gl_in[1u].in_var_TEXCOORD11_centroid * _202)) + (patchIn.gl_in[2u].in_var_TEXCOORD11_centroid * _207); float3 _265 = _256.xyz; float3 _266 = _259.xyz; - float3 _272 = _264 + float3(View.View_WorldCameraOrigin); + float3 _272 = _235.xyz + float3(View.View_WorldCameraOrigin); float _279 = float(int(gl_TessCoord.x == 0.0)); float _282 = float(int(gl_TessCoord.y == 0.0)); float _285 = float(int(gl_TessCoord.z == 0.0)); @@ -321,8 +267,8 @@ struct main0_patchIn float _363 = float(int((_282 + _285) == 2.0)); float _367 = float(int((_285 + _279) == 2.0)); float _370 = float(int(_286 == 2.0)); - _387 = ((float4(_363) * _138[0]) + (float4(_367) * _138[1])) + (float4(_370) * _138[2]); - _388 = ((float3(_363) * _139[0]) + (float3(_367) * _139[1])) + (float3(_370) * _139[2]); + _387 = ((float4(_363) * patchIn.gl_in[0u].in_var_PN_DominantVertex1) + (float4(_367) * patchIn.gl_in[1u].in_var_PN_DominantVertex1)) + (float4(_370) * patchIn.gl_in[2u].in_var_PN_DominantVertex1); + _388 = ((float3(_363) * patchIn.gl_in[0u].in_var_PN_DominantVertex2) + (float3(_367) * patchIn.gl_in[1u].in_var_PN_DominantVertex2)) + (float3(_370) * patchIn.gl_in[2u].in_var_PN_DominantVertex2); } else { @@ -333,13 +279,13 @@ struct main0_patchIn float4 _304 = float4(_279); float4 _306 = float4(_282); float4 _309 = float4(_285); - float4 _311 = ((_304 * _146[0]) + (_306 * _146[1])) + (_309 * _146[2]); - float4 _316 = ((_304 * _147[0]) + (_306 * _147[1])) + (_309 * _147[2]); + float4 _311 = ((_304 * patchIn.gl_in[0u].in_var_PN_DominantEdge2) + (_306 * patchIn.gl_in[1u].in_var_PN_DominantEdge2)) + (_309 * patchIn.gl_in[2u].in_var_PN_DominantEdge2); + float4 _316 = ((_304 * patchIn.gl_in[0u].in_var_PN_DominantEdge3) + (_306 * patchIn.gl_in[1u].in_var_PN_DominantEdge3)) + (_309 * patchIn.gl_in[2u].in_var_PN_DominantEdge3); float3 _331 = float3(_279); float3 _333 = float3(_282); float3 _336 = float3(_285); - float3 _338 = ((_331 * _148[0]) + (_333 * _148[1])) + (_336 * _148[2]); - float3 _343 = ((_331 * _149[0]) + (_333 * _149[1])) + (_336 * _149[2]); + float3 _338 = ((_331 * patchIn.gl_in[0u].in_var_PN_DominantEdge4) + (_333 * patchIn.gl_in[1u].in_var_PN_DominantEdge4)) + (_336 * patchIn.gl_in[2u].in_var_PN_DominantEdge4); + float3 _343 = ((_331 * patchIn.gl_in[0u].in_var_PN_DominantEdge5) + (_333 * patchIn.gl_in[1u].in_var_PN_DominantEdge5)) + (_336 * patchIn.gl_in[2u].in_var_PN_DominantEdge5); _358 = ((_304 * ((_202 * _311) + (_207 * _316))) + (_306 * ((_207 * _311) + (_198 * _316)))) + (_309 * ((_198 * _311) + (_202 * _316))); _359 = ((_331 * ((_240 * _338) + (_254 * _343))) + (_333 * ((_254 * _338) + (_237 * _343)))) + (_336 * ((_237 * _338) + (_240 * _343))); } @@ -401,12 +347,12 @@ struct main0_patchIn } _547 = _535; } - float3 _565 = _264 + ((_398[2] * float3(fast::min(_547 + Material.Material_ScalarExpressions[0].z, 0.0) * Material.Material_ScalarExpressions[0].w)) * float3(((_137[0] * gl_TessCoord.x) + (_137[1] * gl_TessCoord.y)) + (_137[2] * gl_TessCoord.z))); + float3 _565 = _235.xyz + ((_398[2] * float3(fast::min(_547 + Material.Material_ScalarExpressions[0].z, 0.0) * Material.Material_ScalarExpressions[0].w)) * float3(((patchIn.gl_in[0u].in_var_PN_WorldDisplacementMultiplier * gl_TessCoord.x) + (patchIn.gl_in[1u].in_var_PN_WorldDisplacementMultiplier * gl_TessCoord.y)) + (patchIn.gl_in[2u].in_var_PN_WorldDisplacementMultiplier * gl_TessCoord.z))); float4 _574 = View.View_TranslatedWorldToClip * float4(_565.x, _565.y, _565.z, _235.w); _574.z = _574.z + (0.001000000047497451305389404296875 * _574.w); out.gl_Position = _574; - out.out_var_TEXCOORD6 = ((_120[0] * _198) + (_120[1] * _202)) + (_120[2] * _207); - out.out_var_TEXCOORD7 = ((_121[0] * _198) + (_121[1] * _202)) + (_121[2] * _207); + out.out_var_TEXCOORD6 = ((patchIn.gl_in[0u].in_var_TEXCOORD6 * _198) + (patchIn.gl_in[1u].in_var_TEXCOORD6 * _202)) + (patchIn.gl_in[2u].in_var_TEXCOORD6 * _207); + out.out_var_TEXCOORD7 = ((patchIn.gl_in[0u].in_var_TEXCOORD8 * _198) + (patchIn.gl_in[1u].in_var_TEXCOORD8 * _202)) + (patchIn.gl_in[2u].in_var_TEXCOORD8 * _207); out.out_var_TEXCOORD10_centroid = float4(_256.x, _256.y, _256.z, _118.w); out.out_var_TEXCOORD11_centroid = _259; out.gl_ClipDistance[0u] = dot(View.View_GlobalClippingPlane, float4(_565.xyz - float3(View.View_PreViewTranslation), 1.0)); diff --git a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tese/ds-patch-inputs.asm.tese b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tese/ds-patch-inputs.asm.tese index b4dbe705a849..c4830686e5a6 100644 --- a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tese/ds-patch-inputs.asm.tese +++ b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/tese/ds-patch-inputs.asm.tese @@ -1,49 +1,8 @@ -#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 type_ShadowDepthPass { float PrePadding_ShadowDepthPass_LPV_0; @@ -174,9 +133,6 @@ struct main0_patchIn [[ patch(triangle, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]], constant type_ShadowDepthPass& ShadowDepthPass [[buffer(0)]], float3 gl_TessCoord [[position_in_patch]]) { main0_out out = {}; - spvUnsafeArray _93 = spvUnsafeArray({ patchIn.gl_in[0].in_var_TEXCOORD10_centroid, patchIn.gl_in[1].in_var_TEXCOORD10_centroid, patchIn.gl_in[2].in_var_TEXCOORD10_centroid }); - spvUnsafeArray _94 = spvUnsafeArray({ patchIn.gl_in[0].in_var_TEXCOORD11_centroid, patchIn.gl_in[1].in_var_TEXCOORD11_centroid, patchIn.gl_in[2].in_var_TEXCOORD11_centroid }); - spvUnsafeArray, 3> _101 = spvUnsafeArray, 3>({ spvUnsafeArray({ patchIn.gl_in[0].in_var_PN_POSITION_0, patchIn.gl_in[0].in_var_PN_POSITION_1, patchIn.gl_in[0].in_var_PN_POSITION_2 }), spvUnsafeArray({ patchIn.gl_in[1].in_var_PN_POSITION_0, patchIn.gl_in[1].in_var_PN_POSITION_1, patchIn.gl_in[1].in_var_PN_POSITION_2 }), spvUnsafeArray({ patchIn.gl_in[2].in_var_PN_POSITION_0, patchIn.gl_in[2].in_var_PN_POSITION_1, patchIn.gl_in[2].in_var_PN_POSITION_2 }) }); float _119 = gl_TessCoord.x * gl_TessCoord.x; float _120 = gl_TessCoord.y * gl_TessCoord.y; float _121 = gl_TessCoord.z * gl_TessCoord.z; @@ -186,9 +142,9 @@ struct main0_patchIn float4 _139 = float4(_119 * 3.0); float4 _143 = float4(_120 * 3.0); float4 _150 = float4(_121 * 3.0); - float4 _164 = ((((((((((_101[0][0] * float4(_119)) * _127) + ((_101[1][0] * float4(_120)) * _131)) + ((_101[2][0] * float4(_121)) * _136)) + ((_101[0][1] * _139) * _131)) + ((_101[0][2] * _143) * _127)) + ((_101[1][1] * _143) * _136)) + ((_101[1][2] * _150) * _131)) + ((_101[2][1] * _150) * _127)) + ((_101[2][2] * _139) * _136)) + ((((patchIn.in_var_PN_POSITION9 * float4(6.0)) * _136) * _127) * _131); - float3 _179 = ((_93[0].xyz * float3(gl_TessCoord.x)) + (_93[1].xyz * float3(gl_TessCoord.y))).xyz + (_93[2].xyz * float3(gl_TessCoord.z)); - float4 _182 = ((_94[0] * _127) + (_94[1] * _131)) + (_94[2] * _136); + float4 _164 = ((((((((((patchIn.gl_in[0u].in_var_PN_POSITION_0 * float4(_119)) * _127) + ((patchIn.gl_in[1u].in_var_PN_POSITION_0 * float4(_120)) * _131)) + ((patchIn.gl_in[2u].in_var_PN_POSITION_0 * float4(_121)) * _136)) + ((patchIn.gl_in[0u].in_var_PN_POSITION_1 * _139) * _131)) + ((patchIn.gl_in[0u].in_var_PN_POSITION_2 * _143) * _127)) + ((patchIn.gl_in[1u].in_var_PN_POSITION_1 * _143) * _136)) + ((patchIn.gl_in[1u].in_var_PN_POSITION_2 * _150) * _131)) + ((patchIn.gl_in[2u].in_var_PN_POSITION_1 * _150) * _127)) + ((patchIn.gl_in[2u].in_var_PN_POSITION_2 * _139) * _136)) + ((((patchIn.in_var_PN_POSITION9 * float4(6.0)) * _136) * _127) * _131); + float3 _179 = ((patchIn.gl_in[0u].in_var_TEXCOORD10_centroid.xyz * float3(gl_TessCoord.x)) + (patchIn.gl_in[1u].in_var_TEXCOORD10_centroid.xyz * float3(gl_TessCoord.y))).xyz + (patchIn.gl_in[2u].in_var_TEXCOORD10_centroid.xyz * float3(gl_TessCoord.z)); + float4 _182 = ((patchIn.gl_in[0u].in_var_TEXCOORD11_centroid * _127) + (patchIn.gl_in[1u].in_var_TEXCOORD11_centroid * _131)) + (patchIn.gl_in[2u].in_var_TEXCOORD11_centroid * _136); float4 _189 = ShadowDepthPass.ShadowDepthPass_ProjectionMatrix * float4(_164.x, _164.y, _164.z, _164.w); float4 _200; if ((ShadowDepthPass.ShadowDepthPass_bClampToNearPlane > 0.0) && (_189.z < 0.0)) diff --git a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/vert/array-missing-copies.asm.vert b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/vert/array-missing-copies.asm.vert index 184f4522bbd3..f2a8d01bb3ef 100644 --- a/third_party/spirv-cross/reference/opt/shaders-ue4/asm/vert/array-missing-copies.asm.vert +++ b/third_party/spirv-cross/reference/opt/shaders-ue4/asm/vert/array-missing-copies.asm.vert @@ -388,10 +388,10 @@ vertex main0_out main0(main0_in in [[stage_in]], constant type_View& View [[buff } float _207 = floor(_206); float _220 = _121.x; - float3 _235 = select(select(select(select(select(float3(0.03125, _121.yy), float3(0.0625, _220, _121.y), bool3(_207 < 5.0)), float3(0.125, in_var_ATTRIBUTE1[1].w, _220), bool3(_207 < 4.0)), float3(0.25, in_var_ATTRIBUTE1[1].zw), bool3(_207 < 3.0)), float3(0.5, in_var_ATTRIBUTE1[1].yz), bool3(_207 < 2.0)), float3(1.0, in_var_ATTRIBUTE1[1].xy), bool3(_207 < 1.0)); + float3 _235 = select(select(select(select(select(float3(0.03125, _121.yy), float3(0.0625, _220, _121.y), bool3(_207 < 5.0)), float3(0.125, in_var_ATTRIBUTE1[1u].w, _220), bool3(_207 < 4.0)), float3(0.25, in_var_ATTRIBUTE1[1u].zw), bool3(_207 < 3.0)), float3(0.5, in_var_ATTRIBUTE1[1u].yz), bool3(_207 < 2.0)), float3(1.0, in_var_ATTRIBUTE1[1u].xy), bool3(_207 < 1.0)); float _236 = _235.x; - float _245 = (((in_var_ATTRIBUTE1[0].x * 65280.0) + (in_var_ATTRIBUTE1[0].y * 255.0)) - 32768.0) * 0.0078125; - float _252 = (((in_var_ATTRIBUTE1[0].z * 65280.0) + (in_var_ATTRIBUTE1[0].w * 255.0)) - 32768.0) * 0.0078125; + float _245 = (((in_var_ATTRIBUTE1[0u].x * 65280.0) + (in_var_ATTRIBUTE1[0u].y * 255.0)) - 32768.0) * 0.0078125; + float _252 = (((in_var_ATTRIBUTE1[0u].z * 65280.0) + (in_var_ATTRIBUTE1[0u].w * 255.0)) - 32768.0) * 0.0078125; float2 _257 = floor(_122 * float2(_236)); float2 _271 = float2((LandscapeParameters.LandscapeParameters_SubsectionSizeVertsLayerUVPan.x * _236) - 1.0, fast::max((LandscapeParameters.LandscapeParameters_SubsectionSizeVertsLayerUVPan.x * 0.5) * _236, 2.0) - 1.0) * float2(LandscapeParameters.LandscapeParameters_SubsectionSizeVertsLayerUVPan.y); float3 _287 = mix(float3(_257 / float2(_271.x), mix(_245, _252, _235.y)), float3(floor(_257 * float2(0.5)) / float2(_271.y), mix(_245, _252, _235.z)), float3(_206 - _207)); diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/comp/atomic-decrement.asm.comp b/third_party/spirv-cross/reference/opt/shaders/asm/comp/atomic-decrement.asm.comp index 87035744d509..4c9c35303441 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/comp/atomic-decrement.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders/asm/comp/atomic-decrement.asm.comp @@ -11,6 +11,6 @@ layout(binding = 0, r32ui) uniform writeonly uimageBuffer u0; void main() { uint _24 = atomicAdd(u0_counter.c, uint(-1)); - imageStore(u0, floatBitsToInt(uintBitsToFloat(_24)), uvec4(uint(int(gl_GlobalInvocationID.x)))); + imageStore(u0, int(_24), uvec4(uint(int(gl_GlobalInvocationID.x)))); } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/comp/atomic-increment.asm.comp b/third_party/spirv-cross/reference/opt/shaders/asm/comp/atomic-increment.asm.comp index ded7dcd7420b..41daca82ba37 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/comp/atomic-increment.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders/asm/comp/atomic-increment.asm.comp @@ -11,6 +11,6 @@ layout(binding = 0, r32ui) uniform writeonly uimageBuffer u0; void main() { uint _24 = atomicAdd(u0_counter.c, 1u); - imageStore(u0, floatBitsToInt(uintBitsToFloat(_24)), uvec4(uint(int(gl_GlobalInvocationID.x)))); + imageStore(u0, int(_24), uvec4(uint(int(gl_GlobalInvocationID.x)))); } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/comp/bitcast_iadd.asm.comp b/third_party/spirv-cross/reference/opt/shaders/asm/comp/bitcast_iadd.asm.comp index bed2dffccbd2..8c36b989e65c 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/comp/bitcast_iadd.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders/asm/comp/bitcast_iadd.asm.comp @@ -15,13 +15,15 @@ layout(binding = 1, std430) restrict buffer _4_6 void main() { - _6._m0 = _5._m1 + uvec4(_5._m0); - _6._m0 = uvec4(_5._m0) + _5._m1; + uvec4 _26 = _5._m1 + uvec4(_5._m0); + ivec4 _32 = ivec4(_5._m1) + _5._m0; + _6._m0 = _26; + _6._m0 = _26; _6._m0 = _5._m1 + _5._m1; _6._m0 = uvec4(_5._m0 + _5._m0); _6._m1 = ivec4(_5._m1 + _5._m1); _6._m1 = _5._m0 + _5._m0; - _6._m1 = ivec4(_5._m1) + _5._m0; - _6._m1 = _5._m0 + ivec4(_5._m1); + _6._m1 = _32; + _6._m1 = _32; } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/comp/bitcast_iequal.asm.comp b/third_party/spirv-cross/reference/opt/shaders/asm/comp/bitcast_iequal.asm.comp index 8a552dba0688..a873c1f71a5a 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/comp/bitcast_iequal.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders/asm/comp/bitcast_iequal.asm.comp @@ -18,15 +18,16 @@ void main() ivec4 _30 = _5._m0; uvec4 _31 = _5._m1; bvec4 _34 = equal(ivec4(_31), _30); - bvec4 _35 = equal(_30, ivec4(_31)); bvec4 _36 = equal(_31, _31); bvec4 _37 = equal(_30, _30); - _6._m0 = uvec4(_34); - _6._m0 = uvec4(_35); + uvec4 _38 = uvec4(_34); + ivec4 _42 = ivec4(_34); + _6._m0 = _38; + _6._m0 = _38; _6._m0 = uvec4(_36); _6._m0 = uvec4(_37); - _6._m1 = ivec4(_34); - _6._m1 = ivec4(_35); + _6._m1 = _42; + _6._m1 = _42; _6._m1 = ivec4(_36); _6._m1 = ivec4(_37); } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/comp/bitcast_sdiv.asm.comp b/third_party/spirv-cross/reference/opt/shaders/asm/comp/bitcast_sdiv.asm.comp index e28c481d21bb..63a46481da5c 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/comp/bitcast_sdiv.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders/asm/comp/bitcast_sdiv.asm.comp @@ -19,10 +19,10 @@ void main() uvec4 _23 = _5._m1; _6._m0 = uvec4(ivec4(_23) / _22); _6._m0 = uvec4(_22 / ivec4(_23)); - _6._m0 = uvec4(ivec4(_23) / ivec4(_23)); - _6._m0 = uvec4(_22 / _22); - _6._m1 = ivec4(_23) / ivec4(_23); - _6._m1 = _22 / _22; + _6._m0 = uvec4(1u); + _6._m0 = uvec4(1u); + _6._m1 = ivec4(1); + _6._m1 = ivec4(1); _6._m1 = ivec4(_23) / _22; _6._m1 = _22 / ivec4(_23); } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/comp/multiple-entry.asm.comp b/third_party/spirv-cross/reference/opt/shaders/asm/comp/multiple-entry.asm.comp index 6418464f197f..717e9ab8460d 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/comp/multiple-entry.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders/asm/comp/multiple-entry.asm.comp @@ -15,13 +15,15 @@ layout(binding = 1, std430) restrict buffer _7_9 void main() { - _9._m0 = _8._m1 + uvec4(_8._m0); - _9._m0 = uvec4(_8._m0) + _8._m1; + uvec4 _33 = _8._m1 + uvec4(_8._m0); + ivec4 _39 = ivec4(_8._m1) + _8._m0; + _9._m0 = _33; + _9._m0 = _33; _9._m0 = _8._m1 + _8._m1; _9._m0 = uvec4(_8._m0 + _8._m0); _9._m1 = ivec4(_8._m1 + _8._m1); _9._m1 = _8._m0 + _8._m0; - _9._m1 = ivec4(_8._m1) + _8._m0; - _9._m1 = _8._m0 + ivec4(_8._m1); + _9._m1 = _39; + _9._m1 = _39; } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/comp/specialization-constant-workgroup.asm.comp b/third_party/spirv-cross/reference/opt/shaders/asm/comp/specialization-constant-workgroup.asm.comp index e16bd191fdb5..6488c737a188 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/comp/specialization-constant-workgroup.asm.comp +++ b/third_party/spirv-cross/reference/opt/shaders/asm/comp/specialization-constant-workgroup.asm.comp @@ -6,9 +6,9 @@ #ifndef SPIRV_CROSS_CONSTANT_ID_12 #define SPIRV_CROSS_CONSTANT_ID_12 4u #endif - layout(local_size_x = SPIRV_CROSS_CONSTANT_ID_10, local_size_y = 20, local_size_z = SPIRV_CROSS_CONSTANT_ID_12) in; + layout(binding = 0, std430) buffer SSBO { float a; diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/implicit-read-dep-phi.asm.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/implicit-read-dep-phi.asm.frag index e2bac3f91c2c..02bfff1cdc4f 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/implicit-read-dep-phi.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/implicit-read-dep-phi.asm.frag @@ -16,7 +16,8 @@ void main() for (;;) { FragColor = _45; - if (_57 < 4) + bool _22 = _57 < 4; + if (_22) { if (v0[_57] > 0.0) { diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/locations-components.asm.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/locations-components.asm.frag index d8f45e99e734..8ff97ecf3ea0 100644 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/locations-components.asm.frag +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/locations-components.asm.frag @@ -16,7 +16,7 @@ void main() v2.x = _22; v2.y = uintBitsToFloat(_28); v2.z = uintBitsToFloat(_33); - o0.y = float(floatBitsToUint(intBitsToFloat(floatBitsToInt(v2.y) + floatBitsToInt(v2.z)))); + o0.y = float(uint(floatBitsToInt(v2.y) + floatBitsToInt(v2.z))); o0.x = v1.y + v2.x; o0 = vec4(o0.x, o0.y, v1.z, v1.x); } diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/out-of-bounds-access.asm.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/out-of-bounds-access.asm.frag deleted file mode 100644 index 4734c89c9af6..000000000000 --- a/third_party/spirv-cross/reference/opt/shaders/asm/frag/out-of-bounds-access.asm.frag +++ /dev/null @@ -1,8 +0,0 @@ -#version 320 es -precision mediump float; -precision highp int; - -void main() -{ -} - diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/out-of-bounds-access.asm.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/out-of-bounds-access.asm.invalid.frag similarity index 100% rename from third_party/spirv-cross/reference/shaders/asm/frag/out-of-bounds-access.asm.frag rename to third_party/spirv-cross/reference/opt/shaders/asm/frag/out-of-bounds-access.asm.invalid.frag diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/texture-sampling-fp16.asm.vk.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/texture-sampling-fp16.asm.vk.invalid.frag similarity index 100% rename from third_party/spirv-cross/reference/opt/shaders/asm/frag/texture-sampling-fp16.asm.vk.frag rename to third_party/spirv-cross/reference/opt/shaders/asm/frag/texture-sampling-fp16.asm.vk.invalid.frag diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/texture-sampling-fp16.asm.vk.invalid.frag.vk b/third_party/spirv-cross/reference/opt/shaders/asm/frag/texture-sampling-fp16.asm.vk.invalid.frag.vk new file mode 100644 index 000000000000..e13e4254ea77 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/texture-sampling-fp16.asm.vk.invalid.frag.vk @@ -0,0 +1,20 @@ +#version 450 +#if defined(GL_AMD_gpu_shader_half_float) +#extension GL_AMD_gpu_shader_half_float : require +#elif defined(GL_EXT_shader_explicit_arithmetic_types_float16) +#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require +#else +#error No extension available for FP16. +#endif +#extension GL_EXT_shader_16bit_storage : require + +layout(set = 0, binding = 0) uniform sampler2D uTexture; + +layout(location = 0) out f16vec4 FragColor; +layout(location = 0) in f16vec2 UV; + +void main() +{ + FragColor = f16vec4(texture(uTexture, UV)); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/frag/texture-shadow-lod.asm.frag b/third_party/spirv-cross/reference/opt/shaders/asm/frag/texture-shadow-lod.asm.frag new file mode 100644 index 000000000000..49efaef1fec4 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/asm/frag/texture-shadow-lod.asm.frag @@ -0,0 +1,14 @@ +#version 450 +#extension GL_EXT_texture_shadow_lod : require + +layout(binding = 0) uniform sampler2DArrayShadow uShadow2DArray; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec4 vUV; +layout(location = 1) in float vLod; + +void main() +{ + FragColor = vec4(textureLod(uShadow2DArray, vec4(vUV.xyz, vUV.w), vLod)); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/lib/global-array.asm.lib b/third_party/spirv-cross/reference/opt/shaders/asm/lib/global-array.asm.lib new file mode 100644 index 000000000000..ec6f73a0be5d --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/asm/lib/global-array.asm.lib @@ -0,0 +1,11 @@ +#ifdef SPIRV_CROSS_LIBRARY_HEADER +#version 450 +#endif + +const uint _15[4] = uint[](10u, 20u, 30u, 40u); + +uint lookup(uint i) +{ + return _15[i]; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/lib/multi-export.asm.lib b/third_party/spirv-cross/reference/opt/shaders/asm/lib/multi-export.asm.lib new file mode 100644 index 000000000000..de58d04775a6 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/asm/lib/multi-export.asm.lib @@ -0,0 +1,14 @@ +#ifdef SPIRV_CROSS_LIBRARY_HEADER +#version 450 +#endif + +uint add_one(uint x) +{ + return x + 1u; +} + +uint add_two(uint y) +{ + return y + 2u; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/vert/push-constant-row-major-matrix.asm.vk.vert b/third_party/spirv-cross/reference/opt/shaders/asm/vert/push-constant-row-major-matrix.asm.vk.vert new file mode 100644 index 000000000000..ac49a8762927 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/asm/vert/push-constant-row-major-matrix.asm.vk.vert @@ -0,0 +1,16 @@ +#version 450 + +struct type_PushConstant_Matrix +{ + mat4 transform; +}; + +uniform type_PushConstant_Matrix matrix_constants; + +layout(location = 0) in vec4 in_var_POSITION; + +void main() +{ + gl_Position = matrix_constants.transform * in_var_POSITION; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/asm/vert/push-constant-row-major-matrix.asm.vk.vert.vk b/third_party/spirv-cross/reference/opt/shaders/asm/vert/push-constant-row-major-matrix.asm.vk.vert.vk new file mode 100644 index 000000000000..12c49da31abd --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/asm/vert/push-constant-row-major-matrix.asm.vk.vert.vk @@ -0,0 +1,14 @@ +#version 450 + +layout(push_constant, std430) uniform type_PushConstant_Matrix +{ + layout(row_major) mat4 transform; +} matrix_constants; + +layout(location = 0) in vec4 in_var_POSITION; + +void main() +{ + gl_Position = in_var_POSITION * matrix_constants.transform; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/comp/cooperative-matrix.vk.nocompat.comp.vk b/third_party/spirv-cross/reference/opt/shaders/comp/cooperative-matrix.vk.nocompat.comp.vk index d8d9fbc701b1..1803763368fc 100644 --- a/third_party/spirv-cross/reference/opt/shaders/comp/cooperative-matrix.vk.nocompat.comp.vk +++ b/third_party/spirv-cross/reference/opt/shaders/comp/cooperative-matrix.vk.nocompat.comp.vk @@ -13,11 +13,7 @@ #extension GL_EXT_bfloat16 : require layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; -layout(constant_id = 6) const int Scope = 3; -layout(constant_id = 0) const int Rows = 16; -layout(constant_id = 1) const int Columns = 16; -layout(constant_id = 5) const int Layout = 0; -coopmat _881; +coopmat _876; layout(set = 0, binding = 0, std430) buffer SSBO32 { @@ -33,151 +29,151 @@ shared uint blah[512]; void main() { - uint _518 = 256u * gl_WorkGroupID.x; - coopmat _523; - coopMatLoad(_523, ssbo32.data, _518, 16u, gl_CooperativeMatrixLayoutColumnMajor); - coopmat _512 = _523; - uint _526 = 512u * gl_WorkGroupID.x; - coopmat _531; - coopMatLoad(_531, ssbo16.data, _526, 32u, gl_CooperativeMatrixLayoutRowMajor); - _512 = _531; - coopmat _539; - coopMatLoad(_539, ssbo32.data, _518, 16u, int(Layout)); - coopmat _513 = _539; - coopmat _547; - coopMatLoad(_547, ssbo16.data, _526, 32u, int(Layout)); - _513 = _547; - coopmat _555; - coopMatLoad(_555, ssbo32.data, _518, 16u, int(Layout)); - coopmat _514 = _555; - coopmat _563; - coopMatLoad(_563, ssbo16.data, _526, 32u, int(Layout)); - _514 = _563; - uint _570 = 128u * gl_WorkGroupID.x; - coopmat _575; - coopMatLoad(_575, ssbo32.data, _570, 8u, int(Layout)); - coopmat _564 = _575; - coopmat _583; - coopMatLoad(_583, ssbo16.data, _518, 16u, int(Layout)); - _564 = _583; - coopmat _591; - coopMatLoad(_591, ssbo32.data, _570, 8u, int(Layout)); - coopmat _565 = _591; - coopmat _599; - coopMatLoad(_599, ssbo16.data, _518, 16u, int(Layout)); - _565 = _599; - coopmat _607; - coopMatLoad(_607, ssbo32.data, _570, 8u, int(Layout)); - coopmat _566 = _607; - coopmat _615; - coopMatLoad(_615, ssbo16.data, _518, 16u, int(Layout)); - _566 = _615; - coopMatStore(coopmat(100.0), ssbo32.data, _570, 0u, gl_CooperativeMatrixLayoutColumnMajor); - coopMatStore(coopmat(100u), ssbo32.data, _570, 0u, gl_CooperativeMatrixLayoutRowMajor); - coopMatStore(coopmat(-100), ssbo32.data, _570, 0u, int(Layout)); - coopMatStore(coopmat(float16_t(100.0)), ssbo32.data, _570, 0u, int(Layout)); - coopMatStore(coopmat(-100s), ssbo32.data, _570, 0u, int(Layout)); - coopMatStore(coopmat(100us), ssbo32.data, _570, 0u, int(Layout)); - int _659 = int(uint(coopmat(0).length())); - _659 = int(uint(coopmat(0).length())); - _659 = int(uint(coopmat(0).length())); - _659 = int(uint(coopmat(0).length())); - _659 = int(uint(coopmat(0).length())); - _659 = int(uint(coopmat(0).length())); - coopmat _673 = coopmat(100.0); - coopmat _674 = coopmat(100u); - coopmat _678 = coopmat(coopmat(100.0)); - coopmat _675 = _678; - _675 = coopmat(coopmat(100u)); - coopmat _681 = coopmat(100.0); - coopmat _682 = coopmat(100); - coopmat _686 = (coopmat(100.0)) + (coopmat(100.0)); - _681 = _686; - coopmat _689 = _686 - _686; - _681 = _689; - coopmat _692 = _689 * _689; - _681 = _692; - coopmat _695 = _692 / _692; - _681 = _695; - _681 = _695 * 100.0; - coopmat _700 = (coopmat(100)) + (coopmat(100)); - _682 = _700; - coopmat _703 = _700 - _700; - _682 = _703; - coopmat _706 = _703 * _703; - _682 = _706; - coopmat _709 = _706 / _706; - _682 = _709; - _682 = _709 * 100; - coopmat _712 = coopmat(100.0); - int _713 = 0; - int _879 = 0; - for (; _879 < int(uint(coopmat(0).length())); ) + uint _513 = 256u * gl_WorkGroupID.x; + coopmat _518; + coopMatLoad(_518, ssbo32.data, _513, 16u, gl_CooperativeMatrixLayoutColumnMajor); + coopmat _507 = _518; + uint _521 = 512u * gl_WorkGroupID.x; + coopmat _526; + coopMatLoad(_526, ssbo16.data, _521, 32u, gl_CooperativeMatrixLayoutRowMajor); + _507 = _526; + coopmat _534; + coopMatLoad(_534, ssbo32.data, _513, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat _508 = _534; + coopmat _542; + coopMatLoad(_542, ssbo16.data, _521, 32u, gl_CooperativeMatrixLayoutRowMajor); + _508 = _542; + coopmat _550; + coopMatLoad(_550, ssbo32.data, _513, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat _509 = _550; + coopmat _558; + coopMatLoad(_558, ssbo16.data, _521, 32u, gl_CooperativeMatrixLayoutRowMajor); + _509 = _558; + uint _565 = 128u * gl_WorkGroupID.x; + coopmat _570; + coopMatLoad(_570, ssbo32.data, _565, 8u, gl_CooperativeMatrixLayoutRowMajor); + coopmat _559 = _570; + coopmat _578; + coopMatLoad(_578, ssbo16.data, _513, 16u, gl_CooperativeMatrixLayoutRowMajor); + _559 = _578; + coopmat _586; + coopMatLoad(_586, ssbo32.data, _565, 8u, gl_CooperativeMatrixLayoutRowMajor); + coopmat _560 = _586; + coopmat _594; + coopMatLoad(_594, ssbo16.data, _513, 16u, gl_CooperativeMatrixLayoutRowMajor); + _560 = _594; + coopmat _602; + coopMatLoad(_602, ssbo32.data, _565, 8u, gl_CooperativeMatrixLayoutRowMajor); + coopmat _561 = _602; + coopmat _610; + coopMatLoad(_610, ssbo16.data, _513, 16u, gl_CooperativeMatrixLayoutRowMajor); + _561 = _610; + coopMatStore(coopmat(100.0), ssbo32.data, _565, 0u, gl_CooperativeMatrixLayoutColumnMajor); + coopMatStore(coopmat(100u), ssbo32.data, _565, 0u, gl_CooperativeMatrixLayoutRowMajor); + coopMatStore(coopmat(-100), ssbo32.data, _565, 0u, gl_CooperativeMatrixLayoutRowMajor); + coopMatStore(coopmat(float16_t(100.0)), ssbo32.data, _565, 0u, gl_CooperativeMatrixLayoutRowMajor); + coopMatStore(coopmat(-100s), ssbo32.data, _565, 0u, gl_CooperativeMatrixLayoutRowMajor); + coopMatStore(coopmat(100us), ssbo32.data, _565, 0u, gl_CooperativeMatrixLayoutRowMajor); + int _654 = int(uint(coopmat(0).length())); + _654 = int(uint(coopmat(0).length())); + _654 = int(uint(coopmat(0).length())); + _654 = int(uint(coopmat(0).length())); + _654 = int(uint(coopmat(0).length())); + _654 = int(uint(coopmat(0).length())); + coopmat _668 = coopmat(100.0); + coopmat _669 = coopmat(100u); + coopmat _673 = coopmat(coopmat(100.0)); + coopmat _670 = _673; + _670 = coopmat(coopmat(100u)); + coopmat _676 = coopmat(100.0); + coopmat _677 = coopmat(100); + coopmat _681 = (coopmat(100.0)) + (coopmat(100.0)); + _676 = _681; + coopmat _684 = _681 - _681; + _676 = _684; + coopmat _687 = _684 * _684; + _676 = _687; + coopmat _690 = _687 / _687; + _676 = _690; + _676 = _690 * 100.0; + coopmat _695 = (coopmat(100)) + (coopmat(100)); + _677 = _695; + coopmat _698 = _695 - _695; + _677 = _698; + coopmat _701 = _698 * _698; + _677 = _701; + coopmat _704 = _701 / _701; + _677 = _704; + _677 = _704 * 100; + coopmat _707 = coopmat(100.0); + int _708 = 0; + int _874 = 0; + for (; _874 < int(uint(coopmat(0).length())); ) { - _712[_879] += 50.0; - int _729 = _879 + 1; - _713 = _729; - _879 = _729; + _707[_874] += 50.0; + int _724 = _874 + 1; + _708 = _724; + _874 = _724; continue; } - coopMatStore(_712, ssbo32.data, 0u, 16u, int(Layout)); - coopmat _737 = coopmat(gl_WorkGroupID.x); - coopmat _733 = _737; - coopMatStore(_737, ssbo32.data, 0u, 16u, int(Layout)); - coopmat _787 = _881 * _881; - coopmat _783 = _787; - coopmat _740 = _787; - coopmat _754; - coopMatLoad(_754, ssbo32.data, _518, 16u, int(Layout)); - _740 = _754; - coopmat _762; - coopMatLoad(_762, ssbo32.data, _518, 16u, int(Layout)); - coopmat _742 = _762; - coopmat _770; - coopMatLoad(_770, ssbo32.data, _518, 16u, int(Layout)); - coopmat _743 = _770; - coopmat _774 = coopMatMulAdd(_754, _762, _770, 0); - _743 = _774; - coopmat _778 = coopMatMulAdd(_754, _762, _774, 0); - _743 = _778; - _743 = coopMatMulAdd(_754, _762, _778, 16); - coopmat _799; - coopMatLoad(_799, ssbo32.data, _518, 16u, int(Layout)); - coopmat _788 = _799; - coopmat _807; - coopMatLoad(_807, ssbo32.data, _518, 16u, int(Layout)); - coopmat _789 = _807; - coopmat _815; - coopMatLoad(_815, ssbo32.data, _518, 16u, int(Layout)); - coopmat _790 = _815; - _790 = coopMatMulAdd(_799, _807, _815, 31); - coopmat _831; - coopMatLoad(_831, ssbo32.data, _518, 16u, int(Layout)); - coopmat _820 = _831; - coopmat _839; - coopMatLoad(_839, ssbo32.data, _518, 16u, int(Layout)); - coopmat _821 = _839; - coopmat _847; - coopMatLoad(_847, ssbo32.data, _518, 16u, int(Layout)); - coopmat _822 = _847; - _822 = coopMatMulAdd(_831, _839, _847, 31); - coopmat _855; - coopMatLoad(_855, blah, 0u, 16u, int(Layout)); - coopmat _852 = _855; - coopMatStore(_855, blah, 0u, 16u, int(Layout)); - coopmat _859[4]; - int _858 = 0; - int _882 = 0; - for (; _882 < 4; ) + coopMatStore(_707, ssbo32.data, 0u, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat _732 = coopmat(gl_WorkGroupID.x); + coopmat _728 = _732; + coopMatStore(_732, ssbo32.data, 0u, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat _782 = _876 * _876; + coopmat _778 = _782; + coopmat _735 = _782; + coopmat _749; + coopMatLoad(_749, ssbo32.data, _513, 16u, gl_CooperativeMatrixLayoutRowMajor); + _735 = _749; + coopmat _757; + coopMatLoad(_757, ssbo32.data, _513, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat _737 = _757; + coopmat _765; + coopMatLoad(_765, ssbo32.data, _513, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat _738 = _765; + coopmat _769 = coopMatMulAdd(_749, _757, _765, 0); + _738 = _769; + coopmat _773 = coopMatMulAdd(_749, _757, _769, 0); + _738 = _773; + _738 = coopMatMulAdd(_749, _757, _773, 16); + coopmat _794; + coopMatLoad(_794, ssbo32.data, _513, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat _783 = _794; + coopmat _802; + coopMatLoad(_802, ssbo32.data, _513, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat _784 = _802; + coopmat _810; + coopMatLoad(_810, ssbo32.data, _513, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat _785 = _810; + _785 = coopMatMulAdd(_794, _802, _810, 31); + coopmat _826; + coopMatLoad(_826, ssbo32.data, _513, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat _815 = _826; + coopmat _834; + coopMatLoad(_834, ssbo32.data, _513, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat _816 = _834; + coopmat _842; + coopMatLoad(_842, ssbo32.data, _513, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat _817 = _842; + _817 = coopMatMulAdd(_826, _834, _842, 31); + coopmat _850; + coopMatLoad(_850, blah, 0u, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat _847 = _850; + coopMatStore(_850, blah, 0u, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat _854[4]; + int _853 = 0; + int _877 = 0; + for (; _877 < 4; ) { - _859[_882] = coopmat(float(_882)); - int _873 = _882 + 1; - _858 = _873; - _882 = _873; + _854[_877] = coopmat(float(_877)); + int _868 = _877 + 1; + _853 = _868; + _877 = _868; continue; } - coopmat _875 = coopmat(0.0); - coopmat _876 = coopmat(0.0); - coopmat _877 = coopmat(bfloat16_t(2.5)); + coopmat _870 = coopmat(0.0); + coopmat _871 = coopmat(0.0); + coopmat _872 = coopmat(bfloat16_t(2.5)); } diff --git a/third_party/spirv-cross/reference/opt/shaders/comp/long-vector.vk.nocompat.comp.vk b/third_party/spirv-cross/reference/opt/shaders/comp/long-vector.vk.nocompat.comp.vk new file mode 100644 index 000000000000..f5dd28a24c92 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/comp/long-vector.vk.nocompat.comp.vk @@ -0,0 +1,49 @@ +#version 450 +#extension GL_EXT_long_vector : require +#extension GL_EXT_scalar_block_layout : require +layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; + +layout(set = 0, binding = 0, std430) buffer SSBO430 +{ + vector v1[4]; + vector v5[4]; + vector v6[4]; + vector v7[4]; + vector v8[4]; + vector v1024[4]; +} s430; + +layout(set = 0, binding = 1, scalar) buffer SSBOScalar +{ + vector v1[4]; + vector v5[4]; + vector v6[4]; + vector v7[4]; + vector v8[4]; + vector v1024[4]; +} scalar; + +shared vector shared_vec[4]; + +void main() +{ + uint _8 = gl_GlobalInvocationID.x; + s430.v1[0] += 4.0; + s430.v5[gl_GlobalInvocationID.x] += (vector(2.0, 2.0, 2.0, 2.0, 2.0)); + s430.v6[gl_GlobalInvocationID.x] += (vector(3.0, 3.0, 3.0, 3.0, 3.0, 3.0)); + s430.v7[gl_GlobalInvocationID.x] += (vector(4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0)); + s430.v8[gl_GlobalInvocationID.x] += (vector(5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0)); + scalar.v1[0] += 6.0; + scalar.v5[gl_GlobalInvocationID.x] += (vector(6.0, 6.0, 6.0, 6.0, 6.0)); + scalar.v6[gl_GlobalInvocationID.x] += (vector(7.0, 7.0, 7.0, 7.0, 7.0, 7.0)); + scalar.v7[gl_GlobalInvocationID.x] += (vector(8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0)); + scalar.v8[gl_GlobalInvocationID.x] += (vector(9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0)); + vector V = vector(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0); + V[10] += 50.0; + V[gl_LocalInvocationIndex] += 60.0; + shared_vec[gl_LocalInvocationIndex] = V; + barrier(); + s430.v1024[gl_GlobalInvocationID.x] = shared_vec[gl_LocalInvocationIndex]; + scalar.v1024[gl_GlobalInvocationID.x] = V; +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/comp/ssbo-array-length.comp b/third_party/spirv-cross/reference/opt/shaders/comp/ssbo-array-length.comp index ddc666e9b9b1..cad24089b7d9 100644 --- a/third_party/spirv-cross/reference/opt/shaders/comp/ssbo-array-length.comp +++ b/third_party/spirv-cross/reference/opt/shaders/comp/ssbo-array-length.comp @@ -9,6 +9,6 @@ layout(binding = 1, std140) buffer SSBO void main() { - _11.size = uint(int(uint(_11.v.length()))); + _11.size = uint(_11.v.length()); } diff --git a/third_party/spirv-cross/reference/opt/shaders/comp/struct-packing.comp b/third_party/spirv-cross/reference/opt/shaders/comp/struct-packing.comp index f4b58342d485..854de845ff7a 100644 --- a/third_party/spirv-cross/reference/opt/shaders/comp/struct-packing.comp +++ b/third_party/spirv-cross/reference/opt/shaders/comp/struct-packing.comp @@ -77,28 +77,28 @@ layout(binding = 0, std140) restrict buffer SSBO0 void main() { - ssbo_430.content.m0s[0].a[0] = ssbo_140.content.m0s[0].a[0]; - ssbo_430.content.m0s[0].b = ssbo_140.content.m0s[0].b; - ssbo_430.content.m1s[0].a = ssbo_140.content.m1s[0].a; - ssbo_430.content.m1s[0].b = ssbo_140.content.m1s[0].b; - ssbo_430.content.m2s[0].a[0] = ssbo_140.content.m2s[0].a[0]; - ssbo_430.content.m2s[0].b = ssbo_140.content.m2s[0].b; - ssbo_430.content.m0.a[0] = ssbo_140.content.m0.a[0]; + ssbo_430.content.m0s[0].a[0] = ssbo_140.content.m0s[0u].a[0u]; + ssbo_430.content.m0s[0].b = ssbo_140.content.m0s[0u].b; + ssbo_430.content.m1s[0].a = ssbo_140.content.m1s[0u].a; + ssbo_430.content.m1s[0].b = ssbo_140.content.m1s[0u].b; + ssbo_430.content.m2s[0].a[0] = ssbo_140.content.m2s[0u].a[0u]; + ssbo_430.content.m2s[0].b = ssbo_140.content.m2s[0u].b; + ssbo_430.content.m0.a[0] = ssbo_140.content.m0.a[0u]; ssbo_430.content.m0.b = ssbo_140.content.m0.b; ssbo_430.content.m1.a = ssbo_140.content.m1.a; ssbo_430.content.m1.b = ssbo_140.content.m1.b; - ssbo_430.content.m2.a[0] = ssbo_140.content.m2.a[0]; + ssbo_430.content.m2.a[0] = ssbo_140.content.m2.a[0u]; ssbo_430.content.m2.b = ssbo_140.content.m2.b; ssbo_430.content.m3.a = ssbo_140.content.m3.a; ssbo_430.content.m3.b = ssbo_140.content.m3.b; ssbo_430.content.m4 = ssbo_140.content.m4; - ssbo_430.content.m3s[0].c = ssbo_140.content.m3s[0].c; - ssbo_430.content.m3s[1].c = ssbo_140.content.m3s[1].c; - ssbo_430.content.m3s[2].c = ssbo_140.content.m3s[2].c; - ssbo_430.content.m3s[3].c = ssbo_140.content.m3s[3].c; - ssbo_430.content.m3s[4].c = ssbo_140.content.m3s[4].c; - ssbo_430.content.m3s[5].c = ssbo_140.content.m3s[5].c; - ssbo_430.content.m3s[6].c = ssbo_140.content.m3s[6].c; - ssbo_430.content.m3s[7].c = ssbo_140.content.m3s[7].c; + ssbo_430.content.m3s[0].c = ssbo_140.content.m3s[0u].c; + ssbo_430.content.m3s[1].c = ssbo_140.content.m3s[1u].c; + ssbo_430.content.m3s[2].c = ssbo_140.content.m3s[2u].c; + ssbo_430.content.m3s[3].c = ssbo_140.content.m3s[3u].c; + ssbo_430.content.m3s[4].c = ssbo_140.content.m3s[4u].c; + ssbo_430.content.m3s[5].c = ssbo_140.content.m3s[5u].c; + ssbo_430.content.m3s[6].c = ssbo_140.content.m3s[6u].c; + ssbo_430.content.m3s[7].c = ssbo_140.content.m3s[7u].c; } diff --git a/third_party/spirv-cross/reference/opt/shaders/desktop-only/comp/int64.desktop.comp b/third_party/spirv-cross/reference/opt/shaders/desktop-only/comp/int64.desktop.comp index 28afc2fbd7d3..13137c72ec1a 100644 --- a/third_party/spirv-cross/reference/opt/shaders/desktop-only/comp/int64.desktop.comp +++ b/third_party/spirv-cross/reference/opt/shaders/desktop-only/comp/int64.desktop.comp @@ -50,8 +50,8 @@ void main() ssbo_1.b += u64vec4(i64vec4(1l)); ssbo_0.a -= i64vec4(1l); ssbo_1.b -= u64vec4(i64vec4(1l)); - ssbo_1.b = doubleBitsToUint64(int64BitsToDouble(ssbo_0.a)); - ssbo_0.a = doubleBitsToInt64(uint64BitsToDouble(ssbo_1.b)); + ssbo_1.b = u64vec4(ssbo_0.a); + ssbo_0.a = i64vec4(ssbo_1.b); ssbo_2.a[0] += 1l; ssbo_3.a[0] += 2l; } diff --git a/third_party/spirv-cross/reference/opt/shaders/desktop-only/frag/depth-greater-than.desktop.frag b/third_party/spirv-cross/reference/opt/shaders/desktop-only/frag/depth-greater-than.desktop.frag index 8b7c296447ca..ef008f43a11e 100644 --- a/third_party/spirv-cross/reference/opt/shaders/desktop-only/frag/depth-greater-than.desktop.frag +++ b/third_party/spirv-cross/reference/opt/shaders/desktop-only/frag/depth-greater-than.desktop.frag @@ -1,4 +1,5 @@ #version 450 +#extension GL_ARB_conservative_depth : require layout(depth_greater) out float gl_FragDepth; layout(early_fragment_tests) in; diff --git a/third_party/spirv-cross/reference/opt/shaders/desktop-only/frag/depth-less-than.desktop.frag b/third_party/spirv-cross/reference/opt/shaders/desktop-only/frag/depth-less-than.desktop.frag index 44752eb8fb6f..b3c3f84513b3 100644 --- a/third_party/spirv-cross/reference/opt/shaders/desktop-only/frag/depth-less-than.desktop.frag +++ b/third_party/spirv-cross/reference/opt/shaders/desktop-only/frag/depth-less-than.desktop.frag @@ -1,4 +1,5 @@ #version 450 +#extension GL_ARB_conservative_depth : require layout(depth_less) out float gl_FragDepth; layout(early_fragment_tests) in; diff --git a/third_party/spirv-cross/reference/opt/shaders/flatten/struct.rowmajor.flatten.vert b/third_party/spirv-cross/reference/opt/shaders/flatten/struct.rowmajor.flatten.vert index 709d99291a22..0dfa3b46ced7 100644 --- a/third_party/spirv-cross/reference/opt/shaders/flatten/struct.rowmajor.flatten.vert +++ b/third_party/spirv-cross/reference/opt/shaders/flatten/struct.rowmajor.flatten.vert @@ -14,8 +14,7 @@ layout(location = 1) out vec3 V1; void main() { - Foo _20 = Foo(transpose(mat4x3(UBO[0].xyz, UBO[1].xyz, UBO[2].xyz, UBO[3].xyz)), transpose(mat4x3(UBO[4].xyz, UBO[5].xyz, UBO[6].xyz, UBO[7].xyz))); - V0 = v0 * _20.MVP0; - V1 = v1 * _20.MVP1; + V0 = v0 * Foo(transpose(mat4x3(UBO[0].xyz, UBO[1].xyz, UBO[2].xyz, UBO[3].xyz)), transpose(mat4x3(UBO[4].xyz, UBO[5].xyz, UBO[6].xyz, UBO[7].xyz))).MVP0; + V1 = v1 * Foo(transpose(mat4x3(UBO[0].xyz, UBO[1].xyz, UBO[2].xyz, UBO[3].xyz)), transpose(mat4x3(UBO[4].xyz, UBO[5].xyz, UBO[6].xyz, UBO[7].xyz))).MVP1; } diff --git a/third_party/spirv-cross/reference/opt/shaders/frag/shader-debug-info-line-directives.line.gV.frag b/third_party/spirv-cross/reference/opt/shaders/frag/shader-debug-info-line-directives.line.gV.frag index 91baf60f9f2a..eef72649b55f 100644 --- a/third_party/spirv-cross/reference/opt/shaders/frag/shader-debug-info-line-directives.line.gV.frag +++ b/third_party/spirv-cross/reference/opt/shaders/frag/shader-debug-info-line-directives.line.gV.frag @@ -8,8 +8,8 @@ void main() { #line 137 "test.frag" #line 106 "test.frag" - bool _288 = iv.x < 0.0; - if (_288) + bool _298 = iv.x < 0.0; + if (_298) { #line 107 "test.frag" ov.x = 50.0; @@ -20,10 +20,10 @@ void main() ov.x = 60.0; } #line 114 "test.frag" - for (int _519 = 0; _519 < 4; _519++) + for (int _529 = 0; _529 < 4; _529++) { #line 106 "test.frag" - if (_288) + if (_298) { #line 107 "test.frag" ov.x = 50.0; @@ -46,10 +46,10 @@ void main() } } #line 126 "test.frag" - for (int _523 = 0; _523 < 4; _523++) + for (int _533 = 0; _533 < 4; _533++) { #line 106 "test.frag" - if (_288) + if (_298) { #line 107 "test.frag" ov.x = 50.0; @@ -60,10 +60,10 @@ void main() ov.x = 60.0; } #line 114 "test.frag" - for (int _527 = 0; _527 < 4; _527++) + for (int _537 = 0; _537 < 4; _537++) { #line 106 "test.frag" - if (_288) + if (_298) { #line 107 "test.frag" ov.x = 50.0; diff --git a/third_party/spirv-cross/reference/opt/shaders/frag/texture-shadow-lod-bias.frag b/third_party/spirv-cross/reference/opt/shaders/frag/texture-shadow-lod-bias.frag new file mode 100644 index 000000000000..9058653dfcd1 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/frag/texture-shadow-lod-bias.frag @@ -0,0 +1,14 @@ +#version 450 +#extension GL_EXT_texture_shadow_lod : require + +layout(binding = 0) uniform sampler2DArrayShadow uShadow2DArray; + +layout(location = 0) in vec4 vUV; +layout(location = 1) in float vBias; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vec4(texture(uShadow2DArray, vec4(vUV.xyz, vUV.w), vBias) + textureOffset(uShadow2DArray, vec4(vUV.xyz, vUV.w), ivec2(1), vBias)); +} + diff --git a/third_party/spirv-cross/reference/opt/shaders/frag/texture-shadow-lod.vk.frag b/third_party/spirv-cross/reference/opt/shaders/frag/texture-shadow-lod.vk.frag new file mode 100644 index 000000000000..d194199fd4c8 --- /dev/null +++ b/third_party/spirv-cross/reference/opt/shaders/frag/texture-shadow-lod.vk.frag @@ -0,0 +1,15 @@ +#version 450 +#extension GL_EXT_texture_shadow_lod : require + +layout(binding = 0) uniform sampler2DArrayShadow uShadow2DArray; +layout(binding = 1) uniform samplerCubeShadow uShadowCube; + +layout(location = 0) in vec4 vUV; +layout(location = 1) in float vLod; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = vec4(((textureLod(uShadow2DArray, vec4(vUV.xyz, vUV.w), 0.0) + textureLod(uShadow2DArray, vec4(vUV.xyz, vUV.w), vLod)) + textureLod(uShadowCube, vec4(vUV.xyz, vUV.w), vLod)) + textureLodOffset(uShadow2DArray, vec4(vUV.xyz, vUV.w), vLod, ivec2(1))); +} + 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 dbb008af6448..d86fec368ec5 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,11 @@ layout(binding = 3, std140) uniform UBONoWorkaround layout(location = 0) out vec4 FragColor; layout(location = 0) in vec4 Clip; -NestedRowMajor spvWorkaroundRowMajor(NestedRowMajor wrap) { return wrap; } mat4 spvWorkaroundRowMajor(mat4 wrap) { return wrap; } void main() { - FragColor = (((spvWorkaroundRowMajor(_17.rm2).rm.B * spvWorkaroundRowMajor(_35.rm.B)) * spvWorkaroundRowMajor(_42.A)) * spvWorkaroundRowMajor(_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/geom/geometry-passthrough.geom b/third_party/spirv-cross/reference/opt/shaders/geom/geometry-passthrough.geom index d0d8806ad2a8..afbd662324f2 100644 --- a/third_party/spirv-cross/reference/opt/shaders/geom/geometry-passthrough.geom +++ b/third_party/spirv-cross/reference/opt/shaders/geom/geometry-passthrough.geom @@ -2,11 +2,6 @@ #extension GL_NV_geometry_shader_passthrough : require layout(triangles) in; -layout(passthrough) in gl_PerVertex -{ - vec4 gl_Position; -} gl_in[]; - layout(passthrough, location = 0) in VertexBlock { int a; diff --git a/third_party/spirv-cross/reference/opt/shaders/legacy/fragment/struct-varying.legacy.frag b/third_party/spirv-cross/reference/opt/shaders/legacy/fragment/struct-varying.legacy.frag index e131f2e21cf9..308539eb0b0c 100644 --- a/third_party/spirv-cross/reference/opt/shaders/legacy/fragment/struct-varying.legacy.frag +++ b/third_party/spirv-cross/reference/opt/shaders/legacy/fragment/struct-varying.legacy.frag @@ -13,6 +13,6 @@ varying highp vec2 vin_b; void main() { - gl_FragData[0] = ((((Inputs(vin_a, vin_b).a + Inputs(vin_a, vin_b).b.xxyy) + Inputs(vin_a, vin_b).a) + Inputs(vin_a, vin_b).b.yyxx) + vin_a) + vin_b.xxyy; + gl_FragData[0] = ((((vin_a + vin_b.xxyy) + vin_a) + vin_b.yyxx) + vin_a) + vin_b.xxyy; } diff --git a/third_party/spirv-cross/reference/opt/shaders/legacy/vert/struct-varying.legacy.vert b/third_party/spirv-cross/reference/opt/shaders/legacy/vert/struct-varying.legacy.vert index 66136d27ae73..3fb44c8cc6ca 100644 --- a/third_party/spirv-cross/reference/opt/shaders/legacy/vert/struct-varying.legacy.vert +++ b/third_party/spirv-cross/reference/opt/shaders/legacy/vert/struct-varying.legacy.vert @@ -15,9 +15,9 @@ void main() vout_b = Output(vec4(0.5), vec2(0.25)).b; vout_a = Output(vec4(0.5), vec2(0.25)).a; vout_b = Output(vec4(0.5), vec2(0.25)).b; - Output _22 = Output(vout_a, vout_b); - vout_a = _22.a; - vout_b = _22.b; + vec2 _54 = vout_b; + vout_a = vout_a; + vout_b = _54; vout_a.x = 1.0; vout_b.y = 1.0; } diff --git a/third_party/spirv-cross/reference/opt/shaders/mesh/mesh-shader-basic-lines.spv14.vk.nocompat.mesh.vk b/third_party/spirv-cross/reference/opt/shaders/mesh/mesh-shader-basic-lines.spv14.vk.nocompat.mesh.vk index 81f3c96ec185..4d1c4ff5e345 100644 --- a/third_party/spirv-cross/reference/opt/shaders/mesh/mesh-shader-basic-lines.spv14.vk.nocompat.mesh.vk +++ b/third_party/spirv-cross/reference/opt/shaders/mesh/mesh-shader-basic-lines.spv14.vk.nocompat.mesh.vk @@ -34,7 +34,6 @@ layout(location = 4) perprimitiveEXT out BlockOutPrim } prim_outputs[22]; taskPayloadSharedEXT TaskPayload payload; -shared float shared_float[16]; void main() { diff --git a/third_party/spirv-cross/reference/opt/shaders/mesh/mesh-shader-basic-points.spv14.vk.nocompat.mesh.vk b/third_party/spirv-cross/reference/opt/shaders/mesh/mesh-shader-basic-points.spv14.vk.nocompat.mesh.vk index bacc7fdfdc51..7958290df4be 100644 --- a/third_party/spirv-cross/reference/opt/shaders/mesh/mesh-shader-basic-points.spv14.vk.nocompat.mesh.vk +++ b/third_party/spirv-cross/reference/opt/shaders/mesh/mesh-shader-basic-points.spv14.vk.nocompat.mesh.vk @@ -34,7 +34,6 @@ layout(location = 4) perprimitiveEXT out BlockOutPrim } prim_outputs[22]; taskPayloadSharedEXT TaskPayload payload; -shared float shared_float[16]; void main() { diff --git a/third_party/spirv-cross/reference/opt/shaders/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.mesh.vk b/third_party/spirv-cross/reference/opt/shaders/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.mesh.vk index 87fd2c2b7b62..b28ca44c1117 100644 --- a/third_party/spirv-cross/reference/opt/shaders/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.mesh.vk +++ b/third_party/spirv-cross/reference/opt/shaders/mesh/mesh-shader-basic-triangle.spv14.vk.nocompat.mesh.vk @@ -34,7 +34,6 @@ layout(location = 4) perprimitiveEXT out BlockOutPrim } prim_outputs[22]; taskPayloadSharedEXT TaskPayload payload; -shared float shared_float[16]; void main() { diff --git a/third_party/spirv-cross/reference/opt/shaders/tesc/water_tess.tesc b/third_party/spirv-cross/reference/opt/shaders/tesc/water_tess.tesc index 79da68bedf68..8786124bf33d 100644 --- a/third_party/spirv-cross/reference/opt/shaders/tesc/water_tess.tesc +++ b/third_party/spirv-cross/reference/opt/shaders/tesc/water_tess.tesc @@ -34,7 +34,7 @@ void main() { _526 = _516; } - if (!(!_526)) + if (_526) { gl_TessLevelOuter[0] = -1.0; gl_TessLevelOuter[1] = -1.0; diff --git a/third_party/spirv-cross/reference/opt/shaders/tese/load-array-of-array.tese b/third_party/spirv-cross/reference/opt/shaders/tese/load-array-of-array.tese index e4b426d0ad69..a540c8a94f73 100644 --- a/third_party/spirv-cross/reference/opt/shaders/tese/load-array-of-array.tese +++ b/third_party/spirv-cross/reference/opt/shaders/tese/load-array-of-array.tese @@ -5,6 +5,6 @@ layout(location = 0) in vec4 vTexCoord[][1]; void main() { - gl_Position = (vTexCoord[0u][0] + vTexCoord[2u][0]) + vTexCoord[3u][0]; + gl_Position = (vTexCoord[0u][0u] + vTexCoord[2u][0u]) + vTexCoord[3u][0u]; } diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/arm/tensor_read.nocompat.noopt.vk.comp.vk b/third_party/spirv-cross/reference/opt/shaders/vulkan/arm/tensor_read.nocompat.noopt.vk.comp.vk index 6988e522cb9d..ad895fc042fa 100644 --- a/third_party/spirv-cross/reference/opt/shaders/vulkan/arm/tensor_read.nocompat.noopt.vk.comp.vk +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/arm/tensor_read.nocompat.noopt.vk.comp.vk @@ -17,8 +17,8 @@ void main() int _27[2]; tensorReadARM(t, uint[](1u, 2u, 3u, 4u), _27); int two[2] = _27; - int _37; - tensorReadARM(t, uint[](1u, 2u, 3u, 4u), _37); - _32.out_data[1] = _37; + int _35; + tensorReadARM(t, uint[](1u, 2u, 3u, 4u), _35); + _32.out_data[1] = _35; } diff --git a/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/spec-constant-work-group-size.vk.comp b/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/spec-constant-work-group-size.vk.comp index 888f4b164004..541edf09204c 100644 --- a/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/spec-constant-work-group-size.vk.comp +++ b/third_party/spirv-cross/reference/opt/shaders/vulkan/comp/spec-constant-work-group-size.vk.comp @@ -12,14 +12,14 @@ const uint _21 = (uint(a) + 0u); #ifndef SPIRV_CROSS_CONSTANT_ID_10 #define SPIRV_CROSS_CONSTANT_ID_10 1u #endif +layout(local_size_x = SPIRV_CROSS_CONSTANT_ID_10, local_size_y = 20, local_size_z = 1) in; + const uint _27 = gl_WorkGroupSize.x; const uint _28 = (_21 + _27); const uint _29 = gl_WorkGroupSize.y; const uint _30 = (_28 + _29); const int _32 = (1 - a); -layout(local_size_x = SPIRV_CROSS_CONSTANT_ID_10, local_size_y = 20, local_size_z = 1) in; - layout(binding = 0, std430) writeonly buffer SSBO { int v[]; diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/phi-undef-loop.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/phi-undef-loop.asm.comp new file mode 100644 index 000000000000..67b3e24f43a5 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/phi-undef-loop.asm.comp @@ -0,0 +1,18 @@ +static uint _16; + +RWByteAddressBuffer _4 : register(u0); + +void comp_main() +{ + uint _19 = 0u; + for (uint _22 = 0u; _22 < 10u; _19++, _22++) + { + _4.Store(0, _19); + } +} + +[numthreads(1, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/phi-undef-loop.zero-initialize.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/phi-undef-loop.zero-initialize.asm.comp new file mode 100644 index 000000000000..03b1e666f313 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/comp/phi-undef-loop.zero-initialize.asm.comp @@ -0,0 +1,18 @@ +static uint _16 = 0u; + +RWByteAddressBuffer _4 : register(u0); + +void comp_main() +{ + uint _19 = 0u; + for (uint _22 = 0u; _22 < 10u; _19++, _22++) + { + _4.Store(0, _19); + } +} + +[numthreads(1, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/packing/cbuffer-hard-packing.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/packing/cbuffer-hard-packing.asm.invalid.frag similarity index 100% rename from third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/packing/cbuffer-hard-packing.asm.frag rename to third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/packing/cbuffer-hard-packing.asm.invalid.frag diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/vert/push-constant-row-major-matrix.asm.vk.vert b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/vert/push-constant-row-major-matrix.asm.vk.vert new file mode 100644 index 000000000000..24821e891b06 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/vert/push-constant-row-major-matrix.asm.vk.vert @@ -0,0 +1,32 @@ +cbuffer type_PushConstant_Matrix +{ + column_major float4x4 matrix_constants_transform : packoffset(c0); +}; + + +static float4 gl_Position; +static float4 in_var_POSITION; + +struct SPIRV_Cross_Input +{ + float4 in_var_POSITION : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float4 gl_Position : SV_Position; +}; + +void vert_main() +{ + gl_Position = mul(matrix_constants_transform, in_var_POSITION); +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + in_var_POSITION = stage_input.in_var_POSITION; + 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-no-opt/asm/vert/push-constant-row-major-matrix.sm30.asm.vk.vert b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/vert/push-constant-row-major-matrix.sm30.asm.vk.vert new file mode 100644 index 000000000000..4a254528865c --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/asm/vert/push-constant-row-major-matrix.sm30.asm.vk.vert @@ -0,0 +1,35 @@ +cbuffer type_PushConstant_Matrix +{ + column_major float4x4 matrix_constants_transform : packoffset(c0); +}; + +uniform float4 gl_HalfPixel; + +static float4 gl_Position; +static float4 in_var_POSITION; + +struct SPIRV_Cross_Input +{ + float4 in_var_POSITION : TEXCOORD0; +}; + +struct SPIRV_Cross_Output +{ + float4 gl_Position : POSITION; +}; + +void vert_main() +{ + gl_Position = mul(matrix_constants_transform, in_var_POSITION); + gl_Position.x = gl_Position.x - gl_HalfPixel.x * gl_Position.w; + gl_Position.y = gl_Position.y + gl_HalfPixel.y * gl_Position.w; +} + +SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) +{ + in_var_POSITION = stage_input.in_var_POSITION; + 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-no-opt/comp/integer-dot-product.sm64.fxconly.nofxc.comp b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/integer-dot-product.sm64.fxconly.nofxc.comp new file mode 100644 index 000000000000..48f3feb89068 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/comp/integer-dot-product.sm64.fxconly.nofxc.comp @@ -0,0 +1,19 @@ +static const uint3 gl_WorkGroupSize = uint3(1u, 1u, 1u); + +RWByteAddressBuffer comp2 : register(u1, space0); +RWByteAddressBuffer comp : register(u0, space0); + +void comp_main() +{ + uint spdot32 = uint(dot4add_i8packed(comp2.Load(0), comp2.Load(4), 0)); + int spdoti32 = dot4add_i8packed(comp2.Load(0), comp2.Load(4), 0); + uint updot32 = dot4add_u8packed(comp2.Load(0), comp2.Load(4), 0); + uint udotaddsat_pack = dot4add_u8packed(comp2.Load(0), comp2.Load(4), updot32 /* WARN: HLSL will not saturate */); + uint sdotaddsat_pack = uint(dot4add_i8packed(comp2.Load(0), comp2.Load(4), updot32 /* WARN: HLSL will not saturate */)); +} + +[numthreads(1, 1, 1)] +void main() +{ + comp_main(); +} diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/mesh/clip-cull-array-load-store-single.sm65.nofxc.fxconly.spv16.mesh b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/mesh/clip-cull-array-load-store-single.sm65.nofxc.fxconly.spv16.mesh index 4141c742e36a..2309e873df4b 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/mesh/clip-cull-array-load-store-single.sm65.nofxc.fxconly.spv16.mesh +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/mesh/clip-cull-array-load-store-single.sm65.nofxc.fxconly.spv16.mesh @@ -15,14 +15,14 @@ struct gl_MeshPerPrimitiveEXT void write_clip_distance(inout float v[1]) { - v[0] += 1.0f; + v[0] = 1.0f; } void mesh_main(out gl_MeshPerVertexEXT gl_MeshVerticesEXT[3]) { SetMeshOutputCounts(3u, 1u); gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_ClipDistance[0] = 4.0f; - float param[1] = gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_ClipDistance; + float param[1]; write_clip_distance(param); gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_ClipDistance = param; } diff --git a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/mesh/clip-cull-array-load-store.sm65.nofxc.fxconly.spv16.mesh b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/mesh/clip-cull-array-load-store.sm65.nofxc.fxconly.spv16.mesh index 3940ac336192..874ca1f5113c 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl-no-opt/mesh/clip-cull-array-load-store.sm65.nofxc.fxconly.spv16.mesh +++ b/third_party/spirv-cross/reference/shaders-hlsl-no-opt/mesh/clip-cull-array-load-store.sm65.nofxc.fxconly.spv16.mesh @@ -15,10 +15,10 @@ struct gl_MeshPerPrimitiveEXT void write_clip_distance(inout float v[4]) { - v[0] += 1.0f; - v[1] += 2.0f; - v[2] += 3.0f; - v[3] += 4.0f; + v[0] = 1.0f; + v[1] = 2.0f; + v[2] = 3.0f; + v[3] = 4.0f; } void mesh_main(out gl_MeshPerVertexEXT gl_MeshVerticesEXT[3]) @@ -28,8 +28,7 @@ void mesh_main(out gl_MeshPerVertexEXT gl_MeshVerticesEXT[3]) gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_ClipDistance[1] = 4.0f; gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_ClipDistance[2] = 4.0f; gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_ClipDistance[3] = 4.0f; - float _62[4] = { gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_ClipDistance.x, gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_ClipDistance.y, gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_ClipDistance.z, gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_ClipDistance.w }; - float param[4] = _62; + float param[4]; write_clip_distance(param); gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_ClipDistance = float4(param[0], param[1], param[2], param[3]); } diff --git a/third_party/spirv-cross/reference/shaders-hlsl/asm/comp/replicated-composites.spv16.vk.asm.comp b/third_party/spirv-cross/reference/shaders-hlsl/asm/comp/replicated-composites.spv16.vk.asm.comp index 2ae45ff8d42f..27ee6d3ad4b0 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/asm/comp/replicated-composites.spv16.vk.asm.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl/asm/comp/replicated-composites.spv16.vk.asm.comp @@ -2,7 +2,7 @@ #define SPIRV_CROSS_CONSTANT_ID_0 0.0f #endif static const float spec_const = SPIRV_CROSS_CONSTANT_ID_0; -static const float4 _20 = float4(spec_const); +static const float4 _20 = (float4)spec_const; static const float _26[8] = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f }; @@ -14,10 +14,10 @@ cbuffer UBO : register(b0) void comp_main() { - float4 a = float4(0.0f); - float4x4 b = float4x4(float4(1.0f), float4(1.0f), float4(1.0f), float4(1.0f)); + float4 a = (float4)0.0f; + float4x4 b = float4x4((float4)1.0f, (float4)1.0f, (float4)1.0f, (float4)1.0f); float4 c = _20; - float4 d = float4(ubo_uniform_float); + float4 d = (float4)ubo_uniform_float; float4x4 e = float4x4(d, d, d, d); float f[8] = {ubo_uniform_float, ubo_uniform_float, ubo_uniform_float, ubo_uniform_float, ubo_uniform_float, ubo_uniform_float, ubo_uniform_float, ubo_uniform_float}; } diff --git a/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/texture-sampling-fp16.asm.frag b/third_party/spirv-cross/reference/shaders-hlsl/asm/frag/texture-sampling-fp16.asm.invalid.frag similarity index 100% rename from third_party/spirv-cross/reference/shaders-hlsl/asm/frag/texture-sampling-fp16.asm.frag rename to third_party/spirv-cross/reference/shaders-hlsl/asm/frag/texture-sampling-fp16.asm.invalid.frag diff --git a/third_party/spirv-cross/reference/shaders-hlsl/asm/lib/export-calls-export.asm.lib b/third_party/spirv-cross/reference/shaders-hlsl/asm/lib/export-calls-export.asm.lib new file mode 100644 index 000000000000..f3e9c8b265df --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl/asm/lib/export-calls-export.asm.lib @@ -0,0 +1,18 @@ +uint add_one(uint x) +{ + return x + 1u; +} + +uint add_three(uint z) +{ + return z + 3u; +} + +uint add_two(uint y) +{ + uint _16 = y; + uint _17 = add_one(_16); + uint _18 = add_one(_17); + return add_three(_18); +} + diff --git a/third_party/spirv-cross/reference/shaders-hlsl/asm/lib/global-array.asm.lib b/third_party/spirv-cross/reference/shaders-hlsl/asm/lib/global-array.asm.lib new file mode 100644 index 000000000000..5502301c7d00 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl/asm/lib/global-array.asm.lib @@ -0,0 +1,7 @@ +static const uint _15[4] = { 10u, 20u, 30u, 40u }; + +uint lookup(uint i) +{ + return _15[i]; +} + diff --git a/third_party/spirv-cross/reference/shaders-hlsl/asm/lib/multi-export.asm.lib b/third_party/spirv-cross/reference/shaders-hlsl/asm/lib/multi-export.asm.lib new file mode 100644 index 000000000000..78b0fadbb939 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-hlsl/asm/lib/multi-export.asm.lib @@ -0,0 +1,17 @@ +uint add_one(uint x) +{ + return x + 1u; +} + +uint helper_add(uint a, uint b) +{ + return a + b; +} + +uint add_two(uint y) +{ + uint _22 = y; + uint _23 = 2u; + return helper_add(_22, _23); +} + diff --git a/third_party/spirv-cross/reference/shaders-hlsl/comp/ssbo-store-array.comp b/third_party/spirv-cross/reference/shaders-hlsl/comp/ssbo-store-array.comp index 2512118a8dbc..a7b6d773fc1d 100644 --- a/third_party/spirv-cross/reference/shaders-hlsl/comp/ssbo-store-array.comp +++ b/third_party/spirv-cross/reference/shaders-hlsl/comp/ssbo-store-array.comp @@ -3,14 +3,17 @@ struct Data uint arr[3]; }; -RWByteAddressBuffer _13 : register(u0); +static const uint _14[3] = { 1u, 2u, 3u }; +static const Data _15 = { { 1u, 2u, 3u } }; + +RWByteAddressBuffer _21 : register(u0); void comp_main() { - Data d1; - _13.Store(0, d1.arr[0]); - _13.Store(4, d1.arr[1]); - _13.Store(8, d1.arr[2]); + Data d1 = _15; + _21.Store(0, d1.arr[0]); + _21.Store(4, d1.arr[1]); + _21.Store(8, d1.arr[2]); } [numthreads(1, 1, 1)] diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/aliased-struct-divergent-member-name.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/aliased-struct-divergent-member-name.asm.comp index 4151832e846f..4e38689ca59a 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/aliased-struct-divergent-member-name.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/aliased-struct-divergent-member-name.asm.comp @@ -1,8 +1,13 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +struct spvPaddedArrayElement { T data; char padding[stride - sizeof(T)]; }; + struct T { float a; @@ -21,18 +26,17 @@ struct SSBO1 struct T_2 { float c; - char _m0_final_padding[12]; }; struct SSBO2 { - T_2 bar[1]; + spvPaddedArrayElement bar[1]; }; kernel void main0(device SSBO1& _9 [[buffer(0)]], device SSBO2& _13 [[buffer(1)]]) { T v = T{ 40.0 }; _9.foo[10].b = v.a; - _13.bar[30].c = v.a; + _13.bar[30].data.c = v.a; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/bda-atomic-ptr-cast.spv16.msl23.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/bda-atomic-ptr-cast.spv16.msl23.asm.comp new file mode 100644 index 000000000000..29313f553de3 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/bda-atomic-ptr-cast.spv16.msl23.asm.comp @@ -0,0 +1,19 @@ +#pragma clang diagnostic ignored "-Wunused-variable" + +#include +#include +#include + +using namespace metal; + +struct PC +{ + ulong _m0; + uint _m1; +}; + +kernel void main0(constant PC& pc [[buffer(0)]]) +{ + uint _44 = atomic_fetch_max_explicit((device atomic_uint*)(reinterpret_cast(pc._m0 + (ulong(min(pc._m1, 256u)) * 4ul))), 4294967295u, memory_order_relaxed); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/compilation-loop-edge-case.spv16.asm.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/compilation-loop-edge-case.spv16.asm.comp new file mode 100644 index 000000000000..88421c38894d --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/compilation-loop-edge-case.spv16.asm.comp @@ -0,0 +1,154 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +template +[[clang::optnone]] T spvFMul(T l, T r) +{ + return fma(l, r, T(0)); +} + +template +[[clang::optnone]] 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 +[[clang::optnone]] 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 +[[clang::optnone]] matrix spvFMulMatrixMatrix(matrix l, matrix r) +{ + static_assert(LCols == RRows, "column-row configuration mismatch"); + 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 +[[clang::optnone]] T spvFAdd(T l, T r) +{ + return fma(T(1), l, r); +} + +template +[[clang::optnone]] T spvFSub(T l, T r) +{ + return fma(T(-1), r, l); +} + +template +void spvImageFence(ImageT img) { img.fence(); } + +struct _8 +{ + float2 _m0; + float2 _m1; + packed_float3 _m2; + uint _m3; + float _m4; + uint _m5; + uint _m6; + uint _m7; +}; + +kernel void main0(constant _8& _4 [[buffer(0)]], texture3d _5 [[texture(0)]], texture3d _6 [[texture(1)]], texture2d _7 [[texture(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) +{ + float _23 = 1.0 / fast::normalize(float3(spvFAdd(spvFMul(float2(gl_GlobalInvocationID.xy), _4._m0), _4._m1), 1.0)).z; + uint _115 = uint(ceil(spvFMul(_7.read(uint2(gl_GlobalInvocationID.xy), 0u).x, float(_4._m3)))); + float _39 = spvFAdd(spvFMul(precise::exp2(spvFMul(0.0, _4._m2[0])), _4._m2[1]), _4._m2[2]); + float3 _123; + float3 _125; + float _126; + int _127; + _123 = float3(0.0); + _125 = float3(1.0); + _126 = _39; + _127 = 0; + float3 _34; + float3 _35; + float _42; + uint3 _133; + uint4 _139; + uint _140; + uint4 _152; + uint _153; + float3 _164; + float _166; + float3 _167; + float3 _168; + float _177; + uint3 _179; + float3 _192; + float _201; + uint3 _203; + uint _128; + for (;;) + { + _128 = uint(_127); + if (_128 < _115) + { + _133 = uint3(gl_GlobalInvocationID.xy, _128); + _42 = spvFAdd(spvFMul(precise::exp2(spvFMul(spvFMul(spvFAdd(float(_127), 1.0), _4._m4), _4._m2[0])), _4._m2[1]), _4._m2[2]); + spvImageFence(_5); + _139 = _5.read(uint3(_133)); + _140 = _139.x; + spvImageFence(_6); + _152 = _6.read(uint3(_133)); + _153 = _152.x; + _164 = precise::exp((-spvFMul(float3(uint3(_153, _153 >> 9u, _153 >> 18u) & uint3(511u)), precise::exp2(float3(float(int(_153 >> 27u) - 24))))) * spvFMul(spvFSub(_42, _126), _23)); + _34 = spvFAdd(_123, spvFMul(spvFMul(spvFMul(float3(uint3(_140, _140 >> 9u, _140 >> 18u) & uint3(511u)), precise::exp2(float3(float(int(_140 >> 27u) - 24)))), spvFSub(float3(1.0), _164)), _125)); + _35 = spvFMul(_125, _164); + _166 = as_type(931135488u); + _167 = float3(as_type(1199538176u)); + _168 = fast::clamp(_34, float3(0.0), _167); + _177 = as_type((as_type(precise::max(precise::max(_166, _168.x), precise::max(_168.y, _168.z))) + 125845504u) & 2139095040u); + _179 = as_type(spvFAdd(_168, float3(_177))); + _5.write(uint4(((((as_type(_177) << 4u) + 268435456u) | (_179.z << 18u)) | (_179.y << 9u)) | (_179.x & 511u)), uint3(_133)); + _192 = fast::clamp(_35, float3(0.0), _167); + _201 = as_type((as_type(precise::max(precise::max(_166, _192.x), precise::max(_192.y, _192.z))) + 125845504u) & 2139095040u); + _203 = as_type(spvFAdd(_192, float3(_201))); + _6.write(uint4(((((as_type(_201) << 4u) + 268435456u) | (_203.z << 18u)) | (_203.y << 9u)) | (_203.x & 511u)), uint3(_133)); + _123 = _34; + _125 = _35; + _126 = _42; + _127++; + continue; + } + else + { + break; + } + } +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-bfloat.asm.msl31.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-bfloat.asm.msl31.comp new file mode 100644 index 000000000000..757500a1e2af --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-bfloat.asm.msl31.comp @@ -0,0 +1,24 @@ +#include +#include +#include + +using namespace metal; + +struct SSBO +{ + bfloat data[1]; +}; + +kernel void main0(device SSBO& ssbo [[buffer(0)]]) +{ + simdgroup_bfloat8x8 _21; + simdgroup_load(_21, &ssbo.data[0u], 8u); + simdgroup_bfloat8x8 _22; + simdgroup_load(_22, &ssbo.data[0u], 8u); + simdgroup_bfloat8x8 _23; + simdgroup_load(_23, &ssbo.data[0u], 8u); + simdgroup_bfloat8x8 _24; + simdgroup_multiply_accumulate(_24, _21, _22, _23); + simdgroup_store(_24, &ssbo.data[0u], 8u); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-convert.asm.msl31.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-convert.asm.msl31.comp new file mode 100644 index 000000000000..ec5de429d7eb --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-convert.asm.msl31.comp @@ -0,0 +1,59 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#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]; + } +}; + +kernel void main0() +{ + threadgroup spvUnsafeArray _16; + threadgroup spvUnsafeArray _17; + simdgroup_half8x8 _23; + simdgroup_load(_23, &_17[0u], 8u); + simdgroup_float8x8 _24; + _24.thread_elements()[0u] = float(_23.thread_elements()[0u]); + _24.thread_elements()[1u] = float(_23.thread_elements()[1u]); + simdgroup_store(_24, &_16[0u], 8u); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-elementwise.asm.msl31.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-elementwise.asm.msl31.comp new file mode 100644 index 000000000000..04bc412b57eb --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-elementwise.asm.msl31.comp @@ -0,0 +1,72 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#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]; + } +}; + +kernel void main0() +{ + threadgroup spvUnsafeArray _14; + simdgroup_float8x8 _18; + simdgroup_load(_18, &_14[0u], 8u); + simdgroup_float8x8 _19; + simdgroup_load(_19, &_14[0u], 8u); + simdgroup_float8x8 _20; + _20.thread_elements()[0u] = -_18.thread_elements()[0u]; + _20.thread_elements()[1u] = -_18.thread_elements()[1u]; + simdgroup_float8x8 _21; + _21.thread_elements()[0u] = _20.thread_elements()[0u] + _19.thread_elements()[0u]; + _21.thread_elements()[1u] = _20.thread_elements()[1u] + _19.thread_elements()[1u]; + simdgroup_float8x8 _22; + _22.thread_elements()[0u] = _21.thread_elements()[0u] - _18.thread_elements()[0u]; + _22.thread_elements()[1u] = _21.thread_elements()[1u] - _18.thread_elements()[1u]; + simdgroup_float8x8 _23; + _23.thread_elements()[0u] = _22.thread_elements()[0u] * _19.thread_elements()[0u]; + _23.thread_elements()[1u] = _22.thread_elements()[1u] * _19.thread_elements()[1u]; + simdgroup_float8x8 _24; + _24.thread_elements()[0u] = _23.thread_elements()[0u] / _18.thread_elements()[0u]; + _24.thread_elements()[1u] = _23.thread_elements()[1u] / _18.thread_elements()[1u]; + simdgroup_store(_24, &_14[0u], 8u); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-extract-insert.asm.spv16.msl31.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-extract-insert.asm.spv16.msl31.comp new file mode 100644 index 000000000000..25cd2a4445c1 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-extract-insert.asm.spv16.msl31.comp @@ -0,0 +1,61 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#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]; + } +}; + +kernel void main0() +{ + threadgroup spvUnsafeArray _2; + simdgroup_float8x8 _18; + simdgroup_load(_18, &_2[0u], 8u); + simdgroup_float8x8 _21; + _21.thread_elements()[0u] = _18.thread_elements()[0u]; + _21.thread_elements()[1u] = _18.thread_elements()[1u]; + _21.thread_elements()[0u] = 1.0; + simdgroup_store(_21, &_2[0u], 8u); + _2[0u] = _18.thread_elements()[0u]; + _2[0u] = _18.thread_elements()[1u]; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-length.asm.msl31.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-length.asm.msl31.comp new file mode 100644 index 000000000000..8161a5c9c083 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-length.asm.msl31.comp @@ -0,0 +1,16 @@ +#include +#include +#include + +using namespace metal; + +struct SSBO +{ + uint data[1]; +}; + +kernel void main0(device SSBO& ssbo [[buffer(0)]]) +{ + ssbo.data[0u] = uint(sizeof(simdgroup_float8x8::storage_type) / sizeof(float)); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-load-store.asm.msl31.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-load-store.asm.msl31.comp new file mode 100644 index 000000000000..005cf2c7e841 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-load-store.asm.msl31.comp @@ -0,0 +1,21 @@ +#include +#include +#include + +using namespace metal; + +struct SSBO +{ + float data[1]; +}; + +kernel void main0(device SSBO& ssbo [[buffer(0)]]) +{ + simdgroup_float8x8 _20; + simdgroup_load(_20, &ssbo.data[0u], 8u); + simdgroup_store(_20, &ssbo.data[0u], 8u); + simdgroup_float8x8 _21; + simdgroup_load(_21, &ssbo.data[0u], 8u, ulong2(0), true); + simdgroup_store(_21, &ssbo.data[0u], 8u, ulong2(0), true); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-muladd.asm.msl31.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-muladd.asm.msl31.comp new file mode 100644 index 000000000000..f5a47982e218 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-muladd.asm.msl31.comp @@ -0,0 +1,38 @@ +#include +#include +#include + +using namespace metal; + +struct SSBO32 +{ + float data[1]; +}; + +struct SSBO16 +{ + half data[1]; +}; + +kernel void main0(device SSBO32& ssbo32 [[buffer(0)]], device SSBO16& ssbo16 [[buffer(1)]]) +{ + simdgroup_float8x8 _30; + simdgroup_load(_30, &ssbo32.data[0u], 8u); + simdgroup_float8x8 _31; + simdgroup_load(_31, &ssbo32.data[0u], 8u); + simdgroup_float8x8 _32; + simdgroup_load(_32, &ssbo32.data[0u], 8u); + simdgroup_float8x8 _33; + simdgroup_multiply_accumulate(_33, _30, _31, _32); + simdgroup_store(_33, &ssbo32.data[0u], 8u); + simdgroup_half8x8 _35; + simdgroup_load(_35, &ssbo16.data[0u], 8u); + simdgroup_half8x8 _36; + simdgroup_load(_36, &ssbo16.data[0u], 8u); + simdgroup_half8x8 _37; + simdgroup_load(_37, &ssbo16.data[0u], 8u); + simdgroup_half8x8 _38; + simdgroup_multiply_accumulate(_38, _35, _36, _37); + simdgroup_store(_38, &ssbo16.data[0u], 8u); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-multi-simdgroup.asm.spv16.msl31.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-multi-simdgroup.asm.spv16.msl31.comp new file mode 100644 index 000000000000..28db81e559df --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-multi-simdgroup.asm.spv16.msl31.comp @@ -0,0 +1,58 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#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]; + } +}; + +kernel void main0() +{ + threadgroup spvUnsafeArray _2; + simdgroup_float8x8 _18; + simdgroup_load(_18, &_2[0u], 8u); + simdgroup_float8x8 _19; + _19.thread_elements()[0u] = -_18.thread_elements()[0u]; + _19.thread_elements()[1u] = -_18.thread_elements()[1u]; + simdgroup_store(_19, &_2[0u], 8u); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-scalar-mul.asm.msl31.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-scalar-mul.asm.msl31.comp new file mode 100644 index 000000000000..bfe421af1326 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-scalar-mul.asm.msl31.comp @@ -0,0 +1,58 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#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]; + } +}; + +kernel void main0() +{ + threadgroup spvUnsafeArray _14; + simdgroup_float8x8 _18; + simdgroup_load(_18, &_14[0u], 8u); + simdgroup_float8x8 _19; + _19.thread_elements()[0u] = _18.thread_elements()[0u] * 2.0; + _19.thread_elements()[1u] = _18.thread_elements()[1u] * 2.0; + simdgroup_store(_19, &_14[0u], 8u); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-select.asm.invalid.msl31.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-select.asm.invalid.msl31.comp new file mode 100644 index 000000000000..0d103d8dc937 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-select.asm.invalid.msl31.comp @@ -0,0 +1,60 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#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]; + } +}; + +kernel void main0() +{ + threadgroup spvUnsafeArray _2; + simdgroup_float8x8 _19; + simdgroup_load(_19, &_2[0u], 8u); + simdgroup_float8x8 _20; + simdgroup_load(_20, &_2[0u], 8u); + simdgroup_float8x8 _21; + _21.thread_elements()[0u] = true ? _19.thread_elements()[0u] : _20.thread_elements()[0u]; + _21.thread_elements()[1u] = true ? _19.thread_elements()[1u] : _20.thread_elements()[1u]; + simdgroup_store(_21, &_2[0u], 8u); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-splat.asm.msl31.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-splat.asm.msl31.comp new file mode 100644 index 000000000000..6eb2397aa5ae --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-splat.asm.msl31.comp @@ -0,0 +1,56 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#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]; + } +}; + +kernel void main0() +{ + threadgroup spvUnsafeArray _14; + simdgroup_float8x8 _17; + _17.thread_elements()[0u] = 0.0; + _17.thread_elements()[1u] = 0.0; + simdgroup_store(_17, &_14[0u], 8u); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-workgroup-cast-load-store.asm.msl31.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-workgroup-cast-load-store.asm.msl31.comp new file mode 100644 index 000000000000..5d29f8c25d42 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-workgroup-cast-load-store.asm.msl31.comp @@ -0,0 +1,56 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#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]; + } +}; + +kernel void main0() +{ + threadgroup spvUnsafeArray _15; + _15[0u] = uchar(0); + simdgroup_half8x8 _20; + simdgroup_load(_20, reinterpret_cast(&_15[0u]), (16u) / 2u); + simdgroup_store(_20, reinterpret_cast(&_15[0u]), (16u) / 2u); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-workgroup-load-store.asm.msl31.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-workgroup-load-store.asm.msl31.comp new file mode 100644 index 000000000000..a69c7b7faa62 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/cooperative-matrix-workgroup-load-store.asm.msl31.comp @@ -0,0 +1,58 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wmissing-braces" + +#include +#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]; + } +}; + +kernel void main0() +{ + threadgroup spvUnsafeArray _14; + simdgroup_float8x8 _18; + simdgroup_load(_18, &_14[0u], 8u); + simdgroup_store(_18, &_14[0u], 8u); + simdgroup_float8x8 _19; + simdgroup_load(_19, &_14[0u], 8u, ulong2(0), true); + simdgroup_store(_19, &_14[0u], 8u, ulong2(0), true); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/volatile-phys-buf-load-no-forward.asm.msl24.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/volatile-phys-buf-load-no-forward.asm.msl24.comp new file mode 100644 index 000000000000..2a513c35a5bc --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/comp/volatile-phys-buf-load-no-forward.asm.msl24.comp @@ -0,0 +1,19 @@ +#include +#include + +using namespace metal; + +struct Registers +{ + ulong addr; + ulong addr2; +}; + +kernel void main0(constant Registers& registers [[buffer(0)]]) +{ + device int* _21 = reinterpret_cast(registers.addr2); + int _22 = *(reinterpret_cast(registers.addr)); + *_21 = _22; + *(reinterpret_cast(reinterpret_cast(_21) + 4ul)) = _22; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/image-type-normal-comparison-usage.asm.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/image-type-normal-comparison-usage.asm.frag index 2e43ab0c2ab6..23cec815e063 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/image-type-normal-comparison-usage.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/image-type-normal-comparison-usage.asm.frag @@ -1,8 +1,34 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float4 out_var_SV_Target0 [[color(0)]]; @@ -13,7 +39,7 @@ struct main0_in float2 in_var_TEXCOORD0 [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d ShadowMap [[texture(0)]], sampler SampleNormal [[sampler(0)]], sampler SampleShadow [[sampler(1)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d ShadowMap [[texture(0)]], sampler SampleNormal [[sampler(0)]], sampler SampleShadow [[sampler(1)]]) { main0_out out = {}; float _41; @@ -23,7 +49,7 @@ fragment main0_out main0(main0_in in [[stage_in]], depth2d ShadowMap [[te } else { - _41 = ShadowMap.sample_compare(SampleShadow, in.in_var_TEXCOORD0, 0.5, level(0.0)); + _41 = spvDepthCast(ShadowMap).sample_compare(SampleShadow, in.in_var_TEXCOORD0, 0.5, level(0.0)); } out.out_var_SV_Target0 = float4(_41, _41, _41, 1.0); return out; diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/spec-constant-dead-branch-comparison-array.asm.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/spec-constant-dead-branch-comparison-array.asm.frag new file mode 100644 index 000000000000..87014b7b13c8 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/spec-constant-dead-branch-comparison-array.asm.frag @@ -0,0 +1,60 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + +constant uint _10_tmp [[function_constant(0)]]; +constant uint _10 = is_function_constant_defined(_10_tmp) ? _10_tmp : 0u; + +struct main0_out +{ + float4 out_var_SV_Target0 [[color(0)]]; +}; + +struct main0_in +{ + float3 in_var_TEXCOORD0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +uint get_sampler_type() +{ + return _10; +} + +fragment main0_out main0(main0_in in [[stage_in]], texture2d_array ShadowMapArray [[texture(0)]], sampler Sampler [[sampler(0)]]) +{ + main0_out out = {}; + if (get_sampler_type() == 3u) + { + } + out.out_var_SV_Target0 = float4(ShadowMapArray.sample(Sampler, in.in_var_TEXCOORD0.xy, uint(rint(in.in_var_TEXCOORD0.z)))); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/spec-constant-dead-branch-comparison-cube.asm.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/spec-constant-dead-branch-comparison-cube.asm.frag new file mode 100644 index 000000000000..604c71c2f87f --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/spec-constant-dead-branch-comparison-cube.asm.frag @@ -0,0 +1,60 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + +constant uint _10_tmp [[function_constant(0)]]; +constant uint _10 = is_function_constant_defined(_10_tmp) ? _10_tmp : 0u; + +struct main0_out +{ + float4 out_var_SV_Target0 [[color(0)]]; +}; + +struct main0_in +{ + float3 in_var_TEXCOORD0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +uint get_sampler_type() +{ + return _10; +} + +fragment main0_out main0(main0_in in [[stage_in]], texturecube ShadowMapCube [[texture(0)]], sampler Sampler [[sampler(0)]]) +{ + main0_out out = {}; + if (get_sampler_type() == 3u) + { + } + out.out_var_SV_Target0 = float4(ShadowMapCube.sample(Sampler, in.in_var_TEXCOORD0)); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/spec-constant-dead-branch-comparison.asm.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/spec-constant-dead-branch-comparison.asm.frag new file mode 100644 index 000000000000..58ca8ed85a9a --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/frag/spec-constant-dead-branch-comparison.asm.frag @@ -0,0 +1,60 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + +constant uint _10_tmp [[function_constant(0)]]; +constant uint _10 = is_function_constant_defined(_10_tmp) ? _10_tmp : 0u; + +struct main0_out +{ + float4 out_var_SV_Target0 [[color(0)]]; +}; + +struct main0_in +{ + float2 in_var_TEXCOORD0 [[user(locn0)]]; +}; + +static inline __attribute__((always_inline)) +uint get_sampler_type() +{ + return _10; +} + +fragment main0_out main0(main0_in in [[stage_in]], texture2d ShadowMap [[texture(0)]], sampler Sampler [[sampler(0)]]) +{ + main0_out out = {}; + if (get_sampler_type() == 3u) + { + } + out.out_var_SV_Target0 = float4(ShadowMap.sample(Sampler, in.in_var_TEXCOORD0)); + 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 4587fe67ea70..5d551768fc24 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 @@ -126,7 +126,31 @@ inline spvGatherCompareReturn spvGatherCompareSwizzle(const thread T return t.gather_compare(s, params...); } -fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d tex1d [[texture(0)]], texture2d tex2d [[texture(1)]], texture3d tex3d [[texture(2)]], texturecube texCube [[texture(3)]], texture2d_array tex2dArray [[texture(4)]], texturecube_array texCubeArray [[texture(5)]], depth2d depth2d [[texture(6)]], depthcube depthCube [[texture(7)]], depth2d_array depth2dArray [[texture(8)]], depthcube_array depthCubeArray [[texture(9)]], texture2d texBuffer [[texture(10)]], sampler tex1dSamp [[sampler(0)]], sampler tex2dSamp [[sampler(1)]], sampler tex3dSamp [[sampler(2)]], sampler texCubeSamp [[sampler(3)]], sampler tex2dArraySamp [[sampler(4)]], sampler texCubeArraySamp [[sampler(5)]], sampler depth2dSamp [[sampler(6)]], sampler depthCubeSamp [[sampler(7)]], sampler depth2dArraySamp [[sampler(8)]], sampler depthCubeArraySamp [[sampler(9)]]) +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + +fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d tex1d [[texture(0)]], texture2d tex2d [[texture(1)]], texture3d tex3d [[texture(2)]], texturecube texCube [[texture(3)]], texture2d_array tex2dArray [[texture(4)]], texturecube_array texCubeArray [[texture(5)]], texture2d depth2d0 [[texture(6)]], texturecube depthCube [[texture(7)]], texture2d_array depth2dArray [[texture(8)]], texturecube_array depthCubeArray [[texture(9)]], texture2d texBuffer [[texture(10)]], sampler tex1dSamp [[sampler(0)]], sampler tex2dSamp [[sampler(1)]], sampler tex3dSamp [[sampler(2)]], sampler texCubeSamp [[sampler(3)]], sampler tex2dArraySamp [[sampler(4)]], sampler texCubeArraySamp [[sampler(5)]], sampler depth2dSamp [[sampler(6)]], sampler depthCubeSamp [[sampler(7)]], sampler depth2dArraySamp [[sampler(8)]], sampler depthCubeArraySamp [[sampler(9)]]) { constant uint& tex1dSwzl = spvSwizzleConstants[0]; constant uint& tex2dSwzl = spvSwizzleConstants[1]; @@ -134,7 +158,7 @@ fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d constant uint& texCubeSwzl = spvSwizzleConstants[3]; constant uint& tex2dArraySwzl = spvSwizzleConstants[4]; constant uint& texCubeArraySwzl = spvSwizzleConstants[5]; - constant uint& depth2dSwzl = spvSwizzleConstants[6]; + constant uint& depth2d0Swzl = spvSwizzleConstants[6]; constant uint& depthCubeSwzl = spvSwizzleConstants[7]; constant uint& depth2dArraySwzl = spvSwizzleConstants[8]; constant uint& depthCubeArraySwzl = spvSwizzleConstants[9]; @@ -144,29 +168,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(rint(float3(0.0).z))), tex2dArraySwzl); c = spvTextureSwizzle(texCubeArray.sample(texCubeArraySamp, float4(0.0).xyz, uint(rint(float4(0.0).w))), texCubeArraySwzl); - 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(rint(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(rint(float4(0.0).w)), 1.0), depthCubeArraySwzl); + c.x = spvTextureSwizzle(spvDepthCast(depth2d0).sample_compare(depth2dSamp, float3(0.0, 0.0, 1.0).xy, 1.0), depth2d0Swzl); + c.x = spvTextureSwizzle(spvDepthCast(depthCube).sample_compare(depthCubeSamp, float4(0.0, 0.0, 0.0, 1.0).xyz, 1.0), depthCubeSwzl); + c.x = spvTextureSwizzle(spvDepthCast(depth2dArray).sample_compare(depth2dArraySamp, float4(0.0, 0.0, 0.0, 1.0).xy, uint(rint(float4(0.0, 0.0, 0.0, 1.0).z)), 1.0), depth2dArraySwzl); + c.x = spvTextureSwizzle(spvDepthCast(depthCubeArray).sample_compare(depthCubeArraySamp, float4(0.0).xyz, uint(rint(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 _108 = float4(0.0, 0.0, 1.0, 1.0); _108.z = 1.0; - c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSamp, _108.xy / _108.z, 1.0 / _108.z), depth2dSwzl); + c.x = spvTextureSwizzle(spvDepthCast(depth2d0).sample_compare(depth2dSamp, _108.xy / _108.z, 1.0 / _108.z), depth2d0Swzl); 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(rint(float3(0.0).z)), level(0.0)), tex2dArraySwzl); c = spvTextureSwizzle(texCubeArray.sample(texCubeArraySamp, float4(0.0).xyz, uint(rint(float4(0.0).w)), level(0.0)), texCubeArraySwzl); - c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSamp, float3(0.0, 0.0, 1.0).xy, 1.0, level(0.0)), depth2dSwzl); + c.x = spvTextureSwizzle(spvDepthCast(depth2d0).sample_compare(depth2dSamp, float3(0.0, 0.0, 1.0).xy, 1.0, level(0.0)), depth2d0Swzl); 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 _161 = float4(0.0, 0.0, 1.0, 1.0); _161.z = 1.0; - c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSamp, _161.xy / _161.z, 1.0 / _161.z, level(0.0)), depth2dSwzl); + c.x = spvTextureSwizzle(spvDepthCast(depth2d0).sample_compare(depth2dSamp, _161.xy / _161.z, 1.0 / _161.z, level(0.0)), depth2d0Swzl); 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); @@ -176,9 +200,9 @@ fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d c = spvGatherSwizzle(texCube, texCubeSamp, texCubeSwzl, component::y, float3(0.0)); c = spvGatherSwizzle(tex2dArray, tex2dArraySamp, tex2dArraySwzl, component::z, float3(0.0).xy, uint(rint(float3(0.0).z)), int2(0)); c = spvGatherSwizzle(texCubeArray, texCubeArraySamp, texCubeArraySwzl, component::w, float4(0.0).xyz, uint(rint(float4(0.0).w))); - c = spvGatherCompareSwizzle(depth2d, depth2dSamp, depth2dSwzl, float2(0.0), 1.0); - c = spvGatherCompareSwizzle(depthCube, depthCubeSamp, depthCubeSwzl, float3(0.0), 1.0); - c = spvGatherCompareSwizzle(depth2dArray, depth2dArraySamp, depth2dArraySwzl, float3(0.0).xy, uint(rint(float3(0.0).z)), 1.0); - c = spvGatherCompareSwizzle(depthCubeArray, depthCubeArraySamp, depthCubeArraySwzl, float4(0.0).xyz, uint(rint(float4(0.0).w)), 1.0); + c = spvGatherCompareSwizzle(spvDepthCast(depth2d0), depth2dSamp, depth2d0Swzl, float2(0.0), 1.0); + c = spvGatherCompareSwizzle(spvDepthCast(depthCube), depthCubeSamp, depthCubeSwzl, float3(0.0), 1.0); + c = spvGatherCompareSwizzle(spvDepthCast(depth2dArray), depth2dArraySamp, depth2dArraySwzl, float3(0.0).xy, uint(rint(float3(0.0).z)), 1.0); + c = spvGatherCompareSwizzle(spvDepthCast(depthCubeArray), depthCubeArraySamp, depthCubeArraySwzl, float4(0.0).xyz, uint(rint(float4(0.0).w)), 1.0); } 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.invalid.vert similarity index 100% rename from third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/pointer-to-pointer.asm.vert rename to third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/pointer-to-pointer.asm.invalid.vert diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/push-constant-row-major-matrix.asm.vk.vert b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/push-constant-row-major-matrix.asm.vk.vert new file mode 100644 index 000000000000..f5d33b7457a7 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/push-constant-row-major-matrix.asm.vk.vert @@ -0,0 +1,27 @@ +#include +#include + +using namespace metal; + +struct type_PushConstant_Matrix +{ + float4x4 transform; +}; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 in_var_POSITION [[attribute(0)]]; +}; + +vertex main0_out main0(main0_in in [[stage_in]], constant type_PushConstant_Matrix& matrix_constants [[buffer(0)]]) +{ + main0_out out = {}; + out.gl_Position = matrix_constants.transform * in.in_var_POSITION; + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/row-major-column-load.asm.vert b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/row-major-column-load.asm.vert new file mode 100644 index 000000000000..f18d57135be5 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/asm/vert/row-major-column-load.asm.vert @@ -0,0 +1,24 @@ +#include +#include + +using namespace metal; + +struct _Block0T +{ + float3x4 World; +}; + +struct main0_out +{ + float3 _Ret_Val [[user(locn0)]]; + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(constant _Block0T& _Block0 [[buffer(0)]]) +{ + main0_out out = {}; + float3 _18 = float3(_Block0.World[0][3], _Block0.World[1][3], _Block0.World[2][3]); + out._Ret_Val = _18; + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/argument-buffer-set-limit.msl2.argument.argument-tier-1.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/argument-buffer-set-limit.msl2.argument.argument-tier-1.comp new file mode 100644 index 000000000000..80106d2e4935 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/argument-buffer-set-limit.msl2.argument.argument-tier-1.comp @@ -0,0 +1,28 @@ +#include +#include + +using namespace metal; + +struct SSBO +{ + float wr; +}; + +struct UBO +{ + float rd; +}; + +struct spvDescriptorSetBuffer15 +{ + device SSBO* m_9 [[id(0)]]; + texture2d Samp [[id(1)]]; + sampler SampSmplr [[id(2)]]; + constant UBO* m_28 [[id(3)]]; +}; + +kernel void main0(constant spvDescriptorSetBuffer15& spvDescriptorSet15 [[buffer(15)]]) +{ + (*spvDescriptorSet15.m_9).wr = spvDescriptorSet15.Samp.sample(spvDescriptorSet15.SampSmplr, float2(0.5), level(0.0)).x + (*spvDescriptorSet15.m_28).rd; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/integer-dot-product.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/integer-dot-product.comp index dda4903f8bd4..8508e46a8575 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/integer-dot-product.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/integer-dot-product.comp @@ -57,9 +57,10 @@ kernel void main0(const device void* spvBufferAliasSet0Binding1 [[buffer(0)]]) uint supdot32 = reduce_add(uint4(as_type(comp2.x)) * uint4(as_type(comp2.y))); int supdoti32 = reduce_add(int4(as_type(comp2.x)) * int4(as_type(comp2.y))); int sdotaddsat_int = int(addsat(reduce_add(int4(short4(comp3.x)) * int4(short4(comp3.y))), comp3.acc)); - uint sdotaddsat_uint = uint(addsat(reduce_add(int4(short4(comp3.x)) * int4(short4(comp3.y))), comp3.acc)); + uint sdotaddsat_uint = uint(addsat(reduce_add(int4(short4(comp3.x)) * int4(short4(comp3.y))), int(uint(comp3.acc)))); uint udotaddsat_uint = uint(addsat(reduce_add(uint4(comp3.x) * uint4(comp3.y)), uint(comp3.acc))); int sudotaddsat_int = int(addsat(reduce_add(int4(short4(comp3.x)) * int4(comp3.y)), comp3.acc)); - uint sudotaddsat_uint = uint(addsat(reduce_add(int4(short4(comp3.x)) * int4(comp3.y)), comp3.acc)); + uint sudotaddsat_uint = uint(addsat(reduce_add(int4(short4(comp3.x)) * int4(comp3.y)), int(uint(comp3.acc)))); + uint udotaddsat_pack = uint(addsat(reduce_add(uint4(as_type(comp2.x)) * uint4(as_type(comp2.y))), uint(comp3.acc))); } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/precise-non-square-matrix.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/precise-non-square-matrix.comp new file mode 100644 index 000000000000..563f75b10c10 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/precise-non-square-matrix.comp @@ -0,0 +1,74 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +template +[[clang::optnone]] T spvFMul(T l, T r) +{ + return fma(l, r, T(0)); +} + +template +[[clang::optnone]] 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 +[[clang::optnone]] 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 +[[clang::optnone]] matrix spvFMulMatrixMatrix(matrix l, matrix r) +{ + static_assert(LCols == RRows, "column-row configuration mismatch"); + 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; +} + +struct SSBO +{ + float3x4 A; + float4x3 B; + float3x3 C; + float4x4 D; +}; + +kernel void main0(const device SSBO& _17 [[buffer(0)]]) +{ + float4x4 tmp0 = spvFMulMatrixMatrix(_17.A, _17.B); + float3x3 tmp1 = spvFMulMatrixMatrix(_17.B, _17.A); + float3x4 tmp2 = spvFMulMatrixMatrix(_17.A, _17.C); + float3x4 tmp3 = spvFMulMatrixMatrix(_17.D, _17.A); + float4x3 tmp4 = spvFMulMatrixMatrix(_17.B, _17.D); +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/struct-packing-scalar.nocompat.invalid.vk.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/struct-packing-scalar.nocompat.invalid.vk.comp index a0bb9c10fd49..0e22b9f11ba3 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/struct-packing-scalar.nocompat.invalid.vk.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/struct-packing-scalar.nocompat.invalid.vk.comp @@ -1,3 +1,5 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include @@ -7,6 +9,9 @@ typedef packed_float3 packed_float2x3[2]; typedef packed_float3 packed_rm_float3x2[2]; typedef packed_float2 packed_float2x2[2]; +template +struct spvPaddedArrayElement { T data; char padding[stride - sizeof(T)]; }; + struct S0 { packed_float2 a[1]; @@ -64,7 +69,6 @@ struct S0_1 float2 a[1]; char _m1_pad[8]; float b; - char _m0_final_padding[12]; }; struct S1_1 @@ -77,7 +81,6 @@ struct S2_1 { float3 a[1]; float b; - char _m0_final_padding[12]; }; struct S3_1 @@ -88,15 +91,15 @@ struct S3_1 struct Content_1 { - S0_1 m0s[1]; + spvPaddedArrayElement m0s[1]; S1_1 m1s[1]; S2_1 m2s[1]; S0_1 m0; + char _m4_pad[8]; S1_1 m1; S2_1 m2; S3_1 m3; float m4; - char _m0_final_padding[12]; }; struct SSBO0 @@ -126,8 +129,8 @@ constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); kernel void main0(device SSBO1& __restrict ssbo_scalar [[buffer(0)]], device SSBO0& __restrict ssbo_140 [[buffer(1)]], device SSBO2& __restrict ssbo_scalar2 [[buffer(2)]]) { - ssbo_scalar.content.m0s[0].a[0] = ssbo_140.content.m0s[0].a[0]; - ssbo_scalar.content.m0s[0].b = ssbo_140.content.m0s[0].b; + ssbo_scalar.content.m0s[0].a[0] = ssbo_140.content.m0s[0].data.a[0]; + ssbo_scalar.content.m0s[0].b = ssbo_140.content.m0s[0].data.b; ssbo_scalar.content.m1s[0].a = float3(ssbo_140.content.m1s[0].a); ssbo_scalar.content.m1s[0].b = ssbo_140.content.m1s[0].b; ssbo_scalar.content.m2s[0].a[0] = ssbo_140.content.m2s[0].a[0]; diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/subgroups.nocompat.vk.msl32.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/subgroups.nocompat.vk.msl32.comp new file mode 100644 index 000000000000..21555ab32f21 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/comp/subgroups.nocompat.vk.msl32.comp @@ -0,0 +1,916 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +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(as_type((simd_vote::vote_t)vote), 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 ulong spvSubgroupShuffle(ulong value, ushort lane) +{ + return as_type(spvSubgroupShuffle(as_type(value), lane)); +} + +template<> +inline ulong2 spvSubgroupShuffle(ulong2 value, ushort lane) +{ + return ulong2(spvSubgroupShuffle(value.x, lane), spvSubgroupShuffle(value.y, lane)); +} + +inline ulong3 spvSubgroupShuffle(ulong3 value, ushort lane) +{ + return ulong3(spvSubgroupShuffle(value.xy, lane), spvSubgroupShuffle(value.z, lane)); +} + +inline ulong4 spvSubgroupShuffle(ulong4 value, ushort lane) +{ + return ulong4(spvSubgroupShuffle(value.xy, lane), spvSubgroupShuffle(value.zw, lane)); +} + +template +inline vec spvSubgroupShuffle(vec value, ushort lane) +{ + return vec(spvSubgroupShuffle(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 spvSubgroupRotate(T value, ushort delta) +{ + return simd_shuffle_rotate_down(value, delta); +} + +template<> +inline bool spvSubgroupRotate(bool value, ushort delta) +{ + return !!simd_shuffle_rotate_down((ushort)value, delta); +} + +template +inline vec spvSubgroupRotate(vec value, ushort delta) +{ + return (vec)simd_shuffle_rotate_down((vec)value, delta); +} + +template +struct spvClusteredAddDetail; + +// Base cases +template<> +struct spvClusteredAddDetail<1, 0> +{ + template + static T op(T value, uint) + { + return value; + } +}; + +template +struct spvClusteredAddDetail<1, offset> +{ + template + static T op(T value, uint lid) + { + // If the target lane is inactive, then return identity. + if (!extract_bits(as_type((simd_vote::vote_t)simd_active_threads_mask())[(lid ^ offset) / 32], (lid ^ offset) % 32, 1)) + return 0; + return simd_shuffle_xor(value, offset); + } +}; + +template<> +struct spvClusteredAddDetail<4, 0> +{ + template + static T op(T value, uint) + { + return quad_sum(value); + } +}; + +template +struct spvClusteredAddDetail<4, offset> +{ + template + static T op(T value, uint lid) + { + // Here, we care if any of the lanes in the quad are active. + uint quad_mask = extract_bits(as_type((simd_vote::vote_t)simd_active_threads_mask())[(lid ^ offset) / 32], ((lid ^ offset) % 32) & ~3, 4); + if (!quad_mask) + return 0; + // But we need to make sure we shuffle from an active lane. + return simd_shuffle(quad_sum(value), ((lid ^ offset) & ~3) | ctz(quad_mask)); + } +}; + +// General case +template +struct spvClusteredAddDetail +{ + template + static T op(T value, uint lid) + { + return spvClusteredAddDetail::op(value, lid) + spvClusteredAddDetail::op(value, lid); + } +}; + +template +T spvClustered_sum(T value, uint lid) +{ + return spvClusteredAddDetail::op(value, lid); +} + +template +struct spvClusteredMulDetail; + +// Base cases +template<> +struct spvClusteredMulDetail<1, 0> +{ + template + static T op(T value, uint) + { + return value; + } +}; + +template +struct spvClusteredMulDetail<1, offset> +{ + template + static T op(T value, uint lid) + { + // If the target lane is inactive, then return identity. + if (!extract_bits(as_type((simd_vote::vote_t)simd_active_threads_mask())[(lid ^ offset) / 32], (lid ^ offset) % 32, 1)) + return 1; + return simd_shuffle_xor(value, offset); + } +}; + +template<> +struct spvClusteredMulDetail<4, 0> +{ + template + static T op(T value, uint) + { + return quad_product(value); + } +}; + +template +struct spvClusteredMulDetail<4, offset> +{ + template + static T op(T value, uint lid) + { + // Here, we care if any of the lanes in the quad are active. + uint quad_mask = extract_bits(as_type((simd_vote::vote_t)simd_active_threads_mask())[(lid ^ offset) / 32], ((lid ^ offset) % 32) & ~3, 4); + if (!quad_mask) + return 1; + // But we need to make sure we shuffle from an active lane. + return simd_shuffle(quad_product(value), ((lid ^ offset) & ~3) | ctz(quad_mask)); + } +}; + +// General case +template +struct spvClusteredMulDetail +{ + template + static T op(T value, uint lid) + { + return spvClusteredMulDetail::op(value, lid) * spvClusteredMulDetail::op(value, lid); + } +}; + +template +T spvClustered_product(T value, uint lid) +{ + return spvClusteredMulDetail::op(value, lid); +} + +template +struct spvClusteredMinDetail; + +// Base cases +template<> +struct spvClusteredMinDetail<1, 0> +{ + template + static T op(T value, uint) + { + return value; + } +}; + +template +struct spvClusteredMinDetail<1, offset> +{ + template + static T op(T value, uint lid) + { + // If the target lane is inactive, then return identity. + if (!extract_bits(as_type((simd_vote::vote_t)simd_active_threads_mask())[(lid ^ offset) / 32], (lid ^ offset) % 32, 1)) + return numeric_limits::max(); + return simd_shuffle_xor(value, offset); + } +}; + +template<> +struct spvClusteredMinDetail<4, 0> +{ + template + static T op(T value, uint) + { + return quad_min(value); + } +}; + +template +struct spvClusteredMinDetail<4, offset> +{ + template + static T op(T value, uint lid) + { + // Here, we care if any of the lanes in the quad are active. + uint quad_mask = extract_bits(as_type((simd_vote::vote_t)simd_active_threads_mask())[(lid ^ offset) / 32], ((lid ^ offset) % 32) & ~3, 4); + if (!quad_mask) + return numeric_limits::max(); + // But we need to make sure we shuffle from an active lane. + return simd_shuffle(quad_min(value), ((lid ^ offset) & ~3) | ctz(quad_mask)); + } +}; + +// General case +template +struct spvClusteredMinDetail +{ + template + static T op(T value, uint lid) + { + return min(spvClusteredMinDetail::op(value, lid), spvClusteredMinDetail::op(value, lid)); + } +}; + +template +T spvClustered_min(T value, uint lid) +{ + return spvClusteredMinDetail::op(value, lid); +} + +template +struct spvClusteredMaxDetail; + +// Base cases +template<> +struct spvClusteredMaxDetail<1, 0> +{ + template + static T op(T value, uint) + { + return value; + } +}; + +template +struct spvClusteredMaxDetail<1, offset> +{ + template + static T op(T value, uint lid) + { + // If the target lane is inactive, then return identity. + if (!extract_bits(as_type((simd_vote::vote_t)simd_active_threads_mask())[(lid ^ offset) / 32], (lid ^ offset) % 32, 1)) + return numeric_limits::min(); + return simd_shuffle_xor(value, offset); + } +}; + +template<> +struct spvClusteredMaxDetail<4, 0> +{ + template + static T op(T value, uint) + { + return quad_max(value); + } +}; + +template +struct spvClusteredMaxDetail<4, offset> +{ + template + static T op(T value, uint lid) + { + // Here, we care if any of the lanes in the quad are active. + uint quad_mask = extract_bits(as_type((simd_vote::vote_t)simd_active_threads_mask())[(lid ^ offset) / 32], ((lid ^ offset) % 32) & ~3, 4); + if (!quad_mask) + return numeric_limits::min(); + // But we need to make sure we shuffle from an active lane. + return simd_shuffle(quad_max(value), ((lid ^ offset) & ~3) | ctz(quad_mask)); + } +}; + +// General case +template +struct spvClusteredMaxDetail +{ + template + static T op(T value, uint lid) + { + return max(spvClusteredMaxDetail::op(value, lid), spvClusteredMaxDetail::op(value, lid)); + } +}; + +template +T spvClustered_max(T value, uint lid) +{ + return spvClusteredMaxDetail::op(value, lid); +} + +template +struct spvClusteredAndDetail; + +// Base cases +template<> +struct spvClusteredAndDetail<1, 0> +{ + template + static T op(T value, uint) + { + return value; + } +}; + +template +struct spvClusteredAndDetail<1, offset> +{ + template + static T op(T value, uint lid) + { + // If the target lane is inactive, then return identity. + if (!extract_bits(as_type((simd_vote::vote_t)simd_active_threads_mask())[(lid ^ offset) / 32], (lid ^ offset) % 32, 1)) + return ~T(0); + return simd_shuffle_xor(value, offset); + } +}; + +template<> +struct spvClusteredAndDetail<4, 0> +{ + template + static T op(T value, uint) + { + return quad_and(value); + } +}; + +template +struct spvClusteredAndDetail<4, offset> +{ + template + static T op(T value, uint lid) + { + // Here, we care if any of the lanes in the quad are active. + uint quad_mask = extract_bits(as_type((simd_vote::vote_t)simd_active_threads_mask())[(lid ^ offset) / 32], ((lid ^ offset) % 32) & ~3, 4); + if (!quad_mask) + return ~T(0); + // But we need to make sure we shuffle from an active lane. + return simd_shuffle(quad_and(value), ((lid ^ offset) & ~3) | ctz(quad_mask)); + } +}; + +// General case +template +struct spvClusteredAndDetail +{ + template + static T op(T value, uint lid) + { + return spvClusteredAndDetail::op(value, lid) & spvClusteredAndDetail::op(value, lid); + } +}; + +template +T spvClustered_and(T value, uint lid) +{ + return spvClusteredAndDetail::op(value, lid); +} + +template +struct spvClusteredOrDetail; + +// Base cases +template<> +struct spvClusteredOrDetail<1, 0> +{ + template + static T op(T value, uint) + { + return value; + } +}; + +template +struct spvClusteredOrDetail<1, offset> +{ + template + static T op(T value, uint lid) + { + // If the target lane is inactive, then return identity. + if (!extract_bits(as_type((simd_vote::vote_t)simd_active_threads_mask())[(lid ^ offset) / 32], (lid ^ offset) % 32, 1)) + return 0; + return simd_shuffle_xor(value, offset); + } +}; + +template<> +struct spvClusteredOrDetail<4, 0> +{ + template + static T op(T value, uint) + { + return quad_or(value); + } +}; + +template +struct spvClusteredOrDetail<4, offset> +{ + template + static T op(T value, uint lid) + { + // Here, we care if any of the lanes in the quad are active. + uint quad_mask = extract_bits(as_type((simd_vote::vote_t)simd_active_threads_mask())[(lid ^ offset) / 32], ((lid ^ offset) % 32) & ~3, 4); + if (!quad_mask) + return 0; + // But we need to make sure we shuffle from an active lane. + return simd_shuffle(quad_or(value), ((lid ^ offset) & ~3) | ctz(quad_mask)); + } +}; + +// General case +template +struct spvClusteredOrDetail +{ + template + static T op(T value, uint lid) + { + return spvClusteredOrDetail::op(value, lid) | spvClusteredOrDetail::op(value, lid); + } +}; + +template +T spvClustered_or(T value, uint lid) +{ + return spvClusteredOrDetail::op(value, lid); +} + +template +struct spvClusteredXorDetail; + +// Base cases +template<> +struct spvClusteredXorDetail<1, 0> +{ + template + static T op(T value, uint) + { + return value; + } +}; + +template +struct spvClusteredXorDetail<1, offset> +{ + template + static T op(T value, uint lid) + { + // If the target lane is inactive, then return identity. + if (!extract_bits(as_type((simd_vote::vote_t)simd_active_threads_mask())[(lid ^ offset) / 32], (lid ^ offset) % 32, 1)) + return 0; + return simd_shuffle_xor(value, offset); + } +}; + +template<> +struct spvClusteredXorDetail<4, 0> +{ + template + static T op(T value, uint) + { + return quad_xor(value); + } +}; + +template +struct spvClusteredXorDetail<4, offset> +{ + template + static T op(T value, uint lid) + { + // Here, we care if any of the lanes in the quad are active. + uint quad_mask = extract_bits(as_type((simd_vote::vote_t)simd_active_threads_mask())[(lid ^ offset) / 32], ((lid ^ offset) % 32) & ~3, 4); + if (!quad_mask) + return 0; + // But we need to make sure we shuffle from an active lane. + return simd_shuffle(quad_xor(value), ((lid ^ offset) & ~3) | ctz(quad_mask)); + } +}; + +// General case +template +struct spvClusteredXorDetail +{ + template + static T op(T value, uint lid) + { + return spvClusteredXorDetail::op(value, lid) ^ spvClusteredXorDetail::op(value, lid); + } +}; + +template +T spvClustered_xor(T value, uint lid) +{ + return spvClusteredXorDetail::op(value, lid); +} + +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); +} + +struct SSBO +{ + float FragColor; +}; + +constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); + +static inline __attribute__((always_inline)) +void doClusteredRotate(thread uint& gl_SubgroupInvocationID) +{ + uint _15 = spvSubgroupShuffle(20u, ((gl_SubgroupInvocationID + 4u) & 7) + (gl_SubgroupInvocationID & 4294967288)); + uint rotated_clustered = _15; + bool _20 = spvSubgroupShuffle(false, ((gl_SubgroupInvocationID + 4u) & 7) + (gl_SubgroupInvocationID & 4294967288)); + bool rotated_clustered_bool = _20; +} + +kernel void main0(device SSBO& _24 [[buffer(0)]], uint gl_NumSubgroups [[simdgroups_per_threadgroup]], uint gl_SubgroupID [[simdgroup_index_in_threadgroup]], uint gl_SubgroupSize [[threads_per_simdgroup]], uint gl_SubgroupInvocationID [[thread_index_in_simdgroup]]) +{ + 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)); + 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)); + _24.FragColor = float(gl_NumSubgroups); + _24.FragColor = float(gl_SubgroupID); + _24.FragColor = float(gl_SubgroupSize); + _24.FragColor = float(gl_SubgroupInvocationID); + simdgroup_barrier(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture); + atomic_thread_fence(mem_flags::mem_device | mem_flags::mem_threadgroup | mem_flags::mem_texture, memory_order_seq_cst, thread_scope_simdgroup); + atomic_thread_fence(mem_flags::mem_device, memory_order_seq_cst, thread_scope_simdgroup); + atomic_thread_fence(mem_flags::mem_threadgroup, memory_order_seq_cst, thread_scope_simdgroup); + atomic_thread_fence(mem_flags::mem_texture, memory_order_seq_cst, thread_scope_simdgroup); + bool _50 = simd_is_first(); + bool elected = _50; + _24.FragColor = float4(gl_SubgroupEqMask).x; + _24.FragColor = float4(gl_SubgroupGeMask).x; + _24.FragColor = float4(gl_SubgroupGtMask).x; + _24.FragColor = float4(gl_SubgroupLeMask).x; + _24.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); + uint rotated = spvSubgroupRotate(20u, 4u); + bool rotated_bool = spvSubgroupRotate(false, 4u); + doClusteredRotate(gl_SubgroupInvocationID); + 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); + bool4 anded_b = bool4(simd_and(ushort4(ballot_value == uint4(42u)))); + bool4 ored_b = bool4(simd_or(ushort4(ballot_value == uint4(42u)))); + bool4 xored_b = bool4(simd_xor(ushort4(ballot_value == uint4(42u)))); + 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 = spvClustered_sum<1>(added, gl_SubgroupInvocationID); + multiplied = spvClustered_product<1>(multiplied, gl_SubgroupInvocationID); + iadded = spvClustered_sum<1>(iadded, gl_SubgroupInvocationID); + imultiplied = spvClustered_product<1>(imultiplied, gl_SubgroupInvocationID); + lo = spvClustered_min<1>(lo, gl_SubgroupInvocationID); + hi = spvClustered_max<1>(hi, gl_SubgroupInvocationID); + ulo = spvClustered_min<1>(ulo, gl_SubgroupInvocationID); + uhi = spvClustered_max<1>(uhi, gl_SubgroupInvocationID); + slo = spvClustered_min<1>(slo, gl_SubgroupInvocationID); + shi = spvClustered_max<1>(shi, gl_SubgroupInvocationID); + anded = spvClustered_and<1>(anded, gl_SubgroupInvocationID); + ored = spvClustered_or<1>(ored, gl_SubgroupInvocationID); + xored = spvClustered_xor<1>(xored, gl_SubgroupInvocationID); + anded_b = bool4(spvClustered_and<1>(ushort4(anded == uint4(2u)), gl_SubgroupInvocationID)); + ored_b = bool4(spvClustered_or<1>(ushort4(ored == uint4(3u)), gl_SubgroupInvocationID)); + xored_b = bool4(spvClustered_xor<1>(ushort4(xored == uint4(4u)), gl_SubgroupInvocationID)); + added = spvClustered_sum<2>(added, gl_SubgroupInvocationID); + multiplied = spvClustered_product<2>(multiplied, gl_SubgroupInvocationID); + iadded = spvClustered_sum<2>(iadded, gl_SubgroupInvocationID); + imultiplied = spvClustered_product<2>(imultiplied, gl_SubgroupInvocationID); + lo = spvClustered_min<2>(lo, gl_SubgroupInvocationID); + hi = spvClustered_max<2>(hi, gl_SubgroupInvocationID); + ulo = spvClustered_min<2>(ulo, gl_SubgroupInvocationID); + uhi = spvClustered_max<2>(uhi, gl_SubgroupInvocationID); + slo = spvClustered_min<2>(slo, gl_SubgroupInvocationID); + shi = spvClustered_max<2>(shi, gl_SubgroupInvocationID); + anded = spvClustered_and<2>(anded, gl_SubgroupInvocationID); + ored = spvClustered_or<2>(ored, gl_SubgroupInvocationID); + xored = spvClustered_xor<2>(xored, gl_SubgroupInvocationID); + anded_b = bool4(spvClustered_and<2>(ushort4(anded == uint4(2u)), gl_SubgroupInvocationID)); + ored_b = bool4(spvClustered_or<2>(ushort4(ored == uint4(3u)), gl_SubgroupInvocationID)); + xored_b = bool4(spvClustered_xor<2>(ushort4(xored == uint4(4u)), gl_SubgroupInvocationID)); + added = spvClustered_sum<4>(added, gl_SubgroupInvocationID); + multiplied = spvClustered_product<4>(multiplied, gl_SubgroupInvocationID); + iadded = spvClustered_sum<4>(iadded, gl_SubgroupInvocationID); + imultiplied = spvClustered_product<4>(imultiplied, gl_SubgroupInvocationID); + lo = spvClustered_min<4>(lo, gl_SubgroupInvocationID); + hi = spvClustered_max<4>(hi, gl_SubgroupInvocationID); + ulo = spvClustered_min<4>(ulo, gl_SubgroupInvocationID); + uhi = spvClustered_max<4>(uhi, gl_SubgroupInvocationID); + slo = spvClustered_min<4>(slo, gl_SubgroupInvocationID); + shi = spvClustered_max<4>(shi, gl_SubgroupInvocationID); + anded = spvClustered_and<4>(anded, gl_SubgroupInvocationID); + ored = spvClustered_or<4>(ored, gl_SubgroupInvocationID); + xored = spvClustered_xor<4>(xored, gl_SubgroupInvocationID); + anded_b = bool4(spvClustered_and<4>(ushort4(anded == uint4(2u)), gl_SubgroupInvocationID)); + ored_b = bool4(spvClustered_or<4>(ushort4(ored == uint4(3u)), gl_SubgroupInvocationID)); + xored_b = bool4(spvClustered_xor<4>(ushort4(xored == uint4(4u)), gl_SubgroupInvocationID)); + added = spvClustered_sum<16>(added, gl_SubgroupInvocationID); + multiplied = spvClustered_product<16>(multiplied, gl_SubgroupInvocationID); + iadded = spvClustered_sum<16>(iadded, gl_SubgroupInvocationID); + imultiplied = spvClustered_product<16>(imultiplied, gl_SubgroupInvocationID); + lo = spvClustered_min<16>(lo, gl_SubgroupInvocationID); + hi = spvClustered_max<16>(hi, gl_SubgroupInvocationID); + ulo = spvClustered_min<16>(ulo, gl_SubgroupInvocationID); + uhi = spvClustered_max<16>(uhi, gl_SubgroupInvocationID); + slo = spvClustered_min<16>(slo, gl_SubgroupInvocationID); + shi = spvClustered_max<16>(shi, gl_SubgroupInvocationID); + anded = spvClustered_and<16>(anded, gl_SubgroupInvocationID); + ored = spvClustered_or<16>(ored, gl_SubgroupInvocationID); + xored = spvClustered_xor<16>(xored, gl_SubgroupInvocationID); + anded_b = bool4(spvClustered_and<16>(ushort4(anded == uint4(2u)), gl_SubgroupInvocationID)); + ored_b = bool4(spvClustered_or<16>(ushort4(ored == uint4(3u)), gl_SubgroupInvocationID)); + xored_b = bool4(spvClustered_xor<16>(ushort4(xored == uint4(4u)), gl_SubgroupInvocationID)); + 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/frag/depth-clip-enable-early-fragment-tests.emulate-depth-clip-enable.msl2.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/depth-clip-enable-early-fragment-tests.emulate-depth-clip-enable.msl2.frag new file mode 100644 index 000000000000..c1f957f02ce5 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/depth-clip-enable-early-fragment-tests.emulate-depth-clip-enable.msl2.frag @@ -0,0 +1,19 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 color [[color(0)]]; +}; + +[[ early_fragment_tests ]] fragment main0_out main0() +{ + float gl_FragDepth; + main0_out out = {}; + out.color = float4(1.0); + gl_FragDepth = 1.25; + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/depth-clip-enable-fallback.emulate-depth-clip-enable.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/depth-clip-enable-fallback.emulate-depth-clip-enable.frag new file mode 100644 index 000000000000..f84733467cb0 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/depth-clip-enable-fallback.emulate-depth-clip-enable.frag @@ -0,0 +1,31 @@ +#include +#include + +using namespace metal; + +struct spvDepthClipState +{ + uint emulateViewportZ; + uint emulateDepthClamp; + float2 viewportDepthRanges[16]; +}; + +struct main0_out +{ + float4 color [[color(0)]]; + float gl_FragDepth [[depth(any)]]; +}; + +fragment main0_out main0(constant spvDepthClipState& spvDepthClipState [[buffer(17)]]) +{ + main0_out out = {}; + out.color = float4(1.0); + out.gl_FragDepth = 1.25; + if (spvDepthClipState.emulateDepthClamp != 0u) + { + float2 spvViewportDepthRange = spvDepthClipState.viewportDepthRanges[0]; + out.gl_FragDepth = clamp(out.gl_FragDepth, spvViewportDepthRange.x, spvViewportDepthRange.y); + } + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/depth-clip-enable-no-depth-write.emulate-depth-clip-enable.msl2.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/depth-clip-enable-no-depth-write.emulate-depth-clip-enable.msl2.frag new file mode 100644 index 000000000000..c5d303d9e5a8 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/depth-clip-enable-no-depth-write.emulate-depth-clip-enable.msl2.frag @@ -0,0 +1,17 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 color [[color(0)]]; +}; + +fragment main0_out main0() +{ + main0_out out = {}; + out.color = float4(1.0); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/depth-clip-enable-viewport-index.emulate-depth-clip-enable.msl2.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/depth-clip-enable-viewport-index.emulate-depth-clip-enable.msl2.frag new file mode 100644 index 000000000000..c8343d6c6b92 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/depth-clip-enable-viewport-index.emulate-depth-clip-enable.msl2.frag @@ -0,0 +1,31 @@ +#include +#include + +using namespace metal; + +struct spvDepthClipState +{ + uint emulateViewportZ; + uint emulateDepthClamp; + float2 viewportDepthRanges[16]; +}; + +struct main0_out +{ + float4 color [[color(0)]]; + float gl_FragDepth [[depth(any)]]; +}; + +fragment main0_out main0(uint gl_ViewportIndex [[viewport_array_index]], constant spvDepthClipState& spvDepthClipState [[buffer(17)]]) +{ + main0_out out = {}; + out.color = float4(float(int(gl_ViewportIndex))); + out.gl_FragDepth = 1.25; + if (spvDepthClipState.emulateDepthClamp != 0u) + { + float2 spvViewportDepthRange = spvDepthClipState.viewportDepthRanges[gl_ViewportIndex]; + out.gl_FragDepth = clamp(out.gl_FragDepth, spvViewportDepthRange.x, spvViewportDepthRange.y); + } + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/depth-clip-enable.emulate-depth-clip-enable.msl2.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/depth-clip-enable.emulate-depth-clip-enable.msl2.frag new file mode 100644 index 000000000000..218514d7dafe --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/depth-clip-enable.emulate-depth-clip-enable.msl2.frag @@ -0,0 +1,31 @@ +#include +#include + +using namespace metal; + +struct spvDepthClipState +{ + uint emulateViewportZ; + uint emulateDepthClamp; + float2 viewportDepthRanges[16]; +}; + +struct main0_out +{ + float4 color [[color(0)]]; + float gl_FragDepth [[depth(any)]]; +}; + +fragment main0_out main0(uint spvDepthClipViewportIndex [[viewport_array_index]], constant spvDepthClipState& spvDepthClipState [[buffer(17)]]) +{ + main0_out out = {}; + out.color = float4(1.0); + out.gl_FragDepth = 1.25; + if (spvDepthClipState.emulateDepthClamp != 0u) + { + float2 spvViewportDepthRange = spvDepthClipState.viewportDepthRanges[spvDepthClipViewportIndex]; + out.gl_FragDepth = clamp(out.gl_FragDepth, spvViewportDepthRange.x, spvViewportDepthRange.y); + } + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/depth-image-gather.asm.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/depth-image-gather.asm.frag index 025e22585615..afc5e3528228 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/depth-image-gather.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/depth-image-gather.asm.frag @@ -1,8 +1,34 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float4 out_var_SV_Target0 [[color(0)]]; @@ -13,10 +39,10 @@ struct main0_in float2 in_var_TEXCOORD0 [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d g_depthTexture [[texture(0)]], sampler g_sampler [[sampler(0)]], sampler g_comp [[sampler(1)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d g_depthTexture [[texture(0)]], sampler g_sampler [[sampler(0)]], sampler g_comp [[sampler(1)]]) { main0_out out = {}; - out.out_var_SV_Target0 = g_depthTexture.gather_compare(g_comp, in.in_var_TEXCOORD0, 0.5) * g_depthTexture.gather(g_sampler, in.in_var_TEXCOORD0, int2(0)); + out.out_var_SV_Target0 = spvDepthCast(g_depthTexture).gather_compare(g_comp, in.in_var_TEXCOORD0, 0.5) * g_depthTexture.gather(g_sampler, in.in_var_TEXCOORD0, int2(0), component::x); return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/fp16.desktop.invalid.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/fp16.desktop.invalid.frag index 258d7a6f0c8a..f152813e08e0 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/fp16.desktop.invalid.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/fp16.desktop.invalid.frag @@ -124,10 +124,10 @@ void test_builtins(thread half4& v4, thread half3& v3, thread half& v1) res = ceil(v4); res = fract(v4); res = mod(v4, v4); - ResType _224; - _224._m0 = modf(v4, _224._m1); - half4 tmp = _224._m1; - res = _224._m0; + ResType _222; + _222._m0 = modf(v4, _222._m1); + half4 tmp = _222._m1; + res = _222._m0; res = min(v4, v4); res = max(v4, v4); res = clamp(v4, v4, v4); @@ -138,10 +138,10 @@ void test_builtins(thread half4& v4, thread half3& v3, thread half& v1) bool4 btmp = isnan(v4); btmp = isinf(v4); res = fma(v4, v4, v4); - ResType_1 _270; - _270._m0 = frexp(v4, _270._m1); - int4 itmp = _270._m1; - res = _270._m0; + ResType_1 _268; + _268._m0 = frexp(v4, _268._m1); + int4 itmp = _268._m1; + res = _268._m0; res = ldexp(res, itmp); uint pack0 = as_type(v4.xy); uint pack1 = as_type(v4.zw); diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/image-gather.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/image-gather.frag index db793c14eea3..f5511d6afc7b 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/image-gather.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/image-gather.frag @@ -1,8 +1,34 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float4 FragColor [[color(0)]]; @@ -13,12 +39,12 @@ struct main0_in float3 vUV [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], texture2d uSamp [[texture(0)]], depth2d uSampShadow [[texture(1)]], sampler uSampSmplr [[sampler(0)]], sampler uSampShadowSmplr [[sampler(1)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d uSamp [[texture(0)]], texture2d uSampShadow [[texture(1)]], sampler uSampSmplr [[sampler(0)]], sampler uSampShadowSmplr [[sampler(1)]]) { main0_out out = {}; out.FragColor = uSamp.gather(uSampSmplr, in.vUV.xy, int2(0), component::x); out.FragColor += uSamp.gather(uSampSmplr, in.vUV.xy, int2(0), component::y); - out.FragColor += uSampShadow.gather_compare(uSampShadowSmplr, in.vUV.xy, in.vUV.z); + out.FragColor += spvDepthCast(uSampShadow).gather_compare(uSampShadowSmplr, in.vUV.xy, in.vUV.z); return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/shadow-compare-global-alias.invalid.frag b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/shadow-compare-global-alias.invalid.frag index 58985c635414..07ad00c4ecf2 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/shadow-compare-global-alias.invalid.frag +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/frag/shadow-compare-global-alias.invalid.frag @@ -5,6 +5,30 @@ using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float FragColor [[color(0)]]; @@ -16,34 +40,34 @@ struct main0_in }; static inline __attribute__((always_inline)) -float Samp(thread const float3& uv, depth2d uTex, sampler uSamp) +float Samp(thread const float3& uv, texture2d uTex, sampler uSamp) { - return uTex.sample_compare(uSamp, uv.xy, uv.z); + return spvDepthCast(uTex).sample_compare(uSamp, uv.xy, uv.z); } static inline __attribute__((always_inline)) -float Samp2(thread const float3& uv, depth2d uSampler, sampler uSamplerSmplr, thread float3& vUV) +float Samp2(thread const float3& uv, texture2d uSampler, sampler uSamplerSmplr, thread float3& vUV) { - return uSampler.sample_compare(uSamplerSmplr, vUV.xy, vUV.z); + return spvDepthCast(uSampler).sample_compare(uSamplerSmplr, vUV.xy, vUV.z); } static inline __attribute__((always_inline)) -float Samp3(depth2d uT, sampler uS, thread const float3& uv, thread float3& vUV) +float Samp3(texture2d uT, sampler uS, thread const float3& uv, thread float3& vUV) { - return uT.sample_compare(uS, vUV.xy, vUV.z); + return spvDepthCast(uT).sample_compare(uS, vUV.xy, vUV.z); } static inline __attribute__((always_inline)) -float Samp4(depth2d uS, sampler uSSmplr, thread const float3& uv, thread float3& vUV) +float Samp4(texture2d uS, sampler uSSmplr, thread const float3& uv, thread float3& vUV) { - return uS.sample_compare(uSSmplr, vUV.xy, vUV.z); + return spvDepthCast(uS).sample_compare(uSSmplr, vUV.xy, vUV.z); } -fragment main0_out main0(main0_in in [[stage_in]], depth2d uTex [[texture(0)]], depth2d uSampler [[texture(1)]], sampler uSamp [[sampler(0)]], sampler uSamplerSmplr [[sampler(1)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d uTex [[texture(0)]], texture2d uSampler [[texture(1)]], sampler uSamp [[sampler(0)]], sampler uSamplerSmplr [[sampler(1)]]) { main0_out out = {}; - out.FragColor = uSampler.sample_compare(uSamplerSmplr, in.vUV.xy, in.vUV.z); - out.FragColor += uTex.sample_compare(uSamp, in.vUV.xy, in.vUV.z); + out.FragColor = spvDepthCast(uSampler).sample_compare(uSamplerSmplr, in.vUV.xy, in.vUV.z); + out.FragColor += spvDepthCast(uTex).sample_compare(uSamp, in.vUV.xy, in.vUV.z); float3 param = in.vUV; out.FragColor += Samp(param, uTex, uSamp); float3 param_1 = in.vUV; 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 370ef8d7b6fa..8c435f599df5 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 @@ -126,8 +126,32 @@ inline spvGatherCompareReturn spvGatherCompareSwizzle(const thread T return t.gather_compare(s, params...); } +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + static inline __attribute__((always_inline)) -float4 doSwizzle(texture1d tex1d, sampler tex1dSmplr, constant uint& tex1dSwzl, texture2d tex2d, sampler tex2dSmplr, constant uint& tex2dSwzl, texture3d tex3d, sampler tex3dSmplr, constant uint& tex3dSwzl, texturecube texCube, sampler texCubeSmplr, constant uint& texCubeSwzl, texture2d_array tex2dArray, sampler tex2dArraySmplr, constant uint& tex2dArraySwzl, texturecube_array texCubeArray, sampler texCubeArraySmplr, constant uint& texCubeArraySwzl, depth2d depth2d, sampler depth2dSmplr, constant uint& depth2dSwzl, depthcube depthCube, sampler depthCubeSmplr, constant uint& depthCubeSwzl, depth2d_array depth2dArray, sampler depth2dArraySmplr, constant uint& depth2dArraySwzl, depthcube_array depthCubeArray, sampler depthCubeArraySmplr, constant uint& depthCubeArraySwzl, texture2d texBuffer) +float4 doSwizzle(texture1d tex1d, sampler tex1dSmplr, constant uint& tex1dSwzl, texture2d tex2d, sampler tex2dSmplr, constant uint& tex2dSwzl, texture3d tex3d, sampler tex3dSmplr, constant uint& tex3dSwzl, texturecube texCube, sampler texCubeSmplr, constant uint& texCubeSwzl, texture2d_array tex2dArray, sampler tex2dArraySmplr, constant uint& tex2dArraySwzl, texturecube_array texCubeArray, sampler texCubeArraySmplr, constant uint& texCubeArraySwzl, texture2d depth2d0, sampler depth2d0Smplr, constant uint& depth2d0Swzl, texturecube depthCube, sampler depthCubeSmplr, constant uint& depthCubeSwzl, texture2d_array depth2dArray, sampler depth2dArraySmplr, constant uint& depth2dArraySwzl, texturecube_array depthCubeArray, sampler depthCubeArraySmplr, constant uint& depthCubeArraySwzl, texture2d texBuffer) { float4 c = spvTextureSwizzle(tex1d.sample(tex1dSmplr, 0.0), tex1dSwzl); c = spvTextureSwizzle(tex2d.sample(tex2dSmplr, float2(0.0)), tex2dSwzl); @@ -135,29 +159,29 @@ float4 doSwizzle(texture1d tex1d, sampler tex1dSmplr, constant uint& tex1 c = spvTextureSwizzle(texCube.sample(texCubeSmplr, float3(0.0)), texCubeSwzl); c = spvTextureSwizzle(tex2dArray.sample(tex2dArraySmplr, float3(0.0).xy, uint(rint(float3(0.0).z))), tex2dArraySwzl); c = spvTextureSwizzle(texCubeArray.sample(texCubeArraySmplr, float4(0.0).xyz, uint(rint(float4(0.0).w))), texCubeArraySwzl); - 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(rint(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(rint(float4(0.0).w)), 1.0), depthCubeArraySwzl); + c.x = spvTextureSwizzle(spvDepthCast(depth2d0).sample_compare(depth2d0Smplr, float3(0.0, 0.0, 1.0).xy, 1.0), depth2d0Swzl); + c.x = spvTextureSwizzle(spvDepthCast(depthCube).sample_compare(depthCubeSmplr, float4(0.0, 0.0, 0.0, 1.0).xyz, 1.0), depthCubeSwzl); + c.x = spvTextureSwizzle(spvDepthCast(depth2dArray).sample_compare(depth2dArraySmplr, float4(0.0, 0.0, 0.0, 1.0).xy, uint(rint(float4(0.0, 0.0, 0.0, 1.0).z)), 1.0), depth2dArraySwzl); + c.x = spvTextureSwizzle(spvDepthCast(depthCubeArray).sample_compare(depthCubeArraySmplr, float4(0.0).xyz, uint(rint(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 = 1.0; - c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, _103.xy / _103.z, 1.0 / _103.z), depth2dSwzl); + c.x = spvTextureSwizzle(spvDepthCast(depth2d0).sample_compare(depth2d0Smplr, _103.xy / _103.z, 1.0 / _103.z), depth2d0Swzl); 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(rint(float3(0.0).z)), level(0.0)), tex2dArraySwzl); c = spvTextureSwizzle(texCubeArray.sample(texCubeArraySmplr, float4(0.0).xyz, uint(rint(float4(0.0).w)), level(0.0)), texCubeArraySwzl); - c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, float3(0.0, 0.0, 1.0).xy, 1.0, level(0.0)), depth2dSwzl); + c.x = spvTextureSwizzle(spvDepthCast(depth2d0).sample_compare(depth2d0Smplr, float3(0.0, 0.0, 1.0).xy, 1.0, level(0.0)), depth2d0Swzl); 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 = 1.0; - c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, _131.xy / _131.z, 1.0 / _131.z, level(0.0)), depth2dSwzl); + c.x = spvTextureSwizzle(spvDepthCast(depth2d0).sample_compare(depth2d0Smplr, _131.xy / _131.z, 1.0 / _131.z, level(0.0)), depth2d0Swzl); 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); @@ -167,14 +191,14 @@ float4 doSwizzle(texture1d tex1d, sampler tex1dSmplr, constant uint& tex1 c = spvGatherSwizzle(texCube, texCubeSmplr, texCubeSwzl, component::y, float3(0.0)); c = spvGatherSwizzle(tex2dArray, tex2dArraySmplr, tex2dArraySwzl, component::z, float3(0.0).xy, uint(rint(float3(0.0).z)), int2(0)); c = spvGatherSwizzle(texCubeArray, texCubeArraySmplr, texCubeArraySwzl, component::w, float4(0.0).xyz, uint(rint(float4(0.0).w))); - c = spvGatherCompareSwizzle(depth2d, depth2dSmplr, depth2dSwzl, float2(0.0), 1.0); - c = spvGatherCompareSwizzle(depthCube, depthCubeSmplr, depthCubeSwzl, float3(0.0), 1.0); - c = spvGatherCompareSwizzle(depth2dArray, depth2dArraySmplr, depth2dArraySwzl, float3(0.0).xy, uint(rint(float3(0.0).z)), 1.0); - c = spvGatherCompareSwizzle(depthCubeArray, depthCubeArraySmplr, depthCubeArraySwzl, float4(0.0).xyz, uint(rint(float4(0.0).w)), 1.0); + c = spvGatherCompareSwizzle(spvDepthCast(depth2d0), depth2d0Smplr, depth2d0Swzl, float2(0.0), 1.0); + c = spvGatherCompareSwizzle(spvDepthCast(depthCube), depthCubeSmplr, depthCubeSwzl, float3(0.0), 1.0); + c = spvGatherCompareSwizzle(spvDepthCast(depth2dArray), depth2dArraySmplr, depth2dArraySwzl, float3(0.0).xy, uint(rint(float3(0.0).z)), 1.0); + c = spvGatherCompareSwizzle(spvDepthCast(depthCubeArray), depthCubeArraySmplr, depthCubeArraySwzl, float4(0.0).xyz, uint(rint(float4(0.0).w)), 1.0); return c; } -fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d tex1d [[texture(0)]], texture2d tex2d [[texture(1)]], texture3d tex3d [[texture(2)]], texturecube texCube [[texture(3)]], texture2d_array tex2dArray [[texture(4)]], texturecube_array texCubeArray [[texture(5)]], depth2d depth2d [[texture(6)]], depthcube depthCube [[texture(7)]], depth2d_array depth2dArray [[texture(8)]], depthcube_array depthCubeArray [[texture(9)]], texture2d texBuffer [[texture(10)]], sampler tex1dSmplr [[sampler(0)]], sampler tex2dSmplr [[sampler(1)]], sampler tex3dSmplr [[sampler(2)]], sampler texCubeSmplr [[sampler(3)]], sampler tex2dArraySmplr [[sampler(4)]], sampler texCubeArraySmplr [[sampler(5)]], sampler depth2dSmplr [[sampler(6)]], sampler depthCubeSmplr [[sampler(7)]], sampler depth2dArraySmplr [[sampler(8)]], sampler depthCubeArraySmplr [[sampler(9)]]) +fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d tex1d [[texture(0)]], texture2d tex2d [[texture(1)]], texture3d tex3d [[texture(2)]], texturecube texCube [[texture(3)]], texture2d_array tex2dArray [[texture(4)]], texturecube_array texCubeArray [[texture(5)]], texture2d depth2d0 [[texture(6)]], texturecube depthCube [[texture(7)]], texture2d_array depth2dArray [[texture(8)]], texturecube_array depthCubeArray [[texture(9)]], texture2d texBuffer [[texture(10)]], sampler tex1dSmplr [[sampler(0)]], sampler tex2dSmplr [[sampler(1)]], sampler tex3dSmplr [[sampler(2)]], sampler texCubeSmplr [[sampler(3)]], sampler tex2dArraySmplr [[sampler(4)]], sampler texCubeArraySmplr [[sampler(5)]], sampler depth2d0Smplr [[sampler(6)]], sampler depthCubeSmplr [[sampler(7)]], sampler depth2dArraySmplr [[sampler(8)]], sampler depthCubeArraySmplr [[sampler(9)]]) { constant uint& tex1dSwzl = spvSwizzleConstants[0]; constant uint& tex2dSwzl = spvSwizzleConstants[1]; @@ -182,10 +206,10 @@ fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d constant uint& texCubeSwzl = spvSwizzleConstants[3]; constant uint& tex2dArraySwzl = spvSwizzleConstants[4]; constant uint& texCubeArraySwzl = spvSwizzleConstants[5]; - constant uint& depth2dSwzl = spvSwizzleConstants[6]; + constant uint& depth2d0Swzl = spvSwizzleConstants[6]; constant uint& depthCubeSwzl = spvSwizzleConstants[7]; constant uint& depth2dArraySwzl = spvSwizzleConstants[8]; constant uint& depthCubeArraySwzl = spvSwizzleConstants[9]; - float4 c = doSwizzle(tex1d, tex1dSmplr, tex1dSwzl, tex2d, tex2dSmplr, tex2dSwzl, tex3d, tex3dSmplr, tex3dSwzl, texCube, texCubeSmplr, texCubeSwzl, tex2dArray, tex2dArraySmplr, tex2dArraySwzl, texCubeArray, texCubeArraySmplr, texCubeArraySwzl, depth2d, depth2dSmplr, depth2dSwzl, depthCube, depthCubeSmplr, depthCubeSwzl, depth2dArray, depth2dArraySmplr, depth2dArraySwzl, depthCubeArray, depthCubeArraySmplr, depthCubeArraySwzl, texBuffer); + float4 c = doSwizzle(tex1d, tex1dSmplr, tex1dSwzl, tex2d, tex2dSmplr, tex2dSwzl, tex3d, tex3dSmplr, tex3dSwzl, texCube, texCubeSmplr, texCubeSwzl, tex2dArray, tex2dArraySmplr, tex2dArraySwzl, texCubeArray, texCubeArraySmplr, texCubeArraySwzl, depth2d0, depth2d0Smplr, depth2d0Swzl, depthCube, depthCubeSmplr, depthCubeSwzl, depth2dArray, depth2dArraySmplr, depth2dArraySwzl, depthCubeArray, depthCubeArraySmplr, depthCubeArraySwzl, texBuffer); } 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 86aaaeabbd8c..f3a435564273 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 @@ -126,7 +126,31 @@ inline spvGatherCompareReturn spvGatherCompareSwizzle(const thread T return t.gather_compare(s, params...); } -fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d tex1d [[texture(0)]], texture2d tex2d [[texture(1)]], texture3d tex3d [[texture(2)]], texturecube texCube [[texture(3)]], texture2d_array tex2dArray [[texture(4)]], texturecube_array texCubeArray [[texture(5)]], depth2d depth2d [[texture(6)]], depthcube depthCube [[texture(7)]], depth2d_array depth2dArray [[texture(8)]], depthcube_array depthCubeArray [[texture(9)]], texture2d texBuffer [[texture(10)]], sampler tex1dSmplr [[sampler(0)]], sampler tex2dSmplr [[sampler(1)]], sampler tex3dSmplr [[sampler(2)]], sampler texCubeSmplr [[sampler(3)]], sampler tex2dArraySmplr [[sampler(4)]], sampler texCubeArraySmplr [[sampler(5)]], sampler depth2dSmplr [[sampler(6)]], sampler depthCubeSmplr [[sampler(7)]], sampler depth2dArraySmplr [[sampler(8)]], sampler depthCubeArraySmplr [[sampler(9)]]) +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + +fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d tex1d [[texture(0)]], texture2d tex2d [[texture(1)]], texture3d tex3d [[texture(2)]], texturecube texCube [[texture(3)]], texture2d_array tex2dArray [[texture(4)]], texturecube_array texCubeArray [[texture(5)]], texture2d depth2d0 [[texture(6)]], texturecube depthCube [[texture(7)]], texture2d_array depth2dArray [[texture(8)]], texturecube_array depthCubeArray [[texture(9)]], texture2d texBuffer [[texture(10)]], sampler tex1dSmplr [[sampler(0)]], sampler tex2dSmplr [[sampler(1)]], sampler tex3dSmplr [[sampler(2)]], sampler texCubeSmplr [[sampler(3)]], sampler tex2dArraySmplr [[sampler(4)]], sampler texCubeArraySmplr [[sampler(5)]], sampler depth2d0Smplr [[sampler(6)]], sampler depthCubeSmplr [[sampler(7)]], sampler depth2dArraySmplr [[sampler(8)]], sampler depthCubeArraySmplr [[sampler(9)]]) { constant uint& tex1dSwzl = spvSwizzleConstants[0]; constant uint& tex2dSwzl = spvSwizzleConstants[1]; @@ -134,7 +158,7 @@ fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d constant uint& texCubeSwzl = spvSwizzleConstants[3]; constant uint& tex2dArraySwzl = spvSwizzleConstants[4]; constant uint& texCubeArraySwzl = spvSwizzleConstants[5]; - constant uint& depth2dSwzl = spvSwizzleConstants[6]; + constant uint& depth2d0Swzl = spvSwizzleConstants[6]; constant uint& depthCubeSwzl = spvSwizzleConstants[7]; constant uint& depth2dArraySwzl = spvSwizzleConstants[8]; constant uint& depthCubeArraySwzl = spvSwizzleConstants[9]; @@ -144,29 +168,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(rint(float3(0.0).z))), tex2dArraySwzl); c = spvTextureSwizzle(texCubeArray.sample(texCubeArraySmplr, float4(0.0).xyz, uint(rint(float4(0.0).w))), texCubeArraySwzl); - 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(rint(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(rint(float4(0.0).w)), 1.0), depthCubeArraySwzl); + c.x = spvTextureSwizzle(spvDepthCast(depth2d0).sample_compare(depth2d0Smplr, float3(0.0, 0.0, 1.0).xy, 1.0), depth2d0Swzl); + c.x = spvTextureSwizzle(spvDepthCast(depthCube).sample_compare(depthCubeSmplr, float4(0.0, 0.0, 0.0, 1.0).xyz, 1.0), depthCubeSwzl); + c.x = spvTextureSwizzle(spvDepthCast(depth2dArray).sample_compare(depth2dArraySmplr, float4(0.0, 0.0, 0.0, 1.0).xy, uint(rint(float4(0.0, 0.0, 0.0, 1.0).z)), 1.0), depth2dArraySwzl); + c.x = spvTextureSwizzle(spvDepthCast(depthCubeArray).sample_compare(depthCubeArraySmplr, float4(0.0).xyz, uint(rint(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 = 1.0; - c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, _100.xy / _100.z, 1.0 / _100.z), depth2dSwzl); + c.x = spvTextureSwizzle(spvDepthCast(depth2d0).sample_compare(depth2d0Smplr, _100.xy / _100.z, 1.0 / _100.z), depth2d0Swzl); 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(rint(float3(0.0).z)), level(0.0)), tex2dArraySwzl); c = spvTextureSwizzle(texCubeArray.sample(texCubeArraySmplr, float4(0.0).xyz, uint(rint(float4(0.0).w)), level(0.0)), texCubeArraySwzl); - c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, float3(0.0, 0.0, 1.0).xy, 1.0, level(0.0)), depth2dSwzl); + c.x = spvTextureSwizzle(spvDepthCast(depth2d0).sample_compare(depth2d0Smplr, float3(0.0, 0.0, 1.0).xy, 1.0, level(0.0)), depth2d0Swzl); 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 = 1.0; - c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, _128.xy / _128.z, 1.0 / _128.z, level(0.0)), depth2dSwzl); + c.x = spvTextureSwizzle(spvDepthCast(depth2d0).sample_compare(depth2d0Smplr, _128.xy / _128.z, 1.0 / _128.z, level(0.0)), depth2d0Swzl); 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); @@ -176,9 +200,9 @@ fragment void main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d c = spvGatherSwizzle(texCube, texCubeSmplr, texCubeSwzl, component::y, float3(0.0)); c = spvGatherSwizzle(tex2dArray, tex2dArraySmplr, tex2dArraySwzl, component::z, float3(0.0).xy, uint(rint(float3(0.0).z)), int2(0)); c = spvGatherSwizzle(texCubeArray, texCubeArraySmplr, texCubeArraySwzl, component::w, float4(0.0).xyz, uint(rint(float4(0.0).w))); - c = spvGatherCompareSwizzle(depth2d, depth2dSmplr, depth2dSwzl, float2(0.0), 1.0); - c = spvGatherCompareSwizzle(depthCube, depthCubeSmplr, depthCubeSwzl, float3(0.0), 1.0); - c = spvGatherCompareSwizzle(depth2dArray, depth2dArraySmplr, depth2dArraySwzl, float3(0.0).xy, uint(rint(float3(0.0).z)), 1.0); - c = spvGatherCompareSwizzle(depthCubeArray, depthCubeArraySmplr, depthCubeArraySwzl, float4(0.0).xyz, uint(rint(float4(0.0).w)), 1.0); + c = spvGatherCompareSwizzle(spvDepthCast(depth2d0), depth2d0Smplr, depth2d0Swzl, float2(0.0), 1.0); + c = spvGatherCompareSwizzle(spvDepthCast(depthCube), depthCubeSmplr, depthCubeSwzl, float3(0.0), 1.0); + c = spvGatherCompareSwizzle(spvDepthCast(depth2dArray), depth2dArraySmplr, depth2dArraySwzl, float3(0.0).xy, uint(rint(float3(0.0).z)), 1.0); + c = spvGatherCompareSwizzle(spvDepthCast(depthCubeArray), depthCubeArraySmplr, depthCubeArraySwzl, float4(0.0).xyz, uint(rint(float4(0.0).w)), 1.0); } diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/packing/struct-size-padding-array-of-array.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/packing/struct-size-padding-array-of-array.comp index c30fd070ec46..e47bcad2502e 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/packing/struct-size-padding-array-of-array.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/packing/struct-size-padding-array-of-array.comp @@ -1,18 +1,21 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +struct spvPaddedArrayElement { T data; char padding[stride - sizeof(T)]; }; + struct A { float v; - char _m0_final_padding[12]; }; struct B { float2 v; - char _m0_final_padding[8]; }; struct C @@ -29,13 +32,12 @@ struct E { float4 a; float2 b; - char _m0_final_padding[8]; }; struct SSBO { - A a[2][4]; - B b[2][4]; + spvPaddedArrayElement a[2][4]; + spvPaddedArrayElement b[2][4]; C c[2][4]; D d[2][4]; float2x4 e[2][4]; diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/packing/struct-size-padding.comp b/third_party/spirv-cross/reference/shaders-msl-no-opt/packing/struct-size-padding.comp index 98f039fc98a9..9da3dfbbef3a 100644 --- a/third_party/spirv-cross/reference/shaders-msl-no-opt/packing/struct-size-padding.comp +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/packing/struct-size-padding.comp @@ -1,18 +1,21 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +struct spvPaddedArrayElement { T data; char padding[stride - sizeof(T)]; }; + struct A { float v; - char _m0_final_padding[12]; }; struct B { float2 v; - char _m0_final_padding[8]; }; struct C @@ -29,13 +32,12 @@ struct E { float4 a; float2 b; - char _m0_final_padding[8]; }; struct SSBO { - A a[4]; - B b[4]; + spvPaddedArrayElement a[4]; + spvPaddedArrayElement b[4]; C c[4]; D d[4]; float2x4 e[4]; diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/tese/depth-clip-enable-viewport-index.emulate-depth-clip-enable.msl2.tese b/third_party/spirv-cross/reference/shaders-msl-no-opt/tese/depth-clip-enable-viewport-index.emulate-depth-clip-enable.msl2.tese new file mode 100644 index 000000000000..23ca31ef4687 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/tese/depth-clip-enable-viewport-index.emulate-depth-clip-enable.msl2.tese @@ -0,0 +1,41 @@ +#include +#include + +using namespace metal; + +struct spvDepthClipState +{ + uint emulateViewportZ; + uint emulateDepthClamp; + float2 viewportDepthRanges[16]; +}; + +struct main0_out +{ + float4 gl_Position [[position]]; + uint gl_ViewportIndex [[viewport_array_index]]; +}; + +struct main0_in +{ + float4 gl_Position [[attribute(0)]]; +}; + +struct main0_patchIn +{ + patch_control_point gl_in; +}; + +[[ patch(quad, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]], constant spvDepthClipState& spvDepthClipState [[buffer(17)]]) +{ + main0_out out = {}; + out.gl_Position = patchIn.gl_in[0].gl_Position; + out.gl_ViewportIndex = uint(2); + if (spvDepthClipState.emulateViewportZ != 0u) + { + float2 spvViewportDepthRange = spvDepthClipState.viewportDepthRanges[uint(out.gl_ViewportIndex)]; + out.gl_Position.z = out.gl_Position.z * (spvViewportDepthRange.y - spvViewportDepthRange.x) + out.gl_Position.w * spvViewportDepthRange.x; // Emulate viewport Z transform + } + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/tese/depth-clip-enable.emulate-depth-clip-enable.tese b/third_party/spirv-cross/reference/shaders-msl-no-opt/tese/depth-clip-enable.emulate-depth-clip-enable.tese new file mode 100644 index 000000000000..423641367962 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/tese/depth-clip-enable.emulate-depth-clip-enable.tese @@ -0,0 +1,39 @@ +#include +#include + +using namespace metal; + +struct spvDepthClipState +{ + uint emulateViewportZ; + uint emulateDepthClamp; + float2 viewportDepthRanges[16]; +}; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +struct main0_in +{ + float4 gl_Position [[attribute(0)]]; +}; + +struct main0_patchIn +{ + patch_control_point gl_in; +}; + +[[ patch(quad, 0) ]] vertex main0_out main0(main0_patchIn patchIn [[stage_in]], constant spvDepthClipState& spvDepthClipState [[buffer(17)]]) +{ + main0_out out = {}; + out.gl_Position = patchIn.gl_in[0].gl_Position; + if (spvDepthClipState.emulateViewportZ != 0u) + { + float2 spvViewportDepthRange = spvDepthClipState.viewportDepthRanges[0]; + out.gl_Position.z = out.gl_Position.z * (spvViewportDepthRange.y - spvViewportDepthRange.x) + out.gl_Position.w * spvViewportDepthRange.x; // Emulate viewport Z transform + } + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/depth-clip-enable-viewport-index.emulate-depth-clip-enable.msl2.vert b/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/depth-clip-enable-viewport-index.emulate-depth-clip-enable.msl2.vert new file mode 100644 index 000000000000..142b62c418bc --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/depth-clip-enable-viewport-index.emulate-depth-clip-enable.msl2.vert @@ -0,0 +1,31 @@ +#include +#include + +using namespace metal; + +struct spvDepthClipState +{ + uint emulateViewportZ; + uint emulateDepthClamp; + float2 viewportDepthRanges[16]; +}; + +struct main0_out +{ + float4 gl_Position [[position]]; + uint gl_ViewportIndex [[viewport_array_index]]; +}; + +vertex main0_out main0(constant spvDepthClipState& spvDepthClipState [[buffer(17)]]) +{ + main0_out out = {}; + out.gl_Position = float4(0.0, 0.0, 0.25, 1.0); + out.gl_ViewportIndex = uint(2); + if (spvDepthClipState.emulateViewportZ != 0u) + { + float2 spvViewportDepthRange = spvDepthClipState.viewportDepthRanges[uint(out.gl_ViewportIndex)]; + out.gl_Position.z = out.gl_Position.z * (spvViewportDepthRange.y - spvViewportDepthRange.x) + out.gl_Position.w * spvViewportDepthRange.x; // Emulate viewport Z transform + } + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/depth-clip-enable.emulate-depth-clip-enable.emulate-reversed-depth-viewport.fixup-clipspace.vert b/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/depth-clip-enable.emulate-depth-clip-enable.emulate-reversed-depth-viewport.fixup-clipspace.vert new file mode 100644 index 000000000000..b41769415c0b --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/depth-clip-enable.emulate-depth-clip-enable.emulate-reversed-depth-viewport.fixup-clipspace.vert @@ -0,0 +1,34 @@ +#include +#include + +using namespace metal; + +struct spvDepthClipState +{ + uint emulateViewportZ; + uint emulateDepthClamp; + float2 viewportDepthRanges[16]; +}; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(constant spvDepthClipState& spvDepthClipState [[buffer(17)]], constant uint& spvEmulatedReversedDepthViewportMask [[buffer(18)]]) +{ + main0_out out = {}; + out.gl_Position = float4(0.0, 0.0, 0.25, 1.0); + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + if (spvDepthClipState.emulateViewportZ != 0u) + { + float2 spvViewportDepthRange = spvDepthClipState.viewportDepthRanges[0]; + out.gl_Position.z = out.gl_Position.z * (spvViewportDepthRange.y - spvViewportDepthRange.x) + out.gl_Position.w * spvViewportDepthRange.x; // Emulate viewport Z transform + } + if ((spvEmulatedReversedDepthViewportMask & 1u) != 0u) + { + out.gl_Position.z = out.gl_Position.w - out.gl_Position.z; // Emulate reversed-depth viewport + } + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/depth-clip-enable.emulate-depth-clip-enable.fixup-clipspace.vert b/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/depth-clip-enable.emulate-depth-clip-enable.fixup-clipspace.vert new file mode 100644 index 000000000000..634ddafa96cf --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/depth-clip-enable.emulate-depth-clip-enable.fixup-clipspace.vert @@ -0,0 +1,30 @@ +#include +#include + +using namespace metal; + +struct spvDepthClipState +{ + uint emulateViewportZ; + uint emulateDepthClamp; + float2 viewportDepthRanges[16]; +}; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(constant spvDepthClipState& spvDepthClipState [[buffer(17)]]) +{ + main0_out out = {}; + out.gl_Position = float4(0.0, 0.0, 0.25, 1.0); + out.gl_Position.z = (out.gl_Position.z + out.gl_Position.w) * 0.5; // Adjust clip-space for Metal + if (spvDepthClipState.emulateViewportZ != 0u) + { + float2 spvViewportDepthRange = spvDepthClipState.viewportDepthRanges[0]; + out.gl_Position.z = out.gl_Position.z * (spvViewportDepthRange.y - spvViewportDepthRange.x) + out.gl_Position.w * spvViewportDepthRange.x; // Emulate viewport Z transform + } + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/depth-clip-enable.emulate-depth-clip-enable.vert b/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/depth-clip-enable.emulate-depth-clip-enable.vert new file mode 100644 index 000000000000..4e1b58844a71 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/depth-clip-enable.emulate-depth-clip-enable.vert @@ -0,0 +1,29 @@ +#include +#include + +using namespace metal; + +struct spvDepthClipState +{ + uint emulateViewportZ; + uint emulateDepthClamp; + float2 viewportDepthRanges[16]; +}; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(constant spvDepthClipState& spvDepthClipState [[buffer(17)]]) +{ + main0_out out = {}; + out.gl_Position = float4(0.0, 0.0, 0.25, 1.0); + if (spvDepthClipState.emulateViewportZ != 0u) + { + float2 spvViewportDepthRange = spvDepthClipState.viewportDepthRanges[0]; + out.gl_Position.z = out.gl_Position.z * (spvViewportDepthRange.y - spvViewportDepthRange.x) + out.gl_Position.w * spvViewportDepthRange.x; // Emulate viewport Z transform + } + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/reversed-depth-viewport-index.emulate-reversed-depth-viewport.msl2.vert b/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/reversed-depth-viewport-index.emulate-reversed-depth-viewport.msl2.vert new file mode 100644 index 000000000000..5ae26156c4be --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/reversed-depth-viewport-index.emulate-reversed-depth-viewport.msl2.vert @@ -0,0 +1,23 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 gl_Position [[position]]; + uint gl_ViewportIndex [[viewport_array_index]]; +}; + +vertex main0_out main0(constant uint& spvEmulatedReversedDepthViewportMask [[buffer(18)]]) +{ + main0_out out = {}; + out.gl_Position = float4(0.0, 0.0, 0.25, 1.0); + out.gl_ViewportIndex = uint(2); + if (((spvEmulatedReversedDepthViewportMask >> uint(out.gl_ViewportIndex)) & 1u) != 0u) + { + out.gl_Position.z = out.gl_Position.w - out.gl_Position.z; // Emulate reversed-depth viewport + } + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/reversed-depth-viewport.emulate-reversed-depth-viewport.vert b/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/reversed-depth-viewport.emulate-reversed-depth-viewport.vert new file mode 100644 index 000000000000..b800c101d732 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl-no-opt/vert/reversed-depth-viewport.emulate-reversed-depth-viewport.vert @@ -0,0 +1,21 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 gl_Position [[position]]; +}; + +vertex main0_out main0(constant uint& spvEmulatedReversedDepthViewportMask [[buffer(18)]]) +{ + main0_out out = {}; + out.gl_Position = float4(0.0, 0.0, 0.25, 1.0); + if ((spvEmulatedReversedDepthViewportMask & 1u) != 0u) + { + out.gl_Position.z = out.gl_Position.w - out.gl_Position.z; // Emulate reversed-depth viewport + } + return out; +} + 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 ecd10a7acc36..3500455aa332 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 @@ -126,13 +126,37 @@ inline spvGatherCompareReturn spvGatherCompareSwizzle(const thread T return t.gather_compare(s, params...); } +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float4 fragColor [[color(0)]]; }; static inline __attribute__((always_inline)) -float4 do_samples(texture1d t1, sampler t1Smplr, constant uint& t1Swzl, texture2d t2, constant uint& t2Swzl, texture3d t3, sampler t3Smplr, constant uint& t3Swzl, texturecube tc, constant uint& tcSwzl, texture2d_array t2a, sampler t2aSmplr, constant uint& t2aSwzl, texturecube_array tca, sampler tcaSmplr, constant uint& tcaSwzl, texture2d tb, depth2d d2, sampler d2Smplr, constant uint& d2Swzl, depthcube dc, sampler dcSmplr, constant uint& dcSwzl, depth2d_array d2a, constant uint& d2aSwzl, depthcube_array dca, sampler dcaSmplr, constant uint& dcaSwzl, sampler defaultSampler, sampler shadowSampler) +float4 do_samples(texture1d t1, sampler t1Smplr, constant uint& t1Swzl, texture2d t2, constant uint& t2Swzl, texture3d t3, sampler t3Smplr, constant uint& t3Swzl, texturecube tc, constant uint& tcSwzl, texture2d_array t2a, sampler t2aSmplr, constant uint& t2aSwzl, texturecube_array tca, sampler tcaSmplr, constant uint& tcaSwzl, texture2d tb, texture2d d2, sampler d2Smplr, constant uint& d2Swzl, texturecube dc, sampler dcSmplr, constant uint& dcSwzl, texture2d_array d2a, constant uint& d2aSwzl, texturecube_array dca, sampler dcaSmplr, constant uint& dcaSwzl, sampler defaultSampler, sampler shadowSampler) { float4 c = spvTextureSwizzle(t1.sample(t1Smplr, 0.0), t1Swzl); c = spvTextureSwizzle(t2.sample(defaultSampler, float2(0.0)), t2Swzl); @@ -140,29 +164,29 @@ float4 do_samples(texture1d t1, sampler t1Smplr, constant uint& t1Swzl, t c = spvTextureSwizzle(tc.sample(defaultSampler, float3(0.0)), tcSwzl); c = spvTextureSwizzle(t2a.sample(t2aSmplr, float3(0.0).xy, uint(rint(float3(0.0).z))), t2aSwzl); c = spvTextureSwizzle(tca.sample(tcaSmplr, float4(0.0).xyz, uint(rint(float4(0.0).w))), tcaSwzl); - 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(rint(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(rint(float4(0.0).w)), 1.0), dcaSwzl); + c.x = spvTextureSwizzle(spvDepthCast(d2).sample_compare(d2Smplr, float3(0.0, 0.0, 1.0).xy, 1.0), d2Swzl); + c.x = spvTextureSwizzle(spvDepthCast(dc).sample_compare(dcSmplr, float4(0.0, 0.0, 0.0, 1.0).xyz, 1.0), dcSwzl); + c.x = spvTextureSwizzle(spvDepthCast(d2a).sample_compare(shadowSampler, float4(0.0, 0.0, 0.0, 1.0).xy, uint(rint(float4(0.0, 0.0, 0.0, 1.0).z)), 1.0), d2aSwzl); + c.x = spvTextureSwizzle(spvDepthCast(dca).sample_compare(dcaSmplr, float4(0.0).xyz, uint(rint(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 = 1.0; - c.x = spvTextureSwizzle(d2.sample_compare(d2Smplr, _119.xy / _119.z, 1.0 / _119.z), d2Swzl); + c.x = spvTextureSwizzle(spvDepthCast(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(rint(float3(0.0).z)), level(0.0)), t2aSwzl); c = spvTextureSwizzle(tca.sample(tcaSmplr, float4(0.0).xyz, uint(rint(float4(0.0).w)), level(0.0)), tcaSwzl); - c.x = spvTextureSwizzle(d2.sample_compare(d2Smplr, float3(0.0, 0.0, 1.0).xy, 1.0, level(0.0)), d2Swzl); + c.x = spvTextureSwizzle(spvDepthCast(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 = 1.0; - c.x = spvTextureSwizzle(d2.sample_compare(d2Smplr, _153.xy / _153.z, 1.0 / _153.z, level(0.0)), d2Swzl); + c.x = spvTextureSwizzle(spvDepthCast(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); @@ -172,14 +196,14 @@ float4 do_samples(texture1d t1, sampler t1Smplr, constant uint& t1Swzl, t c = spvGatherSwizzle(tc, defaultSampler, tcSwzl, component::y, float3(0.0)); c = spvGatherSwizzle(t2a, t2aSmplr, t2aSwzl, component::z, float3(0.0).xy, uint(rint(float3(0.0).z)), int2(0)); c = spvGatherSwizzle(tca, tcaSmplr, tcaSwzl, component::w, float4(0.0).xyz, uint(rint(float4(0.0).w))); - c = spvGatherCompareSwizzle(d2, d2Smplr, d2Swzl, float2(0.0), 1.0); - c = spvGatherCompareSwizzle(dc, dcSmplr, dcSwzl, float3(0.0), 1.0); - c = spvGatherCompareSwizzle(d2a, shadowSampler, d2aSwzl, float3(0.0).xy, uint(rint(float3(0.0).z)), 1.0); - c = spvGatherCompareSwizzle(dca, dcaSmplr, dcaSwzl, float4(0.0).xyz, uint(rint(float4(0.0).w)), 1.0); + c = spvGatherCompareSwizzle(spvDepthCast(d2), d2Smplr, d2Swzl, float2(0.0), 1.0); + c = spvGatherCompareSwizzle(spvDepthCast(dc), dcSmplr, dcSwzl, float3(0.0), 1.0); + c = spvGatherCompareSwizzle(spvDepthCast(d2a), shadowSampler, d2aSwzl, float3(0.0).xy, uint(rint(float3(0.0).z)), 1.0); + c = spvGatherCompareSwizzle(spvDepthCast(dca), dcaSmplr, dcaSwzl, float4(0.0).xyz, uint(rint(float4(0.0).w)), 1.0); return c; } -fragment main0_out main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d tex1d [[texture(0)]], texture2d tex2d [[texture(1)]], texture3d tex3d [[texture(2)]], texturecube texCube [[texture(3)]], texture2d_array tex2dArray [[texture(4)]], texturecube_array texCubeArray [[texture(5)]], texture2d texBuffer [[texture(6)]], depth2d depth2d [[texture(7)]], depthcube depthCube [[texture(8)]], depth2d_array depth2dArray [[texture(9)]], depthcube_array depthCubeArray [[texture(10)]], sampler defaultSampler [[sampler(0)]], sampler shadowSampler [[sampler(1)]], sampler tex1dSmplr [[sampler(2)]], sampler tex3dSmplr [[sampler(3)]], sampler tex2dArraySmplr [[sampler(4)]], sampler texCubeArraySmplr [[sampler(5)]], sampler depth2dSmplr [[sampler(6)]], sampler depthCubeSmplr [[sampler(7)]], sampler depthCubeArraySmplr [[sampler(8)]]) +fragment main0_out main0(constant uint* spvSwizzleConstants [[buffer(30)]], texture1d tex1d [[texture(0)]], texture2d tex2d [[texture(1)]], texture3d tex3d [[texture(2)]], texturecube texCube [[texture(3)]], texture2d_array tex2dArray [[texture(4)]], texturecube_array texCubeArray [[texture(5)]], texture2d texBuffer [[texture(6)]], texture2d depth2d0 [[texture(7)]], texturecube depthCube [[texture(8)]], texture2d_array depth2dArray [[texture(9)]], texturecube_array depthCubeArray [[texture(10)]], sampler defaultSampler [[sampler(0)]], sampler shadowSampler [[sampler(1)]], sampler tex1dSmplr [[sampler(2)]], sampler tex3dSmplr [[sampler(3)]], sampler tex2dArraySmplr [[sampler(4)]], sampler texCubeArraySmplr [[sampler(5)]], sampler depth2d0Smplr [[sampler(6)]], sampler depthCubeSmplr [[sampler(7)]], sampler depthCubeArraySmplr [[sampler(8)]]) { main0_out out = {}; constant uint& tex1dSwzl = spvSwizzleConstants[0]; @@ -188,11 +212,11 @@ fragment main0_out main0(constant uint* spvSwizzleConstants [[buffer(30)]], text constant uint& texCubeSwzl = spvSwizzleConstants[3]; constant uint& tex2dArraySwzl = spvSwizzleConstants[4]; constant uint& texCubeArraySwzl = spvSwizzleConstants[5]; - constant uint& depth2dSwzl = spvSwizzleConstants[7]; + constant uint& depth2d0Swzl = spvSwizzleConstants[7]; constant uint& depthCubeSwzl = spvSwizzleConstants[8]; constant uint& depth2dArraySwzl = spvSwizzleConstants[9]; constant uint& depthCubeArraySwzl = spvSwizzleConstants[10]; - out.fragColor = do_samples(tex1d, tex1dSmplr, tex1dSwzl, tex2d, tex2dSwzl, tex3d, tex3dSmplr, tex3dSwzl, texCube, texCubeSwzl, tex2dArray, tex2dArraySmplr, tex2dArraySwzl, texCubeArray, texCubeArraySmplr, texCubeArraySwzl, texBuffer, depth2d, depth2dSmplr, depth2dSwzl, depthCube, depthCubeSmplr, depthCubeSwzl, depth2dArray, depth2dArraySwzl, depthCubeArray, depthCubeArraySmplr, depthCubeArraySwzl, defaultSampler, shadowSampler); + out.fragColor = do_samples(tex1d, tex1dSmplr, tex1dSwzl, tex2d, tex2dSwzl, tex3d, tex3dSmplr, tex3dSwzl, texCube, texCubeSwzl, tex2dArray, tex2dArraySmplr, tex2dArraySwzl, texCubeArray, texCubeArraySmplr, texCubeArraySwzl, texBuffer, depth2d0, depth2d0Smplr, depth2d0Swzl, depthCube, depthCubeSmplr, depthCubeSwzl, depth2dArray, depth2dArraySwzl, depthCubeArray, depthCubeArraySmplr, depthCubeArraySwzl, defaultSampler, shadowSampler); return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/comp/block-name-alias-global.asm.comp b/third_party/spirv-cross/reference/shaders-msl/asm/comp/block-name-alias-global.asm.comp index 6dcc14ea8d5b..0136d13b34d8 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/comp/block-name-alias-global.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl/asm/comp/block-name-alias-global.asm.comp @@ -1,8 +1,13 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +struct spvPaddedArrayElement { T data; char padding[stride - sizeof(T)]; }; + struct A { int a; @@ -18,12 +23,11 @@ struct A_2 { int a; int b; - char _m0_final_padding[8]; }; struct A_3 { - A_2 Data[1024]; + spvPaddedArrayElement Data[1024]; }; struct B @@ -33,14 +37,14 @@ struct B struct B_1 { - A_2 Data[1024]; + spvPaddedArrayElement Data[1024]; }; kernel void main0(device A_1& C1 [[buffer(0)]], constant A_3& C2 [[buffer(1)]], device B& C3 [[buffer(2)]], constant B_1& C4 [[buffer(3)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]]) { - C1.Data[gl_GlobalInvocationID.x].a = C2.Data[gl_GlobalInvocationID.x].a; - C1.Data[gl_GlobalInvocationID.x].b = C2.Data[gl_GlobalInvocationID.x].b; - C3.Data[gl_GlobalInvocationID.x].a = C4.Data[gl_GlobalInvocationID.x].a; - C3.Data[gl_GlobalInvocationID.x].b = C4.Data[gl_GlobalInvocationID.x].b; + C1.Data[gl_GlobalInvocationID.x].a = C2.Data[gl_GlobalInvocationID.x].data.a; + C1.Data[gl_GlobalInvocationID.x].b = C2.Data[gl_GlobalInvocationID.x].data.b; + C3.Data[gl_GlobalInvocationID.x].a = C4.Data[gl_GlobalInvocationID.x].data.a; + C3.Data[gl_GlobalInvocationID.x].b = C4.Data[gl_GlobalInvocationID.x].data.b; } diff --git a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/variable-pointers-2.asm.comp b/third_party/spirv-cross/reference/shaders-msl/asm/comp/variable-pointers-2.asm.invalid.comp similarity index 51% rename from third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/variable-pointers-2.asm.comp rename to third_party/spirv-cross/reference/shaders-msl/asm/comp/variable-pointers-2.asm.invalid.comp index fd34476a230d..0301e50e629c 100644 --- a/third_party/spirv-cross/reference/opt/shaders-msl/asm/comp/variable-pointers-2.asm.comp +++ b/third_party/spirv-cross/reference/shaders-msl/asm/comp/variable-pointers-2.asm.invalid.comp @@ -1,3 +1,5 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include @@ -15,17 +17,27 @@ struct bar int d; }; +static inline __attribute__((always_inline)) +device foo* select_buffer(device foo* a, constant bar& cb) +{ + return (cb.d != 0) ? a : nullptr; +} + +static inline __attribute__((always_inline)) +thread uint3* select_input(thread uint3& gl_GlobalInvocationID, thread uint3& gl_LocalInvocationID, constant bar& cb) +{ + return (cb.d != 0) ? &gl_GlobalInvocationID : &gl_LocalInvocationID; +} + kernel void main0(device foo& buf [[buffer(0)]], constant bar& cb [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]]) { - bool _71 = cb.d != 0; - device foo* _72 = _71 ? &buf : nullptr; - device foo* _67 = _72; - device foo* _65 = _72; - thread uint3* _79 = _71 ? &gl_GlobalInvocationID : &gl_LocalInvocationID; - thread uint3* _74 = _79; + device foo* _44 = select_buffer(&buf, cb); + device foo* _65 = _44; + thread uint3* _45 = select_input(gl_GlobalInvocationID, gl_LocalInvocationID, cb); + device foo* _66 = _65; device int* _49; device int* _52; - _49 = &_72->a[0u]; + _49 = &_66->a[0u]; _52 = &buf.a[0u]; int _54; int _55; @@ -35,7 +47,7 @@ kernel void main0(device foo& buf [[buffer(0)]], constant bar& cb [[buffer(1)]], _55 = *_52; if (_54 != _55) { - int _63 = (_54 + _55) + int((*_79).x); + int _63 = (_54 + _55) + int((*_45).x); *_49 = _63; *_52 = _63; _49 = &_49[1u]; diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/frag/bitcast-ptr-vec.argument-tier-1.msl23.asm.frag b/third_party/spirv-cross/reference/shaders-msl/asm/frag/bitcast-ptr-vec.argument-tier-1.msl23.asm.frag index 48c72019ee24..26387bde01ad 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/frag/bitcast-ptr-vec.argument-tier-1.msl23.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl/asm/frag/bitcast-ptr-vec.argument-tier-1.msl23.asm.frag @@ -37,11 +37,14 @@ fragment main0_out main0(constant type_ConstantBuffer_PushConstants& g_PushConst spvDescriptorArray> g_Texture2DDescriptorHeap {spvDescriptorSet0Binding0}; main0_out out = {}; - int2 _55 = int2(gl_FragCoord.xy) - (*(reinterpret_cast(g_PushConstants.SharedConstants + 16ul))); + uint _47 = *(reinterpret_cast(g_PushConstants.SharedConstants + 12ul)); + int2 _54 = *(reinterpret_cast(g_PushConstants.SharedConstants + 16ul)); + int2 _55 = int2(gl_FragCoord.xy) - _54; bool _66; if (!any(_55 < int2(0))) { - _66 = any(_55 >= (*(reinterpret_cast(g_PushConstants.SharedConstants + 24ul)))); + int2 _63 = *(reinterpret_cast(g_PushConstants.SharedConstants + 24ul)); + _66 = any(_55 >= _63); } else { @@ -54,7 +57,7 @@ fragment main0_out main0(constant type_ConstantBuffer_PushConstants& g_PushConst } else { - _77 = g_Texture2DDescriptorHeap[*(reinterpret_cast(g_PushConstants.SharedConstants + 12ul))].read(uint2(int3(select(_55, int2(0), bool2(_66)), 0).xy), 0); + _77 = g_Texture2DDescriptorHeap[_47].read(uint2(int3(select(_55, int2(0), bool2(_66)), 0).xy), 0); } float3 _81 = powr(_77.xyz, *(reinterpret_cast(g_PushConstants.SharedConstants))); out.out_var_SV_Target = float4(_81.x, _81.y, _81.z, _77.w); diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.agx-cube-grad.msl23.asm.frag b/third_party/spirv-cross/reference/shaders-msl/asm/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.agx-cube-grad.msl23.asm.frag index f4b08ef48b19..38c61c8015a5 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.agx-cube-grad.msl23.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl/asm/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.agx-cube-grad.msl23.asm.frag @@ -25,6 +25,30 @@ static inline gradientcube spvGradientCube(float3 P, float3 dPdx, float3 dPdy) return gradientcube(xMajor ? d.xxy : d.xyx, xMajor ? d.zzw : d.zwz); } +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct buf0 { float4 u_scale; @@ -46,10 +70,10 @@ struct main0_in float2 v_drefLodBias [[user(locn1)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depthcube_array u_sampler [[texture(0)]], sampler u_samplerSmplr [[sampler(0)]]) +fragment main0_out main0(main0_in in [[stage_in]], texturecube_array u_sampler [[texture(0)]], sampler u_samplerSmplr [[sampler(0)]]) { main0_out out = {}; - out.o_color = float4(u_sampler.sample_compare(u_samplerSmplr, in.v_texCoord.xyz, uint(rint(in.v_texCoord.w)), in.v_drefLodBias.x, spvGradientCube(in.v_texCoord.xyz, exp2(in.v_drefLodBias.y - 0.5) / float3(u_sampler.get_width()), exp2(in.v_drefLodBias.y - 0.5) / float3(u_sampler.get_width()))), 0.0, 0.0, 1.0); + out.o_color = float4(spvDepthCast(u_sampler).sample_compare(u_samplerSmplr, in.v_texCoord.xyz, uint(rint(in.v_texCoord.w)), in.v_drefLodBias.x, spvGradientCube(in.v_texCoord.xyz, exp2(in.v_drefLodBias.y - 0.5) / float3(u_sampler.get_width()), exp2(in.v_drefLodBias.y - 0.5) / float3(u_sampler.get_width()))), 0.0, 0.0, 1.0); return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/frag/reserved-msl-type-names.asm.frag b/third_party/spirv-cross/reference/shaders-msl/asm/frag/reserved-msl-type-names.asm.frag new file mode 100644 index 000000000000..0f4710ba13f9 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/asm/frag/reserved-msl-type-names.asm.frag @@ -0,0 +1,22 @@ +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +struct main0_in +{ + float2 vUV [[user(locn0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], texture2d sampler0 [[texture(0)]], texture2d depth2d0 [[texture(1)]], sampler sampler0Smplr [[sampler(0)]], sampler depth2d0Smplr [[sampler(1)]]) +{ + main0_out out = {}; + out.FragColor = sampler0.sample(sampler0Smplr, in.vUV) + depth2d0.sample(depth2d0Smplr, in.vUV); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/frag/sample-and-compare.asm.frag b/third_party/spirv-cross/reference/shaders-msl/asm/frag/sample-and-compare.asm.frag index aed8fd382a3d..99949f268e75 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/frag/sample-and-compare.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl/asm/frag/sample-and-compare.asm.frag @@ -1,8 +1,34 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float out_var_SV_Target [[color(0)]]; @@ -13,10 +39,10 @@ struct main0_in float2 in_var_TEXCOORD0 [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d g_Texture [[texture(0)]], sampler g_Sampler [[sampler(0)]], sampler g_CompareSampler [[sampler(1)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d g_Texture [[texture(0)]], sampler g_Sampler [[sampler(0)]], sampler g_CompareSampler [[sampler(1)]]) { main0_out out = {}; - out.out_var_SV_Target = float4(g_Texture.sample(g_Sampler, in.in_var_TEXCOORD0)).x + g_Texture.sample_compare(g_CompareSampler, in.in_var_TEXCOORD0, 0.5, level(0.0)); + out.out_var_SV_Target = float4(g_Texture.sample(g_Sampler, in.in_var_TEXCOORD0)).x + spvDepthCast(g_Texture).sample_compare(g_CompareSampler, in.in_var_TEXCOORD0, 0.5, level(0.0)); return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/frag/texture-sampling-fp16.asm.frag b/third_party/spirv-cross/reference/shaders-msl/asm/frag/texture-sampling-fp16.asm.invalid.frag similarity index 100% rename from third_party/spirv-cross/reference/shaders-msl/asm/frag/texture-sampling-fp16.asm.frag rename to third_party/spirv-cross/reference/shaders-msl/asm/frag/texture-sampling-fp16.asm.invalid.frag diff --git a/third_party/spirv-cross/reference/shaders-msl/asm/frag/unknown-depth-state.asm.frag b/third_party/spirv-cross/reference/shaders-msl/asm/frag/unknown-depth-state.asm.frag index e512bdca4978..8ea33a4d1480 100644 --- a/third_party/spirv-cross/reference/shaders-msl/asm/frag/unknown-depth-state.asm.frag +++ b/third_party/spirv-cross/reference/shaders-msl/asm/frag/unknown-depth-state.asm.frag @@ -5,6 +5,30 @@ using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float FragColor [[color(0)]]; @@ -16,18 +40,18 @@ struct main0_in }; static inline __attribute__((always_inline)) -float sample_combined(thread float3& vUV, depth2d uShadow, sampler uShadowSmplr) +float sample_combined(thread float3& vUV, texture2d uShadow, sampler uShadowSmplr) { - return uShadow.sample_compare(uShadowSmplr, vUV.xy, vUV.z); + return spvDepthCast(uShadow).sample_compare(uShadowSmplr, vUV.xy, vUV.z); } static inline __attribute__((always_inline)) -float sample_separate(thread float3& vUV, depth2d uTexture, sampler uSampler) +float sample_separate(thread float3& vUV, texture2d uTexture, sampler uSampler) { - return uTexture.sample_compare(uSampler, vUV.xy, vUV.z); + return spvDepthCast(uTexture).sample_compare(uSampler, vUV.xy, vUV.z); } -fragment main0_out main0(main0_in in [[stage_in]], depth2d uShadow [[texture(0)]], depth2d uTexture [[texture(1)]], sampler uShadowSmplr [[sampler(0)]], sampler uSampler [[sampler(1)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d uShadow [[texture(0)]], texture2d uTexture [[texture(1)]], sampler uShadowSmplr [[sampler(0)]], sampler uSampler [[sampler(1)]]) { main0_out out = {}; out.FragColor = sample_combined(in.vUV, uShadow, uShadowSmplr) + sample_separate(in.vUV, uTexture, uSampler); diff --git a/third_party/spirv-cross/reference/shaders-msl/comp/overlapping-bindings.msl31.argument.argument-tier-1.decoration-binding.device-argument-buffer.texture-buffer-native.comp b/third_party/spirv-cross/reference/shaders-msl/comp/overlapping-bindings.msl31.argument.argument-tier-1.decoration-binding.device-argument-buffer.texture-buffer-native.comp index 33fd5746030b..de2ce23b4dde 100644 --- a/third_party/spirv-cross/reference/shaders-msl/comp/overlapping-bindings.msl31.argument.argument-tier-1.decoration-binding.device-argument-buffer.texture-buffer-native.comp +++ b/third_party/spirv-cross/reference/shaders-msl/comp/overlapping-bindings.msl31.argument.argument-tier-1.decoration-binding.device-argument-buffer.texture-buffer-native.comp @@ -108,7 +108,7 @@ struct spvDescriptorSetBuffer4 { const device B40* b40 [[id(0)]]; // Overlapping binding: constant B41* b41 [[id(0)]]; - // Overlapping binding: depth2d t40 [[id(0)]]; + // Overlapping binding: texture2d t40 [[id(0)]]; // Overlapping binding: texture2d t41 [[id(0)]]; // Overlapping binding: texture2d t42 [[id(0)]]; // Overlapping binding: texture_buffer u4 [[id(0)]]; @@ -116,7 +116,7 @@ struct spvDescriptorSetBuffer4 }; static inline __attribute__((always_inline)) -void in_function(thread float4& r0, const device array, 8>& t00, const device array& s00, const device array, 8>& t01, const device array, 8>& t02, const device array, 8>& u0, thread float4& r1, const device B10* constant (&b10)[8], constant B11* constant (&b11)[8], constant array, 8>& u1, thread float4& r2, constant array, 8>& t20, constant array& s20, constant array, 8>& t21, constant array, 8>& t22, const device B20* constant (&b20)[8], constant array, 8>& u2, constant B21* constant (&b21)[8], const spvDescriptorArray b30, thread uint3& gl_WorkGroupID, thread float4& r3, const spvDescriptorArray> t30, const spvDescriptorArray s30, const spvDescriptorArray> t31, const spvDescriptorArray> t32, const spvDescriptorArray b31, const spvDescriptorArray> u3, thread float4& r4, depth2d t40, sampler s40, texture2d t41, texture2d t42, const device B40& b40, constant B41& b41, texture_buffer u4) +void in_function(thread float4& r0, const device array, 8>& t00, const device array& s00, const device array, 8>& t01, const device array, 8>& t02, const device array, 8>& u0, thread float4& r1, const device B10* constant (&b10)[8], constant B11* constant (&b11)[8], constant array, 8>& u1, thread float4& r2, constant array, 8>& t20, constant array& s20, constant array, 8>& t21, constant array, 8>& t22, const device B20* constant (&b20)[8], constant array, 8>& u2, constant B21* constant (&b21)[8], const spvDescriptorArray b30, thread uint3& gl_WorkGroupID, thread float4& r3, const spvDescriptorArray> t30, const spvDescriptorArray s30, const spvDescriptorArray> t31, const spvDescriptorArray> t32, const spvDescriptorArray b31, const spvDescriptorArray> u3, thread float4& r4, texture2d t40, sampler s40, texture2d t41, texture2d t42, const device B40& b40, constant B41& b41, texture_buffer u4) { r0 = t00[0].sample(s00[3], float2(0.0), level(0.0)); r0.x = as_type(t01[1].read(uint2(int2(0)), 0).x); @@ -177,7 +177,7 @@ kernel void main0(const device spvDescriptorSetBuffer0& spvDescriptorSet0 [[buff constant auto &b11 = reinterpret_cast(spvDescriptorSet3.b10); constant auto &u1 = reinterpret_cast, 8> &>(spvDescriptorSet3.b10); constant auto &b41 = *reinterpret_cast(spvDescriptorSet4.b40); - constant auto &t40 = reinterpret_cast &>(spvDescriptorSet4.b40); + constant auto &t40 = reinterpret_cast &>(spvDescriptorSet4.b40); constant auto &t41 = reinterpret_cast &>(spvDescriptorSet4.b40); constant auto &t42 = reinterpret_cast &>(spvDescriptorSet4.b40); constant auto &u4 = reinterpret_cast &>(spvDescriptorSet4.b40); diff --git a/third_party/spirv-cross/reference/shaders-msl/comp/ray-query.spv14.vk.ios.msl24..invalid.comp b/third_party/spirv-cross/reference/shaders-msl/comp/ray-query.spv14.vk.ios.msl24..invalid.comp index 09802dd26280..0a39993cee0b 100644 --- a/third_party/spirv-cross/reference/shaders-msl/comp/ray-query.spv14.vk.ios.msl24..invalid.comp +++ b/third_party/spirv-cross/reference/shaders-msl/comp/ray-query.spv14.vk.ios.msl24..invalid.comp @@ -66,7 +66,7 @@ kernel void main0(constant Params& _18 [[buffer(1)]], raytracing::acceleration_s uint type = _80; uint _83 = uint(q2[0].get_candidate_intersection_type()) - 1; type = _83; - bool _85 = q2[1].is_candidate_non_opaque_bounding_box(); + bool _85 = (!q2[1].is_candidate_non_opaque_bounding_box()); res = _85; float _87 = q2[1].get_committed_distance(); fval = _87; diff --git a/third_party/spirv-cross/reference/shaders-msl/comp/struct-packing.comp b/third_party/spirv-cross/reference/shaders-msl/comp/struct-packing.comp index dc1654399d3a..4fe733a38c8e 100644 --- a/third_party/spirv-cross/reference/shaders-msl/comp/struct-packing.comp +++ b/third_party/spirv-cross/reference/shaders-msl/comp/struct-packing.comp @@ -1,13 +1,17 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +struct spvPaddedArrayElement { T data; char padding[stride - sizeof(T)]; }; + struct S0 { float2 a[1]; float b; - char _m0_final_padding[4]; }; struct S1 @@ -20,7 +24,6 @@ struct S2 { float3 a[1]; float b; - char _m0_final_padding[12]; }; struct S3 @@ -45,7 +48,6 @@ struct Content S3 m3; float m4; S4 m3s[8]; - char _m0_final_padding[8]; }; struct SSBO1 @@ -69,7 +71,6 @@ struct S0_1 float2 a[1]; char _m1_pad[8]; float b; - char _m0_final_padding[12]; }; struct S1_1 @@ -82,7 +83,6 @@ struct S2_1 { float3 a[1]; float b; - char _m0_final_padding[12]; }; struct S3_1 @@ -94,21 +94,21 @@ struct S3_1 struct S4_1 { float2 c; - char _m0_final_padding[8]; }; struct Content_1 { - S0_1 m0s[1]; + spvPaddedArrayElement m0s[1]; S1_1 m1s[1]; S2_1 m2s[1]; S0_1 m0; + char _m4_pad[8]; S1_1 m1; S2_1 m2; S3_1 m3; float m4; char _m8_pad[8]; - S4_1 m3s[8]; + spvPaddedArrayElement m3s[8]; }; struct SSBO0 @@ -124,8 +124,8 @@ constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u); kernel void main0(device SSBO1& ssbo_430 [[buffer(0)]], device SSBO0& ssbo_140 [[buffer(1)]]) { Content_1 _60 = ssbo_140.content; - ssbo_430.content.m0s[0].a[0] = _60.m0s[0].a[0]; - ssbo_430.content.m0s[0].b = _60.m0s[0].b; + ssbo_430.content.m0s[0].a[0] = _60.m0s[0].data.a[0]; + ssbo_430.content.m0s[0].b = _60.m0s[0].data.b; ssbo_430.content.m1s[0].a = float3(_60.m1s[0].a); ssbo_430.content.m1s[0].b = _60.m1s[0].b; ssbo_430.content.m2s[0].a[0] = _60.m2s[0].a[0]; @@ -139,14 +139,14 @@ kernel void main0(device SSBO1& ssbo_430 [[buffer(0)]], device SSBO0& ssbo_140 [ ssbo_430.content.m3.a = _60.m3.a; ssbo_430.content.m3.b = _60.m3.b; ssbo_430.content.m4 = _60.m4; - ssbo_430.content.m3s[0].c = _60.m3s[0].c; - ssbo_430.content.m3s[1].c = _60.m3s[1].c; - ssbo_430.content.m3s[2].c = _60.m3s[2].c; - ssbo_430.content.m3s[3].c = _60.m3s[3].c; - ssbo_430.content.m3s[4].c = _60.m3s[4].c; - ssbo_430.content.m3s[5].c = _60.m3s[5].c; - ssbo_430.content.m3s[6].c = _60.m3s[6].c; - ssbo_430.content.m3s[7].c = _60.m3s[7].c; + ssbo_430.content.m3s[0].c = _60.m3s[0].data.c; + ssbo_430.content.m3s[1].c = _60.m3s[1].data.c; + ssbo_430.content.m3s[2].c = _60.m3s[2].data.c; + ssbo_430.content.m3s[3].c = _60.m3s[3].data.c; + ssbo_430.content.m3s[4].c = _60.m3s[4].data.c; + ssbo_430.content.m3s[5].c = _60.m3s[5].data.c; + ssbo_430.content.m3s[6].c = _60.m3s[6].data.c; + ssbo_430.content.m3s[7].c = _60.m3s[7].data.c; ssbo_430.content.m1.a = ssbo_430.content.m3.a * ssbo_430.m6[1][1]; } diff --git a/third_party/spirv-cross/reference/shaders-msl/desktop-only/vert/shader-draw-parameters.desktop.for-tess.vert b/third_party/spirv-cross/reference/shaders-msl/desktop-only/vert/shader-draw-parameters.desktop.for-tess.vert index b3c8b6bb2789..d5ca47be7143 100644 --- a/third_party/spirv-cross/reference/shaders-msl/desktop-only/vert/shader-draw-parameters.desktop.for-tess.vert +++ b/third_party/spirv-cross/reference/shaders-msl/desktop-only/vert/shader-draw-parameters.desktop.for-tess.vert @@ -8,13 +8,14 @@ struct main0_out float4 gl_Position; }; -kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 spvStageInputSize [[grid_size]], uint3 spvDispatchBase [[grid_origin]], device main0_out* spvOut [[buffer(28)]]) +kernel void main0(constant uint* spvDrawIndex [[buffer(19)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 spvStageInputSize [[grid_size]], uint3 spvDispatchBase [[grid_origin]], 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; uint gl_BaseVertex = spvDispatchBase.x; uint gl_BaseInstance = spvDispatchBase.y; - out.gl_Position = float4(float(int(gl_BaseVertex)), float(int(gl_BaseInstance)), 0.0, 1.0); + uint gl_DrawID = *spvDrawIndex; + out.gl_Position = float4(float(int(gl_BaseVertex)), float(int(gl_BaseInstance)), float(int(gl_DrawID)), 1.0); } diff --git a/third_party/spirv-cross/reference/shaders-msl/desktop-only/vert/shader-draw-parameters.desktop.vert b/third_party/spirv-cross/reference/shaders-msl/desktop-only/vert/shader-draw-parameters.desktop.vert index a32c1948f880..a6d42a021e63 100644 --- a/third_party/spirv-cross/reference/shaders-msl/desktop-only/vert/shader-draw-parameters.desktop.vert +++ b/third_party/spirv-cross/reference/shaders-msl/desktop-only/vert/shader-draw-parameters.desktop.vert @@ -8,10 +8,11 @@ struct main0_out float4 gl_Position [[position]]; }; -vertex main0_out main0(uint gl_BaseVertex [[base_vertex]], uint gl_BaseInstance [[base_instance]]) +vertex main0_out main0(constant uint* spvDrawIndex [[buffer(19)]], uint gl_BaseVertex [[base_vertex]], uint gl_BaseInstance [[base_instance]]) { main0_out out = {}; - out.gl_Position = float4(float(int(gl_BaseVertex)), float(int(gl_BaseInstance)), 0.0, 1.0); + uint gl_DrawID = *spvDrawIndex; + out.gl_Position = float4(float(int(gl_BaseVertex)), float(int(gl_BaseInstance)), float(int(gl_DrawID)), 1.0); return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.msl23.frag b/third_party/spirv-cross/reference/shaders-msl/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.msl23.frag index 924ba7ecca0e..abfdc7457edb 100644 --- a/third_party/spirv-cross/reference/shaders-msl/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.msl23.frag +++ b/third_party/spirv-cross/reference/shaders-msl/frag/depth-array-texture-lod.lod-as-grad.1d-as-2d.msl23.frag @@ -1,8 +1,34 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct buf0 { float4 u_scale; @@ -24,10 +50,10 @@ struct main0_in float v_lodBias [[user(locn1)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d_array u_sampler [[texture(0)]], sampler u_samplerSmplr [[sampler(0)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d_array u_sampler [[texture(0)]], sampler u_samplerSmplr [[sampler(0)]]) { main0_out out = {}; - out.o_color = float4(u_sampler.sample_compare(u_samplerSmplr, float2(in.v_texCoord.x, 0.5), uint(rint(in.v_texCoord.y)), in.v_texCoord.z, gradient2d(exp2(in.v_lodBias - 0.5) / float2(u_sampler.get_width(), 1.0), exp2(in.v_lodBias - 0.5) / float2(u_sampler.get_width(), 1.0))), 0.0, 0.0, 1.0); + out.o_color = float4(spvDepthCast(u_sampler).sample_compare(u_samplerSmplr, float2(in.v_texCoord.x, 0.5), uint(rint(in.v_texCoord.y)), in.v_texCoord.z, gradient2d(exp2(in.v_lodBias - 0.5) / float2(u_sampler.get_width(), 1.0), exp2(in.v_lodBias - 0.5) / float2(u_sampler.get_width(), 1.0))), 0.0, 0.0, 1.0); return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/gather-compare-const-offsets.frag b/third_party/spirv-cross/reference/shaders-msl/frag/gather-compare-const-offsets.frag index 600fb1747208..9aa28ce5be40 100644 --- a/third_party/spirv-cross/reference/shaders-msl/frag/gather-compare-const-offsets.frag +++ b/third_party/spirv-cross/reference/shaders-msl/frag/gather-compare-const-offsets.frag @@ -83,6 +83,30 @@ inline spvGatherCompareReturn spvGatherCompareConstOffsets(const thr return spvGatherCompareReturn(rslts[0].w, rslts[1].w, rslts[2].w, rslts[3].w); } +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + constant spvUnsafeArray _38 = spvUnsafeArray({ int2(-8, 3), int2(-4, 7), int2(0, 3), int2(3, 0) }); struct main0_out @@ -96,10 +120,10 @@ struct main0_in float2 compare_value [[user(locn1)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d tex [[texture(0)]], sampler texSmplr [[sampler(0)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d tex [[texture(0)]], sampler texSmplr [[sampler(0)]]) { main0_out out = {}; - out.FragColor = spvGatherCompareConstOffsets(tex, texSmplr, _38, in.coord, in.compare_value.x); + out.FragColor = spvGatherCompareConstOffsets(spvDepthCast(tex), texSmplr, _38, in.coord, in.compare_value.x); return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/gather-dref.frag b/third_party/spirv-cross/reference/shaders-msl/frag/gather-dref.frag index c5c5ccf0bbbc..19e345b315c6 100644 --- a/third_party/spirv-cross/reference/shaders-msl/frag/gather-dref.frag +++ b/third_party/spirv-cross/reference/shaders-msl/frag/gather-dref.frag @@ -1,8 +1,34 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float4 FragColor [[color(0)]]; @@ -13,10 +39,10 @@ struct main0_in float3 vUV [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d uT [[texture(0)]], sampler uTSmplr [[sampler(0)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d uT [[texture(0)]], sampler uTSmplr [[sampler(0)]]) { main0_out out = {}; - out.FragColor = uT.gather_compare(uTSmplr, in.vUV.xy, in.vUV.z); + out.FragColor = spvDepthCast(uT).gather_compare(uTSmplr, in.vUV.xy, in.vUV.z); return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/sample-depth-propagate-state-from-resource.frag b/third_party/spirv-cross/reference/shaders-msl/frag/sample-depth-propagate-state-from-resource.frag index f0bf396c50bd..595459a71447 100644 --- a/third_party/spirv-cross/reference/shaders-msl/frag/sample-depth-propagate-state-from-resource.frag +++ b/third_party/spirv-cross/reference/shaders-msl/frag/sample-depth-propagate-state-from-resource.frag @@ -5,6 +5,30 @@ using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float FragColor [[color(0)]]; @@ -16,24 +40,24 @@ struct main0_in }; static inline __attribute__((always_inline)) -float sample_normal2(depth2d tex, sampler uSampler, thread float3& vUV) +float sample_normal2(texture2d tex, sampler uSampler, thread float3& vUV) { return float4(tex.sample(uSampler, vUV.xy)).x; } static inline __attribute__((always_inline)) -float sample_normal(depth2d tex, sampler uSampler, thread float3& vUV) +float sample_normal(texture2d tex, sampler uSampler, thread float3& vUV) { return sample_normal2(tex, uSampler, vUV); } static inline __attribute__((always_inline)) -float sample_comp(depth2d tex, thread float3& vUV, sampler uSamplerShadow) +float sample_comp(texture2d tex, thread float3& vUV, sampler uSamplerShadow) { - return tex.sample_compare(uSamplerShadow, vUV.xy, vUV.z); + return spvDepthCast(tex).sample_compare(uSamplerShadow, vUV.xy, vUV.z); } -fragment main0_out main0(main0_in in [[stage_in]], depth2d uTexture [[texture(0)]], sampler uSampler [[sampler(0)]], sampler uSamplerShadow [[sampler(1)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d uTexture [[texture(0)]], sampler uSampler [[sampler(0)]], sampler uSamplerShadow [[sampler(1)]]) { main0_out out = {}; out.FragColor = sample_normal(uTexture, uSampler, in.vUV); 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 27653a06a439..63df0799f53d 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 @@ -5,15 +5,39 @@ using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float FragColor [[color(0)]]; }; static inline __attribute__((always_inline)) -float sample_depth_from_function(depth2d uT, sampler uS) +float sample_depth_from_function(texture2d uT, sampler uS) { - return uT.sample_compare(uS, float3(0.5).xy, 0.5); + return spvDepthCast(uT).sample_compare(uS, float3(0.5).xy, 0.5); } static inline __attribute__((always_inline)) @@ -22,7 +46,7 @@ float sample_color_from_function(texture2d uT, sampler uS) return uT.sample(uS, float2(0.5)).x; } -fragment main0_out main0(depth2d uDepth [[texture(0)]], texture2d uColor [[texture(1)]], sampler uSamplerShadow [[sampler(0)]], sampler uSampler [[sampler(1)]]) +fragment main0_out main0(texture2d uDepth [[texture(0)]], texture2d uColor [[texture(1)]], sampler uSamplerShadow [[sampler(0)]], sampler uSampler [[sampler(1)]]) { main0_out out = {}; out.FragColor = sample_depth_from_function(uDepth, uSamplerShadow) + sample_color_from_function(uColor, uSampler); diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/sampler-compare-bias.msl23.1d-as-2d.frag b/third_party/spirv-cross/reference/shaders-msl/frag/sampler-compare-bias.msl23.1d-as-2d.frag index 924736ebb0ac..16a579d874df 100644 --- a/third_party/spirv-cross/reference/shaders-msl/frag/sampler-compare-bias.msl23.1d-as-2d.frag +++ b/third_party/spirv-cross/reference/shaders-msl/frag/sampler-compare-bias.msl23.1d-as-2d.frag @@ -1,8 +1,34 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float FragColor [[color(0)]]; @@ -13,10 +39,10 @@ struct main0_in float3 vUV [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d_array uTex [[texture(0)]], sampler uShadow [[sampler(0)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d_array uTex [[texture(0)]], sampler uShadow [[sampler(0)]]) { main0_out out = {}; - out.FragColor = uTex.sample_compare(uShadow, float2(in.vUV.x, 0.5), uint(rint(in.vUV.y)), in.vUV.z, bias(1.0)); + out.FragColor = spvDepthCast(uTex).sample_compare(uShadow, float2(in.vUV.x, 0.5), uint(rint(in.vUV.y)), in.vUV.z, bias(1.0)); return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/sampler-compare-cascade-gradient.frag b/third_party/spirv-cross/reference/shaders-msl/frag/sampler-compare-cascade-gradient.frag index 092b11d18aa7..890804cf7af3 100644 --- a/third_party/spirv-cross/reference/shaders-msl/frag/sampler-compare-cascade-gradient.frag +++ b/third_party/spirv-cross/reference/shaders-msl/frag/sampler-compare-cascade-gradient.frag @@ -1,8 +1,34 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float FragColor [[color(0)]]; @@ -13,10 +39,10 @@ struct main0_in float4 vUV [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d_array uTex [[texture(0)]], sampler uShadow [[sampler(0)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d_array uTex [[texture(0)]], sampler uShadow [[sampler(0)]]) { main0_out out = {}; - out.FragColor = uTex.sample_compare(uShadow, in.vUV.xy, uint(rint(in.vUV.z)), in.vUV.w, level(0)); + out.FragColor = spvDepthCast(uTex).sample_compare(uShadow, in.vUV.xy, uint(rint(in.vUV.z)), in.vUV.w, level(0)); return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/sampler-compare-cascade-gradient.ios.frag b/third_party/spirv-cross/reference/shaders-msl/frag/sampler-compare-cascade-gradient.ios.frag index fdd4d1644263..c672a95e85f8 100644 --- a/third_party/spirv-cross/reference/shaders-msl/frag/sampler-compare-cascade-gradient.ios.frag +++ b/third_party/spirv-cross/reference/shaders-msl/frag/sampler-compare-cascade-gradient.ios.frag @@ -1,8 +1,28 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float FragColor [[color(0)]]; @@ -13,10 +33,10 @@ struct main0_in float4 vUV [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d_array uTex [[texture(0)]], sampler uShadow [[sampler(0)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d_array uTex [[texture(0)]], sampler uShadow [[sampler(0)]]) { main0_out out = {}; - out.FragColor = uTex.sample_compare(uShadow, in.vUV.xy, uint(rint(in.vUV.z)), in.vUV.w, gradient2d(float2(0.0), float2(0.0))); + out.FragColor = spvDepthCast(uTex).sample_compare(uShadow, in.vUV.xy, uint(rint(in.vUV.z)), in.vUV.w, gradient2d(float2(0.0), float2(0.0))); return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/sampler-compare-cascade-gradient.msl23.frag b/third_party/spirv-cross/reference/shaders-msl/frag/sampler-compare-cascade-gradient.msl23.frag index f66f5d38c151..5b93c0976676 100644 --- a/third_party/spirv-cross/reference/shaders-msl/frag/sampler-compare-cascade-gradient.msl23.frag +++ b/third_party/spirv-cross/reference/shaders-msl/frag/sampler-compare-cascade-gradient.msl23.frag @@ -1,8 +1,34 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float FragColor [[color(0)]]; @@ -13,10 +39,10 @@ struct main0_in float4 vUV [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d_array uTex [[texture(0)]], sampler uShadow [[sampler(0)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d_array uTex [[texture(0)]], sampler uShadow [[sampler(0)]]) { main0_out out = {}; - out.FragColor = uTex.sample_compare(uShadow, in.vUV.xy, uint(rint(in.vUV.z)), in.vUV.w, level(0)) + uTex.sample_compare(uShadow, in.vUV.xy, uint(rint(in.vUV.z)), in.vUV.w, gradient2d(float2(1.0), float2(1.0))); + out.FragColor = spvDepthCast(uTex).sample_compare(uShadow, in.vUV.xy, uint(rint(in.vUV.z)), in.vUV.w, level(0)) + spvDepthCast(uTex).sample_compare(uShadow, in.vUV.xy, uint(rint(in.vUV.z)), in.vUV.w, gradient2d(float2(1.0), float2(1.0))); return out; } diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/struct-array-stride-padded-element.frag b/third_party/spirv-cross/reference/shaders-msl/frag/struct-array-stride-padded-element.frag new file mode 100644 index 000000000000..421c1f57a457 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/frag/struct-array-stride-padded-element.frag @@ -0,0 +1,49 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +template +struct spvPaddedArrayElement { T data; char padding[stride - sizeof(T)]; }; + +struct SpotLight +{ + packed_float3 position; + float range; + packed_float3 direction; + float angle; + packed_float3 color; + float intensity; + float penumbra; +}; + +struct UBO +{ + spvPaddedArrayElement spot_lights[4]; + int spot_light_count; + char _m2_pad[12]; + packed_float3 albedo; + float roughness; + float alpha; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(constant UBO& ubo [[buffer(0)]]) +{ + main0_out out = {}; + float3 acc = float3(0.0); + int n = min(ubo.spot_light_count, 4); + for (int i = 0; i < n; i++) + { + acc += ((float3(ubo.spot_lights[i].data.color) * ubo.spot_lights[i].data.intensity) * ubo.spot_lights[i].data.penumbra); + } + out.FragColor = float4(ubo.albedo[0u], ubo.roughness, ubo.alpha * acc.z, 1.0); + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/frag/texture-proj-shadow.frag b/third_party/spirv-cross/reference/shaders-msl/frag/texture-proj-shadow.frag index 1ef450a2b322..b7d287a475fe 100644 --- a/third_party/spirv-cross/reference/shaders-msl/frag/texture-proj-shadow.frag +++ b/third_party/spirv-cross/reference/shaders-msl/frag/texture-proj-shadow.frag @@ -1,8 +1,34 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct main0_out { float FragColor [[color(0)]]; @@ -15,13 +41,13 @@ struct main0_in float2 vClip2 [[user(locn2)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], depth2d uShadow2D [[texture(0)]], texture1d uSampler1D [[texture(1)]], texture2d uSampler2D [[texture(2)]], texture3d uSampler3D [[texture(3)]], sampler uShadow2DSmplr [[sampler(0)]], sampler uSampler1DSmplr [[sampler(1)]], sampler uSampler2DSmplr [[sampler(2)]], sampler uSampler3DSmplr [[sampler(3)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d uShadow2D [[texture(0)]], texture1d uSampler1D [[texture(1)]], texture2d uSampler2D [[texture(2)]], texture3d uSampler3D [[texture(3)]], sampler uShadow2DSmplr [[sampler(0)]], sampler uSampler1DSmplr [[sampler(1)]], sampler uSampler2DSmplr [[sampler(2)]], sampler uSampler3DSmplr [[sampler(3)]]) { main0_out out = {}; float4 _17 = in.vClip4; float4 _20 = _17; _20.z = _17.w; - out.FragColor = uShadow2D.sample_compare(uShadow2DSmplr, _20.xy / _20.z, _17.z / _20.z); + out.FragColor = spvDepthCast(uShadow2D).sample_compare(uShadow2DSmplr, _20.xy / _20.z, _17.z / _20.z); out.FragColor = uSampler1D.sample(uSampler1DSmplr, in.vClip2.x / in.vClip2.y).x; out.FragColor = uSampler2D.sample(uSampler2DSmplr, in.vClip3.xy / in.vClip3.z).x; out.FragColor = uSampler3D.sample(uSampler3DSmplr, in.vClip4.xyz / in.vClip4.w).x; diff --git a/third_party/spirv-cross/reference/shaders-msl/vert/clip-copy.for-tess.vert b/third_party/spirv-cross/reference/shaders-msl/vert/clip-copy.for-tess.vert new file mode 100644 index 000000000000..2901d4dd5d0a --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/vert/clip-copy.for-tess.vert @@ -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 Block +{ + spvUnsafeArray block0; +}; + +constant spvUnsafeArray _30 = spvUnsafeArray({ 1.0, 2.0, -1.0, -2.0 }); + +struct main0_out +{ + spvUnsafeArray F_array; + spvUnsafeArray m_43_block0; + float4 gl_Position; + spvUnsafeArray gl_ClipDistance; +}; + +static inline __attribute__((always_inline)) +void in_func(device float4& gl_Position, device spvUnsafeArray& gl_ClipDistance, device spvUnsafeArray& F_array, thread Block& _43) +{ + gl_Position = float4(1.0, 2.0, 3.0, 4.0); + gl_ClipDistance = _30; + spvUnsafeArray non_const_clips = gl_ClipDistance; + gl_ClipDistance = non_const_clips; + F_array = non_const_clips; + _43.block0 = _30; +} + +kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint3 spvStageInputSize [[grid_size]], device main0_out* spvOut [[buffer(28)]]) +{ + Block _43 = {}; + device main0_out& out = spvOut[gl_GlobalInvocationID.y * spvStageInputSize.x + gl_GlobalInvocationID.x]; + if (any(gl_GlobalInvocationID >= spvStageInputSize)) + return; + in_func(out.gl_Position, out.gl_ClipDistance, out.F_array, _43); + out.m_43_block0 = _43.block0; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/vert/clip-copy.vert b/third_party/spirv-cross/reference/shaders-msl/vert/clip-copy.vert new file mode 100644 index 000000000000..47648804c5ae --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-msl/vert/clip-copy.vert @@ -0,0 +1,216 @@ +#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]; + } +}; + +template +inline void spvArrayCopyFromConstantToStack(thread T (&dst)[N], constant T (&src)[N]) +{ + for (uint i = 0; i < N; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromConstantToThreadGroup(threadgroup T (&dst)[N], constant T (&src)[N]) +{ + for (uint i = 0; i < N; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromStackToStack(thread T (&dst)[N], thread const T (&src)[N]) +{ + for (uint i = 0; i < N; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromStackToThreadGroup(threadgroup T (&dst)[N], thread const T (&src)[N]) +{ + for (uint i = 0; i < N; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromThreadGroupToStack(thread T (&dst)[N], threadgroup const T (&src)[N]) +{ + for (uint i = 0; i < N; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromThreadGroupToThreadGroup(threadgroup T (&dst)[N], threadgroup const T (&src)[N]) +{ + for (uint i = 0; i < N; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromDeviceToDevice(device T (&dst)[N], device const T (&src)[N]) +{ + for (uint i = 0; i < N; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromConstantToDevice(device T (&dst)[N], constant T (&src)[N]) +{ + for (uint i = 0; i < N; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromStackToDevice(device T (&dst)[N], thread const T (&src)[N]) +{ + for (uint i = 0; i < N; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromThreadGroupToDevice(device T (&dst)[N], threadgroup const T (&src)[N]) +{ + for (uint i = 0; i < N; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromDeviceToStack(thread T (&dst)[N], device const T (&src)[N]) +{ + for (uint i = 0; i < N; i++) + { + dst[i] = src[i]; + } +} + +template +inline void spvArrayCopyFromDeviceToThreadGroup(threadgroup T (&dst)[N], device const T (&src)[N]) +{ + for (uint i = 0; i < N; i++) + { + dst[i] = src[i]; + } +} + +struct Block +{ + spvUnsafeArray block0; +}; + +constant spvUnsafeArray _30 = spvUnsafeArray({ 1.0, 2.0, -1.0, -2.0 }); + +struct main0_out +{ + float F_array_0 [[user(locn0)]]; + float F_array_1 [[user(locn1)]]; + float F_array_2 [[user(locn2)]]; + float F_array_3 [[user(locn3)]]; + float m_43_block0_0 [[user(locn4)]]; + float m_43_block0_1 [[user(locn5)]]; + float m_43_block0_2 [[user(locn6)]]; + float m_43_block0_3 [[user(locn7)]]; + float4 gl_Position [[position]]; + float gl_ClipDistance [[clip_distance]] [4]; + float gl_ClipDistance_0 [[user(clip0)]]; + float gl_ClipDistance_1 [[user(clip1)]]; + float gl_ClipDistance_2 [[user(clip2)]]; + float gl_ClipDistance_3 [[user(clip3)]]; +}; + +static inline __attribute__((always_inline)) +void in_func(thread float4& gl_Position, thread float (&gl_ClipDistance)[4], thread spvUnsafeArray& F_array, thread Block& _43) +{ + gl_Position = float4(1.0, 2.0, 3.0, 4.0); + spvArrayCopyFromConstantToStack(gl_ClipDistance, _30.elements); + spvUnsafeArray _36; + _36[0] = gl_ClipDistance[0]; + _36[1] = gl_ClipDistance[1]; + _36[2] = gl_ClipDistance[2]; + _36[3] = gl_ClipDistance[3]; + spvUnsafeArray non_const_clips = _36; + spvArrayCopyFromStackToStack(gl_ClipDistance, non_const_clips.elements); + F_array = non_const_clips; + _43.block0 = _30; +} + +vertex main0_out main0() +{ + main0_out out = {}; + spvUnsafeArray F_array = {}; + Block _43 = {}; + in_func(out.gl_Position, out.gl_ClipDistance, F_array, _43); + out.gl_ClipDistance_0 = out.gl_ClipDistance[0]; + out.gl_ClipDistance_1 = out.gl_ClipDistance[1]; + out.gl_ClipDistance_2 = out.gl_ClipDistance[2]; + out.gl_ClipDistance_3 = out.gl_ClipDistance[3]; + out.F_array_0 = F_array[0]; + out.F_array_1 = F_array[1]; + out.F_array_2 = F_array[2]; + out.F_array_3 = F_array[3]; + out.m_43_block0_0 = _43.block0[0]; + out.m_43_block0_1 = _43.block0[1]; + out.m_43_block0_2 = _43.block0[2]; + out.m_43_block0_3 = _43.block0[3]; + return out; +} + diff --git a/third_party/spirv-cross/reference/shaders-msl/vert/float-math.invariant-float-math.vert b/third_party/spirv-cross/reference/shaders-msl/vert/float-math.invariant-float-math.vert index 4b25e91b4553..802efa73cd04 100644 --- a/third_party/spirv-cross/reference/shaders-msl/vert/float-math.invariant-float-math.vert +++ b/third_party/spirv-cross/reference/shaders-msl/vert/float-math.invariant-float-math.vert @@ -80,13 +80,14 @@ template template [[clang::optnone]] matrix spvFMulMatrixMatrix(matrix l, matrix r) { + static_assert(LCols == RRows, "column-row configuration mismatch"); matrix res; for (uint i = 0; i < RCols; i++) { - vec tmp(0); + vec tmp(0); for (uint j = 0; j < LCols; j++) { - tmp = fma(vec(r[i][j]), l[j], tmp); + tmp = fma(vec(r[i][j]), l[j], tmp); } res[i] = tmp; } 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 index 26bef234e1fe..36d400ab4a2d 100644 --- a/third_party/spirv-cross/reference/shaders-msl/vert/no-contraction.vert +++ b/third_party/spirv-cross/reference/shaders-msl/vert/no-contraction.vert @@ -41,13 +41,14 @@ template template [[clang::optnone]] matrix spvFMulMatrixMatrix(matrix l, matrix r) { + static_assert(LCols == RRows, "column-row configuration mismatch"); matrix res; for (uint i = 0; i < RCols; i++) { - vec tmp(0); + vec tmp(0); for (uint j = 0; j < LCols; j++) { - tmp = fma(vec(r[i][j]), l[j], tmp); + tmp = fma(vec(r[i][j]), l[j], tmp); } res[i] = tmp; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/cfg-selection-to-unreachable-access-after-merge.vk.nocompat.asm.spv16.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/cfg-selection-to-unreachable-access-after-merge.vk.nocompat.asm.spv16.comp.vk new file mode 100644 index 000000000000..3d8d06c75c8e --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/cfg-selection-to-unreachable-access-after-merge.vk.nocompat.asm.spv16.comp.vk @@ -0,0 +1,65 @@ +#version 450 +#extension GL_EXT_shader_explicit_arithmetic_types_int8 : require +#extension GL_EXT_shader_8bit_storage : require +#extension GL_KHR_shader_subgroup_vote : require +layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; + +bool _42; + +layout(set = 0, binding = 1, std430) buffer Out +{ + uint _m0[]; +} Out_1; + +layout(set = 0, binding = 0, r32ui) uniform readonly uimageBuffer value; + +void main() +{ + uint8_t _str[6] = uint8_t[](uint8_t(118), uint8_t(97), uint8_t(108), uint8_t(117), uint8_t(101), uint8_t(0)); + uint8_t _str_2[4] = uint8_t[](uint8_t(79), uint8_t(117), uint8_t(116), uint8_t(0)); + bool _62; + bool _63; + if (true) + { + bool _58; + uint _59; + switch (imageLoad(value, int(gl_GlobalInvocationID.x)).x) + { + case 0u: + { + _58 = _42; + _59 = 0u; + break; + } + case 2u: + { + _58 = _42; + _59 = 0u; + break; + } + default: + { + _58 = subgroupAny(false); + _59 = 1u; + break; + } + } + if (0u == _59) + { + _62 = true; + _63 = subgroupAny(false); + } + else + { + _62 = false; + _63 = _58; + } + } + else + { + } + Out_1._m0[gl_GlobalInvocationID.x] = uint(_63); + Out_1._m0[gl_GlobalInvocationID.x + 4u] = uint(subgroupAny(_62)); + return; +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/bda-aliasing.asm.spv16.vk.nocompat.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/bda-aliasing.asm.spv16.vk.nocompat.comp.vk new file mode 100644 index 000000000000..eafc9b27f865 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/bda-aliasing.asm.spv16.vk.nocompat.comp.vk @@ -0,0 +1,30 @@ +#version 450 +#if defined(GL_ARB_gpu_shader_int64) +#extension GL_ARB_gpu_shader_int64 : require +#else +#error No extension available for 64-bit integers. +#endif +#extension GL_EXT_buffer_reference2 : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(buffer_reference) buffer uintPointer; + +layout(buffer_reference, buffer_reference_align = 4) buffer uintPointer +{ + uint value; +}; + +layout(push_constant, std430) uniform _3_2 +{ + uint64_t _m0; + uint64_t _m1; + uint64_t _m2; +} _2; + +void main() +{ + uint _19 = uintPointer(_2._m0).value; + uintPointer(_2._m1).value = 99u; + uintPointer(_2._m2).value = _19; +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-synthesized-pointer-to-pointer.asm.nocompat.vk.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-synthesized-pointer-to-pointer.asm.nocompat.vk.comp.vk index 5ba9cc9687f1..d0f1e4c8f8cd 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-synthesized-pointer-to-pointer.asm.nocompat.vk.comp.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/buffer-reference-synthesized-pointer-to-pointer.asm.nocompat.vk.comp.vk @@ -27,7 +27,8 @@ layout(push_constant, std430) uniform _6_14 void main() { - uintPointer _4 = uintPointerPointer(_14._m0).value; + uintPointer _24 = uintPointerPointer(_14._m0).value; + uintPointer _4 = _24; _4.value = 20u; } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/fuzz-collapse-degenerate-loop.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/fuzz-collapse-degenerate-loop.asm.comp index 5a5f212faae6..7b23a20a81f9 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/fuzz-collapse-degenerate-loop.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/fuzz-collapse-degenerate-loop.asm.comp @@ -28,8 +28,9 @@ void main() _10._m0[_34] = 9u; _34++; uint _44 = _35; + uint _46 = _8._m0[_44]; _35 = _44 + 1u; - if (_8._m0[_44] == 1u) + if (_46 == 1u) { _10._m0[_34] = 12u; _34++; diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id-override.vk.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id-override.vk.asm.comp index 3a4f5db12199..892b2171eba6 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id-override.vk.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id-override.vk.asm.comp @@ -6,6 +6,8 @@ #ifndef SPIRV_CROSS_CONSTANT_ID_2 #define SPIRV_CROSS_CONSTANT_ID_2 12u #endif +layout(local_size_x = 3, local_size_y = SPIRV_CROSS_CONSTANT_ID_1, local_size_z = SPIRV_CROSS_CONSTANT_ID_2) in; + #ifndef SPIRV_CROSS_CONSTANT_ID_3 #define SPIRV_CROSS_CONSTANT_ID_3 13u #endif @@ -15,8 +17,6 @@ const uint _6 = SPIRV_CROSS_CONSTANT_ID_3; #endif const uint _7 = SPIRV_CROSS_CONSTANT_ID_4; -layout(local_size_x = 3, local_size_y = SPIRV_CROSS_CONSTANT_ID_1, local_size_z = SPIRV_CROSS_CONSTANT_ID_2) in; - layout(binding = 0, std430) buffer SSBO { vec4 values[]; diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id.vk.invalid.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id.vk.invalid.asm.comp index ae6c1f3965fe..fec4cbdabe43 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id.vk.invalid.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/local-size-id.vk.invalid.asm.comp @@ -14,11 +14,11 @@ const int _13 = SPIRV_CROSS_CONSTANT_ID_2; #ifndef SPIRV_CROSS_CONSTANT_ID_4 #define SPIRV_CROSS_CONSTANT_ID_4 14 #endif +layout(local_size_x = SPIRV_CROSS_CONSTANT_ID_3, local_size_y = SPIRV_CROSS_CONSTANT_ID_4, local_size_z = 2) in; + const uint _37 = (uint(int(gl_WorkGroupSize.x)) + 3u); const uvec3 _38 = uvec3(_37, int(gl_WorkGroupSize.y), 2u); -layout(local_size_x = SPIRV_CROSS_CONSTANT_ID_3, local_size_y = SPIRV_CROSS_CONSTANT_ID_4, local_size_z = 2) in; - layout(binding = 0, std430) buffer SSBO { vec4 values[]; diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/long-vector-odd-type-cast.asm.vk.nocompat.spv16.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/long-vector-odd-type-cast.asm.vk.nocompat.spv16.comp.vk new file mode 100644 index 000000000000..23e28c36fe17 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/long-vector-odd-type-cast.asm.vk.nocompat.spv16.comp.vk @@ -0,0 +1,17 @@ +#version 450 +#extension GL_EXT_long_vector : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(set = 0, binding = 0, std430) buffer SSBO430 +{ + vector v5; +} s430; + +void main() +{ + vector v5 = s430.v5; + vector _27 = vector(vector(v5)); + s430.v5 = uintBitsToFloat(_27); + s430.v5 = vector(vector(_27)); +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/long-vector-ssa.asm.vk.nocompat.spv16.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/long-vector-ssa.asm.vk.nocompat.spv16.comp.vk new file mode 100644 index 000000000000..e6bc6efb6ee1 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/long-vector-ssa.asm.vk.nocompat.spv16.comp.vk @@ -0,0 +1,25 @@ +#version 450 +#extension GL_EXT_long_vector : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(set = 0, binding = 0, std430) buffer SSBO430 +{ + vector v5; +} s430; + +void main() +{ + vector v5 = s430.v5; + vector _26 = v5 * v5; + vector _30 = _26; + _30[0] = 2.0; + vector _31 = _30; + _31[4] = 2.0; + vector _37 = _30; + _37[3] = (v5[0] + v5[4]) + (vector(0))[2]; + s430.v5 = vector(v5[0], _26[0], _26[4], v5[4], v5[3]); + s430.v5 = vector(v5[0], v5[1], v5[2], v5[3], v5[4]); + s430.v5 = vector(v5[0], (vector(0))[0], v5[2], (vector(0))[1], v5[4]); + s430.v5 = _37; +} + 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 fdc65be27f6c..cacabcdf951b 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 @@ -2,6 +2,7 @@ #extension GL_EXT_buffer_reference2 : require #extension GL_EXT_nonuniform_qualifier : require #extension GL_KHR_shader_subgroup_ballot : require +#extension GL_EXT_samplerless_texture_functions : require layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; layout(set = 0, binding = 0, std430) restrict readonly buffer SSBO_Offsets diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/storage-buffer-basic.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/storage-buffer-basic.asm.comp index fcbd85047ef5..0df11af883cd 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/storage-buffer-basic.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/storage-buffer-basic.asm.comp @@ -6,9 +6,9 @@ #ifndef SPIRV_CROSS_CONSTANT_ID_2 #define SPIRV_CROSS_CONSTANT_ID_2 3u #endif - layout(local_size_x = SPIRV_CROSS_CONSTANT_ID_0, local_size_y = 2, local_size_z = SPIRV_CROSS_CONSTANT_ID_2) in; + layout(binding = 0, std430) buffer _3_20 { float _m0[]; diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/temorary-access-terminator.vk.nocompat.asm.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/temorary-access-terminator.vk.nocompat.asm.comp.vk index 63fa0e65b206..9ced776b65c4 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/temorary-access-terminator.vk.nocompat.asm.comp.vk +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/temorary-access-terminator.vk.nocompat.asm.comp.vk @@ -1,5 +1,6 @@ #version 450 #extension GL_KHR_shader_subgroup_ballot : require +#extension GL_EXT_samplerless_texture_functions : require layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; layout(set = 0, binding = 0) uniform usamplerBuffer _8; diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/volatile-phys-buf-load-no-forward.nocompat.vk.asm.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/volatile-phys-buf-load-no-forward.nocompat.vk.asm.comp.vk new file mode 100644 index 000000000000..ceb86a1722b0 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/comp/volatile-phys-buf-load-no-forward.nocompat.vk.asm.comp.vk @@ -0,0 +1,30 @@ +#version 450 +#if defined(GL_ARB_gpu_shader_int64) +#extension GL_ARB_gpu_shader_int64 : require +#else +#error No extension available for 64-bit integers. +#endif +#extension GL_EXT_buffer_reference2 : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(buffer_reference) buffer intPointer; + +layout(buffer_reference, buffer_reference_align = 4) buffer intPointer +{ + int value; +}; + +layout(push_constant, std430) uniform Registers +{ + uint64_t addr; + uint64_t addr2; +} registers; + +void main() +{ + intPointer _21 = intPointer(registers.addr2); + int _22 = intPointer(registers.addr).value; + _21.value = _22; + intPointer(uint64_t(_21) + 4ul).value = _22; +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-hazard-tracking.vk.nocompat.asm.spv16.frag.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-hazard-tracking.vk.nocompat.asm.spv16.frag.vk new file mode 100644 index 000000000000..17399b9f7876 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-hazard-tracking.vk.nocompat.asm.spv16.frag.vk @@ -0,0 +1,26 @@ +#version 460 +#extension GL_EXT_descriptor_heap : require +#extension GL_EXT_nonuniform_qualifier : require +#extension GL_EXT_shader_image_load_formatted : require + +layout(location = 0) out float FragColor; +layout(descriptor_heap, std430) readonly buffer SSBONoWrite +{ + vec4 data[]; +} spvSSBONoWrite_9ResourceHeap[]; + +layout(descriptor_heap, std430) coherent buffer SSBOCoherent +{ + vec4 data[]; +} spvSSBOCoherent_10ResourceHeap[]; + + +void main() +{ + spvSSBOCoherent_10ResourceHeap[2].data[0].z = 0.0; + FragColor = spvSSBONoWrite_9ResourceHeap[2].data[2].z; + float _34 = spvSSBOCoherent_10ResourceHeap[2].data[0].z; + spvSSBOCoherent_10ResourceHeap[2].data[0].z = 0.0; + FragColor = _34; +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-hlsl-strides.spv16.asm.vk.nocompat.frag.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-hlsl-strides.spv16.asm.vk.nocompat.frag.vk new file mode 100644 index 000000000000..786562f7512c --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-hlsl-strides.spv16.asm.vk.nocompat.frag.vk @@ -0,0 +1,31 @@ +#version 460 +#extension GL_EXT_ray_query : require +#extension GL_EXT_descriptor_heap : require +#extension GL_EXT_nonuniform_qualifier : require +#extension GL_EXT_shader_image_load_formatted : require +#extension GL_EXT_samplerless_texture_functions : require + +const bool _56 = (uint(0) > uint(0)); +const int _13 = _56 ? 0 : 0; + +layout(location = 0) out vec4 FragColor; +rayQueryEXT rq; +layout(descriptor_heap) uniform texture1D spv_23ResourceHeap[]; +layout(descriptor_heap, std140) uniform UBO140 +{ + float data[2]; +} spvUBO140_42ResourceHeap[]; + +layout(descriptor_heap) uniform accelerationStructureEXT spv_51ResourceHeap[]; +// WARNING: HLSL style descriptor heap stride is assumed for one or more descriptors. Allowing for compatibility with HLSL shaders. +// This may be not strictly be compatible with GLSL if sizeof(buffer) != sizeof(image). +// Application side can convert bindless indices accordingly to compensate or use explicit mapping API to configure strides outside SPIRV-Cross. + +void main() +{ + FragColor = vec4(0.0); + FragColor += texelFetch(spv_23ResourceHeap[int(gl_FragCoord.x)], 0, 0); + FragColor += vec4(spvUBO140_42ResourceHeap[50].data[1]); + rayQueryInitializeEXT(rq, spv_51ResourceHeap[50], 0u, 0u, vec3(0.0), 0.0, vec3(1.0, 0.0, 0.0), 1.0); +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-multi-stage-chain-typed.vk.spv16.asm.nocompat.frag.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-multi-stage-chain-typed.vk.spv16.asm.nocompat.frag.vk new file mode 100644 index 000000000000..b11b7ccf35dd --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-multi-stage-chain-typed.vk.spv16.asm.nocompat.frag.vk @@ -0,0 +1,23 @@ +#version 460 +#extension GL_EXT_descriptor_heap : require +#extension GL_EXT_nonuniform_qualifier : require +#extension GL_EXT_shader_image_load_formatted : require + +layout(location = 0) out float FragColor; +layout(descriptor_heap, std430) readonly buffer SSBONoWrite +{ + vec4 data[]; +} spvSSBONoWrite_9ResourceHeap[]; + +layout(descriptor_heap, std430) writeonly buffer SSBONoRead +{ + vec4 data[]; +} spvSSBONoRead_10ResourceHeap[]; + + +void main() +{ + spvSSBONoRead_10ResourceHeap[2].data[0].z = spvSSBONoWrite_9ResourceHeap[2].data[2].z; + FragColor = spvSSBONoWrite_9ResourceHeap[2].data[2].z; +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-multi-stage-chain-untyped.vk.spv16.asm.nocompat.frag.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-multi-stage-chain-untyped.vk.spv16.asm.nocompat.frag.vk new file mode 100644 index 000000000000..b11b7ccf35dd --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-multi-stage-chain-untyped.vk.spv16.asm.nocompat.frag.vk @@ -0,0 +1,23 @@ +#version 460 +#extension GL_EXT_descriptor_heap : require +#extension GL_EXT_nonuniform_qualifier : require +#extension GL_EXT_shader_image_load_formatted : require + +layout(location = 0) out float FragColor; +layout(descriptor_heap, std430) readonly buffer SSBONoWrite +{ + vec4 data[]; +} spvSSBONoWrite_9ResourceHeap[]; + +layout(descriptor_heap, std430) writeonly buffer SSBONoRead +{ + vec4 data[]; +} spvSSBONoRead_10ResourceHeap[]; + + +void main() +{ + spvSSBONoRead_10ResourceHeap[2].data[0].z = spvSSBONoWrite_9ResourceHeap[2].data[2].z; + FragColor = spvSSBONoWrite_9ResourceHeap[2].data[2].z; +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-nonwritable-nonreadable-alias.vk.nocompat.asm.spv16.frag.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-nonwritable-nonreadable-alias.vk.nocompat.asm.spv16.frag.vk new file mode 100644 index 000000000000..bc9bc6950ca9 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-nonwritable-nonreadable-alias.vk.nocompat.asm.spv16.frag.vk @@ -0,0 +1,24 @@ +#version 460 +#extension GL_EXT_descriptor_heap : require +#extension GL_EXT_nonuniform_qualifier : require +#extension GL_EXT_shader_image_load_formatted : require + +layout(location = 0) out vec4 FragColor; +layout(descriptor_heap, std430) readonly buffer SSBONoWrite +{ + vec4 data[]; +} spvSSBONoWrite_9ResourceHeap[]; + +layout(descriptor_heap, std430) writeonly buffer SSBONoRead +{ + vec4 data[]; +} spvSSBONoRead_10ResourceHeap[]; + + +void main() +{ + FragColor = vec4(0.0); + spvSSBONoRead_10ResourceHeap[2].data[0] = spvSSBONoWrite_9ResourceHeap[2].data[2]; + FragColor = spvSSBONoWrite_9ResourceHeap[2].data[2]; +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-ssbo-atomic.asm.vk.nocompat.spv16.frag.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-ssbo-atomic.asm.vk.nocompat.spv16.frag.vk new file mode 100644 index 000000000000..2684a7985f80 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-ssbo-atomic.asm.vk.nocompat.spv16.frag.vk @@ -0,0 +1,24 @@ +#version 460 +#extension GL_EXT_descriptor_heap : require +#extension GL_EXT_nonuniform_qualifier : require +#extension GL_EXT_shader_image_load_formatted : require + +layout(descriptor_heap, std430) buffer SSBOAtomic +{ + uint data; + uint data2; +} spvSSBOAtomic_32ResourceHeap[]; + +layout(descriptor_heap, std430) buffer SSBOAtomic_1 +{ + uint data; + uint data2; +} spvSSBOAtomic_35ResourceHeap[]; + +void main() +{ + int desc_index = int(gl_FragCoord.x); + uint _34 = atomicAdd(spvSSBOAtomic_32ResourceHeap[desc_index].data2, 1u); + uint _37 = atomicAdd(spvSSBOAtomic_35ResourceHeap[desc_index].data2, 1u); +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-ssbo-atomic.heap-legacy-mapping.asm.vk.nocompat.spv16.frag.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-ssbo-atomic.heap-legacy-mapping.asm.vk.nocompat.spv16.frag.vk new file mode 100644 index 000000000000..4ca5db9fc2cc --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-ssbo-atomic.heap-legacy-mapping.asm.vk.nocompat.spv16.frag.vk @@ -0,0 +1,24 @@ +#version 460 +#extension GL_EXT_descriptor_heap : require +#extension GL_EXT_nonuniform_qualifier : require +#extension GL_EXT_shader_image_load_formatted : require + +layout(set = 1, binding = 2, std430) buffer SSBOAtomic +{ + uint data; + uint data2; +} spvSSBOAtomic_32ResourceHeap[]; + +layout(set = 1, binding = 2, std430) buffer SSBOAtomic_1 +{ + uint data; + uint data2; +} spvSSBOAtomic_35ResourceHeap[]; + +void main() +{ + int desc_index = int(gl_FragCoord.x); + uint _34 = atomicAdd(spvSSBOAtomic_32ResourceHeap[nonuniformEXT(desc_index)].data2, 1u); + uint _37 = atomicAdd(spvSSBOAtomic_35ResourceHeap[nonuniformEXT(desc_index)].data2, 1u); +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-typed-buffer-pointer.asm.vk.nocompat.spv16.frag.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-typed-buffer-pointer.asm.vk.nocompat.spv16.frag.vk new file mode 100644 index 000000000000..38ffe462ec96 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-typed-buffer-pointer.asm.vk.nocompat.spv16.frag.vk @@ -0,0 +1,18 @@ +#version 460 +#extension GL_EXT_descriptor_heap : require +#extension GL_EXT_nonuniform_qualifier : require +#extension GL_EXT_shader_image_load_formatted : require + +layout(location = 0) out vec4 FragColor; +layout(descriptor_heap, std430) buffer SSBO +{ + vec4 data[]; +} spvSSBO_23ResourceHeap[]; + + +void main() +{ + FragColor = vec4(0.0); + FragColor = spvSSBO_23ResourceHeap[2].data[2] + vec4(float(int(uint(spvSSBO_23ResourceHeap[2].data.length())))); +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-untyped-array-length.asm.vk.nocompat.spv16.frag.vk b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-untyped-array-length.asm.vk.nocompat.spv16.frag.vk new file mode 100644 index 000000000000..4fbbdfe95fc0 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/frag/descriptor-heap-untyped-array-length.asm.vk.nocompat.spv16.frag.vk @@ -0,0 +1,18 @@ +#version 460 +#extension GL_EXT_descriptor_heap : require +#extension GL_EXT_nonuniform_qualifier : require +#extension GL_EXT_shader_image_load_formatted : require + +layout(location = 0) out vec4 FragColor; +layout(descriptor_heap, std430) buffer SSBO +{ + vec4 data[]; +} spvSSBO_23ResourceHeap[]; + + +void main() +{ + FragColor = vec4(0.0); + FragColor += vec4(float(int(uint(spvSSBO_23ResourceHeap[2].data.length())))); +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/asm/loop-header-self-continue-break.asm.comp b/third_party/spirv-cross/reference/shaders-no-opt/asm/loop-header-self-continue-break.asm.comp index 429ed5f707a0..f2fea7d839aa 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/asm/loop-header-self-continue-break.asm.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/asm/loop-header-self-continue-break.asm.comp @@ -9,9 +9,9 @@ #ifndef SPIRV_CROSS_CONSTANT_ID_2 #define SPIRV_CROSS_CONSTANT_ID_2 1u #endif - layout(local_size_x = SPIRV_CROSS_CONSTANT_ID_0, local_size_y = SPIRV_CROSS_CONSTANT_ID_1, local_size_z = SPIRV_CROSS_CONSTANT_ID_2) in; + layout(binding = 0, std430) buffer _3_15 { float _m0[]; diff --git a/third_party/spirv-cross/reference/shaders-no-opt/comp/integer-dot-product.comp b/third_party/spirv-cross/reference/shaders-no-opt/comp/integer-dot-product.comp new file mode 100644 index 000000000000..847874e3b5fd --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/comp/integer-dot-product.comp @@ -0,0 +1,127 @@ +#version 450 +#if defined(GL_EXT_shader_explicit_arithmetic_types_int16) +#extension GL_EXT_shader_explicit_arithmetic_types_int16 : require +#elif 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 +#if defined(GL_EXT_shader_explicit_arithmetic_types_int8) +#extension GL_EXT_shader_explicit_arithmetic_types_int8 : require +#elif defined(GL_NV_gpu_shader5) +#extension GL_NV_gpu_shader5 : require +#else +#error No extension available for Int8. +#endif +#extension GL_EXT_spirv_intrinsics : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(binding = 1, std430) buffer InOut3 +{ + u16vec4 x; + u16vec4 y; + int acc; + int result; +} comp3; + +layout(binding = 1, std430) buffer InOut2 +{ + uint x; + uint y; + uint result; +} comp2; + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4450) +int spvSDot_int_u16vec4_u16vec4(u16vec4 arg0, u16vec4 arg1); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4450) +uint spvSDot_uint_u16vec4_u16vec4(u16vec4 arg0, u16vec4 arg1); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4451) +uint spvUDot_uint_u16vec4_u16vec4(u16vec4 arg0, u16vec4 arg1); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4452) +int spvSUDot_int_u16vec4_u16vec4(u16vec4 arg0, u16vec4 arg1); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4452) +uint spvSUDot_uint_u16vec4_u16vec4(u16vec4 arg0, u16vec4 arg1); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4450) +uint8_t spvSDot_uint8_t_uint_uint(uint arg0, uint arg1, spirv_literal uint packedFormat); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4450) +uint16_t spvSDot_uint16_t_uint_uint(uint arg0, uint arg1, spirv_literal uint packedFormat); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4450) +uint spvSDot_uint_uint_uint(uint arg0, uint arg1, spirv_literal uint packedFormat); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4450) +int spvSDot_int_uint_uint(uint arg0, uint arg1, spirv_literal uint packedFormat); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4451) +uint8_t spvUDot_uint8_t_uint_uint(uint arg0, uint arg1, spirv_literal uint packedFormat); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4451) +uint16_t spvUDot_uint16_t_uint_uint(uint arg0, uint arg1, spirv_literal uint packedFormat); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4451) +uint spvUDot_uint_uint_uint(uint arg0, uint arg1, spirv_literal uint packedFormat); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4452) +uint8_t spvSUDot_uint8_t_uint_uint(uint arg0, uint arg1, spirv_literal uint packedFormat); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4452) +uint16_t spvSUDot_uint16_t_uint_uint(uint arg0, uint arg1, spirv_literal uint packedFormat); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4452) +uint spvSUDot_uint_uint_uint(uint arg0, uint arg1, spirv_literal uint packedFormat); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4452) +int spvSUDot_int_uint_uint(uint arg0, uint arg1, spirv_literal uint packedFormat); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4453) +int spvSDotAccSat_int_u16vec4_u16vec4(u16vec4 arg0, u16vec4 arg1, int); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4453) +uint spvSDotAccSat_uint_u16vec4_u16vec4(u16vec4 arg0, u16vec4 arg1, uint); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4454) +uint spvUDotAccSat_uint_u16vec4_u16vec4(u16vec4 arg0, u16vec4 arg1, uint); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4455) +int spvSUDotAccSat_int_u16vec4_u16vec4(u16vec4 arg0, u16vec4 arg1, int); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4455) +uint spvSUDotAccSat_uint_u16vec4_u16vec4(u16vec4 arg0, u16vec4 arg1, uint); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4454) +uint spvUDotAccSat_uint_uint_uint(uint arg0, uint arg1, uint, spirv_literal uint packedFormat); + +void main() +{ + int sdot_int = spvSDot_int_u16vec4_u16vec4(comp3.x, comp3.y); + uint sdot_uint = spvSDot_uint_u16vec4_u16vec4(comp3.x, comp3.y); + uint udot_uint = spvUDot_uint_u16vec4_u16vec4(comp3.x, comp3.y); + int sudot_int = spvSUDot_int_u16vec4_u16vec4(comp3.x, comp3.y); + uint sudot_uint = spvSUDot_uint_u16vec4_u16vec4(comp3.x, comp3.y); + uint8_t spdot8 = spvSDot_uint8_t_uint_uint(comp2.x, comp2.y, 0); + uint16_t spdot16 = spvSDot_uint16_t_uint_uint(comp2.x, comp2.y, 0); + uint spdot32 = spvSDot_uint_uint_uint(comp2.x, comp2.y, 0); + int spdoti32 = spvSDot_int_uint_uint(comp2.x, comp2.y, 0); + uint8_t updot8 = spvUDot_uint8_t_uint_uint(comp2.x, comp2.y, 0); + uint16_t updot16 = spvUDot_uint16_t_uint_uint(comp2.x, comp2.y, 0); + uint updot32 = spvUDot_uint_uint_uint(comp2.x, comp2.y, 0); + uint8_t supdot8 = spvSUDot_uint8_t_uint_uint(comp2.x, comp2.y, 0); + uint16_t supdot16 = spvSUDot_uint16_t_uint_uint(comp2.x, comp2.y, 0); + uint supdot32 = spvSUDot_uint_uint_uint(comp2.x, comp2.y, 0); + int supdoti32 = spvSUDot_int_uint_uint(comp2.x, comp2.y, 0); + int sdotaddsat_int = spvSDotAccSat_int_u16vec4_u16vec4(comp3.x, comp3.y, comp3.acc); + uint sdotaddsat_uint = spvSDotAccSat_uint_u16vec4_u16vec4(comp3.x, comp3.y, uint(comp3.acc)); + uint udotaddsat_uint = spvUDotAccSat_uint_u16vec4_u16vec4(comp3.x, comp3.y, uint(comp3.acc)); + int sudotaddsat_int = spvSUDotAccSat_int_u16vec4_u16vec4(comp3.x, comp3.y, comp3.acc); + uint sudotaddsat_uint = spvSUDotAccSat_uint_u16vec4_u16vec4(comp3.x, comp3.y, uint(comp3.acc)); + uint udotaddsat_pack = spvUDotAccSat_uint_uint_uint(comp2.x, comp2.y, uint(comp3.acc), 0); +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/comp/loop-resolve-debug-semantics.gV.comp b/third_party/spirv-cross/reference/shaders-no-opt/comp/loop-resolve-debug-semantics.gV.comp index 3116e334ee11..01134fd8d354 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/comp/loop-resolve-debug-semantics.gV.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/comp/loop-resolve-debug-semantics.gV.comp @@ -4,13 +4,13 @@ layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; layout(binding = 0, std430) buffer SSBO { int v[]; -} _66; +} _43; void main() { for (int i = 0; i < 4; i++) { - _66.v[i] += 10; + _43.v[i] += 10; } } diff --git a/third_party/spirv-cross/reference/shaders-no-opt/comp/workgroup-size-spec-constant-array.comp b/third_party/spirv-cross/reference/shaders-no-opt/comp/workgroup-size-spec-constant-array.comp index 3b5f0434e850..976afccef667 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/comp/workgroup-size-spec-constant-array.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/comp/workgroup-size-spec-constant-array.comp @@ -8,14 +8,14 @@ const uint _20 = (uint(A) + 0u); #ifndef SPIRV_CROSS_CONSTANT_ID_0 #define SPIRV_CROSS_CONSTANT_ID_0 1u #endif +layout(local_size_x = SPIRV_CROSS_CONSTANT_ID_0, local_size_y = 1, local_size_z = 1) in; + const uint _25 = gl_WorkGroupSize.x; const uint _26 = (_20 * _25); const uint _30 = (uint(A) + 0u); const uint _31 = gl_WorkGroupSize.x; const uint _32 = (_30 * _31); -layout(local_size_x = SPIRV_CROSS_CONSTANT_ID_0, local_size_y = 1, local_size_z = 1) in; - layout(binding = 0, std430) buffer SSBO { int I; diff --git a/third_party/spirv-cross/reference/shaders-no-opt/comp/workgroup-size-spec-constant-array.spv16.comp b/third_party/spirv-cross/reference/shaders-no-opt/comp/workgroup-size-spec-constant-array.spv16.comp index 8c21039b46d1..45e00a2eceed 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/comp/workgroup-size-spec-constant-array.spv16.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/comp/workgroup-size-spec-constant-array.spv16.comp @@ -3,6 +3,8 @@ #ifndef SPIRV_CROSS_CONSTANT_ID_0 #define SPIRV_CROSS_CONSTANT_ID_0 1u #endif +layout(local_size_x = SPIRV_CROSS_CONSTANT_ID_0, local_size_y = 1, local_size_z = 1) in; + #ifndef SPIRV_CROSS_CONSTANT_ID_1 #define SPIRV_CROSS_CONSTANT_ID_1 2 #endif @@ -19,8 +21,6 @@ const uint _31 = (uint(A) + 0u); const uint _32 = _25.x; const uint _33 = (_31 * _32); -layout(local_size_x = SPIRV_CROSS_CONSTANT_ID_0, local_size_y = 1, local_size_z = 1) in; - layout(binding = 0, std430) buffer SSBO { int I; diff --git a/third_party/spirv-cross/reference/shaders-no-opt/comp/workgroup-size-spec-constant-array.vk.comp b/third_party/spirv-cross/reference/shaders-no-opt/comp/workgroup-size-spec-constant-array.vk.comp index 0e83b230cf8e..828bd316f6d7 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/comp/workgroup-size-spec-constant-array.vk.comp +++ b/third_party/spirv-cross/reference/shaders-no-opt/comp/workgroup-size-spec-constant-array.vk.comp @@ -8,14 +8,14 @@ const uint _20 = (uint(A) + 0u); #ifndef SPIRV_CROSS_CONSTANT_ID_0 #define SPIRV_CROSS_CONSTANT_ID_0 1u #endif +layout(local_size_x = SPIRV_CROSS_CONSTANT_ID_0, local_size_y = 1, local_size_z = 1) in; + const uint _25 = gl_WorkGroupSize.x; const uint _26 = (_20 * _25); const uint _30 = (uint(A) + 0u); const uint _31 = gl_WorkGroupSize.x; const uint _32 = (_30 * _31); -layout(local_size_x = SPIRV_CROSS_CONSTANT_ID_0, local_size_y = 1, local_size_z = 1) in; - layout(binding = 0, std430) buffer SSBO { int I; diff --git a/third_party/spirv-cross/reference/shaders-no-opt/frag/conservative-depth-es.frag b/third_party/spirv-cross/reference/shaders-no-opt/frag/conservative-depth-es.frag new file mode 100644 index 000000000000..866b0ebd98ca --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/frag/conservative-depth-es.frag @@ -0,0 +1,11 @@ +#version 310 es +#extension GL_EXT_conservative_depth : require +precision mediump float; +precision highp int; +layout(depth_greater) out highp float gl_FragDepth; + +void main() +{ + gl_FragDepth = 1.0; +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/frag/conservative-depth.frag b/third_party/spirv-cross/reference/shaders-no-opt/frag/conservative-depth.frag new file mode 100644 index 000000000000..b6f846afba0b --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/frag/conservative-depth.frag @@ -0,0 +1,9 @@ +#version 450 +#extension GL_ARB_conservative_depth : require +layout(depth_greater) out float gl_FragDepth; + +void main() +{ + gl_FragDepth = 1.0; +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/frag/fp16.invalid.desktop.frag b/third_party/spirv-cross/reference/shaders-no-opt/frag/fp16.invalid.desktop.frag index 30f219e9f6f4..a2d32c07b120 100644 --- a/third_party/spirv-cross/reference/shaders-no-opt/frag/fp16.invalid.desktop.frag +++ b/third_party/spirv-cross/reference/shaders-no-opt/frag/fp16.invalid.desktop.frag @@ -98,10 +98,10 @@ void test_builtins() res = ceil(v4); res = fract(v4); res = mod(v4, v4); - ResType _232; - _232._m0 = modf(v4, _232._m1); - f16vec4 tmp = _232._m1; - res = _232._m0; + ResType _230; + _230._m0 = modf(v4, _230._m1); + f16vec4 tmp = _230._m1; + res = _230._m0; res = min(v4, v4); res = max(v4, v4); res = clamp(v4, v4, v4); @@ -112,10 +112,10 @@ void test_builtins() bvec4 btmp = isnan(v4); btmp = isinf(v4); res = fma(v4, v4, v4); - ResType_1 _278; - _278._m0 = frexp(v4, _278._m1); - ivec4 itmp = _278._m1; - res = _278._m0; + ResType_1 _276; + _276._m0 = frexp(v4, _276._m1); + ivec4 itmp = _276._m1; + res = _276._m0; res = ldexp(res, itmp); uint pack0 = packFloat2x16(v4.xy); uint pack1 = packFloat2x16(v4.zw); diff --git a/third_party/spirv-cross/reference/shaders-no-opt/vulkan/comp/shared-explicit-layout.vk.nocompat.spv14.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/vulkan/comp/shared-explicit-layout.vk.nocompat.spv14.comp.vk new file mode 100644 index 000000000000..f21c9fc66502 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/vulkan/comp/shared-explicit-layout.vk.nocompat.spv14.comp.vk @@ -0,0 +1,20 @@ +#version 450 +#extension GL_EXT_shared_memory_block : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(std430) shared SharedMemoryBlockA +{ + uint a; +} _9; + +layout(std430) shared SharedMemoryBlockB +{ + layout(offset = 4) uint b; +} _17; + +void main() +{ + _9.a = 6u; + _17.b = 7u; +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/vulkan/comp/shared-explicit-scalar-layout.vk.nocompat.spv14.comp.vk b/third_party/spirv-cross/reference/shaders-no-opt/vulkan/comp/shared-explicit-scalar-layout.vk.nocompat.spv14.comp.vk new file mode 100644 index 000000000000..0506bfa9d099 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/vulkan/comp/shared-explicit-scalar-layout.vk.nocompat.spv14.comp.vk @@ -0,0 +1,21 @@ +#version 450 +#extension GL_EXT_shared_memory_block : require +#extension GL_EXT_scalar_block_layout : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(std430) shared SharedMemoryBlockA +{ + uint a; +} _9; + +layout(scalar) shared SharedMemoryBlockB +{ + layout(offset = 4) uvec3 b; +} _18; + +void main() +{ + _9.a = 6u; + _18.b = uvec3(1u, 2u, 3u); +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/vulkan/frag/descriptor-heap.heap-legacy-mapping.vk.nocompat.spv16.frag.vk b/third_party/spirv-cross/reference/shaders-no-opt/vulkan/frag/descriptor-heap.heap-legacy-mapping.vk.nocompat.spv16.frag.vk new file mode 100644 index 000000000000..0ec6eedc0888 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/vulkan/frag/descriptor-heap.heap-legacy-mapping.vk.nocompat.spv16.frag.vk @@ -0,0 +1,86 @@ +#version 460 +#extension GL_EXT_ray_query : require +#extension GL_EXT_descriptor_heap : require +#extension GL_EXT_nonuniform_qualifier : require +#extension GL_EXT_shader_image_load_formatted : require +#extension GL_EXT_scalar_block_layout : require +#extension GL_EXT_samplerless_texture_functions : require + +layout(location = 0) out vec4 FragColor; +rayQueryEXT rq; +layout(set = 1, binding = 2) uniform texture1D spv_25ResourceHeap[]; +layout(set = 1, binding = 2) uniform texture2D spv_36ResourceHeap[]; +layout(set = 1, binding = 2) uniform texture3D spv_49ResourceHeap[]; +layout(set = 1, binding = 2) uniform sampler spv_68SamplerHeap[]; +layout(set = 1, binding = 2, r32f) writeonly uniform image1D spvWriteImages1D_heapResourceHeap[]; +layout(set = 1, binding = 2, r32f) writeonly uniform image2D spvWriteImages2D_heapResourceHeap[]; +layout(set = 1, binding = 2, r32f) writeonly uniform image3D spvWriteImages3D_heapResourceHeap[]; +layout(set = 1, binding = 2, r32f) readonly uniform image1D spvRWriteImages1D_heapResourceHeap[]; +layout(set = 1, binding = 2, r32f) readonly uniform image2D spvRWriteImages2D_heapResourceHeap[]; +layout(set = 1, binding = 2, r32f) readonly uniform image3D spvRWriteImages3D_heapResourceHeap[]; +layout(set = 1, binding = 2) uniform image2D spv_164ResourceHeap[]; +layout(set = 1, binding = 2, std140) uniform UBO140 +{ + float data[2]; +} spvUBO140_186ResourceHeap[]; + +layout(set = 1, binding = 2, std140) uniform UBO430 +{ + vec3 data[2]; +} spvUBO430_201ResourceHeap[]; + +layout(set = 1, binding = 2, scalar) uniform UBOScalar +{ + vec3 data[2]; +} spvUBOScalar_215ResourceHeap[]; + +layout(set = 1, binding = 2, std430) readonly buffer SSBOReadOnlyNoWrite +{ + vec4 data; +} spvSSBOReadOnlyNoWrite_230ResourceHeap[]; + +layout(set = 1, binding = 2, std430) coherent writeonly buffer SSBOWriteOnlyNoRead +{ + vec4 data; +} spvSSBOWriteOnlyNoRead_245ResourceHeap[]; + +layout(set = 1, binding = 2, std430) buffer SSBO +{ + vec4 data; +} spvSSBO_254ResourceHeap[]; + +layout(set = 1, binding = 2, r32ui) uniform uimage2D spv_259ResourceHeap[]; +layout(set = 1, binding = 2) uniform accelerationStructureEXT spv_274ResourceHeap[]; + +void main() +{ + FragColor = vec4(0.0); + int desc_index = int(gl_FragCoord.x); + FragColor += texelFetch(spv_25ResourceHeap[nonuniformEXT(desc_index + 0)], 0, 0); + FragColor += texelFetch(spv_36ResourceHeap[nonuniformEXT(desc_index + 1)], ivec2(0), 0); + FragColor += texelFetch(spv_49ResourceHeap[nonuniformEXT(desc_index + 2)], ivec3(0), 0); + FragColor += texture(nonuniformEXT(sampler2D(spv_36ResourceHeap[int(gl_FragCoord.x)], spv_68SamplerHeap[int(gl_FragCoord.y)])), vec2(0.0), 0.0); + FragColor += vec4(texture(nonuniformEXT(sampler2DShadow(spv_36ResourceHeap[int(gl_FragCoord.x)], spv_68SamplerHeap[int(gl_FragCoord.y)])), vec3(vec3(0.0).xy, 0.0), 0.0)); + imageStore(spvWriteImages1D_heapResourceHeap[nonuniformEXT(desc_index + 3)], 0, FragColor); + imageStore(spvWriteImages2D_heapResourceHeap[nonuniformEXT(desc_index + 4)], ivec2(0), FragColor); + imageStore(spvWriteImages3D_heapResourceHeap[nonuniformEXT(desc_index + 5)], ivec3(0), FragColor); + FragColor += imageLoad(spvRWriteImages1D_heapResourceHeap[nonuniformEXT(desc_index + 6)], 0); + FragColor += imageLoad(spvRWriteImages2D_heapResourceHeap[nonuniformEXT(desc_index + 7)], ivec2(0)); + FragColor += imageLoad(spvRWriteImages3D_heapResourceHeap[nonuniformEXT(desc_index + 8)], ivec3(0)); + FragColor += imageLoad(spv_164ResourceHeap[nonuniformEXT(desc_index + 9)], ivec2(0)); + int _180 = desc_index + 10; + FragColor += vec4(spvUBO140_186ResourceHeap[nonuniformEXT(_180)].data[1]); + int _196 = desc_index + 11; + FragColor += vec4(spvUBO430_201ResourceHeap[nonuniformEXT(_196)].data[1].x); + int _210 = desc_index + 12; + FragColor += vec4(spvUBOScalar_215ResourceHeap[nonuniformEXT(_210)].data[1].x); + int _226 = desc_index + 13; + FragColor += spvSSBOReadOnlyNoWrite_230ResourceHeap[nonuniformEXT(_226)].data; + int _239 = desc_index + 14; + spvSSBOWriteOnlyNoRead_245ResourceHeap[nonuniformEXT(_239)].data = vec4(20.0); + int _250 = desc_index + 15; + FragColor += spvSSBO_254ResourceHeap[nonuniformEXT(_250)].data; + uint _270 = imageAtomicAdd(spv_259ResourceHeap[nonuniformEXT(desc_index + 16)], ivec2(0), 50u); + rayQueryInitializeEXT(rq, spv_274ResourceHeap[nonuniformEXT(desc_index + 17)], 0u, 0u, vec3(0.0), 0.0, vec3(1.0, 0.0, 0.0), 1.0); +} + diff --git a/third_party/spirv-cross/reference/shaders-no-opt/vulkan/frag/descriptor-heap.vk.nocompat.spv16.frag.vk b/third_party/spirv-cross/reference/shaders-no-opt/vulkan/frag/descriptor-heap.vk.nocompat.spv16.frag.vk new file mode 100644 index 000000000000..e348ccc56a32 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders-no-opt/vulkan/frag/descriptor-heap.vk.nocompat.spv16.frag.vk @@ -0,0 +1,79 @@ +#version 460 +#extension GL_EXT_ray_query : require +#extension GL_EXT_descriptor_heap : require +#extension GL_EXT_nonuniform_qualifier : require +#extension GL_EXT_shader_image_load_formatted : require +#extension GL_EXT_scalar_block_layout : require +#extension GL_EXT_samplerless_texture_functions : require + +layout(location = 0) out vec4 FragColor; +rayQueryEXT rq; +layout(descriptor_heap) uniform texture1D spv_14ResourceHeap[]; +layout(descriptor_heap) uniform texture2D spv_32ResourceHeap[]; +layout(descriptor_heap) uniform texture3D spv_45ResourceHeap[]; +layout(descriptor_heap) uniform sampler spv_64SamplerHeap[]; +layout(descriptor_heap, r32f) writeonly uniform image1D spvWriteImages1D_heapResourceHeap[]; +layout(descriptor_heap, r32f) writeonly uniform image2D spvWriteImages2D_heapResourceHeap[]; +layout(descriptor_heap, r32f) writeonly uniform image3D spvWriteImages3D_heapResourceHeap[]; +layout(descriptor_heap, r32f) readonly uniform image1D spvRWriteImages1D_heapResourceHeap[]; +layout(descriptor_heap, r32f) readonly uniform image2D spvRWriteImages2D_heapResourceHeap[]; +layout(descriptor_heap, r32f) readonly uniform image3D spvRWriteImages3D_heapResourceHeap[]; +layout(descriptor_heap) uniform image2D spv_145ResourceHeap[]; +layout(descriptor_heap, std140) uniform UBO140 +{ + float data[2]; +} spvUBO140_164ResourceHeap[]; + +layout(descriptor_heap, std140) uniform UBO430 +{ + vec3 data[2]; +} spvUBO430_177ResourceHeap[]; + +layout(descriptor_heap, scalar) uniform UBOScalar +{ + vec3 data[2]; +} spvUBOScalar_189ResourceHeap[]; + +layout(descriptor_heap, std430) readonly buffer SSBOReadOnlyNoWrite +{ + vec4 data; +} spvSSBOReadOnlyNoWrite_202ResourceHeap[]; + +layout(descriptor_heap, std430) coherent writeonly buffer SSBOWriteOnlyNoRead +{ + vec4 data; +} spvSSBOWriteOnlyNoRead_215ResourceHeap[]; + +layout(descriptor_heap, std430) buffer SSBO +{ + vec4 data; +} spvSSBO_222ResourceHeap[]; + +layout(descriptor_heap, r32ui) uniform uimage2D spv_227ResourceHeap[]; +layout(descriptor_heap) uniform accelerationStructureEXT spv_240ResourceHeap[]; + +void main() +{ + FragColor = vec4(0.0); + FragColor += texelFetch(spv_14ResourceHeap[int(gl_FragCoord.x)], 0, 0); + FragColor += texelFetch(spv_32ResourceHeap[int(gl_FragCoord.x)], ivec2(0), 0); + FragColor += texelFetch(spv_45ResourceHeap[int(gl_FragCoord.x)], ivec3(0), 0); + FragColor += texture(sampler2D(spv_32ResourceHeap[int(gl_FragCoord.x)], spv_64SamplerHeap[int(gl_FragCoord.y)]), vec2(0.0), 0.0); + FragColor += vec4(texture(sampler2DShadow(spv_32ResourceHeap[int(gl_FragCoord.x)], spv_64SamplerHeap[int(gl_FragCoord.y)]), vec3(vec3(0.0).xy, 0.0), 0.0)); + imageStore(spvWriteImages1D_heapResourceHeap[10], 0, FragColor); + imageStore(spvWriteImages2D_heapResourceHeap[20], ivec2(0), FragColor); + imageStore(spvWriteImages3D_heapResourceHeap[30], ivec3(0), FragColor); + FragColor += imageLoad(spvRWriteImages1D_heapResourceHeap[10], 0); + FragColor += imageLoad(spvRWriteImages2D_heapResourceHeap[20], ivec2(0)); + FragColor += imageLoad(spvRWriteImages3D_heapResourceHeap[30], ivec3(0)); + FragColor += imageLoad(spv_145ResourceHeap[40], ivec2(0)); + FragColor += vec4(spvUBO140_164ResourceHeap[50].data[1]); + FragColor += vec4(spvUBO430_177ResourceHeap[51].data[1].x); + FragColor += vec4(spvUBOScalar_189ResourceHeap[52].data[1].x); + FragColor += spvSSBOReadOnlyNoWrite_202ResourceHeap[60].data; + spvSSBOWriteOnlyNoRead_215ResourceHeap[61].data = vec4(20.0); + FragColor += spvSSBO_222ResourceHeap[62].data; + uint _236 = imageAtomicAdd(spv_227ResourceHeap[70], ivec2(0), 50u); + rayQueryInitializeEXT(rq, spv_240ResourceHeap[50], 0u, 0u, vec3(0.0), 0.0, vec3(1.0, 0.0, 0.0), 1.0); +} + diff --git a/third_party/spirv-cross/reference/shaders-ue4/asm/frag/depth-compare.asm.frag b/third_party/spirv-cross/reference/shaders-ue4/asm/frag/depth-compare.asm.frag index ef86380c45a4..a35ca8d810e5 100644 --- a/third_party/spirv-cross/reference/shaders-ue4/asm/frag/depth-compare.asm.frag +++ b/third_party/spirv-cross/reference/shaders-ue4/asm/frag/depth-compare.asm.frag @@ -1,8 +1,34 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include using namespace metal; +template +static inline depth2d spvDepthCast(texture2d t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depth2d_array spvDepthCast(texture2d_array t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube spvDepthCast(texturecube t) +{ + return reinterpret_cast &>(t); +} + +template +static inline depthcube_array spvDepthCast(texturecube_array t) +{ + return reinterpret_cast &>(t); +} + struct type_View { float4x4 View_TranslatedWorldToClip; @@ -196,7 +222,7 @@ 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)]], texture2d SceneTexturesStruct_SceneDepthTexture [[texture(0)]], texture2d SceneTexturesStruct_GBufferATexture [[texture(1)]], texture2d SceneTexturesStruct_GBufferBTexture [[texture(2)]], texture2d SceneTexturesStruct_GBufferDTexture [[texture(3)]], depthcube ShadowDepthCubeTexture [[texture(4)]], texture2d SSProfilesTexture [[texture(5)]], sampler SceneTexturesStruct_SceneDepthTextureSampler [[sampler(0)]], sampler SceneTexturesStruct_GBufferATextureSampler [[sampler(1)]], sampler SceneTexturesStruct_GBufferBTextureSampler [[sampler(2)]], sampler SceneTexturesStruct_GBufferDTextureSampler [[sampler(3)]], sampler ShadowDepthTextureSampler [[sampler(4)]], sampler ShadowDepthCubeTextureSampler [[sampler(5)]], float4 gl_FragCoord [[position]]) +fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_Globals& _Globals [[buffer(1)]], texture2d SceneTexturesStruct_SceneDepthTexture [[texture(0)]], texture2d SceneTexturesStruct_GBufferATexture [[texture(1)]], texture2d SceneTexturesStruct_GBufferBTexture [[texture(2)]], texture2d SceneTexturesStruct_GBufferDTexture [[texture(3)]], texturecube ShadowDepthCubeTexture [[texture(4)]], texture2d SSProfilesTexture [[texture(5)]], sampler SceneTexturesStruct_SceneDepthTextureSampler [[sampler(0)]], sampler SceneTexturesStruct_GBufferATextureSampler [[sampler(1)]], sampler SceneTexturesStruct_GBufferBTextureSampler [[sampler(2)]], sampler SceneTexturesStruct_GBufferDTextureSampler [[sampler(3)]], sampler ShadowDepthTextureSampler [[sampler(4)]], sampler ShadowDepthCubeTextureSampler [[sampler(5)]], float4 gl_FragCoord [[position]]) { main0_out out = {}; float2 _114 = gl_FragCoord.xy * View.View_BufferSizeAndInvSize.zw; @@ -236,7 +262,7 @@ fragment main0_out main0(constant type_View& View [[buffer(0)]], constant type_G } float4 _196 = _Globals.ShadowViewProjectionMatrices[_189] * float4(_147.xyz, 1.0); float _198 = _196.w; - _207 = ShadowDepthCubeTexture.sample_compare(ShadowDepthCubeTextureSampler, (_152 / float3(_158)), (_196.z / _198) + ((-_Globals.PointLightDepthBiasAndProjParameters.x) / _198), level(0.0)); + _207 = spvDepthCast(ShadowDepthCubeTexture).sample_compare(ShadowDepthCubeTextureSampler, (_152 / float3(_158)), (_196.z / _198) + ((-_Globals.PointLightDepthBiasAndProjParameters.x) / _198), level(0.0)); } else { diff --git a/third_party/spirv-cross/reference/shaders/asm/comp/specialization-constant-workgroup.asm.comp b/third_party/spirv-cross/reference/shaders/asm/comp/specialization-constant-workgroup.asm.comp index e16bd191fdb5..6488c737a188 100644 --- a/third_party/spirv-cross/reference/shaders/asm/comp/specialization-constant-workgroup.asm.comp +++ b/third_party/spirv-cross/reference/shaders/asm/comp/specialization-constant-workgroup.asm.comp @@ -6,9 +6,9 @@ #ifndef SPIRV_CROSS_CONSTANT_ID_12 #define SPIRV_CROSS_CONSTANT_ID_12 4u #endif - layout(local_size_x = SPIRV_CROSS_CONSTANT_ID_10, local_size_y = 20, local_size_z = SPIRV_CROSS_CONSTANT_ID_12) in; + layout(binding = 0, std430) buffer SSBO { float a; diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/out-of-bounds-access.asm.invalid.frag b/third_party/spirv-cross/reference/shaders/asm/frag/out-of-bounds-access.asm.invalid.frag new file mode 100644 index 000000000000..080283d41209 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/asm/frag/out-of-bounds-access.asm.invalid.frag @@ -0,0 +1,14 @@ +#version 320 es +precision mediump float; +precision highp int; + +void main() +{ + vec3 v = vec3(0.0); + if (false) + { + v.x = 99.0; + v.x = 88.0; + } +} + diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/texture-sampling-fp16.asm.vk.frag b/third_party/spirv-cross/reference/shaders/asm/frag/texture-sampling-fp16.asm.vk.invalid.frag similarity index 100% rename from third_party/spirv-cross/reference/shaders/asm/frag/texture-sampling-fp16.asm.vk.frag rename to third_party/spirv-cross/reference/shaders/asm/frag/texture-sampling-fp16.asm.vk.invalid.frag diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/texture-sampling-fp16.asm.vk.invalid.frag.vk b/third_party/spirv-cross/reference/shaders/asm/frag/texture-sampling-fp16.asm.vk.invalid.frag.vk new file mode 100644 index 000000000000..e13e4254ea77 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/asm/frag/texture-sampling-fp16.asm.vk.invalid.frag.vk @@ -0,0 +1,20 @@ +#version 450 +#if defined(GL_AMD_gpu_shader_half_float) +#extension GL_AMD_gpu_shader_half_float : require +#elif defined(GL_EXT_shader_explicit_arithmetic_types_float16) +#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require +#else +#error No extension available for FP16. +#endif +#extension GL_EXT_shader_16bit_storage : require + +layout(set = 0, binding = 0) uniform sampler2D uTexture; + +layout(location = 0) out f16vec4 FragColor; +layout(location = 0) in f16vec2 UV; + +void main() +{ + FragColor = f16vec4(texture(uTexture, UV)); +} + diff --git a/third_party/spirv-cross/reference/shaders/asm/frag/texture-shadow-lod.asm.frag b/third_party/spirv-cross/reference/shaders/asm/frag/texture-shadow-lod.asm.frag new file mode 100644 index 000000000000..49efaef1fec4 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/asm/frag/texture-shadow-lod.asm.frag @@ -0,0 +1,14 @@ +#version 450 +#extension GL_EXT_texture_shadow_lod : require + +layout(binding = 0) uniform sampler2DArrayShadow uShadow2DArray; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec4 vUV; +layout(location = 1) in float vLod; + +void main() +{ + FragColor = vec4(textureLod(uShadow2DArray, vec4(vUV.xyz, vUV.w), vLod)); +} + diff --git a/third_party/spirv-cross/reference/shaders/asm/lib/global-array.asm.lib b/third_party/spirv-cross/reference/shaders/asm/lib/global-array.asm.lib new file mode 100644 index 000000000000..ec6f73a0be5d --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/asm/lib/global-array.asm.lib @@ -0,0 +1,11 @@ +#ifdef SPIRV_CROSS_LIBRARY_HEADER +#version 450 +#endif + +const uint _15[4] = uint[](10u, 20u, 30u, 40u); + +uint lookup(uint i) +{ + return _15[i]; +} + diff --git a/third_party/spirv-cross/reference/shaders/asm/lib/multi-export.asm.lib b/third_party/spirv-cross/reference/shaders/asm/lib/multi-export.asm.lib new file mode 100644 index 000000000000..6ba81c9ffa0e --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/asm/lib/multi-export.asm.lib @@ -0,0 +1,21 @@ +#ifdef SPIRV_CROSS_LIBRARY_HEADER +#version 450 +#endif + +uint add_one(uint x) +{ + return x + 1u; +} + +uint helper_add(uint a, uint b) +{ + return a + b; +} + +uint add_two(uint y) +{ + uint _22 = y; + uint _23 = 2u; + return helper_add(_22, _23); +} + diff --git a/third_party/spirv-cross/reference/shaders/asm/vert/push-constant-row-major-matrix.asm.vk.vert b/third_party/spirv-cross/reference/shaders/asm/vert/push-constant-row-major-matrix.asm.vk.vert new file mode 100644 index 000000000000..ac49a8762927 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/asm/vert/push-constant-row-major-matrix.asm.vk.vert @@ -0,0 +1,16 @@ +#version 450 + +struct type_PushConstant_Matrix +{ + mat4 transform; +}; + +uniform type_PushConstant_Matrix matrix_constants; + +layout(location = 0) in vec4 in_var_POSITION; + +void main() +{ + gl_Position = matrix_constants.transform * in_var_POSITION; +} + diff --git a/third_party/spirv-cross/reference/shaders/asm/vert/push-constant-row-major-matrix.asm.vk.vert.vk b/third_party/spirv-cross/reference/shaders/asm/vert/push-constant-row-major-matrix.asm.vk.vert.vk new file mode 100644 index 000000000000..12c49da31abd --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/asm/vert/push-constant-row-major-matrix.asm.vk.vert.vk @@ -0,0 +1,14 @@ +#version 450 + +layout(push_constant, std430) uniform type_PushConstant_Matrix +{ + layout(row_major) mat4 transform; +} matrix_constants; + +layout(location = 0) in vec4 in_var_POSITION; + +void main() +{ + gl_Position = in_var_POSITION * matrix_constants.transform; +} + diff --git a/third_party/spirv-cross/reference/shaders/comp/cooperative-matrix.vk.nocompat.comp.vk b/third_party/spirv-cross/reference/shaders/comp/cooperative-matrix.vk.nocompat.comp.vk index 925622075938..45ae78127f65 100644 --- a/third_party/spirv-cross/reference/shaders/comp/cooperative-matrix.vk.nocompat.comp.vk +++ b/third_party/spirv-cross/reference/shaders/comp/cooperative-matrix.vk.nocompat.comp.vk @@ -13,11 +13,6 @@ #extension GL_EXT_bfloat16 : require layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; -layout(constant_id = 6) const int Scope = 3; -layout(constant_id = 0) const int Rows = 16; -layout(constant_id = 1) const int Columns = 16; -layout(constant_id = 5) const int Layout = 0; - layout(set = 0, binding = 0, std430) buffer SSBO32 { float data[]; @@ -32,80 +27,80 @@ shared uint blah[512]; void loads_32() { - coopmat _73; - coopMatLoad(_73, ssbo32.data, 256u * gl_WorkGroupID.x, 16u, gl_CooperativeMatrixLayoutColumnMajor); - coopmat A32 = _73; - coopmat _89; - coopMatLoad(_89, ssbo16.data, 512u * gl_WorkGroupID.x, 32u, gl_CooperativeMatrixLayoutRowMajor); - A32 = _89; - coopmat _102; - coopMatLoad(_102, ssbo32.data, 256u * gl_WorkGroupID.x, 16u, int(Layout)); - coopmat B32 = _102; - coopmat _110; - coopMatLoad(_110, ssbo16.data, 512u * gl_WorkGroupID.x, 32u, int(Layout)); - B32 = _110; - coopmat _122; - coopMatLoad(_122, ssbo32.data, 256u * gl_WorkGroupID.x, 16u, int(Layout)); - coopmat C32 = _122; - coopmat _130; - coopMatLoad(_130, ssbo16.data, 512u * gl_WorkGroupID.x, 32u, int(Layout)); - C32 = _130; + coopmat _71; + coopMatLoad(_71, ssbo32.data, 256u * gl_WorkGroupID.x, 16u, gl_CooperativeMatrixLayoutColumnMajor); + coopmat A32 = _71; + coopmat _87; + coopMatLoad(_87, ssbo16.data, 512u * gl_WorkGroupID.x, 32u, gl_CooperativeMatrixLayoutRowMajor); + A32 = _87; + coopmat _99; + coopMatLoad(_99, ssbo32.data, 256u * gl_WorkGroupID.x, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat B32 = _99; + coopmat _107; + coopMatLoad(_107, ssbo16.data, 512u * gl_WorkGroupID.x, 32u, gl_CooperativeMatrixLayoutRowMajor); + B32 = _107; + coopmat _119; + coopMatLoad(_119, ssbo32.data, 256u * gl_WorkGroupID.x, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat C32 = _119; + coopmat _127; + coopMatLoad(_127, ssbo16.data, 512u * gl_WorkGroupID.x, 32u, gl_CooperativeMatrixLayoutRowMajor); + C32 = _127; } void loads_16() { - coopmat _143; - coopMatLoad(_143, ssbo32.data, 128u * gl_WorkGroupID.x, 8u, int(Layout)); - coopmat A16 = _143; - coopmat _151; - coopMatLoad(_151, ssbo16.data, 256u * gl_WorkGroupID.x, 16u, int(Layout)); - A16 = _151; - coopmat _162; - coopMatLoad(_162, ssbo32.data, 128u * gl_WorkGroupID.x, 8u, int(Layout)); - coopmat B16 = _162; - coopmat _170; - coopMatLoad(_170, ssbo16.data, 256u * gl_WorkGroupID.x, 16u, int(Layout)); - B16 = _170; - coopmat _181; - coopMatLoad(_181, ssbo32.data, 128u * gl_WorkGroupID.x, 8u, int(Layout)); - coopmat C16 = _181; - coopmat _189; - coopMatLoad(_189, ssbo16.data, 256u * gl_WorkGroupID.x, 16u, int(Layout)); - C16 = _189; + coopmat _140; + coopMatLoad(_140, ssbo32.data, 128u * gl_WorkGroupID.x, 8u, gl_CooperativeMatrixLayoutRowMajor); + coopmat A16 = _140; + coopmat _148; + coopMatLoad(_148, ssbo16.data, 256u * gl_WorkGroupID.x, 16u, gl_CooperativeMatrixLayoutRowMajor); + A16 = _148; + coopmat _159; + coopMatLoad(_159, ssbo32.data, 128u * gl_WorkGroupID.x, 8u, gl_CooperativeMatrixLayoutRowMajor); + coopmat B16 = _159; + coopmat _167; + coopMatLoad(_167, ssbo16.data, 256u * gl_WorkGroupID.x, 16u, gl_CooperativeMatrixLayoutRowMajor); + B16 = _167; + coopmat _178; + coopMatLoad(_178, ssbo32.data, 128u * gl_WorkGroupID.x, 8u, gl_CooperativeMatrixLayoutRowMajor); + coopmat C16 = _178; + coopmat _186; + coopMatLoad(_186, ssbo16.data, 256u * gl_WorkGroupID.x, 16u, gl_CooperativeMatrixLayoutRowMajor); + C16 = _186; } void stores() { - coopMatStore(coopmat(100.0), ssbo32.data, 128u * gl_WorkGroupID.x, 0u, gl_CooperativeMatrixLayoutColumnMajor); - coopMatStore(coopmat(100u), ssbo32.data, 128u * gl_WorkGroupID.x, 0u, gl_CooperativeMatrixLayoutRowMajor); - coopMatStore(coopmat(-100), ssbo32.data, 128u * gl_WorkGroupID.x, 0u, int(Layout)); - coopMatStore(coopmat(float16_t(100.0)), ssbo32.data, 128u * gl_WorkGroupID.x, 0u, int(Layout)); - coopMatStore(coopmat(-100s), ssbo32.data, 128u * gl_WorkGroupID.x, 0u, int(Layout)); - coopMatStore(coopmat(100us), ssbo32.data, 128u * gl_WorkGroupID.x, 0u, int(Layout)); + coopMatStore(coopmat(100.0), ssbo32.data, 128u * gl_WorkGroupID.x, 0u, gl_CooperativeMatrixLayoutColumnMajor); + coopMatStore(coopmat(100u), ssbo32.data, 128u * gl_WorkGroupID.x, 0u, gl_CooperativeMatrixLayoutRowMajor); + coopMatStore(coopmat(-100), ssbo32.data, 128u * gl_WorkGroupID.x, 0u, gl_CooperativeMatrixLayoutRowMajor); + coopMatStore(coopmat(float16_t(100.0)), ssbo32.data, 128u * gl_WorkGroupID.x, 0u, gl_CooperativeMatrixLayoutRowMajor); + coopMatStore(coopmat(-100s), ssbo32.data, 128u * gl_WorkGroupID.x, 0u, gl_CooperativeMatrixLayoutRowMajor); + coopMatStore(coopmat(100us), ssbo32.data, 128u * gl_WorkGroupID.x, 0u, gl_CooperativeMatrixLayoutRowMajor); } void len() { - int len_1 = int(uint(coopmat(0).length())); - len_1 = int(uint(coopmat(0).length())); - len_1 = int(uint(coopmat(0).length())); - len_1 = int(uint(coopmat(0).length())); - len_1 = int(uint(coopmat(0).length())); - len_1 = int(uint(coopmat(0).length())); + int len_1 = int(uint(coopmat(0).length())); + len_1 = int(uint(coopmat(0).length())); + len_1 = int(uint(coopmat(0).length())); + len_1 = int(uint(coopmat(0).length())); + len_1 = int(uint(coopmat(0).length())); + len_1 = int(uint(coopmat(0).length())); } void conversions() { - coopmat A = coopmat(100.0); - coopmat A2 = coopmat(100u); - coopmat B = coopmat(A); - B = coopmat(A2); + coopmat A = coopmat(100.0); + coopmat A2 = coopmat(100u); + coopmat B = coopmat(A); + B = coopmat(A2); } void elementwise() { - coopmat A = coopmat(100.0); - coopmat B = coopmat(100); + coopmat A = coopmat(100.0); + coopmat B = coopmat(100); A += A; A -= A; A *= A; @@ -120,39 +115,39 @@ void elementwise() void insert_extract() { - coopmat A = coopmat(100.0); - for (int i = 0; i < int(uint(coopmat(0).length())); i++) + coopmat A = coopmat(100.0); + for (int i = 0; i < int(uint(coopmat(0).length())); i++) { A[i] += 50.0; } - coopMatStore(A, ssbo32.data, 0u, 16u, int(Layout)); + coopMatStore(A, ssbo32.data, 0u, 16u, gl_CooperativeMatrixLayoutRowMajor); } void scalar_construct() { - coopmat A = coopmat(gl_WorkGroupID.x); - coopMatStore(A, ssbo32.data, 0u, 16u, int(Layout)); + coopmat A = coopmat(gl_WorkGroupID.x); + coopMatStore(A, ssbo32.data, 0u, 16u, gl_CooperativeMatrixLayoutRowMajor); } -coopmat coopmat_square(coopmat a) +coopmat coopmat_square(coopmat a) { return a * a; } void matmul() { - coopmat A; - coopmat param = A; + coopmat A; + coopmat param = A; A = coopmat_square(param); - coopmat _261; - coopMatLoad(_261, ssbo32.data, 256u * gl_WorkGroupID.x, 16u, int(Layout)); - A = _261; - coopmat _270; - coopMatLoad(_270, ssbo32.data, 256u * gl_WorkGroupID.x, 16u, int(Layout)); - coopmat B = _270; - coopmat _279; - coopMatLoad(_279, ssbo32.data, 256u * gl_WorkGroupID.x, 16u, int(Layout)); - coopmat C = _279; + coopmat _258; + coopMatLoad(_258, ssbo32.data, 256u * gl_WorkGroupID.x, 16u, gl_CooperativeMatrixLayoutRowMajor); + A = _258; + coopmat _267; + coopMatLoad(_267, ssbo32.data, 256u * gl_WorkGroupID.x, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat B = _267; + coopmat _276; + coopMatLoad(_276, ssbo32.data, 256u * gl_WorkGroupID.x, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat C = _276; C = coopMatMulAdd(A, B, C, 0); C = coopMatMulAdd(A, B, C, 0); C = coopMatMulAdd(A, B, C, 16); @@ -160,46 +155,46 @@ void matmul() void matmul_uint() { - coopmat _302; - coopMatLoad(_302, ssbo32.data, 256u * gl_WorkGroupID.x, 16u, int(Layout)); - coopmat A = _302; - coopmat _313; - coopMatLoad(_313, ssbo32.data, 256u * gl_WorkGroupID.x, 16u, int(Layout)); - coopmat B = _313; - coopmat _324; - coopMatLoad(_324, ssbo32.data, 256u * gl_WorkGroupID.x, 16u, int(Layout)); - coopmat C = _324; + coopmat _299; + coopMatLoad(_299, ssbo32.data, 256u * gl_WorkGroupID.x, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat A = _299; + coopmat _310; + coopMatLoad(_310, ssbo32.data, 256u * gl_WorkGroupID.x, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat B = _310; + coopmat _321; + coopMatLoad(_321, ssbo32.data, 256u * gl_WorkGroupID.x, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat C = _321; C = coopMatMulAdd(A, B, C, 31); } void matmul_int() { - coopmat _339; - coopMatLoad(_339, ssbo32.data, 256u * gl_WorkGroupID.x, 16u, int(Layout)); - coopmat A = _339; - coopmat _350; - coopMatLoad(_350, ssbo32.data, 256u * gl_WorkGroupID.x, 16u, int(Layout)); - coopmat B = _350; - coopmat _361; - coopMatLoad(_361, ssbo32.data, 256u * gl_WorkGroupID.x, 16u, int(Layout)); - coopmat C = _361; + coopmat _336; + coopMatLoad(_336, ssbo32.data, 256u * gl_WorkGroupID.x, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat A = _336; + coopmat _347; + coopMatLoad(_347, ssbo32.data, 256u * gl_WorkGroupID.x, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat B = _347; + coopmat _358; + coopMatLoad(_358, ssbo32.data, 256u * gl_WorkGroupID.x, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat C = _358; C = coopMatMulAdd(A, B, C, 31); } void lds() { - coopmat _456; - coopMatLoad(_456, blah, 0u, 16u, int(Layout)); - coopmat A = _456; - coopMatStore(A, blah, 0u, 16u, int(Layout)); + coopmat _453; + coopMatLoad(_453, blah, 0u, 16u, gl_CooperativeMatrixLayoutRowMajor); + coopmat A = _453; + coopMatStore(A, blah, 0u, 16u, gl_CooperativeMatrixLayoutRowMajor); } void array_of_coopmat() { - coopmat As[4]; + coopmat As[4]; for (int i = 0; i < 4; i++) { - As[i] = coopmat(float(i)); + As[i] = coopmat(float(i)); } } diff --git a/third_party/spirv-cross/reference/shaders/comp/long-vector.vk.nocompat.comp.vk b/third_party/spirv-cross/reference/shaders/comp/long-vector.vk.nocompat.comp.vk new file mode 100644 index 000000000000..3c76bdc305e8 --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/comp/long-vector.vk.nocompat.comp.vk @@ -0,0 +1,49 @@ +#version 450 +#extension GL_EXT_long_vector : require +#extension GL_EXT_scalar_block_layout : require +layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; + +layout(set = 0, binding = 0, std430) buffer SSBO430 +{ + vector v1[4]; + vector v5[4]; + vector v6[4]; + vector v7[4]; + vector v8[4]; + vector v1024[4]; +} s430; + +layout(set = 0, binding = 1, scalar) buffer SSBOScalar +{ + vector v1[4]; + vector v5[4]; + vector v6[4]; + vector v7[4]; + vector v8[4]; + vector v1024[4]; +} scalar; + +shared vector shared_vec[4]; + +void main() +{ + uint idx = gl_GlobalInvocationID.x; + s430.v1[0] += (vector(4.0)); + s430.v5[idx] += (vector(2.0)); + s430.v6[idx] += (vector(3.0)); + s430.v7[idx] += (vector(4.0)); + s430.v8[idx] += (vector(5.0)); + scalar.v1[0] += (vector(6.0)); + scalar.v5[idx] += (vector(6.0)); + scalar.v6[idx] += (vector(7.0)); + scalar.v7[idx] += (vector(8.0)); + scalar.v8[idx] += (vector(9.0)); + vector V = vector(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0); + V[10] += 50.0; + V[gl_LocalInvocationIndex] += 60.0; + shared_vec[gl_LocalInvocationIndex] = V; + barrier(); + s430.v1024[idx] = shared_vec[gl_LocalInvocationIndex]; + scalar.v1024[idx] = V; +} + diff --git a/third_party/spirv-cross/reference/shaders/desktop-only/frag/depth-greater-than.desktop.frag b/third_party/spirv-cross/reference/shaders/desktop-only/frag/depth-greater-than.desktop.frag index 8b7c296447ca..ef008f43a11e 100644 --- a/third_party/spirv-cross/reference/shaders/desktop-only/frag/depth-greater-than.desktop.frag +++ b/third_party/spirv-cross/reference/shaders/desktop-only/frag/depth-greater-than.desktop.frag @@ -1,4 +1,5 @@ #version 450 +#extension GL_ARB_conservative_depth : require layout(depth_greater) out float gl_FragDepth; layout(early_fragment_tests) in; diff --git a/third_party/spirv-cross/reference/shaders/desktop-only/frag/depth-less-than.desktop.frag b/third_party/spirv-cross/reference/shaders/desktop-only/frag/depth-less-than.desktop.frag index 44752eb8fb6f..b3c3f84513b3 100644 --- a/third_party/spirv-cross/reference/shaders/desktop-only/frag/depth-less-than.desktop.frag +++ b/third_party/spirv-cross/reference/shaders/desktop-only/frag/depth-less-than.desktop.frag @@ -1,4 +1,5 @@ #version 450 +#extension GL_ARB_conservative_depth : require layout(depth_less) out float gl_FragDepth; layout(early_fragment_tests) in; diff --git a/third_party/spirv-cross/reference/shaders/frag/texture-shadow-lod-bias.frag b/third_party/spirv-cross/reference/shaders/frag/texture-shadow-lod-bias.frag new file mode 100644 index 000000000000..ed21d3e1a84a --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/frag/texture-shadow-lod-bias.frag @@ -0,0 +1,17 @@ +#version 450 +#extension GL_EXT_texture_shadow_lod : require + +layout(binding = 0) uniform sampler2DArrayShadow uShadow2DArray; + +layout(location = 0) in vec4 vUV; +layout(location = 1) in float vBias; +layout(location = 0) out vec4 FragColor; + +void main() +{ + float r = 0.0; + r += texture(uShadow2DArray, vec4(vUV.xyz, vUV.w), vBias); + r += textureOffset(uShadow2DArray, vec4(vUV.xyz, vUV.w), ivec2(1), vBias); + FragColor = vec4(r); +} + diff --git a/third_party/spirv-cross/reference/shaders/frag/texture-shadow-lod.vk.frag b/third_party/spirv-cross/reference/shaders/frag/texture-shadow-lod.vk.frag new file mode 100644 index 000000000000..bb71b45b2b0a --- /dev/null +++ b/third_party/spirv-cross/reference/shaders/frag/texture-shadow-lod.vk.frag @@ -0,0 +1,20 @@ +#version 450 +#extension GL_EXT_texture_shadow_lod : require + +layout(binding = 0) uniform sampler2DArrayShadow uShadow2DArray; +layout(binding = 1) uniform samplerCubeShadow uShadowCube; + +layout(location = 0) in vec4 vUV; +layout(location = 1) in float vLod; +layout(location = 0) out vec4 FragColor; + +void main() +{ + float r = 0.0; + r += textureLod(uShadow2DArray, vec4(vUV.xyz, vUV.w), 0.0); + r += textureLod(uShadow2DArray, vec4(vUV.xyz, vUV.w), vLod); + r += textureLod(uShadowCube, vec4(vUV.xyz, vUV.w), vLod); + r += textureLodOffset(uShadow2DArray, vec4(vUV.xyz, vUV.w), vLod, ivec2(1)); + FragColor = vec4(r); +} + diff --git a/third_party/spirv-cross/reference/shaders/vulkan/arm/tensor_read.nocompat.noopt.vk.comp.vk b/third_party/spirv-cross/reference/shaders/vulkan/arm/tensor_read.nocompat.noopt.vk.comp.vk index 6988e522cb9d..ad895fc042fa 100644 --- a/third_party/spirv-cross/reference/shaders/vulkan/arm/tensor_read.nocompat.noopt.vk.comp.vk +++ b/third_party/spirv-cross/reference/shaders/vulkan/arm/tensor_read.nocompat.noopt.vk.comp.vk @@ -17,8 +17,8 @@ void main() int _27[2]; tensorReadARM(t, uint[](1u, 2u, 3u, 4u), _27); int two[2] = _27; - int _37; - tensorReadARM(t, uint[](1u, 2u, 3u, 4u), _37); - _32.out_data[1] = _37; + int _35; + tensorReadARM(t, uint[](1u, 2u, 3u, 4u), _35); + _32.out_data[1] = _35; } diff --git a/third_party/spirv-cross/reference/shaders/vulkan/comp/spec-constant-work-group-size.vk.comp b/third_party/spirv-cross/reference/shaders/vulkan/comp/spec-constant-work-group-size.vk.comp index 888f4b164004..541edf09204c 100644 --- a/third_party/spirv-cross/reference/shaders/vulkan/comp/spec-constant-work-group-size.vk.comp +++ b/third_party/spirv-cross/reference/shaders/vulkan/comp/spec-constant-work-group-size.vk.comp @@ -12,14 +12,14 @@ const uint _21 = (uint(a) + 0u); #ifndef SPIRV_CROSS_CONSTANT_ID_10 #define SPIRV_CROSS_CONSTANT_ID_10 1u #endif +layout(local_size_x = SPIRV_CROSS_CONSTANT_ID_10, local_size_y = 20, local_size_z = 1) in; + const uint _27 = gl_WorkGroupSize.x; const uint _28 = (_21 + _27); const uint _29 = gl_WorkGroupSize.y; const uint _30 = (_28 + _29); const int _32 = (1 - a); -layout(local_size_x = SPIRV_CROSS_CONSTANT_ID_10, local_size_y = 20, local_size_z = 1) in; - layout(binding = 0, std430) writeonly buffer SSBO { int v[]; diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/asm/comp/phi-undef-loop.asm.comp b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/comp/phi-undef-loop.asm.comp new file mode 100644 index 000000000000..4d17874180a3 --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/comp/phi-undef-loop.asm.comp @@ -0,0 +1,55 @@ +; Tests an OpPhi at a loop header where one incoming value is OpUndef +; (the other is the loop back-edge). This pattern is produced by +; --merge-return + --inline-entry-points-exhaustive when an inlined function +; with an early `return` inside a loop is folded back. Reading the variable +; on the first iteration would be undefined; we materialize the OpUndef +; incoming as a zero so HLSL/FXC do not reject the generated code with X4555/X4000. +; +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 30 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpMemberDecorate %SSBO 0 Offset 0 + OpDecorate %SSBO BufferBlock + OpDecorate %ssbo DescriptorSet 0 + OpDecorate %ssbo Binding 0 + %void = OpTypeVoid + %fn_type = OpTypeFunction %void + %bool = OpTypeBool + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_10 = OpConstant %uint 10 + %SSBO = OpTypeStruct %uint + %ptr_SSBO = OpTypePointer Uniform %SSBO + %ptr_uint = OpTypePointer Uniform %uint + %ssbo = OpVariable %ptr_SSBO Uniform + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %undef_uint = OpUndef %uint + %main = OpFunction %void None %fn_type + %entry = OpLabel + OpBranch %header + %header = OpLabel + %phi = OpPhi %uint %undef_uint %entry %back %continue + %i = OpPhi %uint %uint_0 %entry %inext %continue + %cond = OpULessThan %bool %i %uint_10 + OpLoopMerge %merge %continue None + OpBranchConditional %cond %body %merge + %body = OpLabel + %dst = OpAccessChain %ptr_uint %ssbo %int_0 + OpStore %dst %phi + OpBranch %continue + %continue = OpLabel + %back = OpIAdd %uint %phi %uint_1 + %inext = OpIAdd %uint %i %uint_1 + OpBranch %header + %merge = OpLabel + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/asm/comp/phi-undef-loop.zero-initialize.asm.comp b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/comp/phi-undef-loop.zero-initialize.asm.comp new file mode 100644 index 000000000000..4d17874180a3 --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/comp/phi-undef-loop.zero-initialize.asm.comp @@ -0,0 +1,55 @@ +; Tests an OpPhi at a loop header where one incoming value is OpUndef +; (the other is the loop back-edge). This pattern is produced by +; --merge-return + --inline-entry-points-exhaustive when an inlined function +; with an early `return` inside a loop is folded back. Reading the variable +; on the first iteration would be undefined; we materialize the OpUndef +; incoming as a zero so HLSL/FXC do not reject the generated code with X4555/X4000. +; +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 30 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpMemberDecorate %SSBO 0 Offset 0 + OpDecorate %SSBO BufferBlock + OpDecorate %ssbo DescriptorSet 0 + OpDecorate %ssbo Binding 0 + %void = OpTypeVoid + %fn_type = OpTypeFunction %void + %bool = OpTypeBool + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_10 = OpConstant %uint 10 + %SSBO = OpTypeStruct %uint + %ptr_SSBO = OpTypePointer Uniform %SSBO + %ptr_uint = OpTypePointer Uniform %uint + %ssbo = OpVariable %ptr_SSBO Uniform + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %undef_uint = OpUndef %uint + %main = OpFunction %void None %fn_type + %entry = OpLabel + OpBranch %header + %header = OpLabel + %phi = OpPhi %uint %undef_uint %entry %back %continue + %i = OpPhi %uint %uint_0 %entry %inext %continue + %cond = OpULessThan %bool %i %uint_10 + OpLoopMerge %merge %continue None + OpBranchConditional %cond %body %merge + %body = OpLabel + %dst = OpAccessChain %ptr_uint %ssbo %int_0 + OpStore %dst %phi + OpBranch %continue + %continue = OpLabel + %back = OpIAdd %uint %phi %uint_1 + %inext = OpIAdd %uint %i %uint_1 + OpBranch %header + %merge = OpLabel + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/asm/packing/cbuffer-hard-packing.asm.frag b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/packing/cbuffer-hard-packing.asm.invalid.frag similarity index 100% rename from third_party/spirv-cross/shaders-hlsl-no-opt/asm/packing/cbuffer-hard-packing.asm.frag rename to third_party/spirv-cross/shaders-hlsl-no-opt/asm/packing/cbuffer-hard-packing.asm.invalid.frag diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/asm/vert/push-constant-row-major-matrix.asm.vk.vert b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/vert/push-constant-row-major-matrix.asm.vk.vert new file mode 100644 index 000000000000..afe5581ba46e --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/vert/push-constant-row-major-matrix.asm.vk.vert @@ -0,0 +1,66 @@ +; SPIR-V +; Version: 1.0 +; Generator: Google spiregg; 0 +; Bound: 23 +; Schema: 0 + OpCapability Shader + OpExtension "SPV_GOOGLE_hlsl_functionality1" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %in_var_POSITION %gl_Position + %4 = OpString ".\\push-constant-row-major-matrix.hlsl" + OpSource HLSL 600 %4 " +struct Matrix { + float4x4 transform; +}; + +[[vk::push_constant]] Matrix matrix_constants; + +float4 main(float4 in_position : POSITION) : SV_Position { + return mul(matrix_constants.transform, in_position); +} +" + OpName %type_PushConstant_Matrix "type.PushConstant.Matrix" + OpMemberName %type_PushConstant_Matrix 0 "transform" + OpName %matrix_constants "matrix_constants" + OpName %in_var_POSITION "in.var.POSITION" + OpName %main "main" + OpDecorateString %in_var_POSITION UserSemantic "POSITION" + OpDecorate %gl_Position BuiltIn Position + OpDecorateString %gl_Position UserSemantic "SV_Position" + OpDecorate %in_var_POSITION Location 0 + OpMemberDecorate %type_PushConstant_Matrix 0 Offset 0 + OpMemberDecorate %type_PushConstant_Matrix 0 MatrixStride 16 + OpMemberDecorate %type_PushConstant_Matrix 0 RowMajor + OpDecorate %type_PushConstant_Matrix Block + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%mat4v4float = OpTypeMatrix %v4float 4 +%type_PushConstant_Matrix = OpTypeStruct %mat4v4float +%_ptr_PushConstant_type_PushConstant_Matrix = OpTypePointer PushConstant %type_PushConstant_Matrix +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Output_v4float = OpTypePointer Output %v4float + %void = OpTypeVoid + %16 = OpTypeFunction %void +%_ptr_PushConstant_mat4v4float = OpTypePointer PushConstant %mat4v4float +%matrix_constants = OpVariable %_ptr_PushConstant_type_PushConstant_Matrix PushConstant +%in_var_POSITION = OpVariable %_ptr_Input_v4float Input +%gl_Position = OpVariable %_ptr_Output_v4float Output + OpLine %4 8 1 + %main = OpFunction %void None %16 + OpNoLine + %18 = OpLabel + OpLine %4 8 1 + %19 = OpLoad %v4float %in_var_POSITION + OpLine %4 9 16 + %20 = OpAccessChain %_ptr_PushConstant_mat4v4float %matrix_constants %int_0 + OpLine %4 9 33 + %21 = OpLoad %mat4v4float %20 + OpLine %4 9 12 + %22 = OpVectorTimesMatrix %v4float %19 %21 + OpLine %4 8 1 + OpStore %gl_Position %22 + OpLine %4 10 1 + OpReturn + OpFunctionEnd \ No newline at end of file diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/asm/vert/push-constant-row-major-matrix.sm30.asm.vk.vert b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/vert/push-constant-row-major-matrix.sm30.asm.vk.vert new file mode 100644 index 000000000000..afe5581ba46e --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/asm/vert/push-constant-row-major-matrix.sm30.asm.vk.vert @@ -0,0 +1,66 @@ +; SPIR-V +; Version: 1.0 +; Generator: Google spiregg; 0 +; Bound: 23 +; Schema: 0 + OpCapability Shader + OpExtension "SPV_GOOGLE_hlsl_functionality1" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %in_var_POSITION %gl_Position + %4 = OpString ".\\push-constant-row-major-matrix.hlsl" + OpSource HLSL 600 %4 " +struct Matrix { + float4x4 transform; +}; + +[[vk::push_constant]] Matrix matrix_constants; + +float4 main(float4 in_position : POSITION) : SV_Position { + return mul(matrix_constants.transform, in_position); +} +" + OpName %type_PushConstant_Matrix "type.PushConstant.Matrix" + OpMemberName %type_PushConstant_Matrix 0 "transform" + OpName %matrix_constants "matrix_constants" + OpName %in_var_POSITION "in.var.POSITION" + OpName %main "main" + OpDecorateString %in_var_POSITION UserSemantic "POSITION" + OpDecorate %gl_Position BuiltIn Position + OpDecorateString %gl_Position UserSemantic "SV_Position" + OpDecorate %in_var_POSITION Location 0 + OpMemberDecorate %type_PushConstant_Matrix 0 Offset 0 + OpMemberDecorate %type_PushConstant_Matrix 0 MatrixStride 16 + OpMemberDecorate %type_PushConstant_Matrix 0 RowMajor + OpDecorate %type_PushConstant_Matrix Block + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%mat4v4float = OpTypeMatrix %v4float 4 +%type_PushConstant_Matrix = OpTypeStruct %mat4v4float +%_ptr_PushConstant_type_PushConstant_Matrix = OpTypePointer PushConstant %type_PushConstant_Matrix +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Output_v4float = OpTypePointer Output %v4float + %void = OpTypeVoid + %16 = OpTypeFunction %void +%_ptr_PushConstant_mat4v4float = OpTypePointer PushConstant %mat4v4float +%matrix_constants = OpVariable %_ptr_PushConstant_type_PushConstant_Matrix PushConstant +%in_var_POSITION = OpVariable %_ptr_Input_v4float Input +%gl_Position = OpVariable %_ptr_Output_v4float Output + OpLine %4 8 1 + %main = OpFunction %void None %16 + OpNoLine + %18 = OpLabel + OpLine %4 8 1 + %19 = OpLoad %v4float %in_var_POSITION + OpLine %4 9 16 + %20 = OpAccessChain %_ptr_PushConstant_mat4v4float %matrix_constants %int_0 + OpLine %4 9 33 + %21 = OpLoad %mat4v4float %20 + OpLine %4 9 12 + %22 = OpVectorTimesMatrix %v4float %19 %21 + OpLine %4 8 1 + OpStore %gl_Position %22 + OpLine %4 10 1 + OpReturn + OpFunctionEnd \ No newline at end of file diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/comp/integer-dot-product.sm64.fxconly.nofxc.comp b/third_party/spirv-cross/shaders-hlsl-no-opt/comp/integer-dot-product.sm64.fxconly.nofxc.comp new file mode 100644 index 000000000000..712594cd5c04 --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/comp/integer-dot-product.sm64.fxconly.nofxc.comp @@ -0,0 +1,42 @@ +#version 450 +#extension GL_EXT_shader_8bit_storage : require +#extension GL_EXT_shader_16bit_storage : require +#extension GL_EXT_shader_explicit_arithmetic_types : require +#extension GL_EXT_spirv_intrinsics : require + +layout(local_size_x = 1) in; + +layout(std430, binding = 0) buffer InOut { + uvec4 x; + uvec4 y; + int result; +} comp; + +layout(std430, binding = 1) buffer InOut2 { + uint x; + uint y; + uint result; +} comp2; + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4450) +uint spdot_to_32(uint x, uint y, spirv_literal uint packedFormat); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4450) +int spdot_to_i32(uint x, uint y, spirv_literal uint packedFormat); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4451) +uint updot_to_32(uint x, uint y, spirv_literal uint packedFormat); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4454) +uint udotaddsat_packed(uint x, uint y, uint acc, spirv_literal uint packedFormat); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4453) +uint sdotaddsat_packed(uint x, uint y, uint acc, spirv_literal uint packedFormat); + +void main() { + uint spdot32 = spdot_to_32(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + int spdoti32 = spdot_to_i32(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + uint updot32 = updot_to_32(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + uint udotaddsat_pack = udotaddsat_packed(comp2.x, comp2.y, updot32, 0); // PackedVectorFormat4x8Bit + uint sdotaddsat_pack = sdotaddsat_packed(comp2.x, comp2.y, updot32, 0); // PackedVectorFormat4x8Bit +} diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/mesh/clip-cull-array-load-store-single.sm65.nofxc.fxconly.spv16.mesh b/third_party/spirv-cross/shaders-hlsl-no-opt/mesh/clip-cull-array-load-store-single.sm65.nofxc.fxconly.spv16.mesh index c7305dad36cc..7c81cabf6916 100644 --- a/third_party/spirv-cross/shaders-hlsl-no-opt/mesh/clip-cull-array-load-store-single.sm65.nofxc.fxconly.spv16.mesh +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/mesh/clip-cull-array-load-store-single.sm65.nofxc.fxconly.spv16.mesh @@ -7,9 +7,9 @@ out gl_MeshPerVertexEXT float gl_ClipDistance[1]; } gl_MeshVerticesEXT[]; -void write_clip_distance(inout float v[1]) +void write_clip_distance(out float v[1]) { - v[0] += 1.0; + v[0] = 1.0; } void main() diff --git a/third_party/spirv-cross/shaders-hlsl-no-opt/mesh/clip-cull-array-load-store.sm65.nofxc.fxconly.spv16.mesh b/third_party/spirv-cross/shaders-hlsl-no-opt/mesh/clip-cull-array-load-store.sm65.nofxc.fxconly.spv16.mesh index 6e84db675c8b..0196ab28c255 100644 --- a/third_party/spirv-cross/shaders-hlsl-no-opt/mesh/clip-cull-array-load-store.sm65.nofxc.fxconly.spv16.mesh +++ b/third_party/spirv-cross/shaders-hlsl-no-opt/mesh/clip-cull-array-load-store.sm65.nofxc.fxconly.spv16.mesh @@ -7,12 +7,12 @@ out gl_MeshPerVertexEXT float gl_ClipDistance[4]; } gl_MeshVerticesEXT[]; -void write_clip_distance(inout float v[4]) +void write_clip_distance(out float v[4]) { - v[0] += 1.0; - v[1] += 2.0; - v[2] += 3.0; - v[3] += 4.0; + v[0] = 1.0; + v[1] = 2.0; + v[2] = 3.0; + v[3] = 4.0; } void main() diff --git a/third_party/spirv-cross/shaders-hlsl/asm/frag/texture-sampling-fp16.asm.frag b/third_party/spirv-cross/shaders-hlsl/asm/frag/texture-sampling-fp16.asm.invalid.frag similarity index 100% rename from third_party/spirv-cross/shaders-hlsl/asm/frag/texture-sampling-fp16.asm.frag rename to third_party/spirv-cross/shaders-hlsl/asm/frag/texture-sampling-fp16.asm.invalid.frag diff --git a/third_party/spirv-cross/shaders-hlsl/asm/lib/export-calls-export.asm.lib b/third_party/spirv-cross/shaders-hlsl/asm/lib/export-calls-export.asm.lib new file mode 100644 index 000000000000..333a5f909822 --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl/asm/lib/export-calls-export.asm.lib @@ -0,0 +1,59 @@ +; SPIR-V +; Version: 1.5 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 50 +; Schema: 0 + OpCapability Linkage + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpSource HLSL 630 + OpName %add_one "add_one" + OpName %x "x" + OpName %add_two "add_two" + OpName %y "y" + OpName %add_three "add_three" + OpName %z "z" + OpDecorate %add_one LinkageAttributes "add_one" Export + OpDecorate %add_two LinkageAttributes "add_two" Export + OpDecorate %add_three LinkageAttributes "add_three" Export + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 + %uint_3 = OpConstant %uint 3 +%_ptr_Function_uint = OpTypePointer Function %uint + %fn1 = OpTypeFunction %uint %_ptr_Function_uint + + %add_one = OpFunction %uint None %fn1 + %x = OpFunctionParameter %_ptr_Function_uint + %o_bb = OpLabel + %o_xv = OpLoad %uint %x + %o_r = OpIAdd %uint %o_xv %uint_1 + OpReturnValue %o_r + OpFunctionEnd + +; add_two calls add_one twice (already-emitted callee), and forward-references +; add_three (callee declared *after* add_two in the module). Both exercise +; the func.active short-circuit but in different directions. + + %add_two = OpFunction %uint None %fn1 + %y = OpFunctionParameter %_ptr_Function_uint + %t_bb = OpLabel + %t_arg1 = OpVariable %_ptr_Function_uint Function + %t_arg2 = OpVariable %_ptr_Function_uint Function + %t_arg3 = OpVariable %_ptr_Function_uint Function + %t_yv = OpLoad %uint %y + OpStore %t_arg1 %t_yv + %t_a = OpFunctionCall %uint %add_one %t_arg1 + OpStore %t_arg2 %t_a + %t_b = OpFunctionCall %uint %add_one %t_arg2 + OpStore %t_arg3 %t_b + %t_r = OpFunctionCall %uint %add_three %t_arg3 + OpReturnValue %t_r + OpFunctionEnd + + %add_three = OpFunction %uint None %fn1 + %z = OpFunctionParameter %_ptr_Function_uint + %r_bb = OpLabel + %r_zv = OpLoad %uint %z + %r_r = OpIAdd %uint %r_zv %uint_3 + OpReturnValue %r_r + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-hlsl/asm/lib/global-array.asm.lib b/third_party/spirv-cross/shaders-hlsl/asm/lib/global-array.asm.lib new file mode 100644 index 000000000000..dbe5bf8d7684 --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl/asm/lib/global-array.asm.lib @@ -0,0 +1,35 @@ +; SPIR-V +; Version: 1.5 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 30 +; Schema: 0 + OpCapability Linkage + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpSource HLSL 630 + OpName %lookup "lookup" + OpName %i "i" + OpName %table "table" + OpDecorate %lookup LinkageAttributes "lookup" Export + %uint = OpTypeInt 32 0 + %uint_10 = OpConstant %uint 10 + %uint_20 = OpConstant %uint 20 + %uint_30 = OpConstant %uint 30 + %uint_40 = OpConstant %uint 40 + %uint_4 = OpConstant %uint 4 +%_arr_uint_uint_4 = OpTypeArray %uint %uint_4 +%_ptr_Private__arr_uint_uint_4 = OpTypePointer Private %_arr_uint_uint_4 +%_ptr_Private_uint = OpTypePointer Private %uint +%_ptr_Function_uint = OpTypePointer Function %uint + %fn1 = OpTypeFunction %uint %_ptr_Function_uint +%table_init = OpConstantComposite %_arr_uint_uint_4 %uint_10 %uint_20 %uint_30 %uint_40 + %table = OpVariable %_ptr_Private__arr_uint_uint_4 Private %table_init + + %lookup = OpFunction %uint None %fn1 + %i = OpFunctionParameter %_ptr_Function_uint + %l_bb = OpLabel + %l_iv = OpLoad %uint %i + %l_ac = OpAccessChain %_ptr_Private_uint %table %l_iv + %l_v = OpLoad %uint %l_ac + OpReturnValue %l_v + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-hlsl/asm/lib/multi-export.asm.lib b/third_party/spirv-cross/shaders-hlsl/asm/lib/multi-export.asm.lib new file mode 100644 index 000000000000..a7851d11031e --- /dev/null +++ b/third_party/spirv-cross/shaders-hlsl/asm/lib/multi-export.asm.lib @@ -0,0 +1,54 @@ +; SPIR-V +; Version: 1.5 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 40 +; Schema: 0 + OpCapability Linkage + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpSource HLSL 630 + OpName %add_one "add_one" + OpName %x "x" + OpName %add_two "add_two" + OpName %y "y" + OpName %helper_add "helper_add" + OpName %a "a" + OpName %b "b" + OpDecorate %add_one LinkageAttributes "add_one" Export + OpDecorate %add_two LinkageAttributes "add_two" Export + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 +%_ptr_Function_uint = OpTypePointer Function %uint + %fn1 = OpTypeFunction %uint %_ptr_Function_uint + %fn2 = OpTypeFunction %uint %_ptr_Function_uint %_ptr_Function_uint + + %helper_add = OpFunction %uint None %fn2 + %a = OpFunctionParameter %_ptr_Function_uint + %b = OpFunctionParameter %_ptr_Function_uint + %h_bb = OpLabel + %h_av = OpLoad %uint %a + %h_bv = OpLoad %uint %b + %h_sum = OpIAdd %uint %h_av %h_bv + OpReturnValue %h_sum + OpFunctionEnd + + %add_one = OpFunction %uint None %fn1 + %x = OpFunctionParameter %_ptr_Function_uint + %o_bb = OpLabel + %o_xv = OpLoad %uint %x + %o_r = OpIAdd %uint %o_xv %uint_1 + OpReturnValue %o_r + OpFunctionEnd + + %add_two = OpFunction %uint None %fn1 + %y = OpFunctionParameter %_ptr_Function_uint + %t_bb = OpLabel + %t_arg1 = OpVariable %_ptr_Function_uint Function + %t_arg2 = OpVariable %_ptr_Function_uint Function + %t_yv = OpLoad %uint %y + OpStore %t_arg1 %t_yv + OpStore %t_arg2 %uint_2 + %t_r = OpFunctionCall %uint %helper_add %t_arg1 %t_arg2 + OpReturnValue %t_r + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-hlsl/comp/ssbo-store-array.comp b/third_party/spirv-cross/shaders-hlsl/comp/ssbo-store-array.comp index dc2a508d8a32..8b74586b3260 100644 --- a/third_party/spirv-cross/shaders-hlsl/comp/ssbo-store-array.comp +++ b/third_party/spirv-cross/shaders-hlsl/comp/ssbo-store-array.comp @@ -12,7 +12,7 @@ layout(set = 0, binding = 0, std430) buffer B0 void main() { - Data d1; + Data d1 = Data( uint[3](1, 2, 3) ); d[0].arr = d1.arr; } diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/bda-atomic-ptr-cast.spv16.msl23.asm.comp b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/bda-atomic-ptr-cast.spv16.msl23.asm.comp new file mode 100644 index 000000000000..63da985aee04 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/bda-atomic-ptr-cast.spv16.msl23.asm.comp @@ -0,0 +1,45 @@ + OpCapability Shader + OpCapability Int64 + OpCapability PhysicalStorageBufferAddresses + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel PhysicalStorageBuffer64 GLSL450 + OpEntryPoint GLCompute %main "main" %pc + OpExecutionMode %main LocalSize 1 1 1 + OpName %main "main" + OpName %PC "PC" + OpName %pc "pc" + OpDecorate %PC Block + OpMemberDecorate %PC 0 Offset 0 + OpMemberDecorate %PC 1 Offset 8 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %ulong = OpTypeInt 64 0 +%_ptr_PhysicalStorageBuffer_uint = OpTypePointer PhysicalStorageBuffer %uint + %PC = OpTypeStruct %ulong %uint +%_ptr_PushConstant_PC = OpTypePointer PushConstant %PC + %pc = OpVariable %_ptr_PushConstant_PC PushConstant + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %int_1 = OpConstant %int 1 +%_ptr_PushConstant_ulong = OpTypePointer PushConstant %ulong +%_ptr_PushConstant_uint = OpTypePointer PushConstant %uint + %uint_256 = OpConstant %uint 256 + %ulong_4 = OpConstant %ulong 4 +%uint_4294967295 = OpConstant %uint 4294967295 + %uint_1 = OpConstant %uint 1 + %uint_0 = OpConstant %uint 0 + %main = OpFunction %void None %3 + %5 = OpLabel + %18 = OpAccessChain %_ptr_PushConstant_ulong %pc %int_0 + %19 = OpLoad %ulong %18 + %26 = OpAccessChain %_ptr_PushConstant_uint %pc %int_1 + %27 = OpLoad %uint %26 + %29 = OpExtInst %uint %1 UMin %27 %uint_256 + %31 = OpUConvert %ulong %29 + %35 = OpIMul %ulong %31 %ulong_4 + %36 = OpIAdd %ulong %19 %35 + %37 = OpConvertUToPtr %_ptr_PhysicalStorageBuffer_uint %36 + %44 = OpAtomicUMax %uint %37 %uint_1 %uint_0 %uint_4294967295 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/compilation-loop-edge-case.spv16.asm.comp b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/compilation-loop-edge-case.spv16.asm.comp new file mode 100644 index 000000000000..35b1a1103398 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/compilation-loop-edge-case.spv16.asm.comp @@ -0,0 +1,275 @@ +; SPIR-V +; Version: 1.5 +; Generator: Google spiregg; 0 +; Bound: 216 +; Schema: 0 + OpCapability SignedZeroInfNanPreserve + OpCapability Shader + OpExtension "SPV_KHR_float_controls" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %2 "main" %gl_GlobalInvocationID %4 %5 %6 %7 + OpExecutionMode %2 LocalSize 8 8 1 + OpExecutionMode %2 SignedZeroInfNanPreserve 32 + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %4 DescriptorSet 0 + OpDecorate %4 Binding 0 + OpDecorate %5 DescriptorSet 0 + OpDecorate %5 Binding 1 + OpDecorate %6 DescriptorSet 0 + OpDecorate %6 Binding 2 + OpDecorate %7 DescriptorSet 0 + OpDecorate %7 Binding 3 + OpMemberDecorate %_struct_18 0 Offset 0 + OpMemberDecorate %_struct_18 1 Offset 8 + OpMemberDecorate %_struct_18 2 Offset 16 + OpMemberDecorate %_struct_18 3 Offset 28 + OpMemberDecorate %_struct_18 4 Offset 32 + OpMemberDecorate %_struct_18 5 Offset 36 + OpMemberDecorate %_struct_18 6 Offset 40 + OpMemberDecorate %_struct_18 7 Offset 44 + OpDecorate %_struct_18 Block + OpDecorate %21 NoContraction + OpDecorate %22 NoContraction + OpDecorate %23 NoContraction + OpDecorate %24 NoContraction + OpDecorate %25 NoContraction + OpDecorate %26 NoContraction + OpDecorate %27 NoContraction + OpDecorate %28 NoContraction + OpDecorate %29 NoContraction + OpDecorate %30 NoContraction + OpDecorate %31 NoContraction + OpDecorate %32 NoContraction + OpDecorate %33 NoContraction + OpDecorate %34 NoContraction + OpDecorate %35 NoContraction + OpDecorate %36 NoContraction + OpDecorate %37 NoContraction + OpDecorate %38 NoContraction + OpDecorate %39 NoContraction + OpDecorate %40 NoContraction + OpDecorate %41 NoContraction + OpDecorate %42 NoContraction + OpDecorate %43 NoContraction + OpDecorate %44 NoContraction + OpDecorate %45 NoContraction + OpDecorate %46 NoContraction + OpDecorate %47 NoContraction + OpDecorate %48 NoContraction + OpDecorate %49 NoContraction + OpDecorate %50 NoContraction + OpDecorate %51 NoContraction + OpDecorate %52 NoContraction + %float = OpTypeFloat 32 + %uint = OpTypeInt 32 0 + %float_1 = OpConstant %float 1 + %v3float = OpTypeVector %float 3 + %57 = OpConstantComposite %v3float %float_1 %float_1 %float_1 + %float_0 = OpConstant %float 0 + %59 = OpConstantComposite %v3float %float_0 %float_0 %float_0 + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %int_1 = OpConstant %int 1 + %int_2 = OpConstant %int 2 + %uint_0 = OpConstant %uint 0 + %int_3 = OpConstant %int 3 + %int_4 = OpConstant %int 4 + %uint_9 = OpConstant %uint 9 + %uint_18 = OpConstant %uint 18 + %uint_511 = OpConstant %uint 511 + %v3uint = OpTypeVector %uint 3 + %71 = OpConstantComposite %v3uint %uint_511 %uint_511 %uint_511 + %uint_27 = OpConstant %uint 27 + %int_24 = OpConstant %int 24 +%uint_1199538176 = OpConstant %uint 1199538176 +%uint_931135488 = OpConstant %uint 931135488 +%uint_125845504 = OpConstant %uint 125845504 +%uint_2139095040 = OpConstant %uint 2139095040 + %uint_4 = OpConstant %uint 4 +%uint_268435456 = OpConstant %uint 268435456 + %v2float = OpTypeVector %float 2 + %_struct_18 = OpTypeStruct %v2float %v2float %v3float %uint %float %uint %uint %uint +%_ptr_Uniform__struct_18 = OpTypePointer Uniform %_struct_18 + %19 = OpTypeImage %uint 3D 2 0 0 2 R32ui +%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 + %20 = OpTypeImage %float 2D 2 0 0 1 Unknown +%_ptr_UniformConstant_20 = OpTypePointer UniformConstant %20 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid + %86 = OpTypeFunction %void + %v2uint = OpTypeVector %uint 2 +%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float + %v4float = OpTypeVector %float 4 +%_ptr_Uniform_uint = OpTypePointer Uniform %uint +%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float + %bool = OpTypeBool +%_ptr_Uniform_float = OpTypePointer Uniform %float + %v4uint = OpTypeVector %uint 4 + %4 = OpVariable %_ptr_Uniform__struct_18 Uniform + %5 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %6 = OpVariable %_ptr_UniformConstant_19 UniformConstant + %7 = OpVariable %_ptr_UniformConstant_20 UniformConstant +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input + %2 = OpFunction %void None %86 + %95 = OpLabel + %96 = OpLoad %v3uint %gl_GlobalInvocationID + %97 = OpVectorShuffle %v2uint %96 %96 0 1 + %98 = OpConvertUToF %v2float %97 + %99 = OpAccessChain %_ptr_Uniform_v2float %4 %int_0 + %100 = OpLoad %v2float %99 + %21 = OpFMul %v2float %98 %100 + %101 = OpAccessChain %_ptr_Uniform_v2float %4 %int_1 + %102 = OpLoad %v2float %101 + %22 = OpFAdd %v2float %21 %102 + %103 = OpCompositeExtract %float %22 0 + %104 = OpCompositeExtract %float %22 1 + %105 = OpCompositeConstruct %v3float %103 %104 %float_1 + %106 = OpExtInst %v3float %1 Normalize %105 + %107 = OpCompositeExtract %float %106 2 + %23 = OpFDiv %float %float_1 %107 + %108 = OpLoad %20 %7 + %109 = OpImageFetch %v4float %108 %97 Lod %uint_0 + %110 = OpCompositeExtract %float %109 0 + %111 = OpAccessChain %_ptr_Uniform_uint %4 %int_3 + %112 = OpLoad %uint %111 + %113 = OpConvertUToF %float %112 + %24 = OpFMul %float %110 %113 + %114 = OpExtInst %float %1 Ceil %24 + %115 = OpConvertFToU %uint %114 + %116 = OpAccessChain %_ptr_Uniform_v3float %4 %int_2 + %117 = OpLoad %v3float %116 + %118 = OpCompositeExtract %float %117 0 + %37 = OpFMul %float %float_0 %118 + %119 = OpExtInst %float %1 Exp2 %37 + %120 = OpCompositeExtract %float %117 1 + %38 = OpFMul %float %119 %120 + %121 = OpCompositeExtract %float %117 2 + %39 = OpFAdd %float %38 %121 + OpBranch %122 + %122 = OpLabel + %123 = OpPhi %v3float %59 %95 %34 %124 + %125 = OpPhi %v3float %57 %95 %35 %124 + %126 = OpPhi %float %39 %95 %42 %124 + %127 = OpPhi %int %int_0 %95 %36 %124 + %128 = OpBitcast %uint %127 + %129 = OpULessThan %bool %128 %115 + OpLoopMerge %130 %124 None + OpBranchConditional %129 %124 %130 + %124 = OpLabel + %131 = OpCompositeExtract %uint %96 0 + %132 = OpCompositeExtract %uint %96 1 + %133 = OpCompositeConstruct %v3uint %131 %132 %128 + %134 = OpConvertSToF %float %127 + %25 = OpFAdd %float %134 %float_1 + %135 = OpAccessChain %_ptr_Uniform_float %4 %int_4 + %136 = OpLoad %float %135 + %26 = OpFMul %float %25 %136 + %40 = OpFMul %float %26 %118 + %137 = OpExtInst %float %1 Exp2 %40 + %41 = OpFMul %float %137 %120 + %42 = OpFAdd %float %41 %121 + %27 = OpFSub %float %42 %126 + %28 = OpFMul %float %27 %23 + %138 = OpLoad %19 %5 + %139 = OpImageRead %v4uint %138 %133 None + %140 = OpCompositeExtract %uint %139 0 + %141 = OpShiftRightLogical %uint %140 %uint_9 + %142 = OpShiftRightLogical %uint %140 %uint_18 + %143 = OpCompositeConstruct %v3uint %140 %141 %142 + %144 = OpBitwiseAnd %v3uint %143 %71 + %145 = OpConvertUToF %v3float %144 + %146 = OpShiftRightLogical %uint %140 %uint_27 + %147 = OpBitcast %int %146 + %43 = OpISub %int %147 %int_24 + %148 = OpConvertSToF %float %43 + %149 = OpCompositeConstruct %v3float %148 %148 %148 + %150 = OpExtInst %v3float %1 Exp2 %149 + %44 = OpFMul %v3float %145 %150 + %151 = OpLoad %19 %6 + %152 = OpImageRead %v4uint %151 %133 None + %153 = OpCompositeExtract %uint %152 0 + %154 = OpShiftRightLogical %uint %153 %uint_9 + %155 = OpShiftRightLogical %uint %153 %uint_18 + %156 = OpCompositeConstruct %v3uint %153 %154 %155 + %157 = OpBitwiseAnd %v3uint %156 %71 + %158 = OpConvertUToF %v3float %157 + %159 = OpShiftRightLogical %uint %153 %uint_27 + %160 = OpBitcast %int %159 + %45 = OpISub %int %160 %int_24 + %161 = OpConvertSToF %float %45 + %162 = OpCompositeConstruct %v3float %161 %161 %161 + %163 = OpExtInst %v3float %1 Exp2 %162 + %46 = OpFMul %v3float %158 %163 + %29 = OpFNegate %v3float %46 + %30 = OpVectorTimesScalar %v3float %29 %28 + %164 = OpExtInst %v3float %1 Exp %30 + %31 = OpFSub %v3float %57 %164 + %32 = OpFMul %v3float %44 %31 + %33 = OpFMul %v3float %32 %125 + %34 = OpFAdd %v3float %123 %33 + %35 = OpFMul %v3float %125 %164 + %165 = OpBitcast %float %uint_1199538176 + %166 = OpBitcast %float %uint_931135488 + %167 = OpCompositeConstruct %v3float %165 %165 %165 + %168 = OpExtInst %v3float %1 FClamp %34 %59 %167 + %169 = OpCompositeExtract %float %168 0 + %170 = OpExtInst %float %1 NMax %166 %169 + %171 = OpCompositeExtract %float %168 1 + %172 = OpCompositeExtract %float %168 2 + %173 = OpExtInst %float %1 NMax %171 %172 + %174 = OpExtInst %float %1 NMax %170 %173 + %175 = OpBitcast %uint %174 + %47 = OpIAdd %uint %175 %uint_125845504 + %176 = OpBitwiseAnd %uint %47 %uint_2139095040 + %177 = OpBitcast %float %176 + %178 = OpCompositeConstruct %v3float %177 %177 %177 + %48 = OpFAdd %v3float %168 %178 + %179 = OpBitcast %v3uint %48 + %180 = OpBitcast %uint %177 + %181 = OpShiftLeftLogical %uint %180 %uint_4 + %49 = OpIAdd %uint %181 %uint_268435456 + %182 = OpCompositeExtract %uint %179 2 + %183 = OpShiftLeftLogical %uint %182 %uint_18 + %184 = OpBitwiseOr %uint %49 %183 + %185 = OpCompositeExtract %uint %179 1 + %186 = OpShiftLeftLogical %uint %185 %uint_9 + %187 = OpBitwiseOr %uint %184 %186 + %188 = OpCompositeExtract %uint %179 0 + %189 = OpBitwiseAnd %uint %188 %uint_511 + %190 = OpBitwiseOr %uint %187 %189 + %191 = OpLoad %19 %5 + OpImageWrite %191 %133 %190 None + %192 = OpExtInst %v3float %1 FClamp %35 %59 %167 + %193 = OpCompositeExtract %float %192 0 + %194 = OpExtInst %float %1 NMax %166 %193 + %195 = OpCompositeExtract %float %192 1 + %196 = OpCompositeExtract %float %192 2 + %197 = OpExtInst %float %1 NMax %195 %196 + %198 = OpExtInst %float %1 NMax %194 %197 + %199 = OpBitcast %uint %198 + %50 = OpIAdd %uint %199 %uint_125845504 + %200 = OpBitwiseAnd %uint %50 %uint_2139095040 + %201 = OpBitcast %float %200 + %202 = OpCompositeConstruct %v3float %201 %201 %201 + %51 = OpFAdd %v3float %192 %202 + %203 = OpBitcast %v3uint %51 + %204 = OpBitcast %uint %201 + %205 = OpShiftLeftLogical %uint %204 %uint_4 + %52 = OpIAdd %uint %205 %uint_268435456 + %206 = OpCompositeExtract %uint %203 2 + %207 = OpShiftLeftLogical %uint %206 %uint_18 + %208 = OpBitwiseOr %uint %52 %207 + %209 = OpCompositeExtract %uint %203 1 + %210 = OpShiftLeftLogical %uint %209 %uint_9 + %211 = OpBitwiseOr %uint %208 %210 + %212 = OpCompositeExtract %uint %203 0 + %213 = OpBitwiseAnd %uint %212 %uint_511 + %214 = OpBitwiseOr %uint %211 %213 + %215 = OpLoad %19 %6 + OpImageWrite %215 %133 %214 None + %36 = OpIAdd %int %127 %int_1 + OpBranch %122 + %130 = OpLabel + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-bfloat.asm.msl31.comp b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-bfloat.asm.msl31.comp new file mode 100644 index 000000000000..18b795c2e965 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-bfloat.asm.msl31.comp @@ -0,0 +1,52 @@ +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 50 +; Schema: 0 + OpCapability Shader + OpCapability CooperativeMatrixKHR + OpCapability BFloat16TypeKHR + OpCapability BFloat16CooperativeMatrixKHR + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_cooperative_matrix" + OpExtension "SPV_KHR_bfloat16" + OpExtension "SPV_KHR_vulkan_memory_model" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 32 1 1 + OpName %main "main" + OpName %SSBO "SSBO" + OpMemberName %SSBO 0 "data" + OpName %ssbo "ssbo" + OpDecorate %arr_bf16 ArrayStride 2 + OpMemberDecorate %SSBO 0 Offset 0 + OpDecorate %SSBO Block + OpDecorate %ssbo DescriptorSet 0 + OpDecorate %ssbo Binding 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %bfloat = OpTypeFloat 16 BFloat16KHR + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_8 = OpConstant %uint 8 + %arr_bf16 = OpTypeRuntimeArray %bfloat + %SSBO = OpTypeStruct %arr_bf16 +%ptr_ssbo_SSBO = OpTypePointer StorageBuffer %SSBO + %ssbo = OpVariable %ptr_ssbo_SSBO StorageBuffer +%ptr_ssbo_bf16 = OpTypePointer StorageBuffer %bfloat +%coopmat_bf16_A = OpTypeCooperativeMatrixKHR %bfloat %uint_3 %uint_8 %uint_8 %uint_0 +%coopmat_bf16_B = OpTypeCooperativeMatrixKHR %bfloat %uint_3 %uint_8 %uint_8 %uint_1 +%coopmat_bf16_acc = OpTypeCooperativeMatrixKHR %bfloat %uint_3 %uint_8 %uint_8 %uint_2 + %main = OpFunction %void None %3 + %5 = OpLabel + %p0 = OpAccessChain %ptr_ssbo_bf16 %ssbo %uint_0 %uint_0 + %bf_A = OpCooperativeMatrixLoadKHR %coopmat_bf16_A %p0 %uint_0 %uint_8 + %bf_B = OpCooperativeMatrixLoadKHR %coopmat_bf16_B %p0 %uint_0 %uint_8 + %bf_C = OpCooperativeMatrixLoadKHR %coopmat_bf16_acc %p0 %uint_0 %uint_8 + %bf_D = OpCooperativeMatrixMulAddKHR %coopmat_bf16_acc %bf_A %bf_B %bf_C + OpCooperativeMatrixStoreKHR %p0 %bf_D %uint_0 %uint_8 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-convert.asm.msl31.comp b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-convert.asm.msl31.comp new file mode 100644 index 000000000000..9b17e0efc8cd --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-convert.asm.msl31.comp @@ -0,0 +1,48 @@ +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 55 +; Schema: 0 + OpCapability Shader + OpCapability Float16 + OpCapability CooperativeMatrixKHR + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_cooperative_matrix" + OpExtension "SPV_KHR_vulkan_memory_model" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 32 1 1 + OpName %main "main" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %half = OpTypeFloat 16 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_3 = OpConstant %uint 3 + %uint_8 = OpConstant %uint 8 + %uint_64 = OpConstant %uint 64 + %arr_float = OpTypeArray %float %uint_64 + %arr_half = OpTypeArray %half %uint_64 +%ptr_wg_arr_f = OpTypePointer Workgroup %arr_float +%ptr_wg_arr_h = OpTypePointer Workgroup %arr_half + %wg_data_f = OpVariable %ptr_wg_arr_f Workgroup + %wg_data_h = OpVariable %ptr_wg_arr_h Workgroup +%ptr_wg_float = OpTypePointer Workgroup %float + %ptr_wg_half = OpTypePointer Workgroup %half +; float32 accumulator cooperative matrix type +%coopmat_f32 = OpTypeCooperativeMatrixKHR %float %uint_3 %uint_8 %uint_8 %uint_0 +; float16 accumulator cooperative matrix type +%coopmat_f16 = OpTypeCooperativeMatrixKHR %half %uint_3 %uint_8 %uint_8 %uint_0 + %main = OpFunction %void None %3 + %5 = OpLabel +; Load a float16 matrix from workgroup memory + %p_half = OpAccessChain %ptr_wg_half %wg_data_h %uint_0 + %m_f16 = OpCooperativeMatrixLoadKHR %coopmat_f16 %p_half %uint_0 %uint_8 +; FConvert: half → float32 + %m_f32 = OpFConvert %coopmat_f32 %m_f16 +; Store float32 result to workgroup memory + %p_float = OpAccessChain %ptr_wg_float %wg_data_f %uint_0 + OpCooperativeMatrixStoreKHR %p_float %m_f32 %uint_0 %uint_8 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-elementwise.asm.msl31.comp b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-elementwise.asm.msl31.comp new file mode 100644 index 000000000000..2353b9c4cf0e --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-elementwise.asm.msl31.comp @@ -0,0 +1,49 @@ +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 60 +; Schema: 0 + OpCapability Shader + OpCapability CooperativeMatrixKHR + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_cooperative_matrix" + OpExtension "SPV_KHR_vulkan_memory_model" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 32 1 1 + OpName %main "main" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_3 = OpConstant %uint 3 + %uint_8 = OpConstant %uint 8 + %uint_64 = OpConstant %uint 64 + %arr_float = OpTypeArray %float %uint_64 +%ptr_wg_arr = OpTypePointer Workgroup %arr_float + %wg_data = OpVariable %ptr_wg_arr Workgroup +%ptr_wg_float = OpTypePointer Workgroup %float +; float32 accumulator cooperative matrix type (use=2 = Accumulator) +%coopmat_f32 = OpTypeCooperativeMatrixKHR %float %uint_3 %uint_8 %uint_8 %uint_1 + %main = OpFunction %void None %3 + %5 = OpLabel + %p = OpAccessChain %ptr_wg_float %wg_data %uint_0 +; Load two float matrices from workgroup memory (row-major) + %m_a = OpCooperativeMatrixLoadKHR %coopmat_f32 %p %uint_0 %uint_8 + %m_b = OpCooperativeMatrixLoadKHR %coopmat_f32 %p %uint_0 %uint_8 +; FNegate: element-wise negate + %neg_a = OpFNegate %coopmat_f32 %m_a +; FAdd: element-wise add + %add_r = OpFAdd %coopmat_f32 %neg_a %m_b +; FSub: element-wise subtract + %sub_r = OpFSub %coopmat_f32 %add_r %m_a +; FMul: element-wise multiply (NOT matrix multiply) + %mul_r = OpFMul %coopmat_f32 %sub_r %m_b +; FDiv: element-wise divide + %div_r = OpFDiv %coopmat_f32 %mul_r %m_a +; Store result back + OpCooperativeMatrixStoreKHR %p %div_r %uint_0 %uint_8 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-extract-insert.asm.spv16.msl31.comp b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-extract-insert.asm.spv16.msl31.comp new file mode 100644 index 000000000000..d67bc0b536af --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-extract-insert.asm.spv16.msl31.comp @@ -0,0 +1,49 @@ +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 55 +; Schema: 0 + OpCapability Shader + OpCapability CooperativeMatrixKHR + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_cooperative_matrix" + OpExtension "SPV_KHR_vulkan_memory_model" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %main "main" %wg_data + OpExecutionMode %main LocalSize 32 1 1 + OpName %main "main" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_3 = OpConstant %uint 3 + %uint_8 = OpConstant %uint 8 + %uint_64 = OpConstant %uint 64 + %float_1 = OpConstant %float 1 + %arr_float = OpTypeArray %float %uint_64 +%ptr_wg_arr = OpTypePointer Workgroup %arr_float + %wg_data = OpVariable %ptr_wg_arr Workgroup +%ptr_wg_float = OpTypePointer Workgroup %float +; float32 cooperative matrix type +%coopmat_f32 = OpTypeCooperativeMatrixKHR %float %uint_3 %uint_8 %uint_8 %uint_0 + %main = OpFunction %void None %3 + %5 = OpLabel + %p = OpAccessChain %ptr_wg_float %wg_data %uint_0 +; Load a matrix + %mat = OpCooperativeMatrixLoadKHR %coopmat_f32 %p %uint_0 %uint_8 +; Extract the first component this invocation holds (index 0) + %elem_0 = OpCompositeExtract %float %mat 0 +; Extract the second component this invocation holds (index 1) + %elem_1 = OpCompositeExtract %float %mat 1 +; Insert 1.0 into component 0 of the matrix + %mat_ins = OpCompositeInsert %coopmat_f32 %float_1 %mat 0 +; Store the modified matrix + OpCooperativeMatrixStoreKHR %p %mat_ins %uint_0 %uint_8 +; Store the extracted scalars to workgroup memory so they are not optimized away + %p_elem0 = OpAccessChain %ptr_wg_float %wg_data %uint_0 + OpStore %p_elem0 %elem_0 + %p_elem1 = OpAccessChain %ptr_wg_float %wg_data %uint_0 + OpStore %p_elem1 %elem_1 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-length.asm.msl31.comp b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-length.asm.msl31.comp new file mode 100644 index 000000000000..69e58586999e --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-length.asm.msl31.comp @@ -0,0 +1,42 @@ +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 24 +; Schema: 0 + OpCapability Shader + OpCapability CooperativeMatrixKHR + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_cooperative_matrix" + OpExtension "SPV_KHR_vulkan_memory_model" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 32 1 1 + OpName %main "main" + OpName %SSBO "SSBO" + OpMemberName %SSBO 0 "data" + OpName %ssbo "ssbo" + OpDecorate %arr_uint ArrayStride 4 + OpMemberDecorate %SSBO 0 Offset 0 + OpDecorate %SSBO Block + OpDecorate %ssbo DescriptorSet 0 + OpDecorate %ssbo Binding 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %float = OpTypeFloat 32 + %uint_0 = OpConstant %uint 0 + %uint_3 = OpConstant %uint 3 + %uint_8 = OpConstant %uint 8 + %arr_uint = OpTypeRuntimeArray %uint + %SSBO = OpTypeStruct %arr_uint +%ptr_ssbo_SSBO = OpTypePointer StorageBuffer %SSBO + %ssbo = OpVariable %ptr_ssbo_SSBO StorageBuffer +%ptr_ssbo_uint = OpTypePointer StorageBuffer %uint + %coopmat_a = OpTypeCooperativeMatrixKHR %float %uint_3 %uint_8 %uint_8 %uint_0 + %main = OpFunction %void None %3 + %5 = OpLabel + %len = OpCooperativeMatrixLengthKHR %uint %coopmat_a + %p = OpAccessChain %ptr_ssbo_uint %ssbo %uint_0 %uint_0 + OpStore %p %len + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-load-store.asm.msl31.comp b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-load-store.asm.msl31.comp new file mode 100644 index 000000000000..a1fcb26e90c2 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-load-store.asm.msl31.comp @@ -0,0 +1,51 @@ +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 50 +; Schema: 0 + OpCapability Shader + OpCapability CooperativeMatrixKHR + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_cooperative_matrix" + OpExtension "SPV_KHR_vulkan_memory_model" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 32 1 1 + OpName %main "main" + OpName %SSBO "SSBO" + OpMemberName %SSBO 0 "data" + OpName %ssbo "ssbo" + OpDecorate %arr_float ArrayStride 4 + OpMemberDecorate %SSBO 0 Offset 0 + OpDecorate %SSBO Block + OpDecorate %ssbo DescriptorSet 0 + OpDecorate %ssbo Binding 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_8 = OpConstant %uint 8 + %arr_float = OpTypeRuntimeArray %float + %SSBO = OpTypeStruct %arr_float +%ptr_ssbo_SSBO = OpTypePointer StorageBuffer %SSBO + %ssbo = OpVariable %ptr_ssbo_SSBO StorageBuffer +%ptr_ssbo_float = OpTypePointer StorageBuffer %float +%coopmat_a = OpTypeCooperativeMatrixKHR %float %uint_3 %uint_8 %uint_8 %uint_0 +%coopmat_acc = OpTypeCooperativeMatrixKHR %float %uint_3 %uint_8 %uint_8 %uint_2 + %main = OpFunction %void None %3 + %5 = OpLabel +; Row-major load from offset 0 + %p0 = OpAccessChain %ptr_ssbo_float %ssbo %uint_0 %uint_0 + %mat_a = OpCooperativeMatrixLoadKHR %coopmat_a %p0 %uint_0 %uint_8 +; Row-major store to offset 0 + OpCooperativeMatrixStoreKHR %p0 %mat_a %uint_0 %uint_8 +; Column-major load from offset 0 + %mat_col = OpCooperativeMatrixLoadKHR %coopmat_acc %p0 %uint_1 %uint_8 +; Column-major store to offset 0 + OpCooperativeMatrixStoreKHR %p0 %mat_col %uint_1 %uint_8 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-muladd.asm.msl31.comp b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-muladd.asm.msl31.comp new file mode 100644 index 000000000000..1ddc3eb44b41 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-muladd.asm.msl31.comp @@ -0,0 +1,77 @@ +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 60 +; Schema: 0 + OpCapability Shader + OpCapability Float16 + OpCapability CooperativeMatrixKHR + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_cooperative_matrix" + OpExtension "SPV_KHR_vulkan_memory_model" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 32 1 1 + OpName %main "main" + OpName %SSBO32 "SSBO32" + OpMemberName %SSBO32 0 "data" + OpName %ssbo32 "ssbo32" + OpName %SSBO16 "SSBO16" + OpMemberName %SSBO16 0 "data" + OpName %ssbo16 "ssbo16" + OpDecorate %arr_float ArrayStride 4 + OpMemberDecorate %SSBO32 0 Offset 0 + OpDecorate %SSBO32 Block + OpDecorate %ssbo32 DescriptorSet 0 + OpDecorate %ssbo32 Binding 0 + OpDecorate %arr_half ArrayStride 2 + OpMemberDecorate %SSBO16 0 Offset 0 + OpDecorate %SSBO16 Block + OpDecorate %ssbo16 DescriptorSet 0 + OpDecorate %ssbo16 Binding 1 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %half = OpTypeFloat 16 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_8 = OpConstant %uint 8 + %arr_float = OpTypeRuntimeArray %float + %SSBO32 = OpTypeStruct %arr_float +%ptr_ssbo_SSBO32 = OpTypePointer StorageBuffer %SSBO32 + %ssbo32 = OpVariable %ptr_ssbo_SSBO32 StorageBuffer + %arr_half = OpTypeRuntimeArray %half + %SSBO16 = OpTypeStruct %arr_half +%ptr_ssbo_SSBO16 = OpTypePointer StorageBuffer %SSBO16 + %ssbo16 = OpVariable %ptr_ssbo_SSBO16 StorageBuffer +%ptr_ssbo_float = OpTypePointer StorageBuffer %float +%ptr_ssbo_half = OpTypePointer StorageBuffer %half +; float32 cooperative matrix types +%coopmat_f32_A = OpTypeCooperativeMatrixKHR %float %uint_3 %uint_8 %uint_8 %uint_0 +%coopmat_f32_B = OpTypeCooperativeMatrixKHR %float %uint_3 %uint_8 %uint_8 %uint_1 +%coopmat_f32_acc = OpTypeCooperativeMatrixKHR %float %uint_3 %uint_8 %uint_8 %uint_2 +; half cooperative matrix types +%coopmat_f16_A = OpTypeCooperativeMatrixKHR %half %uint_3 %uint_8 %uint_8 %uint_0 +%coopmat_f16_B = OpTypeCooperativeMatrixKHR %half %uint_3 %uint_8 %uint_8 %uint_1 +%coopmat_f16_acc = OpTypeCooperativeMatrixKHR %half %uint_3 %uint_8 %uint_8 %uint_2 + %main = OpFunction %void None %3 + %5 = OpLabel +; float32 muladd: D = A * B + C + %p_f32 = OpAccessChain %ptr_ssbo_float %ssbo32 %uint_0 %uint_0 + %f_A = OpCooperativeMatrixLoadKHR %coopmat_f32_A %p_f32 %uint_0 %uint_8 + %f_B = OpCooperativeMatrixLoadKHR %coopmat_f32_B %p_f32 %uint_0 %uint_8 + %f_C = OpCooperativeMatrixLoadKHR %coopmat_f32_acc %p_f32 %uint_0 %uint_8 + %f_D = OpCooperativeMatrixMulAddKHR %coopmat_f32_acc %f_A %f_B %f_C + OpCooperativeMatrixStoreKHR %p_f32 %f_D %uint_0 %uint_8 +; half muladd: D = A * B + C + %p_f16 = OpAccessChain %ptr_ssbo_half %ssbo16 %uint_0 %uint_0 + %h_A = OpCooperativeMatrixLoadKHR %coopmat_f16_A %p_f16 %uint_0 %uint_8 + %h_B = OpCooperativeMatrixLoadKHR %coopmat_f16_B %p_f16 %uint_0 %uint_8 + %h_C = OpCooperativeMatrixLoadKHR %coopmat_f16_acc %p_f16 %uint_0 %uint_8 + %h_D = OpCooperativeMatrixMulAddKHR %coopmat_f16_acc %h_A %h_B %h_C + OpCooperativeMatrixStoreKHR %p_f16 %h_D %uint_0 %uint_8 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-multi-simdgroup.asm.spv16.msl31.comp b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-multi-simdgroup.asm.spv16.msl31.comp new file mode 100644 index 000000000000..08c9d930e77f --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-multi-simdgroup.asm.spv16.msl31.comp @@ -0,0 +1,39 @@ +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 55 +; Schema: 0 + OpCapability Shader + OpCapability CooperativeMatrixKHR + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_cooperative_matrix" + OpExtension "SPV_KHR_vulkan_memory_model" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %main "main" %wg_data +; Two simdgroups: 64 threads total. Validates that the per-simdgroup scratch +; window is sized correctly (128 elements = 2 * 64) and indexed with +; simdgroup_index_in_threadgroup * 64u so the two groups do not collide. + OpExecutionMode %main LocalSize 64 1 1 + OpName %main "main" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_3 = OpConstant %uint 3 + %uint_8 = OpConstant %uint 8 + %uint_64 = OpConstant %uint 64 + %float_2 = OpConstant %float 2 + %arr_float = OpTypeArray %float %uint_64 +%ptr_wg_arr = OpTypePointer Workgroup %arr_float + %wg_data = OpVariable %ptr_wg_arr Workgroup +%ptr_wg_float = OpTypePointer Workgroup %float +%coopmat_f32 = OpTypeCooperativeMatrixKHR %float %uint_3 %uint_8 %uint_8 %uint_0 + %main = OpFunction %void None %3 + %5 = OpLabel + %p = OpAccessChain %ptr_wg_float %wg_data %uint_0 + %mat = OpCooperativeMatrixLoadKHR %coopmat_f32 %p %uint_0 %uint_8 + %negated = OpFNegate %coopmat_f32 %mat + OpCooperativeMatrixStoreKHR %p %negated %uint_0 %uint_8 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-scalar-mul.asm.msl31.comp b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-scalar-mul.asm.msl31.comp new file mode 100644 index 000000000000..b0c260f8ded1 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-scalar-mul.asm.msl31.comp @@ -0,0 +1,40 @@ +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 45 +; Schema: 0 + OpCapability Shader + OpCapability CooperativeMatrixKHR + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_cooperative_matrix" + OpExtension "SPV_KHR_vulkan_memory_model" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 32 1 1 + OpName %main "main" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_3 = OpConstant %uint 3 + %uint_8 = OpConstant %uint 8 + %uint_64 = OpConstant %uint 64 + %float_2 = OpConstant %float 2 + %arr_float = OpTypeArray %float %uint_64 +%ptr_wg_arr = OpTypePointer Workgroup %arr_float + %wg_data = OpVariable %ptr_wg_arr Workgroup +%ptr_wg_float = OpTypePointer Workgroup %float +; float32 accumulator cooperative matrix type +%coopmat_f32 = OpTypeCooperativeMatrixKHR %float %uint_3 %uint_8 %uint_8 %uint_0 + %main = OpFunction %void None %3 + %5 = OpLabel + %p = OpAccessChain %ptr_wg_float %wg_data %uint_0 +; Load matrix from workgroup memory + %mat = OpCooperativeMatrixLoadKHR %coopmat_f32 %p %uint_0 %uint_8 +; Scale every element by 2.0 via OpMatrixTimesScalar + %scaled = OpMatrixTimesScalar %coopmat_f32 %mat %float_2 +; Store result back + OpCooperativeMatrixStoreKHR %p %scaled %uint_0 %uint_8 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-select.asm.invalid.msl31.comp b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-select.asm.invalid.msl31.comp new file mode 100644 index 000000000000..9910f2a4fbe6 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-select.asm.invalid.msl31.comp @@ -0,0 +1,41 @@ +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 45 +; Schema: 0 + OpCapability Shader + OpCapability CooperativeMatrixKHR + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_cooperative_matrix" + OpExtension "SPV_KHR_vulkan_memory_model" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %main "main" %wg_data + OpExecutionMode %main LocalSize 32 1 1 + OpName %main "main" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %bool = OpTypeBool + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_3 = OpConstant %uint 3 + %uint_8 = OpConstant %uint 8 + %uint_64 = OpConstant %uint 64 + %bool_true = OpConstantTrue %bool + %arr_float = OpTypeArray %float %uint_64 +%ptr_wg_arr = OpTypePointer Workgroup %arr_float + %wg_data = OpVariable %ptr_wg_arr Workgroup +%ptr_wg_float = OpTypePointer Workgroup %float +; float32 cooperative matrix type +%coopmat_f32 = OpTypeCooperativeMatrixKHR %float %uint_3 %uint_8 %uint_8 %uint_0 + %main = OpFunction %void None %3 + %5 = OpLabel + %p = OpAccessChain %ptr_wg_float %wg_data %uint_0 +; Load two matrices + %m_a = OpCooperativeMatrixLoadKHR %coopmat_f32 %p %uint_0 %uint_8 + %m_b = OpCooperativeMatrixLoadKHR %coopmat_f32 %p %uint_0 %uint_8 +; OpSelect with scalar bool condition: result = true ? m_a : m_b + %result = OpSelect %coopmat_f32 %bool_true %m_a %m_b + OpCooperativeMatrixStoreKHR %p %result %uint_0 %uint_8 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-splat.asm.msl31.comp b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-splat.asm.msl31.comp new file mode 100644 index 000000000000..9d249c97ec3c --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-splat.asm.msl31.comp @@ -0,0 +1,38 @@ +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 40 +; Schema: 0 + OpCapability Shader + OpCapability CooperativeMatrixKHR + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_cooperative_matrix" + OpExtension "SPV_KHR_vulkan_memory_model" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 32 1 1 + OpName %main "main" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_3 = OpConstant %uint 3 + %uint_8 = OpConstant %uint 8 + %uint_64 = OpConstant %uint 64 + %float_0 = OpConstant %float 0 + %arr_float = OpTypeArray %float %uint_64 +%ptr_wg_arr = OpTypePointer Workgroup %arr_float + %wg_data = OpVariable %ptr_wg_arr Workgroup +%ptr_wg_float = OpTypePointer Workgroup %float +; float32 accumulator cooperative matrix type +%coopmat_f32 = OpTypeCooperativeMatrixKHR %float %uint_3 %uint_8 %uint_8 %uint_0 + %main = OpFunction %void None %3 + %5 = OpLabel +; Splat scalar 0.0 into all elements via OpCompositeConstruct + %splat_0 = OpCompositeConstruct %coopmat_f32 %float_0 +; Store the splatted matrix to workgroup memory + %p = OpAccessChain %ptr_wg_float %wg_data %uint_0 + OpCooperativeMatrixStoreKHR %p %splat_0 %uint_0 %uint_8 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-workgroup-cast-load-store.asm.msl31.comp b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-workgroup-cast-load-store.asm.msl31.comp new file mode 100644 index 000000000000..a8022da52793 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-workgroup-cast-load-store.asm.msl31.comp @@ -0,0 +1,41 @@ +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 80 +; Schema: 0 + OpCapability Shader + OpCapability CooperativeMatrixKHR + OpCapability Float16 + OpCapability Int8 + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_cooperative_matrix" + OpExtension "SPV_KHR_vulkan_memory_model" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 32 1 1 + OpName %main "main" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %u8 = OpTypeInt 8 0 + %half = OpTypeFloat 16 + %uint_0 = OpConstant %uint 0 + %uint_3 = OpConstant %uint 3 + %uint_8 = OpConstant %uint 8 + %uint_16 = OpConstant %uint 16 + %uint_128 = OpConstant %uint 128 + %arr_u8 = OpTypeArray %u8 %uint_128 +%ptr_wg_arr_u8 = OpTypePointer Workgroup %arr_u8 + %wg_data = OpVariable %ptr_wg_arr_u8 Workgroup +%ptr_wg_u8 = OpTypePointer Workgroup %u8 +%coopmat_half = OpTypeCooperativeMatrixKHR %half %uint_3 %uint_8 %uint_8 %uint_0 + %u8_zero = OpConstant %u8 0 + %main = OpFunction %void None %3 + %5 = OpLabel +; Use uint8_t backing storage. MSL backend must cast pointer and convert stride from bytes to elements. + %p_u8 = OpAccessChain %ptr_wg_u8 %wg_data %uint_0 + OpStore %p_u8 %u8_zero + %mat = OpCooperativeMatrixLoadKHR %coopmat_half %p_u8 %uint_0 %uint_16 + OpCooperativeMatrixStoreKHR %p_u8 %mat %uint_0 %uint_16 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-workgroup-load-store.asm.msl31.comp b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-workgroup-load-store.asm.msl31.comp new file mode 100644 index 000000000000..8c49080c6533 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/cooperative-matrix-workgroup-load-store.asm.msl31.comp @@ -0,0 +1,39 @@ +; SPIR-V +; Version: 1.6 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 60 +; Schema: 0 + OpCapability Shader + OpCapability CooperativeMatrixKHR + OpCapability VulkanMemoryModel + OpExtension "SPV_KHR_cooperative_matrix" + OpExtension "SPV_KHR_vulkan_memory_model" + OpMemoryModel Logical Vulkan + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 32 1 1 + OpName %main "main" + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_3 = OpConstant %uint 3 + %uint_8 = OpConstant %uint 8 + %uint_64 = OpConstant %uint 64 + %arr_float = OpTypeArray %float %uint_64 +%ptr_wg_arr_float = OpTypePointer Workgroup %arr_float + %wg_data = OpVariable %ptr_wg_arr_float Workgroup +%ptr_wg_float = OpTypePointer Workgroup %float +%coopmat_a = OpTypeCooperativeMatrixKHR %float %uint_3 %uint_8 %uint_8 %uint_0 + %main = OpFunction %void None %3 + %5 = OpLabel +; Row-major load/store from workgroup memory. + %p0 = OpAccessChain %ptr_wg_float %wg_data %uint_0 + %mat_row = OpCooperativeMatrixLoadKHR %coopmat_a %p0 %uint_0 %uint_8 + OpCooperativeMatrixStoreKHR %p0 %mat_row %uint_0 %uint_8 +; Column-major load/store from workgroup memory. + %mat_col = OpCooperativeMatrixLoadKHR %coopmat_a %p0 %uint_1 %uint_8 + OpCooperativeMatrixStoreKHR %p0 %mat_col %uint_1 %uint_8 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/volatile-phys-buf-load-no-forward.asm.msl24.comp b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/volatile-phys-buf-load-no-forward.asm.msl24.comp new file mode 100644 index 000000000000..7770ef68dcf7 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/comp/volatile-phys-buf-load-no-forward.asm.msl24.comp @@ -0,0 +1,60 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 40 +; Schema: 0 + OpCapability Shader + OpCapability Int64 + OpCapability PhysicalStorageBufferAddresses + OpExtension "SPV_KHR_physical_storage_buffer" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel PhysicalStorageBuffer64 GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpName %main "main" + OpName %Registers "Registers" + OpMemberName %Registers 0 "addr" + OpMemberName %Registers 1 "addr2" + OpName %registers "registers" + OpMemberDecorate %Registers 0 Offset 0 + OpMemberDecorate %Registers 1 Offset 8 + OpDecorate %Registers Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %int = OpTypeInt 32 1 + %ulong = OpTypeInt 64 0 + %Registers = OpTypeStruct %ulong %ulong +%_ptr_PushConstant_Registers = OpTypePointer PushConstant %Registers + %registers = OpVariable %_ptr_PushConstant_Registers PushConstant + %int_0 = OpConstant %int 0 + %int_1 = OpConstant %int 1 + %ulong_4 = OpConstant %ulong 4 +%_ptr_PushConstant_ulong = OpTypePointer PushConstant %ulong +%_ptr_PhysicalStorageBuffer_int = OpTypePointer PhysicalStorageBuffer %int + %main = OpFunction %void None %3 + %5 = OpLabel + + %pc0 = OpAccessChain %_ptr_PushConstant_ulong %registers %int_0 + %addr0 = OpLoad %ulong %pc0 + %src_p = OpConvertUToPtr %_ptr_PhysicalStorageBuffer_int %addr0 + + %pc1 = OpAccessChain %_ptr_PushConstant_ulong %registers %int_1 + %addr1 = OpLoad %ulong %pc1 + %dst_p = OpConvertUToPtr %_ptr_PhysicalStorageBuffer_int %addr1 + + ; Volatile load from src — must NOT be forwarded + %ld = OpLoad %int %src_p Volatile|Aligned 4 + + ; Store the loaded value into dst (first use) + OpStore %dst_p %ld Aligned 4 + + ; Compute dst + 1 element via integer arithmetic + %dst_u64 = OpConvertPtrToU %ulong %dst_p + %dst_plus4 = OpIAdd %ulong %dst_u64 %ulong_4 + %dst_p2 = OpConvertUToPtr %_ptr_PhysicalStorageBuffer_int %dst_plus4 + + ; Store the same loaded value again (second use) + OpStore %dst_p2 %ld Aligned 4 + + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/spec-constant-dead-branch-comparison-array.asm.frag b/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/spec-constant-dead-branch-comparison-array.asm.frag new file mode 100644 index 000000000000..321dc813aa80 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/spec-constant-dead-branch-comparison-array.asm.frag @@ -0,0 +1,75 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 55 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %in_var_TEXCOORD0 %out_var_SV_Target0 + OpExecutionMode %main OriginUpperLeft + OpSource HLSL 600 + OpName %type_2d_image_array "type.2d.image.array" + OpName %ShadowMapArray "ShadowMapArray" + OpName %type_sampler "type.sampler" + OpName %Sampler "Sampler" + OpName %get_sampler_type "get_sampler_type" + OpName %in_var_TEXCOORD0 "in.var.TEXCOORD0" + OpName %out_var_SV_Target0 "out.var.SV_Target0" + OpName %main "main" + OpName %type_sampled_image "type.sampled.image" + OpDecorate %in_var_TEXCOORD0 Location 0 + OpDecorate %out_var_SV_Target0 Location 0 + OpDecorate %ShadowMapArray DescriptorSet 0 + OpDecorate %ShadowMapArray Binding 0 + OpDecorate %Sampler DescriptorSet 0 + OpDecorate %Sampler Binding 1 + OpDecorate %SamplerType SpecId 0 + %float = OpTypeFloat 32 + %float_0_5 = OpConstant %float 0.5 + %float_1 = OpConstant %float 1 + %float_0 = OpConstant %float 0 + %v4float = OpTypeVector %float 4 +%type_2d_image_array = OpTypeImage %float 2D 2 1 0 1 Unknown +%_ptr_UniformConstant_type_2d_image_array = OpTypePointer UniformConstant %type_2d_image_array +%type_sampler = OpTypeSampler +%_ptr_UniformConstant_type_sampler = OpTypePointer UniformConstant %type_sampler + %v3float = OpTypeVector %float 3 +%_ptr_Input_v3float = OpTypePointer Input %v3float +%_ptr_Output_v4float = OpTypePointer Output %v4float + %void = OpTypeVoid + %21 = OpTypeFunction %void + %uint = OpTypeInt 32 0 +%SamplerType = OpSpecConstant %uint 0 + %25 = OpTypeFunction %uint + %bool = OpTypeBool + %uint_3 = OpConstant %uint 3 +%type_sampled_image = OpTypeSampledImage %type_2d_image_array + %ShadowMapArray = OpVariable %_ptr_UniformConstant_type_2d_image_array UniformConstant + %Sampler = OpVariable %_ptr_UniformConstant_type_sampler UniformConstant +%in_var_TEXCOORD0 = OpVariable %_ptr_Input_v3float Input +%out_var_SV_Target0 = OpVariable %_ptr_Output_v4float Output +%get_sampler_type = OpFunction %uint None %25 + %30 = OpLabel + OpReturnValue %SamplerType + OpFunctionEnd + %main = OpFunction %void None %21 + %32 = OpLabel + %33 = OpLoad %v3float %in_var_TEXCOORD0 + %34 = OpFunctionCall %uint %get_sampler_type + %35 = OpIEqual %bool %34 %uint_3 + OpSelectionMerge %36 None + OpBranchConditional %35 %37 %36 + %37 = OpLabel + %38 = OpLoad %type_2d_image_array %ShadowMapArray + %39 = OpLoad %type_sampler %Sampler + %40 = OpSampledImage %type_sampled_image %38 %39 + %41 = OpImageSampleDrefExplicitLod %float %40 %33 %float_0_5 Lod %float_0 + OpBranch %36 + %36 = OpLabel + %42 = OpLoad %type_2d_image_array %ShadowMapArray + %43 = OpLoad %type_sampler %Sampler + %44 = OpSampledImage %type_sampled_image %42 %43 + %45 = OpImageSampleImplicitLod %v4float %44 %33 None + OpStore %out_var_SV_Target0 %45 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/spec-constant-dead-branch-comparison-cube.asm.frag b/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/spec-constant-dead-branch-comparison-cube.asm.frag new file mode 100644 index 000000000000..4e8493ef9b18 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/spec-constant-dead-branch-comparison-cube.asm.frag @@ -0,0 +1,75 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 55 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %in_var_TEXCOORD0 %out_var_SV_Target0 + OpExecutionMode %main OriginUpperLeft + OpSource HLSL 600 + OpName %type_cube_image "type.cube.image" + OpName %ShadowMapCube "ShadowMapCube" + OpName %type_sampler "type.sampler" + OpName %Sampler "Sampler" + OpName %get_sampler_type "get_sampler_type" + OpName %in_var_TEXCOORD0 "in.var.TEXCOORD0" + OpName %out_var_SV_Target0 "out.var.SV_Target0" + OpName %main "main" + OpName %type_sampled_image "type.sampled.image" + OpDecorate %in_var_TEXCOORD0 Location 0 + OpDecorate %out_var_SV_Target0 Location 0 + OpDecorate %ShadowMapCube DescriptorSet 0 + OpDecorate %ShadowMapCube Binding 0 + OpDecorate %Sampler DescriptorSet 0 + OpDecorate %Sampler Binding 1 + OpDecorate %SamplerType SpecId 0 + %float = OpTypeFloat 32 + %float_0_5 = OpConstant %float 0.5 + %float_1 = OpConstant %float 1 + %float_0 = OpConstant %float 0 + %v4float = OpTypeVector %float 4 +%type_cube_image = OpTypeImage %float Cube 2 0 0 1 Unknown +%_ptr_UniformConstant_type_cube_image = OpTypePointer UniformConstant %type_cube_image +%type_sampler = OpTypeSampler +%_ptr_UniformConstant_type_sampler = OpTypePointer UniformConstant %type_sampler + %v3float = OpTypeVector %float 3 +%_ptr_Input_v3float = OpTypePointer Input %v3float +%_ptr_Output_v4float = OpTypePointer Output %v4float + %void = OpTypeVoid + %21 = OpTypeFunction %void + %uint = OpTypeInt 32 0 +%SamplerType = OpSpecConstant %uint 0 + %25 = OpTypeFunction %uint + %bool = OpTypeBool + %uint_3 = OpConstant %uint 3 +%type_sampled_image = OpTypeSampledImage %type_cube_image + %ShadowMapCube = OpVariable %_ptr_UniformConstant_type_cube_image UniformConstant + %Sampler = OpVariable %_ptr_UniformConstant_type_sampler UniformConstant +%in_var_TEXCOORD0 = OpVariable %_ptr_Input_v3float Input +%out_var_SV_Target0 = OpVariable %_ptr_Output_v4float Output +%get_sampler_type = OpFunction %uint None %25 + %30 = OpLabel + OpReturnValue %SamplerType + OpFunctionEnd + %main = OpFunction %void None %21 + %32 = OpLabel + %33 = OpLoad %v3float %in_var_TEXCOORD0 + %34 = OpFunctionCall %uint %get_sampler_type + %35 = OpIEqual %bool %34 %uint_3 + OpSelectionMerge %36 None + OpBranchConditional %35 %37 %36 + %37 = OpLabel + %38 = OpLoad %type_cube_image %ShadowMapCube + %39 = OpLoad %type_sampler %Sampler + %40 = OpSampledImage %type_sampled_image %38 %39 + %41 = OpImageSampleDrefExplicitLod %float %40 %33 %float_0_5 Lod %float_0 + OpBranch %36 + %36 = OpLabel + %42 = OpLoad %type_cube_image %ShadowMapCube + %43 = OpLoad %type_sampler %Sampler + %44 = OpSampledImage %type_sampled_image %42 %43 + %45 = OpImageSampleImplicitLod %v4float %44 %33 None + OpStore %out_var_SV_Target0 %45 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/spec-constant-dead-branch-comparison.asm.frag b/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/spec-constant-dead-branch-comparison.asm.frag new file mode 100644 index 000000000000..ab6afaf8bb8f --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/frag/spec-constant-dead-branch-comparison.asm.frag @@ -0,0 +1,75 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 55 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %in_var_TEXCOORD0 %out_var_SV_Target0 + OpExecutionMode %main OriginUpperLeft + OpSource HLSL 600 + OpName %type_2d_image "type.2d.image" + OpName %ShadowMap "ShadowMap" + OpName %type_sampler "type.sampler" + OpName %Sampler "Sampler" + OpName %get_sampler_type "get_sampler_type" + OpName %in_var_TEXCOORD0 "in.var.TEXCOORD0" + OpName %out_var_SV_Target0 "out.var.SV_Target0" + OpName %main "main" + OpName %type_sampled_image "type.sampled.image" + OpDecorate %in_var_TEXCOORD0 Location 0 + OpDecorate %out_var_SV_Target0 Location 0 + OpDecorate %ShadowMap DescriptorSet 0 + OpDecorate %ShadowMap Binding 0 + OpDecorate %Sampler DescriptorSet 0 + OpDecorate %Sampler Binding 1 + OpDecorate %SamplerType SpecId 0 + %float = OpTypeFloat 32 + %float_0_5 = OpConstant %float 0.5 + %float_1 = OpConstant %float 1 + %float_0 = OpConstant %float 0 + %v4float = OpTypeVector %float 4 +%type_2d_image = OpTypeImage %float 2D 2 0 0 1 Unknown +%_ptr_UniformConstant_type_2d_image = OpTypePointer UniformConstant %type_2d_image +%type_sampler = OpTypeSampler +%_ptr_UniformConstant_type_sampler = OpTypePointer UniformConstant %type_sampler + %v2float = OpTypeVector %float 2 +%_ptr_Input_v2float = OpTypePointer Input %v2float +%_ptr_Output_v4float = OpTypePointer Output %v4float + %void = OpTypeVoid + %21 = OpTypeFunction %void + %uint = OpTypeInt 32 0 +%SamplerType = OpSpecConstant %uint 0 + %25 = OpTypeFunction %uint + %bool = OpTypeBool + %uint_3 = OpConstant %uint 3 +%type_sampled_image = OpTypeSampledImage %type_2d_image + %ShadowMap = OpVariable %_ptr_UniformConstant_type_2d_image UniformConstant + %Sampler = OpVariable %_ptr_UniformConstant_type_sampler UniformConstant +%in_var_TEXCOORD0 = OpVariable %_ptr_Input_v2float Input +%out_var_SV_Target0 = OpVariable %_ptr_Output_v4float Output +%get_sampler_type = OpFunction %uint None %25 + %30 = OpLabel + OpReturnValue %SamplerType + OpFunctionEnd + %main = OpFunction %void None %21 + %32 = OpLabel + %33 = OpLoad %v2float %in_var_TEXCOORD0 + %34 = OpFunctionCall %uint %get_sampler_type + %35 = OpIEqual %bool %34 %uint_3 + OpSelectionMerge %36 None + OpBranchConditional %35 %37 %36 + %37 = OpLabel + %38 = OpLoad %type_2d_image %ShadowMap + %39 = OpLoad %type_sampler %Sampler + %40 = OpSampledImage %type_sampled_image %38 %39 + %41 = OpImageSampleDrefExplicitLod %float %40 %33 %float_0_5 Lod %float_0 + OpBranch %36 + %36 = OpLabel + %42 = OpLoad %type_2d_image %ShadowMap + %43 = OpLoad %type_sampler %Sampler + %44 = OpSampledImage %type_sampled_image %42 %43 + %45 = OpImageSampleImplicitLod %v4float %44 %33 None + OpStore %out_var_SV_Target0 %45 + 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.invalid.vert similarity index 100% rename from third_party/spirv-cross/shaders-msl-no-opt/asm/vert/pointer-to-pointer.asm.vert rename to third_party/spirv-cross/shaders-msl-no-opt/asm/vert/pointer-to-pointer.asm.invalid.vert diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/vert/push-constant-row-major-matrix.asm.vk.vert b/third_party/spirv-cross/shaders-msl-no-opt/asm/vert/push-constant-row-major-matrix.asm.vk.vert new file mode 100644 index 000000000000..afe5581ba46e --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/vert/push-constant-row-major-matrix.asm.vk.vert @@ -0,0 +1,66 @@ +; SPIR-V +; Version: 1.0 +; Generator: Google spiregg; 0 +; Bound: 23 +; Schema: 0 + OpCapability Shader + OpExtension "SPV_GOOGLE_hlsl_functionality1" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %in_var_POSITION %gl_Position + %4 = OpString ".\\push-constant-row-major-matrix.hlsl" + OpSource HLSL 600 %4 " +struct Matrix { + float4x4 transform; +}; + +[[vk::push_constant]] Matrix matrix_constants; + +float4 main(float4 in_position : POSITION) : SV_Position { + return mul(matrix_constants.transform, in_position); +} +" + OpName %type_PushConstant_Matrix "type.PushConstant.Matrix" + OpMemberName %type_PushConstant_Matrix 0 "transform" + OpName %matrix_constants "matrix_constants" + OpName %in_var_POSITION "in.var.POSITION" + OpName %main "main" + OpDecorateString %in_var_POSITION UserSemantic "POSITION" + OpDecorate %gl_Position BuiltIn Position + OpDecorateString %gl_Position UserSemantic "SV_Position" + OpDecorate %in_var_POSITION Location 0 + OpMemberDecorate %type_PushConstant_Matrix 0 Offset 0 + OpMemberDecorate %type_PushConstant_Matrix 0 MatrixStride 16 + OpMemberDecorate %type_PushConstant_Matrix 0 RowMajor + OpDecorate %type_PushConstant_Matrix Block + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%mat4v4float = OpTypeMatrix %v4float 4 +%type_PushConstant_Matrix = OpTypeStruct %mat4v4float +%_ptr_PushConstant_type_PushConstant_Matrix = OpTypePointer PushConstant %type_PushConstant_Matrix +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Output_v4float = OpTypePointer Output %v4float + %void = OpTypeVoid + %16 = OpTypeFunction %void +%_ptr_PushConstant_mat4v4float = OpTypePointer PushConstant %mat4v4float +%matrix_constants = OpVariable %_ptr_PushConstant_type_PushConstant_Matrix PushConstant +%in_var_POSITION = OpVariable %_ptr_Input_v4float Input +%gl_Position = OpVariable %_ptr_Output_v4float Output + OpLine %4 8 1 + %main = OpFunction %void None %16 + OpNoLine + %18 = OpLabel + OpLine %4 8 1 + %19 = OpLoad %v4float %in_var_POSITION + OpLine %4 9 16 + %20 = OpAccessChain %_ptr_PushConstant_mat4v4float %matrix_constants %int_0 + OpLine %4 9 33 + %21 = OpLoad %mat4v4float %20 + OpLine %4 9 12 + %22 = OpVectorTimesMatrix %v4float %19 %21 + OpLine %4 8 1 + OpStore %gl_Position %22 + OpLine %4 10 1 + OpReturn + OpFunctionEnd \ No newline at end of file diff --git a/third_party/spirv-cross/shaders-msl-no-opt/asm/vert/row-major-column-load.asm.vert b/third_party/spirv-cross/shaders-msl-no-opt/asm/vert/row-major-column-load.asm.vert new file mode 100644 index 000000000000..75467186e3f8 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/asm/vert/row-major-column-load.asm.vert @@ -0,0 +1,42 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 20 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %_Ret_Val + OpSource HLSL 600 + OpName %_Block0T "_Block0T" + OpMemberName %_Block0T 0 "World" + OpName %_Block0 "_Block0" + OpName %_Ret_Val "_Ret_Val" + OpName %main "main" + OpDecorate %_Block0T Block + OpMemberDecorate %_Block0T 0 Offset 0 + OpMemberDecorate %_Block0T 0 RowMajor + OpMemberDecorate %_Block0T 0 MatrixStride 16 + OpDecorate %_Block0 Binding 0 + OpDecorate %_Block0 DescriptorSet 0 + OpDecorate %_Ret_Val Location 0 + %float = OpTypeFloat 32 + %v3float = OpTypeVector %float 3 + %mat4v3float = OpTypeMatrix %v3float 4 + %_Block0T = OpTypeStruct %mat4v3float +%_ptr_Uniform__Block0T = OpTypePointer Uniform %_Block0T + %_Block0 = OpVariable %_ptr_Uniform__Block0T Uniform +%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float +%_ptr_Output_v3float = OpTypePointer Output %v3float + %_Ret_Val = OpVariable %_ptr_Output_v3float Output + %void = OpTypeVoid + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %int_3 = OpConstant %int 3 + %func_type = OpTypeFunction %void + %main = OpFunction %void None %func_type + %entry = OpLabel + %ptr = OpAccessChain %_ptr_Uniform_v3float %_Block0 %int_0 %int_3 + %val = OpLoad %v3float %ptr Volatile + OpStore %_Ret_Val %val + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl-no-opt/comp/argument-buffer-set-limit.msl2.argument.argument-tier-1.comp b/third_party/spirv-cross/shaders-msl-no-opt/comp/argument-buffer-set-limit.msl2.argument.argument-tier-1.comp new file mode 100644 index 000000000000..7b6b51971e3f --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/comp/argument-buffer-set-limit.msl2.argument.argument-tier-1.comp @@ -0,0 +1,18 @@ +#version 450 + +layout(set = 15, binding = 0) uniform UBO +{ + float rd; +}; + +layout(set = 15, binding = 1) buffer SSBO +{ + float wr; +}; + +layout(set = 15, binding = 2) uniform sampler2D Samp; + +void main() +{ + wr = textureLod(Samp, vec2(0.5), 0.0).x + rd; +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/comp/integer-dot-product.comp b/third_party/spirv-cross/shaders-msl-no-opt/comp/integer-dot-product.comp index 8b6630922b7b..8e0559ed46a2 100644 --- a/third_party/spirv-cross/shaders-msl-no-opt/comp/integer-dot-product.comp +++ b/third_party/spirv-cross/shaders-msl-no-opt/comp/integer-dot-product.comp @@ -26,64 +26,67 @@ layout(std430, binding = 1) buffer InOut3 { } comp3; // Signed integer dot with unsigned integer -spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4450) +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4450) int sdot_int_result(u16vec4 x, u16vec4 y); -spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4450) +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4450) uint sdot_uint_result(u16vec4 x, u16vec4 y); // Unsigned integer dot with signed integer. Only unsigned result is allowed in SPIR-V. -spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4451) +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4451) uint udot_uint_result(u16vec4 x, u16vec4 y); // Mixed integer dot with unsigned integer -spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4452) +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4452) int sudot_int_result(u16vec4 x, u16vec4 y); -spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4452) +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4452) uint sudot_uint_result(u16vec4 x, u16vec4 y); // Signed packed dot product with different output widths. -spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4450) +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4450) uint8_t spdot_to_8(uint x, uint y, spirv_literal uint packedFormat); -spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4450) +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4450) uint16_t spdot_to_16(uint x, uint y, spirv_literal uint packedFormat); -spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4450) +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4450) uint spdot_to_32(uint x, uint y, spirv_literal uint packedFormat); -spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4450) +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4450) int spdot_to_i32(uint x, uint y, spirv_literal uint packedFormat); // Unsigned packed dot product with different output widths. -spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4451) +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4451) uint8_t updot_to_8(uint x, uint y, spirv_literal uint packedFormat); -spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4451) +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4451) uint16_t updot_to_16(uint x, uint y, spirv_literal uint packedFormat); -spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4451) +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4451) uint updot_to_32(uint x, uint y, spirv_literal uint packedFormat); // Mixed packed dot product with different output widths. -spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4452) +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4452) uint8_t supdot_to_8(uint x, uint y, spirv_literal uint packedFormat); -spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4452) +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4452) uint16_t supdot_to_16(uint x, uint y, spirv_literal uint packedFormat); -spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4452) +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4452) uint supdot_to_32(uint x, uint y, spirv_literal uint packedFormat); -spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4452) +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4452) int supdot_to_i32(uint x, uint y, spirv_literal uint packedFormat); // SDotAccSat with unsigned input and result type -spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4453) +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4453) int sdotaddsat_int_result(u16vec4 x, u16vec4 y, int acc); -spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4453) -uint sdotaddsat_uint_result(u16vec4 x, u16vec4 y, int acc); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4453) +uint sdotaddsat_uint_result(u16vec4 x, u16vec4 y, uint acc); // UDotAccSat. Result type must be unsigned in SPIR-V. -spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4454) -uint udotaddsat(u16vec4 x, u16vec4 y, int acc); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4454) +uint udotaddsat(u16vec4 x, u16vec4 y, uint acc); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4454) +uint udotaddsat_packed(uint x, uint y, uint acc, spirv_literal uint packedFormat); // SUDotAccSat -spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4455) +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4455) int sudotaddsat_int_result(u16vec4 x, u16vec4 y, int acc); -spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019], id = 4455) -uint sudotaddsat_uint_result(u16vec4 x, u16vec4 y, int acc); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4455) +uint sudotaddsat_uint_result(u16vec4 x, u16vec4 y, uint acc); void main() { int sdot_int = sdot_int_result(comp3.x, comp3.y); @@ -111,4 +114,6 @@ void main() { uint udotaddsat_uint = udotaddsat(comp3.x, comp3.y, comp3.acc); int sudotaddsat_int = sudotaddsat_int_result(comp3.x, comp3.y, comp3.acc); uint sudotaddsat_uint = sudotaddsat_uint_result(comp3.x, comp3.y, comp3.acc); + + uint udotaddsat_pack = udotaddsat_packed(comp2.x, comp2.y, comp3.acc, 0); // PackedVectorFormat4x8Bit } diff --git a/third_party/spirv-cross/shaders-msl-no-opt/comp/precise-non-square-matrix.comp b/third_party/spirv-cross/shaders-msl-no-opt/comp/precise-non-square-matrix.comp new file mode 100644 index 000000000000..dbeb4d3e263e --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/comp/precise-non-square-matrix.comp @@ -0,0 +1,18 @@ +#version 450 + +layout(binding = 0) buffer SSBO +{ + mat3x4 A; + mat4x3 B; + mat3x3 C; + mat4 D; +}; + +void main() +{ + precise mat4 tmp0 = A * B; + precise mat3 tmp1 = B * A; + precise mat3x4 tmp2 = A * C; + precise mat3x4 tmp3 = D * A; + precise mat4x3 tmp4 = B * D; +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/comp/subgroups.nocompat.vk.msl32.comp b/third_party/spirv-cross/shaders-msl-no-opt/comp/subgroups.nocompat.vk.msl32.comp new file mode 100644 index 000000000000..c8172fd95c6b --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/comp/subgroups.nocompat.vk.msl32.comp @@ -0,0 +1,211 @@ +#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 +#extension GL_KHR_shader_subgroup_rotate : require +layout(local_size_x = 1) in; + +layout(std430, binding = 0) buffer SSBO +{ + float FragColor; +}; + +void doClusteredRotate() +{ + uint rotated_clustered = subgroupClusteredRotate(20u, 4u, 8u); + bool rotated_clustered_bool = subgroupClusteredRotate(false, 4u, 8u); +} + +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); + + // rotate + uint rotated = subgroupRotate(20u, 4u); + bool rotated_bool = subgroupRotate(false, 4u); + doClusteredRotate(); + + // 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); + 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); + 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, 1u); + multiplied = subgroupClusteredMul(multiplied, 1u); + iadded = subgroupClusteredAdd(iadded, 1u); + imultiplied = subgroupClusteredMul(imultiplied, 1u); + lo = subgroupClusteredMin(lo, 1u); + hi = subgroupClusteredMax(hi, 1u); + ulo = subgroupClusteredMin(ulo, 1u); + uhi = subgroupClusteredMax(uhi, 1u); + slo = subgroupClusteredMin(slo, 1u); + shi = subgroupClusteredMax(shi, 1u); + anded = subgroupClusteredAnd(anded, 1u); + ored = subgroupClusteredOr(ored, 1u); + xored = subgroupClusteredXor(xored, 1u); + + anded_b = subgroupClusteredAnd(equal(anded, uvec4(2u)), 1u); + ored_b = subgroupClusteredOr(equal(ored, uvec4(3u)), 1u); + xored_b = subgroupClusteredXor(equal(xored, uvec4(4u)), 1u); + + added = subgroupClusteredAdd(added, 2u); + multiplied = subgroupClusteredMul(multiplied, 2u); + iadded = subgroupClusteredAdd(iadded, 2u); + imultiplied = subgroupClusteredMul(imultiplied, 2u); + lo = subgroupClusteredMin(lo, 2u); + hi = subgroupClusteredMax(hi, 2u); + ulo = subgroupClusteredMin(ulo, 2u); + uhi = subgroupClusteredMax(uhi, 2u); + slo = subgroupClusteredMin(slo, 2u); + shi = subgroupClusteredMax(shi, 2u); + anded = subgroupClusteredAnd(anded, 2u); + ored = subgroupClusteredOr(ored, 2u); + xored = subgroupClusteredXor(xored, 2u); + + anded_b = subgroupClusteredAnd(equal(anded, uvec4(2u)), 2u); + ored_b = subgroupClusteredOr(equal(ored, uvec4(3u)), 2u); + xored_b = subgroupClusteredXor(equal(xored, uvec4(4u)), 2u); + + 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); + + anded_b = subgroupClusteredAnd(equal(anded, uvec4(2u)), 4u); + ored_b = subgroupClusteredOr(equal(ored, uvec4(3u)), 4u); + xored_b = subgroupClusteredXor(equal(xored, uvec4(4u)), 4u); + + added = subgroupClusteredAdd(added, 16u); + multiplied = subgroupClusteredMul(multiplied, 16u); + iadded = subgroupClusteredAdd(iadded, 16u); + imultiplied = subgroupClusteredMul(imultiplied, 16u); + lo = subgroupClusteredMin(lo, 16u); + hi = subgroupClusteredMax(hi, 16u); + ulo = subgroupClusteredMin(ulo, 16u); + uhi = subgroupClusteredMax(uhi, 16u); + slo = subgroupClusteredMin(slo, 16u); + shi = subgroupClusteredMax(shi, 16u); + anded = subgroupClusteredAnd(anded, 16u); + ored = subgroupClusteredOr(ored, 16u); + xored = subgroupClusteredXor(xored, 16u); + + anded_b = subgroupClusteredAnd(equal(anded, uvec4(2u)), 16u); + ored_b = subgroupClusteredOr(equal(ored, uvec4(3u)), 16u); + xored_b = subgroupClusteredXor(equal(xored, uvec4(4u)), 16u); + + // 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/depth-clip-enable-early-fragment-tests.emulate-depth-clip-enable.msl2.frag b/third_party/spirv-cross/shaders-msl-no-opt/frag/depth-clip-enable-early-fragment-tests.emulate-depth-clip-enable.msl2.frag new file mode 100644 index 000000000000..4e5946c1e4c2 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/frag/depth-clip-enable-early-fragment-tests.emulate-depth-clip-enable.msl2.frag @@ -0,0 +1,10 @@ +#version 450 + +layout(early_fragment_tests) in; +layout(location = 0) out vec4 color; + +void main() +{ + color = vec4(1.0); + gl_FragDepth = 1.25; +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/frag/depth-clip-enable-fallback.emulate-depth-clip-enable.frag b/third_party/spirv-cross/shaders-msl-no-opt/frag/depth-clip-enable-fallback.emulate-depth-clip-enable.frag new file mode 100644 index 000000000000..718be8e8938c --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/frag/depth-clip-enable-fallback.emulate-depth-clip-enable.frag @@ -0,0 +1,9 @@ +#version 450 + +layout(location = 0) out vec4 color; + +void main() +{ + color = vec4(1.0); + gl_FragDepth = 1.25; +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/frag/depth-clip-enable-no-depth-write.emulate-depth-clip-enable.msl2.frag b/third_party/spirv-cross/shaders-msl-no-opt/frag/depth-clip-enable-no-depth-write.emulate-depth-clip-enable.msl2.frag new file mode 100644 index 000000000000..ee5d1a1bdec8 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/frag/depth-clip-enable-no-depth-write.emulate-depth-clip-enable.msl2.frag @@ -0,0 +1,8 @@ +#version 450 + +layout(location = 0) out vec4 color; + +void main() +{ + color = vec4(1.0); +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/frag/depth-clip-enable-viewport-index.emulate-depth-clip-enable.msl2.frag b/third_party/spirv-cross/shaders-msl-no-opt/frag/depth-clip-enable-viewport-index.emulate-depth-clip-enable.msl2.frag new file mode 100644 index 000000000000..603d446f2c13 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/frag/depth-clip-enable-viewport-index.emulate-depth-clip-enable.msl2.frag @@ -0,0 +1,10 @@ +#version 450 +#extension GL_ARB_shader_viewport_layer_array : require + +layout(location = 0) out vec4 color; + +void main() +{ + color = vec4(gl_ViewportIndex); + gl_FragDepth = 1.25; +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/frag/depth-clip-enable.emulate-depth-clip-enable.msl2.frag b/third_party/spirv-cross/shaders-msl-no-opt/frag/depth-clip-enable.emulate-depth-clip-enable.msl2.frag new file mode 100644 index 000000000000..718be8e8938c --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/frag/depth-clip-enable.emulate-depth-clip-enable.msl2.frag @@ -0,0 +1,9 @@ +#version 450 + +layout(location = 0) out vec4 color; + +void main() +{ + color = vec4(1.0); + gl_FragDepth = 1.25; +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/tese/depth-clip-enable-viewport-index.emulate-depth-clip-enable.msl2.tese b/third_party/spirv-cross/shaders-msl-no-opt/tese/depth-clip-enable-viewport-index.emulate-depth-clip-enable.msl2.tese new file mode 100644 index 000000000000..15f884b1e711 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/tese/depth-clip-enable-viewport-index.emulate-depth-clip-enable.msl2.tese @@ -0,0 +1,9 @@ +#version 450 +#extension GL_ARB_shader_viewport_layer_array : require +layout(quads) in; + +void main() +{ + gl_Position = gl_in[0].gl_Position; + gl_ViewportIndex = 2; +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/tese/depth-clip-enable.emulate-depth-clip-enable.tese b/third_party/spirv-cross/shaders-msl-no-opt/tese/depth-clip-enable.emulate-depth-clip-enable.tese new file mode 100644 index 000000000000..c72f09a4b829 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/tese/depth-clip-enable.emulate-depth-clip-enable.tese @@ -0,0 +1,7 @@ +#version 450 +layout(quads) in; + +void main() +{ + gl_Position = gl_in[0].gl_Position; +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/vert/depth-clip-enable-viewport-index.emulate-depth-clip-enable.msl2.vert b/third_party/spirv-cross/shaders-msl-no-opt/vert/depth-clip-enable-viewport-index.emulate-depth-clip-enable.msl2.vert new file mode 100644 index 000000000000..0223a2079b87 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/vert/depth-clip-enable-viewport-index.emulate-depth-clip-enable.msl2.vert @@ -0,0 +1,8 @@ +#version 450 +#extension GL_ARB_shader_viewport_layer_array : require + +void main() +{ + gl_Position = vec4(0.0, 0.0, 0.25, 1.0); + gl_ViewportIndex = 2; +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/vert/depth-clip-enable.emulate-depth-clip-enable.emulate-reversed-depth-viewport.fixup-clipspace.vert b/third_party/spirv-cross/shaders-msl-no-opt/vert/depth-clip-enable.emulate-depth-clip-enable.emulate-reversed-depth-viewport.fixup-clipspace.vert new file mode 100644 index 000000000000..91e6f42f703f --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/vert/depth-clip-enable.emulate-depth-clip-enable.emulate-reversed-depth-viewport.fixup-clipspace.vert @@ -0,0 +1,6 @@ +#version 450 + +void main() +{ + gl_Position = vec4(0.0, 0.0, 0.25, 1.0); +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/vert/depth-clip-enable.emulate-depth-clip-enable.fixup-clipspace.vert b/third_party/spirv-cross/shaders-msl-no-opt/vert/depth-clip-enable.emulate-depth-clip-enable.fixup-clipspace.vert new file mode 100644 index 000000000000..91e6f42f703f --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/vert/depth-clip-enable.emulate-depth-clip-enable.fixup-clipspace.vert @@ -0,0 +1,6 @@ +#version 450 + +void main() +{ + gl_Position = vec4(0.0, 0.0, 0.25, 1.0); +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/vert/depth-clip-enable.emulate-depth-clip-enable.vert b/third_party/spirv-cross/shaders-msl-no-opt/vert/depth-clip-enable.emulate-depth-clip-enable.vert new file mode 100644 index 000000000000..91e6f42f703f --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/vert/depth-clip-enable.emulate-depth-clip-enable.vert @@ -0,0 +1,6 @@ +#version 450 + +void main() +{ + gl_Position = vec4(0.0, 0.0, 0.25, 1.0); +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/vert/reversed-depth-viewport-index.emulate-reversed-depth-viewport.msl2.vert b/third_party/spirv-cross/shaders-msl-no-opt/vert/reversed-depth-viewport-index.emulate-reversed-depth-viewport.msl2.vert new file mode 100644 index 000000000000..0223a2079b87 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/vert/reversed-depth-viewport-index.emulate-reversed-depth-viewport.msl2.vert @@ -0,0 +1,8 @@ +#version 450 +#extension GL_ARB_shader_viewport_layer_array : require + +void main() +{ + gl_Position = vec4(0.0, 0.0, 0.25, 1.0); + gl_ViewportIndex = 2; +} diff --git a/third_party/spirv-cross/shaders-msl-no-opt/vert/reversed-depth-viewport.emulate-reversed-depth-viewport.vert b/third_party/spirv-cross/shaders-msl-no-opt/vert/reversed-depth-viewport.emulate-reversed-depth-viewport.vert new file mode 100644 index 000000000000..91e6f42f703f --- /dev/null +++ b/third_party/spirv-cross/shaders-msl-no-opt/vert/reversed-depth-viewport.emulate-reversed-depth-viewport.vert @@ -0,0 +1,6 @@ +#version 450 + +void main() +{ + gl_Position = vec4(0.0, 0.0, 0.25, 1.0); +} diff --git a/third_party/spirv-cross/shaders-msl/asm/comp/variable-pointers-2.asm.comp b/third_party/spirv-cross/shaders-msl/asm/comp/variable-pointers-2.asm.invalid.comp similarity index 100% rename from third_party/spirv-cross/shaders-msl/asm/comp/variable-pointers-2.asm.comp rename to third_party/spirv-cross/shaders-msl/asm/comp/variable-pointers-2.asm.invalid.comp diff --git a/third_party/spirv-cross/shaders-msl/asm/frag/reserved-msl-type-names.asm.frag b/third_party/spirv-cross/shaders-msl/asm/frag/reserved-msl-type-names.asm.frag new file mode 100644 index 000000000000..dec3b7b7128f --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/asm/frag/reserved-msl-type-names.asm.frag @@ -0,0 +1,43 @@ + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %FragColor %vUV + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpName %main "main" + OpName %FragColor "FragColor" + OpName %texA "sampler" + OpName %vUV "vUV" + OpName %texB "depth2d" + OpDecorate %FragColor Location 0 + OpDecorate %texA Binding 0 + OpDecorate %texA DescriptorSet 0 + OpDecorate %vUV Location 0 + OpDecorate %texB Binding 1 + OpDecorate %texB DescriptorSet 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 + %10 = OpTypeImage %float 2D 0 0 0 1 Unknown + %11 = OpTypeSampledImage %10 +%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11 + %texA = OpVariable %_ptr_UniformConstant_11 UniformConstant + %v2float = OpTypeVector %float 2 +%_ptr_Input_v2float = OpTypePointer Input %v2float + %vUV = OpVariable %_ptr_Input_v2float Input + %texB = OpVariable %_ptr_UniformConstant_11 UniformConstant + %main = OpFunction %void None %3 + %5 = OpLabel + %14 = OpLoad %11 %texA + %18 = OpLoad %v2float %vUV + %19 = OpImageSampleImplicitLod %v4float %14 %18 + %21 = OpLoad %11 %texB + %22 = OpLoad %v2float %vUV + %23 = OpImageSampleImplicitLod %v4float %21 %22 + %24 = OpFAdd %v4float %19 %23 + OpStore %FragColor %24 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-msl/asm/frag/texture-sampling-fp16.asm.frag b/third_party/spirv-cross/shaders-msl/asm/frag/texture-sampling-fp16.asm.invalid.frag similarity index 100% rename from third_party/spirv-cross/shaders-msl/asm/frag/texture-sampling-fp16.asm.frag rename to third_party/spirv-cross/shaders-msl/asm/frag/texture-sampling-fp16.asm.invalid.frag diff --git a/third_party/spirv-cross/shaders-msl/desktop-only/vert/shader-draw-parameters.desktop.for-tess.vert b/third_party/spirv-cross/shaders-msl/desktop-only/vert/shader-draw-parameters.desktop.for-tess.vert index fadd1e73bfd5..997804eceb2f 100644 --- a/third_party/spirv-cross/shaders-msl/desktop-only/vert/shader-draw-parameters.desktop.for-tess.vert +++ b/third_party/spirv-cross/shaders-msl/desktop-only/vert/shader-draw-parameters.desktop.for-tess.vert @@ -7,5 +7,5 @@ out gl_PerVertex void main() { - gl_Position = vec4(gl_BaseVertex, gl_BaseInstance, 0, 1); + gl_Position = vec4(gl_BaseVertex, gl_BaseInstance, gl_DrawID, 1); } diff --git a/third_party/spirv-cross/shaders-msl/desktop-only/vert/shader-draw-parameters.desktop.vert b/third_party/spirv-cross/shaders-msl/desktop-only/vert/shader-draw-parameters.desktop.vert index fadd1e73bfd5..361c95444dd3 100644 --- a/third_party/spirv-cross/shaders-msl/desktop-only/vert/shader-draw-parameters.desktop.vert +++ b/third_party/spirv-cross/shaders-msl/desktop-only/vert/shader-draw-parameters.desktop.vert @@ -5,7 +5,12 @@ out gl_PerVertex vec4 gl_Position; }; +void in_func() +{ + gl_Position.w = float(gl_DrawID); +} + void main() { - gl_Position = vec4(gl_BaseVertex, gl_BaseInstance, 0, 1); + gl_Position = vec4(gl_BaseVertex, gl_BaseInstance, gl_DrawID, 1); } diff --git a/third_party/spirv-cross/shaders-msl/frag/struct-array-stride-padded-element.frag b/third_party/spirv-cross/shaders-msl/frag/struct-array-stride-padded-element.frag new file mode 100644 index 000000000000..66f719fd05c7 --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/frag/struct-array-stride-padded-element.frag @@ -0,0 +1,35 @@ +#version 450 + +// std140 gives SpotLight an ArrayStride of 64 while its packed MSL size is 52. +// The array must be indexed dynamically so the padded array element path is taken; +// every member following the array must keep its SPIR-V offset. +struct SpotLight +{ + vec3 position; + float range; + vec3 direction; + float angle; + vec3 color; + float intensity; + float penumbra; +}; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + SpotLight spot_lights[4]; + int spot_light_count; + vec3 albedo; + float roughness; + float alpha; +} ubo; + +layout(location = 0) out vec4 FragColor; + +void main() +{ + vec3 acc = vec3(0.0); + int n = min(ubo.spot_light_count, 4); + for (int i = 0; i < n; i++) + acc += ubo.spot_lights[i].color * ubo.spot_lights[i].intensity * ubo.spot_lights[i].penumbra; + FragColor = vec4(ubo.albedo.r, ubo.roughness, ubo.alpha * acc.b, 1.0); +} diff --git a/third_party/spirv-cross/shaders-msl/vert/clip-copy.for-tess.vert b/third_party/spirv-cross/shaders-msl/vert/clip-copy.for-tess.vert new file mode 100644 index 000000000000..559496398ecf --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/vert/clip-copy.for-tess.vert @@ -0,0 +1,27 @@ +#version 450 + +out float gl_ClipDistance[4]; + +layout(location = 0) out float F_array[4]; + +layout(location = 4) out Block +{ + float block0[4]; +}; + +void in_func() +{ + gl_Position = vec4(1, 2, 3, 4); + const float clips[4] = float[](1.0, 2.0, -1.0, -2.0); + float non_const_clips[4]; + gl_ClipDistance = clips; + non_const_clips = gl_ClipDistance; + gl_ClipDistance = non_const_clips; + F_array = non_const_clips; + block0 = clips; +} + +void main() +{ + in_func(); +} diff --git a/third_party/spirv-cross/shaders-msl/vert/clip-copy.vert b/third_party/spirv-cross/shaders-msl/vert/clip-copy.vert new file mode 100644 index 000000000000..559496398ecf --- /dev/null +++ b/third_party/spirv-cross/shaders-msl/vert/clip-copy.vert @@ -0,0 +1,27 @@ +#version 450 + +out float gl_ClipDistance[4]; + +layout(location = 0) out float F_array[4]; + +layout(location = 4) out Block +{ + float block0[4]; +}; + +void in_func() +{ + gl_Position = vec4(1, 2, 3, 4); + const float clips[4] = float[](1.0, 2.0, -1.0, -2.0); + float non_const_clips[4]; + gl_ClipDistance = clips; + non_const_clips = gl_ClipDistance; + gl_ClipDistance = non_const_clips; + F_array = non_const_clips; + block0 = clips; +} + +void main() +{ + in_func(); +} diff --git a/third_party/spirv-cross/shaders-no-opt/asm/cfg-selection-to-unreachable-access-after-merge.vk.nocompat.asm.spv16.comp b/third_party/spirv-cross/shaders-no-opt/asm/cfg-selection-to-unreachable-access-after-merge.vk.nocompat.asm.spv16.comp new file mode 100644 index 000000000000..8a073672bded --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/cfg-selection-to-unreachable-access-after-merge.vk.nocompat.asm.spv16.comp @@ -0,0 +1,119 @@ + OpCapability Shader + OpCapability ImageBuffer + OpCapability Int8 + OpCapability GroupNonUniformVote + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %49 "main" %46 %48 %45 + OpExecutionMode %49 LocalSize 4 1 1 + OpSource Unknown 0 + OpName %49 "main" + OpName %50 ".str" + OpName %51 ".str.2" + OpName %45 "value" + OpName %18 "spirv.SignedImage" + OpName %46 "__spirv_BuiltInGlobalInvocationId" + OpName %1 "entry" + OpName %2 "unreachable" + OpName %3 "new.header" + OpName %4 "entry.sw.bb.i_crit_edge1" + OpName %5 "entry.sw.bb.i_crit_edge" + OpName %6 "sw.default.i" + OpName %7 "new.header.new.exit" + OpName %8 "sw.bb.i" + OpName %48 "Out" + OpName %17 "spirv.VulkanBuffer" + OpName %9 "_Z4mainDv3_j.exit" + OpDecorate %45 DescriptorSet 0 + OpDecorate %45 Binding 0 + OpDecorate %46 BuiltIn GlobalInvocationId + OpDecorate %48 DescriptorSet 0 + OpDecorate %48 Binding 1 + OpDecorate %15 ArrayStride 4 + OpMemberDecorate %16 0 Offset 0 + OpDecorate %16 Block + %10 = OpTypeVoid + %11 = OpTypeFunction %10 + %12 = OpTypeInt 32 0 + %13 = OpTypePointer StorageBuffer %12 + %14 = OpTypeBool + %15 = OpTypeRuntimeArray %12 + %16 = OpTypeStruct %15 + %17 = OpTypePointer StorageBuffer %16 + %18 = OpTypeImage %12 Buffer 2 0 0 2 R32ui + %19 = OpTypeInt 8 0 + %20 = OpConstant %12 4 + %21 = OpTypeArray %19 %20 + %22 = OpConstant %12 6 + %23 = OpTypeArray %19 %22 + %24 = OpTypePointer Function %21 + %25 = OpTypePointer Function %23 + %26 = OpConstant %12 0 + %27 = OpConstant %12 1 + %28 = OpConstant %12 3 + %29 = OpTypePointer UniformConstant %18 + %30 = OpTypeVector %12 4 + %31 = OpTypeVector %12 3 + %32 = OpTypePointer Input %31 + %33 = OpConstantTrue %14 + %34 = OpConstant %19 116 + %35 = OpConstant %19 79 + %36 = OpConstant %19 0 + %37 = OpConstant %19 101 + %38 = OpConstant %19 117 + %39 = OpConstant %19 108 + %40 = OpConstant %19 97 + %41 = OpConstant %19 118 + %42 = OpUndef %14 + %43 = OpConstantComposite %23 %41 %40 %39 %38 %37 %36 + %44 = OpConstantComposite %21 %35 %38 %34 %36 + %45 = OpVariable %29 UniformConstant + %46 = OpVariable %32 Input + %47 = OpConstantFalse %14 + %48 = OpVariable %17 StorageBuffer + %49 = OpFunction %10 DontInline %11 ; -- Begin function main + %1 = OpLabel + %50 = OpVariable %25 Function %43 + %51 = OpVariable %24 Function %44 + %52 = OpLoad %31 %46 + %53 = OpCompositeExtract %12 %52 0 + %54 = OpLoad %18 %45 + %55 = OpImageRead %30 %54 %53 + %56 = OpCompositeExtract %12 %55 0 + OpSelectionMerge %9 None + OpBranchConditional %33 %3 %2 + %2 = OpLabel + OpUnreachable + %3 = OpLabel + OpSelectionMerge %7 None + OpSwitch %56 %6 0 %5 2 %4 + %4 = OpLabel + OpBranch %7 + %5 = OpLabel + OpBranch %7 + %6 = OpLabel + %57 = OpGroupNonUniformAny %14 %28 %47 + OpBranch %7 + %7 = OpLabel + %58 = OpPhi %14 %57 %6 %42 %5 %42 %4 + %59 = OpPhi %12 %27 %6 %26 %5 %26 %4 + %60 = OpIEqual %14 %26 %59 + OpBranchConditional %60 %8 %9 + %8 = OpLabel + %61 = OpGroupNonUniformAny %14 %28 %47 + OpBranch %9 + %9 = OpLabel + %62 = OpPhi %14 %33 %8 %47 %7 + %63 = OpPhi %14 %61 %8 %58 %7 + %64 = OpCopyObject %17 %48 + %65 = OpAccessChain %13 %64 %26 %53 + %66 = OpSelect %12 %63 %27 %26 + %67 = OpCopyObject %17 %48 + OpStore %65 %66 Aligned 4 + %68 = OpGroupNonUniformAny %14 %28 %62 + %69 = OpSelect %12 %68 %27 %26 + %70 = OpIAdd %12 %53 %20 + %71 = OpAccessChain %13 %64 %26 %70 + %72 = OpCopyObject %17 %48 + OpStore %71 %69 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/comp/bda-aliasing.asm.spv16.vk.nocompat.comp b/third_party/spirv-cross/shaders-no-opt/asm/comp/bda-aliasing.asm.spv16.vk.nocompat.comp new file mode 100644 index 000000000000..dad000af1051 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/comp/bda-aliasing.asm.spv16.vk.nocompat.comp @@ -0,0 +1,41 @@ +OpCapability Shader +OpCapability Int64 +OpCapability PhysicalStorageBufferAddresses +OpExtension "SPV_KHR_physical_storage_buffer" +OpMemoryModel PhysicalStorageBuffer64 GLSL450 +OpEntryPoint GLCompute %main "main" %push +OpExecutionMode %main LocalSize 1 1 1 +OpDecorate %push_block Block +OpMemberDecorate %push_block 0 Offset 0 +OpMemberDecorate %push_block 1 Offset 8 +OpMemberDecorate %push_block 2 Offset 16 +OpDecorate %physical_uint_ptr ArrayStride 4 +%void = OpTypeVoid +%void_fn = OpTypeFunction %void +%uint = OpTypeInt 32 0 +%ulong = OpTypeInt 64 0 +%zero = OpConstant %uint 0 +%one = OpConstant %uint 1 +%two = OpConstant %uint 2 +%ninety_nine = OpConstant %uint 99 +%push_block = OpTypeStruct %ulong %ulong %ulong +%push_ptr = OpTypePointer PushConstant %push_block +%push_ulong_ptr = OpTypePointer PushConstant %ulong +%physical_uint_ptr = OpTypePointer PhysicalStorageBuffer %uint +%push = OpVariable %push_ptr PushConstant +%main = OpFunction %void None %void_fn +%entry = OpLabel +%source_field = OpAccessChain %push_ulong_ptr %push %zero +%source_address = OpLoad %ulong %source_field +%source = OpConvertUToPtr %physical_uint_ptr %source_address +%old = OpLoad %uint %source Aligned 4 +%alias_field = OpAccessChain %push_ulong_ptr %push %one +%alias_address = OpLoad %ulong %alias_field +%alias = OpConvertUToPtr %physical_uint_ptr %alias_address +OpStore %alias %ninety_nine Aligned 4 +%output_field = OpAccessChain %push_ulong_ptr %push %two +%output_address = OpLoad %ulong %output_field +%output = OpConvertUToPtr %physical_uint_ptr %output_address +OpStore %output %old Aligned 4 +OpReturn +OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/comp/long-vector-odd-type-cast.asm.vk.nocompat.spv16.comp b/third_party/spirv-cross/shaders-no-opt/asm/comp/long-vector-odd-type-cast.asm.vk.nocompat.spv16.comp new file mode 100644 index 000000000000..0c1b6fff4666 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/comp/long-vector-odd-type-cast.asm.vk.nocompat.spv16.comp @@ -0,0 +1,57 @@ +; SPIR-V +; Version: 1.6 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 24 +; Schema: 0 + OpCapability Shader + OpCapability LongVectorEXT + OpExtension "SPV_EXT_long_vector" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" %s430 + OpExecutionMode %main LocalSize 1 1 1 + OpSource GLSL 450 + OpSourceExtension "GL_EXT_long_vector" + OpName %main "main" + OpName %v5 "v5" + OpName %SSBO430 "SSBO430" + OpMemberName %SSBO430 0 "v5" + OpName %s430 "s430" + OpDecorate %SSBO430 Block + OpMemberDecorate %SSBO430 0 Offset 0 + OpDecorate %s430 Binding 0 + OpDecorate %s430 DescriptorSet 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v5float = OpTypeVector %float 5 +%_ptr_Function_v5float = OpTypePointer Function %v5float + %SSBO430 = OpTypeStruct %v5float +%_ptr_StorageBuffer_SSBO430 = OpTypePointer StorageBuffer %SSBO430 + %s430 = OpVariable %_ptr_StorageBuffer_SSBO430 StorageBuffer + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %null = OpConstantNull %v5float + %float_2 = OpConstant %float 2.0 +%_ptr_StorageBuffer_v5float = OpTypePointer StorageBuffer %v5float + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 + %v5uint = OpTypeVector %uint 5 + %uint_1 = OpConstant %uint 1 + %23 = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1 + %main = OpFunction %void None %3 + %5 = OpLabel + %v5 = OpVariable %_ptr_Function_v5float Function + %16 = OpAccessChain %_ptr_StorageBuffer_v5float %s430 %int_0 + %17 = OpLoad %v5float %16 + OpStore %v5 %17 + %18 = OpLoad %v5float %v5 + %conv0 = OpConvertFToS %v5uint %18 + %conv1 = OpConvertSToF %v5float %conv0 + + %19 = OpAccessChain %_ptr_StorageBuffer_v5float %s430 %int_0 + %convbit = OpBitcast %v5float %conv0 + OpStore %19 %convbit + OpStore %19 %conv1 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/comp/long-vector-ssa.asm.vk.nocompat.spv16.comp b/third_party/spirv-cross/shaders-no-opt/asm/comp/long-vector-ssa.asm.vk.nocompat.spv16.comp new file mode 100644 index 000000000000..38ae713957a0 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/comp/long-vector-ssa.asm.vk.nocompat.spv16.comp @@ -0,0 +1,75 @@ +; SPIR-V +; Version: 1.6 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 24 +; Schema: 0 + OpCapability Shader + OpCapability LongVectorEXT + OpExtension "SPV_EXT_long_vector" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %main "main" %s430 + OpExecutionMode %main LocalSize 1 1 1 + OpSource GLSL 450 + OpSourceExtension "GL_EXT_long_vector" + OpName %main "main" + OpName %v5 "v5" + OpName %SSBO430 "SSBO430" + OpMemberName %SSBO430 0 "v5" + OpName %s430 "s430" + OpDecorate %SSBO430 Block + OpMemberDecorate %SSBO430 0 Offset 0 + OpDecorate %s430 Binding 0 + OpDecorate %s430 DescriptorSet 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v5float = OpTypeVector %float 5 +%_ptr_Function_v5float = OpTypePointer Function %v5float + %SSBO430 = OpTypeStruct %v5float +%_ptr_StorageBuffer_SSBO430 = OpTypePointer StorageBuffer %SSBO430 + %s430 = OpVariable %_ptr_StorageBuffer_SSBO430 StorageBuffer + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %null = OpConstantNull %v5float + %float_2 = OpConstant %float 2.0 +%_ptr_StorageBuffer_v5float = OpTypePointer StorageBuffer %v5float + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 + %uint_1 = OpConstant %uint 1 + %23 = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1 + %main = OpFunction %void None %3 + %5 = OpLabel + %v5 = OpVariable %_ptr_Function_v5float Function + %16 = OpAccessChain %_ptr_StorageBuffer_v5float %s430 %int_0 + %17 = OpLoad %v5float %16 + OpStore %v5 %17 + %18 = OpLoad %v5float %v5 + %mul = OpFMul %v5float %18 %18 + + ; Test various SSA-based vector things. + %shuf0 = OpVectorShuffle %v5float %18 %mul 0 5 9 4 3 + %shuf1 = OpVectorShuffle %v5float %18 %mul 0 1 2 3 4 + %shuf2 = OpVectorShuffle %v5float %18 %null 0 5 2 6 4 + %inst0 = OpCompositeInsert %v5float %float_2 %mul 0 + %inst1 = OpCompositeInsert %v5float %float_2 %inst0 4 + %ext0 = OpCompositeExtract %float %18 0 + %ext1 = OpCompositeExtract %float %18 4 + + ; Try extracting from null constant long-vector. Edge cases! + %extadd = OpFAdd %float %ext0 %ext1 + %extnull = OpCompositeExtract %float %null 2 + %extadd2 = OpFAdd %float %extadd %extnull + + %inst2 = OpCompositeInsert %v5float %extadd2 %inst0 3 + + + ; VectorInsertDynamic/ExtractDynamic impl go via common access chain, so leave it as-is. + + %19 = OpAccessChain %_ptr_StorageBuffer_v5float %s430 %int_0 + OpStore %19 %shuf0 + OpStore %19 %shuf1 + OpStore %19 %shuf2 + OpStore %19 %inst2 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/comp/volatile-phys-buf-load-no-forward.nocompat.vk.asm.comp b/third_party/spirv-cross/shaders-no-opt/asm/comp/volatile-phys-buf-load-no-forward.nocompat.vk.asm.comp new file mode 100644 index 000000000000..7770ef68dcf7 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/comp/volatile-phys-buf-load-no-forward.nocompat.vk.asm.comp @@ -0,0 +1,60 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 10 +; Bound: 40 +; Schema: 0 + OpCapability Shader + OpCapability Int64 + OpCapability PhysicalStorageBufferAddresses + OpExtension "SPV_KHR_physical_storage_buffer" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel PhysicalStorageBuffer64 GLSL450 + OpEntryPoint GLCompute %main "main" + OpExecutionMode %main LocalSize 1 1 1 + OpName %main "main" + OpName %Registers "Registers" + OpMemberName %Registers 0 "addr" + OpMemberName %Registers 1 "addr2" + OpName %registers "registers" + OpMemberDecorate %Registers 0 Offset 0 + OpMemberDecorate %Registers 1 Offset 8 + OpDecorate %Registers Block + %void = OpTypeVoid + %3 = OpTypeFunction %void + %int = OpTypeInt 32 1 + %ulong = OpTypeInt 64 0 + %Registers = OpTypeStruct %ulong %ulong +%_ptr_PushConstant_Registers = OpTypePointer PushConstant %Registers + %registers = OpVariable %_ptr_PushConstant_Registers PushConstant + %int_0 = OpConstant %int 0 + %int_1 = OpConstant %int 1 + %ulong_4 = OpConstant %ulong 4 +%_ptr_PushConstant_ulong = OpTypePointer PushConstant %ulong +%_ptr_PhysicalStorageBuffer_int = OpTypePointer PhysicalStorageBuffer %int + %main = OpFunction %void None %3 + %5 = OpLabel + + %pc0 = OpAccessChain %_ptr_PushConstant_ulong %registers %int_0 + %addr0 = OpLoad %ulong %pc0 + %src_p = OpConvertUToPtr %_ptr_PhysicalStorageBuffer_int %addr0 + + %pc1 = OpAccessChain %_ptr_PushConstant_ulong %registers %int_1 + %addr1 = OpLoad %ulong %pc1 + %dst_p = OpConvertUToPtr %_ptr_PhysicalStorageBuffer_int %addr1 + + ; Volatile load from src — must NOT be forwarded + %ld = OpLoad %int %src_p Volatile|Aligned 4 + + ; Store the loaded value into dst (first use) + OpStore %dst_p %ld Aligned 4 + + ; Compute dst + 1 element via integer arithmetic + %dst_u64 = OpConvertPtrToU %ulong %dst_p + %dst_plus4 = OpIAdd %ulong %dst_u64 %ulong_4 + %dst_p2 = OpConvertUToPtr %_ptr_PhysicalStorageBuffer_int %dst_plus4 + + ; Store the same loaded value again (second use) + OpStore %dst_p2 %ld Aligned 4 + + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-hazard-tracking.vk.nocompat.asm.spv16.frag b/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-hazard-tracking.vk.nocompat.asm.spv16.frag new file mode 100644 index 000000000000..3c1d4f6c1398 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-hazard-tracking.vk.nocompat.asm.spv16.frag @@ -0,0 +1,76 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpCapability UntypedPointersKHR + OpCapability DescriptorHeapEXT + OpExtension "SPV_EXT_descriptor_heap" + OpExtension "SPV_KHR_untyped_pointers" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %FragColor %resource_heap + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 460 + OpSourceExtension "GL_EXT_descriptor_heap" + OpSourceExtension "GL_EXT_nonuniform_qualifier" + OpName %main "main" + OpName %FragColor "FragColor" + OpName %resource_heap "resource_heap" + OpName %SSBO "SSBO" + OpMemberName %SSBO 0 "data" + OpDecorate %FragColor Location 0 + OpDecorate %resource_heap BuiltIn ResourceHeapEXT + OpDecorate %_runtimearr_v4float ArrayStride 16 + OpDecorate %SSBO Block + OpDecorate %readonly NonWritable + OpDecorate %writeonly Coherent + OpMemberDecorate %SSBO 0 Offset 0 + OpDecorateId %_runtimearr_20 ArrayStrideIdEXT %21 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_float = OpTypePointer Output %float + %FragColor = OpVariable %_ptr_Output_float Output + %float_0 = OpConstant %float 0 +%_ptr_UniformConstant = OpTypeUntypedPointerKHR UniformConstant +%resource_heap = OpUntypedVariableKHR %_ptr_UniformConstant UniformConstant + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %int_2 = OpConstant %int 2 +%_runtimearr_v4float = OpTypeRuntimeArray %v4float + %SSBO = OpTypeStruct %_runtimearr_v4float +%_ptr_StorageBuffer = OpTypeUntypedPointerKHR StorageBuffer +%_ptr_StorageBuffer_SSBO = OpTypePointer StorageBuffer %SSBO +%_ptr_StorageBuffer_v4float = OpTypePointer StorageBuffer %v4float +%_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float + %20 = OpTypeBufferEXT StorageBuffer + %21 = OpConstantSizeOfEXT %int %20 +%_runtimearr_20 = OpTypeRuntimeArray %20 + %uint = OpTypeInt 32 0 + %main = OpFunction %void None %3 + %5 = OpLabel + %19 = OpUntypedAccessChainKHR %_ptr_UniformConstant %_runtimearr_20 %resource_heap %int_2 + %readonly = OpBufferPointerEXT %_ptr_StorageBuffer %19 + %writeonly = OpBufferPointerEXT %_ptr_StorageBuffer %19 + + %chain_load = OpUntypedAccessChainKHR %_ptr_StorageBuffer %SSBO %readonly %int_0 %int_2 + %chain_load_again = OpUntypedAccessChainKHR %_ptr_StorageBuffer %v4float %chain_load %int_2 + + %chain_store = OpUntypedAccessChainKHR %_ptr_StorageBuffer %SSBO %writeonly %int_0 %int_0 + %chain_store_again = OpUntypedAccessChainKHR %_ptr_StorageBuffer %v4float %chain_store %int_2 + + ; Read through different OpBufferPointerEXT. Aliasing is not considered. + %load_readonly = OpLoad %float %chain_load_again + OpStore %chain_store_again %float_0 + OpStore %FragColor %load_readonly + + ; Now read on the same underlying OpBufferPointerEXT. We have to be careful. + %load_rw = OpLoad %float %chain_store_again + OpStore %chain_store_again %float_0 + OpStore %FragColor %load_rw + + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-hlsl-strides.spv16.asm.vk.nocompat.frag b/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-hlsl-strides.spv16.asm.vk.nocompat.frag new file mode 100644 index 000000000000..9560abe5783f --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-hlsl-strides.spv16.asm.vk.nocompat.frag @@ -0,0 +1,106 @@ + OpCapability Shader + OpCapability Sampled1D + OpCapability RayQueryKHR + OpCapability UntypedPointersKHR + OpCapability DescriptorHeapEXT + OpExtension "SPV_EXT_descriptor_heap" + OpExtension "SPV_KHR_ray_query" + OpExtension "SPV_KHR_untyped_pointers" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %FragColor %gl_FragCoord %resource_heap %rq + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 460 + OpSourceExtension "GL_EXT_descriptor_heap" + OpSourceExtension "GL_EXT_nonuniform_qualifier" + OpSourceExtension "GL_EXT_ray_query" + OpSourceExtension "GL_EXT_samplerless_texture_functions" + OpSourceExtension "GL_EXT_scalar_block_layout" + OpSourceExtension "GL_EXT_shader_image_load_formatted" + OpName %main "main" + OpName %FragColor "FragColor" + OpName %resource_heap "resource_heap" + OpName %gl_FragCoord "gl_FragCoord" + OpName %UBO140 "UBO140" + OpMemberName %UBO140 0 "data" + OpName %rq "rq" + OpDecorate %FragColor Location 0 + OpDecorate %resource_heap BuiltIn ResourceHeapEXT + OpDecorate %gl_FragCoord BuiltIn FragCoord + OpDecorate %_arr_float_uint_2 ArrayStride 16 + OpDecorate %UBO140 Block + OpDecorateId %_runtimearr_23 ArrayStrideIdEXT %heap_size + OpDecorateId %_runtimearr_39 ArrayStrideIdEXT %heap_size + OpDecorateId %_runtimearr_51 ArrayStrideIdEXT %heap_size + OpMemberDecorate %UBO140 0 Offset 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_0 = OpConstant %float 0 + %11 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0 +%_ptr_UniformConstant = OpTypeUntypedPointerKHR UniformConstant +%resource_heap = OpUntypedVariableKHR %_ptr_UniformConstant UniformConstant +%_ptr_Input_v4float = OpTypePointer Input %v4float +%gl_FragCoord = OpVariable %_ptr_Input_v4float Input + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_Input_float = OpTypePointer Input %float + %int = OpTypeInt 32 1 + %23 = OpTypeImage %float 1D 0 0 0 1 Unknown +%_ptr_Uniform = OpTypeUntypedPointerKHR Uniform + %int_0 = OpConstant %int 0 + %int_50 = OpConstant %int 50 + %uint_2 = OpConstant %uint 2 +%_arr_float_uint_2 = OpTypeArray %float %uint_2 + %UBO140 = OpTypeStruct %_arr_float_uint_2 + %int_1 = OpConstant %int 1 + %bool = OpTypeBool + + %39 = OpTypeBufferEXT Uniform + %51 = OpTypeAccelerationStructureKHR + %buffer_size = OpConstantSizeOfEXT %int %39 + %image_size = OpConstantSizeOfEXT %int %23 + + ; D3D12 style sizing + %image_is_greater = OpSpecConstantOp %bool UGreaterThan %image_size %buffer_size + %heap_size = OpSpecConstantOp %int Select %image_is_greater %image_size %buffer_size + +%_runtimearr_23 = OpTypeRuntimeArray %23 +%_runtimearr_39 = OpTypeRuntimeArray %39 +%_runtimearr_51 = OpTypeRuntimeArray %51 + + %48 = OpTypeRayQueryKHR +%_ptr_Private_48 = OpTypePointer Private %48 + %rq = OpVariable %_ptr_Private_48 Private + %v3float = OpTypeVector %float 3 + %57 = OpConstantComposite %v3float %float_0 %float_0 %float_0 + %float_1 = OpConstant %float 1 + %59 = OpConstantComposite %v3float %float_1 %float_0 %float_0 + %main = OpFunction %void None %3 + %5 = OpLabel + OpStore %FragColor %11 + %19 = OpAccessChain %_ptr_Input_float %gl_FragCoord %uint_0 + %20 = OpLoad %float %19 + %22 = OpConvertFToS %int %20 + %25 = OpUntypedAccessChainKHR %_ptr_UniformConstant %_runtimearr_23 %resource_heap %22 + %28 = OpLoad %23 %25 + %30 = OpImageFetch %v4float %28 %int_0 Lod %int_0 + %31 = OpLoad %v4float %FragColor + %32 = OpFAdd %v4float %31 %30 + OpStore %FragColor %32 + %38 = OpUntypedAccessChainKHR %_ptr_UniformConstant %_runtimearr_39 %resource_heap %int_50 + %42 = OpBufferPointerEXT %_ptr_Uniform %38 + %43 = OpUntypedAccessChainKHR %_ptr_Uniform %UBO140 %42 %int_0 %int_1 + %44 = OpLoad %float %43 + %45 = OpLoad %v4float %FragColor + %46 = OpCompositeConstruct %v4float %44 %44 %44 %44 + %47 = OpFAdd %v4float %45 %46 + OpStore %FragColor %47 + %52 = OpUntypedAccessChainKHR %_ptr_UniformConstant %_runtimearr_51 %resource_heap %int_50 + %55 = OpLoad %51 %52 + OpRayQueryInitializeKHR %rq %55 %uint_0 %uint_0 %57 %float_0 %59 %float_1 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-multi-stage-chain-typed.vk.spv16.asm.nocompat.frag b/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-multi-stage-chain-typed.vk.spv16.asm.nocompat.frag new file mode 100644 index 000000000000..6346d0fe683b --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-multi-stage-chain-typed.vk.spv16.asm.nocompat.frag @@ -0,0 +1,69 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpCapability UntypedPointersKHR + OpCapability DescriptorHeapEXT + OpExtension "SPV_EXT_descriptor_heap" + OpExtension "SPV_KHR_untyped_pointers" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %FragColor %resource_heap + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 460 + OpSourceExtension "GL_EXT_descriptor_heap" + OpSourceExtension "GL_EXT_nonuniform_qualifier" + OpName %main "main" + OpName %FragColor "FragColor" + OpName %resource_heap "resource_heap" + OpName %SSBO "SSBO" + OpMemberName %SSBO 0 "data" + OpDecorate %FragColor Location 0 + OpDecorate %resource_heap BuiltIn ResourceHeapEXT + OpDecorate %_runtimearr_v4float ArrayStride 16 + OpDecorate %SSBO Block + OpDecorate %readonly NonWritable + OpDecorate %writeonly NonReadable + OpMemberDecorate %SSBO 0 Offset 0 + OpDecorateId %_runtimearr_20 ArrayStrideIdEXT %21 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_float = OpTypePointer Output %float + %FragColor = OpVariable %_ptr_Output_float Output + %float_0 = OpConstant %float 0 +%_ptr_UniformConstant = OpTypeUntypedPointerKHR UniformConstant +%resource_heap = OpUntypedVariableKHR %_ptr_UniformConstant UniformConstant + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %int_2 = OpConstant %int 2 +%_runtimearr_v4float = OpTypeRuntimeArray %v4float + %SSBO = OpTypeStruct %_runtimearr_v4float +%_ptr_StorageBuffer = OpTypeUntypedPointerKHR StorageBuffer +%_ptr_StorageBuffer_SSBO = OpTypePointer StorageBuffer %SSBO +%_ptr_StorageBuffer_v4float = OpTypePointer StorageBuffer %v4float +%_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float + %20 = OpTypeBufferEXT StorageBuffer + %21 = OpConstantSizeOfEXT %int %20 +%_runtimearr_20 = OpTypeRuntimeArray %20 + %uint = OpTypeInt 32 0 + %main = OpFunction %void None %3 + %5 = OpLabel + %19 = OpUntypedAccessChainKHR %_ptr_UniformConstant %_runtimearr_20 %resource_heap %int_2 + %readonly = OpBufferPointerEXT %_ptr_StorageBuffer_SSBO %19 + %writeonly = OpBufferPointerEXT %_ptr_StorageBuffer_SSBO %19 + + %chain_load = OpAccessChain %_ptr_StorageBuffer_v4float %readonly %int_0 %int_2 + %chain_load_again = OpAccessChain %_ptr_StorageBuffer_float %chain_load %int_2 + + %chain_store = OpAccessChain %_ptr_StorageBuffer_v4float %writeonly %int_0 %int_0 + %chain_store_again = OpAccessChain %_ptr_StorageBuffer_float %chain_store %int_2 + + %loaded = OpLoad %float %chain_load_again + OpStore %chain_store_again %loaded + OpStore %FragColor %loaded + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-multi-stage-chain-untyped.vk.spv16.asm.nocompat.frag b/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-multi-stage-chain-untyped.vk.spv16.asm.nocompat.frag new file mode 100644 index 000000000000..89107bc8b127 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-multi-stage-chain-untyped.vk.spv16.asm.nocompat.frag @@ -0,0 +1,69 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpCapability UntypedPointersKHR + OpCapability DescriptorHeapEXT + OpExtension "SPV_EXT_descriptor_heap" + OpExtension "SPV_KHR_untyped_pointers" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %FragColor %resource_heap + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 460 + OpSourceExtension "GL_EXT_descriptor_heap" + OpSourceExtension "GL_EXT_nonuniform_qualifier" + OpName %main "main" + OpName %FragColor "FragColor" + OpName %resource_heap "resource_heap" + OpName %SSBO "SSBO" + OpMemberName %SSBO 0 "data" + OpDecorate %FragColor Location 0 + OpDecorate %resource_heap BuiltIn ResourceHeapEXT + OpDecorate %_runtimearr_v4float ArrayStride 16 + OpDecorate %SSBO Block + OpDecorate %readonly NonWritable + OpDecorate %writeonly NonReadable + OpMemberDecorate %SSBO 0 Offset 0 + OpDecorateId %_runtimearr_20 ArrayStrideIdEXT %21 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_float = OpTypePointer Output %float + %FragColor = OpVariable %_ptr_Output_float Output + %float_0 = OpConstant %float 0 +%_ptr_UniformConstant = OpTypeUntypedPointerKHR UniformConstant +%resource_heap = OpUntypedVariableKHR %_ptr_UniformConstant UniformConstant + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %int_2 = OpConstant %int 2 +%_runtimearr_v4float = OpTypeRuntimeArray %v4float + %SSBO = OpTypeStruct %_runtimearr_v4float +%_ptr_StorageBuffer = OpTypeUntypedPointerKHR StorageBuffer +%_ptr_StorageBuffer_SSBO = OpTypePointer StorageBuffer %SSBO +%_ptr_StorageBuffer_v4float = OpTypePointer StorageBuffer %v4float +%_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float + %20 = OpTypeBufferEXT StorageBuffer + %21 = OpConstantSizeOfEXT %int %20 +%_runtimearr_20 = OpTypeRuntimeArray %20 + %uint = OpTypeInt 32 0 + %main = OpFunction %void None %3 + %5 = OpLabel + %19 = OpUntypedAccessChainKHR %_ptr_UniformConstant %_runtimearr_20 %resource_heap %int_2 + %readonly = OpBufferPointerEXT %_ptr_StorageBuffer %19 + %writeonly = OpBufferPointerEXT %_ptr_StorageBuffer %19 + + %chain_load = OpUntypedAccessChainKHR %_ptr_StorageBuffer %SSBO %readonly %int_0 %int_2 + %chain_load_again = OpUntypedAccessChainKHR %_ptr_StorageBuffer %v4float %chain_load %int_2 + + %chain_store = OpUntypedAccessChainKHR %_ptr_StorageBuffer %SSBO %writeonly %int_0 %int_0 + %chain_store_again = OpUntypedAccessChainKHR %_ptr_StorageBuffer %v4float %chain_store %int_2 + + %loaded = OpLoad %float %chain_load_again + OpStore %chain_store_again %loaded + OpStore %FragColor %loaded + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-nonwritable-nonreadable-alias.vk.nocompat.asm.spv16.frag b/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-nonwritable-nonreadable-alias.vk.nocompat.asm.spv16.frag new file mode 100644 index 000000000000..bc8462b3f990 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-nonwritable-nonreadable-alias.vk.nocompat.asm.spv16.frag @@ -0,0 +1,65 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpCapability UntypedPointersKHR + OpCapability DescriptorHeapEXT + OpExtension "SPV_EXT_descriptor_heap" + OpExtension "SPV_KHR_untyped_pointers" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %FragColor %resource_heap + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 460 + OpSourceExtension "GL_EXT_descriptor_heap" + OpSourceExtension "GL_EXT_nonuniform_qualifier" + OpName %main "main" + OpName %FragColor "FragColor" + OpName %resource_heap "resource_heap" + OpName %SSBO "SSBO" + OpMemberName %SSBO 0 "data" + OpDecorate %FragColor Location 0 + OpDecorate %resource_heap BuiltIn ResourceHeapEXT + OpDecorate %_runtimearr_v4float ArrayStride 16 + OpDecorate %SSBO Block + OpDecorate %readonly NonWritable + OpDecorate %writeonly NonReadable + OpMemberDecorate %SSBO 0 Offset 0 + OpDecorateId %_runtimearr_20 ArrayStrideIdEXT %21 + %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_0 = OpConstant %float 0 + %11 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0 +%_ptr_UniformConstant = OpTypeUntypedPointerKHR UniformConstant +%resource_heap = OpUntypedVariableKHR %_ptr_UniformConstant UniformConstant + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %int_2 = OpConstant %int 2 +%_runtimearr_v4float = OpTypeRuntimeArray %v4float + %SSBO = OpTypeStruct %_runtimearr_v4float +%_ptr_StorageBuffer = OpTypeUntypedPointerKHR StorageBuffer +%_ptr_StorageBuffer_SSBO = OpTypePointer StorageBuffer %SSBO +%_ptr_StorageBuffer_v4float = OpTypePointer StorageBuffer %v4float + %20 = OpTypeBufferEXT StorageBuffer + %21 = OpConstantSizeOfEXT %int %20 +%_runtimearr_20 = OpTypeRuntimeArray %20 + %uint = OpTypeInt 32 0 + %main = OpFunction %void None %3 + %5 = OpLabel + OpStore %FragColor %11 + %19 = OpUntypedAccessChainKHR %_ptr_UniformConstant %_runtimearr_20 %resource_heap %int_2 + %readonly = OpBufferPointerEXT %_ptr_StorageBuffer_SSBO %19 + %writeonly = OpBufferPointerEXT %_ptr_StorageBuffer_SSBO %19 + %chain_load = OpAccessChain %_ptr_StorageBuffer_v4float %readonly %int_0 %int_2 + %chain_store = OpAccessChain %_ptr_StorageBuffer_v4float %writeonly %int_0 %int_0 + %loaded = OpLoad %v4float %chain_load + OpStore %chain_store %loaded + OpStore %FragColor %loaded + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-ssbo-atomic.asm.vk.nocompat.spv16.frag b/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-ssbo-atomic.asm.vk.nocompat.spv16.frag new file mode 100644 index 000000000000..21953dfffa45 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-ssbo-atomic.asm.vk.nocompat.spv16.frag @@ -0,0 +1,76 @@ +; SPIR-V +; Version: 1.6 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 32 +; Schema: 0 + OpCapability Shader + OpCapability UntypedPointersKHR + OpCapability DescriptorHeapEXT + OpExtension "SPV_EXT_descriptor_heap" + OpExtension "SPV_KHR_untyped_pointers" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %resource_heap %gl_FragCoord + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 460 + OpSourceExtension "GL_EXT_descriptor_heap" + OpSourceExtension "GL_EXT_nonuniform_qualifier" + OpSourceExtension "GL_EXT_ray_query" + OpSourceExtension "GL_EXT_samplerless_texture_functions" + OpSourceExtension "GL_EXT_scalar_block_layout" + OpSourceExtension "GL_EXT_shader_image_load_formatted" + OpName %main "main" + OpName %desc_index "desc_index" + OpName %gl_FragCoord "gl_FragCoord" + OpName %resource_heap "resource_heap" + OpName %SSBOAtomic "SSBOAtomic" + OpMemberName %SSBOAtomic 0 "data" + OpMemberName %SSBOAtomic 1 "data2" + OpDecorate %gl_FragCoord BuiltIn FragCoord + OpDecorate %resource_heap BuiltIn ResourceHeapEXT + OpDecorate %SSBOAtomic Block + OpMemberDecorate %SSBOAtomic 0 Offset 0 + OpMemberDecorate %SSBOAtomic 1 Offset 4 + OpDecorateId %_runtimearr_26 ArrayStrideIdEXT %27 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %int = OpTypeInt 32 1 +%_ptr_Function_int = OpTypePointer Function %int + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%gl_FragCoord = OpVariable %_ptr_Input_v4float Input + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_UniformConstant = OpTypeUntypedPointerKHR UniformConstant +%resource_heap = OpUntypedVariableKHR %_ptr_UniformConstant UniformConstant + %SSBOAtomic = OpTypeStruct %uint %uint + %int_1 = OpConstant %int 1 +%_ptr_StorageBuffer = OpTypeUntypedPointerKHR StorageBuffer +%_ptr_StorageBuffer_SSBOAtomic = OpTypePointer StorageBuffer %SSBOAtomic +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %26 = OpTypeBufferEXT StorageBuffer + %27 = OpConstantSizeOfEXT %int %26 +%_runtimearr_26 = OpTypeRuntimeArray %26 + %uint_1 = OpConstant %uint 1 + %main = OpFunction %void None %3 + %5 = OpLabel + %desc_index = OpVariable %_ptr_Function_int Function + %16 = OpAccessChain %_ptr_Input_float %gl_FragCoord %uint_0 + %17 = OpLoad %float %16 + %18 = OpConvertFToS %int %17 + OpStore %desc_index %18 + %21 = OpLoad %int %desc_index + %25 = OpUntypedAccessChainKHR %_ptr_UniformConstant %_runtimearr_26 %resource_heap %21 + + %untyped_ptr = OpBufferPointerEXT %_ptr_StorageBuffer %25 + %untyped_chain = OpUntypedAccessChainKHR %_ptr_StorageBuffer %SSBOAtomic %untyped_ptr %uint_1 + %dummy0 = OpAtomicIAdd %uint %untyped_chain %uint_1 %uint_0 %uint_1 + + %typed_ptr = OpBufferPointerEXT %_ptr_StorageBuffer_SSBOAtomic %25 + %typed_chain = OpAccessChain %_ptr_StorageBuffer_uint %typed_ptr %uint_1 + %dummy1 = OpAtomicIAdd %uint %typed_chain %uint_1 %uint_0 %uint_1 + + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-ssbo-atomic.heap-legacy-mapping.asm.vk.nocompat.spv16.frag b/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-ssbo-atomic.heap-legacy-mapping.asm.vk.nocompat.spv16.frag new file mode 100644 index 000000000000..21953dfffa45 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-ssbo-atomic.heap-legacy-mapping.asm.vk.nocompat.spv16.frag @@ -0,0 +1,76 @@ +; SPIR-V +; Version: 1.6 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 32 +; Schema: 0 + OpCapability Shader + OpCapability UntypedPointersKHR + OpCapability DescriptorHeapEXT + OpExtension "SPV_EXT_descriptor_heap" + OpExtension "SPV_KHR_untyped_pointers" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %resource_heap %gl_FragCoord + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 460 + OpSourceExtension "GL_EXT_descriptor_heap" + OpSourceExtension "GL_EXT_nonuniform_qualifier" + OpSourceExtension "GL_EXT_ray_query" + OpSourceExtension "GL_EXT_samplerless_texture_functions" + OpSourceExtension "GL_EXT_scalar_block_layout" + OpSourceExtension "GL_EXT_shader_image_load_formatted" + OpName %main "main" + OpName %desc_index "desc_index" + OpName %gl_FragCoord "gl_FragCoord" + OpName %resource_heap "resource_heap" + OpName %SSBOAtomic "SSBOAtomic" + OpMemberName %SSBOAtomic 0 "data" + OpMemberName %SSBOAtomic 1 "data2" + OpDecorate %gl_FragCoord BuiltIn FragCoord + OpDecorate %resource_heap BuiltIn ResourceHeapEXT + OpDecorate %SSBOAtomic Block + OpMemberDecorate %SSBOAtomic 0 Offset 0 + OpMemberDecorate %SSBOAtomic 1 Offset 4 + OpDecorateId %_runtimearr_26 ArrayStrideIdEXT %27 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %int = OpTypeInt 32 1 +%_ptr_Function_int = OpTypePointer Function %int + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%gl_FragCoord = OpVariable %_ptr_Input_v4float Input + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 +%_ptr_Input_float = OpTypePointer Input %float +%_ptr_UniformConstant = OpTypeUntypedPointerKHR UniformConstant +%resource_heap = OpUntypedVariableKHR %_ptr_UniformConstant UniformConstant + %SSBOAtomic = OpTypeStruct %uint %uint + %int_1 = OpConstant %int 1 +%_ptr_StorageBuffer = OpTypeUntypedPointerKHR StorageBuffer +%_ptr_StorageBuffer_SSBOAtomic = OpTypePointer StorageBuffer %SSBOAtomic +%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint + %26 = OpTypeBufferEXT StorageBuffer + %27 = OpConstantSizeOfEXT %int %26 +%_runtimearr_26 = OpTypeRuntimeArray %26 + %uint_1 = OpConstant %uint 1 + %main = OpFunction %void None %3 + %5 = OpLabel + %desc_index = OpVariable %_ptr_Function_int Function + %16 = OpAccessChain %_ptr_Input_float %gl_FragCoord %uint_0 + %17 = OpLoad %float %16 + %18 = OpConvertFToS %int %17 + OpStore %desc_index %18 + %21 = OpLoad %int %desc_index + %25 = OpUntypedAccessChainKHR %_ptr_UniformConstant %_runtimearr_26 %resource_heap %21 + + %untyped_ptr = OpBufferPointerEXT %_ptr_StorageBuffer %25 + %untyped_chain = OpUntypedAccessChainKHR %_ptr_StorageBuffer %SSBOAtomic %untyped_ptr %uint_1 + %dummy0 = OpAtomicIAdd %uint %untyped_chain %uint_1 %uint_0 %uint_1 + + %typed_ptr = OpBufferPointerEXT %_ptr_StorageBuffer_SSBOAtomic %25 + %typed_chain = OpAccessChain %_ptr_StorageBuffer_uint %typed_ptr %uint_1 + %dummy1 = OpAtomicIAdd %uint %typed_chain %uint_1 %uint_0 %uint_1 + + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-typed-buffer-pointer.asm.vk.nocompat.spv16.frag b/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-typed-buffer-pointer.asm.vk.nocompat.spv16.frag new file mode 100644 index 000000000000..aafa56662645 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-typed-buffer-pointer.asm.vk.nocompat.spv16.frag @@ -0,0 +1,66 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpCapability UntypedPointersKHR + OpCapability DescriptorHeapEXT + OpExtension "SPV_EXT_descriptor_heap" + OpExtension "SPV_KHR_untyped_pointers" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %FragColor %resource_heap + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 460 + OpSourceExtension "GL_EXT_descriptor_heap" + OpSourceExtension "GL_EXT_nonuniform_qualifier" + OpName %main "main" + OpName %FragColor "FragColor" + OpName %resource_heap "resource_heap" + OpName %SSBO "SSBO" + OpMemberName %SSBO 0 "data" + OpDecorate %FragColor Location 0 + OpDecorate %resource_heap BuiltIn ResourceHeapEXT + OpDecorate %_runtimearr_v4float ArrayStride 16 + OpDecorate %SSBO Block + OpMemberDecorate %SSBO 0 Offset 0 + OpDecorateId %_runtimearr_20 ArrayStrideIdEXT %21 + %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_0 = OpConstant %float 0 + %11 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0 +%_ptr_UniformConstant = OpTypeUntypedPointerKHR UniformConstant +%resource_heap = OpUntypedVariableKHR %_ptr_UniformConstant UniformConstant + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %int_2 = OpConstant %int 2 +%_runtimearr_v4float = OpTypeRuntimeArray %v4float + %SSBO = OpTypeStruct %_runtimearr_v4float +%_ptr_StorageBuffer = OpTypeUntypedPointerKHR StorageBuffer +%_ptr_StorageBuffer_SSBO = OpTypePointer StorageBuffer %SSBO +%_ptr_StorageBuffer_v4float = OpTypePointer StorageBuffer %v4float + %20 = OpTypeBufferEXT StorageBuffer + %21 = OpConstantSizeOfEXT %int %20 +%_runtimearr_20 = OpTypeRuntimeArray %20 + %uint = OpTypeInt 32 0 + %main = OpFunction %void None %3 + %5 = OpLabel + OpStore %FragColor %11 + %19 = OpUntypedAccessChainKHR %_ptr_UniformConstant %_runtimearr_20 %resource_heap %int_2 + %23 = OpBufferPointerEXT %_ptr_StorageBuffer_SSBO %19 + %25 = OpArrayLength %uint %23 0 + %chain = OpAccessChain %_ptr_StorageBuffer_v4float %23 %int_0 %int_2 + %loaded = OpLoad %v4float %chain + %26 = OpBitcast %int %25 + %27 = OpConvertSToF %float %26 + %28 = OpLoad %v4float %FragColor + %29 = OpCompositeConstruct %v4float %27 %27 %27 %27 + %30 = OpFAdd %v4float %loaded %29 + OpStore %FragColor %30 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-untyped-array-length.asm.vk.nocompat.spv16.frag b/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-untyped-array-length.asm.vk.nocompat.spv16.frag new file mode 100644 index 000000000000..b9fbf56be10d --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/asm/frag/descriptor-heap-untyped-array-length.asm.vk.nocompat.spv16.frag @@ -0,0 +1,61 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 11 +; Bound: 31 +; Schema: 0 + OpCapability Shader + OpCapability UntypedPointersKHR + OpCapability DescriptorHeapEXT + OpExtension "SPV_EXT_descriptor_heap" + OpExtension "SPV_KHR_untyped_pointers" + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %FragColor %resource_heap + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 460 + OpSourceExtension "GL_EXT_descriptor_heap" + OpSourceExtension "GL_EXT_nonuniform_qualifier" + OpName %main "main" + OpName %FragColor "FragColor" + OpName %resource_heap "resource_heap" + OpName %SSBO "SSBO" + OpMemberName %SSBO 0 "data" + OpDecorate %FragColor Location 0 + OpDecorate %resource_heap BuiltIn ResourceHeapEXT + OpDecorate %_runtimearr_v4float ArrayStride 16 + OpDecorate %SSBO Block + OpMemberDecorate %SSBO 0 Offset 0 + OpDecorateId %_runtimearr_20 ArrayStrideIdEXT %21 + %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_0 = OpConstant %float 0 + %11 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0 +%_ptr_UniformConstant = OpTypeUntypedPointerKHR UniformConstant +%resource_heap = OpUntypedVariableKHR %_ptr_UniformConstant UniformConstant + %int = OpTypeInt 32 1 + %int_2 = OpConstant %int 2 +%_runtimearr_v4float = OpTypeRuntimeArray %v4float + %SSBO = OpTypeStruct %_runtimearr_v4float +%_ptr_StorageBuffer = OpTypeUntypedPointerKHR StorageBuffer + %20 = OpTypeBufferEXT StorageBuffer + %21 = OpConstantSizeOfEXT %int %20 +%_runtimearr_20 = OpTypeRuntimeArray %20 + %uint = OpTypeInt 32 0 + %main = OpFunction %void None %3 + %5 = OpLabel + OpStore %FragColor %11 + %19 = OpUntypedAccessChainKHR %_ptr_UniformConstant %_runtimearr_20 %resource_heap %int_2 + %23 = OpBufferPointerEXT %_ptr_StorageBuffer %19 + %25 = OpUntypedArrayLengthKHR %uint %SSBO %23 0 + %26 = OpBitcast %int %25 + %27 = OpConvertSToF %float %26 + %28 = OpLoad %v4float %FragColor + %29 = OpCompositeConstruct %v4float %27 %27 %27 %27 + %30 = OpFAdd %v4float %28 %29 + OpStore %FragColor %30 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders-no-opt/comp/integer-dot-product.comp b/third_party/spirv-cross/shaders-no-opt/comp/integer-dot-product.comp new file mode 100644 index 000000000000..8e0559ed46a2 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/comp/integer-dot-product.comp @@ -0,0 +1,119 @@ +#version 450 +#extension GL_EXT_shader_8bit_storage : require +#extension GL_EXT_shader_16bit_storage : require +#extension GL_EXT_shader_explicit_arithmetic_types : require +#extension GL_EXT_spirv_intrinsics : require + +layout(local_size_x = 1) in; + +layout(std430, binding = 0) buffer InOut { + uvec4 x; + uvec4 y; + int result; +} comp; + +layout(std430, binding = 1) buffer InOut2 { + uint x; + uint y; + uint result; +} comp2; + +layout(std430, binding = 1) buffer InOut3 { + u16vec4 x; + u16vec4 y; + int acc; + int result; +} comp3; + +// Signed integer dot with unsigned integer +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4450) +int sdot_int_result(u16vec4 x, u16vec4 y); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4450) +uint sdot_uint_result(u16vec4 x, u16vec4 y); + +// Unsigned integer dot with signed integer. Only unsigned result is allowed in SPIR-V. +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4451) +uint udot_uint_result(u16vec4 x, u16vec4 y); + +// Mixed integer dot with unsigned integer +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4452) +int sudot_int_result(u16vec4 x, u16vec4 y); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4452) +uint sudot_uint_result(u16vec4 x, u16vec4 y); + +// Signed packed dot product with different output widths. +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4450) +uint8_t spdot_to_8(uint x, uint y, spirv_literal uint packedFormat); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4450) +uint16_t spdot_to_16(uint x, uint y, spirv_literal uint packedFormat); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4450) +uint spdot_to_32(uint x, uint y, spirv_literal uint packedFormat); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4450) +int spdot_to_i32(uint x, uint y, spirv_literal uint packedFormat); + +// Unsigned packed dot product with different output widths. +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4451) +uint8_t updot_to_8(uint x, uint y, spirv_literal uint packedFormat); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4451) +uint16_t updot_to_16(uint x, uint y, spirv_literal uint packedFormat); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4451) +uint updot_to_32(uint x, uint y, spirv_literal uint packedFormat); + +// Mixed packed dot product with different output widths. +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4452) +uint8_t supdot_to_8(uint x, uint y, spirv_literal uint packedFormat); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4452) +uint16_t supdot_to_16(uint x, uint y, spirv_literal uint packedFormat); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4452) +uint supdot_to_32(uint x, uint y, spirv_literal uint packedFormat); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4452) +int supdot_to_i32(uint x, uint y, spirv_literal uint packedFormat); + +// SDotAccSat with unsigned input and result type +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4453) +int sdotaddsat_int_result(u16vec4 x, u16vec4 y, int acc); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4453) +uint sdotaddsat_uint_result(u16vec4 x, u16vec4 y, uint acc); + +// UDotAccSat. Result type must be unsigned in SPIR-V. +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4454) +uint udotaddsat(u16vec4 x, u16vec4 y, uint acc); + +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6018], id = 4454) +uint udotaddsat_packed(uint x, uint y, uint acc, spirv_literal uint packedFormat); + +// SUDotAccSat +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4455) +int sudotaddsat_int_result(u16vec4 x, u16vec4 y, int acc); +spirv_instruction (extensions = ["SPV_KHR_integer_dot_product"], capabilities = [6019, 6016], id = 4455) +uint sudotaddsat_uint_result(u16vec4 x, u16vec4 y, uint acc); + +void main() { + int sdot_int = sdot_int_result(comp3.x, comp3.y); + uint sdot_uint = sdot_uint_result(comp3.x, comp3.y); + uint udot_uint = udot_uint_result(comp3.x, comp3.y); + int sudot_int = sudot_int_result(comp3.x, comp3.y); + uint sudot_uint = sudot_uint_result(comp3.x, comp3.y); + + uint8_t spdot8 = spdot_to_8(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + uint16_t spdot16 = spdot_to_16(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + uint spdot32 = spdot_to_32(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + int spdoti32 = spdot_to_i32(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + + uint8_t updot8 = updot_to_8(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + uint16_t updot16 = updot_to_16(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + uint updot32 = updot_to_32(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + + uint8_t supdot8 = supdot_to_8(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + uint16_t supdot16 = supdot_to_16(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + uint supdot32 = supdot_to_32(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + int supdoti32 = supdot_to_i32(comp2.x, comp2.y, 0x0); // PackedVectorFormat4x8Bit + + int sdotaddsat_int = sdotaddsat_int_result(comp3.x, comp3.y, comp3.acc); + uint sdotaddsat_uint = sdotaddsat_uint_result(comp3.x, comp3.y, comp3.acc); + uint udotaddsat_uint = udotaddsat(comp3.x, comp3.y, comp3.acc); + int sudotaddsat_int = sudotaddsat_int_result(comp3.x, comp3.y, comp3.acc); + uint sudotaddsat_uint = sudotaddsat_uint_result(comp3.x, comp3.y, comp3.acc); + + uint udotaddsat_pack = udotaddsat_packed(comp2.x, comp2.y, comp3.acc, 0); // PackedVectorFormat4x8Bit +} diff --git a/third_party/spirv-cross/shaders-no-opt/frag/conservative-depth-es.frag b/third_party/spirv-cross/shaders-no-opt/frag/conservative-depth-es.frag new file mode 100644 index 000000000000..93d538f8c50b --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/frag/conservative-depth-es.frag @@ -0,0 +1,8 @@ +#version 310 es +#extension GL_EXT_conservative_depth : enable + +layout(depth_greater) out highp float gl_FragDepth; + +void main() { + gl_FragDepth = 1.0; +} diff --git a/third_party/spirv-cross/shaders-no-opt/frag/conservative-depth.frag b/third_party/spirv-cross/shaders-no-opt/frag/conservative-depth.frag new file mode 100644 index 000000000000..de1fd0f2fc6d --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/frag/conservative-depth.frag @@ -0,0 +1,8 @@ +#version 450 +#extension GL_ARB_conservative_depth : enable + +layout(depth_greater) out float gl_FragDepth; + +void main() { + gl_FragDepth = 1; +} diff --git a/third_party/spirv-cross/shaders-no-opt/vulkan/comp/shared-explicit-layout.vk.nocompat.spv14.comp b/third_party/spirv-cross/shaders-no-opt/vulkan/comp/shared-explicit-layout.vk.nocompat.spv14.comp new file mode 100644 index 000000000000..f221634db077 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/vulkan/comp/shared-explicit-layout.vk.nocompat.spv14.comp @@ -0,0 +1,16 @@ +#version 450 + +#extension GL_EXT_shared_memory_block : require + +shared SharedMemoryBlockA { + layout (offset = 0) uint a; +}; + +shared SharedMemoryBlockB { + layout (offset = 4) uint b; +}; + +void main() { + a = 6; + b = 7; +} \ No newline at end of file diff --git a/third_party/spirv-cross/shaders-no-opt/vulkan/comp/shared-explicit-scalar-layout.vk.nocompat.spv14.comp b/third_party/spirv-cross/shaders-no-opt/vulkan/comp/shared-explicit-scalar-layout.vk.nocompat.spv14.comp new file mode 100644 index 000000000000..5b33e1acebba --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/vulkan/comp/shared-explicit-scalar-layout.vk.nocompat.spv14.comp @@ -0,0 +1,17 @@ +#version 450 + +#extension GL_EXT_shared_memory_block : require +#extension GL_EXT_scalar_block_layout : require + +shared SharedMemoryBlockA { + layout (offset = 0) uint a; +}; + +layout (scalar) shared SharedMemoryBlockB { + layout (offset = 4) uvec3 b; +}; + +void main() { + a = 6; + b = uvec3(1, 2, 3); +} \ No newline at end of file diff --git a/third_party/spirv-cross/shaders-no-opt/vulkan/frag/descriptor-heap.heap-legacy-mapping.vk.nocompat.spv16.frag b/third_party/spirv-cross/shaders-no-opt/vulkan/frag/descriptor-heap.heap-legacy-mapping.vk.nocompat.spv16.frag new file mode 100644 index 000000000000..b93bfcaf80c4 --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/vulkan/frag/descriptor-heap.heap-legacy-mapping.vk.nocompat.spv16.frag @@ -0,0 +1,104 @@ +#version 460 +#extension GL_EXT_descriptor_heap : require +#extension GL_EXT_nonuniform_qualifier : require +#extension GL_EXT_samplerless_texture_functions : require +#extension GL_EXT_shader_image_load_formatted : require +#extension GL_EXT_ray_query : require +#extension GL_EXT_scalar_block_layout : require + +layout(descriptor_heap) uniform texture1D Images1D[]; +layout(descriptor_heap) uniform texture2D Images2D[]; +layout(descriptor_heap) uniform texture3D Images3D[]; + +layout(descriptor_heap) uniform accelerationStructureEXT RTAS[]; + +layout(descriptor_heap, r32f) writeonly uniform image1D WriteImages1D[]; +layout(descriptor_heap, r32f) writeonly uniform image2D WriteImages2D[]; +layout(descriptor_heap, r32f) writeonly uniform image3D WriteImages3D[]; + +layout(descriptor_heap, r32f) readonly uniform image1D RWriteImages1D[]; +layout(descriptor_heap, r32f) readonly uniform image2D RWriteImages2D[]; +layout(descriptor_heap, r32f) readonly uniform image3D RWriteImages3D[]; + +layout(descriptor_heap, r32ui) uniform uimage2D ImageAtomics[]; + +layout(descriptor_heap) uniform image2D WriteImages2DUnknown[]; + +layout(descriptor_heap) uniform sampler Samplers[]; + +layout(descriptor_heap, std140) uniform UBO140 +{ + float data[]; +} ubos140[]; + +layout(descriptor_heap, std430) uniform UBO430 +{ + vec3 data[]; +} ubos430[]; + +layout(descriptor_heap, scalar) uniform UBOScalar +{ + vec3 data[]; +} ubosScalar[]; + +layout(descriptor_heap) readonly buffer SSBOReadOnly +{ + vec4 data; +} ssbosReadOnly[]; + +layout(descriptor_heap) coherent writeonly buffer SSBOWriteOnly +{ + vec4 data; +} ssbosWriteOnly[]; + +layout(descriptor_heap) buffer SSBOAtomic +{ + uint data; + uint data2; +} ssbosAtomic[]; + +layout(descriptor_heap) buffer SSBO +{ + vec4 data; +} ssbos[]; + +layout(location = 0) out vec4 FragColor; + +rayQueryEXT rq; + +void main() +{ + FragColor = vec4(0.0); + + int desc_index = int(gl_FragCoord.x); + + FragColor += texelFetch(Images1D[desc_index + 0], 0, 0); + FragColor += texelFetch(Images2D[desc_index + 1], ivec2(0), 0); + FragColor += texelFetch(Images3D[desc_index + 2], ivec3(0), 0); + FragColor += texture(sampler2D(Images2D[int(gl_FragCoord.x)], Samplers[int(gl_FragCoord.y)]), vec2(0), 0); + FragColor += texture(sampler2DShadow(Images2D[int(gl_FragCoord.x)], Samplers[int(gl_FragCoord.y)]), vec3(0), 0); + + imageStore(WriteImages1D[desc_index + 3], 0, FragColor); + imageStore(WriteImages2D[desc_index + 4], ivec2(0), FragColor); + imageStore(WriteImages3D[desc_index + 5], ivec3(0), FragColor); + + FragColor += imageLoad(RWriteImages1D[desc_index + 6], 0); + FragColor += imageLoad(RWriteImages2D[desc_index + 7], ivec2(0)); + FragColor += imageLoad(RWriteImages3D[desc_index + 8], ivec3(0)); + + FragColor += imageLoad(WriteImages2DUnknown[desc_index + 9], ivec2(0)); + + FragColor += ubos140[desc_index + 10].data[1]; + FragColor += ubos430[desc_index + 11].data[1].x; + FragColor += ubosScalar[desc_index + 12].data[1].x; + FragColor += ssbosReadOnly[desc_index + 13].data; + ssbosWriteOnly[desc_index + 14].data = vec4(20.0); + FragColor += ssbos[desc_index + 15].data; + + imageAtomicAdd(ImageAtomics[desc_index + 16], ivec2(0), 50u); + + rayQueryInitializeEXT(rq, RTAS[desc_index + 17], 0, 0, vec3(0.0), 0.0, vec3(1.0, 0.0, 0.0), 1.0); + + // glslang untyped pointer atomics are broken ... + //atomicAdd(ssbosAtomic[desc_index].data2, 1); +} diff --git a/third_party/spirv-cross/shaders-no-opt/vulkan/frag/descriptor-heap.vk.nocompat.spv16.frag b/third_party/spirv-cross/shaders-no-opt/vulkan/frag/descriptor-heap.vk.nocompat.spv16.frag new file mode 100644 index 000000000000..048d1232a14d --- /dev/null +++ b/third_party/spirv-cross/shaders-no-opt/vulkan/frag/descriptor-heap.vk.nocompat.spv16.frag @@ -0,0 +1,93 @@ +#version 460 +#extension GL_EXT_descriptor_heap : require +#extension GL_EXT_nonuniform_qualifier : require +#extension GL_EXT_samplerless_texture_functions : require +#extension GL_EXT_shader_image_load_formatted : require +#extension GL_EXT_ray_query : require +#extension GL_EXT_scalar_block_layout : require + +layout(descriptor_heap) uniform texture1D Images1D[]; +layout(descriptor_heap) uniform texture2D Images2D[]; +layout(descriptor_heap) uniform texture3D Images3D[]; + +layout(descriptor_heap) uniform accelerationStructureEXT RTAS[]; + +layout(descriptor_heap, r32f) writeonly uniform image1D WriteImages1D[]; +layout(descriptor_heap, r32f) writeonly uniform image2D WriteImages2D[]; +layout(descriptor_heap, r32f) writeonly uniform image3D WriteImages3D[]; + +layout(descriptor_heap, r32f) readonly uniform image1D RWriteImages1D[]; +layout(descriptor_heap, r32f) readonly uniform image2D RWriteImages2D[]; +layout(descriptor_heap, r32f) readonly uniform image3D RWriteImages3D[]; + +layout(descriptor_heap, r32ui) uniform uimage2D ImageAtomics[]; + +layout(descriptor_heap) uniform image2D WriteImages2DUnknown[]; + +layout(descriptor_heap) uniform sampler Samplers[]; + +layout(descriptor_heap, std140) uniform UBO140 +{ + float data[]; +} ubos140[]; + +layout(descriptor_heap, std430) uniform UBO430 +{ + vec3 data[]; +} ubos430[]; + +layout(descriptor_heap, scalar) uniform UBOScalar +{ + vec3 data[]; +} ubosScalar[]; + +layout(descriptor_heap) readonly buffer SSBOReadOnly +{ + vec4 data; +} ssbosReadOnly[]; + +layout(descriptor_heap) coherent writeonly buffer SSBOWriteOnly +{ + vec4 data; +} ssbosWriteOnly[]; + +layout(descriptor_heap) buffer SSBO +{ + vec4 data; +} ssbos[]; + +layout(location = 0) out vec4 FragColor; + +rayQueryEXT rq; + +void main() +{ + FragColor = vec4(0.0); + + FragColor += texelFetch(Images1D[int(gl_FragCoord.x)], 0, 0); + FragColor += texelFetch(Images2D[int(gl_FragCoord.x)], ivec2(0), 0); + FragColor += texelFetch(Images3D[int(gl_FragCoord.x)], ivec3(0), 0); + FragColor += texture(sampler2D(Images2D[int(gl_FragCoord.x)], Samplers[int(gl_FragCoord.y)]), vec2(0), 0); + FragColor += texture(sampler2DShadow(Images2D[int(gl_FragCoord.x)], Samplers[int(gl_FragCoord.y)]), vec3(0), 0); + + imageStore(WriteImages1D[10], 0, FragColor); + imageStore(WriteImages2D[20], ivec2(0), FragColor); + imageStore(WriteImages3D[30], ivec3(0), FragColor); + + FragColor += imageLoad(RWriteImages1D[10], 0); + FragColor += imageLoad(RWriteImages2D[20], ivec2(0)); + FragColor += imageLoad(RWriteImages3D[30], ivec3(0)); + + FragColor += imageLoad(WriteImages2DUnknown[40], ivec2(0)); + + FragColor += ubos140[50].data[1]; + FragColor += ubos430[51].data[1].x; + FragColor += ubosScalar[52].data[1].x; + FragColor += ssbosReadOnly[60].data; + ssbosWriteOnly[61].data = vec4(20.0); + FragColor += ssbos[62].data; + + imageAtomicAdd(ImageAtomics[70], ivec2(0), 50u); + + rayQueryInitializeEXT(rq, RTAS[50], 0, 0, vec3(0.0), 0.0, vec3(1.0, 0.0, 0.0), 1.0); +} diff --git a/third_party/spirv-cross/shaders/asm/frag/out-of-bounds-access.asm.frag b/third_party/spirv-cross/shaders/asm/frag/out-of-bounds-access.asm.invalid.frag similarity index 100% rename from third_party/spirv-cross/shaders/asm/frag/out-of-bounds-access.asm.frag rename to third_party/spirv-cross/shaders/asm/frag/out-of-bounds-access.asm.invalid.frag diff --git a/third_party/spirv-cross/shaders/asm/frag/texture-sampling-fp16.asm.vk.frag b/third_party/spirv-cross/shaders/asm/frag/texture-sampling-fp16.asm.vk.invalid.frag similarity index 100% rename from third_party/spirv-cross/shaders/asm/frag/texture-sampling-fp16.asm.vk.frag rename to third_party/spirv-cross/shaders/asm/frag/texture-sampling-fp16.asm.vk.invalid.frag diff --git a/third_party/spirv-cross/shaders/asm/frag/texture-shadow-lod.asm.frag b/third_party/spirv-cross/shaders/asm/frag/texture-shadow-lod.asm.frag new file mode 100644 index 000000000000..c5af14e62f16 --- /dev/null +++ b/third_party/spirv-cross/shaders/asm/frag/texture-shadow-lod.asm.frag @@ -0,0 +1,45 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos Glslang Reference Front End; 1 +; Bound: 50 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" %FragColor %vUV %vLod + OpExecutionMode %main OriginUpperLeft + OpName %main "main" + OpName %FragColor "FragColor" + OpName %uShadow2DArray "uShadow2DArray" + OpName %vUV "vUV" + OpName %vLod "vLod" + OpDecorate %FragColor Location 0 + OpDecorate %uShadow2DArray DescriptorSet 0 + OpDecorate %uShadow2DArray Binding 0 + OpDecorate %vUV Location 0 + OpDecorate %vLod Location 1 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%_ptr_Output_v4float = OpTypePointer Output %v4float + %FragColor = OpVariable %_ptr_Output_v4float Output + %10 = OpTypeImage %float 2D 1 1 0 1 Unknown + %11 = OpTypeSampledImage %10 +%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11 +%uShadow2DArray = OpVariable %_ptr_UniformConstant_11 UniformConstant +%_ptr_Input_v4float = OpTypePointer Input %v4float + %vUV = OpVariable %_ptr_Input_v4float Input +%_ptr_Input_float = OpTypePointer Input %float + %vLod = OpVariable %_ptr_Input_float Input + %main = OpFunction %void None %3 + %5 = OpLabel + %14 = OpLoad %11 %uShadow2DArray + %17 = OpLoad %v4float %vUV + %19 = OpLoad %float %vLod + %20 = OpCompositeExtract %float %17 3 + %21 = OpImageSampleDrefExplicitLod %float %14 %17 %20 Lod %19 + %22 = OpCompositeConstruct %v4float %21 %21 %21 %21 + OpStore %FragColor %22 + OpReturn + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders/asm/lib/global-array.asm.lib b/third_party/spirv-cross/shaders/asm/lib/global-array.asm.lib new file mode 100644 index 000000000000..dbe5bf8d7684 --- /dev/null +++ b/third_party/spirv-cross/shaders/asm/lib/global-array.asm.lib @@ -0,0 +1,35 @@ +; SPIR-V +; Version: 1.5 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 30 +; Schema: 0 + OpCapability Linkage + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpSource HLSL 630 + OpName %lookup "lookup" + OpName %i "i" + OpName %table "table" + OpDecorate %lookup LinkageAttributes "lookup" Export + %uint = OpTypeInt 32 0 + %uint_10 = OpConstant %uint 10 + %uint_20 = OpConstant %uint 20 + %uint_30 = OpConstant %uint 30 + %uint_40 = OpConstant %uint 40 + %uint_4 = OpConstant %uint 4 +%_arr_uint_uint_4 = OpTypeArray %uint %uint_4 +%_ptr_Private__arr_uint_uint_4 = OpTypePointer Private %_arr_uint_uint_4 +%_ptr_Private_uint = OpTypePointer Private %uint +%_ptr_Function_uint = OpTypePointer Function %uint + %fn1 = OpTypeFunction %uint %_ptr_Function_uint +%table_init = OpConstantComposite %_arr_uint_uint_4 %uint_10 %uint_20 %uint_30 %uint_40 + %table = OpVariable %_ptr_Private__arr_uint_uint_4 Private %table_init + + %lookup = OpFunction %uint None %fn1 + %i = OpFunctionParameter %_ptr_Function_uint + %l_bb = OpLabel + %l_iv = OpLoad %uint %i + %l_ac = OpAccessChain %_ptr_Private_uint %table %l_iv + %l_v = OpLoad %uint %l_ac + OpReturnValue %l_v + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders/asm/lib/multi-export.asm.lib b/third_party/spirv-cross/shaders/asm/lib/multi-export.asm.lib new file mode 100644 index 000000000000..a7851d11031e --- /dev/null +++ b/third_party/spirv-cross/shaders/asm/lib/multi-export.asm.lib @@ -0,0 +1,54 @@ +; SPIR-V +; Version: 1.5 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 40 +; Schema: 0 + OpCapability Linkage + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpSource HLSL 630 + OpName %add_one "add_one" + OpName %x "x" + OpName %add_two "add_two" + OpName %y "y" + OpName %helper_add "helper_add" + OpName %a "a" + OpName %b "b" + OpDecorate %add_one LinkageAttributes "add_one" Export + OpDecorate %add_two LinkageAttributes "add_two" Export + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 +%_ptr_Function_uint = OpTypePointer Function %uint + %fn1 = OpTypeFunction %uint %_ptr_Function_uint + %fn2 = OpTypeFunction %uint %_ptr_Function_uint %_ptr_Function_uint + + %helper_add = OpFunction %uint None %fn2 + %a = OpFunctionParameter %_ptr_Function_uint + %b = OpFunctionParameter %_ptr_Function_uint + %h_bb = OpLabel + %h_av = OpLoad %uint %a + %h_bv = OpLoad %uint %b + %h_sum = OpIAdd %uint %h_av %h_bv + OpReturnValue %h_sum + OpFunctionEnd + + %add_one = OpFunction %uint None %fn1 + %x = OpFunctionParameter %_ptr_Function_uint + %o_bb = OpLabel + %o_xv = OpLoad %uint %x + %o_r = OpIAdd %uint %o_xv %uint_1 + OpReturnValue %o_r + OpFunctionEnd + + %add_two = OpFunction %uint None %fn1 + %y = OpFunctionParameter %_ptr_Function_uint + %t_bb = OpLabel + %t_arg1 = OpVariable %_ptr_Function_uint Function + %t_arg2 = OpVariable %_ptr_Function_uint Function + %t_yv = OpLoad %uint %y + OpStore %t_arg1 %t_yv + OpStore %t_arg2 %uint_2 + %t_r = OpFunctionCall %uint %helper_add %t_arg1 %t_arg2 + OpReturnValue %t_r + OpFunctionEnd diff --git a/third_party/spirv-cross/shaders/asm/vert/push-constant-row-major-matrix.asm.vk.vert b/third_party/spirv-cross/shaders/asm/vert/push-constant-row-major-matrix.asm.vk.vert new file mode 100644 index 000000000000..afe5581ba46e --- /dev/null +++ b/third_party/spirv-cross/shaders/asm/vert/push-constant-row-major-matrix.asm.vk.vert @@ -0,0 +1,66 @@ +; SPIR-V +; Version: 1.0 +; Generator: Google spiregg; 0 +; Bound: 23 +; Schema: 0 + OpCapability Shader + OpExtension "SPV_GOOGLE_hlsl_functionality1" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %in_var_POSITION %gl_Position + %4 = OpString ".\\push-constant-row-major-matrix.hlsl" + OpSource HLSL 600 %4 " +struct Matrix { + float4x4 transform; +}; + +[[vk::push_constant]] Matrix matrix_constants; + +float4 main(float4 in_position : POSITION) : SV_Position { + return mul(matrix_constants.transform, in_position); +} +" + OpName %type_PushConstant_Matrix "type.PushConstant.Matrix" + OpMemberName %type_PushConstant_Matrix 0 "transform" + OpName %matrix_constants "matrix_constants" + OpName %in_var_POSITION "in.var.POSITION" + OpName %main "main" + OpDecorateString %in_var_POSITION UserSemantic "POSITION" + OpDecorate %gl_Position BuiltIn Position + OpDecorateString %gl_Position UserSemantic "SV_Position" + OpDecorate %in_var_POSITION Location 0 + OpMemberDecorate %type_PushConstant_Matrix 0 Offset 0 + OpMemberDecorate %type_PushConstant_Matrix 0 MatrixStride 16 + OpMemberDecorate %type_PushConstant_Matrix 0 RowMajor + OpDecorate %type_PushConstant_Matrix Block + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 + %float = OpTypeFloat 32 + %v4float = OpTypeVector %float 4 +%mat4v4float = OpTypeMatrix %v4float 4 +%type_PushConstant_Matrix = OpTypeStruct %mat4v4float +%_ptr_PushConstant_type_PushConstant_Matrix = OpTypePointer PushConstant %type_PushConstant_Matrix +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Output_v4float = OpTypePointer Output %v4float + %void = OpTypeVoid + %16 = OpTypeFunction %void +%_ptr_PushConstant_mat4v4float = OpTypePointer PushConstant %mat4v4float +%matrix_constants = OpVariable %_ptr_PushConstant_type_PushConstant_Matrix PushConstant +%in_var_POSITION = OpVariable %_ptr_Input_v4float Input +%gl_Position = OpVariable %_ptr_Output_v4float Output + OpLine %4 8 1 + %main = OpFunction %void None %16 + OpNoLine + %18 = OpLabel + OpLine %4 8 1 + %19 = OpLoad %v4float %in_var_POSITION + OpLine %4 9 16 + %20 = OpAccessChain %_ptr_PushConstant_mat4v4float %matrix_constants %int_0 + OpLine %4 9 33 + %21 = OpLoad %mat4v4float %20 + OpLine %4 9 12 + %22 = OpVectorTimesMatrix %v4float %19 %21 + OpLine %4 8 1 + OpStore %gl_Position %22 + OpLine %4 10 1 + OpReturn + OpFunctionEnd \ No newline at end of file diff --git a/third_party/spirv-cross/shaders/comp/cooperative-matrix.vk.nocompat.comp b/third_party/spirv-cross/shaders/comp/cooperative-matrix.vk.nocompat.comp index a95414962f90..e9b42d2a4186 100644 --- a/third_party/spirv-cross/shaders/comp/cooperative-matrix.vk.nocompat.comp +++ b/third_party/spirv-cross/shaders/comp/cooperative-matrix.vk.nocompat.comp @@ -17,13 +17,13 @@ layout(set = 0, binding = 0) buffer SSBO16 float16_t data[]; } ssbo16; -layout(constant_id = 0) const int Rows = 16; -layout(constant_id = 1) const int Columns = 16; +/*layout(constant_id = 0)*/ const int Rows = 16; +/*layout(constant_id = 1)*/ const int Columns = 16; const int UseA = gl_MatrixUseA; const int UseB = gl_MatrixUseB; const int UseC = gl_MatrixUseAccumulator; -layout(constant_id = 5) const int Layout = gl_CooperativeMatrixLayoutRowMajor; -layout(constant_id = 6) const int Scope = gl_ScopeSubgroup; +/*layout(constant_id = 5)*/ const int Layout = gl_CooperativeMatrixLayoutRowMajor; +/*layout(constant_id = 6)*/ const int Scope = gl_ScopeSubgroup; coopmat coopmat_square(coopmat a) { diff --git a/third_party/spirv-cross/shaders/comp/long-vector.vk.nocompat.comp b/third_party/spirv-cross/shaders/comp/long-vector.vk.nocompat.comp new file mode 100644 index 000000000000..1dd0fab57b06 --- /dev/null +++ b/third_party/spirv-cross/shaders/comp/long-vector.vk.nocompat.comp @@ -0,0 +1,63 @@ +#version 450 + +#extension GL_EXT_long_vector : require +#extension GL_EXT_scalar_block_layout : require + +layout(local_size_x = 4) in; + +// Spec constant vector size seems a bit broken in glslang. +// It seems to infer cooperative vector for some reason. +// Leave it untested for now. + +layout(set = 0, binding = 0, std430) buffer SSBO430 +{ + vector v1[4]; + vector v5[4]; + vector v6[4]; + vector v7[4]; + vector v8[4]; + vector v1024[4]; +} s430; + +layout(set = 0, binding = 1, scalar) buffer SSBOScalar +{ + vector v1[4]; + vector v5[4]; + vector v6[4]; + vector v7[4]; + vector v8[4]; + vector v1024[4]; +} scalar; + +shared vector shared_vec[4]; + +void main() +{ + uint idx = gl_GlobalInvocationID.x; + s430.v1[0] += 4.0; + s430.v5[idx] += 2.0; + s430.v6[idx] += 3.0; + s430.v7[idx] += 4.0; + s430.v8[idx] += 5.0; + + scalar.v1[0] += 6.0; + scalar.v5[idx] += 6.0; + scalar.v6[idx] += 7.0; + scalar.v7[idx] += 8.0; + scalar.v8[idx] += 9.0; + + // Splat construction. + vector V = vector(1); + + // Access chains + V[10] += 50.0; + V[gl_LocalInvocationIndex] += 60.0; + + shared_vec[gl_LocalInvocationIndex] = V; + barrier(); + + // Huge load-store. + s430.v1024[idx] = shared_vec[gl_LocalInvocationIndex]; + scalar.v1024[idx] = V; +} + diff --git a/third_party/spirv-cross/shaders/frag/texture-shadow-lod-bias.frag b/third_party/spirv-cross/shaders/frag/texture-shadow-lod-bias.frag new file mode 100644 index 000000000000..1d10f5cac916 --- /dev/null +++ b/third_party/spirv-cross/shaders/frag/texture-shadow-lod-bias.frag @@ -0,0 +1,16 @@ +#version 450 +#extension GL_EXT_texture_shadow_lod : require + +layout(binding = 0) uniform sampler2DArrayShadow uShadow2DArray; + +layout(location = 0) in vec4 vUV; +layout(location = 1) in float vBias; +layout(location = 0) out vec4 FragColor; + +void main() +{ + float r = 0.0; + r += texture(uShadow2DArray, vUV, vBias); + r += textureOffset(uShadow2DArray, vUV, ivec2(1, 1), vBias); + FragColor = vec4(r); +} diff --git a/third_party/spirv-cross/shaders/frag/texture-shadow-lod.vk.frag b/third_party/spirv-cross/shaders/frag/texture-shadow-lod.vk.frag new file mode 100644 index 000000000000..661daec121d2 --- /dev/null +++ b/third_party/spirv-cross/shaders/frag/texture-shadow-lod.vk.frag @@ -0,0 +1,19 @@ +#version 450 +#extension GL_EXT_texture_shadow_lod : require + +layout(binding = 0) uniform sampler2DArrayShadow uShadow2DArray; +layout(binding = 1) uniform samplerCubeShadow uShadowCube; + +layout(location = 0) in vec4 vUV; +layout(location = 1) in float vLod; +layout(location = 0) out vec4 FragColor; + +void main() +{ + float r = 0.0; + r += textureLod(uShadow2DArray, vUV, 0.0); + r += textureLod(uShadow2DArray, vUV, vLod); + r += textureLod(uShadowCube, vUV, vLod); + r += textureLodOffset(uShadow2DArray, vUV, vLod, ivec2(1, 1)); + FragColor = vec4(r); +} diff --git a/third_party/spirv-cross/spirv.h b/third_party/spirv-cross/spirv.h index 26bc6d9d8b8d..d00cf0f4e959 100644 --- a/third_party/spirv-cross/spirv.h +++ b/third_party/spirv-cross/spirv.h @@ -179,6 +179,7 @@ typedef enum SpvExecutionMode_ { SpvExecutionModeQuadDerivativesKHR = 5088, SpvExecutionModeRequireFullQuadsKHR = 5089, SpvExecutionModeSharesInputWithAMDX = 5102, + SpvExecutionModeArithmeticPoisonKHR = 5157, SpvExecutionModeOutputLinesEXT = 5269, SpvExecutionModeOutputLinesNV = 5269, SpvExecutionModeOutputPrimitivesEXT = 5270, @@ -195,6 +196,7 @@ typedef enum SpvExecutionMode_ { SpvExecutionModeSampleInterlockUnorderedEXT = 5369, SpvExecutionModeShadingRateInterlockOrderedEXT = 5370, SpvExecutionModeShadingRateInterlockUnorderedEXT = 5371, + SpvExecutionModeShader64BitIndexingEXT = 5427, SpvExecutionModeSharedLocalMemorySizeINTEL = 5618, SpvExecutionModeRoundingModeRTPINTEL = 5620, SpvExecutionModeRoundingModeRTNINTEL = 5621, @@ -249,8 +251,11 @@ typedef enum SpvStorageClass_ { SpvStorageClassPhysicalStorageBufferEXT = 5349, SpvStorageClassHitObjectAttributeNV = 5385, SpvStorageClassTaskPayloadWorkgroupEXT = 5402, + SpvStorageClassHitObjectAttributeEXT = 5411, SpvStorageClassCodeSectionINTEL = 5605, + SpvStorageClassDeviceOnlyALTERA = 5936, SpvStorageClassDeviceOnlyINTEL = 5936, + SpvStorageClassHostOnlyALTERA = 5937, SpvStorageClassHostOnlyINTEL = 5937, SpvStorageClassMax = 0x7fffffff, } SpvStorageClass; @@ -489,6 +494,7 @@ typedef enum SpvFunctionParameterAttribute_ { SpvFunctionParameterAttributeNoCapture = 5, SpvFunctionParameterAttributeNoWrite = 6, SpvFunctionParameterAttributeNoReadWrite = 7, + SpvFunctionParameterAttributeRuntimeAlignedALTERA = 5940, SpvFunctionParameterAttributeRuntimeAlignedINTEL = 5940, SpvFunctionParameterAttributeMax = 0x7fffffff, } SpvFunctionParameterAttribute; @@ -556,6 +562,9 @@ typedef enum SpvDecoration_ { SpvDecorationPayloadNodeSparseArrayAMDX = 5099, SpvDecorationPayloadNodeArraySizeAMDX = 5100, SpvDecorationPayloadDispatchIndirectAMDX = 5105, + SpvDecorationArrayStrideIdEXT = 5124, + SpvDecorationOffsetIdEXT = 5125, + SpvDecorationUTFEncodedKHR = 5145, SpvDecorationOverrideCoverageNV = 5248, SpvDecorationPassthroughNV = 5250, SpvDecorationViewportRelativeNV = 5252, @@ -572,7 +581,10 @@ typedef enum SpvDecoration_ { SpvDecorationRestrictPointerEXT = 5355, SpvDecorationAliasedPointer = 5356, SpvDecorationAliasedPointerEXT = 5356, + SpvDecorationMemberOffsetNV = 5358, SpvDecorationHitObjectShaderRecordBufferNV = 5386, + SpvDecorationHitObjectShaderRecordBufferEXT = 5389, + SpvDecorationBankNV = 5397, SpvDecorationBindlessSamplerNV = 5398, SpvDecorationBindlessImageNV = 5399, SpvDecorationBoundSamplerNV = 5400, @@ -593,54 +605,95 @@ typedef enum SpvDecoration_ { SpvDecorationUserTypeGOOGLE = 5636, SpvDecorationFunctionRoundingModeINTEL = 5822, SpvDecorationFunctionDenormModeINTEL = 5823, + SpvDecorationRegisterALTERA = 5825, SpvDecorationRegisterINTEL = 5825, + SpvDecorationMemoryALTERA = 5826, SpvDecorationMemoryINTEL = 5826, + SpvDecorationNumbanksALTERA = 5827, SpvDecorationNumbanksINTEL = 5827, + SpvDecorationBankwidthALTERA = 5828, SpvDecorationBankwidthINTEL = 5828, + SpvDecorationMaxPrivateCopiesALTERA = 5829, SpvDecorationMaxPrivateCopiesINTEL = 5829, + SpvDecorationSinglepumpALTERA = 5830, SpvDecorationSinglepumpINTEL = 5830, + SpvDecorationDoublepumpALTERA = 5831, SpvDecorationDoublepumpINTEL = 5831, + SpvDecorationMaxReplicatesALTERA = 5832, SpvDecorationMaxReplicatesINTEL = 5832, + SpvDecorationSimpleDualPortALTERA = 5833, SpvDecorationSimpleDualPortINTEL = 5833, + SpvDecorationMergeALTERA = 5834, SpvDecorationMergeINTEL = 5834, + SpvDecorationBankBitsALTERA = 5835, SpvDecorationBankBitsINTEL = 5835, + SpvDecorationForcePow2DepthALTERA = 5836, SpvDecorationForcePow2DepthINTEL = 5836, + SpvDecorationStridesizeALTERA = 5883, SpvDecorationStridesizeINTEL = 5883, + SpvDecorationWordsizeALTERA = 5884, SpvDecorationWordsizeINTEL = 5884, + SpvDecorationTrueDualPortALTERA = 5885, SpvDecorationTrueDualPortINTEL = 5885, + SpvDecorationBurstCoalesceALTERA = 5899, SpvDecorationBurstCoalesceINTEL = 5899, + SpvDecorationCacheSizeALTERA = 5900, SpvDecorationCacheSizeINTEL = 5900, + SpvDecorationDontStaticallyCoalesceALTERA = 5901, SpvDecorationDontStaticallyCoalesceINTEL = 5901, + SpvDecorationPrefetchALTERA = 5902, SpvDecorationPrefetchINTEL = 5902, + SpvDecorationStallEnableALTERA = 5905, SpvDecorationStallEnableINTEL = 5905, + SpvDecorationFuseLoopsInFunctionALTERA = 5907, SpvDecorationFuseLoopsInFunctionINTEL = 5907, + SpvDecorationMathOpDSPModeALTERA = 5909, SpvDecorationMathOpDSPModeINTEL = 5909, SpvDecorationAliasScopeINTEL = 5914, SpvDecorationNoAliasINTEL = 5915, + SpvDecorationInitiationIntervalALTERA = 5917, SpvDecorationInitiationIntervalINTEL = 5917, + SpvDecorationMaxConcurrencyALTERA = 5918, SpvDecorationMaxConcurrencyINTEL = 5918, + SpvDecorationPipelineEnableALTERA = 5919, SpvDecorationPipelineEnableINTEL = 5919, + SpvDecorationBufferLocationALTERA = 5921, SpvDecorationBufferLocationINTEL = 5921, + SpvDecorationIOPipeStorageALTERA = 5944, SpvDecorationIOPipeStorageINTEL = 5944, SpvDecorationFunctionFloatingPointModeINTEL = 6080, SpvDecorationSingleElementVectorINTEL = 6085, SpvDecorationVectorComputeCallableFunctionINTEL = 6087, SpvDecorationMediaBlockIOINTEL = 6140, + SpvDecorationStallFreeALTERA = 6151, SpvDecorationStallFreeINTEL = 6151, SpvDecorationFPMaxErrorDecorationINTEL = 6170, + SpvDecorationLatencyControlLabelALTERA = 6172, SpvDecorationLatencyControlLabelINTEL = 6172, + SpvDecorationLatencyControlConstraintALTERA = 6173, SpvDecorationLatencyControlConstraintINTEL = 6173, + SpvDecorationConduitKernelArgumentALTERA = 6175, SpvDecorationConduitKernelArgumentINTEL = 6175, + SpvDecorationRegisterMapKernelArgumentALTERA = 6176, SpvDecorationRegisterMapKernelArgumentINTEL = 6176, + SpvDecorationMMHostInterfaceAddressWidthALTERA = 6177, SpvDecorationMMHostInterfaceAddressWidthINTEL = 6177, + SpvDecorationMMHostInterfaceDataWidthALTERA = 6178, SpvDecorationMMHostInterfaceDataWidthINTEL = 6178, + SpvDecorationMMHostInterfaceLatencyALTERA = 6179, SpvDecorationMMHostInterfaceLatencyINTEL = 6179, + SpvDecorationMMHostInterfaceReadWriteModeALTERA = 6180, SpvDecorationMMHostInterfaceReadWriteModeINTEL = 6180, + SpvDecorationMMHostInterfaceMaxBurstALTERA = 6181, SpvDecorationMMHostInterfaceMaxBurstINTEL = 6181, + SpvDecorationMMHostInterfaceWaitRequestALTERA = 6182, SpvDecorationMMHostInterfaceWaitRequestINTEL = 6182, + SpvDecorationStableKernelArgumentALTERA = 6183, SpvDecorationStableKernelArgumentINTEL = 6183, SpvDecorationHostAccessINTEL = 6188, + SpvDecorationInitModeALTERA = 6190, SpvDecorationInitModeINTEL = 6190, + SpvDecorationImplementInRegisterMapALTERA = 6191, SpvDecorationImplementInRegisterMapINTEL = 6191, SpvDecorationConditionalINTEL = 6247, SpvDecorationCacheControlLoadINTEL = 6442, @@ -725,6 +778,8 @@ typedef enum SpvBuiltIn_ { SpvBuiltInFragStencilRefEXT = 5014, SpvBuiltInRemainingRecursionLevelsAMDX = 5021, SpvBuiltInShaderIndexAMDX = 5073, + SpvBuiltInSamplerHeapEXT = 5122, + SpvBuiltInResourceHeapEXT = 5123, SpvBuiltInViewportMaskNV = 5253, SpvBuiltInSecondaryPositionNV = 5257, SpvBuiltInSecondaryViewportMaskNV = 5258, @@ -822,15 +877,25 @@ typedef enum SpvLoopControlShift_ { SpvLoopControlIterationMultipleShift = 6, SpvLoopControlPeelCountShift = 7, SpvLoopControlPartialCountShift = 8, + SpvLoopControlInitiationIntervalALTERAShift = 16, SpvLoopControlInitiationIntervalINTELShift = 16, + SpvLoopControlMaxConcurrencyALTERAShift = 17, SpvLoopControlMaxConcurrencyINTELShift = 17, + SpvLoopControlDependencyArrayALTERAShift = 18, SpvLoopControlDependencyArrayINTELShift = 18, + SpvLoopControlPipelineEnableALTERAShift = 19, SpvLoopControlPipelineEnableINTELShift = 19, + SpvLoopControlLoopCoalesceALTERAShift = 20, SpvLoopControlLoopCoalesceINTELShift = 20, + SpvLoopControlMaxInterleavingALTERAShift = 21, SpvLoopControlMaxInterleavingINTELShift = 21, + SpvLoopControlSpeculatedIterationsALTERAShift = 22, SpvLoopControlSpeculatedIterationsINTELShift = 22, + SpvLoopControlNoFusionALTERAShift = 23, SpvLoopControlNoFusionINTELShift = 23, + SpvLoopControlLoopCountALTERAShift = 24, SpvLoopControlLoopCountINTELShift = 24, + SpvLoopControlMaxReinvocationDelayALTERAShift = 25, SpvLoopControlMaxReinvocationDelayINTELShift = 25, SpvLoopControlMax = 0x7fffffff, } SpvLoopControlShift; @@ -846,15 +911,25 @@ typedef enum SpvLoopControlMask_ { SpvLoopControlIterationMultipleMask = 0x00000040, SpvLoopControlPeelCountMask = 0x00000080, SpvLoopControlPartialCountMask = 0x00000100, + SpvLoopControlInitiationIntervalALTERAMask = 0x00010000, SpvLoopControlInitiationIntervalINTELMask = 0x00010000, + SpvLoopControlMaxConcurrencyALTERAMask = 0x00020000, SpvLoopControlMaxConcurrencyINTELMask = 0x00020000, + SpvLoopControlDependencyArrayALTERAMask = 0x00040000, SpvLoopControlDependencyArrayINTELMask = 0x00040000, + SpvLoopControlPipelineEnableALTERAMask = 0x00080000, SpvLoopControlPipelineEnableINTELMask = 0x00080000, + SpvLoopControlLoopCoalesceALTERAMask = 0x00100000, SpvLoopControlLoopCoalesceINTELMask = 0x00100000, + SpvLoopControlMaxInterleavingALTERAMask = 0x00200000, SpvLoopControlMaxInterleavingINTELMask = 0x00200000, + SpvLoopControlSpeculatedIterationsALTERAMask = 0x00400000, SpvLoopControlSpeculatedIterationsINTELMask = 0x00400000, + SpvLoopControlNoFusionALTERAMask = 0x00800000, SpvLoopControlNoFusionINTELMask = 0x00800000, + SpvLoopControlLoopCountALTERAMask = 0x01000000, SpvLoopControlLoopCountINTELMask = 0x01000000, + SpvLoopControlMaxReinvocationDelayALTERAMask = 0x02000000, SpvLoopControlMaxReinvocationDelayINTELMask = 0x02000000, } SpvLoopControlMask; @@ -967,8 +1042,11 @@ typedef enum SpvGroupOperation_ { SpvGroupOperationInclusiveScan = 1, SpvGroupOperationExclusiveScan = 2, SpvGroupOperationClusteredReduce = 3, + SpvGroupOperationPartitionedReduceEXT = 6, SpvGroupOperationPartitionedReduceNV = 6, + SpvGroupOperationPartitionedInclusiveScanEXT = 7, SpvGroupOperationPartitionedInclusiveScanNV = 7, + SpvGroupOperationPartitionedExclusiveScanEXT = 8, SpvGroupOperationPartitionedExclusiveScanNV = 8, SpvGroupOperationMax = 0x7fffffff, } SpvGroupOperation; @@ -1124,6 +1202,10 @@ typedef enum SpvCapability_ { SpvCapabilityBFloat16TypeKHR = 5116, SpvCapabilityBFloat16DotProductKHR = 5117, SpvCapabilityBFloat16CooperativeMatrixKHR = 5118, + SpvCapabilityAbortKHR = 5120, + SpvCapabilityDescriptorHeapEXT = 5128, + SpvCapabilityConstantDataKHR = 5146, + SpvCapabilityPoisonFreezeKHR = 5156, SpvCapabilitySampleMaskOverrideCoverageNV = 5249, SpvCapabilityGeometryShaderPassthroughNV = 5251, SpvCapabilityShaderViewportIndexLayerEXT = 5254, @@ -1141,6 +1223,7 @@ typedef enum SpvCapability_ { SpvCapabilityComputeDerivativeGroupQuadsNV = 5288, SpvCapabilityFragmentDensityEXT = 5291, SpvCapabilityShadingRateNV = 5291, + SpvCapabilityGroupNonUniformPartitionedEXT = 5297, SpvCapabilityGroupNonUniformPartitionedNV = 5297, SpvCapabilityShaderNonUniform = 5301, SpvCapabilityShaderNonUniformEXT = 5301, @@ -1188,6 +1271,7 @@ typedef enum SpvCapability_ { SpvCapabilityDisplacementMicromapNV = 5380, SpvCapabilityRayTracingOpacityMicromapEXT = 5381, SpvCapabilityShaderInvocationReorderNV = 5383, + SpvCapabilityShaderInvocationReorderEXT = 5388, SpvCapabilityBindlessTextureNV = 5390, SpvCapabilityRayQueryPositionFetchKHR = 5391, SpvCapabilityCooperativeVectorNV = 5394, @@ -1196,6 +1280,9 @@ typedef enum SpvCapability_ { SpvCapabilityRawAccessChainsNV = 5414, SpvCapabilityRayTracingSpheresGeometryNV = 5418, SpvCapabilityRayTracingLinearSweptSpheresGeometryNV = 5419, + SpvCapabilityPushConstantBanksNV = 5423, + SpvCapabilityLongVectorEXT = 5425, + SpvCapabilityShader64BitIndexingEXT = 5426, SpvCapabilityCooperativeMatrixReductionsNV = 5430, SpvCapabilityCooperativeMatrixConversionsNV = 5431, SpvCapabilityCooperativeMatrixPerElementOperationsNV = 5432, @@ -1225,26 +1312,42 @@ typedef enum SpvCapability_ { SpvCapabilitySubgroupAvcMotionEstimationChromaINTEL = 5698, SpvCapabilityVariableLengthArrayINTEL = 5817, SpvCapabilityFunctionFloatControlINTEL = 5821, + SpvCapabilityFPGAMemoryAttributesALTERA = 5824, SpvCapabilityFPGAMemoryAttributesINTEL = 5824, SpvCapabilityFPFastMathModeINTEL = 5837, + SpvCapabilityArbitraryPrecisionIntegersALTERA = 5844, SpvCapabilityArbitraryPrecisionIntegersINTEL = 5844, + SpvCapabilityArbitraryPrecisionFloatingPointALTERA = 5845, SpvCapabilityArbitraryPrecisionFloatingPointINTEL = 5845, SpvCapabilityUnstructuredLoopControlsINTEL = 5886, + SpvCapabilityFPGALoopControlsALTERA = 5888, SpvCapabilityFPGALoopControlsINTEL = 5888, SpvCapabilityKernelAttributesINTEL = 5892, SpvCapabilityFPGAKernelAttributesINTEL = 5897, + SpvCapabilityFPGAMemoryAccessesALTERA = 5898, SpvCapabilityFPGAMemoryAccessesINTEL = 5898, + SpvCapabilityFPGAClusterAttributesALTERA = 5904, SpvCapabilityFPGAClusterAttributesINTEL = 5904, + SpvCapabilityLoopFuseALTERA = 5906, SpvCapabilityLoopFuseINTEL = 5906, + SpvCapabilityFPGADSPControlALTERA = 5908, SpvCapabilityFPGADSPControlINTEL = 5908, SpvCapabilityMemoryAccessAliasingINTEL = 5910, + SpvCapabilityFPGAInvocationPipeliningAttributesALTERA = 5916, SpvCapabilityFPGAInvocationPipeliningAttributesINTEL = 5916, + SpvCapabilityFPGABufferLocationALTERA = 5920, SpvCapabilityFPGABufferLocationINTEL = 5920, + SpvCapabilityArbitraryPrecisionFixedPointALTERA = 5922, SpvCapabilityArbitraryPrecisionFixedPointINTEL = 5922, + SpvCapabilityUSMStorageClassesALTERA = 5935, SpvCapabilityUSMStorageClassesINTEL = 5935, + SpvCapabilityRuntimeAlignedAttributeALTERA = 5939, SpvCapabilityRuntimeAlignedAttributeINTEL = 5939, + SpvCapabilityIOPipesALTERA = 5943, SpvCapabilityIOPipesINTEL = 5943, + SpvCapabilityBlockingPipesALTERA = 5945, SpvCapabilityBlockingPipesINTEL = 5945, + SpvCapabilityFPGARegALTERA = 5948, SpvCapabilityFPGARegINTEL = 5948, SpvCapabilityDotProductInputAll = 6016, SpvCapabilityDotProductInputAllKHR = 6016, @@ -1271,13 +1374,18 @@ typedef enum SpvCapability_ { SpvCapabilityBFloat16ConversionINTEL = 6115, SpvCapabilitySplitBarrierINTEL = 6141, SpvCapabilityArithmeticFenceEXT = 6144, + SpvCapabilityFPGAClusterAttributesV2ALTERA = 6150, SpvCapabilityFPGAClusterAttributesV2INTEL = 6150, SpvCapabilityFPGAKernelAttributesv2INTEL = 6161, + SpvCapabilityTaskSequenceALTERA = 6162, SpvCapabilityTaskSequenceINTEL = 6162, SpvCapabilityFPMaxErrorINTEL = 6169, + SpvCapabilityFPGALatencyControlALTERA = 6171, SpvCapabilityFPGALatencyControlINTEL = 6171, + SpvCapabilityFPGAArgumentInterfacesALTERA = 6174, SpvCapabilityFPGAArgumentInterfacesINTEL = 6174, SpvCapabilityGlobalVariableHostAccessINTEL = 6187, + SpvCapabilityGlobalVariableFPGADecorationsALTERA = 6189, SpvCapabilityGlobalVariableFPGADecorationsINTEL = 6189, SpvCapabilitySubgroupBufferPrefetchINTEL = 6220, SpvCapabilitySubgroup2DBlockIOINTEL = 6228, @@ -1294,6 +1402,10 @@ typedef enum SpvCapability_ { SpvCapabilityCacheControlsINTEL = 6441, SpvCapabilityRegisterLimitsINTEL = 6460, SpvCapabilityBindlessImagesINTEL = 6528, + SpvCapabilityDotProductFloat16AccFloat32VALVE = 6912, + SpvCapabilityDotProductFloat16AccFloat16VALVE = 6913, + SpvCapabilityDotProductBFloat16AccVALVE = 6914, + SpvCapabilityDotProductFloat8AccFloat32VALVE = 6915, SpvCapabilityMax = 0x7fffffff, } SpvCapability; @@ -1489,7 +1601,9 @@ typedef enum SpvTensorOperandsMask_ { } SpvTensorOperandsMask; typedef enum SpvInitializationModeQualifier_ { + SpvInitializationModeQualifierInitOnDeviceReprogramALTERA = 0, SpvInitializationModeQualifierInitOnDeviceReprogramINTEL = 0, + SpvInitializationModeQualifierInitOnDeviceResetALTERA = 1, SpvInitializationModeQualifierInitOnDeviceResetINTEL = 1, SpvInitializationModeQualifierMax = 0x7fffffff, } SpvInitializationModeQualifier; @@ -2049,6 +2163,16 @@ typedef enum SpvOp_ { SpvOpSpecConstantStringAMDX = 5104, SpvOpGroupNonUniformQuadAllKHR = 5110, SpvOpGroupNonUniformQuadAnyKHR = 5111, + SpvOpTypeBufferEXT = 5115, + SpvOpBufferPointerEXT = 5119, + SpvOpAbortKHR = 5121, + SpvOpUntypedImageTexelPointerEXT = 5126, + SpvOpMemberDecorateIdEXT = 5127, + SpvOpConstantSizeOfEXT = 5129, + SpvOpConstantDataKHR = 5147, + SpvOpSpecConstantDataKHR = 5148, + SpvOpPoisonKHR = 5158, + SpvOpFreezeKHR = 5159, SpvOpHitObjectRecordHitMotionNV = 5249, SpvOpHitObjectRecordHitWithIndexMotionNV = 5250, SpvOpHitObjectRecordMissMotionNV = 5251, @@ -2084,6 +2208,7 @@ typedef enum SpvOp_ { SpvOpTypeHitObjectNV = 5281, SpvOpImageSampleFootprintNV = 5283, SpvOpTypeCooperativeVectorNV = 5288, + SpvOpTypeVectorIdEXT = 5288, SpvOpCooperativeVectorMatrixMulNV = 5289, SpvOpCooperativeVectorOuterProductAccumulateNV = 5290, SpvOpCooperativeVectorReduceSumAccumulateNV = 5291, @@ -2091,12 +2216,43 @@ typedef enum SpvOp_ { SpvOpCooperativeMatrixConvertNV = 5293, SpvOpEmitMeshTasksEXT = 5294, SpvOpSetMeshOutputsEXT = 5295, + SpvOpGroupNonUniformPartitionEXT = 5296, SpvOpGroupNonUniformPartitionNV = 5296, SpvOpWritePackedPrimitiveIndices4x8NV = 5299, SpvOpFetchMicroTriangleVertexPositionNV = 5300, SpvOpFetchMicroTriangleVertexBarycentricNV = 5301, SpvOpCooperativeVectorLoadNV = 5302, SpvOpCooperativeVectorStoreNV = 5303, + SpvOpHitObjectRecordFromQueryEXT = 5304, + SpvOpHitObjectRecordMissEXT = 5305, + SpvOpHitObjectRecordMissMotionEXT = 5306, + SpvOpHitObjectGetIntersectionTriangleVertexPositionsEXT = 5307, + SpvOpHitObjectGetRayFlagsEXT = 5308, + SpvOpHitObjectSetShaderBindingTableRecordIndexEXT = 5309, + SpvOpHitObjectReorderExecuteShaderEXT = 5310, + SpvOpHitObjectTraceReorderExecuteEXT = 5311, + SpvOpHitObjectTraceMotionReorderExecuteEXT = 5312, + SpvOpTypeHitObjectEXT = 5313, + SpvOpReorderThreadWithHintEXT = 5314, + SpvOpReorderThreadWithHitObjectEXT = 5315, + SpvOpHitObjectTraceRayEXT = 5316, + SpvOpHitObjectTraceRayMotionEXT = 5317, + SpvOpHitObjectRecordEmptyEXT = 5318, + SpvOpHitObjectExecuteShaderEXT = 5319, + SpvOpHitObjectGetCurrentTimeEXT = 5320, + SpvOpHitObjectGetAttributesEXT = 5321, + SpvOpHitObjectGetHitKindEXT = 5322, + SpvOpHitObjectGetPrimitiveIndexEXT = 5323, + SpvOpHitObjectGetGeometryIndexEXT = 5324, + SpvOpHitObjectGetInstanceIdEXT = 5325, + SpvOpHitObjectGetInstanceCustomIndexEXT = 5326, + SpvOpHitObjectGetObjectRayOriginEXT = 5327, + SpvOpHitObjectGetObjectRayDirectionEXT = 5328, + SpvOpHitObjectGetWorldRayDirectionEXT = 5329, + SpvOpHitObjectGetWorldRayOriginEXT = 5330, + SpvOpHitObjectGetObjectToWorldEXT = 5331, + SpvOpHitObjectGetWorldToObjectEXT = 5332, + SpvOpHitObjectGetRayTMaxEXT = 5333, SpvOpReportIntersectionKHR = 5334, SpvOpReportIntersectionNV = 5334, SpvOpIgnoreIntersectionNV = 5335, @@ -2111,6 +2267,12 @@ typedef enum SpvOp_ { SpvOpRayQueryGetClusterIdNV = 5345, SpvOpRayQueryGetIntersectionClusterIdNV = 5345, SpvOpHitObjectGetClusterIdNV = 5346, + SpvOpHitObjectGetRayTMinEXT = 5347, + SpvOpHitObjectGetShaderBindingTableRecordIndexEXT = 5348, + SpvOpHitObjectGetShaderRecordBufferHandleEXT = 5349, + SpvOpHitObjectIsEmptyEXT = 5350, + SpvOpHitObjectIsHitEXT = 5351, + SpvOpHitObjectIsMissEXT = 5352, SpvOpTypeCooperativeMatrixNV = 5358, SpvOpCooperativeMatrixLoadNV = 5359, SpvOpCooperativeMatrixStoreNV = 5360, @@ -2317,23 +2479,41 @@ typedef enum SpvOp_ { SpvOpVariableLengthArrayINTEL = 5818, SpvOpSaveMemoryINTEL = 5819, SpvOpRestoreMemoryINTEL = 5820, + SpvOpArbitraryFloatSinCosPiALTERA = 5840, SpvOpArbitraryFloatSinCosPiINTEL = 5840, + SpvOpArbitraryFloatCastALTERA = 5841, SpvOpArbitraryFloatCastINTEL = 5841, + SpvOpArbitraryFloatCastFromIntALTERA = 5842, SpvOpArbitraryFloatCastFromIntINTEL = 5842, + SpvOpArbitraryFloatCastToIntALTERA = 5843, SpvOpArbitraryFloatCastToIntINTEL = 5843, + SpvOpArbitraryFloatAddALTERA = 5846, SpvOpArbitraryFloatAddINTEL = 5846, + SpvOpArbitraryFloatSubALTERA = 5847, SpvOpArbitraryFloatSubINTEL = 5847, + SpvOpArbitraryFloatMulALTERA = 5848, SpvOpArbitraryFloatMulINTEL = 5848, + SpvOpArbitraryFloatDivALTERA = 5849, SpvOpArbitraryFloatDivINTEL = 5849, + SpvOpArbitraryFloatGTALTERA = 5850, SpvOpArbitraryFloatGTINTEL = 5850, + SpvOpArbitraryFloatGEALTERA = 5851, SpvOpArbitraryFloatGEINTEL = 5851, + SpvOpArbitraryFloatLTALTERA = 5852, SpvOpArbitraryFloatLTINTEL = 5852, + SpvOpArbitraryFloatLEALTERA = 5853, SpvOpArbitraryFloatLEINTEL = 5853, + SpvOpArbitraryFloatEQALTERA = 5854, SpvOpArbitraryFloatEQINTEL = 5854, + SpvOpArbitraryFloatRecipALTERA = 5855, SpvOpArbitraryFloatRecipINTEL = 5855, + SpvOpArbitraryFloatRSqrtALTERA = 5856, SpvOpArbitraryFloatRSqrtINTEL = 5856, + SpvOpArbitraryFloatCbrtALTERA = 5857, SpvOpArbitraryFloatCbrtINTEL = 5857, + SpvOpArbitraryFloatHypotALTERA = 5858, SpvOpArbitraryFloatHypotINTEL = 5858, + SpvOpArbitraryFloatSqrtALTERA = 5859, SpvOpArbitraryFloatSqrtINTEL = 5859, SpvOpArbitraryFloatLogINTEL = 5860, SpvOpArbitraryFloatLog2INTEL = 5861, @@ -2362,21 +2542,37 @@ typedef enum SpvOp_ { SpvOpAliasDomainDeclINTEL = 5911, SpvOpAliasScopeDeclINTEL = 5912, SpvOpAliasScopeListDeclINTEL = 5913, + SpvOpFixedSqrtALTERA = 5923, SpvOpFixedSqrtINTEL = 5923, + SpvOpFixedRecipALTERA = 5924, SpvOpFixedRecipINTEL = 5924, + SpvOpFixedRsqrtALTERA = 5925, SpvOpFixedRsqrtINTEL = 5925, + SpvOpFixedSinALTERA = 5926, SpvOpFixedSinINTEL = 5926, + SpvOpFixedCosALTERA = 5927, SpvOpFixedCosINTEL = 5927, + SpvOpFixedSinCosALTERA = 5928, SpvOpFixedSinCosINTEL = 5928, + SpvOpFixedSinPiALTERA = 5929, SpvOpFixedSinPiINTEL = 5929, + SpvOpFixedCosPiALTERA = 5930, SpvOpFixedCosPiINTEL = 5930, + SpvOpFixedSinCosPiALTERA = 5931, SpvOpFixedSinCosPiINTEL = 5931, + SpvOpFixedLogALTERA = 5932, SpvOpFixedLogINTEL = 5932, + SpvOpFixedExpALTERA = 5933, SpvOpFixedExpINTEL = 5933, + SpvOpPtrCastToCrossWorkgroupALTERA = 5934, SpvOpPtrCastToCrossWorkgroupINTEL = 5934, + SpvOpCrossWorkgroupCastToPtrALTERA = 5938, SpvOpCrossWorkgroupCastToPtrINTEL = 5938, + SpvOpReadPipeBlockingALTERA = 5946, SpvOpReadPipeBlockingINTEL = 5946, + SpvOpWritePipeBlockingALTERA = 5947, SpvOpWritePipeBlockingINTEL = 5947, + SpvOpFPGARegALTERA = 5949, SpvOpFPGARegINTEL = 5949, SpvOpRayQueryGetRayTMinKHR = 6016, SpvOpRayQueryGetRayFlagsKHR = 6017, @@ -2406,10 +2602,15 @@ typedef enum SpvOp_ { SpvOpControlBarrierArriveINTEL = 6142, SpvOpControlBarrierWaitINTEL = 6143, SpvOpArithmeticFenceEXT = 6145, + SpvOpTaskSequenceCreateALTERA = 6163, SpvOpTaskSequenceCreateINTEL = 6163, + SpvOpTaskSequenceAsyncALTERA = 6164, SpvOpTaskSequenceAsyncINTEL = 6164, + SpvOpTaskSequenceGetALTERA = 6165, SpvOpTaskSequenceGetINTEL = 6165, + SpvOpTaskSequenceReleaseALTERA = 6166, SpvOpTaskSequenceReleaseINTEL = 6166, + SpvOpTypeTaskSequenceALTERA = 6199, SpvOpTypeTaskSequenceINTEL = 6199, SpvOpSubgroupBlockPrefetchINTEL = 6221, SpvOpSubgroup2DBlockLoadINTEL = 6231, @@ -2441,6 +2642,9 @@ typedef enum SpvOp_ { SpvOpConvertHandleToImageINTEL = 6529, SpvOpConvertHandleToSamplerINTEL = 6530, SpvOpConvertHandleToSampledImageINTEL = 6531, + SpvOpFDot2MixAcc32VALVE = 6916, + SpvOpFDot2MixAcc16VALVE = 6917, + SpvOpFDot4MixAcc32VALVE = 6918, SpvOpMax = 0x7fffffff, } SpvOp; @@ -2888,6 +3092,16 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpSpecConstantStringAMDX: *hasResult = true; *hasResultType = false; break; case SpvOpGroupNonUniformQuadAllKHR: *hasResult = true; *hasResultType = true; break; case SpvOpGroupNonUniformQuadAnyKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpTypeBufferEXT: *hasResult = true; *hasResultType = false; break; + case SpvOpBufferPointerEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpAbortKHR: *hasResult = false; *hasResultType = false; break; + case SpvOpUntypedImageTexelPointerEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpMemberDecorateIdEXT: *hasResult = false; *hasResultType = false; break; + case SpvOpConstantSizeOfEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpConstantDataKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpSpecConstantDataKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpPoisonKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpFreezeKHR: *hasResult = true; *hasResultType = true; break; case SpvOpHitObjectRecordHitMotionNV: *hasResult = false; *hasResultType = false; break; case SpvOpHitObjectRecordHitWithIndexMotionNV: *hasResult = false; *hasResultType = false; break; case SpvOpHitObjectRecordMissMotionNV: *hasResult = false; *hasResultType = false; break; @@ -2922,7 +3136,7 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpReorderThreadWithHintNV: *hasResult = false; *hasResultType = false; break; case SpvOpTypeHitObjectNV: *hasResult = true; *hasResultType = false; break; case SpvOpImageSampleFootprintNV: *hasResult = true; *hasResultType = true; break; - case SpvOpTypeCooperativeVectorNV: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeVectorIdEXT: *hasResult = true; *hasResultType = false; break; case SpvOpCooperativeVectorMatrixMulNV: *hasResult = true; *hasResultType = true; break; case SpvOpCooperativeVectorOuterProductAccumulateNV: *hasResult = false; *hasResultType = false; break; case SpvOpCooperativeVectorReduceSumAccumulateNV: *hasResult = false; *hasResultType = false; break; @@ -2930,12 +3144,42 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpCooperativeMatrixConvertNV: *hasResult = true; *hasResultType = true; break; case SpvOpEmitMeshTasksEXT: *hasResult = false; *hasResultType = false; break; case SpvOpSetMeshOutputsEXT: *hasResult = false; *hasResultType = false; break; - case SpvOpGroupNonUniformPartitionNV: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformPartitionEXT: *hasResult = true; *hasResultType = true; break; case SpvOpWritePackedPrimitiveIndices4x8NV: *hasResult = false; *hasResultType = false; break; case SpvOpFetchMicroTriangleVertexPositionNV: *hasResult = true; *hasResultType = true; break; case SpvOpFetchMicroTriangleVertexBarycentricNV: *hasResult = true; *hasResultType = true; break; case SpvOpCooperativeVectorLoadNV: *hasResult = true; *hasResultType = true; break; case SpvOpCooperativeVectorStoreNV: *hasResult = false; *hasResultType = false; break; + case SpvOpHitObjectRecordFromQueryEXT: *hasResult = false; *hasResultType = false; break; + case SpvOpHitObjectRecordMissEXT: *hasResult = false; *hasResultType = false; break; + case SpvOpHitObjectRecordMissMotionEXT: *hasResult = false; *hasResultType = false; break; + case SpvOpHitObjectGetIntersectionTriangleVertexPositionsEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectGetRayFlagsEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectSetShaderBindingTableRecordIndexEXT: *hasResult = false; *hasResultType = false; break; + case SpvOpHitObjectReorderExecuteShaderEXT: *hasResult = false; *hasResultType = false; break; + case SpvOpHitObjectTraceReorderExecuteEXT: *hasResult = false; *hasResultType = false; break; + case SpvOpHitObjectTraceMotionReorderExecuteEXT: *hasResult = false; *hasResultType = false; break; + case SpvOpTypeHitObjectEXT: *hasResult = true; *hasResultType = false; break; + case SpvOpReorderThreadWithHintEXT: *hasResult = false; *hasResultType = false; break; + case SpvOpReorderThreadWithHitObjectEXT: *hasResult = false; *hasResultType = false; break; + case SpvOpHitObjectTraceRayEXT: *hasResult = false; *hasResultType = false; break; + case SpvOpHitObjectTraceRayMotionEXT: *hasResult = false; *hasResultType = false; break; + case SpvOpHitObjectRecordEmptyEXT: *hasResult = false; *hasResultType = false; break; + case SpvOpHitObjectExecuteShaderEXT: *hasResult = false; *hasResultType = false; break; + case SpvOpHitObjectGetCurrentTimeEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectGetAttributesEXT: *hasResult = false; *hasResultType = false; break; + case SpvOpHitObjectGetHitKindEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectGetPrimitiveIndexEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectGetGeometryIndexEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectGetInstanceIdEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectGetInstanceCustomIndexEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectGetObjectRayOriginEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectGetObjectRayDirectionEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectGetWorldRayDirectionEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectGetWorldRayOriginEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectGetObjectToWorldEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectGetWorldToObjectEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectGetRayTMaxEXT: *hasResult = true; *hasResultType = true; break; case SpvOpReportIntersectionKHR: *hasResult = true; *hasResultType = true; break; case SpvOpIgnoreIntersectionNV: *hasResult = false; *hasResultType = false; break; case SpvOpTerminateRayNV: *hasResult = false; *hasResultType = false; break; @@ -2947,6 +3191,12 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpExecuteCallableNV: *hasResult = false; *hasResultType = false; break; case SpvOpRayQueryGetIntersectionClusterIdNV: *hasResult = true; *hasResultType = true; break; case SpvOpHitObjectGetClusterIdNV: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectGetRayTMinEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectGetShaderBindingTableRecordIndexEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectGetShaderRecordBufferHandleEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectIsEmptyEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectIsHitEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpHitObjectIsMissEXT: *hasResult = true; *hasResultType = true; break; case SpvOpTypeCooperativeMatrixNV: *hasResult = true; *hasResultType = false; break; case SpvOpCooperativeMatrixLoadNV: *hasResult = true; *hasResultType = true; break; case SpvOpCooperativeMatrixStoreNV: *hasResult = false; *hasResultType = false; break; @@ -3150,24 +3400,24 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpVariableLengthArrayINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpSaveMemoryINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpRestoreMemoryINTEL: *hasResult = false; *hasResultType = false; break; - case SpvOpArbitraryFloatSinCosPiINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpArbitraryFloatCastINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpArbitraryFloatCastFromIntINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpArbitraryFloatCastToIntINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpArbitraryFloatAddINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpArbitraryFloatSubINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpArbitraryFloatMulINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpArbitraryFloatDivINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpArbitraryFloatGTINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpArbitraryFloatGEINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpArbitraryFloatLTINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpArbitraryFloatLEINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpArbitraryFloatEQINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpArbitraryFloatRecipINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpArbitraryFloatRSqrtINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpArbitraryFloatCbrtINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpArbitraryFloatHypotINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpArbitraryFloatSqrtINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpArbitraryFloatSinCosPiALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpArbitraryFloatCastALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpArbitraryFloatCastFromIntALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpArbitraryFloatCastToIntALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpArbitraryFloatAddALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpArbitraryFloatSubALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpArbitraryFloatMulALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpArbitraryFloatDivALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpArbitraryFloatGTALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpArbitraryFloatGEALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpArbitraryFloatLTALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpArbitraryFloatLEALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpArbitraryFloatEQALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpArbitraryFloatRecipALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpArbitraryFloatRSqrtALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpArbitraryFloatCbrtALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpArbitraryFloatHypotALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpArbitraryFloatSqrtALTERA: *hasResult = true; *hasResultType = true; break; case SpvOpArbitraryFloatLogINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpArbitraryFloatLog2INTEL: *hasResult = true; *hasResultType = true; break; case SpvOpArbitraryFloatLog10INTEL: *hasResult = true; *hasResultType = true; break; @@ -3195,22 +3445,22 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpAliasDomainDeclINTEL: *hasResult = true; *hasResultType = false; break; case SpvOpAliasScopeDeclINTEL: *hasResult = true; *hasResultType = false; break; case SpvOpAliasScopeListDeclINTEL: *hasResult = true; *hasResultType = false; break; - case SpvOpFixedSqrtINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpFixedRecipINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpFixedRsqrtINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpFixedSinINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpFixedCosINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpFixedSinCosINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpFixedSinPiINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpFixedCosPiINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpFixedSinCosPiINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpFixedLogINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpFixedExpINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpPtrCastToCrossWorkgroupINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpCrossWorkgroupCastToPtrINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpReadPipeBlockingINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpWritePipeBlockingINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpFPGARegINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpFixedSqrtALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpFixedRecipALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpFixedRsqrtALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpFixedSinALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpFixedCosALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpFixedSinCosALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpFixedSinPiALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpFixedCosPiALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpFixedSinCosPiALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpFixedLogALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpFixedExpALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpPtrCastToCrossWorkgroupALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpCrossWorkgroupCastToPtrALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpReadPipeBlockingALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpWritePipeBlockingALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpFPGARegALTERA: *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; @@ -3239,11 +3489,11 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpControlBarrierArriveINTEL: *hasResult = false; *hasResultType = false; break; case SpvOpControlBarrierWaitINTEL: *hasResult = false; *hasResultType = false; break; case SpvOpArithmeticFenceEXT: *hasResult = true; *hasResultType = true; break; - case SpvOpTaskSequenceCreateINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpTaskSequenceAsyncINTEL: *hasResult = false; *hasResultType = false; break; - case SpvOpTaskSequenceGetINTEL: *hasResult = true; *hasResultType = true; break; - case SpvOpTaskSequenceReleaseINTEL: *hasResult = false; *hasResultType = false; break; - case SpvOpTypeTaskSequenceINTEL: *hasResult = true; *hasResultType = false; break; + case SpvOpTaskSequenceCreateALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpTaskSequenceAsyncALTERA: *hasResult = false; *hasResultType = false; break; + case SpvOpTaskSequenceGetALTERA: *hasResult = true; *hasResultType = true; break; + case SpvOpTaskSequenceReleaseALTERA: *hasResult = false; *hasResultType = false; break; + case SpvOpTypeTaskSequenceALTERA: *hasResult = true; *hasResultType = false; break; case SpvOpSubgroupBlockPrefetchINTEL: *hasResult = false; *hasResultType = false; break; case SpvOpSubgroup2DBlockLoadINTEL: *hasResult = false; *hasResultType = false; break; case SpvOpSubgroup2DBlockLoadTransformINTEL: *hasResult = false; *hasResultType = false; break; @@ -3274,6 +3524,9 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy case SpvOpConvertHandleToImageINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpConvertHandleToSamplerINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpConvertHandleToSampledImageINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpFDot2MixAcc32VALVE: *hasResult = true; *hasResultType = true; break; + case SpvOpFDot2MixAcc16VALVE: *hasResult = true; *hasResultType = true; break; + case SpvOpFDot4MixAcc32VALVE: *hasResult = true; *hasResultType = true; break; } } inline const char* SpvSourceLanguageToString(SpvSourceLanguage value) { @@ -3408,6 +3661,7 @@ inline const char* SpvExecutionModeToString(SpvExecutionMode value) { case SpvExecutionModeQuadDerivativesKHR: return "QuadDerivativesKHR"; case SpvExecutionModeRequireFullQuadsKHR: return "RequireFullQuadsKHR"; case SpvExecutionModeSharesInputWithAMDX: return "SharesInputWithAMDX"; + case SpvExecutionModeArithmeticPoisonKHR: return "ArithmeticPoisonKHR"; case SpvExecutionModeOutputLinesEXT: return "OutputLinesEXT"; case SpvExecutionModeOutputPrimitivesEXT: return "OutputPrimitivesEXT"; case SpvExecutionModeDerivativeGroupQuadsKHR: return "DerivativeGroupQuadsKHR"; @@ -3419,6 +3673,7 @@ inline const char* SpvExecutionModeToString(SpvExecutionMode value) { case SpvExecutionModeSampleInterlockUnorderedEXT: return "SampleInterlockUnorderedEXT"; case SpvExecutionModeShadingRateInterlockOrderedEXT: return "ShadingRateInterlockOrderedEXT"; case SpvExecutionModeShadingRateInterlockUnorderedEXT: return "ShadingRateInterlockUnorderedEXT"; + case SpvExecutionModeShader64BitIndexingEXT: return "Shader64BitIndexingEXT"; case SpvExecutionModeSharedLocalMemorySizeINTEL: return "SharedLocalMemorySizeINTEL"; case SpvExecutionModeRoundingModeRTPINTEL: return "RoundingModeRTPINTEL"; case SpvExecutionModeRoundingModeRTNINTEL: return "RoundingModeRTNINTEL"; @@ -3468,9 +3723,10 @@ inline const char* SpvStorageClassToString(SpvStorageClass value) { case SpvStorageClassPhysicalStorageBuffer: return "PhysicalStorageBuffer"; case SpvStorageClassHitObjectAttributeNV: return "HitObjectAttributeNV"; case SpvStorageClassTaskPayloadWorkgroupEXT: return "TaskPayloadWorkgroupEXT"; + case SpvStorageClassHitObjectAttributeEXT: return "HitObjectAttributeEXT"; case SpvStorageClassCodeSectionINTEL: return "CodeSectionINTEL"; - case SpvStorageClassDeviceOnlyINTEL: return "DeviceOnlyINTEL"; - case SpvStorageClassHostOnlyINTEL: return "HostOnlyINTEL"; + case SpvStorageClassDeviceOnlyALTERA: return "DeviceOnlyALTERA"; + case SpvStorageClassHostOnlyALTERA: return "HostOnlyALTERA"; default: return "Unknown"; } } @@ -3652,7 +3908,7 @@ inline const char* SpvFunctionParameterAttributeToString(SpvFunctionParameterAtt case SpvFunctionParameterAttributeNoCapture: return "NoCapture"; case SpvFunctionParameterAttributeNoWrite: return "NoWrite"; case SpvFunctionParameterAttributeNoReadWrite: return "NoReadWrite"; - case SpvFunctionParameterAttributeRuntimeAlignedINTEL: return "RuntimeAlignedINTEL"; + case SpvFunctionParameterAttributeRuntimeAlignedALTERA: return "RuntimeAlignedALTERA"; default: return "Unknown"; } } @@ -3721,6 +3977,9 @@ inline const char* SpvDecorationToString(SpvDecoration value) { case SpvDecorationPayloadNodeSparseArrayAMDX: return "PayloadNodeSparseArrayAMDX"; case SpvDecorationPayloadNodeArraySizeAMDX: return "PayloadNodeArraySizeAMDX"; case SpvDecorationPayloadDispatchIndirectAMDX: return "PayloadDispatchIndirectAMDX"; + case SpvDecorationArrayStrideIdEXT: return "ArrayStrideIdEXT"; + case SpvDecorationOffsetIdEXT: return "OffsetIdEXT"; + case SpvDecorationUTFEncodedKHR: return "UTFEncodedKHR"; case SpvDecorationOverrideCoverageNV: return "OverrideCoverageNV"; case SpvDecorationPassthroughNV: return "PassthroughNV"; case SpvDecorationViewportRelativeNV: return "ViewportRelativeNV"; @@ -3732,7 +3991,10 @@ inline const char* SpvDecorationToString(SpvDecoration value) { case SpvDecorationNonUniform: return "NonUniform"; case SpvDecorationRestrictPointer: return "RestrictPointer"; case SpvDecorationAliasedPointer: return "AliasedPointer"; + case SpvDecorationMemberOffsetNV: return "MemberOffsetNV"; case SpvDecorationHitObjectShaderRecordBufferNV: return "HitObjectShaderRecordBufferNV"; + case SpvDecorationHitObjectShaderRecordBufferEXT: return "HitObjectShaderRecordBufferEXT"; + case SpvDecorationBankNV: return "BankNV"; case SpvDecorationBindlessSamplerNV: return "BindlessSamplerNV"; case SpvDecorationBindlessImageNV: return "BindlessImageNV"; case SpvDecorationBoundSamplerNV: return "BoundSamplerNV"; @@ -3751,55 +4013,55 @@ inline const char* SpvDecorationToString(SpvDecoration value) { case SpvDecorationUserTypeGOOGLE: return "UserTypeGOOGLE"; case SpvDecorationFunctionRoundingModeINTEL: return "FunctionRoundingModeINTEL"; case SpvDecorationFunctionDenormModeINTEL: return "FunctionDenormModeINTEL"; - case SpvDecorationRegisterINTEL: return "RegisterINTEL"; - case SpvDecorationMemoryINTEL: return "MemoryINTEL"; - case SpvDecorationNumbanksINTEL: return "NumbanksINTEL"; - case SpvDecorationBankwidthINTEL: return "BankwidthINTEL"; - case SpvDecorationMaxPrivateCopiesINTEL: return "MaxPrivateCopiesINTEL"; - case SpvDecorationSinglepumpINTEL: return "SinglepumpINTEL"; - case SpvDecorationDoublepumpINTEL: return "DoublepumpINTEL"; - case SpvDecorationMaxReplicatesINTEL: return "MaxReplicatesINTEL"; - case SpvDecorationSimpleDualPortINTEL: return "SimpleDualPortINTEL"; - case SpvDecorationMergeINTEL: return "MergeINTEL"; - case SpvDecorationBankBitsINTEL: return "BankBitsINTEL"; - case SpvDecorationForcePow2DepthINTEL: return "ForcePow2DepthINTEL"; - case SpvDecorationStridesizeINTEL: return "StridesizeINTEL"; - case SpvDecorationWordsizeINTEL: return "WordsizeINTEL"; - case SpvDecorationTrueDualPortINTEL: return "TrueDualPortINTEL"; - case SpvDecorationBurstCoalesceINTEL: return "BurstCoalesceINTEL"; - case SpvDecorationCacheSizeINTEL: return "CacheSizeINTEL"; - case SpvDecorationDontStaticallyCoalesceINTEL: return "DontStaticallyCoalesceINTEL"; - case SpvDecorationPrefetchINTEL: return "PrefetchINTEL"; - case SpvDecorationStallEnableINTEL: return "StallEnableINTEL"; - case SpvDecorationFuseLoopsInFunctionINTEL: return "FuseLoopsInFunctionINTEL"; - case SpvDecorationMathOpDSPModeINTEL: return "MathOpDSPModeINTEL"; + case SpvDecorationRegisterALTERA: return "RegisterALTERA"; + case SpvDecorationMemoryALTERA: return "MemoryALTERA"; + case SpvDecorationNumbanksALTERA: return "NumbanksALTERA"; + case SpvDecorationBankwidthALTERA: return "BankwidthALTERA"; + case SpvDecorationMaxPrivateCopiesALTERA: return "MaxPrivateCopiesALTERA"; + case SpvDecorationSinglepumpALTERA: return "SinglepumpALTERA"; + case SpvDecorationDoublepumpALTERA: return "DoublepumpALTERA"; + case SpvDecorationMaxReplicatesALTERA: return "MaxReplicatesALTERA"; + case SpvDecorationSimpleDualPortALTERA: return "SimpleDualPortALTERA"; + case SpvDecorationMergeALTERA: return "MergeALTERA"; + case SpvDecorationBankBitsALTERA: return "BankBitsALTERA"; + case SpvDecorationForcePow2DepthALTERA: return "ForcePow2DepthALTERA"; + case SpvDecorationStridesizeALTERA: return "StridesizeALTERA"; + case SpvDecorationWordsizeALTERA: return "WordsizeALTERA"; + case SpvDecorationTrueDualPortALTERA: return "TrueDualPortALTERA"; + case SpvDecorationBurstCoalesceALTERA: return "BurstCoalesceALTERA"; + case SpvDecorationCacheSizeALTERA: return "CacheSizeALTERA"; + case SpvDecorationDontStaticallyCoalesceALTERA: return "DontStaticallyCoalesceALTERA"; + case SpvDecorationPrefetchALTERA: return "PrefetchALTERA"; + case SpvDecorationStallEnableALTERA: return "StallEnableALTERA"; + case SpvDecorationFuseLoopsInFunctionALTERA: return "FuseLoopsInFunctionALTERA"; + case SpvDecorationMathOpDSPModeALTERA: return "MathOpDSPModeALTERA"; case SpvDecorationAliasScopeINTEL: return "AliasScopeINTEL"; case SpvDecorationNoAliasINTEL: return "NoAliasINTEL"; - case SpvDecorationInitiationIntervalINTEL: return "InitiationIntervalINTEL"; - case SpvDecorationMaxConcurrencyINTEL: return "MaxConcurrencyINTEL"; - case SpvDecorationPipelineEnableINTEL: return "PipelineEnableINTEL"; - case SpvDecorationBufferLocationINTEL: return "BufferLocationINTEL"; - case SpvDecorationIOPipeStorageINTEL: return "IOPipeStorageINTEL"; + case SpvDecorationInitiationIntervalALTERA: return "InitiationIntervalALTERA"; + case SpvDecorationMaxConcurrencyALTERA: return "MaxConcurrencyALTERA"; + case SpvDecorationPipelineEnableALTERA: return "PipelineEnableALTERA"; + case SpvDecorationBufferLocationALTERA: return "BufferLocationALTERA"; + case SpvDecorationIOPipeStorageALTERA: return "IOPipeStorageALTERA"; case SpvDecorationFunctionFloatingPointModeINTEL: return "FunctionFloatingPointModeINTEL"; case SpvDecorationSingleElementVectorINTEL: return "SingleElementVectorINTEL"; case SpvDecorationVectorComputeCallableFunctionINTEL: return "VectorComputeCallableFunctionINTEL"; case SpvDecorationMediaBlockIOINTEL: return "MediaBlockIOINTEL"; - case SpvDecorationStallFreeINTEL: return "StallFreeINTEL"; + case SpvDecorationStallFreeALTERA: return "StallFreeALTERA"; case SpvDecorationFPMaxErrorDecorationINTEL: return "FPMaxErrorDecorationINTEL"; - case SpvDecorationLatencyControlLabelINTEL: return "LatencyControlLabelINTEL"; - case SpvDecorationLatencyControlConstraintINTEL: return "LatencyControlConstraintINTEL"; - case SpvDecorationConduitKernelArgumentINTEL: return "ConduitKernelArgumentINTEL"; - case SpvDecorationRegisterMapKernelArgumentINTEL: return "RegisterMapKernelArgumentINTEL"; - case SpvDecorationMMHostInterfaceAddressWidthINTEL: return "MMHostInterfaceAddressWidthINTEL"; - case SpvDecorationMMHostInterfaceDataWidthINTEL: return "MMHostInterfaceDataWidthINTEL"; - case SpvDecorationMMHostInterfaceLatencyINTEL: return "MMHostInterfaceLatencyINTEL"; - case SpvDecorationMMHostInterfaceReadWriteModeINTEL: return "MMHostInterfaceReadWriteModeINTEL"; - case SpvDecorationMMHostInterfaceMaxBurstINTEL: return "MMHostInterfaceMaxBurstINTEL"; - case SpvDecorationMMHostInterfaceWaitRequestINTEL: return "MMHostInterfaceWaitRequestINTEL"; - case SpvDecorationStableKernelArgumentINTEL: return "StableKernelArgumentINTEL"; + case SpvDecorationLatencyControlLabelALTERA: return "LatencyControlLabelALTERA"; + case SpvDecorationLatencyControlConstraintALTERA: return "LatencyControlConstraintALTERA"; + case SpvDecorationConduitKernelArgumentALTERA: return "ConduitKernelArgumentALTERA"; + case SpvDecorationRegisterMapKernelArgumentALTERA: return "RegisterMapKernelArgumentALTERA"; + case SpvDecorationMMHostInterfaceAddressWidthALTERA: return "MMHostInterfaceAddressWidthALTERA"; + case SpvDecorationMMHostInterfaceDataWidthALTERA: return "MMHostInterfaceDataWidthALTERA"; + case SpvDecorationMMHostInterfaceLatencyALTERA: return "MMHostInterfaceLatencyALTERA"; + case SpvDecorationMMHostInterfaceReadWriteModeALTERA: return "MMHostInterfaceReadWriteModeALTERA"; + case SpvDecorationMMHostInterfaceMaxBurstALTERA: return "MMHostInterfaceMaxBurstALTERA"; + case SpvDecorationMMHostInterfaceWaitRequestALTERA: return "MMHostInterfaceWaitRequestALTERA"; + case SpvDecorationStableKernelArgumentALTERA: return "StableKernelArgumentALTERA"; case SpvDecorationHostAccessINTEL: return "HostAccessINTEL"; - case SpvDecorationInitModeINTEL: return "InitModeINTEL"; - case SpvDecorationImplementInRegisterMapINTEL: return "ImplementInRegisterMapINTEL"; + case SpvDecorationInitModeALTERA: return "InitModeALTERA"; + case SpvDecorationImplementInRegisterMapALTERA: return "ImplementInRegisterMapALTERA"; case SpvDecorationConditionalINTEL: return "ConditionalINTEL"; case SpvDecorationCacheControlLoadINTEL: return "CacheControlLoadINTEL"; case SpvDecorationCacheControlStoreINTEL: return "CacheControlStoreINTEL"; @@ -3880,6 +4142,8 @@ inline const char* SpvBuiltInToString(SpvBuiltIn value) { case SpvBuiltInFragStencilRefEXT: return "FragStencilRefEXT"; case SpvBuiltInRemainingRecursionLevelsAMDX: return "RemainingRecursionLevelsAMDX"; case SpvBuiltInShaderIndexAMDX: return "ShaderIndexAMDX"; + case SpvBuiltInSamplerHeapEXT: return "SamplerHeapEXT"; + case SpvBuiltInResourceHeapEXT: return "ResourceHeapEXT"; case SpvBuiltInViewportMaskNV: return "ViewportMaskNV"; case SpvBuiltInSecondaryPositionNV: return "SecondaryPositionNV"; case SpvBuiltInSecondaryViewportMaskNV: return "SecondaryViewportMaskNV"; @@ -3958,9 +4222,9 @@ inline const char* SpvGroupOperationToString(SpvGroupOperation value) { case SpvGroupOperationInclusiveScan: return "InclusiveScan"; case SpvGroupOperationExclusiveScan: return "ExclusiveScan"; case SpvGroupOperationClusteredReduce: return "ClusteredReduce"; - case SpvGroupOperationPartitionedReduceNV: return "PartitionedReduceNV"; - case SpvGroupOperationPartitionedInclusiveScanNV: return "PartitionedInclusiveScanNV"; - case SpvGroupOperationPartitionedExclusiveScanNV: return "PartitionedExclusiveScanNV"; + case SpvGroupOperationPartitionedReduceEXT: return "PartitionedReduceEXT"; + case SpvGroupOperationPartitionedInclusiveScanEXT: return "PartitionedInclusiveScanEXT"; + case SpvGroupOperationPartitionedExclusiveScanEXT: return "PartitionedExclusiveScanEXT"; default: return "Unknown"; } } @@ -4107,6 +4371,10 @@ inline const char* SpvCapabilityToString(SpvCapability value) { case SpvCapabilityBFloat16TypeKHR: return "BFloat16TypeKHR"; case SpvCapabilityBFloat16DotProductKHR: return "BFloat16DotProductKHR"; case SpvCapabilityBFloat16CooperativeMatrixKHR: return "BFloat16CooperativeMatrixKHR"; + case SpvCapabilityAbortKHR: return "AbortKHR"; + case SpvCapabilityDescriptorHeapEXT: return "DescriptorHeapEXT"; + case SpvCapabilityConstantDataKHR: return "ConstantDataKHR"; + case SpvCapabilityPoisonFreezeKHR: return "PoisonFreezeKHR"; case SpvCapabilitySampleMaskOverrideCoverageNV: return "SampleMaskOverrideCoverageNV"; case SpvCapabilityGeometryShaderPassthroughNV: return "GeometryShaderPassthroughNV"; case SpvCapabilityShaderViewportIndexLayerEXT: return "ShaderViewportIndexLayerEXT"; @@ -4120,7 +4388,7 @@ inline const char* SpvCapabilityToString(SpvCapability value) { case SpvCapabilityFragmentBarycentricKHR: return "FragmentBarycentricKHR"; case SpvCapabilityComputeDerivativeGroupQuadsKHR: return "ComputeDerivativeGroupQuadsKHR"; case SpvCapabilityFragmentDensityEXT: return "FragmentDensityEXT"; - case SpvCapabilityGroupNonUniformPartitionedNV: return "GroupNonUniformPartitionedNV"; + case SpvCapabilityGroupNonUniformPartitionedEXT: return "GroupNonUniformPartitionedEXT"; case SpvCapabilityShaderNonUniform: return "ShaderNonUniform"; case SpvCapabilityRuntimeDescriptorArray: return "RuntimeDescriptorArray"; case SpvCapabilityInputAttachmentArrayDynamicIndexing: return "InputAttachmentArrayDynamicIndexing"; @@ -4150,6 +4418,7 @@ inline const char* SpvCapabilityToString(SpvCapability value) { case SpvCapabilityDisplacementMicromapNV: return "DisplacementMicromapNV"; case SpvCapabilityRayTracingOpacityMicromapEXT: return "RayTracingOpacityMicromapEXT"; case SpvCapabilityShaderInvocationReorderNV: return "ShaderInvocationReorderNV"; + case SpvCapabilityShaderInvocationReorderEXT: return "ShaderInvocationReorderEXT"; case SpvCapabilityBindlessTextureNV: return "BindlessTextureNV"; case SpvCapabilityRayQueryPositionFetchKHR: return "RayQueryPositionFetchKHR"; case SpvCapabilityCooperativeVectorNV: return "CooperativeVectorNV"; @@ -4158,6 +4427,9 @@ inline const char* SpvCapabilityToString(SpvCapability value) { case SpvCapabilityRawAccessChainsNV: return "RawAccessChainsNV"; case SpvCapabilityRayTracingSpheresGeometryNV: return "RayTracingSpheresGeometryNV"; case SpvCapabilityRayTracingLinearSweptSpheresGeometryNV: return "RayTracingLinearSweptSpheresGeometryNV"; + case SpvCapabilityPushConstantBanksNV: return "PushConstantBanksNV"; + case SpvCapabilityLongVectorEXT: return "LongVectorEXT"; + case SpvCapabilityShader64BitIndexingEXT: return "Shader64BitIndexingEXT"; case SpvCapabilityCooperativeMatrixReductionsNV: return "CooperativeMatrixReductionsNV"; case SpvCapabilityCooperativeMatrixConversionsNV: return "CooperativeMatrixConversionsNV"; case SpvCapabilityCooperativeMatrixPerElementOperationsNV: return "CooperativeMatrixPerElementOperationsNV"; @@ -4187,27 +4459,27 @@ inline const char* SpvCapabilityToString(SpvCapability value) { case SpvCapabilitySubgroupAvcMotionEstimationChromaINTEL: return "SubgroupAvcMotionEstimationChromaINTEL"; case SpvCapabilityVariableLengthArrayINTEL: return "VariableLengthArrayINTEL"; case SpvCapabilityFunctionFloatControlINTEL: return "FunctionFloatControlINTEL"; - case SpvCapabilityFPGAMemoryAttributesINTEL: return "FPGAMemoryAttributesINTEL"; + case SpvCapabilityFPGAMemoryAttributesALTERA: return "FPGAMemoryAttributesALTERA"; case SpvCapabilityFPFastMathModeINTEL: return "FPFastMathModeINTEL"; - case SpvCapabilityArbitraryPrecisionIntegersINTEL: return "ArbitraryPrecisionIntegersINTEL"; - case SpvCapabilityArbitraryPrecisionFloatingPointINTEL: return "ArbitraryPrecisionFloatingPointINTEL"; + case SpvCapabilityArbitraryPrecisionIntegersALTERA: return "ArbitraryPrecisionIntegersALTERA"; + case SpvCapabilityArbitraryPrecisionFloatingPointALTERA: return "ArbitraryPrecisionFloatingPointALTERA"; case SpvCapabilityUnstructuredLoopControlsINTEL: return "UnstructuredLoopControlsINTEL"; - case SpvCapabilityFPGALoopControlsINTEL: return "FPGALoopControlsINTEL"; + case SpvCapabilityFPGALoopControlsALTERA: return "FPGALoopControlsALTERA"; case SpvCapabilityKernelAttributesINTEL: return "KernelAttributesINTEL"; case SpvCapabilityFPGAKernelAttributesINTEL: return "FPGAKernelAttributesINTEL"; - case SpvCapabilityFPGAMemoryAccessesINTEL: return "FPGAMemoryAccessesINTEL"; - case SpvCapabilityFPGAClusterAttributesINTEL: return "FPGAClusterAttributesINTEL"; - case SpvCapabilityLoopFuseINTEL: return "LoopFuseINTEL"; - case SpvCapabilityFPGADSPControlINTEL: return "FPGADSPControlINTEL"; + case SpvCapabilityFPGAMemoryAccessesALTERA: return "FPGAMemoryAccessesALTERA"; + case SpvCapabilityFPGAClusterAttributesALTERA: return "FPGAClusterAttributesALTERA"; + case SpvCapabilityLoopFuseALTERA: return "LoopFuseALTERA"; + case SpvCapabilityFPGADSPControlALTERA: return "FPGADSPControlALTERA"; case SpvCapabilityMemoryAccessAliasingINTEL: return "MemoryAccessAliasingINTEL"; - case SpvCapabilityFPGAInvocationPipeliningAttributesINTEL: return "FPGAInvocationPipeliningAttributesINTEL"; - case SpvCapabilityFPGABufferLocationINTEL: return "FPGABufferLocationINTEL"; - case SpvCapabilityArbitraryPrecisionFixedPointINTEL: return "ArbitraryPrecisionFixedPointINTEL"; - case SpvCapabilityUSMStorageClassesINTEL: return "USMStorageClassesINTEL"; - case SpvCapabilityRuntimeAlignedAttributeINTEL: return "RuntimeAlignedAttributeINTEL"; - case SpvCapabilityIOPipesINTEL: return "IOPipesINTEL"; - case SpvCapabilityBlockingPipesINTEL: return "BlockingPipesINTEL"; - case SpvCapabilityFPGARegINTEL: return "FPGARegINTEL"; + case SpvCapabilityFPGAInvocationPipeliningAttributesALTERA: return "FPGAInvocationPipeliningAttributesALTERA"; + case SpvCapabilityFPGABufferLocationALTERA: return "FPGABufferLocationALTERA"; + case SpvCapabilityArbitraryPrecisionFixedPointALTERA: return "ArbitraryPrecisionFixedPointALTERA"; + case SpvCapabilityUSMStorageClassesALTERA: return "USMStorageClassesALTERA"; + case SpvCapabilityRuntimeAlignedAttributeALTERA: return "RuntimeAlignedAttributeALTERA"; + case SpvCapabilityIOPipesALTERA: return "IOPipesALTERA"; + case SpvCapabilityBlockingPipesALTERA: return "BlockingPipesALTERA"; + case SpvCapabilityFPGARegALTERA: return "FPGARegALTERA"; case SpvCapabilityDotProductInputAll: return "DotProductInputAll"; case SpvCapabilityDotProductInput4x8Bit: return "DotProductInput4x8Bit"; case SpvCapabilityDotProductInput4x8BitPacked: return "DotProductInput4x8BitPacked"; @@ -4228,14 +4500,14 @@ inline const char* SpvCapabilityToString(SpvCapability value) { case SpvCapabilityBFloat16ConversionINTEL: return "BFloat16ConversionINTEL"; case SpvCapabilitySplitBarrierINTEL: return "SplitBarrierINTEL"; case SpvCapabilityArithmeticFenceEXT: return "ArithmeticFenceEXT"; - case SpvCapabilityFPGAClusterAttributesV2INTEL: return "FPGAClusterAttributesV2INTEL"; + case SpvCapabilityFPGAClusterAttributesV2ALTERA: return "FPGAClusterAttributesV2ALTERA"; case SpvCapabilityFPGAKernelAttributesv2INTEL: return "FPGAKernelAttributesv2INTEL"; - case SpvCapabilityTaskSequenceINTEL: return "TaskSequenceINTEL"; + case SpvCapabilityTaskSequenceALTERA: return "TaskSequenceALTERA"; case SpvCapabilityFPMaxErrorINTEL: return "FPMaxErrorINTEL"; - case SpvCapabilityFPGALatencyControlINTEL: return "FPGALatencyControlINTEL"; - case SpvCapabilityFPGAArgumentInterfacesINTEL: return "FPGAArgumentInterfacesINTEL"; + case SpvCapabilityFPGALatencyControlALTERA: return "FPGALatencyControlALTERA"; + case SpvCapabilityFPGAArgumentInterfacesALTERA: return "FPGAArgumentInterfacesALTERA"; case SpvCapabilityGlobalVariableHostAccessINTEL: return "GlobalVariableHostAccessINTEL"; - case SpvCapabilityGlobalVariableFPGADecorationsINTEL: return "GlobalVariableFPGADecorationsINTEL"; + case SpvCapabilityGlobalVariableFPGADecorationsALTERA: return "GlobalVariableFPGADecorationsALTERA"; case SpvCapabilitySubgroupBufferPrefetchINTEL: return "SubgroupBufferPrefetchINTEL"; case SpvCapabilitySubgroup2DBlockIOINTEL: return "Subgroup2DBlockIOINTEL"; case SpvCapabilitySubgroup2DBlockTransformINTEL: return "Subgroup2DBlockTransformINTEL"; @@ -4251,6 +4523,10 @@ inline const char* SpvCapabilityToString(SpvCapability value) { case SpvCapabilityCacheControlsINTEL: return "CacheControlsINTEL"; case SpvCapabilityRegisterLimitsINTEL: return "RegisterLimitsINTEL"; case SpvCapabilityBindlessImagesINTEL: return "BindlessImagesINTEL"; + case SpvCapabilityDotProductFloat16AccFloat32VALVE: return "DotProductFloat16AccFloat32VALVE"; + case SpvCapabilityDotProductFloat16AccFloat16VALVE: return "DotProductFloat16AccFloat16VALVE"; + case SpvCapabilityDotProductBFloat16AccVALVE: return "DotProductBFloat16AccVALVE"; + case SpvCapabilityDotProductFloat8AccFloat32VALVE: return "DotProductFloat8AccFloat32VALVE"; default: return "Unknown"; } } @@ -4359,8 +4635,8 @@ inline const char* SpvTensorClampModeToString(SpvTensorClampMode value) { inline const char* SpvInitializationModeQualifierToString(SpvInitializationModeQualifier value) { switch (value) { - case SpvInitializationModeQualifierInitOnDeviceReprogramINTEL: return "InitOnDeviceReprogramINTEL"; - case SpvInitializationModeQualifierInitOnDeviceResetINTEL: return "InitOnDeviceResetINTEL"; + case SpvInitializationModeQualifierInitOnDeviceReprogramALTERA: return "InitOnDeviceReprogramALTERA"; + case SpvInitializationModeQualifierInitOnDeviceResetALTERA: return "InitOnDeviceResetALTERA"; default: return "Unknown"; } } @@ -4881,6 +5157,16 @@ inline const char* SpvOpToString(SpvOp value) { case SpvOpSpecConstantStringAMDX: return "OpSpecConstantStringAMDX"; case SpvOpGroupNonUniformQuadAllKHR: return "OpGroupNonUniformQuadAllKHR"; case SpvOpGroupNonUniformQuadAnyKHR: return "OpGroupNonUniformQuadAnyKHR"; + case SpvOpTypeBufferEXT: return "OpTypeBufferEXT"; + case SpvOpBufferPointerEXT: return "OpBufferPointerEXT"; + case SpvOpAbortKHR: return "OpAbortKHR"; + case SpvOpUntypedImageTexelPointerEXT: return "OpUntypedImageTexelPointerEXT"; + case SpvOpMemberDecorateIdEXT: return "OpMemberDecorateIdEXT"; + case SpvOpConstantSizeOfEXT: return "OpConstantSizeOfEXT"; + case SpvOpConstantDataKHR: return "OpConstantDataKHR"; + case SpvOpSpecConstantDataKHR: return "OpSpecConstantDataKHR"; + case SpvOpPoisonKHR: return "OpPoisonKHR"; + case SpvOpFreezeKHR: return "OpFreezeKHR"; case SpvOpHitObjectRecordHitMotionNV: return "OpHitObjectRecordHitMotionNV"; case SpvOpHitObjectRecordHitWithIndexMotionNV: return "OpHitObjectRecordHitWithIndexMotionNV"; case SpvOpHitObjectRecordMissMotionNV: return "OpHitObjectRecordMissMotionNV"; @@ -4923,12 +5209,42 @@ inline const char* SpvOpToString(SpvOp value) { case SpvOpCooperativeMatrixConvertNV: return "OpCooperativeMatrixConvertNV"; case SpvOpEmitMeshTasksEXT: return "OpEmitMeshTasksEXT"; case SpvOpSetMeshOutputsEXT: return "OpSetMeshOutputsEXT"; - case SpvOpGroupNonUniformPartitionNV: return "OpGroupNonUniformPartitionNV"; + case SpvOpGroupNonUniformPartitionEXT: return "OpGroupNonUniformPartitionEXT"; case SpvOpWritePackedPrimitiveIndices4x8NV: return "OpWritePackedPrimitiveIndices4x8NV"; case SpvOpFetchMicroTriangleVertexPositionNV: return "OpFetchMicroTriangleVertexPositionNV"; case SpvOpFetchMicroTriangleVertexBarycentricNV: return "OpFetchMicroTriangleVertexBarycentricNV"; case SpvOpCooperativeVectorLoadNV: return "OpCooperativeVectorLoadNV"; case SpvOpCooperativeVectorStoreNV: return "OpCooperativeVectorStoreNV"; + case SpvOpHitObjectRecordFromQueryEXT: return "OpHitObjectRecordFromQueryEXT"; + case SpvOpHitObjectRecordMissEXT: return "OpHitObjectRecordMissEXT"; + case SpvOpHitObjectRecordMissMotionEXT: return "OpHitObjectRecordMissMotionEXT"; + case SpvOpHitObjectGetIntersectionTriangleVertexPositionsEXT: return "OpHitObjectGetIntersectionTriangleVertexPositionsEXT"; + case SpvOpHitObjectGetRayFlagsEXT: return "OpHitObjectGetRayFlagsEXT"; + case SpvOpHitObjectSetShaderBindingTableRecordIndexEXT: return "OpHitObjectSetShaderBindingTableRecordIndexEXT"; + case SpvOpHitObjectReorderExecuteShaderEXT: return "OpHitObjectReorderExecuteShaderEXT"; + case SpvOpHitObjectTraceReorderExecuteEXT: return "OpHitObjectTraceReorderExecuteEXT"; + case SpvOpHitObjectTraceMotionReorderExecuteEXT: return "OpHitObjectTraceMotionReorderExecuteEXT"; + case SpvOpTypeHitObjectEXT: return "OpTypeHitObjectEXT"; + case SpvOpReorderThreadWithHintEXT: return "OpReorderThreadWithHintEXT"; + case SpvOpReorderThreadWithHitObjectEXT: return "OpReorderThreadWithHitObjectEXT"; + case SpvOpHitObjectTraceRayEXT: return "OpHitObjectTraceRayEXT"; + case SpvOpHitObjectTraceRayMotionEXT: return "OpHitObjectTraceRayMotionEXT"; + case SpvOpHitObjectRecordEmptyEXT: return "OpHitObjectRecordEmptyEXT"; + case SpvOpHitObjectExecuteShaderEXT: return "OpHitObjectExecuteShaderEXT"; + case SpvOpHitObjectGetCurrentTimeEXT: return "OpHitObjectGetCurrentTimeEXT"; + case SpvOpHitObjectGetAttributesEXT: return "OpHitObjectGetAttributesEXT"; + case SpvOpHitObjectGetHitKindEXT: return "OpHitObjectGetHitKindEXT"; + case SpvOpHitObjectGetPrimitiveIndexEXT: return "OpHitObjectGetPrimitiveIndexEXT"; + case SpvOpHitObjectGetGeometryIndexEXT: return "OpHitObjectGetGeometryIndexEXT"; + case SpvOpHitObjectGetInstanceIdEXT: return "OpHitObjectGetInstanceIdEXT"; + case SpvOpHitObjectGetInstanceCustomIndexEXT: return "OpHitObjectGetInstanceCustomIndexEXT"; + case SpvOpHitObjectGetObjectRayOriginEXT: return "OpHitObjectGetObjectRayOriginEXT"; + case SpvOpHitObjectGetObjectRayDirectionEXT: return "OpHitObjectGetObjectRayDirectionEXT"; + case SpvOpHitObjectGetWorldRayDirectionEXT: return "OpHitObjectGetWorldRayDirectionEXT"; + case SpvOpHitObjectGetWorldRayOriginEXT: return "OpHitObjectGetWorldRayOriginEXT"; + case SpvOpHitObjectGetObjectToWorldEXT: return "OpHitObjectGetObjectToWorldEXT"; + case SpvOpHitObjectGetWorldToObjectEXT: return "OpHitObjectGetWorldToObjectEXT"; + case SpvOpHitObjectGetRayTMaxEXT: return "OpHitObjectGetRayTMaxEXT"; case SpvOpReportIntersectionKHR: return "OpReportIntersectionKHR"; case SpvOpIgnoreIntersectionNV: return "OpIgnoreIntersectionNV"; case SpvOpTerminateRayNV: return "OpTerminateRayNV"; @@ -4940,6 +5256,12 @@ inline const char* SpvOpToString(SpvOp value) { case SpvOpExecuteCallableNV: return "OpExecuteCallableNV"; case SpvOpRayQueryGetClusterIdNV: return "OpRayQueryGetClusterIdNV"; case SpvOpHitObjectGetClusterIdNV: return "OpHitObjectGetClusterIdNV"; + case SpvOpHitObjectGetRayTMinEXT: return "OpHitObjectGetRayTMinEXT"; + case SpvOpHitObjectGetShaderBindingTableRecordIndexEXT: return "OpHitObjectGetShaderBindingTableRecordIndexEXT"; + case SpvOpHitObjectGetShaderRecordBufferHandleEXT: return "OpHitObjectGetShaderRecordBufferHandleEXT"; + case SpvOpHitObjectIsEmptyEXT: return "OpHitObjectIsEmptyEXT"; + case SpvOpHitObjectIsHitEXT: return "OpHitObjectIsHitEXT"; + case SpvOpHitObjectIsMissEXT: return "OpHitObjectIsMissEXT"; case SpvOpTypeCooperativeMatrixNV: return "OpTypeCooperativeMatrixNV"; case SpvOpCooperativeMatrixLoadNV: return "OpCooperativeMatrixLoadNV"; case SpvOpCooperativeMatrixStoreNV: return "OpCooperativeMatrixStoreNV"; @@ -5143,24 +5465,24 @@ inline const char* SpvOpToString(SpvOp value) { case SpvOpVariableLengthArrayINTEL: return "OpVariableLengthArrayINTEL"; case SpvOpSaveMemoryINTEL: return "OpSaveMemoryINTEL"; case SpvOpRestoreMemoryINTEL: return "OpRestoreMemoryINTEL"; - case SpvOpArbitraryFloatSinCosPiINTEL: return "OpArbitraryFloatSinCosPiINTEL"; - case SpvOpArbitraryFloatCastINTEL: return "OpArbitraryFloatCastINTEL"; - case SpvOpArbitraryFloatCastFromIntINTEL: return "OpArbitraryFloatCastFromIntINTEL"; - case SpvOpArbitraryFloatCastToIntINTEL: return "OpArbitraryFloatCastToIntINTEL"; - case SpvOpArbitraryFloatAddINTEL: return "OpArbitraryFloatAddINTEL"; - case SpvOpArbitraryFloatSubINTEL: return "OpArbitraryFloatSubINTEL"; - case SpvOpArbitraryFloatMulINTEL: return "OpArbitraryFloatMulINTEL"; - case SpvOpArbitraryFloatDivINTEL: return "OpArbitraryFloatDivINTEL"; - case SpvOpArbitraryFloatGTINTEL: return "OpArbitraryFloatGTINTEL"; - case SpvOpArbitraryFloatGEINTEL: return "OpArbitraryFloatGEINTEL"; - case SpvOpArbitraryFloatLTINTEL: return "OpArbitraryFloatLTINTEL"; - case SpvOpArbitraryFloatLEINTEL: return "OpArbitraryFloatLEINTEL"; - case SpvOpArbitraryFloatEQINTEL: return "OpArbitraryFloatEQINTEL"; - case SpvOpArbitraryFloatRecipINTEL: return "OpArbitraryFloatRecipINTEL"; - case SpvOpArbitraryFloatRSqrtINTEL: return "OpArbitraryFloatRSqrtINTEL"; - case SpvOpArbitraryFloatCbrtINTEL: return "OpArbitraryFloatCbrtINTEL"; - case SpvOpArbitraryFloatHypotINTEL: return "OpArbitraryFloatHypotINTEL"; - case SpvOpArbitraryFloatSqrtINTEL: return "OpArbitraryFloatSqrtINTEL"; + case SpvOpArbitraryFloatSinCosPiALTERA: return "OpArbitraryFloatSinCosPiALTERA"; + case SpvOpArbitraryFloatCastALTERA: return "OpArbitraryFloatCastALTERA"; + case SpvOpArbitraryFloatCastFromIntALTERA: return "OpArbitraryFloatCastFromIntALTERA"; + case SpvOpArbitraryFloatCastToIntALTERA: return "OpArbitraryFloatCastToIntALTERA"; + case SpvOpArbitraryFloatAddALTERA: return "OpArbitraryFloatAddALTERA"; + case SpvOpArbitraryFloatSubALTERA: return "OpArbitraryFloatSubALTERA"; + case SpvOpArbitraryFloatMulALTERA: return "OpArbitraryFloatMulALTERA"; + case SpvOpArbitraryFloatDivALTERA: return "OpArbitraryFloatDivALTERA"; + case SpvOpArbitraryFloatGTALTERA: return "OpArbitraryFloatGTALTERA"; + case SpvOpArbitraryFloatGEALTERA: return "OpArbitraryFloatGEALTERA"; + case SpvOpArbitraryFloatLTALTERA: return "OpArbitraryFloatLTALTERA"; + case SpvOpArbitraryFloatLEALTERA: return "OpArbitraryFloatLEALTERA"; + case SpvOpArbitraryFloatEQALTERA: return "OpArbitraryFloatEQALTERA"; + case SpvOpArbitraryFloatRecipALTERA: return "OpArbitraryFloatRecipALTERA"; + case SpvOpArbitraryFloatRSqrtALTERA: return "OpArbitraryFloatRSqrtALTERA"; + case SpvOpArbitraryFloatCbrtALTERA: return "OpArbitraryFloatCbrtALTERA"; + case SpvOpArbitraryFloatHypotALTERA: return "OpArbitraryFloatHypotALTERA"; + case SpvOpArbitraryFloatSqrtALTERA: return "OpArbitraryFloatSqrtALTERA"; case SpvOpArbitraryFloatLogINTEL: return "OpArbitraryFloatLogINTEL"; case SpvOpArbitraryFloatLog2INTEL: return "OpArbitraryFloatLog2INTEL"; case SpvOpArbitraryFloatLog10INTEL: return "OpArbitraryFloatLog10INTEL"; @@ -5188,22 +5510,22 @@ inline const char* SpvOpToString(SpvOp value) { case SpvOpAliasDomainDeclINTEL: return "OpAliasDomainDeclINTEL"; case SpvOpAliasScopeDeclINTEL: return "OpAliasScopeDeclINTEL"; case SpvOpAliasScopeListDeclINTEL: return "OpAliasScopeListDeclINTEL"; - case SpvOpFixedSqrtINTEL: return "OpFixedSqrtINTEL"; - case SpvOpFixedRecipINTEL: return "OpFixedRecipINTEL"; - case SpvOpFixedRsqrtINTEL: return "OpFixedRsqrtINTEL"; - case SpvOpFixedSinINTEL: return "OpFixedSinINTEL"; - case SpvOpFixedCosINTEL: return "OpFixedCosINTEL"; - case SpvOpFixedSinCosINTEL: return "OpFixedSinCosINTEL"; - case SpvOpFixedSinPiINTEL: return "OpFixedSinPiINTEL"; - case SpvOpFixedCosPiINTEL: return "OpFixedCosPiINTEL"; - case SpvOpFixedSinCosPiINTEL: return "OpFixedSinCosPiINTEL"; - case SpvOpFixedLogINTEL: return "OpFixedLogINTEL"; - case SpvOpFixedExpINTEL: return "OpFixedExpINTEL"; - case SpvOpPtrCastToCrossWorkgroupINTEL: return "OpPtrCastToCrossWorkgroupINTEL"; - case SpvOpCrossWorkgroupCastToPtrINTEL: return "OpCrossWorkgroupCastToPtrINTEL"; - case SpvOpReadPipeBlockingINTEL: return "OpReadPipeBlockingINTEL"; - case SpvOpWritePipeBlockingINTEL: return "OpWritePipeBlockingINTEL"; - case SpvOpFPGARegINTEL: return "OpFPGARegINTEL"; + case SpvOpFixedSqrtALTERA: return "OpFixedSqrtALTERA"; + case SpvOpFixedRecipALTERA: return "OpFixedRecipALTERA"; + case SpvOpFixedRsqrtALTERA: return "OpFixedRsqrtALTERA"; + case SpvOpFixedSinALTERA: return "OpFixedSinALTERA"; + case SpvOpFixedCosALTERA: return "OpFixedCosALTERA"; + case SpvOpFixedSinCosALTERA: return "OpFixedSinCosALTERA"; + case SpvOpFixedSinPiALTERA: return "OpFixedSinPiALTERA"; + case SpvOpFixedCosPiALTERA: return "OpFixedCosPiALTERA"; + case SpvOpFixedSinCosPiALTERA: return "OpFixedSinCosPiALTERA"; + case SpvOpFixedLogALTERA: return "OpFixedLogALTERA"; + case SpvOpFixedExpALTERA: return "OpFixedExpALTERA"; + case SpvOpPtrCastToCrossWorkgroupALTERA: return "OpPtrCastToCrossWorkgroupALTERA"; + case SpvOpCrossWorkgroupCastToPtrALTERA: return "OpCrossWorkgroupCastToPtrALTERA"; + case SpvOpReadPipeBlockingALTERA: return "OpReadPipeBlockingALTERA"; + case SpvOpWritePipeBlockingALTERA: return "OpWritePipeBlockingALTERA"; + case SpvOpFPGARegALTERA: return "OpFPGARegALTERA"; case SpvOpRayQueryGetRayTMinKHR: return "OpRayQueryGetRayTMinKHR"; case SpvOpRayQueryGetRayFlagsKHR: return "OpRayQueryGetRayFlagsKHR"; case SpvOpRayQueryGetIntersectionTKHR: return "OpRayQueryGetIntersectionTKHR"; @@ -5232,11 +5554,11 @@ inline const char* SpvOpToString(SpvOp value) { case SpvOpControlBarrierArriveINTEL: return "OpControlBarrierArriveINTEL"; case SpvOpControlBarrierWaitINTEL: return "OpControlBarrierWaitINTEL"; case SpvOpArithmeticFenceEXT: return "OpArithmeticFenceEXT"; - case SpvOpTaskSequenceCreateINTEL: return "OpTaskSequenceCreateINTEL"; - case SpvOpTaskSequenceAsyncINTEL: return "OpTaskSequenceAsyncINTEL"; - case SpvOpTaskSequenceGetINTEL: return "OpTaskSequenceGetINTEL"; - case SpvOpTaskSequenceReleaseINTEL: return "OpTaskSequenceReleaseINTEL"; - case SpvOpTypeTaskSequenceINTEL: return "OpTypeTaskSequenceINTEL"; + case SpvOpTaskSequenceCreateALTERA: return "OpTaskSequenceCreateALTERA"; + case SpvOpTaskSequenceAsyncALTERA: return "OpTaskSequenceAsyncALTERA"; + case SpvOpTaskSequenceGetALTERA: return "OpTaskSequenceGetALTERA"; + case SpvOpTaskSequenceReleaseALTERA: return "OpTaskSequenceReleaseALTERA"; + case SpvOpTypeTaskSequenceALTERA: return "OpTypeTaskSequenceALTERA"; case SpvOpSubgroupBlockPrefetchINTEL: return "OpSubgroupBlockPrefetchINTEL"; case SpvOpSubgroup2DBlockLoadINTEL: return "OpSubgroup2DBlockLoadINTEL"; case SpvOpSubgroup2DBlockLoadTransformINTEL: return "OpSubgroup2DBlockLoadTransformINTEL"; @@ -5267,6 +5589,9 @@ inline const char* SpvOpToString(SpvOp value) { case SpvOpConvertHandleToImageINTEL: return "OpConvertHandleToImageINTEL"; case SpvOpConvertHandleToSamplerINTEL: return "OpConvertHandleToSamplerINTEL"; case SpvOpConvertHandleToSampledImageINTEL: return "OpConvertHandleToSampledImageINTEL"; + case SpvOpFDot2MixAcc32VALVE: return "OpFDot2MixAcc32VALVE"; + case SpvOpFDot2MixAcc16VALVE: return "OpFDot2MixAcc16VALVE"; + case SpvOpFDot4MixAcc32VALVE: return "OpFDot4MixAcc32VALVE"; default: return "Unknown"; } } diff --git a/third_party/spirv-cross/spirv.hpp b/third_party/spirv-cross/spirv.hpp index 086fcc48c92b..462c3f6bfed8 100644 --- a/third_party/spirv-cross/spirv.hpp +++ b/third_party/spirv-cross/spirv.hpp @@ -175,6 +175,7 @@ enum ExecutionMode { ExecutionModeQuadDerivativesKHR = 5088, ExecutionModeRequireFullQuadsKHR = 5089, ExecutionModeSharesInputWithAMDX = 5102, + ExecutionModeArithmeticPoisonKHR = 5157, ExecutionModeOutputLinesEXT = 5269, ExecutionModeOutputLinesNV = 5269, ExecutionModeOutputPrimitivesEXT = 5270, @@ -191,6 +192,7 @@ enum ExecutionMode { ExecutionModeSampleInterlockUnorderedEXT = 5369, ExecutionModeShadingRateInterlockOrderedEXT = 5370, ExecutionModeShadingRateInterlockUnorderedEXT = 5371, + ExecutionModeShader64BitIndexingEXT = 5427, ExecutionModeSharedLocalMemorySizeINTEL = 5618, ExecutionModeRoundingModeRTPINTEL = 5620, ExecutionModeRoundingModeRTNINTEL = 5621, @@ -245,8 +247,11 @@ enum StorageClass { StorageClassPhysicalStorageBufferEXT = 5349, StorageClassHitObjectAttributeNV = 5385, StorageClassTaskPayloadWorkgroupEXT = 5402, + StorageClassHitObjectAttributeEXT = 5411, StorageClassCodeSectionINTEL = 5605, + StorageClassDeviceOnlyALTERA = 5936, StorageClassDeviceOnlyINTEL = 5936, + StorageClassHostOnlyALTERA = 5937, StorageClassHostOnlyINTEL = 5937, StorageClassMax = 0x7fffffff, }; @@ -485,6 +490,7 @@ enum FunctionParameterAttribute { FunctionParameterAttributeNoCapture = 5, FunctionParameterAttributeNoWrite = 6, FunctionParameterAttributeNoReadWrite = 7, + FunctionParameterAttributeRuntimeAlignedALTERA = 5940, FunctionParameterAttributeRuntimeAlignedINTEL = 5940, FunctionParameterAttributeMax = 0x7fffffff, }; @@ -552,6 +558,9 @@ enum Decoration { DecorationPayloadNodeSparseArrayAMDX = 5099, DecorationPayloadNodeArraySizeAMDX = 5100, DecorationPayloadDispatchIndirectAMDX = 5105, + DecorationArrayStrideIdEXT = 5124, + DecorationOffsetIdEXT = 5125, + DecorationUTFEncodedKHR = 5145, DecorationOverrideCoverageNV = 5248, DecorationPassthroughNV = 5250, DecorationViewportRelativeNV = 5252, @@ -568,7 +577,10 @@ enum Decoration { DecorationRestrictPointerEXT = 5355, DecorationAliasedPointer = 5356, DecorationAliasedPointerEXT = 5356, + DecorationMemberOffsetNV = 5358, DecorationHitObjectShaderRecordBufferNV = 5386, + DecorationHitObjectShaderRecordBufferEXT = 5389, + DecorationBankNV = 5397, DecorationBindlessSamplerNV = 5398, DecorationBindlessImageNV = 5399, DecorationBoundSamplerNV = 5400, @@ -589,54 +601,95 @@ enum Decoration { DecorationUserTypeGOOGLE = 5636, DecorationFunctionRoundingModeINTEL = 5822, DecorationFunctionDenormModeINTEL = 5823, + DecorationRegisterALTERA = 5825, DecorationRegisterINTEL = 5825, + DecorationMemoryALTERA = 5826, DecorationMemoryINTEL = 5826, + DecorationNumbanksALTERA = 5827, DecorationNumbanksINTEL = 5827, + DecorationBankwidthALTERA = 5828, DecorationBankwidthINTEL = 5828, + DecorationMaxPrivateCopiesALTERA = 5829, DecorationMaxPrivateCopiesINTEL = 5829, + DecorationSinglepumpALTERA = 5830, DecorationSinglepumpINTEL = 5830, + DecorationDoublepumpALTERA = 5831, DecorationDoublepumpINTEL = 5831, + DecorationMaxReplicatesALTERA = 5832, DecorationMaxReplicatesINTEL = 5832, + DecorationSimpleDualPortALTERA = 5833, DecorationSimpleDualPortINTEL = 5833, + DecorationMergeALTERA = 5834, DecorationMergeINTEL = 5834, + DecorationBankBitsALTERA = 5835, DecorationBankBitsINTEL = 5835, + DecorationForcePow2DepthALTERA = 5836, DecorationForcePow2DepthINTEL = 5836, + DecorationStridesizeALTERA = 5883, DecorationStridesizeINTEL = 5883, + DecorationWordsizeALTERA = 5884, DecorationWordsizeINTEL = 5884, + DecorationTrueDualPortALTERA = 5885, DecorationTrueDualPortINTEL = 5885, + DecorationBurstCoalesceALTERA = 5899, DecorationBurstCoalesceINTEL = 5899, + DecorationCacheSizeALTERA = 5900, DecorationCacheSizeINTEL = 5900, + DecorationDontStaticallyCoalesceALTERA = 5901, DecorationDontStaticallyCoalesceINTEL = 5901, + DecorationPrefetchALTERA = 5902, DecorationPrefetchINTEL = 5902, + DecorationStallEnableALTERA = 5905, DecorationStallEnableINTEL = 5905, + DecorationFuseLoopsInFunctionALTERA = 5907, DecorationFuseLoopsInFunctionINTEL = 5907, + DecorationMathOpDSPModeALTERA = 5909, DecorationMathOpDSPModeINTEL = 5909, DecorationAliasScopeINTEL = 5914, DecorationNoAliasINTEL = 5915, + DecorationInitiationIntervalALTERA = 5917, DecorationInitiationIntervalINTEL = 5917, + DecorationMaxConcurrencyALTERA = 5918, DecorationMaxConcurrencyINTEL = 5918, + DecorationPipelineEnableALTERA = 5919, DecorationPipelineEnableINTEL = 5919, + DecorationBufferLocationALTERA = 5921, DecorationBufferLocationINTEL = 5921, + DecorationIOPipeStorageALTERA = 5944, DecorationIOPipeStorageINTEL = 5944, DecorationFunctionFloatingPointModeINTEL = 6080, DecorationSingleElementVectorINTEL = 6085, DecorationVectorComputeCallableFunctionINTEL = 6087, DecorationMediaBlockIOINTEL = 6140, + DecorationStallFreeALTERA = 6151, DecorationStallFreeINTEL = 6151, DecorationFPMaxErrorDecorationINTEL = 6170, + DecorationLatencyControlLabelALTERA = 6172, DecorationLatencyControlLabelINTEL = 6172, + DecorationLatencyControlConstraintALTERA = 6173, DecorationLatencyControlConstraintINTEL = 6173, + DecorationConduitKernelArgumentALTERA = 6175, DecorationConduitKernelArgumentINTEL = 6175, + DecorationRegisterMapKernelArgumentALTERA = 6176, DecorationRegisterMapKernelArgumentINTEL = 6176, + DecorationMMHostInterfaceAddressWidthALTERA = 6177, DecorationMMHostInterfaceAddressWidthINTEL = 6177, + DecorationMMHostInterfaceDataWidthALTERA = 6178, DecorationMMHostInterfaceDataWidthINTEL = 6178, + DecorationMMHostInterfaceLatencyALTERA = 6179, DecorationMMHostInterfaceLatencyINTEL = 6179, + DecorationMMHostInterfaceReadWriteModeALTERA = 6180, DecorationMMHostInterfaceReadWriteModeINTEL = 6180, + DecorationMMHostInterfaceMaxBurstALTERA = 6181, DecorationMMHostInterfaceMaxBurstINTEL = 6181, + DecorationMMHostInterfaceWaitRequestALTERA = 6182, DecorationMMHostInterfaceWaitRequestINTEL = 6182, + DecorationStableKernelArgumentALTERA = 6183, DecorationStableKernelArgumentINTEL = 6183, DecorationHostAccessINTEL = 6188, + DecorationInitModeALTERA = 6190, DecorationInitModeINTEL = 6190, + DecorationImplementInRegisterMapALTERA = 6191, DecorationImplementInRegisterMapINTEL = 6191, DecorationConditionalINTEL = 6247, DecorationCacheControlLoadINTEL = 6442, @@ -721,6 +774,8 @@ enum BuiltIn { BuiltInFragStencilRefEXT = 5014, BuiltInRemainingRecursionLevelsAMDX = 5021, BuiltInShaderIndexAMDX = 5073, + BuiltInSamplerHeapEXT = 5122, + BuiltInResourceHeapEXT = 5123, BuiltInViewportMaskNV = 5253, BuiltInSecondaryPositionNV = 5257, BuiltInSecondaryViewportMaskNV = 5258, @@ -818,15 +873,25 @@ enum LoopControlShift { LoopControlIterationMultipleShift = 6, LoopControlPeelCountShift = 7, LoopControlPartialCountShift = 8, + LoopControlInitiationIntervalALTERAShift = 16, LoopControlInitiationIntervalINTELShift = 16, + LoopControlMaxConcurrencyALTERAShift = 17, LoopControlMaxConcurrencyINTELShift = 17, + LoopControlDependencyArrayALTERAShift = 18, LoopControlDependencyArrayINTELShift = 18, + LoopControlPipelineEnableALTERAShift = 19, LoopControlPipelineEnableINTELShift = 19, + LoopControlLoopCoalesceALTERAShift = 20, LoopControlLoopCoalesceINTELShift = 20, + LoopControlMaxInterleavingALTERAShift = 21, LoopControlMaxInterleavingINTELShift = 21, + LoopControlSpeculatedIterationsALTERAShift = 22, LoopControlSpeculatedIterationsINTELShift = 22, + LoopControlNoFusionALTERAShift = 23, LoopControlNoFusionINTELShift = 23, + LoopControlLoopCountALTERAShift = 24, LoopControlLoopCountINTELShift = 24, + LoopControlMaxReinvocationDelayALTERAShift = 25, LoopControlMaxReinvocationDelayINTELShift = 25, LoopControlMax = 0x7fffffff, }; @@ -842,15 +907,25 @@ enum LoopControlMask { LoopControlIterationMultipleMask = 0x00000040, LoopControlPeelCountMask = 0x00000080, LoopControlPartialCountMask = 0x00000100, + LoopControlInitiationIntervalALTERAMask = 0x00010000, LoopControlInitiationIntervalINTELMask = 0x00010000, + LoopControlMaxConcurrencyALTERAMask = 0x00020000, LoopControlMaxConcurrencyINTELMask = 0x00020000, + LoopControlDependencyArrayALTERAMask = 0x00040000, LoopControlDependencyArrayINTELMask = 0x00040000, + LoopControlPipelineEnableALTERAMask = 0x00080000, LoopControlPipelineEnableINTELMask = 0x00080000, + LoopControlLoopCoalesceALTERAMask = 0x00100000, LoopControlLoopCoalesceINTELMask = 0x00100000, + LoopControlMaxInterleavingALTERAMask = 0x00200000, LoopControlMaxInterleavingINTELMask = 0x00200000, + LoopControlSpeculatedIterationsALTERAMask = 0x00400000, LoopControlSpeculatedIterationsINTELMask = 0x00400000, + LoopControlNoFusionALTERAMask = 0x00800000, LoopControlNoFusionINTELMask = 0x00800000, + LoopControlLoopCountALTERAMask = 0x01000000, LoopControlLoopCountINTELMask = 0x01000000, + LoopControlMaxReinvocationDelayALTERAMask = 0x02000000, LoopControlMaxReinvocationDelayINTELMask = 0x02000000, }; @@ -963,8 +1038,11 @@ enum GroupOperation { GroupOperationInclusiveScan = 1, GroupOperationExclusiveScan = 2, GroupOperationClusteredReduce = 3, + GroupOperationPartitionedReduceEXT = 6, GroupOperationPartitionedReduceNV = 6, + GroupOperationPartitionedInclusiveScanEXT = 7, GroupOperationPartitionedInclusiveScanNV = 7, + GroupOperationPartitionedExclusiveScanEXT = 8, GroupOperationPartitionedExclusiveScanNV = 8, GroupOperationMax = 0x7fffffff, }; @@ -1120,6 +1198,10 @@ enum Capability { CapabilityBFloat16TypeKHR = 5116, CapabilityBFloat16DotProductKHR = 5117, CapabilityBFloat16CooperativeMatrixKHR = 5118, + CapabilityAbortKHR = 5120, + CapabilityDescriptorHeapEXT = 5128, + CapabilityConstantDataKHR = 5146, + CapabilityPoisonFreezeKHR = 5156, CapabilitySampleMaskOverrideCoverageNV = 5249, CapabilityGeometryShaderPassthroughNV = 5251, CapabilityShaderViewportIndexLayerEXT = 5254, @@ -1137,6 +1219,7 @@ enum Capability { CapabilityComputeDerivativeGroupQuadsNV = 5288, CapabilityFragmentDensityEXT = 5291, CapabilityShadingRateNV = 5291, + CapabilityGroupNonUniformPartitionedEXT = 5297, CapabilityGroupNonUniformPartitionedNV = 5297, CapabilityShaderNonUniform = 5301, CapabilityShaderNonUniformEXT = 5301, @@ -1184,6 +1267,7 @@ enum Capability { CapabilityDisplacementMicromapNV = 5380, CapabilityRayTracingOpacityMicromapEXT = 5381, CapabilityShaderInvocationReorderNV = 5383, + CapabilityShaderInvocationReorderEXT = 5388, CapabilityBindlessTextureNV = 5390, CapabilityRayQueryPositionFetchKHR = 5391, CapabilityCooperativeVectorNV = 5394, @@ -1192,6 +1276,9 @@ enum Capability { CapabilityRawAccessChainsNV = 5414, CapabilityRayTracingSpheresGeometryNV = 5418, CapabilityRayTracingLinearSweptSpheresGeometryNV = 5419, + CapabilityPushConstantBanksNV = 5423, + CapabilityLongVectorEXT = 5425, + CapabilityShader64BitIndexingEXT = 5426, CapabilityCooperativeMatrixReductionsNV = 5430, CapabilityCooperativeMatrixConversionsNV = 5431, CapabilityCooperativeMatrixPerElementOperationsNV = 5432, @@ -1221,26 +1308,42 @@ enum Capability { CapabilitySubgroupAvcMotionEstimationChromaINTEL = 5698, CapabilityVariableLengthArrayINTEL = 5817, CapabilityFunctionFloatControlINTEL = 5821, + CapabilityFPGAMemoryAttributesALTERA = 5824, CapabilityFPGAMemoryAttributesINTEL = 5824, CapabilityFPFastMathModeINTEL = 5837, + CapabilityArbitraryPrecisionIntegersALTERA = 5844, CapabilityArbitraryPrecisionIntegersINTEL = 5844, + CapabilityArbitraryPrecisionFloatingPointALTERA = 5845, CapabilityArbitraryPrecisionFloatingPointINTEL = 5845, CapabilityUnstructuredLoopControlsINTEL = 5886, + CapabilityFPGALoopControlsALTERA = 5888, CapabilityFPGALoopControlsINTEL = 5888, CapabilityKernelAttributesINTEL = 5892, CapabilityFPGAKernelAttributesINTEL = 5897, + CapabilityFPGAMemoryAccessesALTERA = 5898, CapabilityFPGAMemoryAccessesINTEL = 5898, + CapabilityFPGAClusterAttributesALTERA = 5904, CapabilityFPGAClusterAttributesINTEL = 5904, + CapabilityLoopFuseALTERA = 5906, CapabilityLoopFuseINTEL = 5906, + CapabilityFPGADSPControlALTERA = 5908, CapabilityFPGADSPControlINTEL = 5908, CapabilityMemoryAccessAliasingINTEL = 5910, + CapabilityFPGAInvocationPipeliningAttributesALTERA = 5916, CapabilityFPGAInvocationPipeliningAttributesINTEL = 5916, + CapabilityFPGABufferLocationALTERA = 5920, CapabilityFPGABufferLocationINTEL = 5920, + CapabilityArbitraryPrecisionFixedPointALTERA = 5922, CapabilityArbitraryPrecisionFixedPointINTEL = 5922, + CapabilityUSMStorageClassesALTERA = 5935, CapabilityUSMStorageClassesINTEL = 5935, + CapabilityRuntimeAlignedAttributeALTERA = 5939, CapabilityRuntimeAlignedAttributeINTEL = 5939, + CapabilityIOPipesALTERA = 5943, CapabilityIOPipesINTEL = 5943, + CapabilityBlockingPipesALTERA = 5945, CapabilityBlockingPipesINTEL = 5945, + CapabilityFPGARegALTERA = 5948, CapabilityFPGARegINTEL = 5948, CapabilityDotProductInputAll = 6016, CapabilityDotProductInputAllKHR = 6016, @@ -1267,13 +1370,18 @@ enum Capability { CapabilityBFloat16ConversionINTEL = 6115, CapabilitySplitBarrierINTEL = 6141, CapabilityArithmeticFenceEXT = 6144, + CapabilityFPGAClusterAttributesV2ALTERA = 6150, CapabilityFPGAClusterAttributesV2INTEL = 6150, CapabilityFPGAKernelAttributesv2INTEL = 6161, + CapabilityTaskSequenceALTERA = 6162, CapabilityTaskSequenceINTEL = 6162, CapabilityFPMaxErrorINTEL = 6169, + CapabilityFPGALatencyControlALTERA = 6171, CapabilityFPGALatencyControlINTEL = 6171, + CapabilityFPGAArgumentInterfacesALTERA = 6174, CapabilityFPGAArgumentInterfacesINTEL = 6174, CapabilityGlobalVariableHostAccessINTEL = 6187, + CapabilityGlobalVariableFPGADecorationsALTERA = 6189, CapabilityGlobalVariableFPGADecorationsINTEL = 6189, CapabilitySubgroupBufferPrefetchINTEL = 6220, CapabilitySubgroup2DBlockIOINTEL = 6228, @@ -1290,6 +1398,10 @@ enum Capability { CapabilityCacheControlsINTEL = 6441, CapabilityRegisterLimitsINTEL = 6460, CapabilityBindlessImagesINTEL = 6528, + CapabilityDotProductFloat16AccFloat32VALVE = 6912, + CapabilityDotProductFloat16AccFloat16VALVE = 6913, + CapabilityDotProductBFloat16AccVALVE = 6914, + CapabilityDotProductFloat8AccFloat32VALVE = 6915, CapabilityMax = 0x7fffffff, }; @@ -1485,7 +1597,9 @@ enum TensorOperandsMask { }; enum InitializationModeQualifier { + InitializationModeQualifierInitOnDeviceReprogramALTERA = 0, InitializationModeQualifierInitOnDeviceReprogramINTEL = 0, + InitializationModeQualifierInitOnDeviceResetALTERA = 1, InitializationModeQualifierInitOnDeviceResetINTEL = 1, InitializationModeQualifierMax = 0x7fffffff, }; @@ -2045,6 +2159,16 @@ enum Op { OpSpecConstantStringAMDX = 5104, OpGroupNonUniformQuadAllKHR = 5110, OpGroupNonUniformQuadAnyKHR = 5111, + OpTypeBufferEXT = 5115, + OpBufferPointerEXT = 5119, + OpAbortKHR = 5121, + OpUntypedImageTexelPointerEXT = 5126, + OpMemberDecorateIdEXT = 5127, + OpConstantSizeOfEXT = 5129, + OpConstantDataKHR = 5147, + OpSpecConstantDataKHR = 5148, + OpPoisonKHR = 5158, + OpFreezeKHR = 5159, OpHitObjectRecordHitMotionNV = 5249, OpHitObjectRecordHitWithIndexMotionNV = 5250, OpHitObjectRecordMissMotionNV = 5251, @@ -2080,6 +2204,7 @@ enum Op { OpTypeHitObjectNV = 5281, OpImageSampleFootprintNV = 5283, OpTypeCooperativeVectorNV = 5288, + OpTypeVectorIdEXT = 5288, OpCooperativeVectorMatrixMulNV = 5289, OpCooperativeVectorOuterProductAccumulateNV = 5290, OpCooperativeVectorReduceSumAccumulateNV = 5291, @@ -2087,12 +2212,43 @@ enum Op { OpCooperativeMatrixConvertNV = 5293, OpEmitMeshTasksEXT = 5294, OpSetMeshOutputsEXT = 5295, + OpGroupNonUniformPartitionEXT = 5296, OpGroupNonUniformPartitionNV = 5296, OpWritePackedPrimitiveIndices4x8NV = 5299, OpFetchMicroTriangleVertexPositionNV = 5300, OpFetchMicroTriangleVertexBarycentricNV = 5301, OpCooperativeVectorLoadNV = 5302, OpCooperativeVectorStoreNV = 5303, + OpHitObjectRecordFromQueryEXT = 5304, + OpHitObjectRecordMissEXT = 5305, + OpHitObjectRecordMissMotionEXT = 5306, + OpHitObjectGetIntersectionTriangleVertexPositionsEXT = 5307, + OpHitObjectGetRayFlagsEXT = 5308, + OpHitObjectSetShaderBindingTableRecordIndexEXT = 5309, + OpHitObjectReorderExecuteShaderEXT = 5310, + OpHitObjectTraceReorderExecuteEXT = 5311, + OpHitObjectTraceMotionReorderExecuteEXT = 5312, + OpTypeHitObjectEXT = 5313, + OpReorderThreadWithHintEXT = 5314, + OpReorderThreadWithHitObjectEXT = 5315, + OpHitObjectTraceRayEXT = 5316, + OpHitObjectTraceRayMotionEXT = 5317, + OpHitObjectRecordEmptyEXT = 5318, + OpHitObjectExecuteShaderEXT = 5319, + OpHitObjectGetCurrentTimeEXT = 5320, + OpHitObjectGetAttributesEXT = 5321, + OpHitObjectGetHitKindEXT = 5322, + OpHitObjectGetPrimitiveIndexEXT = 5323, + OpHitObjectGetGeometryIndexEXT = 5324, + OpHitObjectGetInstanceIdEXT = 5325, + OpHitObjectGetInstanceCustomIndexEXT = 5326, + OpHitObjectGetObjectRayOriginEXT = 5327, + OpHitObjectGetObjectRayDirectionEXT = 5328, + OpHitObjectGetWorldRayDirectionEXT = 5329, + OpHitObjectGetWorldRayOriginEXT = 5330, + OpHitObjectGetObjectToWorldEXT = 5331, + OpHitObjectGetWorldToObjectEXT = 5332, + OpHitObjectGetRayTMaxEXT = 5333, OpReportIntersectionKHR = 5334, OpReportIntersectionNV = 5334, OpIgnoreIntersectionNV = 5335, @@ -2107,6 +2263,12 @@ enum Op { OpRayQueryGetClusterIdNV = 5345, OpRayQueryGetIntersectionClusterIdNV = 5345, OpHitObjectGetClusterIdNV = 5346, + OpHitObjectGetRayTMinEXT = 5347, + OpHitObjectGetShaderBindingTableRecordIndexEXT = 5348, + OpHitObjectGetShaderRecordBufferHandleEXT = 5349, + OpHitObjectIsEmptyEXT = 5350, + OpHitObjectIsHitEXT = 5351, + OpHitObjectIsMissEXT = 5352, OpTypeCooperativeMatrixNV = 5358, OpCooperativeMatrixLoadNV = 5359, OpCooperativeMatrixStoreNV = 5360, @@ -2313,23 +2475,41 @@ enum Op { OpVariableLengthArrayINTEL = 5818, OpSaveMemoryINTEL = 5819, OpRestoreMemoryINTEL = 5820, + OpArbitraryFloatSinCosPiALTERA = 5840, OpArbitraryFloatSinCosPiINTEL = 5840, + OpArbitraryFloatCastALTERA = 5841, OpArbitraryFloatCastINTEL = 5841, + OpArbitraryFloatCastFromIntALTERA = 5842, OpArbitraryFloatCastFromIntINTEL = 5842, + OpArbitraryFloatCastToIntALTERA = 5843, OpArbitraryFloatCastToIntINTEL = 5843, + OpArbitraryFloatAddALTERA = 5846, OpArbitraryFloatAddINTEL = 5846, + OpArbitraryFloatSubALTERA = 5847, OpArbitraryFloatSubINTEL = 5847, + OpArbitraryFloatMulALTERA = 5848, OpArbitraryFloatMulINTEL = 5848, + OpArbitraryFloatDivALTERA = 5849, OpArbitraryFloatDivINTEL = 5849, + OpArbitraryFloatGTALTERA = 5850, OpArbitraryFloatGTINTEL = 5850, + OpArbitraryFloatGEALTERA = 5851, OpArbitraryFloatGEINTEL = 5851, + OpArbitraryFloatLTALTERA = 5852, OpArbitraryFloatLTINTEL = 5852, + OpArbitraryFloatLEALTERA = 5853, OpArbitraryFloatLEINTEL = 5853, + OpArbitraryFloatEQALTERA = 5854, OpArbitraryFloatEQINTEL = 5854, + OpArbitraryFloatRecipALTERA = 5855, OpArbitraryFloatRecipINTEL = 5855, + OpArbitraryFloatRSqrtALTERA = 5856, OpArbitraryFloatRSqrtINTEL = 5856, + OpArbitraryFloatCbrtALTERA = 5857, OpArbitraryFloatCbrtINTEL = 5857, + OpArbitraryFloatHypotALTERA = 5858, OpArbitraryFloatHypotINTEL = 5858, + OpArbitraryFloatSqrtALTERA = 5859, OpArbitraryFloatSqrtINTEL = 5859, OpArbitraryFloatLogINTEL = 5860, OpArbitraryFloatLog2INTEL = 5861, @@ -2358,21 +2538,37 @@ enum Op { OpAliasDomainDeclINTEL = 5911, OpAliasScopeDeclINTEL = 5912, OpAliasScopeListDeclINTEL = 5913, + OpFixedSqrtALTERA = 5923, OpFixedSqrtINTEL = 5923, + OpFixedRecipALTERA = 5924, OpFixedRecipINTEL = 5924, + OpFixedRsqrtALTERA = 5925, OpFixedRsqrtINTEL = 5925, + OpFixedSinALTERA = 5926, OpFixedSinINTEL = 5926, + OpFixedCosALTERA = 5927, OpFixedCosINTEL = 5927, + OpFixedSinCosALTERA = 5928, OpFixedSinCosINTEL = 5928, + OpFixedSinPiALTERA = 5929, OpFixedSinPiINTEL = 5929, + OpFixedCosPiALTERA = 5930, OpFixedCosPiINTEL = 5930, + OpFixedSinCosPiALTERA = 5931, OpFixedSinCosPiINTEL = 5931, + OpFixedLogALTERA = 5932, OpFixedLogINTEL = 5932, + OpFixedExpALTERA = 5933, OpFixedExpINTEL = 5933, + OpPtrCastToCrossWorkgroupALTERA = 5934, OpPtrCastToCrossWorkgroupINTEL = 5934, + OpCrossWorkgroupCastToPtrALTERA = 5938, OpCrossWorkgroupCastToPtrINTEL = 5938, + OpReadPipeBlockingALTERA = 5946, OpReadPipeBlockingINTEL = 5946, + OpWritePipeBlockingALTERA = 5947, OpWritePipeBlockingINTEL = 5947, + OpFPGARegALTERA = 5949, OpFPGARegINTEL = 5949, OpRayQueryGetRayTMinKHR = 6016, OpRayQueryGetRayFlagsKHR = 6017, @@ -2402,10 +2598,15 @@ enum Op { OpControlBarrierArriveINTEL = 6142, OpControlBarrierWaitINTEL = 6143, OpArithmeticFenceEXT = 6145, + OpTaskSequenceCreateALTERA = 6163, OpTaskSequenceCreateINTEL = 6163, + OpTaskSequenceAsyncALTERA = 6164, OpTaskSequenceAsyncINTEL = 6164, + OpTaskSequenceGetALTERA = 6165, OpTaskSequenceGetINTEL = 6165, + OpTaskSequenceReleaseALTERA = 6166, OpTaskSequenceReleaseINTEL = 6166, + OpTypeTaskSequenceALTERA = 6199, OpTypeTaskSequenceINTEL = 6199, OpSubgroupBlockPrefetchINTEL = 6221, OpSubgroup2DBlockLoadINTEL = 6231, @@ -2437,6 +2638,9 @@ enum Op { OpConvertHandleToImageINTEL = 6529, OpConvertHandleToSamplerINTEL = 6530, OpConvertHandleToSampledImageINTEL = 6531, + OpFDot2MixAcc32VALVE = 6916, + OpFDot2MixAcc16VALVE = 6917, + OpFDot4MixAcc32VALVE = 6918, OpMax = 0x7fffffff, }; @@ -2884,6 +3088,16 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpSpecConstantStringAMDX: *hasResult = true; *hasResultType = false; break; case OpGroupNonUniformQuadAllKHR: *hasResult = true; *hasResultType = true; break; case OpGroupNonUniformQuadAnyKHR: *hasResult = true; *hasResultType = true; break; + case OpTypeBufferEXT: *hasResult = true; *hasResultType = false; break; + case OpBufferPointerEXT: *hasResult = true; *hasResultType = true; break; + case OpAbortKHR: *hasResult = false; *hasResultType = false; break; + case OpUntypedImageTexelPointerEXT: *hasResult = true; *hasResultType = true; break; + case OpMemberDecorateIdEXT: *hasResult = false; *hasResultType = false; break; + case OpConstantSizeOfEXT: *hasResult = true; *hasResultType = true; break; + case OpConstantDataKHR: *hasResult = true; *hasResultType = true; break; + case OpSpecConstantDataKHR: *hasResult = true; *hasResultType = true; break; + case OpPoisonKHR: *hasResult = true; *hasResultType = true; break; + case OpFreezeKHR: *hasResult = true; *hasResultType = true; break; case OpHitObjectRecordHitMotionNV: *hasResult = false; *hasResultType = false; break; case OpHitObjectRecordHitWithIndexMotionNV: *hasResult = false; *hasResultType = false; break; case OpHitObjectRecordMissMotionNV: *hasResult = false; *hasResultType = false; break; @@ -2918,7 +3132,7 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpReorderThreadWithHintNV: *hasResult = false; *hasResultType = false; break; case OpTypeHitObjectNV: *hasResult = true; *hasResultType = false; break; case OpImageSampleFootprintNV: *hasResult = true; *hasResultType = true; break; - case OpTypeCooperativeVectorNV: *hasResult = true; *hasResultType = false; break; + case OpTypeVectorIdEXT: *hasResult = true; *hasResultType = false; break; case OpCooperativeVectorMatrixMulNV: *hasResult = true; *hasResultType = true; break; case OpCooperativeVectorOuterProductAccumulateNV: *hasResult = false; *hasResultType = false; break; case OpCooperativeVectorReduceSumAccumulateNV: *hasResult = false; *hasResultType = false; break; @@ -2926,12 +3140,42 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpCooperativeMatrixConvertNV: *hasResult = true; *hasResultType = true; break; case OpEmitMeshTasksEXT: *hasResult = false; *hasResultType = false; break; case OpSetMeshOutputsEXT: *hasResult = false; *hasResultType = false; break; - case OpGroupNonUniformPartitionNV: *hasResult = true; *hasResultType = true; break; + case OpGroupNonUniformPartitionEXT: *hasResult = true; *hasResultType = true; break; case OpWritePackedPrimitiveIndices4x8NV: *hasResult = false; *hasResultType = false; break; case OpFetchMicroTriangleVertexPositionNV: *hasResult = true; *hasResultType = true; break; case OpFetchMicroTriangleVertexBarycentricNV: *hasResult = true; *hasResultType = true; break; case OpCooperativeVectorLoadNV: *hasResult = true; *hasResultType = true; break; case OpCooperativeVectorStoreNV: *hasResult = false; *hasResultType = false; break; + case OpHitObjectRecordFromQueryEXT: *hasResult = false; *hasResultType = false; break; + case OpHitObjectRecordMissEXT: *hasResult = false; *hasResultType = false; break; + case OpHitObjectRecordMissMotionEXT: *hasResult = false; *hasResultType = false; break; + case OpHitObjectGetIntersectionTriangleVertexPositionsEXT: *hasResult = true; *hasResultType = true; break; + case OpHitObjectGetRayFlagsEXT: *hasResult = true; *hasResultType = true; break; + case OpHitObjectSetShaderBindingTableRecordIndexEXT: *hasResult = false; *hasResultType = false; break; + case OpHitObjectReorderExecuteShaderEXT: *hasResult = false; *hasResultType = false; break; + case OpHitObjectTraceReorderExecuteEXT: *hasResult = false; *hasResultType = false; break; + case OpHitObjectTraceMotionReorderExecuteEXT: *hasResult = false; *hasResultType = false; break; + case OpTypeHitObjectEXT: *hasResult = true; *hasResultType = false; break; + case OpReorderThreadWithHintEXT: *hasResult = false; *hasResultType = false; break; + case OpReorderThreadWithHitObjectEXT: *hasResult = false; *hasResultType = false; break; + case OpHitObjectTraceRayEXT: *hasResult = false; *hasResultType = false; break; + case OpHitObjectTraceRayMotionEXT: *hasResult = false; *hasResultType = false; break; + case OpHitObjectRecordEmptyEXT: *hasResult = false; *hasResultType = false; break; + case OpHitObjectExecuteShaderEXT: *hasResult = false; *hasResultType = false; break; + case OpHitObjectGetCurrentTimeEXT: *hasResult = true; *hasResultType = true; break; + case OpHitObjectGetAttributesEXT: *hasResult = false; *hasResultType = false; break; + case OpHitObjectGetHitKindEXT: *hasResult = true; *hasResultType = true; break; + case OpHitObjectGetPrimitiveIndexEXT: *hasResult = true; *hasResultType = true; break; + case OpHitObjectGetGeometryIndexEXT: *hasResult = true; *hasResultType = true; break; + case OpHitObjectGetInstanceIdEXT: *hasResult = true; *hasResultType = true; break; + case OpHitObjectGetInstanceCustomIndexEXT: *hasResult = true; *hasResultType = true; break; + case OpHitObjectGetObjectRayOriginEXT: *hasResult = true; *hasResultType = true; break; + case OpHitObjectGetObjectRayDirectionEXT: *hasResult = true; *hasResultType = true; break; + case OpHitObjectGetWorldRayDirectionEXT: *hasResult = true; *hasResultType = true; break; + case OpHitObjectGetWorldRayOriginEXT: *hasResult = true; *hasResultType = true; break; + case OpHitObjectGetObjectToWorldEXT: *hasResult = true; *hasResultType = true; break; + case OpHitObjectGetWorldToObjectEXT: *hasResult = true; *hasResultType = true; break; + case OpHitObjectGetRayTMaxEXT: *hasResult = true; *hasResultType = true; break; case OpReportIntersectionKHR: *hasResult = true; *hasResultType = true; break; case OpIgnoreIntersectionNV: *hasResult = false; *hasResultType = false; break; case OpTerminateRayNV: *hasResult = false; *hasResultType = false; break; @@ -2943,6 +3187,12 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpExecuteCallableNV: *hasResult = false; *hasResultType = false; break; case OpRayQueryGetIntersectionClusterIdNV: *hasResult = true; *hasResultType = true; break; case OpHitObjectGetClusterIdNV: *hasResult = true; *hasResultType = true; break; + case OpHitObjectGetRayTMinEXT: *hasResult = true; *hasResultType = true; break; + case OpHitObjectGetShaderBindingTableRecordIndexEXT: *hasResult = true; *hasResultType = true; break; + case OpHitObjectGetShaderRecordBufferHandleEXT: *hasResult = true; *hasResultType = true; break; + case OpHitObjectIsEmptyEXT: *hasResult = true; *hasResultType = true; break; + case OpHitObjectIsHitEXT: *hasResult = true; *hasResultType = true; break; + case OpHitObjectIsMissEXT: *hasResult = true; *hasResultType = true; break; case OpTypeCooperativeMatrixNV: *hasResult = true; *hasResultType = false; break; case OpCooperativeMatrixLoadNV: *hasResult = true; *hasResultType = true; break; case OpCooperativeMatrixStoreNV: *hasResult = false; *hasResultType = false; break; @@ -3146,24 +3396,24 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpVariableLengthArrayINTEL: *hasResult = true; *hasResultType = true; break; case OpSaveMemoryINTEL: *hasResult = true; *hasResultType = true; break; case OpRestoreMemoryINTEL: *hasResult = false; *hasResultType = false; break; - case OpArbitraryFloatSinCosPiINTEL: *hasResult = true; *hasResultType = true; break; - case OpArbitraryFloatCastINTEL: *hasResult = true; *hasResultType = true; break; - case OpArbitraryFloatCastFromIntINTEL: *hasResult = true; *hasResultType = true; break; - case OpArbitraryFloatCastToIntINTEL: *hasResult = true; *hasResultType = true; break; - case OpArbitraryFloatAddINTEL: *hasResult = true; *hasResultType = true; break; - case OpArbitraryFloatSubINTEL: *hasResult = true; *hasResultType = true; break; - case OpArbitraryFloatMulINTEL: *hasResult = true; *hasResultType = true; break; - case OpArbitraryFloatDivINTEL: *hasResult = true; *hasResultType = true; break; - case OpArbitraryFloatGTINTEL: *hasResult = true; *hasResultType = true; break; - case OpArbitraryFloatGEINTEL: *hasResult = true; *hasResultType = true; break; - case OpArbitraryFloatLTINTEL: *hasResult = true; *hasResultType = true; break; - case OpArbitraryFloatLEINTEL: *hasResult = true; *hasResultType = true; break; - case OpArbitraryFloatEQINTEL: *hasResult = true; *hasResultType = true; break; - case OpArbitraryFloatRecipINTEL: *hasResult = true; *hasResultType = true; break; - case OpArbitraryFloatRSqrtINTEL: *hasResult = true; *hasResultType = true; break; - case OpArbitraryFloatCbrtINTEL: *hasResult = true; *hasResultType = true; break; - case OpArbitraryFloatHypotINTEL: *hasResult = true; *hasResultType = true; break; - case OpArbitraryFloatSqrtINTEL: *hasResult = true; *hasResultType = true; break; + case OpArbitraryFloatSinCosPiALTERA: *hasResult = true; *hasResultType = true; break; + case OpArbitraryFloatCastALTERA: *hasResult = true; *hasResultType = true; break; + case OpArbitraryFloatCastFromIntALTERA: *hasResult = true; *hasResultType = true; break; + case OpArbitraryFloatCastToIntALTERA: *hasResult = true; *hasResultType = true; break; + case OpArbitraryFloatAddALTERA: *hasResult = true; *hasResultType = true; break; + case OpArbitraryFloatSubALTERA: *hasResult = true; *hasResultType = true; break; + case OpArbitraryFloatMulALTERA: *hasResult = true; *hasResultType = true; break; + case OpArbitraryFloatDivALTERA: *hasResult = true; *hasResultType = true; break; + case OpArbitraryFloatGTALTERA: *hasResult = true; *hasResultType = true; break; + case OpArbitraryFloatGEALTERA: *hasResult = true; *hasResultType = true; break; + case OpArbitraryFloatLTALTERA: *hasResult = true; *hasResultType = true; break; + case OpArbitraryFloatLEALTERA: *hasResult = true; *hasResultType = true; break; + case OpArbitraryFloatEQALTERA: *hasResult = true; *hasResultType = true; break; + case OpArbitraryFloatRecipALTERA: *hasResult = true; *hasResultType = true; break; + case OpArbitraryFloatRSqrtALTERA: *hasResult = true; *hasResultType = true; break; + case OpArbitraryFloatCbrtALTERA: *hasResult = true; *hasResultType = true; break; + case OpArbitraryFloatHypotALTERA: *hasResult = true; *hasResultType = true; break; + case OpArbitraryFloatSqrtALTERA: *hasResult = true; *hasResultType = true; break; case OpArbitraryFloatLogINTEL: *hasResult = true; *hasResultType = true; break; case OpArbitraryFloatLog2INTEL: *hasResult = true; *hasResultType = true; break; case OpArbitraryFloatLog10INTEL: *hasResult = true; *hasResultType = true; break; @@ -3191,22 +3441,22 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpAliasDomainDeclINTEL: *hasResult = true; *hasResultType = false; break; case OpAliasScopeDeclINTEL: *hasResult = true; *hasResultType = false; break; case OpAliasScopeListDeclINTEL: *hasResult = true; *hasResultType = false; break; - case OpFixedSqrtINTEL: *hasResult = true; *hasResultType = true; break; - case OpFixedRecipINTEL: *hasResult = true; *hasResultType = true; break; - case OpFixedRsqrtINTEL: *hasResult = true; *hasResultType = true; break; - case OpFixedSinINTEL: *hasResult = true; *hasResultType = true; break; - case OpFixedCosINTEL: *hasResult = true; *hasResultType = true; break; - case OpFixedSinCosINTEL: *hasResult = true; *hasResultType = true; break; - case OpFixedSinPiINTEL: *hasResult = true; *hasResultType = true; break; - case OpFixedCosPiINTEL: *hasResult = true; *hasResultType = true; break; - case OpFixedSinCosPiINTEL: *hasResult = true; *hasResultType = true; break; - case OpFixedLogINTEL: *hasResult = true; *hasResultType = true; break; - case OpFixedExpINTEL: *hasResult = true; *hasResultType = true; break; - case OpPtrCastToCrossWorkgroupINTEL: *hasResult = true; *hasResultType = true; break; - case OpCrossWorkgroupCastToPtrINTEL: *hasResult = true; *hasResultType = true; break; - case OpReadPipeBlockingINTEL: *hasResult = true; *hasResultType = true; break; - case OpWritePipeBlockingINTEL: *hasResult = true; *hasResultType = true; break; - case OpFPGARegINTEL: *hasResult = true; *hasResultType = true; break; + case OpFixedSqrtALTERA: *hasResult = true; *hasResultType = true; break; + case OpFixedRecipALTERA: *hasResult = true; *hasResultType = true; break; + case OpFixedRsqrtALTERA: *hasResult = true; *hasResultType = true; break; + case OpFixedSinALTERA: *hasResult = true; *hasResultType = true; break; + case OpFixedCosALTERA: *hasResult = true; *hasResultType = true; break; + case OpFixedSinCosALTERA: *hasResult = true; *hasResultType = true; break; + case OpFixedSinPiALTERA: *hasResult = true; *hasResultType = true; break; + case OpFixedCosPiALTERA: *hasResult = true; *hasResultType = true; break; + case OpFixedSinCosPiALTERA: *hasResult = true; *hasResultType = true; break; + case OpFixedLogALTERA: *hasResult = true; *hasResultType = true; break; + case OpFixedExpALTERA: *hasResult = true; *hasResultType = true; break; + case OpPtrCastToCrossWorkgroupALTERA: *hasResult = true; *hasResultType = true; break; + case OpCrossWorkgroupCastToPtrALTERA: *hasResult = true; *hasResultType = true; break; + case OpReadPipeBlockingALTERA: *hasResult = true; *hasResultType = true; break; + case OpWritePipeBlockingALTERA: *hasResult = true; *hasResultType = true; break; + case OpFPGARegALTERA: *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; @@ -3235,11 +3485,11 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpControlBarrierArriveINTEL: *hasResult = false; *hasResultType = false; break; case OpControlBarrierWaitINTEL: *hasResult = false; *hasResultType = false; break; case OpArithmeticFenceEXT: *hasResult = true; *hasResultType = true; break; - case OpTaskSequenceCreateINTEL: *hasResult = true; *hasResultType = true; break; - case OpTaskSequenceAsyncINTEL: *hasResult = false; *hasResultType = false; break; - case OpTaskSequenceGetINTEL: *hasResult = true; *hasResultType = true; break; - case OpTaskSequenceReleaseINTEL: *hasResult = false; *hasResultType = false; break; - case OpTypeTaskSequenceINTEL: *hasResult = true; *hasResultType = false; break; + case OpTaskSequenceCreateALTERA: *hasResult = true; *hasResultType = true; break; + case OpTaskSequenceAsyncALTERA: *hasResult = false; *hasResultType = false; break; + case OpTaskSequenceGetALTERA: *hasResult = true; *hasResultType = true; break; + case OpTaskSequenceReleaseALTERA: *hasResult = false; *hasResultType = false; break; + case OpTypeTaskSequenceALTERA: *hasResult = true; *hasResultType = false; break; case OpSubgroupBlockPrefetchINTEL: *hasResult = false; *hasResultType = false; break; case OpSubgroup2DBlockLoadINTEL: *hasResult = false; *hasResultType = false; break; case OpSubgroup2DBlockLoadTransformINTEL: *hasResult = false; *hasResultType = false; break; @@ -3270,6 +3520,9 @@ inline void HasResultAndType(Op opcode, bool *hasResult, bool *hasResultType) { case OpConvertHandleToImageINTEL: *hasResult = true; *hasResultType = true; break; case OpConvertHandleToSamplerINTEL: *hasResult = true; *hasResultType = true; break; case OpConvertHandleToSampledImageINTEL: *hasResult = true; *hasResultType = true; break; + case OpFDot2MixAcc32VALVE: *hasResult = true; *hasResultType = true; break; + case OpFDot2MixAcc16VALVE: *hasResult = true; *hasResultType = true; break; + case OpFDot4MixAcc32VALVE: *hasResult = true; *hasResultType = true; break; } } inline const char* SourceLanguageToString(SourceLanguage value) { @@ -3404,6 +3657,7 @@ inline const char* ExecutionModeToString(ExecutionMode value) { case ExecutionModeQuadDerivativesKHR: return "QuadDerivativesKHR"; case ExecutionModeRequireFullQuadsKHR: return "RequireFullQuadsKHR"; case ExecutionModeSharesInputWithAMDX: return "SharesInputWithAMDX"; + case ExecutionModeArithmeticPoisonKHR: return "ArithmeticPoisonKHR"; case ExecutionModeOutputLinesEXT: return "OutputLinesEXT"; case ExecutionModeOutputPrimitivesEXT: return "OutputPrimitivesEXT"; case ExecutionModeDerivativeGroupQuadsKHR: return "DerivativeGroupQuadsKHR"; @@ -3415,6 +3669,7 @@ inline const char* ExecutionModeToString(ExecutionMode value) { case ExecutionModeSampleInterlockUnorderedEXT: return "SampleInterlockUnorderedEXT"; case ExecutionModeShadingRateInterlockOrderedEXT: return "ShadingRateInterlockOrderedEXT"; case ExecutionModeShadingRateInterlockUnorderedEXT: return "ShadingRateInterlockUnorderedEXT"; + case ExecutionModeShader64BitIndexingEXT: return "Shader64BitIndexingEXT"; case ExecutionModeSharedLocalMemorySizeINTEL: return "SharedLocalMemorySizeINTEL"; case ExecutionModeRoundingModeRTPINTEL: return "RoundingModeRTPINTEL"; case ExecutionModeRoundingModeRTNINTEL: return "RoundingModeRTNINTEL"; @@ -3464,9 +3719,10 @@ inline const char* StorageClassToString(StorageClass value) { case StorageClassPhysicalStorageBuffer: return "PhysicalStorageBuffer"; case StorageClassHitObjectAttributeNV: return "HitObjectAttributeNV"; case StorageClassTaskPayloadWorkgroupEXT: return "TaskPayloadWorkgroupEXT"; + case StorageClassHitObjectAttributeEXT: return "HitObjectAttributeEXT"; case StorageClassCodeSectionINTEL: return "CodeSectionINTEL"; - case StorageClassDeviceOnlyINTEL: return "DeviceOnlyINTEL"; - case StorageClassHostOnlyINTEL: return "HostOnlyINTEL"; + case StorageClassDeviceOnlyALTERA: return "DeviceOnlyALTERA"; + case StorageClassHostOnlyALTERA: return "HostOnlyALTERA"; default: return "Unknown"; } } @@ -3648,7 +3904,7 @@ inline const char* FunctionParameterAttributeToString(FunctionParameterAttribute case FunctionParameterAttributeNoCapture: return "NoCapture"; case FunctionParameterAttributeNoWrite: return "NoWrite"; case FunctionParameterAttributeNoReadWrite: return "NoReadWrite"; - case FunctionParameterAttributeRuntimeAlignedINTEL: return "RuntimeAlignedINTEL"; + case FunctionParameterAttributeRuntimeAlignedALTERA: return "RuntimeAlignedALTERA"; default: return "Unknown"; } } @@ -3717,6 +3973,9 @@ inline const char* DecorationToString(Decoration value) { case DecorationPayloadNodeSparseArrayAMDX: return "PayloadNodeSparseArrayAMDX"; case DecorationPayloadNodeArraySizeAMDX: return "PayloadNodeArraySizeAMDX"; case DecorationPayloadDispatchIndirectAMDX: return "PayloadDispatchIndirectAMDX"; + case DecorationArrayStrideIdEXT: return "ArrayStrideIdEXT"; + case DecorationOffsetIdEXT: return "OffsetIdEXT"; + case DecorationUTFEncodedKHR: return "UTFEncodedKHR"; case DecorationOverrideCoverageNV: return "OverrideCoverageNV"; case DecorationPassthroughNV: return "PassthroughNV"; case DecorationViewportRelativeNV: return "ViewportRelativeNV"; @@ -3728,7 +3987,10 @@ inline const char* DecorationToString(Decoration value) { case DecorationNonUniform: return "NonUniform"; case DecorationRestrictPointer: return "RestrictPointer"; case DecorationAliasedPointer: return "AliasedPointer"; + case DecorationMemberOffsetNV: return "MemberOffsetNV"; case DecorationHitObjectShaderRecordBufferNV: return "HitObjectShaderRecordBufferNV"; + case DecorationHitObjectShaderRecordBufferEXT: return "HitObjectShaderRecordBufferEXT"; + case DecorationBankNV: return "BankNV"; case DecorationBindlessSamplerNV: return "BindlessSamplerNV"; case DecorationBindlessImageNV: return "BindlessImageNV"; case DecorationBoundSamplerNV: return "BoundSamplerNV"; @@ -3747,55 +4009,55 @@ inline const char* DecorationToString(Decoration value) { case DecorationUserTypeGOOGLE: return "UserTypeGOOGLE"; case DecorationFunctionRoundingModeINTEL: return "FunctionRoundingModeINTEL"; case DecorationFunctionDenormModeINTEL: return "FunctionDenormModeINTEL"; - case DecorationRegisterINTEL: return "RegisterINTEL"; - case DecorationMemoryINTEL: return "MemoryINTEL"; - case DecorationNumbanksINTEL: return "NumbanksINTEL"; - case DecorationBankwidthINTEL: return "BankwidthINTEL"; - case DecorationMaxPrivateCopiesINTEL: return "MaxPrivateCopiesINTEL"; - case DecorationSinglepumpINTEL: return "SinglepumpINTEL"; - case DecorationDoublepumpINTEL: return "DoublepumpINTEL"; - case DecorationMaxReplicatesINTEL: return "MaxReplicatesINTEL"; - case DecorationSimpleDualPortINTEL: return "SimpleDualPortINTEL"; - case DecorationMergeINTEL: return "MergeINTEL"; - case DecorationBankBitsINTEL: return "BankBitsINTEL"; - case DecorationForcePow2DepthINTEL: return "ForcePow2DepthINTEL"; - case DecorationStridesizeINTEL: return "StridesizeINTEL"; - case DecorationWordsizeINTEL: return "WordsizeINTEL"; - case DecorationTrueDualPortINTEL: return "TrueDualPortINTEL"; - case DecorationBurstCoalesceINTEL: return "BurstCoalesceINTEL"; - case DecorationCacheSizeINTEL: return "CacheSizeINTEL"; - case DecorationDontStaticallyCoalesceINTEL: return "DontStaticallyCoalesceINTEL"; - case DecorationPrefetchINTEL: return "PrefetchINTEL"; - case DecorationStallEnableINTEL: return "StallEnableINTEL"; - case DecorationFuseLoopsInFunctionINTEL: return "FuseLoopsInFunctionINTEL"; - case DecorationMathOpDSPModeINTEL: return "MathOpDSPModeINTEL"; + case DecorationRegisterALTERA: return "RegisterALTERA"; + case DecorationMemoryALTERA: return "MemoryALTERA"; + case DecorationNumbanksALTERA: return "NumbanksALTERA"; + case DecorationBankwidthALTERA: return "BankwidthALTERA"; + case DecorationMaxPrivateCopiesALTERA: return "MaxPrivateCopiesALTERA"; + case DecorationSinglepumpALTERA: return "SinglepumpALTERA"; + case DecorationDoublepumpALTERA: return "DoublepumpALTERA"; + case DecorationMaxReplicatesALTERA: return "MaxReplicatesALTERA"; + case DecorationSimpleDualPortALTERA: return "SimpleDualPortALTERA"; + case DecorationMergeALTERA: return "MergeALTERA"; + case DecorationBankBitsALTERA: return "BankBitsALTERA"; + case DecorationForcePow2DepthALTERA: return "ForcePow2DepthALTERA"; + case DecorationStridesizeALTERA: return "StridesizeALTERA"; + case DecorationWordsizeALTERA: return "WordsizeALTERA"; + case DecorationTrueDualPortALTERA: return "TrueDualPortALTERA"; + case DecorationBurstCoalesceALTERA: return "BurstCoalesceALTERA"; + case DecorationCacheSizeALTERA: return "CacheSizeALTERA"; + case DecorationDontStaticallyCoalesceALTERA: return "DontStaticallyCoalesceALTERA"; + case DecorationPrefetchALTERA: return "PrefetchALTERA"; + case DecorationStallEnableALTERA: return "StallEnableALTERA"; + case DecorationFuseLoopsInFunctionALTERA: return "FuseLoopsInFunctionALTERA"; + case DecorationMathOpDSPModeALTERA: return "MathOpDSPModeALTERA"; case DecorationAliasScopeINTEL: return "AliasScopeINTEL"; case DecorationNoAliasINTEL: return "NoAliasINTEL"; - case DecorationInitiationIntervalINTEL: return "InitiationIntervalINTEL"; - case DecorationMaxConcurrencyINTEL: return "MaxConcurrencyINTEL"; - case DecorationPipelineEnableINTEL: return "PipelineEnableINTEL"; - case DecorationBufferLocationINTEL: return "BufferLocationINTEL"; - case DecorationIOPipeStorageINTEL: return "IOPipeStorageINTEL"; + case DecorationInitiationIntervalALTERA: return "InitiationIntervalALTERA"; + case DecorationMaxConcurrencyALTERA: return "MaxConcurrencyALTERA"; + case DecorationPipelineEnableALTERA: return "PipelineEnableALTERA"; + case DecorationBufferLocationALTERA: return "BufferLocationALTERA"; + case DecorationIOPipeStorageALTERA: return "IOPipeStorageALTERA"; case DecorationFunctionFloatingPointModeINTEL: return "FunctionFloatingPointModeINTEL"; case DecorationSingleElementVectorINTEL: return "SingleElementVectorINTEL"; case DecorationVectorComputeCallableFunctionINTEL: return "VectorComputeCallableFunctionINTEL"; case DecorationMediaBlockIOINTEL: return "MediaBlockIOINTEL"; - case DecorationStallFreeINTEL: return "StallFreeINTEL"; + case DecorationStallFreeALTERA: return "StallFreeALTERA"; case DecorationFPMaxErrorDecorationINTEL: return "FPMaxErrorDecorationINTEL"; - case DecorationLatencyControlLabelINTEL: return "LatencyControlLabelINTEL"; - case DecorationLatencyControlConstraintINTEL: return "LatencyControlConstraintINTEL"; - case DecorationConduitKernelArgumentINTEL: return "ConduitKernelArgumentINTEL"; - case DecorationRegisterMapKernelArgumentINTEL: return "RegisterMapKernelArgumentINTEL"; - case DecorationMMHostInterfaceAddressWidthINTEL: return "MMHostInterfaceAddressWidthINTEL"; - case DecorationMMHostInterfaceDataWidthINTEL: return "MMHostInterfaceDataWidthINTEL"; - case DecorationMMHostInterfaceLatencyINTEL: return "MMHostInterfaceLatencyINTEL"; - case DecorationMMHostInterfaceReadWriteModeINTEL: return "MMHostInterfaceReadWriteModeINTEL"; - case DecorationMMHostInterfaceMaxBurstINTEL: return "MMHostInterfaceMaxBurstINTEL"; - case DecorationMMHostInterfaceWaitRequestINTEL: return "MMHostInterfaceWaitRequestINTEL"; - case DecorationStableKernelArgumentINTEL: return "StableKernelArgumentINTEL"; + case DecorationLatencyControlLabelALTERA: return "LatencyControlLabelALTERA"; + case DecorationLatencyControlConstraintALTERA: return "LatencyControlConstraintALTERA"; + case DecorationConduitKernelArgumentALTERA: return "ConduitKernelArgumentALTERA"; + case DecorationRegisterMapKernelArgumentALTERA: return "RegisterMapKernelArgumentALTERA"; + case DecorationMMHostInterfaceAddressWidthALTERA: return "MMHostInterfaceAddressWidthALTERA"; + case DecorationMMHostInterfaceDataWidthALTERA: return "MMHostInterfaceDataWidthALTERA"; + case DecorationMMHostInterfaceLatencyALTERA: return "MMHostInterfaceLatencyALTERA"; + case DecorationMMHostInterfaceReadWriteModeALTERA: return "MMHostInterfaceReadWriteModeALTERA"; + case DecorationMMHostInterfaceMaxBurstALTERA: return "MMHostInterfaceMaxBurstALTERA"; + case DecorationMMHostInterfaceWaitRequestALTERA: return "MMHostInterfaceWaitRequestALTERA"; + case DecorationStableKernelArgumentALTERA: return "StableKernelArgumentALTERA"; case DecorationHostAccessINTEL: return "HostAccessINTEL"; - case DecorationInitModeINTEL: return "InitModeINTEL"; - case DecorationImplementInRegisterMapINTEL: return "ImplementInRegisterMapINTEL"; + case DecorationInitModeALTERA: return "InitModeALTERA"; + case DecorationImplementInRegisterMapALTERA: return "ImplementInRegisterMapALTERA"; case DecorationConditionalINTEL: return "ConditionalINTEL"; case DecorationCacheControlLoadINTEL: return "CacheControlLoadINTEL"; case DecorationCacheControlStoreINTEL: return "CacheControlStoreINTEL"; @@ -3876,6 +4138,8 @@ inline const char* BuiltInToString(BuiltIn value) { case BuiltInFragStencilRefEXT: return "FragStencilRefEXT"; case BuiltInRemainingRecursionLevelsAMDX: return "RemainingRecursionLevelsAMDX"; case BuiltInShaderIndexAMDX: return "ShaderIndexAMDX"; + case BuiltInSamplerHeapEXT: return "SamplerHeapEXT"; + case BuiltInResourceHeapEXT: return "ResourceHeapEXT"; case BuiltInViewportMaskNV: return "ViewportMaskNV"; case BuiltInSecondaryPositionNV: return "SecondaryPositionNV"; case BuiltInSecondaryViewportMaskNV: return "SecondaryViewportMaskNV"; @@ -3954,9 +4218,9 @@ inline const char* GroupOperationToString(GroupOperation value) { case GroupOperationInclusiveScan: return "InclusiveScan"; case GroupOperationExclusiveScan: return "ExclusiveScan"; case GroupOperationClusteredReduce: return "ClusteredReduce"; - case GroupOperationPartitionedReduceNV: return "PartitionedReduceNV"; - case GroupOperationPartitionedInclusiveScanNV: return "PartitionedInclusiveScanNV"; - case GroupOperationPartitionedExclusiveScanNV: return "PartitionedExclusiveScanNV"; + case GroupOperationPartitionedReduceEXT: return "PartitionedReduceEXT"; + case GroupOperationPartitionedInclusiveScanEXT: return "PartitionedInclusiveScanEXT"; + case GroupOperationPartitionedExclusiveScanEXT: return "PartitionedExclusiveScanEXT"; default: return "Unknown"; } } @@ -4103,6 +4367,10 @@ inline const char* CapabilityToString(Capability value) { case CapabilityBFloat16TypeKHR: return "BFloat16TypeKHR"; case CapabilityBFloat16DotProductKHR: return "BFloat16DotProductKHR"; case CapabilityBFloat16CooperativeMatrixKHR: return "BFloat16CooperativeMatrixKHR"; + case CapabilityAbortKHR: return "AbortKHR"; + case CapabilityDescriptorHeapEXT: return "DescriptorHeapEXT"; + case CapabilityConstantDataKHR: return "ConstantDataKHR"; + case CapabilityPoisonFreezeKHR: return "PoisonFreezeKHR"; case CapabilitySampleMaskOverrideCoverageNV: return "SampleMaskOverrideCoverageNV"; case CapabilityGeometryShaderPassthroughNV: return "GeometryShaderPassthroughNV"; case CapabilityShaderViewportIndexLayerEXT: return "ShaderViewportIndexLayerEXT"; @@ -4116,7 +4384,7 @@ inline const char* CapabilityToString(Capability value) { case CapabilityFragmentBarycentricKHR: return "FragmentBarycentricKHR"; case CapabilityComputeDerivativeGroupQuadsKHR: return "ComputeDerivativeGroupQuadsKHR"; case CapabilityFragmentDensityEXT: return "FragmentDensityEXT"; - case CapabilityGroupNonUniformPartitionedNV: return "GroupNonUniformPartitionedNV"; + case CapabilityGroupNonUniformPartitionedEXT: return "GroupNonUniformPartitionedEXT"; case CapabilityShaderNonUniform: return "ShaderNonUniform"; case CapabilityRuntimeDescriptorArray: return "RuntimeDescriptorArray"; case CapabilityInputAttachmentArrayDynamicIndexing: return "InputAttachmentArrayDynamicIndexing"; @@ -4146,6 +4414,7 @@ inline const char* CapabilityToString(Capability value) { case CapabilityDisplacementMicromapNV: return "DisplacementMicromapNV"; case CapabilityRayTracingOpacityMicromapEXT: return "RayTracingOpacityMicromapEXT"; case CapabilityShaderInvocationReorderNV: return "ShaderInvocationReorderNV"; + case CapabilityShaderInvocationReorderEXT: return "ShaderInvocationReorderEXT"; case CapabilityBindlessTextureNV: return "BindlessTextureNV"; case CapabilityRayQueryPositionFetchKHR: return "RayQueryPositionFetchKHR"; case CapabilityCooperativeVectorNV: return "CooperativeVectorNV"; @@ -4154,6 +4423,9 @@ inline const char* CapabilityToString(Capability value) { case CapabilityRawAccessChainsNV: return "RawAccessChainsNV"; case CapabilityRayTracingSpheresGeometryNV: return "RayTracingSpheresGeometryNV"; case CapabilityRayTracingLinearSweptSpheresGeometryNV: return "RayTracingLinearSweptSpheresGeometryNV"; + case CapabilityPushConstantBanksNV: return "PushConstantBanksNV"; + case CapabilityLongVectorEXT: return "LongVectorEXT"; + case CapabilityShader64BitIndexingEXT: return "Shader64BitIndexingEXT"; case CapabilityCooperativeMatrixReductionsNV: return "CooperativeMatrixReductionsNV"; case CapabilityCooperativeMatrixConversionsNV: return "CooperativeMatrixConversionsNV"; case CapabilityCooperativeMatrixPerElementOperationsNV: return "CooperativeMatrixPerElementOperationsNV"; @@ -4183,27 +4455,27 @@ inline const char* CapabilityToString(Capability value) { case CapabilitySubgroupAvcMotionEstimationChromaINTEL: return "SubgroupAvcMotionEstimationChromaINTEL"; case CapabilityVariableLengthArrayINTEL: return "VariableLengthArrayINTEL"; case CapabilityFunctionFloatControlINTEL: return "FunctionFloatControlINTEL"; - case CapabilityFPGAMemoryAttributesINTEL: return "FPGAMemoryAttributesINTEL"; + case CapabilityFPGAMemoryAttributesALTERA: return "FPGAMemoryAttributesALTERA"; case CapabilityFPFastMathModeINTEL: return "FPFastMathModeINTEL"; - case CapabilityArbitraryPrecisionIntegersINTEL: return "ArbitraryPrecisionIntegersINTEL"; - case CapabilityArbitraryPrecisionFloatingPointINTEL: return "ArbitraryPrecisionFloatingPointINTEL"; + case CapabilityArbitraryPrecisionIntegersALTERA: return "ArbitraryPrecisionIntegersALTERA"; + case CapabilityArbitraryPrecisionFloatingPointALTERA: return "ArbitraryPrecisionFloatingPointALTERA"; case CapabilityUnstructuredLoopControlsINTEL: return "UnstructuredLoopControlsINTEL"; - case CapabilityFPGALoopControlsINTEL: return "FPGALoopControlsINTEL"; + case CapabilityFPGALoopControlsALTERA: return "FPGALoopControlsALTERA"; case CapabilityKernelAttributesINTEL: return "KernelAttributesINTEL"; case CapabilityFPGAKernelAttributesINTEL: return "FPGAKernelAttributesINTEL"; - case CapabilityFPGAMemoryAccessesINTEL: return "FPGAMemoryAccessesINTEL"; - case CapabilityFPGAClusterAttributesINTEL: return "FPGAClusterAttributesINTEL"; - case CapabilityLoopFuseINTEL: return "LoopFuseINTEL"; - case CapabilityFPGADSPControlINTEL: return "FPGADSPControlINTEL"; + case CapabilityFPGAMemoryAccessesALTERA: return "FPGAMemoryAccessesALTERA"; + case CapabilityFPGAClusterAttributesALTERA: return "FPGAClusterAttributesALTERA"; + case CapabilityLoopFuseALTERA: return "LoopFuseALTERA"; + case CapabilityFPGADSPControlALTERA: return "FPGADSPControlALTERA"; case CapabilityMemoryAccessAliasingINTEL: return "MemoryAccessAliasingINTEL"; - case CapabilityFPGAInvocationPipeliningAttributesINTEL: return "FPGAInvocationPipeliningAttributesINTEL"; - case CapabilityFPGABufferLocationINTEL: return "FPGABufferLocationINTEL"; - case CapabilityArbitraryPrecisionFixedPointINTEL: return "ArbitraryPrecisionFixedPointINTEL"; - case CapabilityUSMStorageClassesINTEL: return "USMStorageClassesINTEL"; - case CapabilityRuntimeAlignedAttributeINTEL: return "RuntimeAlignedAttributeINTEL"; - case CapabilityIOPipesINTEL: return "IOPipesINTEL"; - case CapabilityBlockingPipesINTEL: return "BlockingPipesINTEL"; - case CapabilityFPGARegINTEL: return "FPGARegINTEL"; + case CapabilityFPGAInvocationPipeliningAttributesALTERA: return "FPGAInvocationPipeliningAttributesALTERA"; + case CapabilityFPGABufferLocationALTERA: return "FPGABufferLocationALTERA"; + case CapabilityArbitraryPrecisionFixedPointALTERA: return "ArbitraryPrecisionFixedPointALTERA"; + case CapabilityUSMStorageClassesALTERA: return "USMStorageClassesALTERA"; + case CapabilityRuntimeAlignedAttributeALTERA: return "RuntimeAlignedAttributeALTERA"; + case CapabilityIOPipesALTERA: return "IOPipesALTERA"; + case CapabilityBlockingPipesALTERA: return "BlockingPipesALTERA"; + case CapabilityFPGARegALTERA: return "FPGARegALTERA"; case CapabilityDotProductInputAll: return "DotProductInputAll"; case CapabilityDotProductInput4x8Bit: return "DotProductInput4x8Bit"; case CapabilityDotProductInput4x8BitPacked: return "DotProductInput4x8BitPacked"; @@ -4224,14 +4496,14 @@ inline const char* CapabilityToString(Capability value) { case CapabilityBFloat16ConversionINTEL: return "BFloat16ConversionINTEL"; case CapabilitySplitBarrierINTEL: return "SplitBarrierINTEL"; case CapabilityArithmeticFenceEXT: return "ArithmeticFenceEXT"; - case CapabilityFPGAClusterAttributesV2INTEL: return "FPGAClusterAttributesV2INTEL"; + case CapabilityFPGAClusterAttributesV2ALTERA: return "FPGAClusterAttributesV2ALTERA"; case CapabilityFPGAKernelAttributesv2INTEL: return "FPGAKernelAttributesv2INTEL"; - case CapabilityTaskSequenceINTEL: return "TaskSequenceINTEL"; + case CapabilityTaskSequenceALTERA: return "TaskSequenceALTERA"; case CapabilityFPMaxErrorINTEL: return "FPMaxErrorINTEL"; - case CapabilityFPGALatencyControlINTEL: return "FPGALatencyControlINTEL"; - case CapabilityFPGAArgumentInterfacesINTEL: return "FPGAArgumentInterfacesINTEL"; + case CapabilityFPGALatencyControlALTERA: return "FPGALatencyControlALTERA"; + case CapabilityFPGAArgumentInterfacesALTERA: return "FPGAArgumentInterfacesALTERA"; case CapabilityGlobalVariableHostAccessINTEL: return "GlobalVariableHostAccessINTEL"; - case CapabilityGlobalVariableFPGADecorationsINTEL: return "GlobalVariableFPGADecorationsINTEL"; + case CapabilityGlobalVariableFPGADecorationsALTERA: return "GlobalVariableFPGADecorationsALTERA"; case CapabilitySubgroupBufferPrefetchINTEL: return "SubgroupBufferPrefetchINTEL"; case CapabilitySubgroup2DBlockIOINTEL: return "Subgroup2DBlockIOINTEL"; case CapabilitySubgroup2DBlockTransformINTEL: return "Subgroup2DBlockTransformINTEL"; @@ -4247,6 +4519,10 @@ inline const char* CapabilityToString(Capability value) { case CapabilityCacheControlsINTEL: return "CacheControlsINTEL"; case CapabilityRegisterLimitsINTEL: return "RegisterLimitsINTEL"; case CapabilityBindlessImagesINTEL: return "BindlessImagesINTEL"; + case CapabilityDotProductFloat16AccFloat32VALVE: return "DotProductFloat16AccFloat32VALVE"; + case CapabilityDotProductFloat16AccFloat16VALVE: return "DotProductFloat16AccFloat16VALVE"; + case CapabilityDotProductBFloat16AccVALVE: return "DotProductBFloat16AccVALVE"; + case CapabilityDotProductFloat8AccFloat32VALVE: return "DotProductFloat8AccFloat32VALVE"; default: return "Unknown"; } } @@ -4355,8 +4631,8 @@ inline const char* TensorClampModeToString(TensorClampMode value) { inline const char* InitializationModeQualifierToString(InitializationModeQualifier value) { switch (value) { - case InitializationModeQualifierInitOnDeviceReprogramINTEL: return "InitOnDeviceReprogramINTEL"; - case InitializationModeQualifierInitOnDeviceResetINTEL: return "InitOnDeviceResetINTEL"; + case InitializationModeQualifierInitOnDeviceReprogramALTERA: return "InitOnDeviceReprogramALTERA"; + case InitializationModeQualifierInitOnDeviceResetALTERA: return "InitOnDeviceResetALTERA"; default: return "Unknown"; } } @@ -4877,6 +5153,16 @@ inline const char* OpToString(Op value) { case OpSpecConstantStringAMDX: return "OpSpecConstantStringAMDX"; case OpGroupNonUniformQuadAllKHR: return "OpGroupNonUniformQuadAllKHR"; case OpGroupNonUniformQuadAnyKHR: return "OpGroupNonUniformQuadAnyKHR"; + case OpTypeBufferEXT: return "OpTypeBufferEXT"; + case OpBufferPointerEXT: return "OpBufferPointerEXT"; + case OpAbortKHR: return "OpAbortKHR"; + case OpUntypedImageTexelPointerEXT: return "OpUntypedImageTexelPointerEXT"; + case OpMemberDecorateIdEXT: return "OpMemberDecorateIdEXT"; + case OpConstantSizeOfEXT: return "OpConstantSizeOfEXT"; + case OpConstantDataKHR: return "OpConstantDataKHR"; + case OpSpecConstantDataKHR: return "OpSpecConstantDataKHR"; + case OpPoisonKHR: return "OpPoisonKHR"; + case OpFreezeKHR: return "OpFreezeKHR"; case OpHitObjectRecordHitMotionNV: return "OpHitObjectRecordHitMotionNV"; case OpHitObjectRecordHitWithIndexMotionNV: return "OpHitObjectRecordHitWithIndexMotionNV"; case OpHitObjectRecordMissMotionNV: return "OpHitObjectRecordMissMotionNV"; @@ -4919,12 +5205,42 @@ inline const char* OpToString(Op value) { case OpCooperativeMatrixConvertNV: return "OpCooperativeMatrixConvertNV"; case OpEmitMeshTasksEXT: return "OpEmitMeshTasksEXT"; case OpSetMeshOutputsEXT: return "OpSetMeshOutputsEXT"; - case OpGroupNonUniformPartitionNV: return "OpGroupNonUniformPartitionNV"; + case OpGroupNonUniformPartitionEXT: return "OpGroupNonUniformPartitionEXT"; case OpWritePackedPrimitiveIndices4x8NV: return "OpWritePackedPrimitiveIndices4x8NV"; case OpFetchMicroTriangleVertexPositionNV: return "OpFetchMicroTriangleVertexPositionNV"; case OpFetchMicroTriangleVertexBarycentricNV: return "OpFetchMicroTriangleVertexBarycentricNV"; case OpCooperativeVectorLoadNV: return "OpCooperativeVectorLoadNV"; case OpCooperativeVectorStoreNV: return "OpCooperativeVectorStoreNV"; + case OpHitObjectRecordFromQueryEXT: return "OpHitObjectRecordFromQueryEXT"; + case OpHitObjectRecordMissEXT: return "OpHitObjectRecordMissEXT"; + case OpHitObjectRecordMissMotionEXT: return "OpHitObjectRecordMissMotionEXT"; + case OpHitObjectGetIntersectionTriangleVertexPositionsEXT: return "OpHitObjectGetIntersectionTriangleVertexPositionsEXT"; + case OpHitObjectGetRayFlagsEXT: return "OpHitObjectGetRayFlagsEXT"; + case OpHitObjectSetShaderBindingTableRecordIndexEXT: return "OpHitObjectSetShaderBindingTableRecordIndexEXT"; + case OpHitObjectReorderExecuteShaderEXT: return "OpHitObjectReorderExecuteShaderEXT"; + case OpHitObjectTraceReorderExecuteEXT: return "OpHitObjectTraceReorderExecuteEXT"; + case OpHitObjectTraceMotionReorderExecuteEXT: return "OpHitObjectTraceMotionReorderExecuteEXT"; + case OpTypeHitObjectEXT: return "OpTypeHitObjectEXT"; + case OpReorderThreadWithHintEXT: return "OpReorderThreadWithHintEXT"; + case OpReorderThreadWithHitObjectEXT: return "OpReorderThreadWithHitObjectEXT"; + case OpHitObjectTraceRayEXT: return "OpHitObjectTraceRayEXT"; + case OpHitObjectTraceRayMotionEXT: return "OpHitObjectTraceRayMotionEXT"; + case OpHitObjectRecordEmptyEXT: return "OpHitObjectRecordEmptyEXT"; + case OpHitObjectExecuteShaderEXT: return "OpHitObjectExecuteShaderEXT"; + case OpHitObjectGetCurrentTimeEXT: return "OpHitObjectGetCurrentTimeEXT"; + case OpHitObjectGetAttributesEXT: return "OpHitObjectGetAttributesEXT"; + case OpHitObjectGetHitKindEXT: return "OpHitObjectGetHitKindEXT"; + case OpHitObjectGetPrimitiveIndexEXT: return "OpHitObjectGetPrimitiveIndexEXT"; + case OpHitObjectGetGeometryIndexEXT: return "OpHitObjectGetGeometryIndexEXT"; + case OpHitObjectGetInstanceIdEXT: return "OpHitObjectGetInstanceIdEXT"; + case OpHitObjectGetInstanceCustomIndexEXT: return "OpHitObjectGetInstanceCustomIndexEXT"; + case OpHitObjectGetObjectRayOriginEXT: return "OpHitObjectGetObjectRayOriginEXT"; + case OpHitObjectGetObjectRayDirectionEXT: return "OpHitObjectGetObjectRayDirectionEXT"; + case OpHitObjectGetWorldRayDirectionEXT: return "OpHitObjectGetWorldRayDirectionEXT"; + case OpHitObjectGetWorldRayOriginEXT: return "OpHitObjectGetWorldRayOriginEXT"; + case OpHitObjectGetObjectToWorldEXT: return "OpHitObjectGetObjectToWorldEXT"; + case OpHitObjectGetWorldToObjectEXT: return "OpHitObjectGetWorldToObjectEXT"; + case OpHitObjectGetRayTMaxEXT: return "OpHitObjectGetRayTMaxEXT"; case OpReportIntersectionKHR: return "OpReportIntersectionKHR"; case OpIgnoreIntersectionNV: return "OpIgnoreIntersectionNV"; case OpTerminateRayNV: return "OpTerminateRayNV"; @@ -4936,6 +5252,12 @@ inline const char* OpToString(Op value) { case OpExecuteCallableNV: return "OpExecuteCallableNV"; case OpRayQueryGetClusterIdNV: return "OpRayQueryGetClusterIdNV"; case OpHitObjectGetClusterIdNV: return "OpHitObjectGetClusterIdNV"; + case OpHitObjectGetRayTMinEXT: return "OpHitObjectGetRayTMinEXT"; + case OpHitObjectGetShaderBindingTableRecordIndexEXT: return "OpHitObjectGetShaderBindingTableRecordIndexEXT"; + case OpHitObjectGetShaderRecordBufferHandleEXT: return "OpHitObjectGetShaderRecordBufferHandleEXT"; + case OpHitObjectIsEmptyEXT: return "OpHitObjectIsEmptyEXT"; + case OpHitObjectIsHitEXT: return "OpHitObjectIsHitEXT"; + case OpHitObjectIsMissEXT: return "OpHitObjectIsMissEXT"; case OpTypeCooperativeMatrixNV: return "OpTypeCooperativeMatrixNV"; case OpCooperativeMatrixLoadNV: return "OpCooperativeMatrixLoadNV"; case OpCooperativeMatrixStoreNV: return "OpCooperativeMatrixStoreNV"; @@ -5139,24 +5461,24 @@ inline const char* OpToString(Op value) { case OpVariableLengthArrayINTEL: return "OpVariableLengthArrayINTEL"; case OpSaveMemoryINTEL: return "OpSaveMemoryINTEL"; case OpRestoreMemoryINTEL: return "OpRestoreMemoryINTEL"; - case OpArbitraryFloatSinCosPiINTEL: return "OpArbitraryFloatSinCosPiINTEL"; - case OpArbitraryFloatCastINTEL: return "OpArbitraryFloatCastINTEL"; - case OpArbitraryFloatCastFromIntINTEL: return "OpArbitraryFloatCastFromIntINTEL"; - case OpArbitraryFloatCastToIntINTEL: return "OpArbitraryFloatCastToIntINTEL"; - case OpArbitraryFloatAddINTEL: return "OpArbitraryFloatAddINTEL"; - case OpArbitraryFloatSubINTEL: return "OpArbitraryFloatSubINTEL"; - case OpArbitraryFloatMulINTEL: return "OpArbitraryFloatMulINTEL"; - case OpArbitraryFloatDivINTEL: return "OpArbitraryFloatDivINTEL"; - case OpArbitraryFloatGTINTEL: return "OpArbitraryFloatGTINTEL"; - case OpArbitraryFloatGEINTEL: return "OpArbitraryFloatGEINTEL"; - case OpArbitraryFloatLTINTEL: return "OpArbitraryFloatLTINTEL"; - case OpArbitraryFloatLEINTEL: return "OpArbitraryFloatLEINTEL"; - case OpArbitraryFloatEQINTEL: return "OpArbitraryFloatEQINTEL"; - case OpArbitraryFloatRecipINTEL: return "OpArbitraryFloatRecipINTEL"; - case OpArbitraryFloatRSqrtINTEL: return "OpArbitraryFloatRSqrtINTEL"; - case OpArbitraryFloatCbrtINTEL: return "OpArbitraryFloatCbrtINTEL"; - case OpArbitraryFloatHypotINTEL: return "OpArbitraryFloatHypotINTEL"; - case OpArbitraryFloatSqrtINTEL: return "OpArbitraryFloatSqrtINTEL"; + case OpArbitraryFloatSinCosPiALTERA: return "OpArbitraryFloatSinCosPiALTERA"; + case OpArbitraryFloatCastALTERA: return "OpArbitraryFloatCastALTERA"; + case OpArbitraryFloatCastFromIntALTERA: return "OpArbitraryFloatCastFromIntALTERA"; + case OpArbitraryFloatCastToIntALTERA: return "OpArbitraryFloatCastToIntALTERA"; + case OpArbitraryFloatAddALTERA: return "OpArbitraryFloatAddALTERA"; + case OpArbitraryFloatSubALTERA: return "OpArbitraryFloatSubALTERA"; + case OpArbitraryFloatMulALTERA: return "OpArbitraryFloatMulALTERA"; + case OpArbitraryFloatDivALTERA: return "OpArbitraryFloatDivALTERA"; + case OpArbitraryFloatGTALTERA: return "OpArbitraryFloatGTALTERA"; + case OpArbitraryFloatGEALTERA: return "OpArbitraryFloatGEALTERA"; + case OpArbitraryFloatLTALTERA: return "OpArbitraryFloatLTALTERA"; + case OpArbitraryFloatLEALTERA: return "OpArbitraryFloatLEALTERA"; + case OpArbitraryFloatEQALTERA: return "OpArbitraryFloatEQALTERA"; + case OpArbitraryFloatRecipALTERA: return "OpArbitraryFloatRecipALTERA"; + case OpArbitraryFloatRSqrtALTERA: return "OpArbitraryFloatRSqrtALTERA"; + case OpArbitraryFloatCbrtALTERA: return "OpArbitraryFloatCbrtALTERA"; + case OpArbitraryFloatHypotALTERA: return "OpArbitraryFloatHypotALTERA"; + case OpArbitraryFloatSqrtALTERA: return "OpArbitraryFloatSqrtALTERA"; case OpArbitraryFloatLogINTEL: return "OpArbitraryFloatLogINTEL"; case OpArbitraryFloatLog2INTEL: return "OpArbitraryFloatLog2INTEL"; case OpArbitraryFloatLog10INTEL: return "OpArbitraryFloatLog10INTEL"; @@ -5184,22 +5506,22 @@ inline const char* OpToString(Op value) { case OpAliasDomainDeclINTEL: return "OpAliasDomainDeclINTEL"; case OpAliasScopeDeclINTEL: return "OpAliasScopeDeclINTEL"; case OpAliasScopeListDeclINTEL: return "OpAliasScopeListDeclINTEL"; - case OpFixedSqrtINTEL: return "OpFixedSqrtINTEL"; - case OpFixedRecipINTEL: return "OpFixedRecipINTEL"; - case OpFixedRsqrtINTEL: return "OpFixedRsqrtINTEL"; - case OpFixedSinINTEL: return "OpFixedSinINTEL"; - case OpFixedCosINTEL: return "OpFixedCosINTEL"; - case OpFixedSinCosINTEL: return "OpFixedSinCosINTEL"; - case OpFixedSinPiINTEL: return "OpFixedSinPiINTEL"; - case OpFixedCosPiINTEL: return "OpFixedCosPiINTEL"; - case OpFixedSinCosPiINTEL: return "OpFixedSinCosPiINTEL"; - case OpFixedLogINTEL: return "OpFixedLogINTEL"; - case OpFixedExpINTEL: return "OpFixedExpINTEL"; - case OpPtrCastToCrossWorkgroupINTEL: return "OpPtrCastToCrossWorkgroupINTEL"; - case OpCrossWorkgroupCastToPtrINTEL: return "OpCrossWorkgroupCastToPtrINTEL"; - case OpReadPipeBlockingINTEL: return "OpReadPipeBlockingINTEL"; - case OpWritePipeBlockingINTEL: return "OpWritePipeBlockingINTEL"; - case OpFPGARegINTEL: return "OpFPGARegINTEL"; + case OpFixedSqrtALTERA: return "OpFixedSqrtALTERA"; + case OpFixedRecipALTERA: return "OpFixedRecipALTERA"; + case OpFixedRsqrtALTERA: return "OpFixedRsqrtALTERA"; + case OpFixedSinALTERA: return "OpFixedSinALTERA"; + case OpFixedCosALTERA: return "OpFixedCosALTERA"; + case OpFixedSinCosALTERA: return "OpFixedSinCosALTERA"; + case OpFixedSinPiALTERA: return "OpFixedSinPiALTERA"; + case OpFixedCosPiALTERA: return "OpFixedCosPiALTERA"; + case OpFixedSinCosPiALTERA: return "OpFixedSinCosPiALTERA"; + case OpFixedLogALTERA: return "OpFixedLogALTERA"; + case OpFixedExpALTERA: return "OpFixedExpALTERA"; + case OpPtrCastToCrossWorkgroupALTERA: return "OpPtrCastToCrossWorkgroupALTERA"; + case OpCrossWorkgroupCastToPtrALTERA: return "OpCrossWorkgroupCastToPtrALTERA"; + case OpReadPipeBlockingALTERA: return "OpReadPipeBlockingALTERA"; + case OpWritePipeBlockingALTERA: return "OpWritePipeBlockingALTERA"; + case OpFPGARegALTERA: return "OpFPGARegALTERA"; case OpRayQueryGetRayTMinKHR: return "OpRayQueryGetRayTMinKHR"; case OpRayQueryGetRayFlagsKHR: return "OpRayQueryGetRayFlagsKHR"; case OpRayQueryGetIntersectionTKHR: return "OpRayQueryGetIntersectionTKHR"; @@ -5228,11 +5550,11 @@ inline const char* OpToString(Op value) { case OpControlBarrierArriveINTEL: return "OpControlBarrierArriveINTEL"; case OpControlBarrierWaitINTEL: return "OpControlBarrierWaitINTEL"; case OpArithmeticFenceEXT: return "OpArithmeticFenceEXT"; - case OpTaskSequenceCreateINTEL: return "OpTaskSequenceCreateINTEL"; - case OpTaskSequenceAsyncINTEL: return "OpTaskSequenceAsyncINTEL"; - case OpTaskSequenceGetINTEL: return "OpTaskSequenceGetINTEL"; - case OpTaskSequenceReleaseINTEL: return "OpTaskSequenceReleaseINTEL"; - case OpTypeTaskSequenceINTEL: return "OpTypeTaskSequenceINTEL"; + case OpTaskSequenceCreateALTERA: return "OpTaskSequenceCreateALTERA"; + case OpTaskSequenceAsyncALTERA: return "OpTaskSequenceAsyncALTERA"; + case OpTaskSequenceGetALTERA: return "OpTaskSequenceGetALTERA"; + case OpTaskSequenceReleaseALTERA: return "OpTaskSequenceReleaseALTERA"; + case OpTypeTaskSequenceALTERA: return "OpTypeTaskSequenceALTERA"; case OpSubgroupBlockPrefetchINTEL: return "OpSubgroupBlockPrefetchINTEL"; case OpSubgroup2DBlockLoadINTEL: return "OpSubgroup2DBlockLoadINTEL"; case OpSubgroup2DBlockLoadTransformINTEL: return "OpSubgroup2DBlockLoadTransformINTEL"; @@ -5263,6 +5585,9 @@ inline const char* OpToString(Op value) { case OpConvertHandleToImageINTEL: return "OpConvertHandleToImageINTEL"; case OpConvertHandleToSamplerINTEL: return "OpConvertHandleToSamplerINTEL"; case OpConvertHandleToSampledImageINTEL: return "OpConvertHandleToSampledImageINTEL"; + case OpFDot2MixAcc32VALVE: return "OpFDot2MixAcc32VALVE"; + case OpFDot2MixAcc16VALVE: return "OpFDot2MixAcc16VALVE"; + case OpFDot4MixAcc32VALVE: return "OpFDot4MixAcc32VALVE"; default: return "Unknown"; } } diff --git a/third_party/spirv-cross/spirv_cfg.cpp b/third_party/spirv-cross/spirv_cfg.cpp index c68886d989bc..ae928a03a65c 100644 --- a/third_party/spirv-cross/spirv_cfg.cpp +++ b/third_party/spirv-cross/spirv_cfg.cpp @@ -59,20 +59,26 @@ void CFG::build_immediate_dominators() for (auto i = post_order.size(); i; i--) { uint32_t block = post_order[i - 1]; - auto &pred = preceding_edges[block]; - if (pred.empty()) // This is for the entry block, but we've already set up the dominators. - continue; - for (auto &edge : pred) + const auto resolve_preds = [&](const SmallVector &pred) { - if (immediate_dominators[block]) + if (pred.empty()) // This is for the entry block, but we've already set up the dominators. + return; + + for (auto &edge : pred) { - assert(immediate_dominators[edge]); - immediate_dominators[block] = find_common_dominator(immediate_dominators[block], edge); + if (immediate_dominators[block]) + { + assert(immediate_dominators[edge]); + immediate_dominators[block] = find_common_dominator(immediate_dominators[block], edge); + } + else + immediate_dominators[block] = edge; } - else - immediate_dominators[block] = edge; - } + }; + + resolve_preds(preceding_edges[block]); + resolve_preds(virtual_dominance_preceding_edges[block]); } } @@ -193,6 +199,13 @@ void CFG::post_order_visit_resolve(uint32_t block_id) if (block.merge == SPIRBlock::MergeLoop && !is_back_edge(block.merge_block)) add_branch(block_id, block.merge_block); + // Similar case as do/while loops, but expressed in a different form. + // if (true) { foo = 1; } else { return/unreachable/kill/blah; } access(foo); + // Only consider this branch when computing dominance to avoid breaking other analysis like + // parameter preservation. + if (block.merge == SPIRBlock::MergeSelection && !is_back_edge(block.next_block)) + add_virtual_dominance_branch(block_id, block.next_block); + // First visit our branch targets. switch (block.terminator) { @@ -289,18 +302,26 @@ void CFG::build_post_order_visit_order() post_order_visit_entry(block); } +static void add_unique(SmallVector &l, uint32_t value) +{ + auto itr = find(begin(l), end(l), value); + if (itr == end(l)) + l.push_back(value); +} + void CFG::add_branch(uint32_t from, uint32_t to) { assert(from && to); - const auto add_unique = [](SmallVector &l, uint32_t value) { - auto itr = find(begin(l), end(l), value); - if (itr == end(l)) - l.push_back(value); - }; add_unique(preceding_edges[to], from); add_unique(succeeding_edges[from], to); } +void CFG::add_virtual_dominance_branch(uint32_t from, uint32_t to) +{ + assert(from && to); + add_unique(virtual_dominance_preceding_edges[to], from); +} + uint32_t CFG::find_loop_dominator(uint32_t block_id) const { while (block_id != SPIRBlock::NoDominator) diff --git a/third_party/spirv-cross/spirv_cfg.hpp b/third_party/spirv-cross/spirv_cfg.hpp index 1c21ea070bd6..9e6141bbef7b 100644 --- a/third_party/spirv-cross/spirv_cfg.hpp +++ b/third_party/spirv-cross/spirv_cfg.hpp @@ -122,6 +122,7 @@ class CFG Compiler &compiler; const SPIRFunction &func; std::unordered_map> preceding_edges; + std::unordered_map> virtual_dominance_preceding_edges; std::unordered_map> succeeding_edges; std::unordered_map immediate_dominators; std::unordered_map visit_order; @@ -129,6 +130,7 @@ class CFG SmallVector empty_vector; void add_branch(uint32_t from, uint32_t to); + void add_virtual_dominance_branch(uint32_t from, uint32_t to); void build_post_order_visit_order(); void build_immediate_dominators(); void post_order_visit_branches(uint32_t block); diff --git a/third_party/spirv-cross/spirv_common.hpp b/third_party/spirv-cross/spirv_common.hpp index 43ad1a6f139e..f24f0d1cbf32 100644 --- a/third_party/spirv-cross/spirv_common.hpp +++ b/third_party/spirv-cross/spirv_common.hpp @@ -629,7 +629,8 @@ struct SPIRType : IVariant FloatE4M3, FloatE5M2, - Tensor + Tensor, + DescriptorHeapBuffer }; // Scalar/vector/matrix support. @@ -676,6 +677,11 @@ struct SPIRType : IVariant uint32_t rank; uint32_t shape; } tensor; + + struct + { + spv::StorageClass storage; + } descriptor_heap_buffer; } ext; spv::StorageClass storage = spv::StorageClassGeneric; @@ -829,6 +835,13 @@ struct SPIRExpression : IVariant // Whether or not gl_MeshVerticesEXT[].gl_Position (as a whole or .y) is referenced bool access_meshlet_position_y = false; + // If this expression represents a OpBufferPointerEXT cast. + bool buffer_pointer = false; + + // Temporaries which can remain forwarded as long as this variable is not modified. + // Only used for buffer pointers. + SmallVector buffer_pointer_dependees; + // A list of expressions which this expression depends on. SmallVector expression_dependencies; @@ -1221,6 +1234,12 @@ struct SPIRVariable : IVariant // Used to find global LUTs bool is_written_to = false; + // Untyped pointer. The pointer of the variable is effectively void. + // The underlying payload for allocation is in alloca_type, but may be 0 too. + // This is mostly here to support descriptor heap proxy. + bool untyped = false; + ID untyped_alloca_type = 0; + SPIRFunction::Parameter *parameter = nullptr; SPIRV_CROSS_DECLARE_CLONE(SPIRVariable) @@ -1339,36 +1358,50 @@ struct SPIRConstant : IVariant inline uint32_t specialization_constant_id(uint32_t col, uint32_t row) const { + if (col >= 4 || row >= 4) + SPIRV_CROSS_THROW("Out of bounds col/row. Long vector bug."); return m.c[col].id[row]; } inline uint32_t specialization_constant_id(uint32_t col) const { + if (col >= 4) + SPIRV_CROSS_THROW("Out of bounds col/row. Long vector bug."); return m.id[col]; } inline uint32_t scalar(uint32_t col = 0, uint32_t row = 0) const { + if (col >= 4 || row >= 4) + SPIRV_CROSS_THROW("Out of bounds col/row. Long vector bug."); return m.c[col].r[row].u32; } inline int16_t scalar_i16(uint32_t col = 0, uint32_t row = 0) const { + if (col >= 4 || row >= 4) + SPIRV_CROSS_THROW("Out of bounds col/row. Long vector bug."); return int16_t(m.c[col].r[row].u32 & 0xffffu); } inline uint16_t scalar_u16(uint32_t col = 0, uint32_t row = 0) const { + if (col >= 4 || row >= 4) + SPIRV_CROSS_THROW("Out of bounds col/row. Long vector bug."); return uint16_t(m.c[col].r[row].u32 & 0xffffu); } inline int8_t scalar_i8(uint32_t col = 0, uint32_t row = 0) const { + if (col >= 4 || row >= 4) + SPIRV_CROSS_THROW("Out of bounds col/row. Long vector bug."); return int8_t(m.c[col].r[row].u32 & 0xffu); } inline uint8_t scalar_u8(uint32_t col = 0, uint32_t row = 0) const { + if (col >= 4 || row >= 4) + SPIRV_CROSS_THROW("Out of bounds col/row. Long vector bug."); return uint8_t(m.c[col].r[row].u32 & 0xffu); } @@ -1397,26 +1430,36 @@ struct SPIRConstant : IVariant inline float scalar_f32(uint32_t col = 0, uint32_t row = 0) const { + if (col >= 4 || row >= 4) + SPIRV_CROSS_THROW("Out of bounds col/row. Long vector bug."); return m.c[col].r[row].f32; } inline int32_t scalar_i32(uint32_t col = 0, uint32_t row = 0) const { + if (col >= 4 || row >= 4) + SPIRV_CROSS_THROW("Out of bounds col/row. Long vector bug."); return m.c[col].r[row].i32; } inline double scalar_f64(uint32_t col = 0, uint32_t row = 0) const { + if (col >= 4 || row >= 4) + SPIRV_CROSS_THROW("Out of bounds col/row. Long vector bug."); return m.c[col].r[row].f64; } inline int64_t scalar_i64(uint32_t col = 0, uint32_t row = 0) const { + if (col >= 4 || row >= 4) + SPIRV_CROSS_THROW("Out of bounds col/row. Long vector bug."); return m.c[col].r[row].i64; } inline uint64_t scalar_u64(uint32_t col = 0, uint32_t row = 0) const { + if (col >= 4 || row >= 4) + SPIRV_CROSS_THROW("Out of bounds col/row. Long vector bug."); return m.c[col].r[row].u64; } @@ -1450,6 +1493,9 @@ struct SPIRConstant : IVariant if (!subconstants.empty()) return false; + // Only used in contexts where we consume normal vectors. + // Don't need to consider long vector or composites. + for (uint32_t col = 0; col < columns(); col++) for (uint32_t row = 0; row < vector_size(); row++) if (scalar_u64(col, row) != 0) @@ -1504,6 +1550,9 @@ struct SPIRConstant : IVariant { bool matrix = vector_elements[0]->m.c[0].vecsize > 1; + if (num_elements > 4) + SPIRV_CROSS_THROW("Invalid constant. Long vector bug."); + if (matrix) { m.columns = num_elements; @@ -1545,6 +1594,7 @@ struct SPIRConstant : IVariant bool is_null_array_specialized_length = false; // For composites which are constant arrays, etc. + // Also used by long vectors where N > 4 or N is unknown. SmallVector subconstants; // Whether the subconstants are intended to be replicated (e.g. OpConstantCompositeReplicateEXT) @@ -1556,6 +1606,9 @@ struct SPIRConstant : IVariant // preprocessor directives before compiling the shader. std::string specialization_constant_macro_name; + // ConstantSizeOfEXT. + ID size_of_type = 0; + SPIRV_CROSS_DECLARE_CLONE(SPIRConstant) }; @@ -1836,10 +1889,12 @@ struct Meta uint32_t set = 0; uint32_t binding = 0; uint32_t offset = 0; + uint32_t offset_id = 0; uint32_t xfb_buffer = 0; uint32_t xfb_stride = 0; uint32_t stream = 0; uint32_t array_stride = 0; + uint32_t array_stride_id = 0; uint32_t matrix_stride = 0; uint32_t input_attachment = 0; uint32_t spec_id = 0; diff --git a/third_party/spirv-cross/spirv_common.hpp.orig b/third_party/spirv-cross/spirv_common.hpp.orig index cd06f754ca76..73c780d704e2 100644 --- a/third_party/spirv-cross/spirv_common.hpp.orig +++ b/third_party/spirv-cross/spirv_common.hpp.orig @@ -608,7 +608,8 @@ struct SPIRType : IVariant FloatE4M3, FloatE5M2, - Tensor + Tensor, + DescriptorHeapBuffer }; // Scalar/vector/matrix support. @@ -655,6 +656,11 @@ struct SPIRType : IVariant uint32_t rank; uint32_t shape; } tensor; + + struct + { + spv::StorageClass storage; + } descriptor_heap_buffer; } ext; spv::StorageClass storage = spv::StorageClassGeneric; @@ -808,6 +814,13 @@ struct SPIRExpression : IVariant // Whether or not gl_MeshVerticesEXT[].gl_Position (as a whole or .y) is referenced bool access_meshlet_position_y = false; + // If this expression represents a OpBufferPointerEXT cast. + bool buffer_pointer = false; + + // Temporaries which can remain forwarded as long as this variable is not modified. + // Only used for buffer pointers. + SmallVector buffer_pointer_dependees; + // A list of expressions which this expression depends on. SmallVector expression_dependencies; @@ -1200,6 +1213,12 @@ struct SPIRVariable : IVariant // Used to find global LUTs bool is_written_to = false; + // Untyped pointer. The pointer of the variable is effectively void. + // The underlying payload for allocation is in alloca_type, but may be 0 too. + // This is mostly here to support descriptor heap proxy. + bool untyped = false; + ID untyped_alloca_type = 0; + SPIRFunction::Parameter *parameter = nullptr; SPIRV_CROSS_DECLARE_CLONE(SPIRVariable) @@ -1318,36 +1337,50 @@ struct SPIRConstant : IVariant inline uint32_t specialization_constant_id(uint32_t col, uint32_t row) const { + if (col >= 4 || row >= 4) + SPIRV_CROSS_THROW("Out of bounds col/row. Long vector bug."); return m.c[col].id[row]; } inline uint32_t specialization_constant_id(uint32_t col) const { + if (col >= 4) + SPIRV_CROSS_THROW("Out of bounds col/row. Long vector bug."); return m.id[col]; } inline uint32_t scalar(uint32_t col = 0, uint32_t row = 0) const { + if (col >= 4 || row >= 4) + SPIRV_CROSS_THROW("Out of bounds col/row. Long vector bug."); return m.c[col].r[row].u32; } inline int16_t scalar_i16(uint32_t col = 0, uint32_t row = 0) const { + if (col >= 4 || row >= 4) + SPIRV_CROSS_THROW("Out of bounds col/row. Long vector bug."); return int16_t(m.c[col].r[row].u32 & 0xffffu); } inline uint16_t scalar_u16(uint32_t col = 0, uint32_t row = 0) const { + if (col >= 4 || row >= 4) + SPIRV_CROSS_THROW("Out of bounds col/row. Long vector bug."); return uint16_t(m.c[col].r[row].u32 & 0xffffu); } inline int8_t scalar_i8(uint32_t col = 0, uint32_t row = 0) const { + if (col >= 4 || row >= 4) + SPIRV_CROSS_THROW("Out of bounds col/row. Long vector bug."); return int8_t(m.c[col].r[row].u32 & 0xffu); } inline uint8_t scalar_u8(uint32_t col = 0, uint32_t row = 0) const { + if (col >= 4 || row >= 4) + SPIRV_CROSS_THROW("Out of bounds col/row. Long vector bug."); return uint8_t(m.c[col].r[row].u32 & 0xffu); } @@ -1376,26 +1409,36 @@ struct SPIRConstant : IVariant inline float scalar_f32(uint32_t col = 0, uint32_t row = 0) const { + if (col >= 4 || row >= 4) + SPIRV_CROSS_THROW("Out of bounds col/row. Long vector bug."); return m.c[col].r[row].f32; } inline int32_t scalar_i32(uint32_t col = 0, uint32_t row = 0) const { + if (col >= 4 || row >= 4) + SPIRV_CROSS_THROW("Out of bounds col/row. Long vector bug."); return m.c[col].r[row].i32; } inline double scalar_f64(uint32_t col = 0, uint32_t row = 0) const { + if (col >= 4 || row >= 4) + SPIRV_CROSS_THROW("Out of bounds col/row. Long vector bug."); return m.c[col].r[row].f64; } inline int64_t scalar_i64(uint32_t col = 0, uint32_t row = 0) const { + if (col >= 4 || row >= 4) + SPIRV_CROSS_THROW("Out of bounds col/row. Long vector bug."); return m.c[col].r[row].i64; } inline uint64_t scalar_u64(uint32_t col = 0, uint32_t row = 0) const { + if (col >= 4 || row >= 4) + SPIRV_CROSS_THROW("Out of bounds col/row. Long vector bug."); return m.c[col].r[row].u64; } @@ -1429,6 +1472,9 @@ struct SPIRConstant : IVariant if (!subconstants.empty()) return false; + // Only used in contexts where we consume normal vectors. + // Don't need to consider long vector or composites. + for (uint32_t col = 0; col < columns(); col++) for (uint32_t row = 0; row < vector_size(); row++) if (scalar_u64(col, row) != 0) @@ -1483,6 +1529,9 @@ struct SPIRConstant : IVariant { bool matrix = vector_elements[0]->m.c[0].vecsize > 1; + if (num_elements > 4) + SPIRV_CROSS_THROW("Invalid constant. Long vector bug."); + if (matrix) { m.columns = num_elements; @@ -1524,6 +1573,7 @@ struct SPIRConstant : IVariant bool is_null_array_specialized_length = false; // For composites which are constant arrays, etc. + // Also used by long vectors where N > 4 or N is unknown. SmallVector subconstants; // Whether the subconstants are intended to be replicated (e.g. OpConstantCompositeReplicateEXT) @@ -1535,6 +1585,9 @@ struct SPIRConstant : IVariant // preprocessor directives before compiling the shader. std::string specialization_constant_macro_name; + // ConstantSizeOfEXT. + ID size_of_type = 0; + SPIRV_CROSS_DECLARE_CLONE(SPIRConstant) }; @@ -1815,10 +1868,12 @@ struct Meta uint32_t set = 0; uint32_t binding = 0; uint32_t offset = 0; + uint32_t offset_id = 0; uint32_t xfb_buffer = 0; uint32_t xfb_stride = 0; uint32_t stream = 0; uint32_t array_stride = 0; + uint32_t array_stride_id = 0; uint32_t matrix_stride = 0; uint32_t input_attachment = 0; uint32_t spec_id = 0; diff --git a/third_party/spirv-cross/spirv_cross.cpp b/third_party/spirv-cross/spirv_cross.cpp index 1031d3ff654c..0f071d3f2052 100644 --- a/third_party/spirv-cross/spirv_cross.cpp +++ b/third_party/spirv-cross/spirv_cross.cpp @@ -78,19 +78,29 @@ string Compiler::compile() bool Compiler::variable_storage_is_aliased(const SPIRVariable &v) { auto &type = get(v.basetype); + + // Untyped pointer, assume full aliasing. + if (type.basetype == SPIRType::Void) + return true; + bool ssbo = v.storage == StorageClassStorageBuffer || ir.meta[type.self].decoration.decoration_flags.get(DecorationBufferBlock); bool image = type.basetype == SPIRType::Image; bool counter = type.basetype == SPIRType::AtomicCounter; bool buffer_reference = type.storage == StorageClassPhysicalStorageBuffer; + bool shared_block = + type.storage == StorageClassWorkgroup && has_decoration(type.self, Decoration::DecorationBlock); bool is_restrict; if (ssbo) is_restrict = ir.get_buffer_block_flags(v).get(DecorationRestrict); + else if (shared_block) + // When more than one shared block is present, all shared blocks must be decorated Aliased + is_restrict = !has_decoration(v.self, DecorationAliased); else is_restrict = has_decoration(v.self, DecorationRestrict); - return !is_restrict && (ssbo || image || counter || buffer_reference); + return !is_restrict && (ssbo || image || counter || buffer_reference || shared_block); } bool Compiler::block_is_control_dependent(const SPIRBlock &block) @@ -411,20 +421,37 @@ SPIRVariable *Compiler::maybe_get_backing_variable(uint32_t chain) { auto *cexpr = maybe_get(chain); if (cexpr) + { var = maybe_get(cexpr->loaded_from); + if (!var && cexpr->loaded_from != chain) + var = maybe_get_backing_variable(cexpr->loaded_from); + } auto *access_chain = maybe_get(chain); if (access_chain) + { var = maybe_get(access_chain->loaded_from); + if (!var && access_chain->loaded_from != chain) + var = maybe_get_backing_variable(access_chain->loaded_from); + } } return var; } +SPIRExpression *Compiler::maybe_get_backing_buffer_pointer(uint32_t chain) +{ + auto *expr = maybe_get(chain); + while (expr && !expr->buffer_pointer && expr->loaded_from) + expr = maybe_get(expr->loaded_from); + return expr && expr->buffer_pointer ? expr : nullptr; +} + void Compiler::register_read(uint32_t expr, uint32_t chain, bool forwarded) { auto &e = get(expr); auto *var = maybe_get_backing_variable(chain); + auto *buffer_pointer = maybe_get_backing_buffer_pointer(chain); if (var) { @@ -439,6 +466,13 @@ void Compiler::register_read(uint32_t expr, uint32_t chain, bool forwarded) if (var && var->parameter) var->parameter->read_count++; } + else if (buffer_pointer) + { + e.loaded_from = buffer_pointer->self; + // If the backing variable is immutable, we do not need to depend on the variable. + if (forwarded && !is_immutable(buffer_pointer->self)) + buffer_pointer->buffer_pointer_dependees.push_back(e.self); + } } void Compiler::register_write(uint32_t chain) @@ -456,6 +490,8 @@ void Compiler::register_write(uint32_t chain) var = maybe_get(access_chain->loaded_from); } + auto *buffer_pointer = maybe_get_backing_buffer_pointer(chain); + auto &chain_type = expression_type(chain); if (var) @@ -466,6 +502,10 @@ void Compiler::register_write(uint32_t chain) // If our variable is in a storage class which can alias with other buffers, // invalidate all variables which depend on aliased variables. And if this is a // variable pointer, then invalidate all variables regardless. + // For BDA, this is overly conservative, since BDA pointers are usually restrict + // depending on how that BDA pointer is loaded, but being overly conservative + // is better than risking bad aliasing which is very hard to diagnose. + // The only real cost is slightly less pretty code, which is an acceptable compromise. if (get_variable_data_type(*var).pointer) { flush_all_active_variables(); @@ -500,6 +540,10 @@ void Compiler::register_write(uint32_t chain) force_recompile(); } } + else if (buffer_pointer) + { + flush_dependees(*buffer_pointer); + } else if (chain_type.pointer) { // If we stored through a variable pointer, then we don't know which @@ -521,6 +565,16 @@ void Compiler::flush_dependees(SPIRVariable &var) var.dependees.clear(); } +void Compiler::flush_dependees(SPIRExpression &expr) +{ + // A little ugly to split things up like this since BufferPointerEXT is a weird case + // where it's both an expression (chain into global heap) and a memory declaration at the same time ... + assert(expr.buffer_pointer); + for (auto dep : expr.buffer_pointer_dependees) + invalid_expressions.insert(dep); + expr.buffer_pointer_dependees.clear(); +} + void Compiler::flush_all_aliased_variables() { for (auto aliased : aliased_variables) @@ -531,6 +585,8 @@ void Compiler::flush_all_atomic_capable_variables() { for (auto global : global_variables) flush_dependees(get(global)); + for (auto global : buffer_pointer_variables) + flush_dependees(get(global)); flush_all_aliased_variables(); } @@ -552,6 +608,8 @@ void Compiler::flush_all_active_variables() flush_dependees(get(arg.id)); for (auto global : global_variables) flush_dependees(get(global)); + for (auto global : buffer_pointer_variables) + flush_dependees(get(global)); flush_all_aliased_variables(); } @@ -660,8 +718,9 @@ bool Compiler::is_hidden_variable(const SPIRVariable &var, bool include_builtins } // 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 != StorageClassGeneric && + // which are not part of the entry point. Library modules have no real entry point so the filter + // would hide every global so skip it in that case. + if (ir.get_spirv_version() >= 0x10400 && !ir.is_library_module && var.storage != StorageClassGeneric && var.storage != StorageClassFunction && !interface_variable_exists_in_entry_point(var.self)) { return true; @@ -734,17 +793,17 @@ bool Compiler::is_array(const SPIRType &type) const bool Compiler::is_pointer(const SPIRType &type) const { - return type.op == OpTypePointer && type.basetype != SPIRType::Unknown; // Ignore function pointers. + return (type.op == OpTypePointer || type.op == OpTypeUntypedPointerKHR) && type.basetype != SPIRType::Unknown; // Ignore function pointers. } bool Compiler::is_physical_pointer(const SPIRType &type) const { - return type.op == OpTypePointer && type.storage == StorageClassPhysicalStorageBuffer; + return (type.op == OpTypePointer || type.op == OpTypeUntypedPointerKHR) && type.storage == StorageClassPhysicalStorageBuffer; } bool Compiler::is_physical_or_buffer_pointer(const SPIRType &type) const { - return type.op == OpTypePointer && + return (type.op == OpTypePointer || type.op == OpTypeUntypedPointerKHR) && (type.storage == StorageClassPhysicalStorageBuffer || type.storage == StorageClassUniform || type.storage == StorageClassStorageBuffer || type.storage == StorageClassWorkgroup || type.storage == StorageClassPushConstant); @@ -762,6 +821,16 @@ bool Compiler::is_runtime_size_array(const SPIRType &type) return type.op == OpTypeRuntimeArray; } +bool Compiler::is_struct_wrapped_opaque_descriptor_array(const SPIRType &type) const +{ + // Specific detection of glslang code patterns. + return type.basetype == SPIRType::Struct && + has_decoration(type.self, DecorationBlock) && + type.member_types.size() == 1 && + type_is_opaque_value(get(type.member_types.front())) && + is_runtime_size_array(get(type.member_types.front())); +} + ShaderResources Compiler::get_shader_resources() const { return get_shader_resources(nullptr); @@ -1235,9 +1304,11 @@ void Compiler::parse_fixup() else if (id.get_type() == TypeVariable) { auto &var = id.get(); - if (var.storage == StorageClassPrivate || var.storage == StorageClassWorkgroup || - var.storage == StorageClassTaskPayloadWorkgroupEXT || - var.storage == StorageClassOutput) + auto &type = get(var.basetype); + + if (var.storage == StorageClassPrivate || + (var.storage == StorageClassWorkgroup && !has_decoration(type.self, DecorationBlock)) || + var.storage == StorageClassTaskPayloadWorkgroupEXT || var.storage == StorageClassOutput) { global_variables.push_back(var.self); } @@ -2060,7 +2131,7 @@ size_t Compiler::get_declared_struct_size_runtime_array(const SPIRType &type, si size_t size = get_declared_struct_size(type); auto &last_type = get(type.member_types.back()); - if (!last_type.array.empty() && last_type.array_size_literal[0] && last_type.array[0] == 0) // Runtime array + if (!last_type.array.empty() && last_type.array_size_literal.back() && last_type.array.back() == 0) // Runtime array size += array_size * type_struct_member_array_stride(type, uint32_t(type.member_types.size() - 1)); return size; @@ -4791,6 +4862,18 @@ void Compiler::build_function_control_flow_graphs_and_analyze() CFGBuilder handler(*this); handler.function_cfgs[ir.default_entry_point].reset(new CFG(*this, get(ir.default_entry_point))); traverse_all_reachable_opcodes(get(ir.default_entry_point), handler); + if (ir.is_library_module) + { + // In library mode, default_entry_point is just the first exported + // function. Build a CFG for every other exported function (and its + // callees) so per-function analyses below cover all of them. + for (auto export_id : ir.library_exported_functions) + { + auto &func = get(export_id); + if (handler.follow_function_call(func)) + traverse_all_reachable_opcodes(func, handler); + } + } function_cfgs = std::move(handler.function_cfgs); bool single_function = function_cfgs.size() <= 1; @@ -5421,6 +5504,248 @@ void Compiler::analyze_non_block_pointer_types() physical_storage_type_to_alignment = std::move(handler.physical_block_type_meta); } +void Compiler::analyze_descriptor_heap_types() +{ + struct HeapHandler : OpcodeHandler + { + bool handle(Op opcode, const uint32_t *args, uint32_t) override + { + switch (opcode) + { + case OpBufferPointerEXT: + { + auto &ptr_type = compiler.get(args[0]); + // BufferPointerEXT can return untyped or typed pointers. + // If it's typed, we resolve it here. + if (ptr_type.basetype == SPIRType::Struct) + { + DescriptorHeapMeta meta = {}; + meta.data_type = ptr_type.self; + meta.hlsl_style_stride = hlsl_style_stride_access_chains.count(args[2]); + meta.buffer_pointer_id = args[1]; + meta.storage = ptr_type.storage; + meta.nonreadable = compiler.has_decoration(args[1], DecorationNonReadable); + meta.nonwritable = compiler.has_decoration(args[1], DecorationNonWritable); + meta.coherent = compiler.has_decoration(args[1], DecorationCoherent); + meta.is_restrict = compiler.has_decoration(args[1], DecorationRestrict); + meta.is_volatile = compiler.has_decoration(args[1], DecorationVolatile); + add_unique_type(meta); + } + buffer_pointers[args[1]] = { args[0], hlsl_style_stride_access_chains.count(args[2]) != 0 }; + break; + } + + case OpUntypedAccessChainKHR: + case OpUntypedInBoundsAccessChainKHR: + case OpUntypedArrayLengthKHR: + { + auto &data_type = compiler.get(args[2]); + + // Newer glslang can emit uniformconstant descriptors as: + // struct { non{readable,writable} T descriptors[]; }, as a way to add NonWritable / NonReadable. + // Detect this as a special case. We cannot deal with arbitrary complication in HLLs. + bool is_struct_wrapped_runtime_array = compiler.is_struct_wrapped_opaque_descriptor_array(data_type); + + TypeID descriptor_array_type_id = args[2]; + if (is_struct_wrapped_runtime_array) + { + descriptor_array_type_id = data_type.member_types.front(); + if (!compiler.has_member_decoration(data_type.self, 0, DecorationOffset) && + compiler.get_member_decoration(data_type.self, 0, DecorationOffset) != 0) + { + ID offset_id = compiler.get_member_decoration(data_type.self, 0, DecorationOffsetIdEXT); + auto *c = compiler.maybe_get (offset_id); + if (!c || c->specialization || c->scalar() != 0) + SPIRV_CROSS_THROW("Offset for resource heap must be constant 0."); + } + } + + if (compiler.is_pointer(data_type)) + SPIRV_CROSS_THROW("pointer type not allowed."); + + bool hlsl_style_stride = false; + + // Need to validate the array stride and types. HLLs are not flexible enough to support the full flexibility of SPIR-V. + if (BuiltIn(compiler.get_decoration(args[3], DecorationBuiltIn)) == BuiltInResourceHeapEXT) + { + if (!is_struct_wrapped_runtime_array && !is_runtime_size_array(data_type)) + SPIRV_CROSS_THROW("Descriptor heap must be accessed as a runtime array."); + + // The only meaningful use of this is ArrayStride equal to sizeof(type) right now. + uint32_t array_stride_id = compiler.get_decoration(descriptor_array_type_id, DecorationArrayStrideIdEXT); + if (!array_stride_id) + SPIRV_CROSS_THROW("Expected ArrayStrideIdEXT to be set for resource heap."); + + auto *spec_c = compiler.maybe_get(array_stride_id); + auto *c = compiler.maybe_get(array_stride_id); + + if (!spec_c && !c) + SPIRV_CROSS_THROW("Array stride must be some constant expression."); + + if (spec_c) + { + // This gets potentially infinitely weird, but if we get HLSL-style shaders + // we expect the array stride to be max(buffer, image) since all descriptors have equal size in D3D12. + // We just have to be a bit loose here since it's impossible to anticipate every theoretical formulation. + // Anything non-conforming to strict GLSL is flagged in the codegen output. + if (spec_c->opcode == OpSelect) + { + auto *true_value = compiler.maybe_get(spec_c->arguments[1]); + auto *false_value = compiler.maybe_get(spec_c->arguments[2]); + hlsl_style_stride = true_value && true_value->size_of_type && + false_value && false_value->size_of_type; + } + + if (!hlsl_style_stride) + SPIRV_CROSS_THROW("Unusual pattern of descriptor stride detected. This probably cannot be expressed in current GLSL."); + } + + if (c && !c->size_of_type) + SPIRV_CROSS_THROW("Resource heap array stride must be ConstantSizeOfEXT for high level languages."); + + auto &descriptor_array_type = compiler.get(descriptor_array_type_id); + auto &element_type = compiler.get(descriptor_array_type.parent_type); + + if (element_type.basetype == SPIRType::DescriptorHeapBuffer) + { + if (c && compiler.get(c->size_of_type).basetype != SPIRType::DescriptorHeapBuffer) + SPIRV_CROSS_THROW("Buffer descriptors in heap must be ConstantSizeOfEXT(OpTypeBufferEXT) for GLSL."); + } + else if (element_type.basetype == SPIRType::Image) + { + if (c && compiler.get(c->size_of_type).basetype != SPIRType::Image) + SPIRV_CROSS_THROW("Image descriptors in heap must be ConstantSizeOfEXT(OpTypeImage) for GLSL."); + } + else if (element_type.basetype == SPIRType::AccelerationStructure) + { + if (c && compiler.get(c->size_of_type).basetype != SPIRType::AccelerationStructure) + SPIRV_CROSS_THROW("RTAS descriptors in heap must be ConstantSizeOfEXT(OpTypeAccelerationStructure) for GLSL."); + } + } + else if (BuiltIn(compiler.get_decoration(args[3], DecorationBuiltIn)) == BuiltInSamplerHeapEXT) + { + if (!is_struct_wrapped_runtime_array && !is_runtime_size_array(data_type)) + SPIRV_CROSS_THROW("Descriptor heap must be accessed as a runtime array."); + + // The only meaningful use of this is ArrayStride equal to sizeof(sampler) right now. + uint32_t array_stride_id = compiler.get_decoration(descriptor_array_type_id, DecorationArrayStrideIdEXT); + if (!array_stride_id) + SPIRV_CROSS_THROW("Expected ArrayStrideIdEXT to be set for sampler heap."); + + auto *c = compiler.maybe_get(array_stride_id); + if (!c || !c->size_of_type || compiler.get(c->size_of_type).basetype != SPIRType::Sampler) + SPIRV_CROSS_THROW("Sampler heap array stride must be ConstantSizeOfEXT(OpTypeSampler) for high level languages."); + } + + // Remember this for OpBufferPointerEXT. + if (hlsl_style_stride) + hlsl_style_stride_access_chains.insert(args[1]); + + auto *element_type = &compiler.get(descriptor_array_type_id); + while (compiler.is_array(*element_type)) + element_type = &compiler.get(element_type->parent_type); + + if (element_type->basetype == SPIRType::SampledImage) + { + SPIRV_CROSS_THROW("Attempting to access heap as combined sampler image. This does not make sense."); + } + else if (element_type->basetype == SPIRType::Image || + element_type->basetype == SPIRType::AccelerationStructure || + element_type->basetype == SPIRType::Sampler) + { + DescriptorHeapMeta meta = {}; + meta.data_type = element_type->self; + meta.name_type = data_type.self; + meta.hlsl_style_stride = hlsl_style_stride; + + if (is_struct_wrapped_runtime_array) + { + meta.nonreadable = compiler.has_member_decoration(data_type.self, 0, DecorationNonReadable); + meta.nonwritable = compiler.has_member_decoration(data_type.self, 0, DecorationNonWritable); + meta.coherent = compiler.has_member_decoration(data_type.self, 0, DecorationCoherent); + meta.is_volatile = compiler.has_member_decoration(data_type.self, 0, DecorationVolatile); + meta.is_restrict = compiler.has_member_decoration(data_type.self, 0, DecorationRestrict); + } + + add_unique_type(meta); + } + else if (buffer_pointers.count(args[3]) != 0) + { + if (!compiler.has_decoration(element_type->self, DecorationBlock) && + !compiler.has_decoration(element_type->self, DecorationBufferBlock)) + { + SPIRV_CROSS_THROW("BufferPointerEXT must reference a block type."); + } + + auto &pointer_meta = buffer_pointers[args[3]]; + auto &buffer_type = compiler.get(pointer_meta.type); + if (buffer_type.basetype == SPIRType::Void) + { + // This is where the pointer becomes typed, so register it here. + DescriptorHeapMeta meta = {}; + meta.data_type = data_type.self; + meta.hlsl_style_stride = pointer_meta.hlsl_style_stride; + meta.buffer_pointer_id = args[3]; + meta.storage = buffer_type.storage; + meta.nonreadable = compiler.has_decoration(args[3], DecorationNonReadable); + meta.nonwritable = compiler.has_decoration(args[3], DecorationNonWritable); + meta.coherent = compiler.has_decoration(args[3], DecorationCoherent); + meta.is_volatile = compiler.has_decoration(args[3], DecorationVolatile); + meta.is_restrict = compiler.has_decoration(args[3], DecorationRestrict); + add_unique_type(meta); + } + } + break; + } + + default: + break; + } + + return true; + } + + explicit HeapHandler(Compiler &compiler_) : OpcodeHandler(compiler_) {} + + std::vector heap_types; + + struct BufferPointerMeta + { + TypeID type; + bool hlsl_style_stride; + }; + std::unordered_map buffer_pointers; + std::unordered_set hlsl_style_stride_access_chains; + + void add_unique_type(const DescriptorHeapMeta &meta) + { + assert(meta.data_type != 0); + + for (auto &type : heap_types) + { + if (type.data_type == meta.data_type && type.name_type == meta.name_type && + type.storage == meta.storage && + type.buffer_pointer_id == meta.buffer_pointer_id && + type.nonreadable == meta.nonreadable && + type.nonwritable == meta.nonwritable && + type.coherent == meta.coherent && + type.is_restrict == meta.is_restrict && + type.hlsl_style_stride == meta.hlsl_style_stride && + type.is_volatile == meta.is_volatile) + { + return; + } + } + + heap_types.push_back(meta); + } + }; + + HeapHandler handler(*this); + traverse_all_reachable_opcodes(get(ir.default_entry_point), handler); + descriptor_heap_types = std::move(handler.heap_types); +} + bool Compiler::InterlockedResourceAccessPrepassHandler::handle(Op op, const uint32_t *, uint32_t) { if (op == OpBeginInvocationInterlockEXT || op == OpEndInvocationInterlockEXT) @@ -5804,4 +6129,3 @@ const SPIRType *Compiler::OpcodeHandler::get_expression_result_type(uint32_t id) return &compiler.get(itr->second); } - diff --git a/third_party/spirv-cross/spirv_cross.hpp b/third_party/spirv-cross/spirv_cross.hpp index f72d79979eef..6ffe6db46298 100644 --- a/third_party/spirv-cross/spirv_cross.hpp +++ b/third_party/spirv-cross/spirv_cross.hpp @@ -91,6 +91,28 @@ struct BuiltInResource Resource resource; }; +// Needs to stay in sync 1:1 with C API. +enum ResourceType +{ + ResourceTypeUnknown = 0, + ResourceTypeUniformBuffer = 1, + ResourceTypeStorageBuffer = 2, + ResourceTypeStageInput = 3, + ResourceTypeStageOutput = 4, + ResourceTypeSubpassInput = 5, + ResourceTypeStorageImage = 6, + ResourceTypeSampledImage = 7, + ResourceTypeAtomicCounter = 8, + ResourceTypePushConstant = 9, + ResourceTypeSeparateImage = 10, + ResourceTypeSeparateSamplers = 11, + ResourceTypeAccelerationStructure = 12, + ResourceTypeRayQuery = 13, + ResourceTypeShaderRecordBuffer = 14, + ResourceTypeGLPlainUniform = 15, + ResourceTypeTensor = 16 +}; + struct ShaderResources { SmallVector uniform_buffers; @@ -585,6 +607,7 @@ class Compiler // (SSBO, image load store, etc) SmallVector global_variables; SmallVector aliased_variables; + SmallVector buffer_pointer_variables; SPIRFunction *current_function = nullptr; SPIRBlock *current_block = nullptr; @@ -700,11 +723,13 @@ class Compiler bool is_physical_or_buffer_pointer(const SPIRType &type) const; bool is_physical_pointer_to_buffer_block(const SPIRType &type) const; static bool is_runtime_size_array(const SPIRType &type); + bool is_struct_wrapped_opaque_descriptor_array(const SPIRType &type) const; uint32_t expression_type_id(uint32_t id) const; const SPIRType &expression_type(uint32_t id) const; bool expression_is_lvalue(uint32_t id) const; bool variable_storage_is_aliased(const SPIRVariable &var); SPIRVariable *maybe_get_backing_variable(uint32_t chain); + SPIRExpression *maybe_get_backing_buffer_pointer(uint32_t chain); void register_read(uint32_t expr, uint32_t chain, bool forwarded); void register_write(uint32_t chain); @@ -739,6 +764,7 @@ class Compiler // Dependency tracking for temporaries read from variables. void flush_dependees(SPIRVariable &var); + void flush_dependees(SPIRExpression &expr); void flush_all_active_variables(); void flush_control_dependent_expressions(uint32_t block); void flush_all_atomic_capable_variables(); @@ -1090,6 +1116,26 @@ class Compiler SmallVector physical_storage_non_block_pointer_types; std::unordered_map physical_storage_type_to_alignment; + struct DescriptorHeapMeta + { + TypeID data_type; + TypeID name_type; // This can be non-zero, as a way to disambiguate. + bool hlsl_style_stride; + + // For buffers + ID buffer_pointer_id; + StorageClass storage; + + // For buffers and storage images if using newer glslang. + bool nonwritable; + bool nonreadable; + bool coherent; + bool is_volatile; + bool is_restrict; + }; + std::vector descriptor_heap_types; + void analyze_descriptor_heap_types(); + void analyze_variable_scope(SPIRFunction &function, AnalyzeVariableScopeAccessHandler &handler); void find_function_local_luts(SPIRFunction &function, const AnalyzeVariableScopeAccessHandler &handler, bool single_function); diff --git a/third_party/spirv-cross/spirv_cross_parsed_ir.cpp b/third_party/spirv-cross/spirv_cross_parsed_ir.cpp index bb9a5f58ed18..47cd1dbe1328 100644 --- a/third_party/spirv-cross/spirv_cross_parsed_ir.cpp +++ b/third_party/spirv-cross/spirv_cross_parsed_ir.cpp @@ -79,6 +79,9 @@ ParsedIR &ParsedIR::operator=(ParsedIR &&other) SPIRV_CROSS_NOEXCEPT memory_model = other.memory_model; default_entry_point = other.default_entry_point; + is_library_module = other.is_library_module; + library_exports = std::move(other.library_exports); + library_exported_functions = std::move(other.library_exported_functions); sources = std::move(other.sources); loop_iteration_depth_hard = other.loop_iteration_depth_hard; loop_iteration_depth_soft = other.loop_iteration_depth_soft; @@ -111,6 +114,9 @@ ParsedIR &ParsedIR::operator=(const ParsedIR &other) continue_block_to_loop_header = other.continue_block_to_loop_header; entry_points = other.entry_points; default_entry_point = other.default_entry_point; + is_library_module = other.is_library_module; + library_exports = other.library_exports; + library_exported_functions = other.library_exported_functions; sources = other.sources; loop_iteration_depth_hard = other.loop_iteration_depth_hard; loop_iteration_depth_soft = other.loop_iteration_depth_soft; @@ -404,6 +410,10 @@ void ParsedIR::set_decoration(ID id, Decoration decoration, uint32_t argument) dec.offset = argument; break; + case DecorationOffsetIdEXT: + dec.offset_id = argument; + break; + case DecorationXfbBuffer: dec.xfb_buffer = argument; break; @@ -420,6 +430,10 @@ void ParsedIR::set_decoration(ID id, Decoration decoration, uint32_t argument) dec.array_stride = argument; break; + case DecorationArrayStrideIdEXT: + dec.array_stride_id = argument; + break; + case DecorationMatrixStride: dec.matrix_stride = argument; break; @@ -492,6 +506,10 @@ void ParsedIR::set_member_decoration(TypeID id, uint32_t index, Decoration decor dec.offset = argument; break; + case DecorationOffsetIdEXT: + dec.offset_id = argument; + break; + case DecorationXfbBuffer: dec.xfb_buffer = argument; break; @@ -645,6 +663,8 @@ uint32_t ParsedIR::get_decoration(ID id, Decoration decoration) const return dec.component; case DecorationOffset: return dec.offset; + case DecorationOffsetIdEXT: + return dec.offset_id; case DecorationXfbBuffer: return dec.xfb_buffer; case DecorationXfbStride: @@ -661,6 +681,8 @@ uint32_t ParsedIR::get_decoration(ID id, Decoration decoration) const return dec.spec_id; case DecorationArrayStride: return dec.array_stride; + case DecorationArrayStrideIdEXT: + return dec.array_stride_id; case DecorationMatrixStride: return dec.matrix_stride; case DecorationIndex: @@ -720,6 +742,10 @@ void ParsedIR::unset_decoration(ID id, Decoration decoration) dec.offset = 0; break; + case DecorationOffsetIdEXT: + dec.offset_id = 0; + break; + case DecorationXfbBuffer: dec.xfb_buffer = 0; break; @@ -806,6 +832,8 @@ uint32_t ParsedIR::get_member_decoration(TypeID id, uint32_t index, Decoration d return dec.binding; case DecorationOffset: return dec.offset; + case DecorationOffsetIdEXT: + return dec.offset_id; case DecorationXfbBuffer: return dec.xfb_buffer; case DecorationXfbStride: @@ -903,6 +931,10 @@ void ParsedIR::unset_member_decoration(TypeID id, uint32_t index, Decoration dec dec.offset = 0; break; + case DecorationOffsetIdEXT: + dec.offset_id = 0; + break; + case DecorationXfbBuffer: dec.xfb_buffer = 0; break; diff --git a/third_party/spirv-cross/spirv_cross_parsed_ir.hpp b/third_party/spirv-cross/spirv_cross_parsed_ir.hpp index b1e76f20537b..efe9d4a4b166 100644 --- a/third_party/spirv-cross/spirv_cross_parsed_ir.hpp +++ b/third_party/spirv-cross/spirv_cross_parsed_ir.hpp @@ -110,6 +110,13 @@ class ParsedIR std::unordered_map entry_points; FunctionID default_entry_point = 0; + // A "library" module has no OpEntryPoint and instead exports symbols via + // OpDecorate ... LinkageAttributes ... Export. These vectors keep track + // of all these exports and specifically the function exports. + bool is_library_module = false; + SmallVector library_exports; + SmallVector library_exported_functions; + struct Source { SourceLanguage lang = SourceLanguageUnknown; diff --git a/third_party/spirv-cross/spirv_glsl.cpp b/third_party/spirv-cross/spirv_glsl.cpp index 964fde5f2bbb..64119889aa1b 100644 --- a/third_party/spirv-cross/spirv_glsl.cpp +++ b/third_party/spirv-cross/spirv_glsl.cpp @@ -380,6 +380,7 @@ void CompilerGLSL::reset(uint32_t iteration_count) expression_usage_counts.clear(); forwarded_temporaries.clear(); suppressed_usage_tracking.clear(); + buffer_pointer_variables.clear(); // Ensure that we declare phi-variable copies even if the original declaration isn't deferred flushed_phi_variables.clear(); @@ -394,6 +395,7 @@ void CompilerGLSL::reset(uint32_t iteration_count) }); ir.for_each_typed_id([&](uint32_t, SPIRVariable &var) { var.dependees.clear(); }); + ir.for_each_typed_id([&](uint32_t, SPIRBlock &block) { block.rearm_dominated_variables.clear(); }); ir.reset_all_of_type(); ir.reset_all_of_type(); @@ -622,7 +624,7 @@ void CompilerGLSL::find_static_extensions() { switch (cap) { - case CapabilityShaderNonUniformEXT: + case CapabilityShaderNonUniform: if (!options.vulkan_semantics) require_extension_internal("GL_NV_gpu_shader5"); else @@ -700,6 +702,22 @@ void CompilerGLSL::find_static_extensions() require_extension_internal("GL_ARM_tensors"); break; + case CapabilityDescriptorHeapEXT: + if (!options.vulkan_semantics) + SPIRV_CROSS_THROW("DescriptorHeapEXT requires Vulkan semantics."); + require_extension_internal("GL_EXT_descriptor_heap"); + require_extension_internal("GL_EXT_nonuniform_qualifier"); + // We lose information about writeonly/readonly in SPIR-V. Just pre-empt this to avoid complicating code later. + require_extension_internal("GL_EXT_shader_image_load_formatted"); + break; + + case CapabilityLongVectorEXT: + if (!options.vulkan_semantics) + SPIRV_CROSS_THROW("Long vector requires Vulkan semantics."); + require_extension_internal("GL_EXT_long_vector"); + long_vector_enabled = true; + break; + default: break; } @@ -720,6 +738,15 @@ void CompilerGLSL::find_static_extensions() require_extension_internal("GL_EXT_shader_quad_control"); } + if (execution.flags.get(ExecutionModeDepthGreater) || + execution.flags.get(ExecutionModeDepthLess)) + { + if (!options.es) + require_extension_internal("GL_ARB_conservative_depth"); + else if (options.version >= 300) + require_extension_internal("GL_EXT_conservative_depth"); + } + // KHR one is likely to get promoted at some point, so if we don't see an explicit SPIR-V extension, assume KHR. for (auto &ext : ir.declared_extensions) if (ext == "SPV_NV_fragment_shader_barycentric") @@ -752,6 +779,46 @@ void CompilerGLSL::ray_tracing_khr_fixup_locations() }); } +std::string CompilerGLSL::integer_dot_product_entry_point(const IntegerDotProduct &idot) +{ + std::string expr = "spv"; + + switch (idot.op) + { + case OpSDot: expr += "SDot"; break; + case OpUDot: expr += "UDot"; break; + case OpSUDot: expr += "SUDot"; break; + case OpSDotAccSat: expr += "SDotAccSat"; break; + case OpUDotAccSat: expr += "UDotAccSat"; break; + case OpSUDotAccSat: expr += "SUDotAccSat"; break; + default: SPIRV_CROSS_THROW("Invalid integer dot product opcode."); + } + + expr += "_" + type_to_glsl(get(idot.result_type)); + for (auto &arg : idot.argument_type) + expr += "_" + type_to_glsl(get(arg)); + + return expr; +} + +void CompilerGLSL::add_integer_dot_product_polyfill(const IntegerDotProduct &idot) +{ + for (auto &impl : integer_dot_products_polyfills) + { + if (impl.result_type == idot.result_type && + impl.argument_type[0] == idot.argument_type[0] && + impl.argument_type[1] == idot.argument_type[1] && + impl.op == idot.op) + { + return; + } + } + + require_extension_internal("GL_EXT_spirv_intrinsics"); + integer_dot_products_polyfills.push_back(idot); + force_recompile(); +} + string CompilerGLSL::compile() { ir.fixup_reserved_names(); @@ -794,6 +861,17 @@ string CompilerGLSL::compile() if (ir.addressing_model == AddressingModelPhysicalStorageBuffer64) analyze_non_block_pointer_types(); + if (std::find(ir.declared_capabilities.begin(), ir.declared_capabilities.end(), + CapabilityDescriptorHeapEXT) != ir.declared_capabilities.end()) + { + // Need to figure out all the aliased types that view the heap. + // In GLSL, each unique type must be declared with layout(descriptor_heap) type-decl spvSomeIdentResourceHeap[]; + // During untyped access chain traversal, we prefix the name to match the aliases. + // HLSL has more direct native support and will not need these, but we still need to call this function + // to verify that descriptor strides make sense. + analyze_descriptor_heap_types(); + } + uint32_t pass_count = 0; do { @@ -809,17 +887,30 @@ string CompilerGLSL::compile() emit_polyfills(required_polyfills, false); if ((options.es || options.vulkan_semantics) && required_polyfills_relaxed != 0) emit_polyfills(required_polyfills_relaxed, true); + emit_polyfills_integer_dot_product(); - emit_function(get(ir.default_entry_point), Bitset()); + if (ir.is_library_module) + { + // Emit each exported function as a normal free function. + // emit_function recursively emits callees, so internal helpers + // are picked up too. + for (auto export_id : ir.library_exported_functions) + emit_function(get(export_id), Bitset()); + } + else + emit_function(get(ir.default_entry_point), Bitset()); pass_count++; } while (is_forcing_recompilation()); // Implement the interlocked wrapper function at the end. // The body was implemented in lieu of main(). - if (interlocked_is_complex) + if (interlocked_is_complex && !ir.is_library_module) { - statement("void main()"); + if (options.use_entry_point_name) + statement("void ", get_entry_point().name, "()"); + else + statement("void main()"); begin_scope(); statement("// Interlocks were used in a way not compatible with GLSL, this is very slow."); statement("SPIRV_Cross_beginInvocationInterlock();"); @@ -828,8 +919,10 @@ string CompilerGLSL::compile() end_scope(); } - // Entry point in GLSL is always main(). - get_entry_point().name = "main"; + // Entry point in GLSL is always main(). Skip the rename for library + // modules; their exports keep their declared names. + if (!options.use_entry_point_name && !ir.is_library_module) + get_entry_point().name = "main"; return buffer.str(); } @@ -901,6 +994,16 @@ void CompilerGLSL::request_subgroup_feature(ShaderSubgroupSupportHelper::Feature void CompilerGLSL::emit_header() { auto &execution = get_entry_point(); + + // Library modules have no entry point. The emitted GLSL is meant to be #include'd or appended + // rather than compiled standalone, so the version and extension directives that follow are + // wrapped in `#ifdef SPIRV_CROSS_LIBRARY_HEADER ... #endif`. By default they are skipped (the + // consuming translation unit provides its own preamble); a caller that wants to compile the + // library standalone defines SPIRV_CROSS_LIBRARY_HEADER to opt in. The stage-specific layout + // block at the end of this function is skipped entirely in library mode. + if (ir.is_library_module) + statement("#ifdef SPIRV_CROSS_LIBRARY_HEADER"); + statement("#version ", options.version, options.es && options.version > 100 ? " es" : ""); if (!options.es && options.version < 420) @@ -1110,6 +1213,13 @@ void CompilerGLSL::emit_header() for (auto &header : header_lines) statement(header); + if (ir.is_library_module) + { + statement("#endif"); + statement(""); + return; + } + SmallVector inputs; SmallVector outputs; @@ -1277,10 +1387,14 @@ void CompilerGLSL::emit_header() statement("#endif"); } - if (!options.es && execution.flags.get(ExecutionModeDepthGreater)) - statement("layout(depth_greater) out float gl_FragDepth;"); - else if (!options.es && execution.flags.get(ExecutionModeDepthLess)) - statement("layout(depth_less) out float gl_FragDepth;"); + if (!options.es || options.version >= 300) + { + const char *prec = options.es ? "highp " : ""; + if (execution.flags.get(ExecutionModeDepthGreater)) + statement("layout(depth_greater) out ", prec, "float gl_FragDepth;"); + else if (execution.flags.get(ExecutionModeDepthLess)) + statement("layout(depth_less) out ", prec, "float gl_FragDepth;"); + } if (execution.flags.get(ExecutionModeRequireFullQuadsKHR)) statement("layout(full_quads) in;"); @@ -1347,9 +1461,6 @@ void CompilerGLSL::emit_struct(SPIRType &type) emitted = true; } - if (has_extended_decoration(type.self, SPIRVCrossDecorationPaddingTarget)) - emit_struct_padding_target(type); - end_scope_decl(); if (emitted) @@ -1698,6 +1809,10 @@ uint32_t CompilerGLSL::type_to_packed_alignment(const SPIRType &type, const Bits if ((type.vecsize == 2 || type.vecsize == 4) && type.columns == 1) return type.vecsize * base_alignment; + // Special long-vector rule. + if (type.vecsize > 4) + return 4 * base_alignment; + // Rule 3 if (type.vecsize == 3 && type.columns == 1) return 4 * base_alignment; @@ -2255,6 +2370,7 @@ string CompilerGLSL::layout_for_variable(const SPIRVariable &var) (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); + bool shared_block = var.storage == StorageClassWorkgroup && typeflags.get(DecorationBlock); // GL 3.0/GLSL 1.30 is not considered legacy, but it doesn't have UBOs ... bool can_use_buffer_blocks = (options.es && options.version >= 300) || (!options.es && options.version >= 140); @@ -2288,7 +2404,7 @@ string CompilerGLSL::layout_for_variable(const SPIRVariable &var) { attr.push_back(buffer_to_packing_standard(type, false, true)); } - else if (can_use_buffer_blocks && (push_constant_block || ssbo_block)) + else if (can_use_buffer_blocks && (push_constant_block || ssbo_block || shared_block)) { attr.push_back(buffer_to_packing_standard(type, true, true)); } @@ -2390,7 +2506,7 @@ void CompilerGLSL::emit_push_constant_block(const SPIRVariable &var) else if (options.vulkan_semantics) emit_push_constant_block_vulkan(var); else if (options.emit_push_constant_as_uniform_buffer) - emit_buffer_block_native(var); + emit_buffer_block_native(&var, nullptr); else emit_push_constant_block_glsl(var); } @@ -2439,7 +2555,7 @@ void CompilerGLSL::emit_buffer_block(const SPIRVariable &var) (ubo_block && options.emit_uniform_buffer_as_plain_uniforms)) emit_buffer_block_legacy(var); else - emit_buffer_block_native(var); + emit_buffer_block_native(&var, nullptr); } void CompilerGLSL::emit_buffer_block_legacy(const SPIRVariable &var) @@ -2585,30 +2701,102 @@ void CompilerGLSL::emit_buffer_reference_block(uint32_t type_id, bool forward_de } } -void CompilerGLSL::emit_buffer_block_native(const SPIRVariable &var) +std::string CompilerGLSL::heap_meta_to_prefix(const DescriptorHeapMeta &meta) { - auto &type = get(var.basetype); + std::string prefix; + + if (meta.nonreadable) + prefix += "NoRead"; + if (meta.nonwritable) + prefix += "NoWrite"; + if (meta.coherent) + prefix += "Coherent"; + if (meta.is_volatile) + prefix += "Volatile"; + if (meta.is_restrict) + prefix += "Restrict"; + + return prefix; +} + +std::string CompilerGLSL::to_buffer_pointer_name_prefix(uint32_t ptr_id) const +{ + auto itr = std::find_if(descriptor_heap_types.begin(), descriptor_heap_types.end(), + [&](const DescriptorHeapMeta &meta) { return meta.buffer_pointer_id == ptr_id; }); + + assert(itr != descriptor_heap_types.end()); + + auto name = to_name(itr->data_type); + + // The same block type can be instantiated with different read-write decorations. + name += heap_meta_to_prefix(*itr); + + // Disambiguate since we can create multiple buffer pointers with same types. + name += to_name(itr->buffer_pointer_id); + + return join("spv", name); +} + +void CompilerGLSL::emit_buffer_block_native(const SPIRVariable *var, const DescriptorHeapMeta *heap_meta) +{ + assert(var || heap_meta); + + SPIRType *type; + if (var) + type = &get(var->basetype); + else + type = &get(heap_meta->data_type); + + Bitset flags = var ? ir.get_buffer_block_flags(*var) : ir.get_buffer_block_type_flags(*type); + auto storage = var ? var->storage : heap_meta->storage; + + if (heap_meta) + { + if (heap_meta->nonreadable) + flags.set(DecorationNonReadable); + if (heap_meta->nonwritable) + flags.set(DecorationNonWritable); + if (heap_meta->coherent) + flags.set(DecorationCoherent); + if (heap_meta->is_volatile) + flags.set(DecorationVolatile); + if (heap_meta->is_restrict) + flags.set(DecorationRestrict); + } + + bool ssbo = storage == StorageClassStorageBuffer || storage == StorageClassShaderRecordBufferKHR || + has_decoration(type->self, DecorationBufferBlock); + + bool shared = storage == StorageClassWorkgroup; + if (shared) + require_extension_internal("GL_EXT_shared_memory_block"); - Bitset flags = ir.get_buffer_block_flags(var); - 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); bool is_readonly = ssbo && flags.get(DecorationNonWritable); bool is_coherent = ssbo && flags.get(DecorationCoherent); // Block names should never alias, but from HLSL input they kind of can because block types are reused for UAVs ... - auto buffer_name = to_name(type.self, false); + auto buffer_name = to_name(type->self, false); - auto &block_namespace = ssbo ? block_ssbo_names : block_ubo_names; + if (heap_meta) + { + // The same block type can be instantiated with different read-write decorations. + buffer_name += heap_meta_to_prefix(*heap_meta); + } + + auto &block_namespace = ssbo ? block_ssbo_names : (shared ? block_shared_mem_names : block_ubo_names); // Shaders never use the block by interface name, so we don't // have to track this other than updating name caches. // If we have a collision for any reason, just fallback immediately. - if (ir.meta[type.self].decoration.alias.empty() || block_namespace.find(buffer_name) != end(block_namespace) || - resource_names.find(buffer_name) != end(resource_names)) + if (var) { - buffer_name = get_block_fallback_name(var.self); + if (ir.meta[type->self].decoration.alias.empty() || block_namespace.find(buffer_name) != end(block_namespace) || + resource_names.find(buffer_name) != end(resource_names)) + { + buffer_name = get_block_fallback_name(var->self); + } } // Make sure we get something unique for both global name scope and block name scope. @@ -2619,40 +2807,67 @@ void CompilerGLSL::emit_buffer_block_native(const SPIRVariable &var) // This cannot conflict with anything else, so we're safe now. // We cannot reuse this fallback name in neither global scope (blocked by block_names) nor block name scope. if (buffer_name.empty()) - buffer_name = join("_", get(var.basetype).self, "_", var.self); + { + if (var) + buffer_name = join("_", get(var->basetype).self, "_", var->self); + else + buffer_name = join("_", type->self); + } block_names.insert(buffer_name); block_namespace.insert(buffer_name); // Save for post-reflection later. - declared_block_names[var.self] = buffer_name; + if (var) + declared_block_names[var->self] = buffer_name; + + string layout; + + if (var) + { + layout = layout_for_variable(*var); + } + else + { + auto packing_standard = buffer_to_packing_standard(*type, ssbo, true); + layout = join("layout(", + to_descriptor_heap_layout(*type, ssbo ? StorageClassStorageBuffer : StorageClassUniform), + ", ", packing_standard, ") "); + } - statement(layout_for_variable(var), is_coherent ? "coherent " : "", is_restrict ? "restrict " : "", - is_writeonly ? "writeonly " : "", is_readonly ? "readonly " : "", ssbo ? "buffer " : "uniform ", - buffer_name); + statement(layout, is_coherent ? "coherent " : "", is_restrict ? "restrict " : "", is_writeonly ? "writeonly " : "", + is_readonly ? "readonly " : "", (ssbo ? "buffer " : (shared ? "shared " : "uniform ")), buffer_name); begin_scope(); - type.member_name_cache.clear(); + type->member_name_cache.clear(); uint32_t i = 0; - for (auto &member : type.member_types) + for (auto &member : type->member_types) { - add_member_name(type, i); - emit_struct_member(type, member, i); + add_member_name(*type, i); + emit_struct_member(*type, member, i); i++; } // Don't declare empty blocks in GLSL, this is not allowed. - if (type_is_empty(type) && !backend.supports_empty_struct) + if (type_is_empty(*type) && !backend.supports_empty_struct) statement("int empty_struct_member;"); // var.self can be used as a backup name for the block name, // so we need to make sure we don't disturb the name here on a recompile. // It will need to be reset if we have to recompile. - preserve_alias_on_reset(var.self); - add_resource_name(var.self); - end_scope_decl(to_name(var.self) + type_to_array_glsl(type, var.self)); + if (var) + { + preserve_alias_on_reset(var->self); + add_resource_name(var->self); + end_scope_decl(to_name(var->self) + type_to_array_glsl(*type, var->self)); + } + else + { + end_scope_decl(join(to_buffer_pointer_name_prefix(heap_meta->buffer_pointer_id), "ResourceHeap[]")); + } + statement(""); } @@ -3792,6 +4007,49 @@ void CompilerGLSL::emit_resources() statement(""); emitted = false; + SmallVector spec_const_dependencies; + bool legacy_spec_constant_workgroup = execution.model == ExecutionModelGLCompute && !options.vulkan_semantics && + (execution.workgroup_size.constant != 0 || execution.flags.get( + ExecutionModeLocalSizeId)); + if (legacy_spec_constant_workgroup) + { + SpecializationConstant wg_x, wg_y, wg_z; + get_work_group_size_specialization_constants(wg_x, wg_y, wg_z); + + if (wg_x.id != ConstantID(0)) + spec_const_dependencies.push_back(wg_x.id); + if (wg_y.id != ConstantID(0)) + spec_const_dependencies.push_back(wg_y.id); + if (wg_z.id != ConstantID(0)) + spec_const_dependencies.push_back(wg_z.id); + } + + const auto notify_spec_constant = [&](ConstantID id) + { + if (legacy_spec_constant_workgroup) + { + auto itr = std::find(spec_const_dependencies.begin(), spec_const_dependencies.end(), id); + + if (itr == spec_const_dependencies.end()) + return; + + spec_const_dependencies.erase(itr); + if (spec_const_dependencies.empty()) + { + SpecializationConstant wg_x, wg_y, wg_z; + // We have declared all dependencies. We must delcare the workgroup size immediately + // as subsequent spec constant ops may depend on the declaration. + // Newer glslang does not allow gl_WorkGroupSize to be accessed before layout(local_size) in; + get_work_group_size_specialization_constants(wg_x, wg_y, wg_z); + SmallVector inputs; + build_workgroup_size(inputs, wg_x, wg_y, wg_z); + statement("layout(", merge(inputs), ") in;"); + statement(""); + legacy_spec_constant_workgroup = false; + } + } + }; + // If emitted Vulkan GLSL, // emit specialization constants as actual floats, // spec op expressions will redirect to the constant name. @@ -3822,11 +4080,15 @@ void CompilerGLSL::emit_resources() emit_constant(c); emitted = true; } + + if (c.specialization) + notify_spec_constant(ConstantID(c.self)); } else if (id.get_type() == TypeConstantOp) { emit_specialization_constant_op(id.get()); emitted = true; + notify_spec_constant(ConstantID(id.get_id())); } else if (id.get_type() == TypeType) { @@ -3881,24 +4143,6 @@ void CompilerGLSL::emit_resources() if (emitted) statement(""); - // If we needed to declare work group size late, check here. - // If the work group size depends on a specialization constant, we need to declare the layout() block - // after constants (and their macros) have been declared. - if (execution.model == ExecutionModelGLCompute && !options.vulkan_semantics && - (execution.workgroup_size.constant != 0 || execution.flags.get(ExecutionModeLocalSizeId))) - { - SpecializationConstant wg_x, wg_y, wg_z; - get_work_group_size_specialization_constants(wg_x, wg_y, wg_z); - - if ((wg_x.id != ConstantID(0)) || (wg_y.id != ConstantID(0)) || (wg_z.id != ConstantID(0))) - { - SmallVector inputs; - build_workgroup_size(inputs, wg_x, wg_y, wg_z); - statement("layout(", merge(inputs), ") in;"); - statement(""); - } - } - emitted = false; if (ir.addressing_model == AddressingModelPhysicalStorageBuffer64) @@ -3914,12 +4158,13 @@ void CompilerGLSL::emit_resources() }); } - // Output UBOs and SSBOs + // Output UBOs, SSBOs, and shared memory blocks using explicit layout ir.for_each_typed_id([&](uint32_t, SPIRVariable &var) { auto &type = this->get(var.basetype); bool is_block_storage = type.storage == StorageClassStorageBuffer || type.storage == StorageClassUniform || - type.storage == StorageClassShaderRecordBufferKHR; + type.storage == StorageClassShaderRecordBufferKHR || + type.storage == StorageClassWorkgroup; bool has_block_flags = ir.meta[type.self].decoration.decoration_flags.get(DecorationBlock) || ir.meta[type.self].decoration.decoration_flags.get(DecorationBufferBlock); @@ -4072,6 +4317,54 @@ void CompilerGLSL::emit_resources() } } + bool needs_hlsl_warning = false; + + for (const auto &heap_type : descriptor_heap_types) + { + auto &type = get(heap_type.data_type); + + if (heap_type.hlsl_style_stride) + needs_hlsl_warning = true; + + if (type.basetype == SPIRType::Image || type.basetype == SPIRType::AccelerationStructure) + { + string type_layout; + + if (type.basetype == SPIRType::Image && type.image.sampled == 2 && type.image.format != ImageFormatUnknown) + { + type_layout = join("layout(", to_descriptor_heap_layout(type), ", ", format_to_glsl(type.image.format), ") ", + heap_type.nonwritable ? "readonly " : "", + heap_type.nonreadable ? "writeonly " : "", + heap_type.coherent ? "coherent " : "", + heap_type.is_volatile ? "volatile " : "", + heap_type.is_restrict ? "restrict " : "", + "uniform "); + } + else + type_layout = join("layout(", to_descriptor_heap_layout(type), ") uniform "); + + statement(type_layout, variable_decl(type, join("spv", + to_name(heap_type.name_type ? heap_type.name_type : TypeID(type.self)), "ResourceHeap")), "[];"); + } + else if (type.basetype == SPIRType::Sampler) + { + statement("layout(", to_descriptor_heap_layout(type), ") uniform ", + variable_decl(type, join("spv", + to_name(heap_type.name_type ? heap_type.name_type : TypeID(type.self)), "SamplerHeap")), "[];"); + } + else + { + emit_buffer_block_native(nullptr, &heap_type); + } + } + + if (needs_hlsl_warning) + { + statement("// WARNING: HLSL style descriptor heap stride is assumed for one or more descriptors. Allowing for compatibility with HLSL shaders."); + statement("// This may be not strictly be compatible with GLSL if sizeof(buffer) != sizeof(image)."); + statement("// Application side can convert bindless indices accordingly to compensate or use explicit mapping API to configure strides outside SPIRV-Cross."); + } + if (emitted) statement(""); } @@ -4161,19 +4454,19 @@ void CompilerGLSL::emit_output_variable_initializer(const SPIRVariable &var) 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); + auto chain = access_chain_internal(var.self, indices, 2, ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, &meta, nullptr); 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); + auto chain = access_chain_internal(var.self, indices, 2, 0, &meta, nullptr); 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); + access_chain_internal(var.self, &i, 1, ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, &meta, nullptr); statement(chain, " = ", to_expression(c.subconstants[i]), ";"); } @@ -4866,6 +5159,37 @@ void CompilerGLSL::emit_extension_workarounds(ExecutionModel model) } } +void CompilerGLSL::emit_polyfills_integer_dot_product() +{ + for (auto &op : integer_dot_products_polyfills) + { + string caps = join("[", CapabilityDotProduct); + auto &arg_type = get(op.argument_type[0]); + if (arg_type.basetype == SPIRType::SByte || arg_type.basetype == SPIRType::UByte) + caps += join(", ", CapabilityDotProductInput4x8Bit); + else if (arg_type.vecsize == 1) + caps += join(", ", CapabilityDotProductInput4x8BitPacked); + else + caps += join(", ", CapabilityDotProductInputAll); + caps += "]"; + + auto arg0 = type_to_glsl(get(op.argument_type[0])); + auto arg1 = type_to_glsl(get(op.argument_type[1])); + auto acc_arg = + (op.op == OpSDotAccSat || op.op == OpUDotAccSat || op.op == OpSUDotAccSat) + ? (", " + type_to_glsl(get(op.result_type))) : ""; + + bool packed_vector = get(op.argument_type[0]).vecsize == 1; + const char *packed_argument = packed_vector ? ", spirv_literal uint packedFormat" : ""; + + statement("spirv_instruction (extensions = [\"SPV_KHR_integer_dot_product\"], capabilities = ", + caps, ", id = ", op.op, ")"); + statement(type_to_glsl(get(op.result_type)), " ", integer_dot_product_entry_point(op), "(", + arg0, " arg0, ", arg1, " arg1", acc_arg, packed_argument, ");"); + statement(""); + } +} + void CompilerGLSL::emit_polyfills(uint32_t polyfills, bool relaxed) { const char *qual = ""; @@ -5394,8 +5718,9 @@ string CompilerGLSL::to_enclosed_pointer_expression(uint32_t id, bool register_e string CompilerGLSL::to_extract_component_expression(uint32_t id, uint32_t index) { + auto &type = expression_type(id); auto expr = to_enclosed_expression(id); - if (has_extended_decoration(id, SPIRVCrossDecorationPhysicalTypePacked)) + if (has_extended_decoration(id, SPIRVCrossDecorationPhysicalTypePacked) || type.vecsize > 4) return join(expr, "[", index, "]"); else return join(expr, ".", index_to_swizzle(index)); @@ -5537,7 +5862,7 @@ string CompilerGLSL::to_non_uniform_aware_expression(uint32_t id) { string expr = to_expression(id); - if (has_decoration(id, DecorationNonUniform)) + if (is_descriptor_non_uniform(id)) convert_non_uniform_expression(expr, id); return expr; @@ -5594,7 +5919,8 @@ string CompilerGLSL::to_expression(uint32_t id, bool register_expression_read) uint32_t physical_type_id = get_extended_decoration(id, SPIRVCrossDecorationPhysicalTypeID); bool is_packed = has_extended_decoration(id, SPIRVCrossDecorationPhysicalTypePacked); bool relaxed = has_decoration(id, DecorationRelaxedPrecision); - return convert_row_major_matrix(e.expression, get(e.expression_type), physical_type_id, + auto &value_type = get_pointee_type(get(e.expression_type)); + return convert_row_major_matrix(e.expression, value_type, physical_type_id, is_packed, relaxed); } else if (flattened_structs.count(id)) @@ -5886,6 +6212,9 @@ string CompilerGLSL::constant_op_expression(const SPIRConstantOp &cop) string left_arg = to_enclosed_expression(cop.arguments[0]); string right_arg = to_enclosed_expression(cop.arguments[1]); + auto &left_type = expression_type(cop.arguments[0]); + auto &right_type = expression_type(cop.arguments[1]); + for (uint32_t i = 2; i < uint32_t(cop.arguments.size()); i++) { uint32_t index = cop.arguments[i]; @@ -5898,11 +6227,17 @@ string CompilerGLSL::constant_op_expression(const SPIRConstantOp &cop) } else if (index >= left_components) { - expr += right_arg + "." + "xyzw"[index - left_components]; + if (right_type.vecsize <= 4) + expr += right_arg + "." + "xyzw"[index - left_components]; + else + expr += join(right_arg, "[", index - left_components, "]"); } else { - expr += left_arg + "." + "xyzw"[index]; + if (left_type.vecsize <= 4) + expr += left_arg + "." + "xyzw"[index]; + else + expr += join(left_arg, "[", index, "]"); } if (i + 1 < uint32_t(cop.arguments.size())) @@ -5929,7 +6264,7 @@ string CompilerGLSL::constant_op_expression(const SPIRConstantOp &cop) else { expr = access_chain_internal(cop.arguments[0], &cop.arguments[1], uint32_t(cop.arguments.size() - 1), - ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, nullptr); + ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, nullptr, nullptr); } return expr; } @@ -6099,12 +6434,23 @@ string CompilerGLSL::constant_expression(const SPIRConstant &c, } else { - return join(type_to_glsl(type), "(", to_expression(c.subconstants[0]), ")"); + // HLSL needs to emit scalar-to-vector constructors as C-style type casts, e.g. `(float4)1.0` vs. `vec4(1.0)`. + std::string subconst_expr = to_expression(c.subconstants[0]); + if (!backend.use_constructor_splatting && + type.vecsize > 1 && type.columns == 1 && is_scalar(get(expression_type_id(c.subconstants[0])))) + return join("(", type_to_glsl(type), ")", subconst_expr); + else + return join(type_to_glsl(type), "(", subconst_expr, ")"); } } + else if (c.subconstants.empty() && type.vecsize > 4) + { + // Null long-vector + return join(type_to_glsl(type), "(0)"); + } else if (!c.subconstants.empty()) { - // Handles Arrays and structures. + // Handles Arrays, structures and long vectors. string res; // Only consider the decay if we are inside a struct scope where we are emitting a member with Offset decoration. @@ -6491,17 +6837,26 @@ std::string CompilerGLSL::convert_double_to_string(const SPIRConstant &c, uint32 string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t vector) { - auto type = get(c.constant_type); - type.columns = 1; + const auto &composite_type = get(c.constant_type); - auto scalar_type = type; - scalar_type.vecsize = 1; + if (composite_type.op != OpTypeMatrix && composite_type.op != OpTypeVector && + composite_type.op != OpTypeInt && composite_type.op != OpTypeFloat && + composite_type.op != OpTypeBool && composite_type.op != OpTypeCooperativeMatrixKHR) + SPIRV_CROSS_THROW("Unexpected constant expression vector type."); + + const auto *vector_type = &composite_type; + if (vector_type->op == OpTypeMatrix) + vector_type = &get(vector_type->parent_type); + + const auto *scalar_type = vector_type; + if (scalar_type->op == OpTypeVector || scalar_type->op == OpTypeCooperativeMatrixKHR) + scalar_type = &get(scalar_type->parent_type); string res; bool splat = backend.use_constructor_splatting && c.vector_size() > 1; bool swizzle_splat = backend.can_swizzle_scalar && c.vector_size() > 1; - if (!type_is_floating_point(type)) + if (!type_is_floating_point(*scalar_type)) { // Cannot swizzle literal integers as a special case. swizzle_splat = false; @@ -6523,7 +6878,7 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t if (splat || swizzle_splat) { - if (type.width == 64) + if (scalar_type->width == 64) { uint64_t ident = c.scalar_u64(vector, 0); for (uint32_t i = 1; i < c.vector_size(); i++) @@ -6551,16 +6906,16 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t } if (c.vector_size() > 1 && !swizzle_splat) - res += type_to_glsl(type) + "("; + res += type_to_glsl(*vector_type) + "("; - switch (type.basetype) + switch (scalar_type->basetype) { case SPIRType::FloatE4M3: if (splat || swizzle_splat) { res += convert_floate4m3_to_string(c, vector, 0); if (swizzle_splat) - res = remap_swizzle(get(c.constant_type), 1, res); + res = remap_swizzle(composite_type, 1, res); } else { @@ -6583,7 +6938,7 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t { res += convert_half_to_string(c, vector, 0); if (swizzle_splat) - res = remap_swizzle(get(c.constant_type), 1, res); + res = remap_swizzle(composite_type, 1, res); } else { @@ -6606,7 +6961,7 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t { res += convert_float_to_string(c, vector, 0); if (swizzle_splat) - res = remap_swizzle(get(c.constant_type), 1, res); + res = remap_swizzle(composite_type, 1, res); } else { @@ -6628,7 +6983,7 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t { res += convert_double_to_string(c, vector, 0); if (swizzle_splat) - res = remap_swizzle(get(c.constant_type), 1, res); + res = remap_swizzle(composite_type, 1, res); } else { @@ -6647,14 +7002,9 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t case SPIRType::Int64: { - auto tmp = type; - tmp.vecsize = 1; - tmp.columns = 1; - auto int64_type = type_to_glsl(tmp); - if (splat) { - res += convert_to_string(c.scalar_i64(vector, 0), int64_type, backend.long_long_literal_suffix); + res += convert_to_string(c.scalar_i64(vector, 0), type_to_glsl(*scalar_type), backend.long_long_literal_suffix); } else { @@ -6663,7 +7013,7 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t if (c.vector_size() > 1 && c.specialization_constant_id(vector, i) != 0) res += to_expression(c.specialization_constant_id(vector, i)); else - res += convert_to_string(c.scalar_i64(vector, i), int64_type, backend.long_long_literal_suffix); + res += convert_to_string(c.scalar_i64(vector, i), type_to_glsl(*scalar_type), backend.long_long_literal_suffix); if (i + 1 < c.vector_size()) res += ", "; @@ -6781,7 +7131,7 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t else { // If backend doesn't have a literal suffix, we need to value cast. - res += type_to_glsl(scalar_type); + res += type_to_glsl(*scalar_type); res += "("; res += convert_to_string(c.scalar_u16(vector, i)); res += ")"; @@ -6815,7 +7165,7 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t else { // If backend doesn't have a literal suffix, we need to value cast. - res += type_to_glsl(scalar_type); + res += type_to_glsl(*scalar_type); res += "("; res += convert_to_string(c.scalar_i16(vector, i)); res += ")"; @@ -6841,7 +7191,7 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t res += to_expression(c.specialization_constant_id(vector, i)); else { - res += type_to_glsl(scalar_type); + res += type_to_glsl(*scalar_type); res += "("; res += convert_to_string(c.scalar_u8(vector, i)); res += ")"; @@ -6866,7 +7216,7 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t res += to_expression(c.specialization_constant_id(vector, i)); else { - res += type_to_glsl(scalar_type); + res += type_to_glsl(*scalar_type); res += "("; res += convert_to_string(c.scalar_i8(vector, i)); res += ")"; @@ -7386,6 +7736,7 @@ void CompilerGLSL::emit_trinary_func_op_bitextract(uint32_t result_type, uint32_ auto op2_expr = to_unpacked_expression(op2); // Use value casts here instead. Input must be exactly int or uint, but SPIR-V might be 16-bit. + expected_type.op = OpTypeInt; expected_type.basetype = input_type1; expected_type.vecsize = 1; string cast_op1 = expression_type(op1).basetype != input_type1 ? @@ -8092,7 +8443,7 @@ std::string CompilerGLSL::to_texture_op(const Instruction &i, bool sparse, bool auto &result_type = get(result_type_id); inherited_expressions.push_back(coord); - if (has_decoration(img, DecorationNonUniform) && !maybe_get_backing_variable(img)) + if (is_descriptor_non_uniform(img) && !maybe_get_backing_variable(img)) nonuniform_expression = true; switch (op) @@ -8146,6 +8497,9 @@ std::string CompilerGLSL::to_texture_op(const Instruction &i, bool sparse, bool case OpImageFetch: case OpImageSparseFetch: + if (options.vulkan_semantics && !dummy_sampler_id && (op == OpImageFetch || op == OpImageSparseFetch)) + require_extension_internal("GL_EXT_samplerless_texture_functions"); + // fallthrough case OpImageRead: // Reads == fetches in Metal (other langs will not get here) opt = &ops[4]; length -= 4; @@ -8246,6 +8600,17 @@ std::string CompilerGLSL::to_texture_op(const Instruction &i, bool sparse, bool base_args.is_proj = proj != 0; string expr; + + // texture() with bias on sampler2DArrayShadow or samplerCubeArrayShadow requires GL_EXT_texture_shadow_lod. + // textureOffset() with bias on sampler2DArrayShadow also requires it. + if (bias != 0 && dref != 0 && !fetch && !gather && + ((imgtype.image.arrayed && imgtype.image.dim == Dim2D) || + (imgtype.image.arrayed && imgtype.image.dim == DimCube)) && + is_depth_image(imgtype, img)) + { + require_extension_internal("GL_EXT_texture_shadow_lod"); + } + TextureFunctionNameArguments name_args = {}; name_args.base = base_args; @@ -8339,20 +8704,25 @@ bool CompilerGLSL::expression_is_constant_null(uint32_t id) const return c->constant_is_null(); } -bool CompilerGLSL::expression_is_non_value_type_array(uint32_t ptr) +bool CompilerGLSL::expression_is_non_value_type_array(uint32_t value_type_id, uint32_t ptr) { - auto &type = expression_type(ptr); - if (!is_array(get_pointee_type(type))) + auto &type = get(value_type_id); + if (!is_array(type)) return false; if (!backend.array_is_value_type) return true; + if (!backend.array_is_value_type_in_buffer_blocks && maybe_get_backing_buffer_pointer(ptr)) + return true; + auto *var = maybe_get_backing_variable(ptr); if (!var) return false; auto &backed_type = get(var->basetype); + + // Only consider explicitly laid out types here, not IO blocks. return !backend.array_is_value_type_in_buffer_blocks && backed_type.basetype == SPIRType::Struct && has_member_decoration(backed_type.self, 0, DecorationOffset); } @@ -8380,12 +8750,15 @@ string CompilerGLSL::to_function_name(const TextureFunctionNameArguments &args) if (((imgtype.image.arrayed && imgtype.image.dim == Dim2D) || imgtype.image.dim == DimCube) && is_depth_image(imgtype, tex) && args.lod && !args.base.is_fetch) { - if (!expression_is_constant_null(args.lod)) + if (has_extension("GL_EXT_texture_shadow_lod") || + options.vulkan_semantics || !expression_is_constant_null(args.lod)) + { + require_extension_internal("GL_EXT_texture_shadow_lod"); + } + else { - SPIRV_CROSS_THROW("textureLod on sampler2DArrayShadow is not constant 0.0. This cannot be " - "expressed in GLSL."); + workaround_lod_array_shadow_as_grad = true; } - workaround_lod_array_shadow_as_grad = true; } if (args.is_sparse_feedback) @@ -8520,9 +8893,11 @@ string CompilerGLSL::to_function_args(const TextureFunctionArguments &args, bool // To emulate this, we will have to use textureGrad with a constant gradient of 0. // The workaround will assert that the LOD is in fact constant 0, or we cannot emit correct code. // This happens for HLSL SampleCmpLevelZero on Texture2DArray and TextureCube. + // If GL_EXT_texture_shadow_lod is in use, textureLod is available directly with arbitrary LOD. bool workaround_lod_array_shadow_as_grad = ((imgtype.image.arrayed && imgtype.image.dim == Dim2D) || imgtype.image.dim == DimCube) && - is_depth_image(imgtype, img) && args.lod != 0 && !args.base.is_fetch; + is_depth_image(imgtype, img) && args.lod != 0 && !args.base.is_fetch && + !has_extension("GL_EXT_texture_shadow_lod"); if (args.dref) { @@ -10525,6 +10900,15 @@ string CompilerGLSL::builtin_to_glsl(BuiltIn builtin, StorageClass storage) return "gl_ClusterIDNV"; } + case BuiltInResourceHeapEXT: + // This builtin name is a placeholder. + // We will override this name later with prefix per actual type. + // However, this allows untyped access chain to index into the heap directly. + return "ResourceHeap"; + + case BuiltInSamplerHeapEXT: + return "SamplerHeap"; + default: return join("gl_BuiltIn_", convert_to_string(builtin)); } @@ -10586,7 +10970,8 @@ bool CompilerGLSL::access_chain_needs_stage_io_builtin_translation(uint32_t) } string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indices, uint32_t count, - AccessChainFlags flags, AccessChainMeta *meta) + AccessChainFlags flags, AccessChainMeta *meta, + const SPIRType *untyped_data_type) { string expr; @@ -10612,7 +10997,12 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice // Start traversing type hierarchy at the proper non-pointer types, // but keep type_id referencing the original pointer for use below. uint32_t type_id = expression_type_id(base); - const auto *type = &get_pointee_type(type_id); + + // If nullptr we're doing untyped pointers. + // For now we don't really care about types since we're just doing a single index into the heap. + // If we intend to support complete untyped pointers usage later, we need to pass down the base type + // and override chain type based on that. + const auto *type = untyped_data_type ? untyped_data_type : &get_pointee_type(type_id); if (!backend.native_pointers) { @@ -10644,10 +11034,14 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice access_meshlet_position_y = base_expr->access_meshlet_position_y; } - // If we are translating access to a structured buffer, the first subscript '._m0' must be hidden + // If we are translating access to a structured buffer, the first subscript '._m0' must be hidden. bool hide_first_subscript = count > 1 && is_user_type_structured(base); - const auto append_index = [&](uint32_t index, bool is_literal, bool is_ptr_chain = false) { + // If we're doing untyped access into a struct containing descriptors, skip the first index. + if (untyped_data_type && is_struct_wrapped_opaque_descriptor_array(*untyped_data_type)) + hide_first_subscript = true; + + const auto append_index = [&](uint32_t index, bool is_literal, bool is_ptr_chain) { AccessChainFlags mod_flags = flags; if (!is_literal) mod_flags &= ~ACCESS_CHAIN_INDEX_IS_LITERAL_BIT; @@ -10805,7 +11199,7 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice case BuiltInClipDistance: if (type->array.size() == 1) // Red herring. Only consider block IO for two-dimensional arrays here. { - append_index(index, is_literal); + append_index(index, is_literal, false); break; } // fallthrough @@ -10818,7 +11212,7 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice else if (var->storage == StorageClassOutput) expr = join("gl_out[", to_expression(index, register_expression_read), "].", expr); else - append_index(index, is_literal); + append_index(index, is_literal, false); break; case BuiltInPrimitiveId: @@ -10829,11 +11223,11 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice if (mesh_shader) expr = join("gl_MeshPrimitivesEXT[", to_expression(index, register_expression_read), "].", expr); else - append_index(index, is_literal); + append_index(index, is_literal, false); break; default: - append_index(index, is_literal); + append_index(index, is_literal, false); break; } } @@ -10874,7 +11268,7 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice // Some builtins are arrays in SPIR-V but not in other languages, e.g. gl_SampleMask[] is an array in SPIR-V but not in Metal. // By throwing away the index, we imply the index was 0, which it must be for gl_SampleMask. // For literal indices we are working on composites, so we ignore this since we have already converted to proper array. - append_index(index, is_literal); + append_index(index, is_literal, false); } if (var && has_decoration(var->self, DecorationBuiltIn) && @@ -10884,6 +11278,15 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice access_meshlet_position_y = true; } + if (get(type->parent_type).op == OpTypeStruct && + has_decoration(type->parent_type, DecorationArrayStride)) + { + uint32_t native_stride = get_decoration(type->parent_type, DecorationArrayStride); + uint32_t array_stride = get_decoration(type_id, DecorationArrayStride); + if (native_stride != array_stride) + expr += ".data"; + } + type_id = type->parent_type; type = &get(type_id); @@ -10968,7 +11371,14 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice else physical_type = 0; - row_major_matrix_needs_conversion = member_is_non_native_row_major_matrix(*type, index); + // GLSL does not allow `layout(row_major)` qualifier inside bare struct declarations. + // Structs used as members of UBO/SSBO blocks can have layout qualifiers applied at the block level. + // Push constant blocks in OpenGL are also emitted as bare structs (without Block decoration in output). + auto *var = maybe_get_backing_variable(base); + const bool is_push_constant_emulated = !options.vulkan_semantics && var != nullptr && var->storage == StorageClassPushConstant; + + row_major_matrix_needs_conversion = member_is_non_native_row_major_matrix(*type, index, is_push_constant_emulated); + type_id = type->member_types[index]; type = &get(type->member_types[index]); } // Matrix -> Vector @@ -10999,7 +11409,7 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice type = &get(type_id); } // Vector -> Scalar - else if (type->op == OpTypeCooperativeMatrixKHR || type->vecsize > 1) + else if (type->op == OpTypeCooperativeMatrixKHR || type->op == OpTypeVector) { string deferred_index; if (row_major_matrix_needs_conversion) @@ -11063,7 +11473,8 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice { bool out_of_bounds = index >= type->vecsize && type->op != OpTypeCooperativeMatrixKHR; - if (!is_packed && !row_major_matrix_needs_conversion && type->op != OpTypeCooperativeMatrixKHR) + if (!is_packed && !row_major_matrix_needs_conversion && type->op != OpTypeCooperativeMatrixKHR && + type->vecsize <= 4) { expr += "."; expr += index_to_swizzle(out_of_bounds ? 0 : index); @@ -11079,9 +11490,9 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice auto &c = get(index); bool out_of_bounds = (c.scalar() >= type->vecsize); - if (c.specialization) + if (c.specialization || type->vecsize > 4) { - // If the index is a spec constant, we cannot turn extract into a swizzle. + // If the index is a spec constant or long vector, we cannot turn extract into a swizzle. expr += join("[", out_of_bounds ? "0" : to_expression(index), "]"); } else @@ -11180,16 +11591,19 @@ string CompilerGLSL::to_flattened_struct_member(const string &basename, const SP return ret; } -uint32_t CompilerGLSL::get_physical_type_stride(const SPIRType &) const +uint32_t CompilerGLSL::get_physical_type_id_stride(TypeID) const { - SPIRV_CROSS_THROW("Invalid to call get_physical_type_stride on a backend without native pointer support."); + SPIRV_CROSS_THROW("Invalid to call get_physical_type_id_stride on a backend without native pointer support."); } string CompilerGLSL::access_chain(uint32_t base, const uint32_t *indices, uint32_t count, const SPIRType &target_type, - AccessChainMeta *meta, bool ptr_chain) + AccessChainMeta *meta, bool ptr_chain, const SPIRType *untyped_data_type) { if (flattened_buffer_blocks.count(base)) { + if (untyped_data_type) + SPIRV_CROSS_THROW("Flattening not compatible with untyped pointers."); + uint32_t matrix_stride = 0; uint32_t array_stride = 0; bool need_transpose = false; @@ -11207,6 +11621,9 @@ string CompilerGLSL::access_chain(uint32_t base, const uint32_t *indices, uint32 } else if (flattened_structs.count(base) && count > 0) { + if (untyped_data_type) + SPIRV_CROSS_THROW("Flattening not compatible with untyped pointers."); + AccessChainFlags flags = ACCESS_CHAIN_CHAIN_ONLY_BIT | ACCESS_CHAIN_SKIP_REGISTER_EXPRESSION_READ_BIT; if (ptr_chain) flags |= ACCESS_CHAIN_PTR_CHAIN_BIT; @@ -11218,7 +11635,7 @@ string CompilerGLSL::access_chain(uint32_t base, const uint32_t *indices, uint32 meta->flattened_struct = target_type.basetype == SPIRType::Struct; } - auto chain = access_chain_internal(base, indices, count, flags, nullptr).substr(1); + auto chain = access_chain_internal(base, indices, count, flags, nullptr, nullptr).substr(1); if (meta) { meta->need_transpose = false; @@ -11243,19 +11660,19 @@ string CompilerGLSL::access_chain(uint32_t base, const uint32_t *indices, uint32 // If there is a mismatch we have to go via 64-bit pointer arithmetic :'( // Using packed hacks only gets us so far, and is not designed to deal with pointer to // random values. It works for structs though. - auto &pointee_type = get_pointee_type(get(type_id)); - uint32_t physical_stride = get_physical_type_stride(pointee_type); + TypeID pointee_type_id = get_pointee_type_id(type_id); + uint32_t physical_stride = get_physical_type_id_stride(pointee_type_id); uint32_t requested_stride = get_decoration(type_id, DecorationArrayStride); if (physical_stride != requested_stride) { flags |= ACCESS_CHAIN_PTR_CHAIN_POINTER_ARITH_BIT; - if (is_vector(pointee_type)) + if (is_vector(get(pointee_type_id))) flags |= ACCESS_CHAIN_PTR_CHAIN_CAST_TO_SCALAR_BIT; } } } - return access_chain_internal(base, indices, count, flags, meta); + return access_chain_internal(base, indices, count, flags, meta, untyped_data_type); } } @@ -11755,6 +12172,9 @@ bool CompilerGLSL::should_forward(uint32_t id) const if (is_immutable(id)) return true; + if (expr && expr->buffer_pointer) + return true; + return false; } @@ -11843,6 +12263,8 @@ void CompilerGLSL::register_impure_function_call() flush_dependees(get(global)); for (auto aliased : aliased_variables) flush_dependees(get(aliased)); + for (auto ptr : buffer_pointer_variables) + flush_dependees(get(ptr)); } void CompilerGLSL::register_call_out_argument(uint32_t id) @@ -12258,7 +12680,7 @@ void CompilerGLSL::emit_store_statement(uint32_t lhs_expression, uint32_t rhs_ex if (!unroll_array_to_complex_store(lhs_expression, rhs_expression)) { auto lhs = to_dereferenced_expression(lhs_expression); - if (has_decoration(lhs_expression, DecorationNonUniform)) + if (is_descriptor_non_uniform(lhs_expression)) convert_non_uniform_expression(lhs, lhs_expression); // We might need to cast in order to store to a builtin. @@ -12476,6 +12898,18 @@ static bool opcode_is_precision_sensitive_operation(Op op) case OpConvertUToF: case OpConvertFToU: case OpConvertFToS: + case OpShiftLeftLogical: + case OpShiftRightLogical: + case OpShiftRightArithmetic: + case OpBitwiseOr: + case OpBitwiseXor: + case OpBitwiseAnd: + case OpNot: + case OpBitFieldInsert: + case OpBitFieldSExtract: + case OpBitFieldUExtract: + case OpBitReverse: + case OpBitCount: return true; default: @@ -12649,6 +13083,26 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // If an expression is mutable and forwardable, we speculate that it is immutable. bool forward = should_forward(ptr) && forced_temporaries.find(id) == end(forced_temporaries); + // Volatile memory access requires the value be read exactly once from + // memory. Do not forward the expression so that re-evaluation at each + // use site cannot re-read potentially modified memory. + // FIXME: To force implementations to actually respect the volatile nature of the load, + // the block itself must be marked volatile, or VulkanMM is used to do an explicit volatile load. + if (forward && length >= 4 && (ops[3] & MemoryAccessVolatileMask) != 0) + forward = false; + + // If trying to load raw BDA pointers, we may not be able to rely on aliasing rules, especially + // if that pointer came from bitcasts or similar. + // We won't be able to tie the loaded expression to a flushable memory declaration, + // so have to block forwarding early. + // If the BDA expression is loaded from a memory declaration, the memory declaration decides. + if (forward && expression_type(ptr).storage == StorageClassPhysicalStorageBuffer && + !maybe_get_backing_variable(ptr) && + !maybe_get_backing_buffer_pointer(ptr)) + { + forward = false; + } + // If loading a non-native row-major matrix, mark the expression as need_transpose. bool need_transpose = false; bool old_need_transpose = false; @@ -12712,7 +13166,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // Also, loading from gl_SampleMask array needs special unroll. unroll_array_from_complex_load(id, ptr, expr); - if (!type_is_opaque_value(type) && has_decoration(ptr, DecorationNonUniform)) + if (!type_is_opaque_value(type) && is_descriptor_non_uniform(ptr)) { // If we're loading something non-opaque, we need to handle non-uniform descriptor access. convert_non_uniform_expression(expr, ptr); @@ -12732,7 +13186,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) bool usage_tracking = flattened && (type.basetype == SPIRType::Struct || (type.columns > 1)); SPIRExpression *e = nullptr; - if (!forward && expression_is_non_value_type_array(ptr)) + if (!forward && expression_is_non_value_type_array(result_type, ptr)) { // Complicated load case where we need to make a copy of ptr, but we cannot, because // it is an array, and our backend does not support arrays as value types. @@ -12770,11 +13224,41 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) break; } + case OpUntypedPtrAccessChainKHR: + SPIRV_CROSS_THROW("OpUntypedPtrAccessChainKHR is not supported."); + break; + + case OpUntypedAccessChainKHR: + case OpUntypedInBoundsAccessChainKHR: case OpInBoundsAccessChain: case OpAccessChain: case OpPtrAccessChain: { - auto *var = maybe_get(ops[2]); + bool untyped = opcode == OpUntypedAccessChainKHR || opcode == OpUntypedInBoundsAccessChainKHR; + + uint32_t type_id = ops[0]; + uint32_t result_id = ops[1]; + uint32_t ptr_id = ops[untyped ? 3 : 2]; + uint32_t indices_start = untyped ? 4 : 3; + + if (untyped) + { + auto *var = maybe_get_backing_variable(ptr_id); + // Buffer pointers stop the loaded from chain to deal with aliasing better, so carve that out specifically. + auto *expr = maybe_get_backing_buffer_pointer(ptr_id); + + if (!expr) + { + if (!var || !has_decoration(var->self, DecorationBuiltIn) || + (BuiltIn(get_decoration(var->self, DecorationBuiltIn)) != BuiltInResourceHeapEXT && + BuiltIn(get_decoration(var->self, DecorationBuiltIn)) != BuiltInSamplerHeapEXT)) + { + SPIRV_CROSS_THROW("Untyped pointer access chains are currently only supported for descriptor heap access."); + } + } + } + + auto *var = maybe_get(ptr_id); if (var) flush_variable_declaration(var->self); @@ -12782,57 +13266,85 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // If an expression is mutable and forwardable, we speculate that it is immutable. AccessChainMeta meta; bool ptr_chain = opcode == OpPtrAccessChain; - auto &target_type = get(ops[0]); - auto e = access_chain(ops[2], &ops[3], length - 3, target_type, &meta, ptr_chain); + auto &target_type = get(type_id); + auto e = access_chain(ptr_id, &ops[indices_start], length - indices_start, target_type, &meta, ptr_chain, + untyped ? &get(ops[2]) : nullptr); + + if (untyped) + { + auto &base_data_type = get(ops[2]); + bool is_struct_wrapped_runtime_array = is_struct_wrapped_opaque_descriptor_array(base_data_type); + + TypeID descriptor_array_type_id = ops[2]; + if (is_struct_wrapped_runtime_array) + descriptor_array_type_id = base_data_type.member_types.front(); + + auto &data_type = get(descriptor_array_type_id); + auto *ptr_expr = maybe_get(ptr_id); + if (data_type.basetype == SPIRType::Image || data_type.basetype == SPIRType::Sampler || + data_type.basetype == SPIRType::AccelerationStructure || + (ptr_expr && ptr_expr->buffer_pointer)) + { + // We can resolve this type now. + // For further buffer access chains, we don't do any fixups since we have resolved to proper types. + // For buffer types we only prepend when the access chain starts from a BufferPointerEXT base. + // Multi-stage access chains are not possible for image types. + if (ptr_expr && ptr_expr->buffer_pointer) + e = join(to_buffer_pointer_name_prefix(ptr_expr->self), e); + else + e = join("spv", to_name(base_data_type.self), e); + } + } // If the base is flattened UBO of struct type, the expression has to be a composite. // In that case, backends which do not support inline syntax need it to be bound to a temporary. // Otherwise, invalid expressions like ({UBO[0].xyz, UBO[0].w, UBO[1]}).member are emitted. bool requires_temporary = false; - if (flattened_buffer_blocks.count(ops[2]) && target_type.basetype == SPIRType::Struct) + if (flattened_buffer_blocks.count(ptr_id) && target_type.basetype == SPIRType::Struct) requires_temporary = !backend.can_declare_struct_inline; auto &expr = requires_temporary ? - emit_op(ops[0], ops[1], std::move(e), false) : - set(ops[1], std::move(e), ops[0], should_forward(ops[2])); + emit_op(type_id, result_id, std::move(e), false) : + set(result_id, std::move(e), type_id, should_forward(ptr_id)); - auto *backing_variable = maybe_get_backing_variable(ops[2]); - expr.loaded_from = backing_variable ? backing_variable->self : ID(ops[2]); + auto *backing_variable = maybe_get_backing_variable(ptr_id); + expr.loaded_from = backing_variable ? backing_variable->self : ID(ptr_id); expr.need_transpose = meta.need_transpose; expr.access_chain = true; expr.access_meshlet_position_y = meta.access_meshlet_position_y; // Mark the result as being packed. Some platforms handled packed vectors differently than non-packed. if (meta.storage_is_packed) - set_extended_decoration(ops[1], SPIRVCrossDecorationPhysicalTypePacked); + set_extended_decoration(result_id, SPIRVCrossDecorationPhysicalTypePacked); if (meta.storage_physical_type != 0) - set_extended_decoration(ops[1], SPIRVCrossDecorationPhysicalTypeID, meta.storage_physical_type); + set_extended_decoration(result_id, SPIRVCrossDecorationPhysicalTypeID, meta.storage_physical_type); if (meta.storage_is_invariant) - set_decoration(ops[1], DecorationInvariant); + set_decoration(result_id, DecorationInvariant); if (meta.flattened_struct) - flattened_structs[ops[1]] = true; + flattened_structs[result_id] = true; if (meta.relaxed_precision && backend.requires_relaxed_precision_analysis) - set_decoration(ops[1], DecorationRelaxedPrecision); + set_decoration(result_id, DecorationRelaxedPrecision); if (meta.chain_is_builtin) - set_decoration(ops[1], DecorationBuiltIn, meta.builtin); + set_decoration(result_id, DecorationBuiltIn, meta.builtin); // If we have some expression dependencies in our access chain, this access chain is technically a forwarded // temporary which could be subject to invalidation. // Need to assume we're forwarded while calling inherit_expression_depdendencies. - forwarded_temporaries.insert(ops[1]); + forwarded_temporaries.insert(result_id); // The access chain itself is never forced to a temporary, but its dependencies might. - suppressed_usage_tracking.insert(ops[1]); + suppressed_usage_tracking.insert(result_id); - for (uint32_t i = 2; i < length; i++) + // Include the base pointer. + for (uint32_t i = indices_start - 1; i < length; i++) { - inherit_expression_dependencies(ops[1], ops[i]); + inherit_expression_dependencies(result_id, ops[i]); add_implied_read_expression(expr, ops[i]); } // If we have no dependencies after all, i.e., all indices in the access chain are immutable temporaries, // we're not forwarded after all. if (expr.expression_dependencies.empty()) - forwarded_temporaries.erase(ops[1]); + forwarded_temporaries.erase(result_id); break; } @@ -12866,15 +13378,80 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) break; } + case OpUntypedArrayLengthKHR: case OpArrayLength: { + bool untyped = opcode == OpUntypedArrayLengthKHR; 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); + + const SPIRType *untyped_data_type = untyped ? &get(ops[2]) : nullptr; + uint32_t ptr_id = ops[untyped ? 3 : 2]; + uint32_t index_offset = untyped ? 4 : 3; + + auto e = access_chain_internal(ptr_id, &ops[index_offset], length - index_offset, + ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, + nullptr, untyped_data_type); + + if (untyped) + { + auto *ptr_expr = maybe_get(ptr_id); + if (ptr_expr && ptr_expr->buffer_pointer) + e = join(to_buffer_pointer_name_prefix(ptr_expr->self), e); + } + + if (is_descriptor_non_uniform(ptr_id)) + convert_non_uniform_expression(e, ptr_id); + set(id, join(type_to_glsl(get(result_type)), "(", e, ".length())"), result_type, true); + break; + } + + case OpBufferPointerEXT: + { + uint32_t type_id = ops[0]; + uint32_t result_id = ops[1]; + uint32_t ptr_id = ops[2]; + + auto *backing_variable = maybe_get_backing_variable(ptr_id); + if (!backing_variable) + SPIRV_CROSS_THROW("There is no backing variable for BufferPointerEXT."); + + auto *chain_expr = maybe_get(ptr_id); + if (!chain_expr || !chain_expr->access_chain) + SPIRV_CROSS_THROW("Expected to see access chain for BufferPointerEXT."); + + auto e = to_expression(ptr_id); + + // BufferPointerEXT can return a typed pointer, in which case we need to resolve the heap alias now. + auto &type = get(type_id); + if (type.basetype == SPIRType::Struct) + e = join(to_buffer_pointer_name_prefix(result_id), e); + + auto &expr = set(result_id, std::move(e), type_id, true); + // There isn't any backing variable here. OpBufferPointerEXT is meant to be a memory declaration instruction. + expr.loaded_from = 0; + expr.access_chain = true; + expr.buffer_pointer = true; + expr.implied_read_expressions = chain_expr->implied_read_expressions; + expr.expression_dependencies = chain_expr->expression_dependencies; + expr.immutable = false; + + // If the buffer pointer is marked non-writable, ignore alias tracking by flagging the expression as immutable. + for (auto &heap : descriptor_heap_types) + { + if (heap.buffer_pointer_id == result_id) + { + if (heap.nonwritable) + expr.immutable = true; + break; + } + } + + if (!expr.immutable && ir.get_buffer_block_type_flags(get(type_id)).get(DecorationNonWritable)) + expr.immutable = true; + + // Used for load-store tracking. + buffer_pointer_variables.push_back(result_id); break; } @@ -13108,7 +13685,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // Make a copy, then use access chain to store the variable. statement(declare_temporary(result_type, id), to_expression(vec), ";"); set(id, to_name(id), result_type, true); - auto chain = access_chain_internal(id, &index, 1, 0, nullptr); + auto chain = access_chain_internal(id, &index, 1, 0, nullptr, nullptr); statement(chain, " = ", to_unpacked_expression(comp), ";"); break; } @@ -13118,7 +13695,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) uint32_t result_type = ops[0]; uint32_t id = ops[1]; - auto expr = access_chain_internal(ops[2], &ops[3], 1, 0, nullptr); + auto expr = access_chain_internal(ops[2], &ops[3], 1, 0, nullptr, nullptr); emit_op(result_type, id, expr, should_forward(ops[2])); inherit_expression_dependencies(id, ops[2]); inherit_expression_dependencies(id, ops[3]); @@ -13137,8 +13714,11 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) bool allow_base_expression = forced_temporaries.find(id) == end(forced_temporaries); // Do not allow base expression for struct members. We risk doing "swizzle" optimizations in this case. + // Long vector or arrays are complex too. auto &composite_type = expression_type(ops[2]); - bool composite_type_is_complex = composite_type.basetype == SPIRType::Struct || !composite_type.array.empty(); + bool composite_type_is_complex = composite_type.basetype == SPIRType::Struct || + !composite_type.array.empty() || + composite_type.vecsize > 4; if (composite_type_is_complex) allow_base_expression = false; @@ -13182,7 +13762,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // 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 | - ACCESS_CHAIN_FORCE_COMPOSITE_BIT, &meta); + ACCESS_CHAIN_FORCE_COMPOSITE_BIT, &meta, nullptr); 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]; @@ -13193,7 +13773,8 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) else { auto expr = access_chain_internal(ops[2], &ops[3], length, - ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_FORCE_COMPOSITE_BIT, &meta); + ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_FORCE_COMPOSITE_BIT, + &meta, nullptr); e = &emit_op(result_type, id, expr, should_forward(ops[2]), should_suppress_usage_tracking(ops[2])); inherit_expression_dependencies(id, ops[2]); } @@ -13261,7 +13842,8 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) if (!forced_temporaries.count(composite)) force_temporary_and_recompile(composite); - auto chain = access_chain_internal(composite, elems, length, ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, nullptr); + auto chain = access_chain_internal(composite, elems, length, ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, + nullptr, nullptr); statement(chain, " = ", to_unpacked_expression(obj), ";"); set(id, to_expression(composite), result_type, true); invalid_expressions.insert(composite); @@ -13280,7 +13862,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) set(id, to_name(id), result_type, true); } - auto chain = access_chain_internal(id, elems, length, ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, nullptr); + auto chain = access_chain_internal(id, elems, length, ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, nullptr, nullptr); statement(chain, " = ", to_unpacked_expression(obj), ";"); } @@ -13406,6 +13988,10 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) if (!shuffle && has_extended_decoration(vec0, SPIRVCrossDecorationPhysicalTypePacked)) shuffle = true; + // Long vector, force shuffle path since we cannot use swizzles. + if (type0.vecsize > 4) + shuffle = true; + string expr; bool should_fwd, trivial_forward; @@ -14574,7 +15160,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) op = "textureQueryLod"; auto sampler_expr = to_expression(ops[2]); - if (has_decoration(ops[2], DecorationNonUniform)) + if (is_descriptor_non_uniform(ops[2])) { if (maybe_get_backing_variable(ops[2])) convert_non_uniform_expression(sampler_expr, ops[2]); @@ -14849,23 +15435,28 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) break; } + case OpUntypedImageTexelPointerEXT: case OpImageTexelPointer: { + bool untyped = opcode == OpUntypedImageTexelPointerEXT; uint32_t result_type = ops[0]; uint32_t id = ops[1]; - auto coord_expr = to_expression(ops[3]); - auto target_coord_type = expression_type(ops[3]); + uint32_t image_id = ops[untyped ? 3 : 2]; + uint32_t coord_id = ops[untyped ? 4 : 3]; + + auto coord_expr = to_expression(coord_id); + auto target_coord_type = expression_type(coord_id); target_coord_type.basetype = SPIRType::Int; - coord_expr = bitcast_expression(target_coord_type, expression_type(ops[3]).basetype, coord_expr); + coord_expr = bitcast_expression(target_coord_type, expression_type(coord_id).basetype, coord_expr); - auto expr = join(to_expression(ops[2]), ", ", coord_expr); + auto expr = join(to_expression(image_id), ", ", coord_expr); auto &e = set(id, expr, result_type, true); // When using the pointer, we need to know which variable it is actually loaded from. - auto *var = maybe_get_backing_variable(ops[2]); + auto *var = maybe_get_backing_variable(image_id); e.loaded_from = var ? var->self : ID(0); - inherit_expression_dependencies(id, ops[3]); + inherit_expression_dependencies(id, coord_id); break; } @@ -16123,12 +16714,70 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) } else { - rhs = join(type_to_glsl(type), "(", to_expression(ops[2]), ")"); + // HLSL needs to emit scalar-to-vector constructors as C-style type casts, e.g. `(float4)1.0` vs. `vec4(1.0)`. + if (!backend.use_constructor_splatting && + type.vecsize > 1 && type.columns == 1 && is_scalar(get(expression_type_id(ops[2])))) + rhs = join("(", type_to_glsl(type), ")", to_enclosed_expression(ops[2])); + else + rhs = join(type_to_glsl(type), "(", to_expression(ops[2]), ")"); } emit_op(result_type, id, rhs, true); break; } + case OpSDot: + case OpUDot: + case OpSUDot: + case OpSDotAccSat: + case OpUDotAccSat: + case OpSUDotAccSat: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + + bool is_acc_sat = opcode == OpSDotAccSat || opcode == OpUDotAccSat || opcode == OpSUDotAccSat; + + if (length == (is_acc_sat ? 6 : 5)) + { + if (ops[length - 1] != PackedVectorFormatPackedVectorFormat4x8Bit) + SPIRV_CROSS_THROW("Only 4x8bit packing is supported."); + } + + IntegerDotProduct idot = {}; + idot.argument_type[0] = expression_type_id(ops[2]); + idot.argument_type[1] = expression_type_id(ops[3]); + idot.result_type = result_type; + idot.op = opcode; + add_integer_dot_product_polyfill(idot); + + auto expr = join(integer_dot_product_entry_point(idot), "(", to_expression(ops[2]), ", ", to_expression(ops[3])); + + if (is_acc_sat) + { + expr += ", "; + expr += to_expression(ops[4]); + } + + if (expression_type(ops[2]).vecsize == 1) + { + expr += ", "; + expr += to_string(PackedVectorFormatPackedVectorFormat4x8Bit); + } + + expr += ")"; + + bool forward = should_forward(ops[2]) && should_forward(ops[3]); + if (is_acc_sat && forward) + forward = should_forward(ops[4]); + + emit_op(result_type, id, expr, forward); + inherit_expression_dependencies(id, ops[2]); + inherit_expression_dependencies(id, ops[3]); + if (is_acc_sat) + inherit_expression_dependencies(id, ops[4]); + break; + } + default: statement("// unimplemented op ", instruction.op); break; @@ -16224,10 +16873,11 @@ bool CompilerGLSL::is_non_native_row_major_matrix(uint32_t id) } // Checks whether the member is a row_major matrix that requires conversion before use -bool CompilerGLSL::member_is_non_native_row_major_matrix(const SPIRType &type, uint32_t index) +bool CompilerGLSL::member_is_non_native_row_major_matrix(const SPIRType &type, uint32_t index, bool is_layout_disabled) { - // Natively supported row-major matrices do not need to be converted. - if (backend.native_row_major_matrix && !is_legacy()) + // Natively supported row-major matrices do not need to be converted, + // unless layout qualifiers are disabled, which is the case for Vulkan push_constant to OpenGL struct translation. + if (backend.native_row_major_matrix && !is_legacy() && !is_layout_disabled) return false; // Non-matrix or column-major matrix types do not need to be converted. @@ -16263,7 +16913,11 @@ bool CompilerGLSL::member_is_packed_physical_type(const SPIRType &type, uint32_t string CompilerGLSL::convert_row_major_matrix(string exp_str, const SPIRType &exp_type, uint32_t /* physical_type_id */, bool /*is_packed*/, bool relaxed) { + if (is_pointer(exp_type)) + SPIRV_CROSS_THROW("Cannot transpose a pointer type."); + strip_enclosed_expression(exp_str); + if (!is_matrix(exp_type)) { auto column_index = exp_str.find_last_of('['); @@ -16283,7 +16937,6 @@ string CompilerGLSL::convert_row_major_matrix(string exp_str, const SPIRType &ex column_expr = column_expr.substr(end_deferred_index) + column_expr.substr(0, end_deferred_index); } - auto transposed_expr = type_to_glsl_constructor(exp_type) + "("; // Loading a column from a row-major matrix. Unroll the load. @@ -16350,10 +17003,6 @@ void CompilerGLSL::emit_struct_member(const SPIRType &type, uint32_t member_type variable_decl(membertype, to_member_name(type, index)), ";"); } -void CompilerGLSL::emit_struct_padding_target(const SPIRType &) -{ -} - string CompilerGLSL::flags_to_qualifiers_glsl(const SPIRType &type, uint32_t id, const Bitset &flags) { // GL_EXT_buffer_reference variables can be marked as restrict. @@ -17003,6 +17652,8 @@ string CompilerGLSL::type_to_glsl(const SPIRType &type, uint32_t id) std::string component_type_str = type_to_glsl(get(type.ext.coopVecNV.component_type_id)); + // There's two options. This is an alias of VectorTypeIdEXT. + // Just use NV_coopvec for now ... return join("coopvecNV<", component_type_str, ", ", to_expression(type.ext.coopVecNV.component_count_id), ">"); } @@ -17061,9 +17712,32 @@ string CompilerGLSL::type_to_glsl(const SPIRType &type, uint32_t id) to_expression(coop_type->ext.cooperative.columns_id), ", ", use, ">"); } - if (type.vecsize == 1 && type.columns == 1) // Scalar builtin + // Array types are resolved in type_to_array_glsl. + const auto *non_array_type = &type; + while (is_array(*non_array_type)) + non_array_type = &get(non_array_type->parent_type); + + if (non_array_type->vecsize > 4 || + (long_vector_enabled && non_array_type->vecsize == 1 && non_array_type->op == OpTypeVector)) { - switch (type.basetype) + // Long vector. It also supports "smol vector" of just 1 element. + // Be conservative when enabling long vector for single vector components. + // We're very sensitive to bugs here since SPIRV-Cross code assumes that vecsize == 1 is not a vector + // in many places and SPIRType's are sometimes synthesized on the stack without + // ensuring that op is overridden to the correct scalar Op type. + // This used to be enough, but not anymore. + // The test suite is clean of this assumption, but it's very likely that we missed some edge case in the wild. + if (!options.vulkan_semantics) + SPIRV_CROSS_THROW("Long vector requires Vulkan semantics."); + + // We might have a local override in terms of sign. Ensure the top-level basetype wins. + auto parent_type = get(non_array_type->parent_type); + parent_type.basetype = non_array_type->basetype; + return join("vector<", type_to_glsl(parent_type), ", ", non_array_type->vecsize, ">"); + } + else if (non_array_type->vecsize == 1 && non_array_type->columns == 1) // Scalar builtin + { + switch (non_array_type->basetype) { case SPIRType::Boolean: return "bool"; @@ -17110,69 +17784,69 @@ string CompilerGLSL::type_to_glsl(const SPIRType &type, uint32_t id) return "???"; } } - else if (type.vecsize > 1 && type.columns == 1) // Vector builtin + else if (non_array_type->vecsize > 1 && non_array_type->columns == 1) // Vector builtin { - switch (type.basetype) + switch (non_array_type->basetype) { case SPIRType::Boolean: - return join("bvec", type.vecsize); + return join("bvec", non_array_type->vecsize); case SPIRType::SByte: - return join("i8vec", type.vecsize); + return join("i8vec", non_array_type->vecsize); case SPIRType::UByte: - return join("u8vec", type.vecsize); + return join("u8vec", non_array_type->vecsize); case SPIRType::Short: - return join("i16vec", type.vecsize); + return join("i16vec", non_array_type->vecsize); case SPIRType::UShort: - return join("u16vec", type.vecsize); + return join("u16vec", non_array_type->vecsize); case SPIRType::Int: - return join("ivec", type.vecsize); + return join("ivec", non_array_type->vecsize); case SPIRType::UInt: - return join("uvec", type.vecsize); + return join("uvec", non_array_type->vecsize); case SPIRType::Half: - return join("f16vec", type.vecsize); + return join("f16vec", non_array_type->vecsize); case SPIRType::BFloat16: if (!options.vulkan_semantics) SPIRV_CROSS_THROW("bfloat16 requires Vulkan semantics."); require_extension_internal("GL_EXT_bfloat16"); - return join("bf16vec", type.vecsize); + return join("bf16vec", non_array_type->vecsize); case SPIRType::FloatE4M3: if (!options.vulkan_semantics) SPIRV_CROSS_THROW("floate4m3_t requires Vulkan semantics."); require_extension_internal("GL_EXT_float_e4m3"); - return join("fe4m3vec", type.vecsize); + return join("fe4m3vec", non_array_type->vecsize); case SPIRType::FloatE5M2: if (!options.vulkan_semantics) SPIRV_CROSS_THROW("floate5m2_t requires Vulkan semantics."); require_extension_internal("GL_EXT_float_e5m2"); - return join("fe5m2vec", type.vecsize); + return join("fe5m2vec", non_array_type->vecsize); case SPIRType::Float: - return join("vec", type.vecsize); + return join("vec", non_array_type->vecsize); case SPIRType::Double: - return join("dvec", type.vecsize); + return join("dvec", non_array_type->vecsize); case SPIRType::Int64: - return join("i64vec", type.vecsize); + return join("i64vec", non_array_type->vecsize); case SPIRType::UInt64: - return join("u64vec", type.vecsize); + return join("u64vec", non_array_type->vecsize); default: return "???"; } } - else if (type.vecsize == type.columns) // Simple Matrix builtin + else if (non_array_type->vecsize == non_array_type->columns) // Simple Matrix builtin { - switch (type.basetype) + switch (non_array_type->basetype) { case SPIRType::Boolean: - return join("bmat", type.vecsize); + return join("bmat", non_array_type->vecsize); case SPIRType::Int: - return join("imat", type.vecsize); + return join("imat", non_array_type->vecsize); case SPIRType::UInt: - return join("umat", type.vecsize); + return join("umat", non_array_type->vecsize); case SPIRType::Half: - return join("f16mat", type.vecsize); + return join("f16mat", non_array_type->vecsize); case SPIRType::Float: - return join("mat", type.vecsize); + return join("mat", non_array_type->vecsize); case SPIRType::Double: - return join("dmat", type.vecsize); + return join("dmat", non_array_type->vecsize); // Matrix types not supported for int64/uint64. default: return "???"; @@ -17180,20 +17854,20 @@ string CompilerGLSL::type_to_glsl(const SPIRType &type, uint32_t id) } else { - switch (type.basetype) + switch (non_array_type->basetype) { case SPIRType::Boolean: - return join("bmat", type.columns, "x", type.vecsize); + return join("bmat", non_array_type->columns, "x", non_array_type->vecsize); case SPIRType::Int: - return join("imat", type.columns, "x", type.vecsize); + return join("imat", non_array_type->columns, "x", non_array_type->vecsize); case SPIRType::UInt: - return join("umat", type.columns, "x", type.vecsize); + return join("umat", non_array_type->columns, "x", non_array_type->vecsize); case SPIRType::Half: - return join("f16mat", type.columns, "x", type.vecsize); + return join("f16mat", non_array_type->columns, "x", non_array_type->vecsize); case SPIRType::Float: - return join("mat", type.columns, "x", type.vecsize); + return join("mat", non_array_type->columns, "x", non_array_type->vecsize); case SPIRType::Double: - return join("dmat", type.columns, "x", type.vecsize); + return join("dmat", non_array_type->columns, "x", non_array_type->vecsize); // Matrix types not supported for int64/uint64. default: return "???"; @@ -17372,7 +18046,12 @@ void CompilerGLSL::add_function_overload(const SPIRFunction &func) void CompilerGLSL::emit_function_prototype(SPIRFunction &func, const Bitset &return_flags) { - if (func.self != ir.default_entry_point) + // In library mode default_entry_point points at the first exported + // function; treat every export as a normal function rather than as the + // shader's entry point. + const bool is_entry_point = !ir.is_library_module && func.self == ir.default_entry_point; + + if (!is_entry_point) add_function_overload(func); // Avoid shadow declarations. @@ -17386,12 +18065,14 @@ void CompilerGLSL::emit_function_prototype(SPIRFunction &func, const Bitset &ret decl += type_to_array_glsl(type, 0); decl += " "; - if (func.self == ir.default_entry_point) + if (is_entry_point) { // If we need complex fallback in GLSL, we just wrap main() in a function // and interlock the entire shader ... if (interlocked_is_complex) decl += "spvMainInterlockedBody"; + else if (options.use_entry_point_name) + decl += get_entry_point().name; else decl += "main"; @@ -17922,13 +18603,35 @@ string CompilerGLSL::emit_continue_block(uint32_t continue_block, bool follow_tr return merge(statements); } +// Loop variable with OpUndef init: zero-init instead of leaving uninitialized (FXC X4555/X4000). +std::string CompilerGLSL::undef_loop_variable_initializer_suffix(const SPIRVariable &var) +{ + if (!backend.requires_phi_undef_zero_init) + return ""; + + uint32_t expr = var.static_expression; + if (expr == 0 || ir.ids[expr].get_type() != TypeUndef) + return ""; + + auto &type = get(var.basetype); + if (!type_can_zero_initialize(type)) + return ""; + + // variable_decl() already emits the zero initializer for an OpUndef loop variable + // in this mode; adding a second one here would produce "x = 0 = 0". + if (var.loop_variable && options.force_zero_initialized_variables) + return ""; + + return join(" = ", to_zero_initialized_expression(var.basetype)); +} + void CompilerGLSL::emit_while_loop_initializers(const SPIRBlock &block) { // While loops do not take initializers, so declare all of them outside. for (auto &loop_var : block.loop_variables) { auto &var = get(loop_var); - statement(variable_decl(var), ";"); + statement(variable_decl(var), undef_loop_variable_initializer_suffix(var), ";"); } } @@ -17960,7 +18663,10 @@ string CompilerGLSL::emit_for_loop_initializers(const SPIRBlock &block) else if (!same_types || missing_initializers == uint32_t(block.loop_variables.size())) { for (auto &loop_var : block.loop_variables) - statement(variable_decl(get(loop_var)), ";"); + { + auto &var = get(loop_var); + statement(variable_decl(var), undef_loop_variable_initializer_suffix(var), ";"); + } return ""; } else @@ -17971,10 +18677,11 @@ string CompilerGLSL::emit_for_loop_initializers(const SPIRBlock &block) for (auto &loop_var : block.loop_variables) { - uint32_t static_expr = get(loop_var).static_expression; + auto &var_for_undef = get(loop_var); + uint32_t static_expr = var_for_undef.static_expression; if (static_expr == 0 || ir.ids[static_expr].get_type() == TypeUndef) { - statement(variable_decl(get(loop_var)), ";"); + statement(variable_decl(var_for_undef), undef_loop_variable_initializer_suffix(var_for_undef), ";"); } else { @@ -18119,6 +18826,10 @@ bool CompilerGLSL::attempt_emit_loop_header(SPIRBlock &block, SPIRBlock::Method { block.disable_block_optimization = true; force_recompile(); + // We're skipping the emission of the continue block, so this is kinda redundant. + // However, it's important that we run the codegen part, since we might need to do fixups for a future pass. + // This avoids a potentially "unbounded" number of recompilation chains. + emit_continue_block(block.continue_block, true, true); begin_scope(); // We'll see an end_scope() later. return false; } @@ -18228,7 +18939,11 @@ void CompilerGLSL::emit_hoisted_temporaries(SmallVector> &tempo // There are some rare scenarios where we are asked to declare pointer types as hoisted temporaries. // This should be ignored unless we're doing actual variable pointers and backend supports it. // Access chains cannot normally be lowered to temporaries in GLSL and HLSL. - if (type.pointer && !backend.native_pointers) + if (type.pointer && (!backend.native_pointers || type_is_opaque_value(get_pointee_type(type)))) + continue; + + // Anything involving opaque objects cannot be lowered to temporaries ever. + if (type_is_opaque_value(type)) continue; add_local_variable_name(tmp.second); @@ -19350,16 +20065,28 @@ void CompilerGLSL::convert_non_uniform_expression(string &expr, uint32_t ptr_id) return; auto *var = maybe_get_backing_variable(ptr_id); - if (!var) + auto *buffer_pointer = maybe_get_backing_buffer_pointer(ptr_id); + if (!var && !buffer_pointer) return; - if (var->storage != StorageClassUniformConstant && + if (!buffer_pointer && + var->storage != StorageClassUniformConstant && var->storage != StorageClassStorageBuffer && var->storage != StorageClassUniform) return; - auto &backing_type = get(var->basetype); - if (backing_type.array.empty()) + auto &backing_type = get(var ? var->basetype : buffer_pointer->expression_type); + + bool descriptor_heap = false; + if (var) + { + auto builtin = BuiltIn(get_decoration(var->self, DecorationBuiltIn)); + descriptor_heap = builtin == BuiltInResourceHeapEXT || builtin == BuiltInSamplerHeapEXT; + } + else if (buffer_pointer) + descriptor_heap = true; + + if (!descriptor_heap && backing_type.array.empty()) return; // If we get here, we know we're accessing an arrayed resource which @@ -19446,6 +20173,7 @@ void CompilerGLSL::reset_name_caches() block_output_names.clear(); block_ubo_names.clear(); block_ssbo_names.clear(); + block_shared_mem_names.clear(); block_names.clear(); function_overloads.clear(); } @@ -19648,9 +20376,9 @@ void CompilerGLSL::emit_copy_logical_type(uint32_t lhs_id, uint32_t lhs_type_id, AccessChainMeta lhs_meta, rhs_meta; auto lhs = access_chain_internal(lhs_id, chain.data(), uint32_t(chain.size()), - ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, &lhs_meta); + ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, &lhs_meta, nullptr); auto rhs = access_chain_internal(rhs_id, chain.data(), uint32_t(chain.size()), - ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, &rhs_meta); + ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, &rhs_meta, nullptr); uint32_t id = ir.increase_bound_by(2); lhs_id = id; @@ -20340,3 +21068,130 @@ bool CompilerGLSL::has_legacy_nocontract(uint32_t result_type, uint32_t id) cons FPFastMathModeAllowReassocMask; return (get_fp_fast_math_flags_for_op(result_type, id) & fp_flags) != fp_flags; } + +void CompilerGLSL::remap_descriptor_heap(ResourceType type, uint32_t desc_set, uint32_t binding, Dim dim) +{ + for (auto &mapping : descriptor_heap_mappings) + { + if (mapping.type == type) + { + mapping.desc_set = desc_set; + mapping.binding = binding; + mapping.dim = dim; + return; + } + } + + descriptor_heap_mappings.push_back({ type, desc_set, binding, dim }); +} + +bool CompilerGLSL::is_descriptor_non_uniform(uint32_t id) const +{ + if (has_decoration(id, DecorationNonUniform)) + return true; + + // Only infer nonuniform for descriptors. + auto &type = expression_type(id); + + if (is_pointer(type)) + { + if (type.storage != StorageClassUniform && type.storage != StorageClassStorageBuffer && + type.storage != StorageClassUniformConstant && type.storage != StorageClassImage) + return false; + } + else if (!type_is_opaque_value(type)) + { + return false; + } + + if (descriptor_heap_mappings.empty()) + return false; + + if (has_decoration(id, DecorationUniform)) + return false; + + if (std::find(ir.declared_capabilities.begin(), ir.declared_capabilities.end(), + CapabilityDescriptorHeapEXT) == ir.declared_capabilities.end()) + return false; + + // Definitely not. + if (maybe_get(id) || maybe_get(id)) + return false; + + // DescriptorHeapEXT requires that nonuniformEXT is implied, + // but if we're remapping to legacy set/binding model, glslang will not emit the cap in cross compiled source, + // so we have to enforce it. We don't have compiler-infra to deduce subgroup uniformity statically, + // so just slap it on everything. Compilers generally figure this stuff out. + return true; +} + +std::string CompilerGLSL::to_descriptor_heap_layout(const SPIRType &type, StorageClass storage) const +{ + auto resource = ResourceTypeUnknown; + Dim dim = DimMax; + + switch (type.basetype) + { + case SPIRType::Sampler: + resource = ResourceTypeSeparateSamplers; + break; + + case SPIRType::Image: + dim = type.image.dim == DimBuffer ? DimBuffer : Dim2D; + resource = type.image.sampled == 2 ? ResourceTypeStorageImage : ResourceTypeSeparateImage; + break; + + case SPIRType::SampledImage: + resource = ResourceTypeSampledImage; + break; + + case SPIRType::AccelerationStructure: + resource = ResourceTypeAccelerationStructure; + break; + + case SPIRType::AtomicCounter: + resource = ResourceTypeAtomicCounter; + break; + + case SPIRType::Struct: + { + bool ssbo = storage == StorageClassStorageBuffer || has_decoration(type.self, DecorationBufferBlock); + resource = ssbo ? ResourceTypeStorageBuffer : ResourceTypeUniformBuffer; + break; + } + + default: + break; + } + + for (auto &mapping : descriptor_heap_mappings) + { + if (mapping.type == resource) + { + bool has_match = false; + + if (type.basetype == SPIRType::Image) + { + if (dim == DimBuffer && (mapping.dim == DimMax || mapping.dim == DimBuffer)) + has_match = true; + if (dim != DimBuffer && mapping.dim != DimBuffer) + has_match = true; + } + else + { + has_match = true; + } + + if (has_match) + return join("set = ", mapping.desc_set, ", binding = ", mapping.binding); + } + } + + // Fallback to unknown mapping. + for (auto &mapping : descriptor_heap_mappings) + if (mapping.type == ResourceTypeUnknown) + return join("set = ", mapping.desc_set, ", binding = ", mapping.binding); + + return "descriptor_heap"; +} + diff --git a/third_party/spirv-cross/spirv_glsl.cpp.orig b/third_party/spirv-cross/spirv_glsl.cpp.orig index 90fa14be95df..9ed7a046ab8c 100644 --- a/third_party/spirv-cross/spirv_glsl.cpp.orig +++ b/third_party/spirv-cross/spirv_glsl.cpp.orig @@ -368,6 +368,7 @@ void CompilerGLSL::reset(uint32_t iteration_count) expression_usage_counts.clear(); forwarded_temporaries.clear(); suppressed_usage_tracking.clear(); + buffer_pointer_variables.clear(); // Ensure that we declare phi-variable copies even if the original declaration isn't deferred flushed_phi_variables.clear(); @@ -382,6 +383,7 @@ void CompilerGLSL::reset(uint32_t iteration_count) }); ir.for_each_typed_id([&](uint32_t, SPIRVariable &var) { var.dependees.clear(); }); + ir.for_each_typed_id([&](uint32_t, SPIRBlock &block) { block.rearm_dominated_variables.clear(); }); ir.reset_all_of_type(); ir.reset_all_of_type(); @@ -610,7 +612,7 @@ void CompilerGLSL::find_static_extensions() { switch (cap) { - case CapabilityShaderNonUniformEXT: + case CapabilityShaderNonUniform: if (!options.vulkan_semantics) require_extension_internal("GL_NV_gpu_shader5"); else @@ -688,6 +690,22 @@ void CompilerGLSL::find_static_extensions() require_extension_internal("GL_ARM_tensors"); break; + case CapabilityDescriptorHeapEXT: + if (!options.vulkan_semantics) + SPIRV_CROSS_THROW("DescriptorHeapEXT requires Vulkan semantics."); + require_extension_internal("GL_EXT_descriptor_heap"); + require_extension_internal("GL_EXT_nonuniform_qualifier"); + // We lose information about writeonly/readonly in SPIR-V. Just pre-empt this to avoid complicating code later. + require_extension_internal("GL_EXT_shader_image_load_formatted"); + break; + + case CapabilityLongVectorEXT: + if (!options.vulkan_semantics) + SPIRV_CROSS_THROW("Long vector requires Vulkan semantics."); + require_extension_internal("GL_EXT_long_vector"); + long_vector_enabled = true; + break; + default: break; } @@ -708,6 +726,15 @@ void CompilerGLSL::find_static_extensions() require_extension_internal("GL_EXT_shader_quad_control"); } + if (execution.flags.get(ExecutionModeDepthGreater) || + execution.flags.get(ExecutionModeDepthLess)) + { + if (!options.es) + require_extension_internal("GL_ARB_conservative_depth"); + else if (options.version >= 300) + require_extension_internal("GL_EXT_conservative_depth"); + } + // KHR one is likely to get promoted at some point, so if we don't see an explicit SPIR-V extension, assume KHR. for (auto &ext : ir.declared_extensions) if (ext == "SPV_NV_fragment_shader_barycentric") @@ -740,6 +767,46 @@ void CompilerGLSL::ray_tracing_khr_fixup_locations() }); } +std::string CompilerGLSL::integer_dot_product_entry_point(const IntegerDotProduct &idot) +{ + std::string expr = "spv"; + + switch (idot.op) + { + case OpSDot: expr += "SDot"; break; + case OpUDot: expr += "UDot"; break; + case OpSUDot: expr += "SUDot"; break; + case OpSDotAccSat: expr += "SDotAccSat"; break; + case OpUDotAccSat: expr += "UDotAccSat"; break; + case OpSUDotAccSat: expr += "SUDotAccSat"; break; + default: SPIRV_CROSS_THROW("Invalid integer dot product opcode."); + } + + expr += "_" + type_to_glsl(get(idot.result_type)); + for (auto &arg : idot.argument_type) + expr += "_" + type_to_glsl(get(arg)); + + return expr; +} + +void CompilerGLSL::add_integer_dot_product_polyfill(const IntegerDotProduct &idot) +{ + for (auto &impl : integer_dot_products_polyfills) + { + if (impl.result_type == idot.result_type && + impl.argument_type[0] == idot.argument_type[0] && + impl.argument_type[1] == idot.argument_type[1] && + impl.op == idot.op) + { + return; + } + } + + require_extension_internal("GL_EXT_spirv_intrinsics"); + integer_dot_products_polyfills.push_back(idot); + force_recompile(); +} + string CompilerGLSL::compile() { ir.fixup_reserved_names(); @@ -782,6 +849,17 @@ string CompilerGLSL::compile() if (ir.addressing_model == AddressingModelPhysicalStorageBuffer64) analyze_non_block_pointer_types(); + if (std::find(ir.declared_capabilities.begin(), ir.declared_capabilities.end(), + CapabilityDescriptorHeapEXT) != ir.declared_capabilities.end()) + { + // Need to figure out all the aliased types that view the heap. + // In GLSL, each unique type must be declared with layout(descriptor_heap) type-decl spvSomeIdentResourceHeap[]; + // During untyped access chain traversal, we prefix the name to match the aliases. + // HLSL has more direct native support and will not need these, but we still need to call this function + // to verify that descriptor strides make sense. + analyze_descriptor_heap_types(); + } + uint32_t pass_count = 0; do { @@ -797,17 +875,30 @@ string CompilerGLSL::compile() emit_polyfills(required_polyfills, false); if ((options.es || options.vulkan_semantics) && required_polyfills_relaxed != 0) emit_polyfills(required_polyfills_relaxed, true); + emit_polyfills_integer_dot_product(); - emit_function(get(ir.default_entry_point), Bitset()); + if (ir.is_library_module) + { + // Emit each exported function as a normal free function. + // emit_function recursively emits callees, so internal helpers + // are picked up too. + for (auto export_id : ir.library_exported_functions) + emit_function(get(export_id), Bitset()); + } + else + emit_function(get(ir.default_entry_point), Bitset()); pass_count++; } while (is_forcing_recompilation()); // Implement the interlocked wrapper function at the end. // The body was implemented in lieu of main(). - if (interlocked_is_complex) + if (interlocked_is_complex && !ir.is_library_module) { - statement("void main()"); + if (options.use_entry_point_name) + statement("void ", get_entry_point().name, "()"); + else + statement("void main()"); begin_scope(); statement("// Interlocks were used in a way not compatible with GLSL, this is very slow."); statement("SPIRV_Cross_beginInvocationInterlock();"); @@ -816,8 +907,10 @@ string CompilerGLSL::compile() end_scope(); } - // Entry point in GLSL is always main(). - get_entry_point().name = "main"; + // Entry point in GLSL is always main(). Skip the rename for library + // modules; their exports keep their declared names. + if (!options.use_entry_point_name && !ir.is_library_module) + get_entry_point().name = "main"; return buffer.str(); } @@ -889,6 +982,16 @@ void CompilerGLSL::request_subgroup_feature(ShaderSubgroupSupportHelper::Feature void CompilerGLSL::emit_header() { auto &execution = get_entry_point(); + + // Library modules have no entry point. The emitted GLSL is meant to be #include'd or appended + // rather than compiled standalone, so the version and extension directives that follow are + // wrapped in `#ifdef SPIRV_CROSS_LIBRARY_HEADER ... #endif`. By default they are skipped (the + // consuming translation unit provides its own preamble); a caller that wants to compile the + // library standalone defines SPIRV_CROSS_LIBRARY_HEADER to opt in. The stage-specific layout + // block at the end of this function is skipped entirely in library mode. + if (ir.is_library_module) + statement("#ifdef SPIRV_CROSS_LIBRARY_HEADER"); + statement("#version ", options.version, options.es && options.version > 100 ? " es" : ""); if (!options.es && options.version < 420) @@ -1098,6 +1201,13 @@ void CompilerGLSL::emit_header() for (auto &header : header_lines) statement(header); + if (ir.is_library_module) + { + statement("#endif"); + statement(""); + return; + } + SmallVector inputs; SmallVector outputs; @@ -1265,10 +1375,14 @@ void CompilerGLSL::emit_header() statement("#endif"); } - if (!options.es && execution.flags.get(ExecutionModeDepthGreater)) - statement("layout(depth_greater) out float gl_FragDepth;"); - else if (!options.es && execution.flags.get(ExecutionModeDepthLess)) - statement("layout(depth_less) out float gl_FragDepth;"); + if (!options.es || options.version >= 300) + { + const char *prec = options.es ? "highp " : ""; + if (execution.flags.get(ExecutionModeDepthGreater)) + statement("layout(depth_greater) out ", prec, "float gl_FragDepth;"); + else if (execution.flags.get(ExecutionModeDepthLess)) + statement("layout(depth_less) out ", prec, "float gl_FragDepth;"); + } if (execution.flags.get(ExecutionModeRequireFullQuadsKHR)) statement("layout(full_quads) in;"); @@ -1335,9 +1449,6 @@ void CompilerGLSL::emit_struct(SPIRType &type) emitted = true; } - if (has_extended_decoration(type.self, SPIRVCrossDecorationPaddingTarget)) - emit_struct_padding_target(type); - end_scope_decl(); if (emitted) @@ -1686,6 +1797,10 @@ uint32_t CompilerGLSL::type_to_packed_alignment(const SPIRType &type, const Bits if ((type.vecsize == 2 || type.vecsize == 4) && type.columns == 1) return type.vecsize * base_alignment; + // Special long-vector rule. + if (type.vecsize > 4) + return 4 * base_alignment; + // Rule 3 if (type.vecsize == 3 && type.columns == 1) return 4 * base_alignment; @@ -2243,6 +2358,7 @@ string CompilerGLSL::layout_for_variable(const SPIRVariable &var) (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); + bool shared_block = var.storage == StorageClassWorkgroup && typeflags.get(DecorationBlock); // GL 3.0/GLSL 1.30 is not considered legacy, but it doesn't have UBOs ... bool can_use_buffer_blocks = (options.es && options.version >= 300) || (!options.es && options.version >= 140); @@ -2276,7 +2392,7 @@ string CompilerGLSL::layout_for_variable(const SPIRVariable &var) { attr.push_back(buffer_to_packing_standard(type, false, true)); } - else if (can_use_buffer_blocks && (push_constant_block || ssbo_block)) + else if (can_use_buffer_blocks && (push_constant_block || ssbo_block || shared_block)) { attr.push_back(buffer_to_packing_standard(type, true, true)); } @@ -2378,7 +2494,7 @@ void CompilerGLSL::emit_push_constant_block(const SPIRVariable &var) else if (options.vulkan_semantics) emit_push_constant_block_vulkan(var); else if (options.emit_push_constant_as_uniform_buffer) - emit_buffer_block_native(var); + emit_buffer_block_native(&var, nullptr); else emit_push_constant_block_glsl(var); } @@ -2427,7 +2543,7 @@ void CompilerGLSL::emit_buffer_block(const SPIRVariable &var) (ubo_block && options.emit_uniform_buffer_as_plain_uniforms)) emit_buffer_block_legacy(var); else - emit_buffer_block_native(var); + emit_buffer_block_native(&var, nullptr); } void CompilerGLSL::emit_buffer_block_legacy(const SPIRVariable &var) @@ -2573,30 +2689,102 @@ void CompilerGLSL::emit_buffer_reference_block(uint32_t type_id, bool forward_de } } -void CompilerGLSL::emit_buffer_block_native(const SPIRVariable &var) +std::string CompilerGLSL::heap_meta_to_prefix(const DescriptorHeapMeta &meta) { - auto &type = get(var.basetype); + std::string prefix; + + if (meta.nonreadable) + prefix += "NoRead"; + if (meta.nonwritable) + prefix += "NoWrite"; + if (meta.coherent) + prefix += "Coherent"; + if (meta.is_volatile) + prefix += "Volatile"; + if (meta.is_restrict) + prefix += "Restrict"; + + return prefix; +} + +std::string CompilerGLSL::to_buffer_pointer_name_prefix(uint32_t ptr_id) const +{ + auto itr = std::find_if(descriptor_heap_types.begin(), descriptor_heap_types.end(), + [&](const DescriptorHeapMeta &meta) { return meta.buffer_pointer_id == ptr_id; }); + + assert(itr != descriptor_heap_types.end()); + + auto name = to_name(itr->data_type); + + // The same block type can be instantiated with different read-write decorations. + name += heap_meta_to_prefix(*itr); + + // Disambiguate since we can create multiple buffer pointers with same types. + name += to_name(itr->buffer_pointer_id); + + return join("spv", name); +} + +void CompilerGLSL::emit_buffer_block_native(const SPIRVariable *var, const DescriptorHeapMeta *heap_meta) +{ + assert(var || heap_meta); + + SPIRType *type; + if (var) + type = &get(var->basetype); + else + type = &get(heap_meta->data_type); + + Bitset flags = var ? ir.get_buffer_block_flags(*var) : ir.get_buffer_block_type_flags(*type); + auto storage = var ? var->storage : heap_meta->storage; + + if (heap_meta) + { + if (heap_meta->nonreadable) + flags.set(DecorationNonReadable); + if (heap_meta->nonwritable) + flags.set(DecorationNonWritable); + if (heap_meta->coherent) + flags.set(DecorationCoherent); + if (heap_meta->is_volatile) + flags.set(DecorationVolatile); + if (heap_meta->is_restrict) + flags.set(DecorationRestrict); + } + + bool ssbo = storage == StorageClassStorageBuffer || storage == StorageClassShaderRecordBufferKHR || + has_decoration(type->self, DecorationBufferBlock); + + bool shared = storage == StorageClassWorkgroup; + if (shared) + require_extension_internal("GL_EXT_shared_memory_block"); - Bitset flags = ir.get_buffer_block_flags(var); - 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); bool is_readonly = ssbo && flags.get(DecorationNonWritable); bool is_coherent = ssbo && flags.get(DecorationCoherent); // Block names should never alias, but from HLSL input they kind of can because block types are reused for UAVs ... - auto buffer_name = to_name(type.self, false); + auto buffer_name = to_name(type->self, false); - auto &block_namespace = ssbo ? block_ssbo_names : block_ubo_names; + if (heap_meta) + { + // The same block type can be instantiated with different read-write decorations. + buffer_name += heap_meta_to_prefix(*heap_meta); + } + + auto &block_namespace = ssbo ? block_ssbo_names : (shared ? block_shared_mem_names : block_ubo_names); // Shaders never use the block by interface name, so we don't // have to track this other than updating name caches. // If we have a collision for any reason, just fallback immediately. - if (ir.meta[type.self].decoration.alias.empty() || block_namespace.find(buffer_name) != end(block_namespace) || - resource_names.find(buffer_name) != end(resource_names)) + if (var) { - buffer_name = get_block_fallback_name(var.self); + if (ir.meta[type->self].decoration.alias.empty() || block_namespace.find(buffer_name) != end(block_namespace) || + resource_names.find(buffer_name) != end(resource_names)) + { + buffer_name = get_block_fallback_name(var->self); + } } // Make sure we get something unique for both global name scope and block name scope. @@ -2607,40 +2795,67 @@ void CompilerGLSL::emit_buffer_block_native(const SPIRVariable &var) // This cannot conflict with anything else, so we're safe now. // We cannot reuse this fallback name in neither global scope (blocked by block_names) nor block name scope. if (buffer_name.empty()) - buffer_name = join("_", get(var.basetype).self, "_", var.self); + { + if (var) + buffer_name = join("_", get(var->basetype).self, "_", var->self); + else + buffer_name = join("_", type->self); + } block_names.insert(buffer_name); block_namespace.insert(buffer_name); // Save for post-reflection later. - declared_block_names[var.self] = buffer_name; + if (var) + declared_block_names[var->self] = buffer_name; + + string layout; + + if (var) + { + layout = layout_for_variable(*var); + } + else + { + auto packing_standard = buffer_to_packing_standard(*type, ssbo, true); + layout = join("layout(", + to_descriptor_heap_layout(*type, ssbo ? StorageClassStorageBuffer : StorageClassUniform), + ", ", packing_standard, ") "); + } - statement(layout_for_variable(var), is_coherent ? "coherent " : "", is_restrict ? "restrict " : "", - is_writeonly ? "writeonly " : "", is_readonly ? "readonly " : "", ssbo ? "buffer " : "uniform ", - buffer_name); + statement(layout, is_coherent ? "coherent " : "", is_restrict ? "restrict " : "", is_writeonly ? "writeonly " : "", + is_readonly ? "readonly " : "", (ssbo ? "buffer " : (shared ? "shared " : "uniform ")), buffer_name); begin_scope(); - type.member_name_cache.clear(); + type->member_name_cache.clear(); uint32_t i = 0; - for (auto &member : type.member_types) + for (auto &member : type->member_types) { - add_member_name(type, i); - emit_struct_member(type, member, i); + add_member_name(*type, i); + emit_struct_member(*type, member, i); i++; } // Don't declare empty blocks in GLSL, this is not allowed. - if (type_is_empty(type) && !backend.supports_empty_struct) + if (type_is_empty(*type) && !backend.supports_empty_struct) statement("int empty_struct_member;"); // var.self can be used as a backup name for the block name, // so we need to make sure we don't disturb the name here on a recompile. // It will need to be reset if we have to recompile. - preserve_alias_on_reset(var.self); - add_resource_name(var.self); - end_scope_decl(to_name(var.self) + type_to_array_glsl(type, var.self)); + if (var) + { + preserve_alias_on_reset(var->self); + add_resource_name(var->self); + end_scope_decl(to_name(var->self) + type_to_array_glsl(*type, var->self)); + } + else + { + end_scope_decl(join(to_buffer_pointer_name_prefix(heap_meta->buffer_pointer_id), "ResourceHeap[]")); + } + statement(""); } @@ -3780,6 +3995,49 @@ void CompilerGLSL::emit_resources() statement(""); emitted = false; + SmallVector spec_const_dependencies; + bool legacy_spec_constant_workgroup = execution.model == ExecutionModelGLCompute && !options.vulkan_semantics && + (execution.workgroup_size.constant != 0 || execution.flags.get( + ExecutionModeLocalSizeId)); + if (legacy_spec_constant_workgroup) + { + SpecializationConstant wg_x, wg_y, wg_z; + get_work_group_size_specialization_constants(wg_x, wg_y, wg_z); + + if (wg_x.id != ConstantID(0)) + spec_const_dependencies.push_back(wg_x.id); + if (wg_y.id != ConstantID(0)) + spec_const_dependencies.push_back(wg_y.id); + if (wg_z.id != ConstantID(0)) + spec_const_dependencies.push_back(wg_z.id); + } + + const auto notify_spec_constant = [&](ConstantID id) + { + if (legacy_spec_constant_workgroup) + { + auto itr = std::find(spec_const_dependencies.begin(), spec_const_dependencies.end(), id); + + if (itr == spec_const_dependencies.end()) + return; + + spec_const_dependencies.erase(itr); + if (spec_const_dependencies.empty()) + { + SpecializationConstant wg_x, wg_y, wg_z; + // We have declared all dependencies. We must delcare the workgroup size immediately + // as subsequent spec constant ops may depend on the declaration. + // Newer glslang does not allow gl_WorkGroupSize to be accessed before layout(local_size) in; + get_work_group_size_specialization_constants(wg_x, wg_y, wg_z); + SmallVector inputs; + build_workgroup_size(inputs, wg_x, wg_y, wg_z); + statement("layout(", merge(inputs), ") in;"); + statement(""); + legacy_spec_constant_workgroup = false; + } + } + }; + // If emitted Vulkan GLSL, // emit specialization constants as actual floats, // spec op expressions will redirect to the constant name. @@ -3810,11 +4068,15 @@ void CompilerGLSL::emit_resources() emit_constant(c); emitted = true; } + + if (c.specialization) + notify_spec_constant(ConstantID(c.self)); } else if (id.get_type() == TypeConstantOp) { emit_specialization_constant_op(id.get()); emitted = true; + notify_spec_constant(ConstantID(id.get_id())); } else if (id.get_type() == TypeType) { @@ -3869,24 +4131,6 @@ void CompilerGLSL::emit_resources() if (emitted) statement(""); - // If we needed to declare work group size late, check here. - // If the work group size depends on a specialization constant, we need to declare the layout() block - // after constants (and their macros) have been declared. - if (execution.model == ExecutionModelGLCompute && !options.vulkan_semantics && - (execution.workgroup_size.constant != 0 || execution.flags.get(ExecutionModeLocalSizeId))) - { - SpecializationConstant wg_x, wg_y, wg_z; - get_work_group_size_specialization_constants(wg_x, wg_y, wg_z); - - if ((wg_x.id != ConstantID(0)) || (wg_y.id != ConstantID(0)) || (wg_z.id != ConstantID(0))) - { - SmallVector inputs; - build_workgroup_size(inputs, wg_x, wg_y, wg_z); - statement("layout(", merge(inputs), ") in;"); - statement(""); - } - } - emitted = false; if (ir.addressing_model == AddressingModelPhysicalStorageBuffer64) @@ -3902,12 +4146,13 @@ void CompilerGLSL::emit_resources() }); } - // Output UBOs and SSBOs + // Output UBOs, SSBOs, and shared memory blocks using explicit layout ir.for_each_typed_id([&](uint32_t, SPIRVariable &var) { auto &type = this->get(var.basetype); bool is_block_storage = type.storage == StorageClassStorageBuffer || type.storage == StorageClassUniform || - type.storage == StorageClassShaderRecordBufferKHR; + type.storage == StorageClassShaderRecordBufferKHR || + type.storage == StorageClassWorkgroup; bool has_block_flags = ir.meta[type.self].decoration.decoration_flags.get(DecorationBlock) || ir.meta[type.self].decoration.decoration_flags.get(DecorationBufferBlock); @@ -4060,6 +4305,54 @@ void CompilerGLSL::emit_resources() } } + bool needs_hlsl_warning = false; + + for (const auto &heap_type : descriptor_heap_types) + { + auto &type = get(heap_type.data_type); + + if (heap_type.hlsl_style_stride) + needs_hlsl_warning = true; + + if (type.basetype == SPIRType::Image || type.basetype == SPIRType::AccelerationStructure) + { + string type_layout; + + if (type.basetype == SPIRType::Image && type.image.sampled == 2 && type.image.format != ImageFormatUnknown) + { + type_layout = join("layout(", to_descriptor_heap_layout(type), ", ", format_to_glsl(type.image.format), ") ", + heap_type.nonwritable ? "readonly " : "", + heap_type.nonreadable ? "writeonly " : "", + heap_type.coherent ? "coherent " : "", + heap_type.is_volatile ? "volatile " : "", + heap_type.is_restrict ? "restrict " : "", + "uniform "); + } + else + type_layout = join("layout(", to_descriptor_heap_layout(type), ") uniform "); + + statement(type_layout, variable_decl(type, join("spv", + to_name(heap_type.name_type ? heap_type.name_type : TypeID(type.self)), "ResourceHeap")), "[];"); + } + else if (type.basetype == SPIRType::Sampler) + { + statement("layout(", to_descriptor_heap_layout(type), ") uniform ", + variable_decl(type, join("spv", + to_name(heap_type.name_type ? heap_type.name_type : TypeID(type.self)), "SamplerHeap")), "[];"); + } + else + { + emit_buffer_block_native(nullptr, &heap_type); + } + } + + if (needs_hlsl_warning) + { + statement("// WARNING: HLSL style descriptor heap stride is assumed for one or more descriptors. Allowing for compatibility with HLSL shaders."); + statement("// This may be not strictly be compatible with GLSL if sizeof(buffer) != sizeof(image)."); + statement("// Application side can convert bindless indices accordingly to compensate or use explicit mapping API to configure strides outside SPIRV-Cross."); + } + if (emitted) statement(""); } @@ -4149,19 +4442,19 @@ void CompilerGLSL::emit_output_variable_initializer(const SPIRVariable &var) 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); + auto chain = access_chain_internal(var.self, indices, 2, ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, &meta, nullptr); 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); + auto chain = access_chain_internal(var.self, indices, 2, 0, &meta, nullptr); 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); + access_chain_internal(var.self, &i, 1, ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, &meta, nullptr); statement(chain, " = ", to_expression(c.subconstants[i]), ";"); } @@ -4854,6 +5147,37 @@ void CompilerGLSL::emit_extension_workarounds(ExecutionModel model) } } +void CompilerGLSL::emit_polyfills_integer_dot_product() +{ + for (auto &op : integer_dot_products_polyfills) + { + string caps = join("[", CapabilityDotProduct); + auto &arg_type = get(op.argument_type[0]); + if (arg_type.basetype == SPIRType::SByte || arg_type.basetype == SPIRType::UByte) + caps += join(", ", CapabilityDotProductInput4x8Bit); + else if (arg_type.vecsize == 1) + caps += join(", ", CapabilityDotProductInput4x8BitPacked); + else + caps += join(", ", CapabilityDotProductInputAll); + caps += "]"; + + auto arg0 = type_to_glsl(get(op.argument_type[0])); + auto arg1 = type_to_glsl(get(op.argument_type[1])); + auto acc_arg = + (op.op == OpSDotAccSat || op.op == OpUDotAccSat || op.op == OpSUDotAccSat) + ? (", " + type_to_glsl(get(op.result_type))) : ""; + + bool packed_vector = get(op.argument_type[0]).vecsize == 1; + const char *packed_argument = packed_vector ? ", spirv_literal uint packedFormat" : ""; + + statement("spirv_instruction (extensions = [\"SPV_KHR_integer_dot_product\"], capabilities = ", + caps, ", id = ", op.op, ")"); + statement(type_to_glsl(get(op.result_type)), " ", integer_dot_product_entry_point(op), "(", + arg0, " arg0, ", arg1, " arg1", acc_arg, packed_argument, ");"); + statement(""); + } +} + void CompilerGLSL::emit_polyfills(uint32_t polyfills, bool relaxed) { const char *qual = ""; @@ -5382,8 +5706,9 @@ string CompilerGLSL::to_enclosed_pointer_expression(uint32_t id, bool register_e string CompilerGLSL::to_extract_component_expression(uint32_t id, uint32_t index) { + auto &type = expression_type(id); auto expr = to_enclosed_expression(id); - if (has_extended_decoration(id, SPIRVCrossDecorationPhysicalTypePacked)) + if (has_extended_decoration(id, SPIRVCrossDecorationPhysicalTypePacked) || type.vecsize > 4) return join(expr, "[", index, "]"); else return join(expr, ".", index_to_swizzle(index)); @@ -5525,7 +5850,7 @@ string CompilerGLSL::to_non_uniform_aware_expression(uint32_t id) { string expr = to_expression(id); - if (has_decoration(id, DecorationNonUniform)) + if (is_descriptor_non_uniform(id)) convert_non_uniform_expression(expr, id); return expr; @@ -5582,7 +5907,8 @@ string CompilerGLSL::to_expression(uint32_t id, bool register_expression_read) uint32_t physical_type_id = get_extended_decoration(id, SPIRVCrossDecorationPhysicalTypeID); bool is_packed = has_extended_decoration(id, SPIRVCrossDecorationPhysicalTypePacked); bool relaxed = has_decoration(id, DecorationRelaxedPrecision); - return convert_row_major_matrix(e.expression, get(e.expression_type), physical_type_id, + auto &value_type = get_pointee_type(get(e.expression_type)); + return convert_row_major_matrix(e.expression, value_type, physical_type_id, is_packed, relaxed); } else if (flattened_structs.count(id)) @@ -5874,6 +6200,9 @@ string CompilerGLSL::constant_op_expression(const SPIRConstantOp &cop) string left_arg = to_enclosed_expression(cop.arguments[0]); string right_arg = to_enclosed_expression(cop.arguments[1]); + auto &left_type = expression_type(cop.arguments[0]); + auto &right_type = expression_type(cop.arguments[1]); + for (uint32_t i = 2; i < uint32_t(cop.arguments.size()); i++) { uint32_t index = cop.arguments[i]; @@ -5886,11 +6215,17 @@ string CompilerGLSL::constant_op_expression(const SPIRConstantOp &cop) } else if (index >= left_components) { - expr += right_arg + "." + "xyzw"[index - left_components]; + if (right_type.vecsize <= 4) + expr += right_arg + "." + "xyzw"[index - left_components]; + else + expr += join(right_arg, "[", index - left_components, "]"); } else { - expr += left_arg + "." + "xyzw"[index]; + if (left_type.vecsize <= 4) + expr += left_arg + "." + "xyzw"[index]; + else + expr += join(left_arg, "[", index, "]"); } if (i + 1 < uint32_t(cop.arguments.size())) @@ -5917,7 +6252,7 @@ string CompilerGLSL::constant_op_expression(const SPIRConstantOp &cop) else { expr = access_chain_internal(cop.arguments[0], &cop.arguments[1], uint32_t(cop.arguments.size() - 1), - ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, nullptr); + ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, nullptr, nullptr); } return expr; } @@ -6087,12 +6422,23 @@ string CompilerGLSL::constant_expression(const SPIRConstant &c, } else { - return join(type_to_glsl(type), "(", to_expression(c.subconstants[0]), ")"); + // HLSL needs to emit scalar-to-vector constructors as C-style type casts, e.g. `(float4)1.0` vs. `vec4(1.0)`. + std::string subconst_expr = to_expression(c.subconstants[0]); + if (!backend.use_constructor_splatting && + type.vecsize > 1 && type.columns == 1 && is_scalar(get(expression_type_id(c.subconstants[0])))) + return join("(", type_to_glsl(type), ")", subconst_expr); + else + return join(type_to_glsl(type), "(", subconst_expr, ")"); } } + else if (c.subconstants.empty() && type.vecsize > 4) + { + // Null long-vector + return join(type_to_glsl(type), "(0)"); + } else if (!c.subconstants.empty()) { - // Handles Arrays and structures. + // Handles Arrays, structures and long vectors. string res; // Only consider the decay if we are inside a struct scope where we are emitting a member with Offset decoration. @@ -6479,17 +6825,26 @@ std::string CompilerGLSL::convert_double_to_string(const SPIRConstant &c, uint32 string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t vector) { - auto type = get(c.constant_type); - type.columns = 1; + const auto &composite_type = get(c.constant_type); - auto scalar_type = type; - scalar_type.vecsize = 1; + if (composite_type.op != OpTypeMatrix && composite_type.op != OpTypeVector && + composite_type.op != OpTypeInt && composite_type.op != OpTypeFloat && + composite_type.op != OpTypeBool && composite_type.op != OpTypeCooperativeMatrixKHR) + SPIRV_CROSS_THROW("Unexpected constant expression vector type."); + + const auto *vector_type = &composite_type; + if (vector_type->op == OpTypeMatrix) + vector_type = &get(vector_type->parent_type); + + const auto *scalar_type = vector_type; + if (scalar_type->op == OpTypeVector || scalar_type->op == OpTypeCooperativeMatrixKHR) + scalar_type = &get(scalar_type->parent_type); string res; bool splat = backend.use_constructor_splatting && c.vector_size() > 1; bool swizzle_splat = backend.can_swizzle_scalar && c.vector_size() > 1; - if (!type_is_floating_point(type)) + if (!type_is_floating_point(*scalar_type)) { // Cannot swizzle literal integers as a special case. swizzle_splat = false; @@ -6511,7 +6866,7 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t if (splat || swizzle_splat) { - if (type.width == 64) + if (scalar_type->width == 64) { uint64_t ident = c.scalar_u64(vector, 0); for (uint32_t i = 1; i < c.vector_size(); i++) @@ -6539,16 +6894,16 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t } if (c.vector_size() > 1 && !swizzle_splat) - res += type_to_glsl(type) + "("; + res += type_to_glsl(*vector_type) + "("; - switch (type.basetype) + switch (scalar_type->basetype) { case SPIRType::FloatE4M3: if (splat || swizzle_splat) { res += convert_floate4m3_to_string(c, vector, 0); if (swizzle_splat) - res = remap_swizzle(get(c.constant_type), 1, res); + res = remap_swizzle(composite_type, 1, res); } else { @@ -6571,7 +6926,7 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t { res += convert_half_to_string(c, vector, 0); if (swizzle_splat) - res = remap_swizzle(get(c.constant_type), 1, res); + res = remap_swizzle(composite_type, 1, res); } else { @@ -6594,7 +6949,7 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t { res += convert_float_to_string(c, vector, 0); if (swizzle_splat) - res = remap_swizzle(get(c.constant_type), 1, res); + res = remap_swizzle(composite_type, 1, res); } else { @@ -6616,7 +6971,7 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t { res += convert_double_to_string(c, vector, 0); if (swizzle_splat) - res = remap_swizzle(get(c.constant_type), 1, res); + res = remap_swizzle(composite_type, 1, res); } else { @@ -6635,14 +6990,9 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t case SPIRType::Int64: { - auto tmp = type; - tmp.vecsize = 1; - tmp.columns = 1; - auto int64_type = type_to_glsl(tmp); - if (splat) { - res += convert_to_string(c.scalar_i64(vector, 0), int64_type, backend.long_long_literal_suffix); + res += convert_to_string(c.scalar_i64(vector, 0), type_to_glsl(*scalar_type), backend.long_long_literal_suffix); } else { @@ -6651,7 +7001,7 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t if (c.vector_size() > 1 && c.specialization_constant_id(vector, i) != 0) res += to_expression(c.specialization_constant_id(vector, i)); else - res += convert_to_string(c.scalar_i64(vector, i), int64_type, backend.long_long_literal_suffix); + res += convert_to_string(c.scalar_i64(vector, i), type_to_glsl(*scalar_type), backend.long_long_literal_suffix); if (i + 1 < c.vector_size()) res += ", "; @@ -6769,7 +7119,7 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t else { // If backend doesn't have a literal suffix, we need to value cast. - res += type_to_glsl(scalar_type); + res += type_to_glsl(*scalar_type); res += "("; res += convert_to_string(c.scalar_u16(vector, i)); res += ")"; @@ -6803,7 +7153,7 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t else { // If backend doesn't have a literal suffix, we need to value cast. - res += type_to_glsl(scalar_type); + res += type_to_glsl(*scalar_type); res += "("; res += convert_to_string(c.scalar_i16(vector, i)); res += ")"; @@ -6829,7 +7179,7 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t res += to_expression(c.specialization_constant_id(vector, i)); else { - res += type_to_glsl(scalar_type); + res += type_to_glsl(*scalar_type); res += "("; res += convert_to_string(c.scalar_u8(vector, i)); res += ")"; @@ -6854,7 +7204,7 @@ string CompilerGLSL::constant_expression_vector(const SPIRConstant &c, uint32_t res += to_expression(c.specialization_constant_id(vector, i)); else { - res += type_to_glsl(scalar_type); + res += type_to_glsl(*scalar_type); res += "("; res += convert_to_string(c.scalar_i8(vector, i)); res += ")"; @@ -7374,6 +7724,7 @@ void CompilerGLSL::emit_trinary_func_op_bitextract(uint32_t result_type, uint32_ auto op2_expr = to_unpacked_expression(op2); // Use value casts here instead. Input must be exactly int or uint, but SPIR-V might be 16-bit. + expected_type.op = OpTypeInt; expected_type.basetype = input_type1; expected_type.vecsize = 1; string cast_op1 = expression_type(op1).basetype != input_type1 ? @@ -8080,7 +8431,7 @@ std::string CompilerGLSL::to_texture_op(const Instruction &i, bool sparse, bool auto &result_type = get(result_type_id); inherited_expressions.push_back(coord); - if (has_decoration(img, DecorationNonUniform) && !maybe_get_backing_variable(img)) + if (is_descriptor_non_uniform(img) && !maybe_get_backing_variable(img)) nonuniform_expression = true; switch (op) @@ -8134,6 +8485,9 @@ std::string CompilerGLSL::to_texture_op(const Instruction &i, bool sparse, bool case OpImageFetch: case OpImageSparseFetch: + if (options.vulkan_semantics && !dummy_sampler_id && (op == OpImageFetch || op == OpImageSparseFetch)) + require_extension_internal("GL_EXT_samplerless_texture_functions"); + // fallthrough case OpImageRead: // Reads == fetches in Metal (other langs will not get here) opt = &ops[4]; length -= 4; @@ -8234,6 +8588,17 @@ std::string CompilerGLSL::to_texture_op(const Instruction &i, bool sparse, bool base_args.is_proj = proj != 0; string expr; + + // texture() with bias on sampler2DArrayShadow or samplerCubeArrayShadow requires GL_EXT_texture_shadow_lod. + // textureOffset() with bias on sampler2DArrayShadow also requires it. + if (bias != 0 && dref != 0 && !fetch && !gather && + ((imgtype.image.arrayed && imgtype.image.dim == Dim2D) || + (imgtype.image.arrayed && imgtype.image.dim == DimCube)) && + is_depth_image(imgtype, img)) + { + require_extension_internal("GL_EXT_texture_shadow_lod"); + } + TextureFunctionNameArguments name_args = {}; name_args.base = base_args; @@ -8327,20 +8692,25 @@ bool CompilerGLSL::expression_is_constant_null(uint32_t id) const return c->constant_is_null(); } -bool CompilerGLSL::expression_is_non_value_type_array(uint32_t ptr) +bool CompilerGLSL::expression_is_non_value_type_array(uint32_t value_type_id, uint32_t ptr) { - auto &type = expression_type(ptr); - if (!is_array(get_pointee_type(type))) + auto &type = get(value_type_id); + if (!is_array(type)) return false; if (!backend.array_is_value_type) return true; + if (!backend.array_is_value_type_in_buffer_blocks && maybe_get_backing_buffer_pointer(ptr)) + return true; + auto *var = maybe_get_backing_variable(ptr); if (!var) return false; auto &backed_type = get(var->basetype); + + // Only consider explicitly laid out types here, not IO blocks. return !backend.array_is_value_type_in_buffer_blocks && backed_type.basetype == SPIRType::Struct && has_member_decoration(backed_type.self, 0, DecorationOffset); } @@ -8368,12 +8738,15 @@ string CompilerGLSL::to_function_name(const TextureFunctionNameArguments &args) if (((imgtype.image.arrayed && imgtype.image.dim == Dim2D) || imgtype.image.dim == DimCube) && is_depth_image(imgtype, tex) && args.lod && !args.base.is_fetch) { - if (!expression_is_constant_null(args.lod)) + if (has_extension("GL_EXT_texture_shadow_lod") || + options.vulkan_semantics || !expression_is_constant_null(args.lod)) + { + require_extension_internal("GL_EXT_texture_shadow_lod"); + } + else { - SPIRV_CROSS_THROW("textureLod on sampler2DArrayShadow is not constant 0.0. This cannot be " - "expressed in GLSL."); + workaround_lod_array_shadow_as_grad = true; } - workaround_lod_array_shadow_as_grad = true; } if (args.is_sparse_feedback) @@ -8508,9 +8881,11 @@ string CompilerGLSL::to_function_args(const TextureFunctionArguments &args, bool // To emulate this, we will have to use textureGrad with a constant gradient of 0. // The workaround will assert that the LOD is in fact constant 0, or we cannot emit correct code. // This happens for HLSL SampleCmpLevelZero on Texture2DArray and TextureCube. + // If GL_EXT_texture_shadow_lod is in use, textureLod is available directly with arbitrary LOD. bool workaround_lod_array_shadow_as_grad = ((imgtype.image.arrayed && imgtype.image.dim == Dim2D) || imgtype.image.dim == DimCube) && - is_depth_image(imgtype, img) && args.lod != 0 && !args.base.is_fetch; + is_depth_image(imgtype, img) && args.lod != 0 && !args.base.is_fetch && + !has_extension("GL_EXT_texture_shadow_lod"); if (args.dref) { @@ -10513,6 +10888,15 @@ string CompilerGLSL::builtin_to_glsl(BuiltIn builtin, StorageClass storage) return "gl_ClusterIDNV"; } + case BuiltInResourceHeapEXT: + // This builtin name is a placeholder. + // We will override this name later with prefix per actual type. + // However, this allows untyped access chain to index into the heap directly. + return "ResourceHeap"; + + case BuiltInSamplerHeapEXT: + return "SamplerHeap"; + default: return join("gl_BuiltIn_", convert_to_string(builtin)); } @@ -10574,7 +10958,8 @@ bool CompilerGLSL::access_chain_needs_stage_io_builtin_translation(uint32_t) } string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indices, uint32_t count, - AccessChainFlags flags, AccessChainMeta *meta) + AccessChainFlags flags, AccessChainMeta *meta, + const SPIRType *untyped_data_type) { string expr; @@ -10600,7 +10985,12 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice // Start traversing type hierarchy at the proper non-pointer types, // but keep type_id referencing the original pointer for use below. uint32_t type_id = expression_type_id(base); - const auto *type = &get_pointee_type(type_id); + + // If nullptr we're doing untyped pointers. + // For now we don't really care about types since we're just doing a single index into the heap. + // If we intend to support complete untyped pointers usage later, we need to pass down the base type + // and override chain type based on that. + const auto *type = untyped_data_type ? untyped_data_type : &get_pointee_type(type_id); if (!backend.native_pointers) { @@ -10632,10 +11022,14 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice access_meshlet_position_y = base_expr->access_meshlet_position_y; } - // If we are translating access to a structured buffer, the first subscript '._m0' must be hidden + // If we are translating access to a structured buffer, the first subscript '._m0' must be hidden. bool hide_first_subscript = count > 1 && is_user_type_structured(base); - const auto append_index = [&](uint32_t index, bool is_literal, bool is_ptr_chain = false) { + // If we're doing untyped access into a struct containing descriptors, skip the first index. + if (untyped_data_type && is_struct_wrapped_opaque_descriptor_array(*untyped_data_type)) + hide_first_subscript = true; + + const auto append_index = [&](uint32_t index, bool is_literal, bool is_ptr_chain) { AccessChainFlags mod_flags = flags; if (!is_literal) mod_flags &= ~ACCESS_CHAIN_INDEX_IS_LITERAL_BIT; @@ -10793,7 +11187,7 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice case BuiltInClipDistance: if (type->array.size() == 1) // Red herring. Only consider block IO for two-dimensional arrays here. { - append_index(index, is_literal); + append_index(index, is_literal, false); break; } // fallthrough @@ -10806,7 +11200,7 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice else if (var->storage == StorageClassOutput) expr = join("gl_out[", to_expression(index, register_expression_read), "].", expr); else - append_index(index, is_literal); + append_index(index, is_literal, false); break; case BuiltInPrimitiveId: @@ -10817,11 +11211,11 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice if (mesh_shader) expr = join("gl_MeshPrimitivesEXT[", to_expression(index, register_expression_read), "].", expr); else - append_index(index, is_literal); + append_index(index, is_literal, false); break; default: - append_index(index, is_literal); + append_index(index, is_literal, false); break; } } @@ -10862,7 +11256,7 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice // Some builtins are arrays in SPIR-V but not in other languages, e.g. gl_SampleMask[] is an array in SPIR-V but not in Metal. // By throwing away the index, we imply the index was 0, which it must be for gl_SampleMask. // For literal indices we are working on composites, so we ignore this since we have already converted to proper array. - append_index(index, is_literal); + append_index(index, is_literal, false); } if (var && has_decoration(var->self, DecorationBuiltIn) && @@ -10872,6 +11266,15 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice access_meshlet_position_y = true; } + if (get(type->parent_type).op == OpTypeStruct && + has_decoration(type->parent_type, DecorationArrayStride)) + { + uint32_t native_stride = get_decoration(type->parent_type, DecorationArrayStride); + uint32_t array_stride = get_decoration(type_id, DecorationArrayStride); + if (native_stride != array_stride) + expr += ".data"; + } + type_id = type->parent_type; type = &get(type_id); @@ -10956,7 +11359,14 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice else physical_type = 0; - row_major_matrix_needs_conversion = member_is_non_native_row_major_matrix(*type, index); + // GLSL does not allow `layout(row_major)` qualifier inside bare struct declarations. + // Structs used as members of UBO/SSBO blocks can have layout qualifiers applied at the block level. + // Push constant blocks in OpenGL are also emitted as bare structs (without Block decoration in output). + auto *var = maybe_get_backing_variable(base); + const bool is_push_constant_emulated = !options.vulkan_semantics && var != nullptr && var->storage == StorageClassPushConstant; + + row_major_matrix_needs_conversion = member_is_non_native_row_major_matrix(*type, index, is_push_constant_emulated); + type_id = type->member_types[index]; type = &get(type->member_types[index]); } // Matrix -> Vector @@ -10987,7 +11397,7 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice type = &get(type_id); } // Vector -> Scalar - else if (type->op == OpTypeCooperativeMatrixKHR || type->vecsize > 1) + else if (type->op == OpTypeCooperativeMatrixKHR || type->op == OpTypeVector) { string deferred_index; if (row_major_matrix_needs_conversion) @@ -11051,7 +11461,8 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice { bool out_of_bounds = index >= type->vecsize && type->op != OpTypeCooperativeMatrixKHR; - if (!is_packed && !row_major_matrix_needs_conversion && type->op != OpTypeCooperativeMatrixKHR) + if (!is_packed && !row_major_matrix_needs_conversion && type->op != OpTypeCooperativeMatrixKHR && + type->vecsize <= 4) { expr += "."; expr += index_to_swizzle(out_of_bounds ? 0 : index); @@ -11067,9 +11478,9 @@ string CompilerGLSL::access_chain_internal(uint32_t base, const uint32_t *indice auto &c = get(index); bool out_of_bounds = (c.scalar() >= type->vecsize); - if (c.specialization) + if (c.specialization || type->vecsize > 4) { - // If the index is a spec constant, we cannot turn extract into a swizzle. + // If the index is a spec constant or long vector, we cannot turn extract into a swizzle. expr += join("[", out_of_bounds ? "0" : to_expression(index), "]"); } else @@ -11168,16 +11579,19 @@ string CompilerGLSL::to_flattened_struct_member(const string &basename, const SP return ret; } -uint32_t CompilerGLSL::get_physical_type_stride(const SPIRType &) const +uint32_t CompilerGLSL::get_physical_type_id_stride(TypeID) const { - SPIRV_CROSS_THROW("Invalid to call get_physical_type_stride on a backend without native pointer support."); + SPIRV_CROSS_THROW("Invalid to call get_physical_type_id_stride on a backend without native pointer support."); } string CompilerGLSL::access_chain(uint32_t base, const uint32_t *indices, uint32_t count, const SPIRType &target_type, - AccessChainMeta *meta, bool ptr_chain) + AccessChainMeta *meta, bool ptr_chain, const SPIRType *untyped_data_type) { if (flattened_buffer_blocks.count(base)) { + if (untyped_data_type) + SPIRV_CROSS_THROW("Flattening not compatible with untyped pointers."); + uint32_t matrix_stride = 0; uint32_t array_stride = 0; bool need_transpose = false; @@ -11195,6 +11609,9 @@ string CompilerGLSL::access_chain(uint32_t base, const uint32_t *indices, uint32 } else if (flattened_structs.count(base) && count > 0) { + if (untyped_data_type) + SPIRV_CROSS_THROW("Flattening not compatible with untyped pointers."); + AccessChainFlags flags = ACCESS_CHAIN_CHAIN_ONLY_BIT | ACCESS_CHAIN_SKIP_REGISTER_EXPRESSION_READ_BIT; if (ptr_chain) flags |= ACCESS_CHAIN_PTR_CHAIN_BIT; @@ -11206,7 +11623,7 @@ string CompilerGLSL::access_chain(uint32_t base, const uint32_t *indices, uint32 meta->flattened_struct = target_type.basetype == SPIRType::Struct; } - auto chain = access_chain_internal(base, indices, count, flags, nullptr).substr(1); + auto chain = access_chain_internal(base, indices, count, flags, nullptr, nullptr).substr(1); if (meta) { meta->need_transpose = false; @@ -11231,19 +11648,19 @@ string CompilerGLSL::access_chain(uint32_t base, const uint32_t *indices, uint32 // If there is a mismatch we have to go via 64-bit pointer arithmetic :'( // Using packed hacks only gets us so far, and is not designed to deal with pointer to // random values. It works for structs though. - auto &pointee_type = get_pointee_type(get(type_id)); - uint32_t physical_stride = get_physical_type_stride(pointee_type); + TypeID pointee_type_id = get_pointee_type_id(type_id); + uint32_t physical_stride = get_physical_type_id_stride(pointee_type_id); uint32_t requested_stride = get_decoration(type_id, DecorationArrayStride); if (physical_stride != requested_stride) { flags |= ACCESS_CHAIN_PTR_CHAIN_POINTER_ARITH_BIT; - if (is_vector(pointee_type)) + if (is_vector(get(pointee_type_id))) flags |= ACCESS_CHAIN_PTR_CHAIN_CAST_TO_SCALAR_BIT; } } } - return access_chain_internal(base, indices, count, flags, meta); + return access_chain_internal(base, indices, count, flags, meta, untyped_data_type); } } @@ -11743,6 +12160,9 @@ bool CompilerGLSL::should_forward(uint32_t id) const if (is_immutable(id)) return true; + if (expr && expr->buffer_pointer) + return true; + return false; } @@ -11831,6 +12251,8 @@ void CompilerGLSL::register_impure_function_call() flush_dependees(get(global)); for (auto aliased : aliased_variables) flush_dependees(get(aliased)); + for (auto ptr : buffer_pointer_variables) + flush_dependees(get(ptr)); } void CompilerGLSL::register_call_out_argument(uint32_t id) @@ -12246,7 +12668,7 @@ void CompilerGLSL::emit_store_statement(uint32_t lhs_expression, uint32_t rhs_ex if (!unroll_array_to_complex_store(lhs_expression, rhs_expression)) { auto lhs = to_dereferenced_expression(lhs_expression); - if (has_decoration(lhs_expression, DecorationNonUniform)) + if (is_descriptor_non_uniform(lhs_expression)) convert_non_uniform_expression(lhs, lhs_expression); // We might need to cast in order to store to a builtin. @@ -12464,6 +12886,18 @@ static bool opcode_is_precision_sensitive_operation(Op op) case OpConvertUToF: case OpConvertFToU: case OpConvertFToS: + case OpShiftLeftLogical: + case OpShiftRightLogical: + case OpShiftRightArithmetic: + case OpBitwiseOr: + case OpBitwiseXor: + case OpBitwiseAnd: + case OpNot: + case OpBitFieldInsert: + case OpBitFieldSExtract: + case OpBitFieldUExtract: + case OpBitReverse: + case OpBitCount: return true; default: @@ -12637,6 +13071,26 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // If an expression is mutable and forwardable, we speculate that it is immutable. bool forward = should_forward(ptr) && forced_temporaries.find(id) == end(forced_temporaries); + // Volatile memory access requires the value be read exactly once from + // memory. Do not forward the expression so that re-evaluation at each + // use site cannot re-read potentially modified memory. + // FIXME: To force implementations to actually respect the volatile nature of the load, + // the block itself must be marked volatile, or VulkanMM is used to do an explicit volatile load. + if (forward && length >= 4 && (ops[3] & MemoryAccessVolatileMask) != 0) + forward = false; + + // If trying to load raw BDA pointers, we may not be able to rely on aliasing rules, especially + // if that pointer came from bitcasts or similar. + // We won't be able to tie the loaded expression to a flushable memory declaration, + // so have to block forwarding early. + // If the BDA expression is loaded from a memory declaration, the memory declaration decides. + if (forward && expression_type(ptr).storage == StorageClassPhysicalStorageBuffer && + !maybe_get_backing_variable(ptr) && + !maybe_get_backing_buffer_pointer(ptr)) + { + forward = false; + } + // If loading a non-native row-major matrix, mark the expression as need_transpose. bool need_transpose = false; bool old_need_transpose = false; @@ -12700,7 +13154,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // Also, loading from gl_SampleMask array needs special unroll. unroll_array_from_complex_load(id, ptr, expr); - if (!type_is_opaque_value(type) && has_decoration(ptr, DecorationNonUniform)) + if (!type_is_opaque_value(type) && is_descriptor_non_uniform(ptr)) { // If we're loading something non-opaque, we need to handle non-uniform descriptor access. convert_non_uniform_expression(expr, ptr); @@ -12720,7 +13174,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) bool usage_tracking = flattened && (type.basetype == SPIRType::Struct || (type.columns > 1)); SPIRExpression *e = nullptr; - if (!forward && expression_is_non_value_type_array(ptr)) + if (!forward && expression_is_non_value_type_array(result_type, ptr)) { // Complicated load case where we need to make a copy of ptr, but we cannot, because // it is an array, and our backend does not support arrays as value types. @@ -12758,11 +13212,41 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) break; } + case OpUntypedPtrAccessChainKHR: + SPIRV_CROSS_THROW("OpUntypedPtrAccessChainKHR is not supported."); + break; + + case OpUntypedAccessChainKHR: + case OpUntypedInBoundsAccessChainKHR: case OpInBoundsAccessChain: case OpAccessChain: case OpPtrAccessChain: { - auto *var = maybe_get(ops[2]); + bool untyped = opcode == OpUntypedAccessChainKHR || opcode == OpUntypedInBoundsAccessChainKHR; + + uint32_t type_id = ops[0]; + uint32_t result_id = ops[1]; + uint32_t ptr_id = ops[untyped ? 3 : 2]; + uint32_t indices_start = untyped ? 4 : 3; + + if (untyped) + { + auto *var = maybe_get_backing_variable(ptr_id); + // Buffer pointers stop the loaded from chain to deal with aliasing better, so carve that out specifically. + auto *expr = maybe_get_backing_buffer_pointer(ptr_id); + + if (!expr) + { + if (!var || !has_decoration(var->self, DecorationBuiltIn) || + (BuiltIn(get_decoration(var->self, DecorationBuiltIn)) != BuiltInResourceHeapEXT && + BuiltIn(get_decoration(var->self, DecorationBuiltIn)) != BuiltInSamplerHeapEXT)) + { + SPIRV_CROSS_THROW("Untyped pointer access chains are currently only supported for descriptor heap access."); + } + } + } + + auto *var = maybe_get(ptr_id); if (var) flush_variable_declaration(var->self); @@ -12770,57 +13254,85 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // If an expression is mutable and forwardable, we speculate that it is immutable. AccessChainMeta meta; bool ptr_chain = opcode == OpPtrAccessChain; - auto &target_type = get(ops[0]); - auto e = access_chain(ops[2], &ops[3], length - 3, target_type, &meta, ptr_chain); + auto &target_type = get(type_id); + auto e = access_chain(ptr_id, &ops[indices_start], length - indices_start, target_type, &meta, ptr_chain, + untyped ? &get(ops[2]) : nullptr); + + if (untyped) + { + auto &base_data_type = get(ops[2]); + bool is_struct_wrapped_runtime_array = is_struct_wrapped_opaque_descriptor_array(base_data_type); + + TypeID descriptor_array_type_id = ops[2]; + if (is_struct_wrapped_runtime_array) + descriptor_array_type_id = base_data_type.member_types.front(); + + auto &data_type = get(descriptor_array_type_id); + auto *ptr_expr = maybe_get(ptr_id); + if (data_type.basetype == SPIRType::Image || data_type.basetype == SPIRType::Sampler || + data_type.basetype == SPIRType::AccelerationStructure || + (ptr_expr && ptr_expr->buffer_pointer)) + { + // We can resolve this type now. + // For further buffer access chains, we don't do any fixups since we have resolved to proper types. + // For buffer types we only prepend when the access chain starts from a BufferPointerEXT base. + // Multi-stage access chains are not possible for image types. + if (ptr_expr && ptr_expr->buffer_pointer) + e = join(to_buffer_pointer_name_prefix(ptr_expr->self), e); + else + e = join("spv", to_name(base_data_type.self), e); + } + } // If the base is flattened UBO of struct type, the expression has to be a composite. // In that case, backends which do not support inline syntax need it to be bound to a temporary. // Otherwise, invalid expressions like ({UBO[0].xyz, UBO[0].w, UBO[1]}).member are emitted. bool requires_temporary = false; - if (flattened_buffer_blocks.count(ops[2]) && target_type.basetype == SPIRType::Struct) + if (flattened_buffer_blocks.count(ptr_id) && target_type.basetype == SPIRType::Struct) requires_temporary = !backend.can_declare_struct_inline; auto &expr = requires_temporary ? - emit_op(ops[0], ops[1], std::move(e), false) : - set(ops[1], std::move(e), ops[0], should_forward(ops[2])); + emit_op(type_id, result_id, std::move(e), false) : + set(result_id, std::move(e), type_id, should_forward(ptr_id)); - auto *backing_variable = maybe_get_backing_variable(ops[2]); - expr.loaded_from = backing_variable ? backing_variable->self : ID(ops[2]); + auto *backing_variable = maybe_get_backing_variable(ptr_id); + expr.loaded_from = backing_variable ? backing_variable->self : ID(ptr_id); expr.need_transpose = meta.need_transpose; expr.access_chain = true; expr.access_meshlet_position_y = meta.access_meshlet_position_y; // Mark the result as being packed. Some platforms handled packed vectors differently than non-packed. if (meta.storage_is_packed) - set_extended_decoration(ops[1], SPIRVCrossDecorationPhysicalTypePacked); + set_extended_decoration(result_id, SPIRVCrossDecorationPhysicalTypePacked); if (meta.storage_physical_type != 0) - set_extended_decoration(ops[1], SPIRVCrossDecorationPhysicalTypeID, meta.storage_physical_type); + set_extended_decoration(result_id, SPIRVCrossDecorationPhysicalTypeID, meta.storage_physical_type); if (meta.storage_is_invariant) - set_decoration(ops[1], DecorationInvariant); + set_decoration(result_id, DecorationInvariant); if (meta.flattened_struct) - flattened_structs[ops[1]] = true; + flattened_structs[result_id] = true; if (meta.relaxed_precision && backend.requires_relaxed_precision_analysis) - set_decoration(ops[1], DecorationRelaxedPrecision); + set_decoration(result_id, DecorationRelaxedPrecision); if (meta.chain_is_builtin) - set_decoration(ops[1], DecorationBuiltIn, meta.builtin); + set_decoration(result_id, DecorationBuiltIn, meta.builtin); // If we have some expression dependencies in our access chain, this access chain is technically a forwarded // temporary which could be subject to invalidation. // Need to assume we're forwarded while calling inherit_expression_depdendencies. - forwarded_temporaries.insert(ops[1]); + forwarded_temporaries.insert(result_id); // The access chain itself is never forced to a temporary, but its dependencies might. - suppressed_usage_tracking.insert(ops[1]); + suppressed_usage_tracking.insert(result_id); - for (uint32_t i = 2; i < length; i++) + // Include the base pointer. + for (uint32_t i = indices_start - 1; i < length; i++) { - inherit_expression_dependencies(ops[1], ops[i]); + inherit_expression_dependencies(result_id, ops[i]); add_implied_read_expression(expr, ops[i]); } // If we have no dependencies after all, i.e., all indices in the access chain are immutable temporaries, // we're not forwarded after all. if (expr.expression_dependencies.empty()) - forwarded_temporaries.erase(ops[1]); + forwarded_temporaries.erase(result_id); break; } @@ -12854,15 +13366,80 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) break; } + case OpUntypedArrayLengthKHR: case OpArrayLength: { + bool untyped = opcode == OpUntypedArrayLengthKHR; 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); + + const SPIRType *untyped_data_type = untyped ? &get(ops[2]) : nullptr; + uint32_t ptr_id = ops[untyped ? 3 : 2]; + uint32_t index_offset = untyped ? 4 : 3; + + auto e = access_chain_internal(ptr_id, &ops[index_offset], length - index_offset, + ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, + nullptr, untyped_data_type); + + if (untyped) + { + auto *ptr_expr = maybe_get(ptr_id); + if (ptr_expr && ptr_expr->buffer_pointer) + e = join(to_buffer_pointer_name_prefix(ptr_expr->self), e); + } + + if (is_descriptor_non_uniform(ptr_id)) + convert_non_uniform_expression(e, ptr_id); + set(id, join(type_to_glsl(get(result_type)), "(", e, ".length())"), result_type, true); + break; + } + + case OpBufferPointerEXT: + { + uint32_t type_id = ops[0]; + uint32_t result_id = ops[1]; + uint32_t ptr_id = ops[2]; + + auto *backing_variable = maybe_get_backing_variable(ptr_id); + if (!backing_variable) + SPIRV_CROSS_THROW("There is no backing variable for BufferPointerEXT."); + + auto *chain_expr = maybe_get(ptr_id); + if (!chain_expr || !chain_expr->access_chain) + SPIRV_CROSS_THROW("Expected to see access chain for BufferPointerEXT."); + + auto e = to_expression(ptr_id); + + // BufferPointerEXT can return a typed pointer, in which case we need to resolve the heap alias now. + auto &type = get(type_id); + if (type.basetype == SPIRType::Struct) + e = join(to_buffer_pointer_name_prefix(result_id), e); + + auto &expr = set(result_id, std::move(e), type_id, true); + // There isn't any backing variable here. OpBufferPointerEXT is meant to be a memory declaration instruction. + expr.loaded_from = 0; + expr.access_chain = true; + expr.buffer_pointer = true; + expr.implied_read_expressions = chain_expr->implied_read_expressions; + expr.expression_dependencies = chain_expr->expression_dependencies; + expr.immutable = false; + + // If the buffer pointer is marked non-writable, ignore alias tracking by flagging the expression as immutable. + for (auto &heap : descriptor_heap_types) + { + if (heap.buffer_pointer_id == result_id) + { + if (heap.nonwritable) + expr.immutable = true; + break; + } + } + + if (!expr.immutable && ir.get_buffer_block_type_flags(get(type_id)).get(DecorationNonWritable)) + expr.immutable = true; + + // Used for load-store tracking. + buffer_pointer_variables.push_back(result_id); break; } @@ -13096,7 +13673,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // Make a copy, then use access chain to store the variable. statement(declare_temporary(result_type, id), to_expression(vec), ";"); set(id, to_name(id), result_type, true); - auto chain = access_chain_internal(id, &index, 1, 0, nullptr); + auto chain = access_chain_internal(id, &index, 1, 0, nullptr, nullptr); statement(chain, " = ", to_unpacked_expression(comp), ";"); break; } @@ -13106,7 +13683,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) uint32_t result_type = ops[0]; uint32_t id = ops[1]; - auto expr = access_chain_internal(ops[2], &ops[3], 1, 0, nullptr); + auto expr = access_chain_internal(ops[2], &ops[3], 1, 0, nullptr, nullptr); emit_op(result_type, id, expr, should_forward(ops[2])); inherit_expression_dependencies(id, ops[2]); inherit_expression_dependencies(id, ops[3]); @@ -13125,8 +13702,11 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) bool allow_base_expression = forced_temporaries.find(id) == end(forced_temporaries); // Do not allow base expression for struct members. We risk doing "swizzle" optimizations in this case. + // Long vector or arrays are complex too. auto &composite_type = expression_type(ops[2]); - bool composite_type_is_complex = composite_type.basetype == SPIRType::Struct || !composite_type.array.empty(); + bool composite_type_is_complex = composite_type.basetype == SPIRType::Struct || + !composite_type.array.empty() || + composite_type.vecsize > 4; if (composite_type_is_complex) allow_base_expression = false; @@ -13170,7 +13750,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // 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 | - ACCESS_CHAIN_FORCE_COMPOSITE_BIT, &meta); + ACCESS_CHAIN_FORCE_COMPOSITE_BIT, &meta, nullptr); 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]; @@ -13181,7 +13761,8 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) else { auto expr = access_chain_internal(ops[2], &ops[3], length, - ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_FORCE_COMPOSITE_BIT, &meta); + ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_FORCE_COMPOSITE_BIT, + &meta, nullptr); e = &emit_op(result_type, id, expr, should_forward(ops[2]), should_suppress_usage_tracking(ops[2])); inherit_expression_dependencies(id, ops[2]); } @@ -13249,7 +13830,8 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) if (!forced_temporaries.count(composite)) force_temporary_and_recompile(composite); - auto chain = access_chain_internal(composite, elems, length, ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, nullptr); + auto chain = access_chain_internal(composite, elems, length, ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, + nullptr, nullptr); statement(chain, " = ", to_unpacked_expression(obj), ";"); set(id, to_expression(composite), result_type, true); invalid_expressions.insert(composite); @@ -13268,7 +13850,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) set(id, to_name(id), result_type, true); } - auto chain = access_chain_internal(id, elems, length, ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, nullptr); + auto chain = access_chain_internal(id, elems, length, ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, nullptr, nullptr); statement(chain, " = ", to_unpacked_expression(obj), ";"); } @@ -13394,6 +13976,10 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) if (!shuffle && has_extended_decoration(vec0, SPIRVCrossDecorationPhysicalTypePacked)) shuffle = true; + // Long vector, force shuffle path since we cannot use swizzles. + if (type0.vecsize > 4) + shuffle = true; + string expr; bool should_fwd, trivial_forward; @@ -14562,7 +15148,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) op = "textureQueryLod"; auto sampler_expr = to_expression(ops[2]); - if (has_decoration(ops[2], DecorationNonUniform)) + if (is_descriptor_non_uniform(ops[2])) { if (maybe_get_backing_variable(ops[2])) convert_non_uniform_expression(sampler_expr, ops[2]); @@ -14837,23 +15423,28 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) break; } + case OpUntypedImageTexelPointerEXT: case OpImageTexelPointer: { + bool untyped = opcode == OpUntypedImageTexelPointerEXT; uint32_t result_type = ops[0]; uint32_t id = ops[1]; - auto coord_expr = to_expression(ops[3]); - auto target_coord_type = expression_type(ops[3]); + uint32_t image_id = ops[untyped ? 3 : 2]; + uint32_t coord_id = ops[untyped ? 4 : 3]; + + auto coord_expr = to_expression(coord_id); + auto target_coord_type = expression_type(coord_id); target_coord_type.basetype = SPIRType::Int; - coord_expr = bitcast_expression(target_coord_type, expression_type(ops[3]).basetype, coord_expr); + coord_expr = bitcast_expression(target_coord_type, expression_type(coord_id).basetype, coord_expr); - auto expr = join(to_expression(ops[2]), ", ", coord_expr); + auto expr = join(to_expression(image_id), ", ", coord_expr); auto &e = set(id, expr, result_type, true); // When using the pointer, we need to know which variable it is actually loaded from. - auto *var = maybe_get_backing_variable(ops[2]); + auto *var = maybe_get_backing_variable(image_id); e.loaded_from = var ? var->self : ID(0); - inherit_expression_dependencies(id, ops[3]); + inherit_expression_dependencies(id, coord_id); break; } @@ -16111,12 +16702,70 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) } else { - rhs = join(type_to_glsl(type), "(", to_expression(ops[2]), ")"); + // HLSL needs to emit scalar-to-vector constructors as C-style type casts, e.g. `(float4)1.0` vs. `vec4(1.0)`. + if (!backend.use_constructor_splatting && + type.vecsize > 1 && type.columns == 1 && is_scalar(get(expression_type_id(ops[2])))) + rhs = join("(", type_to_glsl(type), ")", to_enclosed_expression(ops[2])); + else + rhs = join(type_to_glsl(type), "(", to_expression(ops[2]), ")"); } emit_op(result_type, id, rhs, true); break; } + case OpSDot: + case OpUDot: + case OpSUDot: + case OpSDotAccSat: + case OpUDotAccSat: + case OpSUDotAccSat: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + + bool is_acc_sat = opcode == OpSDotAccSat || opcode == OpUDotAccSat || opcode == OpSUDotAccSat; + + if (length == (is_acc_sat ? 6 : 5)) + { + if (ops[length - 1] != PackedVectorFormatPackedVectorFormat4x8Bit) + SPIRV_CROSS_THROW("Only 4x8bit packing is supported."); + } + + IntegerDotProduct idot = {}; + idot.argument_type[0] = expression_type_id(ops[2]); + idot.argument_type[1] = expression_type_id(ops[3]); + idot.result_type = result_type; + idot.op = opcode; + add_integer_dot_product_polyfill(idot); + + auto expr = join(integer_dot_product_entry_point(idot), "(", to_expression(ops[2]), ", ", to_expression(ops[3])); + + if (is_acc_sat) + { + expr += ", "; + expr += to_expression(ops[4]); + } + + if (expression_type(ops[2]).vecsize == 1) + { + expr += ", "; + expr += to_string(PackedVectorFormatPackedVectorFormat4x8Bit); + } + + expr += ")"; + + bool forward = should_forward(ops[2]) && should_forward(ops[3]); + if (is_acc_sat && forward) + forward = should_forward(ops[4]); + + emit_op(result_type, id, expr, forward); + inherit_expression_dependencies(id, ops[2]); + inherit_expression_dependencies(id, ops[3]); + if (is_acc_sat) + inherit_expression_dependencies(id, ops[4]); + break; + } + default: statement("// unimplemented op ", instruction.op); break; @@ -16212,10 +16861,11 @@ bool CompilerGLSL::is_non_native_row_major_matrix(uint32_t id) } // Checks whether the member is a row_major matrix that requires conversion before use -bool CompilerGLSL::member_is_non_native_row_major_matrix(const SPIRType &type, uint32_t index) +bool CompilerGLSL::member_is_non_native_row_major_matrix(const SPIRType &type, uint32_t index, bool is_layout_disabled) { - // Natively supported row-major matrices do not need to be converted. - if (backend.native_row_major_matrix && !is_legacy()) + // Natively supported row-major matrices do not need to be converted, + // unless layout qualifiers are disabled, which is the case for Vulkan push_constant to OpenGL struct translation. + if (backend.native_row_major_matrix && !is_legacy() && !is_layout_disabled) return false; // Non-matrix or column-major matrix types do not need to be converted. @@ -16251,7 +16901,11 @@ bool CompilerGLSL::member_is_packed_physical_type(const SPIRType &type, uint32_t string CompilerGLSL::convert_row_major_matrix(string exp_str, const SPIRType &exp_type, uint32_t /* physical_type_id */, bool /*is_packed*/, bool relaxed) { + if (is_pointer(exp_type)) + SPIRV_CROSS_THROW("Cannot transpose a pointer type."); + strip_enclosed_expression(exp_str); + if (!is_matrix(exp_type)) { auto column_index = exp_str.find_last_of('['); @@ -16271,7 +16925,6 @@ string CompilerGLSL::convert_row_major_matrix(string exp_str, const SPIRType &ex column_expr = column_expr.substr(end_deferred_index) + column_expr.substr(0, end_deferred_index); } - auto transposed_expr = type_to_glsl_constructor(exp_type) + "("; // Loading a column from a row-major matrix. Unroll the load. @@ -16338,10 +16991,6 @@ void CompilerGLSL::emit_struct_member(const SPIRType &type, uint32_t member_type variable_decl(membertype, to_member_name(type, index)), ";"); } -void CompilerGLSL::emit_struct_padding_target(const SPIRType &) -{ -} - string CompilerGLSL::flags_to_qualifiers_glsl(const SPIRType &type, uint32_t id, const Bitset &flags) { // GL_EXT_buffer_reference variables can be marked as restrict. @@ -16991,6 +17640,8 @@ string CompilerGLSL::type_to_glsl(const SPIRType &type, uint32_t id) std::string component_type_str = type_to_glsl(get(type.ext.coopVecNV.component_type_id)); + // There's two options. This is an alias of VectorTypeIdEXT. + // Just use NV_coopvec for now ... return join("coopvecNV<", component_type_str, ", ", to_expression(type.ext.coopVecNV.component_count_id), ">"); } @@ -17049,9 +17700,32 @@ string CompilerGLSL::type_to_glsl(const SPIRType &type, uint32_t id) to_expression(coop_type->ext.cooperative.columns_id), ", ", use, ">"); } - if (type.vecsize == 1 && type.columns == 1) // Scalar builtin + // Array types are resolved in type_to_array_glsl. + const auto *non_array_type = &type; + while (is_array(*non_array_type)) + non_array_type = &get(non_array_type->parent_type); + + if (non_array_type->vecsize > 4 || + (long_vector_enabled && non_array_type->vecsize == 1 && non_array_type->op == OpTypeVector)) { - switch (type.basetype) + // Long vector. It also supports "smol vector" of just 1 element. + // Be conservative when enabling long vector for single vector components. + // We're very sensitive to bugs here since SPIRV-Cross code assumes that vecsize == 1 is not a vector + // in many places and SPIRType's are sometimes synthesized on the stack without + // ensuring that op is overridden to the correct scalar Op type. + // This used to be enough, but not anymore. + // The test suite is clean of this assumption, but it's very likely that we missed some edge case in the wild. + if (!options.vulkan_semantics) + SPIRV_CROSS_THROW("Long vector requires Vulkan semantics."); + + // We might have a local override in terms of sign. Ensure the top-level basetype wins. + auto parent_type = get(non_array_type->parent_type); + parent_type.basetype = non_array_type->basetype; + return join("vector<", type_to_glsl(parent_type), ", ", non_array_type->vecsize, ">"); + } + else if (non_array_type->vecsize == 1 && non_array_type->columns == 1) // Scalar builtin + { + switch (non_array_type->basetype) { case SPIRType::Boolean: return "bool"; @@ -17098,69 +17772,69 @@ string CompilerGLSL::type_to_glsl(const SPIRType &type, uint32_t id) return "???"; } } - else if (type.vecsize > 1 && type.columns == 1) // Vector builtin + else if (non_array_type->vecsize > 1 && non_array_type->columns == 1) // Vector builtin { - switch (type.basetype) + switch (non_array_type->basetype) { case SPIRType::Boolean: - return join("bvec", type.vecsize); + return join("bvec", non_array_type->vecsize); case SPIRType::SByte: - return join("i8vec", type.vecsize); + return join("i8vec", non_array_type->vecsize); case SPIRType::UByte: - return join("u8vec", type.vecsize); + return join("u8vec", non_array_type->vecsize); case SPIRType::Short: - return join("i16vec", type.vecsize); + return join("i16vec", non_array_type->vecsize); case SPIRType::UShort: - return join("u16vec", type.vecsize); + return join("u16vec", non_array_type->vecsize); case SPIRType::Int: - return join("ivec", type.vecsize); + return join("ivec", non_array_type->vecsize); case SPIRType::UInt: - return join("uvec", type.vecsize); + return join("uvec", non_array_type->vecsize); case SPIRType::Half: - return join("f16vec", type.vecsize); + return join("f16vec", non_array_type->vecsize); case SPIRType::BFloat16: if (!options.vulkan_semantics) SPIRV_CROSS_THROW("bfloat16 requires Vulkan semantics."); require_extension_internal("GL_EXT_bfloat16"); - return join("bf16vec", type.vecsize); + return join("bf16vec", non_array_type->vecsize); case SPIRType::FloatE4M3: if (!options.vulkan_semantics) SPIRV_CROSS_THROW("floate4m3_t requires Vulkan semantics."); require_extension_internal("GL_EXT_float_e4m3"); - return join("fe4m3vec", type.vecsize); + return join("fe4m3vec", non_array_type->vecsize); case SPIRType::FloatE5M2: if (!options.vulkan_semantics) SPIRV_CROSS_THROW("floate5m2_t requires Vulkan semantics."); require_extension_internal("GL_EXT_float_e5m2"); - return join("fe5m2vec", type.vecsize); + return join("fe5m2vec", non_array_type->vecsize); case SPIRType::Float: - return join("vec", type.vecsize); + return join("vec", non_array_type->vecsize); case SPIRType::Double: - return join("dvec", type.vecsize); + return join("dvec", non_array_type->vecsize); case SPIRType::Int64: - return join("i64vec", type.vecsize); + return join("i64vec", non_array_type->vecsize); case SPIRType::UInt64: - return join("u64vec", type.vecsize); + return join("u64vec", non_array_type->vecsize); default: return "???"; } } - else if (type.vecsize == type.columns) // Simple Matrix builtin + else if (non_array_type->vecsize == non_array_type->columns) // Simple Matrix builtin { - switch (type.basetype) + switch (non_array_type->basetype) { case SPIRType::Boolean: - return join("bmat", type.vecsize); + return join("bmat", non_array_type->vecsize); case SPIRType::Int: - return join("imat", type.vecsize); + return join("imat", non_array_type->vecsize); case SPIRType::UInt: - return join("umat", type.vecsize); + return join("umat", non_array_type->vecsize); case SPIRType::Half: - return join("f16mat", type.vecsize); + return join("f16mat", non_array_type->vecsize); case SPIRType::Float: - return join("mat", type.vecsize); + return join("mat", non_array_type->vecsize); case SPIRType::Double: - return join("dmat", type.vecsize); + return join("dmat", non_array_type->vecsize); // Matrix types not supported for int64/uint64. default: return "???"; @@ -17168,20 +17842,20 @@ string CompilerGLSL::type_to_glsl(const SPIRType &type, uint32_t id) } else { - switch (type.basetype) + switch (non_array_type->basetype) { case SPIRType::Boolean: - return join("bmat", type.columns, "x", type.vecsize); + return join("bmat", non_array_type->columns, "x", non_array_type->vecsize); case SPIRType::Int: - return join("imat", type.columns, "x", type.vecsize); + return join("imat", non_array_type->columns, "x", non_array_type->vecsize); case SPIRType::UInt: - return join("umat", type.columns, "x", type.vecsize); + return join("umat", non_array_type->columns, "x", non_array_type->vecsize); case SPIRType::Half: - return join("f16mat", type.columns, "x", type.vecsize); + return join("f16mat", non_array_type->columns, "x", non_array_type->vecsize); case SPIRType::Float: - return join("mat", type.columns, "x", type.vecsize); + return join("mat", non_array_type->columns, "x", non_array_type->vecsize); case SPIRType::Double: - return join("dmat", type.columns, "x", type.vecsize); + return join("dmat", non_array_type->columns, "x", non_array_type->vecsize); // Matrix types not supported for int64/uint64. default: return "???"; @@ -17360,7 +18034,12 @@ void CompilerGLSL::add_function_overload(const SPIRFunction &func) void CompilerGLSL::emit_function_prototype(SPIRFunction &func, const Bitset &return_flags) { - if (func.self != ir.default_entry_point) + // In library mode default_entry_point points at the first exported + // function; treat every export as a normal function rather than as the + // shader's entry point. + const bool is_entry_point = !ir.is_library_module && func.self == ir.default_entry_point; + + if (!is_entry_point) add_function_overload(func); // Avoid shadow declarations. @@ -17374,12 +18053,14 @@ void CompilerGLSL::emit_function_prototype(SPIRFunction &func, const Bitset &ret decl += type_to_array_glsl(type, 0); decl += " "; - if (func.self == ir.default_entry_point) + if (is_entry_point) { // If we need complex fallback in GLSL, we just wrap main() in a function // and interlock the entire shader ... if (interlocked_is_complex) decl += "spvMainInterlockedBody"; + else if (options.use_entry_point_name) + decl += get_entry_point().name; else decl += "main"; @@ -17910,13 +18591,35 @@ string CompilerGLSL::emit_continue_block(uint32_t continue_block, bool follow_tr return merge(statements); } +// Loop variable with OpUndef init: zero-init instead of leaving uninitialized (FXC X4555/X4000). +std::string CompilerGLSL::undef_loop_variable_initializer_suffix(const SPIRVariable &var) +{ + if (!backend.requires_phi_undef_zero_init) + return ""; + + uint32_t expr = var.static_expression; + if (expr == 0 || ir.ids[expr].get_type() != TypeUndef) + return ""; + + auto &type = get(var.basetype); + if (!type_can_zero_initialize(type)) + return ""; + + // variable_decl() already emits the zero initializer for an OpUndef loop variable + // in this mode; adding a second one here would produce "x = 0 = 0". + if (var.loop_variable && options.force_zero_initialized_variables) + return ""; + + return join(" = ", to_zero_initialized_expression(var.basetype)); +} + void CompilerGLSL::emit_while_loop_initializers(const SPIRBlock &block) { // While loops do not take initializers, so declare all of them outside. for (auto &loop_var : block.loop_variables) { auto &var = get(loop_var); - statement(variable_decl(var), ";"); + statement(variable_decl(var), undef_loop_variable_initializer_suffix(var), ";"); } } @@ -17948,7 +18651,10 @@ string CompilerGLSL::emit_for_loop_initializers(const SPIRBlock &block) else if (!same_types || missing_initializers == uint32_t(block.loop_variables.size())) { for (auto &loop_var : block.loop_variables) - statement(variable_decl(get(loop_var)), ";"); + { + auto &var = get(loop_var); + statement(variable_decl(var), undef_loop_variable_initializer_suffix(var), ";"); + } return ""; } else @@ -17959,10 +18665,11 @@ string CompilerGLSL::emit_for_loop_initializers(const SPIRBlock &block) for (auto &loop_var : block.loop_variables) { - uint32_t static_expr = get(loop_var).static_expression; + auto &var_for_undef = get(loop_var); + uint32_t static_expr = var_for_undef.static_expression; if (static_expr == 0 || ir.ids[static_expr].get_type() == TypeUndef) { - statement(variable_decl(get(loop_var)), ";"); + statement(variable_decl(var_for_undef), undef_loop_variable_initializer_suffix(var_for_undef), ";"); } else { @@ -18107,6 +18814,10 @@ bool CompilerGLSL::attempt_emit_loop_header(SPIRBlock &block, SPIRBlock::Method { block.disable_block_optimization = true; force_recompile(); + // We're skipping the emission of the continue block, so this is kinda redundant. + // However, it's important that we run the codegen part, since we might need to do fixups for a future pass. + // This avoids a potentially "unbounded" number of recompilation chains. + emit_continue_block(block.continue_block, true, true); begin_scope(); // We'll see an end_scope() later. return false; } @@ -18216,7 +18927,11 @@ void CompilerGLSL::emit_hoisted_temporaries(SmallVector> &tempo // There are some rare scenarios where we are asked to declare pointer types as hoisted temporaries. // This should be ignored unless we're doing actual variable pointers and backend supports it. // Access chains cannot normally be lowered to temporaries in GLSL and HLSL. - if (type.pointer && !backend.native_pointers) + if (type.pointer && (!backend.native_pointers || type_is_opaque_value(get_pointee_type(type)))) + continue; + + // Anything involving opaque objects cannot be lowered to temporaries ever. + if (type_is_opaque_value(type)) continue; add_local_variable_name(tmp.second); @@ -19338,16 +20053,28 @@ void CompilerGLSL::convert_non_uniform_expression(string &expr, uint32_t ptr_id) return; auto *var = maybe_get_backing_variable(ptr_id); - if (!var) + auto *buffer_pointer = maybe_get_backing_buffer_pointer(ptr_id); + if (!var && !buffer_pointer) return; - if (var->storage != StorageClassUniformConstant && + if (!buffer_pointer && + var->storage != StorageClassUniformConstant && var->storage != StorageClassStorageBuffer && var->storage != StorageClassUniform) return; - auto &backing_type = get(var->basetype); - if (backing_type.array.empty()) + auto &backing_type = get(var ? var->basetype : buffer_pointer->expression_type); + + bool descriptor_heap = false; + if (var) + { + auto builtin = BuiltIn(get_decoration(var->self, DecorationBuiltIn)); + descriptor_heap = builtin == BuiltInResourceHeapEXT || builtin == BuiltInSamplerHeapEXT; + } + else if (buffer_pointer) + descriptor_heap = true; + + if (!descriptor_heap && backing_type.array.empty()) return; // If we get here, we know we're accessing an arrayed resource which @@ -19434,6 +20161,7 @@ void CompilerGLSL::reset_name_caches() block_output_names.clear(); block_ubo_names.clear(); block_ssbo_names.clear(); + block_shared_mem_names.clear(); block_names.clear(); function_overloads.clear(); } @@ -19636,9 +20364,9 @@ void CompilerGLSL::emit_copy_logical_type(uint32_t lhs_id, uint32_t lhs_type_id, AccessChainMeta lhs_meta, rhs_meta; auto lhs = access_chain_internal(lhs_id, chain.data(), uint32_t(chain.size()), - ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, &lhs_meta); + ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, &lhs_meta, nullptr); auto rhs = access_chain_internal(rhs_id, chain.data(), uint32_t(chain.size()), - ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, &rhs_meta); + ACCESS_CHAIN_INDEX_IS_LITERAL_BIT, &rhs_meta, nullptr); uint32_t id = ir.increase_bound_by(2); lhs_id = id; @@ -20328,3 +21056,130 @@ bool CompilerGLSL::has_legacy_nocontract(uint32_t result_type, uint32_t id) cons FPFastMathModeAllowReassocMask; return (get_fp_fast_math_flags_for_op(result_type, id) & fp_flags) != fp_flags; } + +void CompilerGLSL::remap_descriptor_heap(ResourceType type, uint32_t desc_set, uint32_t binding, Dim dim) +{ + for (auto &mapping : descriptor_heap_mappings) + { + if (mapping.type == type) + { + mapping.desc_set = desc_set; + mapping.binding = binding; + mapping.dim = dim; + return; + } + } + + descriptor_heap_mappings.push_back({ type, desc_set, binding, dim }); +} + +bool CompilerGLSL::is_descriptor_non_uniform(uint32_t id) const +{ + if (has_decoration(id, DecorationNonUniform)) + return true; + + // Only infer nonuniform for descriptors. + auto &type = expression_type(id); + + if (is_pointer(type)) + { + if (type.storage != StorageClassUniform && type.storage != StorageClassStorageBuffer && + type.storage != StorageClassUniformConstant && type.storage != StorageClassImage) + return false; + } + else if (!type_is_opaque_value(type)) + { + return false; + } + + if (descriptor_heap_mappings.empty()) + return false; + + if (has_decoration(id, DecorationUniform)) + return false; + + if (std::find(ir.declared_capabilities.begin(), ir.declared_capabilities.end(), + CapabilityDescriptorHeapEXT) == ir.declared_capabilities.end()) + return false; + + // Definitely not. + if (maybe_get(id) || maybe_get(id)) + return false; + + // DescriptorHeapEXT requires that nonuniformEXT is implied, + // but if we're remapping to legacy set/binding model, glslang will not emit the cap in cross compiled source, + // so we have to enforce it. We don't have compiler-infra to deduce subgroup uniformity statically, + // so just slap it on everything. Compilers generally figure this stuff out. + return true; +} + +std::string CompilerGLSL::to_descriptor_heap_layout(const SPIRType &type, StorageClass storage) const +{ + auto resource = ResourceTypeUnknown; + Dim dim = DimMax; + + switch (type.basetype) + { + case SPIRType::Sampler: + resource = ResourceTypeSeparateSamplers; + break; + + case SPIRType::Image: + dim = type.image.dim == DimBuffer ? DimBuffer : Dim2D; + resource = type.image.sampled == 2 ? ResourceTypeStorageImage : ResourceTypeSeparateImage; + break; + + case SPIRType::SampledImage: + resource = ResourceTypeSampledImage; + break; + + case SPIRType::AccelerationStructure: + resource = ResourceTypeAccelerationStructure; + break; + + case SPIRType::AtomicCounter: + resource = ResourceTypeAtomicCounter; + break; + + case SPIRType::Struct: + { + bool ssbo = storage == StorageClassStorageBuffer || has_decoration(type.self, DecorationBufferBlock); + resource = ssbo ? ResourceTypeStorageBuffer : ResourceTypeUniformBuffer; + break; + } + + default: + break; + } + + for (auto &mapping : descriptor_heap_mappings) + { + if (mapping.type == resource) + { + bool has_match = false; + + if (type.basetype == SPIRType::Image) + { + if (dim == DimBuffer && (mapping.dim == DimMax || mapping.dim == DimBuffer)) + has_match = true; + if (dim != DimBuffer && mapping.dim != DimBuffer) + has_match = true; + } + else + { + has_match = true; + } + + if (has_match) + return join("set = ", mapping.desc_set, ", binding = ", mapping.binding); + } + } + + // Fallback to unknown mapping. + for (auto &mapping : descriptor_heap_mappings) + if (mapping.type == ResourceTypeUnknown) + return join("set = ", mapping.desc_set, ", binding = ", mapping.binding); + + return "descriptor_heap"; +} + diff --git a/third_party/spirv-cross/spirv_glsl.hpp b/third_party/spirv-cross/spirv_glsl.hpp index 98e93ee99daf..0e8a36620f11 100644 --- a/third_party/spirv-cross/spirv_glsl.hpp +++ b/third_party/spirv-cross/spirv_glsl.hpp @@ -159,6 +159,9 @@ class CompilerGLSL : public Compiler // If non-zero, controls layout(num_views = N) in; in GL_OVR_multiview2. uint32_t ovr_multiview_view_count = 0; + // Emit the entry point name in SPIR-V rather than "main". + bool use_entry_point_name = false; + enum Precision { DontCare, @@ -303,6 +306,19 @@ class CompilerGLSL : public Compiler // Returns the macro name corresponding to constant id std::string constant_value_macro_name(uint32_t id) const; + // Rather than using layout(descriptor_heap), emit layout(set, binding). + // This intended to be compatible with descriptor buffers, legacy descriptor indexing, + // or when the heap descriptors require unusual kinds of mapping in the Vulkan API + // which is not expressible by GLSL directly. + // + // ResourceTypeUnknown can be used as a default catch-all mapping. + // dim can be used to disambiguate between texel buffers and images since they are both image types, + // but use different descriptor types in the Vulkan API. + // No distinction is made between 1D/2D/3D/Cube textures. + // The default argument of DimMax maps to both texel buffers and images. + // dim is ignored for ResourceTypeUnknown. + void remap_descriptor_heap(ResourceType type, uint32_t desc_set, uint32_t binding, Dim dim = DimMax); + protected: struct ShaderSubgroupSupportHelper { @@ -447,7 +463,6 @@ class CompilerGLSL : public Compiler virtual std::string builtin_to_glsl(BuiltIn builtin, StorageClass storage); virtual void emit_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index, const std::string &qualifier = "", uint32_t base_offset = 0); - virtual void emit_struct_padding_target(const SPIRType &type); virtual std::string image_type_glsl(const SPIRType &type, uint32_t id = 0, bool member = false); std::string constant_expression(const SPIRConstant &c, bool inside_block_like_struct_scope = false, @@ -589,7 +604,7 @@ class CompilerGLSL : public Compiler void add_function_overload(const SPIRFunction &func); virtual bool is_non_native_row_major_matrix(uint32_t id); - virtual bool member_is_non_native_row_major_matrix(const SPIRType &type, uint32_t index); + virtual bool member_is_non_native_row_major_matrix(const SPIRType &type, uint32_t index, bool is_layout_disabled = false); bool member_is_remapped_physical_type(const SPIRType &type, uint32_t index) const; bool member_is_packed_physical_type(const SPIRType &type, uint32_t index) const; virtual std::string convert_row_major_matrix(std::string exp_str, const SPIRType &exp_type, @@ -602,6 +617,7 @@ class CompilerGLSL : public Compiler std::unordered_set block_output_names; std::unordered_set block_ubo_names; std::unordered_set block_ssbo_names; + std::unordered_set block_shared_mem_names; std::unordered_set block_names; // A union of all block_*_names. std::unordered_map> function_overloads; std::unordered_map preserved_aliases; @@ -668,6 +684,7 @@ class CompilerGLSL : public Compiler bool requires_relaxed_precision_analysis = false; bool implicit_c_integer_promotion_rules = false; bool supports_spec_constant_array_size = true; + bool requires_phi_undef_zero_init = false; } backend; void emit_struct(SPIRType &type); @@ -675,7 +692,9 @@ class CompilerGLSL : public Compiler void emit_extension_workarounds(ExecutionModel model); void emit_subgroup_arithmetic_workaround(const std::string &func, Op op, GroupOperation group_op); void emit_polyfills(uint32_t polyfills, bool relaxed); - void emit_buffer_block_native(const SPIRVariable &var); + void emit_buffer_block_native(const SPIRVariable *var, const DescriptorHeapMeta *heap_meta = nullptr); + std::string to_buffer_pointer_name_prefix(uint32_t ptr_id) const; + static std::string heap_meta_to_prefix(const DescriptorHeapMeta &meta); void emit_buffer_reference_block(uint32_t type_id, bool forward_declaration); void emit_buffer_block_legacy(const SPIRVariable &var); void emit_buffer_block_flattened(const SPIRVariable &type); @@ -769,11 +788,11 @@ class CompilerGLSL : public Compiler AccessChainFlags flags, bool &access_chain_is_arrayed, uint32_t index); std::string access_chain_internal(uint32_t base, const uint32_t *indices, uint32_t count, AccessChainFlags flags, - AccessChainMeta *meta); + AccessChainMeta *meta, const SPIRType *untyped_data_type); // Only meaningful on backends with physical pointer support ala MSL. // Relevant for PtrAccessChain / BDA. - virtual uint32_t get_physical_type_stride(const SPIRType &type) const; + virtual uint32_t get_physical_type_id_stride(TypeID type_id) const; StorageClass get_expression_effective_storage_class(uint32_t ptr); virtual bool access_chain_needs_stage_io_builtin_translation(uint32_t base); @@ -783,7 +802,8 @@ class CompilerGLSL : public Compiler StorageClass storage, bool &is_packed); std::string access_chain(uint32_t base, const uint32_t *indices, uint32_t count, const SPIRType &target_type, - AccessChainMeta *meta = nullptr, bool ptr_chain = false); + AccessChainMeta *meta = nullptr, bool ptr_chain = false, + const SPIRType *untyped_data_type = nullptr); std::string flattened_access_chain(uint32_t base, const uint32_t *indices, uint32_t count, const SPIRType &target_type, uint32_t offset, uint32_t matrix_stride, @@ -976,8 +996,20 @@ class CompilerGLSL : public Compiler uint32_t required_polyfills_relaxed = 0; void require_polyfill(Polyfill polyfill, bool relaxed); + struct IntegerDotProduct + { + Id result_type; + Id argument_type[2]; + Op op; + }; + SmallVector integer_dot_products_polyfills; + void add_integer_dot_product_polyfill(const IntegerDotProduct &idot); + std::string integer_dot_product_entry_point(const IntegerDotProduct &idot); + void emit_polyfills_integer_dot_product(); + bool ray_tracing_is_khr = false; bool barycentric_is_nv = false; + bool long_vector_enabled = false; void ray_tracing_khr_fixup_locations(); bool args_will_forward(uint32_t id, const uint32_t *args, uint32_t num_args, bool pure); @@ -1021,6 +1053,7 @@ class CompilerGLSL : public Compiler std::string emit_for_loop_initializers(const SPIRBlock &block); void emit_while_loop_initializers(const SPIRBlock &block); + std::string undef_loop_variable_initializer_suffix(const SPIRVariable &var); bool for_loop_initializers_are_same_type(const SPIRBlock &block); bool optimize_read_modify_write(const SPIRType &type, const std::string &lhs, const std::string &rhs); void fixup_image_load_store_access(); @@ -1053,7 +1086,7 @@ class CompilerGLSL : public Compiler void disallow_forwarding_in_expression_chain(const SPIRExpression &expr); bool expression_is_constant_null(uint32_t id) const; - bool expression_is_non_value_type_array(uint32_t ptr); + bool expression_is_non_value_type_array(uint32_t value_type_id, uint32_t ptr); virtual void emit_store_statement(uint32_t lhs_expression, uint32_t rhs_expression); uint32_t get_integer_width_for_instruction(const Instruction &instr) const; @@ -1087,6 +1120,17 @@ class CompilerGLSL : public Compiler uint32_t get_fp_fast_math_flags_for_op(uint32_t result_type, uint32_t id) const; bool has_legacy_nocontract(uint32_t result_type, uint32_t id) const; + struct DescriptorHeapMapping + { + ResourceType type; + uint32_t desc_set; + uint32_t binding; + Dim dim; + }; + SmallVector descriptor_heap_mappings; + bool is_descriptor_non_uniform(uint32_t id) const; + std::string to_descriptor_heap_layout(const SPIRType &type, StorageClass storage = StorageClassUniformConstant) const; + private: void init(); diff --git a/third_party/spirv-cross/spirv_hlsl.cpp b/third_party/spirv-cross/spirv_hlsl.cpp index a18fa3c6027a..2ce47965c51c 100644 --- a/third_party/spirv-cross/spirv_hlsl.cpp +++ b/third_party/spirv-cross/spirv_hlsl.cpp @@ -769,6 +769,10 @@ void CompilerHLSL::emit_builtin_inputs_in_struct() auto builtin = static_cast(i); switch (builtin) { + case BuiltInPosition: + type = "float4"; + semantic = legacy ? "POSITION" : "SV_Position"; + break; case BuiltInFragCoord: type = "float4"; semantic = legacy ? "VPOS" : "SV_Position"; @@ -783,8 +787,27 @@ void CompilerHLSL::emit_builtin_inputs_in_struct() break; case BuiltInPrimitiveId: - type = "uint"; - semantic = "SV_PrimitiveID"; + // For geometry shaders, PrimitiveId is a direct function parameter + // (SV_PrimitiveID), not part of the input struct. + if (get_entry_point().model != ExecutionModelGeometry) + { + type = "uint"; + semantic = "SV_PrimitiveID"; + } + break; + + case BuiltInInvocationId: + if (get_entry_point().model == ExecutionModelGeometry) + { + type = "uint"; + semantic = "SV_GSInstanceID"; + } + else if (get_entry_point().model != ExecutionModelTessellationControl) + { + // For tesc, InvocationId is a direct function parameter (SV_OutputControlPointID), + // not part of the input struct. + SPIRV_CROSS_THROW("InvocationId is only supported in geometry and tessellation control shaders."); + } break; case BuiltInInstanceId: @@ -1139,8 +1162,9 @@ void CompilerHLSL::emit_interface_block_in_struct(const SPIRVariable &var, unord (execution.model == ExecutionModelGeometry && var.storage == StorageClassInput) || has_decoration(var.self, DecorationPerVertexKHR)) { - decl_type.array.erase(decl_type.array.begin()); - decl_type.array_size_literal.erase(decl_type.array_size_literal.begin()); + // The per-vertex/per-CP dimension is the outermost (last element in array vector). + decl_type.array.pop_back(); + decl_type.array_size_literal.pop_back(); } statement(to_interpolation_qualifiers(get_decoration_bitset(var.self)), variable_decl(decl_type, name), " : ", semantic, ";"); @@ -1164,6 +1188,9 @@ std::string CompilerHLSL::builtin_to_glsl(BuiltIn builtin, StorageClass storage) { switch (builtin) { + case BuiltInPosition: + // We want to avoid clash between input/output for geometry shader + return storage == StorageClass::StorageClassInput ? "gl_PositionIn" : "gl_Position"; case BuiltInVertexId: return "gl_VertexID"; case BuiltInInstanceId: @@ -1247,9 +1274,7 @@ void CompilerHLSL::emit_builtin_variables() // 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); @@ -1268,147 +1293,163 @@ void CompilerHLSL::emit_builtin_variables() } } - switch (builtin) + // If we need to emit 2 separate variables (for both input & output), we'll update this value + bool has_separate_input_output = false; + for (int variable_index = 0; variable_index < (has_separate_input_output ? 2 : 1); variable_index++) { - case BuiltInFragCoord: - case BuiltInPosition: - type = "float4"; - break; + uint32_t array_size = 0; + StorageClass storage = active_input_builtins.get(i) && variable_index == 0 + ? StorageClassInput + : StorageClassOutput; + const char *type = nullptr; + switch (builtin) + { + case BuiltInFragCoord: + type = "float4"; + break; - case BuiltInFragDepth: - type = "float"; - break; + case BuiltInPosition: + type = "float4"; + if (storage == StorageClass::StorageClassInput && + (get_execution_model() == ExecutionModelGeometry || + get_execution_model() == ExecutionModelTessellationControl)) + array_size = input_vertices_from_execution_mode(get_entry_point()); + break; - case BuiltInVertexId: - case BuiltInVertexIndex: - case BuiltInInstanceIndex: - type = "int"; - if (hlsl_options.support_nonzero_base_vertex_base_instance || hlsl_options.shader_model >= 68) - base_vertex_info.used = true; - break; + case BuiltInFragDepth: + type = "float"; + break; - case BuiltInBaseVertex: - case BuiltInBaseInstance: - type = "int"; - base_vertex_info.used = true; - break; + case BuiltInVertexId: + case BuiltInVertexIndex: + case BuiltInInstanceIndex: + type = "int"; + if (hlsl_options.support_nonzero_base_vertex_base_instance || hlsl_options.shader_model >= 68) + base_vertex_info.used = true; + break; - case BuiltInInstanceId: - case BuiltInSampleId: - type = "int"; - break; + case BuiltInBaseVertex: + case BuiltInBaseInstance: + type = "int"; + base_vertex_info.used = true; + break; - case BuiltInPointSize: - if (hlsl_options.point_size_compat || hlsl_options.shader_model <= 30) - { - // Just emit the global variable, it will be ignored. - type = "float"; + case BuiltInInstanceId: + case BuiltInSampleId: + type = "int"; break; - } - else - SPIRV_CROSS_THROW(join("Unsupported builtin in HLSL: ", unsigned(builtin))); - case BuiltInGlobalInvocationId: - case BuiltInLocalInvocationId: - case BuiltInWorkgroupId: - type = "uint3"; - break; + case BuiltInPointSize: + if (hlsl_options.point_size_compat || hlsl_options.shader_model <= 30) + { + // Just emit the global variable, it will be ignored. + type = "float"; + break; + } + else + SPIRV_CROSS_THROW(join("Unsupported builtin in HLSL: ", unsigned(builtin))); - case BuiltInLocalInvocationIndex: - type = "uint"; - break; + case BuiltInGlobalInvocationId: + case BuiltInLocalInvocationId: + case BuiltInWorkgroupId: + type = "uint3"; + break; - case BuiltInFrontFacing: - type = "bool"; - break; + case BuiltInLocalInvocationIndex: + type = "uint"; + break; - case BuiltInNumWorkgroups: - case BuiltInPointCoord: - // Handled specially. - break; + case BuiltInFrontFacing: + type = "bool"; + break; - case BuiltInSubgroupLocalInvocationId: - case BuiltInSubgroupSize: - if (hlsl_options.shader_model < 60) - SPIRV_CROSS_THROW("Need SM 6.0 for Wave ops."); - break; + case BuiltInNumWorkgroups: + case BuiltInPointCoord: + // Handled specially. + break; - case BuiltInSubgroupEqMask: - case BuiltInSubgroupLtMask: - case BuiltInSubgroupLeMask: - case BuiltInSubgroupGtMask: - case BuiltInSubgroupGeMask: - if (hlsl_options.shader_model < 60) - SPIRV_CROSS_THROW("Need SM 6.0 for Wave ops."); - type = "uint4"; - break; + case BuiltInSubgroupLocalInvocationId: + case BuiltInSubgroupSize: + if (hlsl_options.shader_model < 60) + SPIRV_CROSS_THROW("Need SM 6.0 for Wave ops."); + break; - case BuiltInHelperInvocation: - if (hlsl_options.shader_model < 50) - SPIRV_CROSS_THROW("Need SM 5.0 for Helper Invocation."); - break; + case BuiltInSubgroupEqMask: + case BuiltInSubgroupLtMask: + case BuiltInSubgroupLeMask: + case BuiltInSubgroupGtMask: + case BuiltInSubgroupGeMask: + if (hlsl_options.shader_model < 60) + SPIRV_CROSS_THROW("Need SM 6.0 for Wave ops."); + type = "uint4"; + break; - case BuiltInClipDistance: - array_size = clip_distance_count; - type = "float"; - break; + case BuiltInHelperInvocation: + if (hlsl_options.shader_model < 50) + SPIRV_CROSS_THROW("Need SM 5.0 for Helper Invocation."); + break; - case BuiltInCullDistance: - array_size = cull_distance_count; - type = "float"; - break; + case BuiltInClipDistance: + array_size = clip_distance_count; + type = "float"; + break; - case BuiltInSampleMask: - if (active_input_builtins.get(BuiltInSampleMask)) - type = sample_mask_in_basetype == SPIRType::UInt ? "uint" : "int"; - else - type = sample_mask_out_basetype == SPIRType::UInt ? "uint" : "int"; - array_size = 1; - break; + case BuiltInCullDistance: + array_size = cull_distance_count; + type = "float"; + break; - case BuiltInPrimitiveId: - case BuiltInViewIndex: - case BuiltInLayer: - type = "uint"; - break; + case BuiltInSampleMask: + if (storage == StorageClass::StorageClassInput) + type = sample_mask_in_basetype == SPIRType::UInt ? "uint" : "int"; + else + type = sample_mask_out_basetype == SPIRType::UInt ? "uint" : "int"; + array_size = 1; + break; - case BuiltInViewportIndex: - case BuiltInPrimitiveShadingRateKHR: - case BuiltInPrimitiveLineIndicesEXT: - case BuiltInCullPrimitiveEXT: - type = "uint"; - break; + case BuiltInPrimitiveId: + case BuiltInViewIndex: + case BuiltInLayer: + type = "uint"; + break; - case BuiltInBaryCoordKHR: - case BuiltInBaryCoordNoPerspKHR: - if (hlsl_options.shader_model < 61) - SPIRV_CROSS_THROW("Need SM 6.1 for barycentrics."); - type = "float3"; - break; + case BuiltInViewportIndex: + case BuiltInPrimitiveShadingRateKHR: + case BuiltInPrimitiveLineIndicesEXT: + case BuiltInCullPrimitiveEXT: + type = "uint"; + break; - default: - SPIRV_CROSS_THROW(join("Unsupported builtin in HLSL: ", unsigned(builtin))); - } + case BuiltInBaryCoordKHR: + case BuiltInBaryCoordNoPerspKHR: + if (hlsl_options.shader_model < 61) + SPIRV_CROSS_THROW("Need SM 6.1 for barycentrics."); + type = "float3"; + break; - StorageClass storage = active_input_builtins.get(i) ? StorageClassInput : StorageClassOutput; + default: + SPIRV_CROSS_THROW(join("Unsupported builtin in HLSL: ", unsigned(builtin))); + } - if (type) - { - if (array_size) - statement("static ", type, " ", builtin_to_glsl(builtin, storage), "[", array_size, "]", init_expr, ";"); - else - statement("static ", type, " ", builtin_to_glsl(builtin, storage), init_expr, ";"); - } + if (type) + { + auto builtin_name = builtin_to_glsl(builtin, storage); + if (array_size) + statement("static ", type, " ", builtin_name, "[", array_size, "]", init_expr, ";"); + else + statement("static ", type, " ", builtin_name, 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)) - { - type = sample_mask_out_basetype == SPIRType::UInt ? "uint" : "int"; - if (array_size) - statement("static ", type, " ", this->builtin_to_glsl(builtin, StorageClassOutput), "[", array_size, "]", init_expr, ";"); - else - statement("static ", type, " ", this->builtin_to_glsl(builtin, StorageClassOutput), init_expr, ";"); + if (storage == StorageClassInput && this->active_output_builtins.get(i)) + { + auto out_builtin_name = builtin_to_glsl(builtin, StorageClassOutput); + if (out_builtin_name != builtin_name) + { + // If built-in name differs, we need to output it again + // (we reevaluate type and array size in case they are different) + has_separate_input_output = true; + } + } + } } }); @@ -1569,7 +1610,9 @@ void CompilerHLSL::emit_specialization_constants_and_structs() auto &undef = id.get(); auto &type = this->get(undef.basetype); // OpUndef can be void for some reason ... - if (type.basetype == SPIRType::Void) + // Apparently also block types, but we don't declare those as normal types, + // so skip those. It's only used in some esoteric debug instructions in DXC. + if (type.basetype == SPIRType::Void || type_is_top_level_block(type)) return; string initializer; @@ -3076,7 +3119,12 @@ uint32_t CompilerHLSL::input_vertices_from_execution_mode(SPIREntryPoint &execut void CompilerHLSL::emit_function_prototype(SPIRFunction &func, const Bitset &return_flags) { - if (func.self != ir.default_entry_point) + // In library mode default_entry_point points at the first exported + // function; treat every export as a normal function rather than as the + // shader's entry point. + const bool is_entry_point = !ir.is_library_module && func.self == ir.default_entry_point; + + if (!is_entry_point) add_function_overload(func); // Avoid shadow declarations. @@ -3097,7 +3145,7 @@ void CompilerHLSL::emit_function_prototype(SPIRFunction &func, const Bitset &ret decl = "void "; } - if (func.self == ir.default_entry_point) + if (is_entry_point) { decl += get_inner_entry_point_name(); processing_entry_point = true; @@ -3249,6 +3297,8 @@ void CompilerHLSL::emit_hlsl_entry_point() statement("[maxvertexcount(", execution.output_vertices, ")]"); arguments.push_back(join(prim, " SPIRV_Cross_Input stage_input[", input_vertices, "]")); + if (active_input_builtins.get(BuiltInPrimitiveId)) + arguments.push_back("uint gl_PrimitiveID : SV_PrimitiveID"); arguments.push_back(join("inout ", stream_type, " ", "geometry_stream")); break; } @@ -3351,6 +3401,17 @@ void CompilerHLSL::emit_hlsl_entry_point() auto builtin = builtin_to_glsl(static_cast(i), StorageClassInput); switch (static_cast(i)) { + case BuiltInPosition: + if (execution.model == ExecutionModelGeometry) + { + statement("for (int i = 0; i < ", input_vertices, "; i++)"); + begin_scope(); + statement(builtin, "[i] = stage_input[i].", builtin, ";"); + end_scope(); + } + else + statement(builtin, " = stage_input.", builtin, ";"); + break; case BuiltInFragCoord: // VPOS in D3D9 is sampled at integer locations, apply half-pixel offset to be consistent. // TODO: Do we need an option here? Any reason why a D3D9 shader would be used @@ -3420,6 +3481,30 @@ void CompilerHLSL::emit_hlsl_entry_point() case BuiltInHelperInvocation: break; + case BuiltInPrimitiveId: + if (execution.model == ExecutionModelGeometry) + { + // PrimitiveId is a separate function parameter for GS. + // The global is named gl_PrimitiveIDIn (GLSL convention). + statement(builtin, " = gl_PrimitiveID;"); + } + else + statement(builtin, " = stage_input.", builtin, ";"); + break; + + case BuiltInInvocationId: + if (execution.model == ExecutionModelTessellationControl) + { + // Copy from function parameter to global. + statement(builtin, " = uCPID;"); + } + else + { + // For geometry shaders, copy from struct as usual. + statement(builtin, " = stage_input[0].", builtin, ";"); + } + break; + case BuiltInSubgroupEqMask: // Emulate these ... // No 64-bit in HLSL, so have to do it in 32-bit and unroll. @@ -3874,7 +3959,7 @@ void CompilerHLSL::emit_texture_op(const Instruction &i, bool sparse) else { auto &imgformat = get(imgtype.image.type); - if (hlsl_options.shader_model < 67 && imgformat.basetype != SPIRType::Float) + if (hlsl_options.shader_model < 67 && imgformat.basetype != SPIRType::Float && !gather) { SPIRV_CROSS_THROW("Sampling non-float textures is not supported in HLSL SM < 6.7."); } @@ -5159,7 +5244,8 @@ string CompilerHLSL::write_access_chain_value(uint32_t value, const SmallVector< { AccessChainMeta meta; ret = access_chain_internal(value, composite_chain.data(), uint32_t(composite_chain.size()), - ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_LITERAL_MSB_FORCE_ID, &meta); + ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_LITERAL_MSB_FORCE_ID, &meta, + nullptr); } if (enclose) @@ -5839,6 +5925,7 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction) { auto ops = stream(instruction); auto opcode = static_cast(instruction.op); + uint32_t length = instruction.length; #define HLSL_BOP(op) emit_binary_op(ops[0], ops[1], ops[2], ops[3], #op) #define HLSL_BOP_CAST(op, type) \ @@ -6823,6 +6910,69 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction) statement("geometry_stream.RestartStrip();"); break; } + + case OpSDot: + case OpUDot: + case OpSUDot: + case OpSDotAccSat: + case OpUDotAccSat: + case OpSUDotAccSat: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + bool is_acc_sat = opcode == OpSDotAccSat || opcode == OpUDotAccSat || opcode == OpSUDotAccSat; + + if (length == (is_acc_sat ? 6 : 5)) + { + if (ops[length - 1] != PackedVectorFormatPackedVectorFormat4x8Bit) + SPIRV_CROSS_THROW("Only 4x8bit packing is supported."); + } + + // Don't bother with polyfills. Integer dot products that aren't full speed are worthless. + if (hlsl_options.shader_model < 64) + SPIRV_CROSS_THROW("Integer dot product requires SM 6.4."); + if (opcode == OpSUDotAccSat || opcode == OpSUDot) + SPIRV_CROSS_THROW("Mixed signed dot product not supported."); + if (expression_type(ops[2]).vecsize != 1) + SPIRV_CROSS_THROW("HLSL dot products must be 4x8bit packed."); + if (integer_width != 32) + SPIRV_CROSS_THROW("HLSL dot products must be 32-bit accumulator."); + + const char *intrinsic; + if (opcode == OpSDot || opcode == OpSDotAccSat) + intrinsic = "dot4add_i8packed"; + else + intrinsic = "dot4add_u8packed"; + + auto expr = join(intrinsic, "(", to_expression(ops[2]), ", ", to_expression(ops[3]), ", "); + + // HLSL only has the accumulating variant without saturation. + // We could implement saturation ourselves, but it negates the point of using it. + // Take the lazier approach and just implement it as-is. + // Saturation is extremely unlikely to come up for any reasonable i8 kernel. + if (is_acc_sat) + expr += to_expression(ops[4]) + " /* WARN: HLSL will not saturate */)"; + else + expr += "0)"; + + if (((opcode == OpSDot || opcode == OpSDotAccSat) && get (result_type).basetype != SPIRType::Int) || + ((opcode == OpUDot || opcode == OpUDotAccSat) && get (result_type).basetype != SPIRType::UInt)) + { + expr = join(type_to_glsl(get (result_type)), "(", expr, ")"); + } + + bool forward = should_forward(ops[2]) && should_forward(ops[3]); + if (is_acc_sat && forward) + forward = should_forward(ops[4]); + + emit_op(result_type, id, expr, forward); + inherit_expression_dependencies(id, ops[2]); + inherit_expression_dependencies(id, ops[3]); + if (is_acc_sat) + inherit_expression_dependencies(id, ops[4]); + break; + } + default: CompilerGLSL::emit_instruction(instruction); break; @@ -7023,6 +7173,7 @@ string CompilerHLSL::compile() backend.can_return_array = false; backend.nonuniform_qualifier = "NonUniformResourceIndex"; backend.support_case_fallthrough = false; + backend.requires_phi_undef_zero_init = true; backend.force_merged_mesh_block = get_execution_model() == ExecutionModelMeshEXT; backend.force_gl_in_out_block = backend.force_merged_mesh_block; backend.supports_empty_struct = hlsl_options.shader_model <= 30; @@ -7068,14 +7219,27 @@ string CompilerHLSL::compile() emit_header(); emit_resources(); - emit_function(get(ir.default_entry_point), Bitset()); - emit_hlsl_entry_point(); + if (ir.is_library_module) + { + // Emit each exported function as a normal free function. + // emit_function recursively emits callees, so internal helpers + // are picked up too. + for (auto export_id : ir.library_exported_functions) + emit_function(get(export_id), Bitset()); + } + else + { + emit_function(get(ir.default_entry_point), Bitset()); + emit_hlsl_entry_point(); + } pass_count++; } while (is_forcing_recompilation()); // Entry point in HLSL is always main() for the time being. - get_entry_point().name = "main"; + // Skip the rename for library modules; their exports keep their declared names. + if (!ir.is_library_module) + get_entry_point().name = "main"; return buffer.str(); } diff --git a/third_party/spirv-cross/spirv_msl.cpp b/third_party/spirv-cross/spirv_msl.cpp index 025427cc83b6..efd66f285676 100644 --- a/third_party/spirv-cross/spirv_msl.cpp +++ b/third_party/spirv-cross/spirv_msl.cpp @@ -1087,6 +1087,18 @@ void CompilerMSL::build_implicit_builtins() dynamic_offsets_buffer_id = var_id; } + if (active_input_builtins.get(BuiltInDrawIndex)) + { + // This is always emulated. + uint32_t var_id = build_constant_uint_array_pointer(); + set_name(var_id, "spvDrawIndex"); + // This should never match anything. + set_decoration(var_id, DecorationDescriptorSet, ~(6u)); + set_decoration(var_id, DecorationBinding, msl_options.draw_id_buffer_index); + set_extended_decoration(var_id, SPIRVCrossDecorationResourceIndexPrimary, msl_options.draw_id_buffer_index); + draw_index_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 || is_tese_shader()) && !capture_output_to_buffer && !get_is_rasterization_disabled() && @@ -1766,6 +1778,8 @@ string CompilerMSL::compile() add_active_interface_variable(view_mask_buffer_id); if (dynamic_offsets_buffer_id) add_active_interface_variable(dynamic_offsets_buffer_id); + if (draw_index_buffer_id) + add_active_interface_variable(draw_index_buffer_id); if (builtin_layer_id) add_active_interface_variable(builtin_layer_id); if (builtin_dispatch_base_id && !msl_options.supports_msl_version(1, 2)) @@ -1778,6 +1792,8 @@ string CompilerMSL::compile() // Create structs to hold input, output and uniform variables. // Do output first to ensure out. is declared at top of entry function. qual_pos_var_name = ""; + qual_viewport_idx_var_name = ""; + qual_frag_depth_var_name = ""; if (is_mesh_shader()) { fixup_implicit_builtin_block_names(get_execution_model()); @@ -1930,6 +1946,14 @@ void CompilerMSL::preprocess_op_codes() add_header_line("using namespace metal::raytracing;"); add_header_line("#endif"); } + + if (preproc.uses_cooperative_matrix) + { + if (!msl_options.supports_msl_version(3, 1)) + SPIRV_CROSS_THROW("Cooperative matrices require MSL 3.1 or later."); + add_header_line("#include "); + validate_cooperative_matrix_types(); + } } // Move the Private and Workgroup global variables to the entry function. @@ -2965,6 +2989,10 @@ void CompilerMSL::add_plain_variable_to_interface_block(StorageClass storage, co set_member_decoration(ib_type.self, ib_mbr_idx, DecorationBuiltIn, builtin); if (builtin == BuiltInPosition && storage == StorageClassOutput) qual_pos_var_name = qual_var_name; + if (builtin == BuiltInViewportIndex && storage == StorageClassOutput) + qual_viewport_idx_var_name = qual_var_name; + if (builtin == BuiltInFragDepth && storage == StorageClassOutput) + qual_frag_depth_var_name = qual_var_name; } // Copy interpolation decorations if needed @@ -3593,6 +3621,10 @@ void CompilerMSL::add_plain_member_variable_to_interface_block(StorageClass stor set_member_decoration(ib_type.self, ib_mbr_idx, DecorationBuiltIn, builtin); if (builtin == BuiltInPosition && storage == StorageClassOutput) qual_pos_var_name = qual_var_name; + if (builtin == BuiltInViewportIndex && storage == StorageClassOutput) + qual_viewport_idx_var_name = qual_var_name; + if (builtin == BuiltInFragDepth && storage == StorageClassOutput) + qual_frag_depth_var_name = qual_var_name; } const SPIRConstant *c = nullptr; @@ -5048,23 +5080,16 @@ void CompilerMSL::mark_scalar_layout_structs(const SPIRType &type) if (struct_needs_explicit_padding) { - msl_size = get_declared_struct_size_msl(*struct_type, true, true); - if (array_stride < msl_size) - { - SPIRV_CROSS_THROW("Cannot express an array stride smaller than size of struct type."); - } - else + msl_size = get_declared_struct_size_msl(*struct_type); + + if (array_stride > msl_size) { - if (has_extended_decoration(struct_type->self, SPIRVCrossDecorationPaddingTarget)) - { - if (array_stride != - get_extended_decoration(struct_type->self, SPIRVCrossDecorationPaddingTarget)) - SPIRV_CROSS_THROW( - "A struct is used with different array strides. Cannot express this in MSL."); - } - else - set_extended_decoration(struct_type->self, SPIRVCrossDecorationPaddingTarget, array_stride); + set_decoration(struct_type->self, DecorationArrayStride, msl_size); + add_spv_func_and_recompile(SPVFuncImplPaddedArrayElement); } + + if (array_stride < msl_size) + SPIRV_CROSS_THROW("Cannot express an array stride smaller than size of struct type."); } } } @@ -5108,6 +5133,36 @@ void CompilerMSL::align_struct(SPIRType &ib_type, unordered_set &align // offsets, array strides and matrix strides. ensure_member_packing_rules_msl(ib_type, mbr_idx); + // Arrays of structs: the element struct may just have been packed (by its own align_struct pass above) + // to a size smaller than the declared ArrayStride. mark_scalar_layout_structs() runs before that packing + // and only sees the unpacked size, so it can miss this case. MSL cannot express an array stride larger + // than sizeof(T); route such arrays through spvPaddedArrayElement exactly like that pass does. + { + auto &mbr_type = get(ib_type.member_types[mbr_idx]); + if (mbr_type.basetype == SPIRType::Struct && !mbr_type.array.empty() && + !(mbr_type.pointer && mbr_type.storage == StorageClassPhysicalStorageBuffer)) + { + auto *struct_type = &mbr_type; + while (!struct_type->array.empty()) + struct_type = &get(struct_type->parent_type); + + if (!has_decoration(struct_type->self, DecorationArrayStride)) + { + uint32_t array_stride = type_struct_member_array_stride(ib_type, mbr_idx); + uint32_t dimensions = uint32_t(mbr_type.array.size() - 1); + for (uint32_t dim = 0; dim < dimensions; dim++) + array_stride /= max(to_array_size_literal(mbr_type, dim), 1u); + + uint32_t msl_size = get_declared_struct_size_msl(*struct_type); + if (array_stride > msl_size) + { + set_decoration(struct_type->self, DecorationArrayStride, msl_size); + add_spv_func_and_recompile(SPVFuncImplPaddedArrayElement); + } + } + } + } + // Align current offset to the current member's default alignment. If the member was packed, it will observe // the updated alignment here. uint32_t msl_align_mask = get_declared_struct_member_alignment_msl(ib_type, mbr_idx) - 1; @@ -5115,6 +5170,12 @@ void CompilerMSL::align_struct(SPIRType &ib_type, unordered_set &align // Fetch the member offset as declared in the SPIRV. uint32_t spirv_mbr_offset = get_member_decoration(ib_type_id, mbr_idx, DecorationOffset); + + // A previous compilation pass may have recorded a padding target that no longer applies + // (e.g. a struct array that is now emitted with spvPaddedArrayElement and therefore + // already spans its full ArrayStride). Recompute it from scratch on every pass. + unset_extended_member_decoration(ib_type_id, mbr_idx, SPIRVCrossDecorationPaddingTarget); + if (spirv_mbr_offset > aligned_msl_offset) { // Since MSL and SPIR-V have slightly different struct member alignment and @@ -5170,8 +5231,10 @@ bool CompilerMSL::validate_member_packing_rules_msl(const SPIRType &type, uint32 // If app tries to be cheeky and access the member out of bounds, this will not work, but this is the best we can do. // In OpAccessChain with logical memory models, access chains must be in-bounds in SPIR-V specification. bool relax_array_stride = mbr_type.array.back() == 1 && mbr_type.array_size_literal.back(); + bool is_plain_struct = !mbr_type.pointer && mbr_type.basetype == SPIRType::Struct; - if (!relax_array_stride) + // Array of struct is padded on-demand. + if (!relax_array_stride && !is_plain_struct) { uint32_t spirv_array_stride = type_struct_member_array_stride(type, index); uint32_t msl_array_stride = get_declared_struct_member_array_stride_msl(type, index); @@ -6420,13 +6483,14 @@ void CompilerMSL::emit_custom_functions() statement("template"); statement("[[clang::optnone]] matrix spvFMulMatrixMatrix(matrix l, matrix r)"); begin_scope(); + statement("static_assert(LCols == RRows, \"column-row configuration mismatch\");"); statement("matrix res;"); statement("for (uint i = 0; i < RCols; i++)"); begin_scope(); - statement("vec tmp(0);"); + statement("vec tmp(0);"); statement("for (uint j = 0; j < LCols; j++)"); begin_scope(); - statement("tmp = fma(vec(r[i][j]), l[j], tmp);"); + statement("tmp = fma(vec(r[i][j]), l[j], tmp);"); end_scope(); statement("res[i] = tmp;"); end_scope(); @@ -8213,6 +8277,13 @@ void CompilerMSL::emit_custom_functions() statement(""); break; + case SPVFuncImplPaddedArrayElement: + // .data is used in access chain. + statement("template "); + statement("struct spvPaddedArrayElement { T data; char padding[stride - sizeof(T)]; };"); + statement(""); + break; + case SPVFuncImplReduceAdd: // Metal doesn't support __builtin_reduce_add or simd_reduce_add, so we need this. // Metal also doesn't support the other vector builtins, which would have been useful to make this a single template. @@ -8246,6 +8317,37 @@ void CompilerMSL::emit_custom_functions() statement(""); break; + case SPVFuncImplDepthCast: + statement("template "); + statement("static inline depth2d spvDepthCast(texture2d t)"); + begin_scope(); + statement("return reinterpret_cast &>(t);"); + end_scope(); + statement(""); + statement("template "); + statement("static inline depth2d_array spvDepthCast(texture2d_array t)"); + begin_scope(); + statement("return reinterpret_cast &>(t);"); + end_scope(); + statement(""); + statement("template "); + statement("static inline depthcube spvDepthCast(texturecube t)"); + begin_scope(); + statement("return reinterpret_cast &>(t);"); + end_scope(); + statement(""); + + if (!msl_options.is_ios() || msl_options.supports_msl_version(2)) + { + statement("template "); + statement("static inline depthcube_array spvDepthCast(texturecube_array t)"); + begin_scope(); + statement("return reinterpret_cast &>(t);"); + end_scope(); + statement(""); + } + break; + case SPVFuncImplMulExtended: // Compiler may hit an internal error with mulhi, but doesn't when encapsulated for some reason. statement("template"); @@ -8412,6 +8514,17 @@ void CompilerMSL::emit_resources() // Emit declarations for the specialization Metal function constants void CompilerMSL::emit_specialization_constants_and_structs() { + if (needs_depth_clip_state_buffer()) + { + statement("struct spvDepthClipState"); + begin_scope(); + statement("uint emulateViewportZ;"); + statement("uint emulateDepthClamp;"); + statement("float2 viewportDepthRanges[16];"); + end_scope_decl(); + statement(""); + } + SpecializationConstant wg_x, wg_y, wg_z; ID workgroup_size_id = get_work_group_size_specialization_constants(wg_x, wg_y, wg_z); if (workgroup_size_id == 0 && is_mesh_shader()) @@ -8718,7 +8831,7 @@ 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); + ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_PTR_CHAIN_BIT, &meta, nullptr); if (i + 1 < num_control_points) expr += ", "; } @@ -8754,7 +8867,8 @@ bool CompilerMSL::emit_tessellation_io_load(uint32_t result_type_id, uint32_t id 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); + ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_PTR_CHAIN_BIT, + &meta, nullptr); if (!is_matrix(sub_type) && sub_type.basetype != SPIRType::Struct && expr_type.vecsize > sub_type.vecsize) expr += vector_swizzle(sub_type.vecsize, 0); @@ -8812,7 +8926,8 @@ bool CompilerMSL::emit_tessellation_io_load(uint32_t result_type_id, uint32_t id 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); + ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_PTR_CHAIN_BIT, + &meta, nullptr); } else expr += to_expression(ptr) + "." + to_member_name(iface_type, interface_index); @@ -8836,7 +8951,8 @@ bool CompilerMSL::emit_tessellation_io_load(uint32_t result_type_id, uint32_t id 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); + ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_PTR_CHAIN_BIT, + &meta, nullptr); } else expr += to_expression(ptr) + "." + to_member_name(iface_type, interface_index); @@ -8856,7 +8972,7 @@ bool CompilerMSL::emit_tessellation_io_load(uint32_t result_type_id, uint32_t id 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); + &meta, nullptr); } else expr += to_expression(ptr) + "." + to_member_name(iface_type, interface_index); @@ -8901,7 +9017,8 @@ bool CompilerMSL::emit_tessellation_io_load(uint32_t result_type_id, uint32_t id 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); + ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_PTR_CHAIN_BIT, + &meta, nullptr); if (expr_type.vecsize > result_type.vecsize) expr += vector_swizzle(result_type.vecsize, 0); if (j + 1 < result_type.columns) @@ -8946,7 +9063,8 @@ bool CompilerMSL::emit_tessellation_io_load(uint32_t result_type_id, uint32_t id 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); + ACCESS_CHAIN_INDEX_IS_LITERAL_BIT | ACCESS_CHAIN_PTR_CHAIN_BIT, + &meta, nullptr); if (expr_type.vecsize > result_type.vecsize) expr += vector_swizzle(result_type.vecsize, 0); @@ -8991,7 +9109,6 @@ bool CompilerMSL::emit_tessellation_access_chain(const uint32_t *ops, uint32_t l auto *var = maybe_get_backing_variable(ops[2]); bool patch = false; bool flat_data = false; - bool ptr_is_chain = false; bool flatten_composites = false; bool is_block = false; @@ -9012,12 +9129,6 @@ bool CompilerMSL::emit_tessellation_access_chain(const uint32_t *ops, uint32_t l // Patch inputs are treated as normal block IO variables, so they don't deal with this path at all. if (patch && (!is_block || is_arrayed || 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]); } bool builtin_variable = false; @@ -9038,10 +9149,27 @@ bool CompilerMSL::emit_tessellation_access_chain(const uint32_t *ops, uint32_t l if (variable_is_flat) { + if (auto *ptr_expr = maybe_get(ops[2])) + { + // Too many edge cases in incrementally resolving tessellation access chains. + // Only reasonable option is to completely rematerialize the chain from the start. + SmallVector rematerialize_ops; + rematerialize_ops.push_back(ops[0]); + rematerialize_ops.push_back(ops[1]); + + for (auto expr : ptr_expr->implied_read_expressions) + rematerialize_ops.push_back(expr); + + for (uint32_t i = 3; i < length; i++) + rematerialize_ops.push_back(ops[i]); + + return emit_tessellation_access_chain(rematerialize_ops.data(), uint32_t(rematerialize_ops.size())); + } + // 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) + if (var->storage == StorageClassOutput) { bool masked = false; if (is_block) @@ -9068,7 +9196,7 @@ bool CompilerMSL::emit_tessellation_access_chain(const uint32_t *ops, uint32_t l indices.reserve(length - 3 + 1); - uint32_t first_non_array_index = (ptr_is_chain ? 3 : 4) - (patch ? 1 : 0); + uint32_t first_non_array_index = 4 - (patch ? 1 : 0); VariableID stage_var_id; if (patch) @@ -9076,8 +9204,9 @@ bool CompilerMSL::emit_tessellation_access_chain(const uint32_t *ops, uint32_t l 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 && !patch) + VariableID ptr = stage_var_id; + + if (!patch) { // Index into gl_in/gl_out with first array index. indices.push_back(ops[first_non_array_index - 1]); @@ -9088,17 +9217,7 @@ bool CompilerMSL::emit_tessellation_access_chain(const uint32_t *ops, uint32_t l uint32_t const_mbr_id = next_id++; 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)) + if (flatten_composites || is_block) { uint32_t i = first_non_array_index; auto *type = &get_variable_element_type(*var); @@ -9194,42 +9313,8 @@ bool CompilerMSL::emit_tessellation_access_chain(const uint32_t *ops, uint32_t l // We use the pointer to the base of the input/output array here, // so this is always a pointer chain. - string e; - - 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, !patch); - } - else - { - // If we're accessing a struct, we need to use member indices which are based on the IO block, - // not actual struct type, so we have to use a split access chain here where - // first path resolves the control point index, i.e. gl_in[index], and second half deals with - // looking up flattened member name. - - // However, it is possible that we partially accessed a struct, - // by taking pointer to member inside the control-point array. - // For this case, we fall back to a natural access chain since we have already dealt with remapping struct members. - // One way to check this here is if we have 2 implied read expressions. - // 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); - 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()), - ACCESS_CHAIN_CHAIN_ONLY_BIT, &meta)); - } - else - { - e = access_chain_internal(ptr, indices.data(), uint32_t(indices.size()), 0, &meta); - } - } + // This is the start of an access chain, use ptr_chain to index into control point array. + auto e = access_chain(ptr, indices.data(), uint32_t(indices.size()), result_ptr_type, &meta, !patch); // Get the actual type of the object that was accessed. If it's a vector type and we changed it, // then we'll need to add a swizzle. @@ -9449,6 +9534,227 @@ bool CompilerMSL::check_physical_type_cast(std::string &expr, const SPIRType *ty return false; } +// Metal only implements Subgroup scoped 8x8 matrices with floating-point components. +void CompilerMSL::validate_cooperative_matrix_type(const SPIRType &type) +{ + // Only the component types which have a simdgroup_*8x8 equivalent. + auto &comp = get(type.parent_type); + if (comp.basetype != SPIRType::Float && comp.basetype != SPIRType::Half && comp.basetype != SPIRType::BFloat16) + SPIRV_CROSS_THROW("MSL cooperative matrices only support float16, float32, and bfloat16 component types."); + + // Only Subgroup scope. + auto &scope = get(type.ext.cooperative.scope_id); + if (scope.specialization) + SPIRV_CROSS_THROW("MSL does not support spec-constant scope for cooperative matrices."); + if (scope.scalar() != ScopeSubgroup) + SPIRV_CROSS_THROW("MSL cooperative matrices only support Subgroup scope."); + + // Only 8x8. + auto &rows = get(type.ext.cooperative.rows_id); + auto &columns = get(type.ext.cooperative.columns_id); + if (rows.specialization || columns.specialization) + SPIRV_CROSS_THROW("MSL does not support spec-constant dimensions for cooperative matrices."); + if (rows.scalar() != 8 || columns.scalar() != 8) + SPIRV_CROSS_THROW("MSL cooperative matrices only support 8x8 dimensions."); +} + +// Validates all cooperative matrix types up-front, rather than failing partway through a function. +void CompilerMSL::validate_cooperative_matrix_types() +{ + ir.for_each_typed_id([&](uint32_t, const SPIRType &type) { + if (type.op == OpTypeCooperativeMatrixKHR) + validate_cooperative_matrix_type(type); + }); +} + +// 8x8 matrix over a 32-wide SIMD-group: every invocation holds two components. +static const uint32_t k_cooperative_matrix_components_per_thread = (8 * 8) / 32; + +// Non-matrix operands, e.g. the scalar in OpMatrixTimesScalar, are broadcast to every component. +string CompilerMSL::to_cooperative_matrix_component(uint32_t id, const string &index) +{ + if (expression_type(id).op != OpTypeCooperativeMatrixKHR) + return to_enclosed_unpacked_expression(id); + + return join(to_enclosed_unpacked_expression(id), ".thread_elements()[", index, "]"); +} + +// op is prefixed to every component, so an empty op copies or broadcasts op0 instead. +void CompilerMSL::emit_cooperative_matrix_unary_op(uint32_t result_type, uint32_t result_id, uint32_t op0, + const char *op) +{ + emit_uninitialized_temporary_expression(result_type, result_id); + + for (uint32_t i = 0; i < k_cooperative_matrix_components_per_thread; i++) + { + auto index = join(i, "u"); + statement(to_cooperative_matrix_component(result_id, index), " = ", op, + to_cooperative_matrix_component(op0, index), ";"); + } + + inherit_expression_dependencies(result_id, op0); +} + +void CompilerMSL::emit_cooperative_matrix_binary_op(uint32_t result_type, uint32_t result_id, uint32_t op0, + uint32_t op1, const char *op) +{ + emit_uninitialized_temporary_expression(result_type, result_id); + + for (uint32_t i = 0; i < k_cooperative_matrix_components_per_thread; i++) + { + auto index = join(i, "u"); + statement(to_cooperative_matrix_component(result_id, index), " = ", + to_cooperative_matrix_component(op0, index), " ", op, " ", + to_cooperative_matrix_component(op1, index), ";"); + } + + inherit_expression_dependencies(result_id, op0); + inherit_expression_dependencies(result_id, op1); +} + +void CompilerMSL::emit_cooperative_matrix_unary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, + const char *op) +{ + emit_uninitialized_temporary_expression(result_type, result_id); + + for (uint32_t i = 0; i < k_cooperative_matrix_components_per_thread; i++) + { + auto index = join(i, "u"); + statement(to_cooperative_matrix_component(result_id, index), " = ", op, "(", + to_cooperative_matrix_component(op0, index), ");"); + } + + inherit_expression_dependencies(result_id, op0); +} + +void CompilerMSL::emit_cooperative_matrix_select_op(uint32_t result_type, uint32_t result_id, uint32_t cond, + uint32_t op0, uint32_t op1) +{ + emit_uninitialized_temporary_expression(result_type, result_id); + + for (uint32_t i = 0; i < k_cooperative_matrix_components_per_thread; i++) + { + auto index = join(i, "u"); + statement(to_cooperative_matrix_component(result_id, index), " = ", to_enclosed_unpacked_expression(cond), + " ? ", to_cooperative_matrix_component(op0, index), " : ", + to_cooperative_matrix_component(op1, index), ";"); + } + + inherit_expression_dependencies(result_id, cond); + inherit_expression_dependencies(result_id, op0); + inherit_expression_dependencies(result_id, op1); +} + +// Returns false if instruction is not a cooperative matrix op, so the caller can fall back. +bool CompilerMSL::maybe_emit_cooperative_matrix_op(const Instruction &instruction) +{ + if (instruction.length < 3) + return false; + + auto opcode = static_cast(instruction.op); + bool has_result = false, has_result_type = false; + HasResultAndType(opcode, &has_result, &has_result_type); + if (!has_result_type) + return false; + + auto *ops = stream(instruction); + uint32_t result_type = ops[0]; + uint32_t result_id = ops[1]; + + auto *type = &get(result_type); + while (type && (is_pointer(*type) || is_array(*type))) + type = maybe_get(type->parent_type); + + if (!type || type->op != OpTypeCooperativeMatrixKHR) + { + // Extraction returns a scalar, so here the cooperative matrix is an operand, not the result. + if ((opcode == OpCompositeExtract || opcode == OpVectorExtractDynamic) && instruction.length >= 4 && + expression_type(ops[2]).op == OpTypeCooperativeMatrixKHR) + { + bool index_is_id = opcode == OpVectorExtractDynamic; + auto index = index_is_id ? to_expression(ops[3]) : join(ops[3], "u"); + + emit_op(result_type, result_id, to_cooperative_matrix_component(ops[2], index), should_forward(ops[2])); + + inherit_expression_dependencies(result_id, ops[2]); + if (index_is_id) + inherit_expression_dependencies(result_id, ops[3]); + return true; + } + + return false; + } + + // Unsupported component types, scope or dimensions are rejected by validate_cooperative_matrix_types(). + switch (opcode) + { + case OpFNegate: + emit_cooperative_matrix_unary_op(result_type, result_id, ops[2], "-"); + break; + + case OpFAdd: + emit_cooperative_matrix_binary_op(result_type, result_id, ops[2], ops[3], "+"); + break; + + case OpFSub: + emit_cooperative_matrix_binary_op(result_type, result_id, ops[2], ops[3], "-"); + break; + + case OpFMul: + case OpMatrixTimesScalar: + emit_cooperative_matrix_binary_op(result_type, result_id, ops[2], ops[3], "*"); + break; + + case OpFDiv: + emit_cooperative_matrix_binary_op(result_type, result_id, ops[2], ops[3], "/"); + break; + + case OpFConvert: + { + auto component_type = type_to_glsl(get(type->parent_type)); + emit_cooperative_matrix_unary_func_op(result_type, result_id, ops[2], component_type.c_str()); + break; + } + + case OpCompositeConstruct: + // A cooperative matrix is constructed from a single scalar, broadcast to every component. + if (instruction.length != 3) + SPIRV_CROSS_THROW("OpCompositeConstruct for cooperative matrix requires exactly one scalar component."); + emit_cooperative_matrix_unary_op(result_type, result_id, ops[2], ""); + break; + + case OpSelect: + // The condition is a scalar bool. Boolean cooperative matrices are rejected by validation. + emit_cooperative_matrix_select_op(result_type, result_id, ops[2], ops[3], ops[4]); + break; + + case OpCompositeInsert: + case OpVectorInsertDynamic: + { + // OpCompositeInsert takes (object, composite, literal index), + // OpVectorInsertDynamic takes (vector, component, index id). + bool index_is_id = opcode == OpVectorInsertDynamic; + uint32_t object = index_is_id ? ops[3] : ops[2]; + uint32_t matrix = index_is_id ? ops[2] : ops[3]; + auto index = index_is_id ? to_expression(ops[4]) : join(ops[4], "u"); + + // Copy the matrix, then overwrite the one component being inserted. + emit_cooperative_matrix_unary_op(result_type, result_id, matrix, ""); + statement(to_cooperative_matrix_component(result_id, index), " = ", to_unpacked_expression(object), ";"); + + inherit_expression_dependencies(result_id, object); + if (index_is_id) + inherit_expression_dependencies(result_id, ops[4]); + break; + } + + default: + SPIRV_CROSS_THROW("Unsupported operation on cooperative matrix in MSL backend."); + } + + return true; +} + // Override for MSL-specific syntax instructions void CompilerMSL::emit_instruction(const Instruction &instruction) { @@ -9489,10 +9795,31 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) } else { - // Sample mask input for Metal is not an array - if (BuiltIn(get_decoration(ptr, DecorationBuiltIn)) == BuiltInSampleMask) - set_decoration(id, DecorationBuiltIn, BuiltInSampleMask); - CompilerGLSL::emit_instruction(instruction); + auto is_sample_mask = BuiltIn(get_decoration(ptr, DecorationBuiltIn)) == BuiltInSampleMask; + auto ptr_storage = get_expression_effective_storage_class(ptr); + auto *ptr_var = maybe_get_backing_variable(ptr); + + // More edge cases ... Normally composite outputs are lowered at the end, + // but that's not the case for clip-cull arrays. + if (ptr_var && ptr_storage == StorageClassOutput && is_builtin_variable(*ptr_var) && + !is_sample_mask && is_array(get(ops[0]))) + { + emit_uninitialized_temporary_expression(ops[0], id); + auto &type = get(ops[0]); + if (type.array.size() != 1) + SPIRV_CROSS_THROW("Cannot load array of clip-cull distances from array of array."); + if (!type.array_size_literal.front()) + SPIRV_CROSS_THROW("Cannot load array of clip-cull distances from spec constant array size."); + for (uint32_t i = 0; i < type.array[0]; i++) + statement(to_expression(id), "[", i, "] = ", to_expression(ptr), "[", i, "];"); + } + else + { + // Sample mask input for Metal is not an array + if (is_sample_mask) + set_decoration(id, DecorationBuiltIn, BuiltInSampleMask); + CompilerGLSL::emit_instruction(instruction); + } } break; } @@ -9671,6 +9998,8 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) break; case OpFMul: + if (maybe_emit_cooperative_matrix_op(instruction)) + break; if (msl_options.invariant_float_math || has_legacy_nocontract(ops[0], ops[1])) MSL_BFOP(spvFMul); else @@ -9678,6 +10007,8 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) break; case OpFAdd: + if (maybe_emit_cooperative_matrix_op(instruction)) + break; if (msl_options.invariant_float_math || has_legacy_nocontract(ops[0], ops[1])) MSL_BFOP(spvFAdd); else @@ -9685,6 +10016,8 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) break; case OpFSub: + if (maybe_emit_cooperative_matrix_op(instruction)) + break; if (msl_options.invariant_float_math || has_legacy_nocontract(ops[0], ops[1])) MSL_BFOP(spvFSub); else @@ -9853,6 +10186,7 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) auto &e = set(id, join(to_expression(ops[2]), "_atomic[", coord, "]"), result_type, true); e.loaded_from = var ? var->self : ID(0); + e.access_chain = true; // This is kinda an access chain and should be treated as a dereferenced expression. inherit_expression_dependencies(id, ops[3]); } else @@ -10016,7 +10350,7 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) case Dim1D: if (!msl_options.texture_1D_as_2D) SPIRV_CROSS_THROW("ImageQueryLod is not supported on 1D textures."); - [[fallthrough]]; + /* fallthrough */ case Dim2D: if (coord_type.vecsize > 2) coord_expr = enclose_expression(coord_expr) + ".xy"; @@ -10488,7 +10822,7 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) case OpRayQueryGetIntersectionCandidateAABBOpaqueKHR: { flush_variable_declaration(ops[0]); - emit_op(ops[0], ops[1], join(to_expression(ops[2]), ".is_candidate_non_opaque_bounding_box()"), false); + emit_op(ops[0], ops[1], join("(!", to_expression(ops[2]), ".is_candidate_non_opaque_bounding_box())"), false); break; } case OpRayQueryConfirmIntersectionKHR: @@ -10522,15 +10856,23 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) if (opcode != OpBitcast || is_pointer(type) || is_pointer(input_type)) { string op; + auto input_expr = to_unpacked_expression(ops[2]); if ((type.vecsize == 1 || is_pointer(type)) && (input_type.vecsize == 1 || is_pointer(input_type))) - op = join("reinterpret_cast<", type_to_glsl(type), ">(", to_unpacked_expression(ops[2]), ")"); + op = join("reinterpret_cast<", type_to_glsl(type), ">(", input_expr, ")"); else if (input_type.vecsize == 2) - op = join("reinterpret_cast<", type_to_glsl(type), ">(as_type(", to_unpacked_expression(ops[2]), "))"); + op = join("reinterpret_cast<", type_to_glsl(type), ">(as_type(", input_expr, "))"); else - op = join("as_type<", type_to_glsl(type), ">(reinterpret_cast(", to_unpacked_expression(ops[2]), "))"); + op = join("as_type<", type_to_glsl(type), ">(reinterpret_cast(", input_expr, "))"); - emit_op(ops[0], ops[1], op, should_forward(ops[2])); + auto &expr = emit_op(ops[0], ops[1], op, should_forward(ops[2])); + if (is_pointer(type)) + { + if (auto *backing_var = maybe_get_backing_variable(ops[2])) + expr.loaded_from = backing_var->self; + else + expr.loaded_from = ID(ops[2]); + } inherit_expression_dependencies(ops[1], ops[2]); } else @@ -10694,10 +11036,212 @@ void CompilerMSL::emit_instruction(const Instruction &instruction) break; } + case OpCooperativeMatrixLoadKHR: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + uint32_t ptr = ops[2]; + uint32_t layout = ops[3]; + + auto &layout_c = get(layout); + if (layout_c.specialization) + SPIRV_CROSS_THROW("MSL cooperative matrix load does not support spec-constant layout."); + uint32_t layout_val = layout_c.scalar(); + bool col_major = false; + + switch (layout_val) + { + case CooperativeMatrixLayoutRowMajorKHR: + case CooperativeMatrixLayoutColumnMajorKHR: + if (instruction.length < 5) + SPIRV_CROSS_THROW("MSL cooperative matrix load requires Stride for row/column-major layouts."); + col_major = (layout_val == CooperativeMatrixLayoutColumnMajorKHR); + break; + + default: + SPIRV_CROSS_THROW("MSL cooperative matrix load only supports RowMajorKHR and ColumnMajorKHR layouts."); + } + + uint32_t stride = ops[4]; + + emit_uninitialized_temporary_expression(result_type, id); + + auto ptr_expr = to_ptr_expression(ptr); + string stride_expr = to_expression(stride); + + // The pointer operand is allowed to use a different element type than the cooperative matrix component type. + // In that case, cast the pointer and convert the stride from source element units to component element units. + auto &mat_type = get(result_type); + auto &component_type = get(mat_type.parent_type); + auto &ptr_type = expression_type(ptr); + auto &pointee_type = get(ptr_type.parent_type); + if (pointee_type.self != component_type.self) + { + auto addr_space = get_type_address_space(ptr_type, ptr); + ptr_expr = join("reinterpret_cast<", addr_space, " ", type_to_glsl(component_type), "*>(", ptr_expr, ")"); + + uint32_t src_bytes = (pointee_type.width * pointee_type.vecsize) / 8; + uint32_t dst_bytes = (component_type.width * component_type.vecsize) / 8; + if (src_bytes == 0 || dst_bytes == 0) + SPIRV_CROSS_THROW("Cannot determine element size for cooperative matrix load/store."); + + if (src_bytes == dst_bytes) + { + // No conversion needed. + } + else if (src_bytes > dst_bytes && (src_bytes % dst_bytes) == 0) + { + uint32_t multiplier = src_bytes / dst_bytes; + stride_expr = join("(", stride_expr, ") * ", multiplier, "u"); + } + else if (src_bytes < dst_bytes && (dst_bytes % src_bytes) == 0) + { + uint32_t divisor = dst_bytes / src_bytes; + stride_expr = join("(", stride_expr, ") / ", divisor, "u"); + } + else + { + stride_expr = join("((", stride_expr, ") * ", src_bytes, "u) / ", dst_bytes, "u"); + } + } + + if (col_major) + statement("simdgroup_load(", to_expression(id), ", ", + ptr_expr, ", ", stride_expr, ", ulong2(0), true);"); + else + statement("simdgroup_load(", to_expression(id), ", ", + ptr_expr, ", ", stride_expr, ");"); + + register_read(id, ptr, false); + break; + } + + case OpCooperativeMatrixStoreKHR: + { + uint32_t ptr = ops[0]; + uint32_t obj = ops[1]; + uint32_t layout = ops[2]; + + auto &layout_c = get(layout); + if (layout_c.specialization) + SPIRV_CROSS_THROW("MSL cooperative matrix store does not support spec-constant layout."); + uint32_t layout_val = layout_c.scalar(); + bool col_major = false; + + switch (layout_val) + { + case CooperativeMatrixLayoutRowMajorKHR: + case CooperativeMatrixLayoutColumnMajorKHR: + if (instruction.length < 4) + SPIRV_CROSS_THROW("MSL cooperative matrix store requires Stride for row/column-major layouts."); + col_major = (layout_val == CooperativeMatrixLayoutColumnMajorKHR); + break; + + default: + SPIRV_CROSS_THROW("MSL cooperative matrix store only supports RowMajorKHR and ColumnMajorKHR layouts."); + } + + uint32_t stride = ops[3]; + + auto ptr_expr = to_ptr_expression(ptr); + string stride_expr = to_expression(stride); + + // The pointer operand is allowed to use a different element type than the cooperative matrix component type. + // In that case, cast the pointer and convert the stride from source element units to component element units. + auto &mat_type = expression_type(obj); + auto &component_type = get(mat_type.parent_type); + auto &ptr_type = expression_type(ptr); + auto &pointee_type = get(ptr_type.parent_type); + if (pointee_type.self != component_type.self) + { + auto addr_space = get_type_address_space(ptr_type, ptr); + ptr_expr = join("reinterpret_cast<", addr_space, " ", type_to_glsl(component_type), "*>(", ptr_expr, ")"); + + uint32_t src_bytes = (pointee_type.width * pointee_type.vecsize) / 8; + uint32_t dst_bytes = (component_type.width * component_type.vecsize) / 8; + if (src_bytes == 0 || dst_bytes == 0) + SPIRV_CROSS_THROW("Cannot determine element size for cooperative matrix load/store."); + + if (src_bytes == dst_bytes) + { + // No conversion needed. + } + else if (src_bytes > dst_bytes && (src_bytes % dst_bytes) == 0) + { + uint32_t multiplier = src_bytes / dst_bytes; + stride_expr = join("(", stride_expr, ") * ", multiplier, "u"); + } + else if (src_bytes < dst_bytes && (dst_bytes % src_bytes) == 0) + { + uint32_t divisor = dst_bytes / src_bytes; + stride_expr = join("(", stride_expr, ") / ", divisor, "u"); + } + else + { + stride_expr = join("((", stride_expr, ") * ", src_bytes, "u) / ", dst_bytes, "u"); + } + } + + if (col_major) + statement("simdgroup_store(", to_expression(obj), ", ", + ptr_expr, ", ", stride_expr, ", ulong2(0), true);"); + else + statement("simdgroup_store(", to_expression(obj), ", ", + ptr_expr, ", ", stride_expr, ");"); + + register_write(ptr); + break; + } + + case OpCooperativeMatrixMulAddKHR: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + uint32_t A = ops[2], B = ops[3], C = ops[4]; + + // Matrix operand flags only affect integer components, which are not supported here. + + emit_uninitialized_temporary_expression(result_type, id); + statement("simdgroup_multiply_accumulate(", to_expression(id), ", ", + to_unpacked_expression(A), ", ", + to_unpacked_expression(B), ", ", + to_unpacked_expression(C), ");"); + + inherit_expression_dependencies(id, A); + inherit_expression_dependencies(id, B); + inherit_expression_dependencies(id, C); + break; + } + + case OpCooperativeMatrixLengthKHR: + { + uint32_t result_type = ops[0]; + uint32_t id = ops[1]; + auto &coop_type = get(ops[2]); + + if (coop_type.op != OpTypeCooperativeMatrixKHR) + SPIRV_CROSS_THROW("OpCooperativeMatrixLengthKHR requires cooperative matrix type."); + + auto &component_type = get(coop_type.parent_type); + auto coop_type_name = type_to_glsl(coop_type); + auto component_type_name = type_to_glsl(component_type); + + auto expr = join(type_to_glsl(get(result_type)), + "(sizeof(", coop_type_name, "::storage_type) / sizeof(", component_type_name, "))"); + emit_op(result_type, id, expr, true); + break; + } + default: + { + // Prevent GLSL cooperative matrix code from leaking into MSL output. + if (maybe_emit_cooperative_matrix_op(instruction)) + break; + CompilerGLSL::emit_instruction(instruction); break; } + } previous_instruction_opcode = opcode; } @@ -10852,7 +11396,7 @@ void CompilerMSL::emit_barrier(uint32_t id_exe_scope, uint32_t id_mem_scope, uin break; case ScopeSubgroup: - bar_stmt += ", thread_scope_subgroup"; + bar_stmt += ", thread_scope_simdgroup"; break; case ScopeInvocation: @@ -10923,6 +11467,12 @@ bool CompilerMSL::emit_array_copy(const char *expr, uint32_t lhs_id, uint32_t rh else if (rhs_var && rhs_storage != StorageClassGeneric && type_is_explicit_layout(get(rhs_var->basetype))) rhs_is_array_template = false; + // Special consideration for clip/culldistance. Normally composites are lowered, but clip/cull is special for reasons ... + if (lhs_var && lhs_storage == StorageClassOutput && is_builtin_variable(*lhs_var)) + lhs_is_array_template = false; + if (rhs_var && rhs_storage == StorageClassOutput && is_builtin_variable(*rhs_var)) + rhs_is_array_template = false; + // If threadgroup storage qualifiers are *not* used: // Avoid spvCopy* wrapper functions; Otherwise, spvUnsafeArray<> template cannot be used with that storage qualifier. if (lhs_is_array_template && rhs_is_array_template && !using_builtin_array()) @@ -11251,9 +11801,7 @@ void CompilerMSL::emit_atomic_func_op(uint32_t result_type, uint32_t result_id, // There is no other way, since C++ does not have explicit signage for atomics. exp += type_to_glsl(remapped_type); exp += "*)"; - - exp += "&"; - exp += to_enclosed_expression(obj); + exp += to_enclosed_pointer_expression(obj); } if (is_atomic_compare_exchange_strong) @@ -12025,7 +12573,7 @@ string CompilerMSL::to_function_name(const TextureFunctionNameArguments &args) if (msl_options.swizzle_texture_samples && args.base.is_gather && !is_dynamic_img_sampler && (!constexpr_sampler || !constexpr_sampler->ycbcr_conversion_enable)) { - bool is_compare = comparison_ids.count(img); + bool is_compare = args.has_dref; add_spv_func_and_recompile(is_compare ? SPVFuncImplGatherCompareSwizzle : SPVFuncImplGatherSwizzle); return is_compare ? "spvGatherCompareSwizzle" : "spvGatherSwizzle"; } @@ -12034,7 +12582,7 @@ string CompilerMSL::to_function_name(const TextureFunctionNameArguments &args) if (args.has_array_offsets && !is_dynamic_img_sampler && (!constexpr_sampler || !constexpr_sampler->ycbcr_conversion_enable)) { - bool is_compare = comparison_ids.count(img); + bool is_compare = args.has_dref; add_spv_func_and_recompile(is_compare ? SPVFuncImplGatherCompareConstOffsets : SPVFuncImplGatherConstOffsets); return is_compare ? "spvGatherCompareConstOffsets" : "spvGatherConstOffsets"; } @@ -12149,7 +12697,18 @@ string CompilerMSL::to_function_name(const TextureFunctionNameArguments &args) } else { - fname = to_expression(combined ? combined->image : img) + "."; + string img_expr = to_expression(combined ? combined->image : img); + + // Vulkan ignores Depth as part of the SPIR-V type, and we cannot rely on it. + // We also cannot rely on deduction through code analysis since a texture can be consumed + // in both Dref and non-Dref contexts, which MSL normally does not allow without hackery. + if (args.has_dref) + { + add_spv_func_and_recompile(SPVFuncImplDepthCast); + img_expr = join("spvDepthCast(", img_expr, ")"); + } + + fname = img_expr + "."; // Texture function and sampler if (args.base.is_fetch) @@ -12216,12 +12775,31 @@ string CompilerMSL::to_function_args(const TextureFunctionArguments &args, bool msl_options.swizzle_texture_samples && args.base.is_gather) { auto *combined = maybe_get(img); - farg_str += to_expression(combined ? combined->image : img); + auto img_expr = to_expression(combined ? combined->image : img); + if (args.dref) + { + add_spv_func_and_recompile(SPVFuncImplDepthCast); + img_expr = join("spvDepthCast(", img_expr, ")"); + } + farg_str += img_expr; } // Gathers with constant offsets call a special function, so include the texture. if (args.has_array_offsets) - farg_str += to_expression(img); + { + // Vulkan ignores Depth as part of the SPIR-V type, and we cannot rely on it. + // We also cannot rely on deduction through code analysis since a texture can be consumed + // in both Dref and non-Dref contexts, which MSL normally does not allow without hackery. + if (args.dref) + { + add_spv_func_and_recompile(SPVFuncImplDepthCast); + farg_str += join("spvDepthCast(", to_expression(img), ")"); + } + else + { + farg_str += to_expression(img); + } + } // Sampler reference if (!args.base.is_fetch) @@ -12709,18 +13287,12 @@ string CompilerMSL::to_function_args(const TextureFunctionArguments &args, bool { forward = forward && should_forward(args.component); - uint32_t image_var = 0; - if (const auto *combined = maybe_get(img)) - { - if (const auto *img_var = maybe_get_backing_variable(combined->image)) - image_var = img_var->self; - } - else if (const auto *var = maybe_get_backing_variable(img)) - { - image_var = var->self; - } - - if (image_var == 0 || !is_depth_image(expression_type(image_var), image_var)) + // gather_compare (Dref) takes no component argument, and neither does plain gather() + // on a resource that's genuinely depth-typed at this call site. + // Cast to a depthXXX via spvDepthCast + // because this specific call has a Dref. A resource that's only comparison_ids-tracked + // but has no Dref on THIS call stays texture2d here and does take a component. + if (!args.dref) farg_str += ", " + to_component_argument(args.component); } } @@ -13249,7 +13821,7 @@ bool CompilerMSL::is_non_native_row_major_matrix(uint32_t id) } // Checks whether the member is a row_major matrix that requires conversion before use -bool CompilerMSL::member_is_non_native_row_major_matrix(const SPIRType &type, uint32_t index) +bool CompilerMSL::member_is_non_native_row_major_matrix(const SPIRType &type, uint32_t index, bool /*is_layout_disabled*/) { return has_member_decoration(type.self, index, DecorationRowMajor); } @@ -13282,11 +13854,49 @@ void CompilerMSL::emit_fixup() { if (options.vertex.fixup_clipspace) statement(qual_pos_var_name, ".z = (", qual_pos_var_name, ".z + ", qual_pos_var_name, - ".w) * 0.5; // Adjust clip-space for Metal"); + ".w) * 0.5; // Adjust clip-space for Metal"); + + if (msl_options.emulate_depth_clip_enable) + { + string viewport_idx = + qual_viewport_idx_var_name.empty() ? "0" : join("uint(", qual_viewport_idx_var_name, ")"); + statement("if (spvDepthClipState.emulateViewportZ != 0u)"); + begin_scope(); + statement("float2 spvViewportDepthRange = spvDepthClipState.viewportDepthRanges[", viewport_idx, "];"); + statement(qual_pos_var_name, ".z = ", qual_pos_var_name, + ".z * (spvViewportDepthRange.y - spvViewportDepthRange.x) + ", qual_pos_var_name, + ".w * spvViewportDepthRange.x; // Emulate viewport Z transform"); + end_scope(); + } + + if (msl_options.emulate_reversed_depth_viewport) + { + if (qual_viewport_idx_var_name.empty()) + // If ViewportIndex is not written, the primitive uses viewport 0. + statement("if ((spvEmulatedReversedDepthViewportMask & 1u) != 0u)"); + else + statement("if (((spvEmulatedReversedDepthViewportMask >> uint(", qual_viewport_idx_var_name, + ")) & 1u) != 0u)"); + begin_scope(); + statement(qual_pos_var_name, ".z = ", qual_pos_var_name, ".w - ", qual_pos_var_name, + ".z; // Emulate reversed-depth viewport"); + end_scope(); + } if (options.vertex.flip_vert_y) statement(qual_pos_var_name, ".y = -(", qual_pos_var_name, ".y);", " // Invert Y-axis for Metal"); } + else if (get_execution_model() == ExecutionModelFragment && !qual_frag_depth_var_name.empty() && + msl_options.emulate_depth_clip_enable) + { + string viewport_idx = depth_clip_viewport_idx_var_name.empty() ? "0" : depth_clip_viewport_idx_var_name; + statement("if (spvDepthClipState.emulateDepthClamp != 0u)"); + begin_scope(); + statement("float2 spvViewportDepthRange = spvDepthClipState.viewportDepthRanges[", viewport_idx, "];"); + statement(qual_frag_depth_var_name, " = clamp(", qual_frag_depth_var_name, + ", spvViewportDepthRange.x, spvViewportDepthRange.y);"); + end_scope(); + } } } @@ -13475,6 +14085,24 @@ string CompilerMSL::to_struct_member(const SPIRType &type, uint32_t member_type_ else decl_type = type_to_glsl(*declared_type, orig_id, true); + if (physical_type.basetype == SPIRType::Struct && + has_decoration(physical_type.self, DecorationArrayStride) && + is_array(physical_type)) + { + uint32_t native_stride = get_decoration(physical_type.self, DecorationArrayStride); + uint32_t array_stride = get_decoration(type.member_types[index], DecorationArrayStride); + auto *struct_array_type = &physical_type; + + while (struct_array_type->parent_type && is_array(get(struct_array_type->parent_type))) + { + array_stride = get_decoration(struct_array_type->parent_type, DecorationArrayStride); + struct_array_type = &get(struct_array_type->parent_type); + } + + if (array_stride != native_stride) + decl_type = join("spvPaddedArrayElement<", decl_type, ", ", array_stride, ">"); + } + const char *overlapping_binding_tag = has_extended_member_decoration(type.self, index, SPIRVCrossDecorationOverlappingBinding) ? "// Overlapping binding: " : ""; @@ -13513,16 +14141,6 @@ void CompilerMSL::emit_struct_member(const SPIRType &type, uint32_t member_type_ builtin_declaration = false; } -void CompilerMSL::emit_struct_padding_target(const SPIRType &type) -{ - uint32_t struct_size = get_declared_struct_size_msl(type, true, true); - uint32_t target_size = get_extended_decoration(type.self, SPIRVCrossDecorationPaddingTarget); - if (target_size < struct_size) - SPIRV_CROSS_THROW("Cannot pad with negative bytes."); - else if (target_size > struct_size) - statement("char _m0_final_padding[", target_size - struct_size, "];"); -} - // Return a MSL qualifier for the specified function attribute member string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t index) { @@ -13562,9 +14180,6 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in return ""; return string(" [[") + builtin_qualifier(builtin) + "]]"; - case BuiltInDrawIndex: - SPIRV_CROSS_THROW("DrawIndex is not supported in MSL."); - default: return ""; } @@ -14413,6 +15028,9 @@ bool CompilerMSL::is_direct_input_builtin(BuiltIn bi_type) /* fallthrough */ case BuiltInSubgroupLocalInvocationId: return !msl_options.emulate_subgroups; + case BuiltInDrawIndex: + // Emulated + return false; default: return true; } @@ -14436,6 +15054,8 @@ bool CompilerMSL::is_intersection_query() const void CompilerMSL::entry_point_args_builtin(string &ep_args) { + depth_clip_viewport_idx_var_name = ""; + // Builtin variables SmallVector, 8> active_builtins; ir.for_each_typed_id([&](uint32_t var_id, SPIRVariable &var) { @@ -14460,6 +15080,9 @@ void CompilerMSL::entry_point_args_builtin(string &ep_args) if (is_direct_input_builtin(bi_type)) { + if (bi_type == BuiltInViewportIndex) + depth_clip_viewport_idx_var_name = to_expression(var_id); + if (!ep_args.empty()) ep_args += ", "; @@ -14524,6 +15147,32 @@ void CompilerMSL::entry_point_args_builtin(string &ep_args) if (needs_base_instance_arg == TriState::Yes) ep_args += built_in_func_arg(BuiltInBaseInstance, !ep_args.empty()); + if (needs_depth_clip_state_buffer()) + { + if (get_execution_model() == ExecutionModelFragment && msl_options.supports_msl_version(2, 0) && + depth_clip_viewport_idx_var_name.empty()) + { + if (!ep_args.empty()) + ep_args += ", "; + depth_clip_viewport_idx_var_name = "spvDepthClipViewportIndex"; + ep_args += "uint spvDepthClipViewportIndex [[viewport_array_index]]"; + } + + if (!ep_args.empty()) + ep_args += ", "; + ep_args += join("constant spvDepthClipState& spvDepthClipState [[buffer(", + msl_options.depth_clip_state_buffer_index, ")]]"); + } + + if (msl_options.emulate_reversed_depth_viewport && stage_out_var_id && !capture_output_to_buffer && + is_vertex_like_shader() && !qual_pos_var_name.empty()) + { + if (!ep_args.empty()) + ep_args += ", "; + ep_args += join("constant uint& spvEmulatedReversedDepthViewportMask [[buffer(", + msl_options.reversed_depth_viewport_buffer_index, ")]]"); + } + if (capture_output_to_buffer) { // Add parameters to hold the indirect draw parameters and the shader output. This has to be handled @@ -15711,6 +16360,12 @@ void CompilerMSL::fix_up_shader_inputs_outputs() to_expression(builtin_dispatch_base_id), ".y;"); }); break; + case BuiltInDrawIndex: + entry_func.fixup_hooks_in.push_back([=]() { + statement(builtin_type_decl(bi_type), " ", to_expression(var_id), " = *", + to_expression(draw_index_buffer_id), ";"); + }); + break; default: break; } @@ -16258,6 +16913,30 @@ const std::unordered_set &CompilerMSL::get_reserved_keyword_set() "gradientcube", "gradient3d", "min_lod_clamp", + + // MSL type names emitted by sampler_type() and image_type_glsl(). A variable or struct + // member carrying one of these shadows the type itself, and the next declaration that + // uses the type fails to compile: + // texture2d sampler [[id(0)]]; + // sampler samplerSmplr [[id(1)]]; // error: must use 'struct' tag to refer to type + // GLSL permits a uniform named "sampler", so this is reachable from ordinary shaders. + "sampler", + "texture1d", + "texture1d_array", + "texture2d", + "texture2d_array", + "texture2d_ms", + "texture2d_ms_array", + "texture3d", + "texture_buffer", + "texturecube", + "texturecube_array", + "depth2d", + "depth2d_array", + "depth2d_ms", + "depth2d_ms_array", + "depthcube", + "depthcube_array", "assert", "VARIABLE_TRACEPOINT", "STATIC_DATA_TRACEPOINT", @@ -16725,6 +17404,36 @@ string CompilerMSL::type_to_glsl(const SPIRType &type, uint32_t id, bool member) return type_name; } + // Cooperative matrix -> Metal simdgroup matrix type + { + const SPIRType *coop_type = &type; + while (coop_type && (is_pointer(*coop_type) || is_array(*coop_type))) + coop_type = maybe_get(coop_type->parent_type); + + if (coop_type && coop_type->op == OpTypeCooperativeMatrixKHR) + { + if (!msl_options.supports_msl_version(3, 1)) + SPIRV_CROSS_THROW("Cooperative matrices require MSL 3.1 or later."); + + // Only Subgroup scoped 8x8 matrices can be expressed. + validate_cooperative_matrix_type(*coop_type); + + // Map component type to simdgroup_*8x8 + auto &comp = get(coop_type->parent_type); + switch (comp.basetype) + { + case SPIRType::Float: + return "simdgroup_float8x8"; + case SPIRType::Half: + return "simdgroup_half8x8"; + case SPIRType::BFloat16: + return "simdgroup_bfloat8x8"; + default: + SPIRV_CROSS_THROW("Unsupported component type for MSL cooperative matrix."); + } + } + } + switch (type.basetype) { case SPIRType::Struct: @@ -16808,6 +17517,11 @@ string CompilerMSL::type_to_glsl(const SPIRType &type, uint32_t id, bool member) case SPIRType::Double: type_name = "double"; // Currently unsupported break; + case SPIRType::BFloat16: + if (!msl_options.supports_msl_version(3, 1)) + SPIRV_CROSS_THROW("bfloat16 requires MSL 3.1 or later."); + type_name = "bfloat"; + break; case SPIRType::AccelerationStructure: if (msl_options.supports_msl_version(2, 4)) type_name = "raytracing::acceleration_structure"; @@ -17074,110 +17788,67 @@ string CompilerMSL::image_type_glsl(const SPIRType &type, uint32_t id, bool memb auto &img_type = type.image; - if (is_depth_image(type, id)) + switch (img_type.dim) { - switch (img_type.dim) - { - case Dim1D: - case Dim2D: - if (img_type.dim == Dim1D && !msl_options.texture_1D_as_2D) - { - // Use a native Metal 1D texture - img_type_name += "depth1d_unsupported_by_metal"; - break; - } + case DimBuffer: + if (img_type.ms || img_type.arrayed) + SPIRV_CROSS_THROW("Cannot use texel buffers with multisampling or array layers."); - if (img_type.ms && img_type.arrayed) - { - if (!msl_options.supports_msl_version(2, 1)) - SPIRV_CROSS_THROW("Multisampled array textures are supported from 2.1."); - img_type_name += "depth2d_ms_array"; - } - else if (img_type.ms) - img_type_name += "depth2d_ms"; - else if (img_type.arrayed) - img_type_name += "depth2d_array"; - else - img_type_name += "depth2d"; - break; - case Dim3D: - img_type_name += "depth3d_unsupported_by_metal"; - break; - case DimCube: - if (!msl_options.emulate_cube_array) - img_type_name += (img_type.arrayed ? "depthcube_array" : "depthcube"); - else - img_type_name += (img_type.arrayed ? "depth2d_array" : "depthcube"); - break; - default: - img_type_name += "unknown_depth_texture_type"; - break; + if (msl_options.texture_buffer_native) + { + if (!msl_options.supports_msl_version(2, 1)) + SPIRV_CROSS_THROW("Native texture_buffer type is only supported in MSL 2.1."); + img_type_name = "texture_buffer"; } - } - else + else + img_type_name += "texture2d"; + break; + case Dim1D: + case Dim2D: + case DimSubpassData: { - switch (img_type.dim) + bool subpass_array = + img_type.dim == DimSubpassData && (msl_options.multiview || msl_options.arrayed_subpass_input); + if (img_type.dim == Dim1D && !msl_options.texture_1D_as_2D) { - case DimBuffer: - if (img_type.ms || img_type.arrayed) - SPIRV_CROSS_THROW("Cannot use texel buffers with multisampling or array layers."); - - if (msl_options.texture_buffer_native) - { - if (!msl_options.supports_msl_version(2, 1)) - SPIRV_CROSS_THROW("Native texture_buffer type is only supported in MSL 2.1."); - img_type_name = "texture_buffer"; - } - else - img_type_name += "texture2d"; + // Use a native Metal 1D texture + img_type_name += (img_type.arrayed ? "texture1d_array" : "texture1d"); break; - case Dim1D: - case Dim2D: - case DimSubpassData: - { - bool subpass_array = - img_type.dim == DimSubpassData && (msl_options.multiview || msl_options.arrayed_subpass_input); - if (img_type.dim == Dim1D && !msl_options.texture_1D_as_2D) - { - // Use a native Metal 1D texture - img_type_name += (img_type.arrayed ? "texture1d_array" : "texture1d"); - break; - } + } - // Use Metal's native frame-buffer fetch API for subpass inputs. - if (type_is_msl_framebuffer_fetch(type)) - { - auto img_type_4 = get(img_type.type); - img_type_4.vecsize = 4; - return type_to_glsl(img_type_4); - } - if (img_type.ms && (img_type.arrayed || subpass_array)) - { - if (!msl_options.supports_msl_version(2, 1)) - SPIRV_CROSS_THROW("Multisampled array textures are supported from 2.1."); - img_type_name += "texture2d_ms_array"; - } - else if (img_type.ms) - img_type_name += "texture2d_ms"; - else if (img_type.arrayed || subpass_array) - img_type_name += "texture2d_array"; - else - img_type_name += "texture2d"; - break; + // Use Metal's native frame-buffer fetch API for subpass inputs. + if (type_is_msl_framebuffer_fetch(type)) + { + auto img_type_4 = get(img_type.type); + img_type_4.vecsize = 4; + return type_to_glsl(img_type_4); } - case Dim3D: - img_type_name += "texture3d"; - break; - case DimCube: - if (!msl_options.emulate_cube_array) - img_type_name += (img_type.arrayed ? "texturecube_array" : "texturecube"); - else - img_type_name += (img_type.arrayed ? "texture2d_array" : "texturecube"); - break; - default: - img_type_name += "unknown_texture_type"; - break; + if (img_type.ms && (img_type.arrayed || subpass_array)) + { + if (!msl_options.supports_msl_version(2, 1)) + SPIRV_CROSS_THROW("Multisampled array textures are supported from 2.1."); + img_type_name += "texture2d_ms_array"; } + else if (img_type.ms) + img_type_name += "texture2d_ms"; + else if (img_type.arrayed || subpass_array) + img_type_name += "texture2d_array"; + else + img_type_name += "texture2d"; + break; + } + case Dim3D: + img_type_name += "texture3d"; + break; + case DimCube: + if (!msl_options.emulate_cube_array) + img_type_name += (img_type.arrayed ? "texturecube_array" : "texturecube"); + else + img_type_name += (img_type.arrayed ? "texture2d_array" : "texturecube"); + break; + default: + img_type_name += "unknown_texture_type"; + break; } // Append the pixel type @@ -17814,8 +18485,9 @@ string CompilerMSL::builtin_to_glsl(BuiltIn builtin, StorageClass storage) { SPIRV_CROSS_THROW("BaseInstance requires Metal 1.1 and Mac or Apple A9+ hardware."); } + case BuiltInDrawIndex: - SPIRV_CROSS_THROW("DrawIndex is not supported in MSL."); + return "gl_DrawID"; // When used in the entry function, output builtins are qualified with output struct name. // Test storage class as NOT Input, as output builtins might be part of generic type. @@ -17926,8 +18598,6 @@ string CompilerMSL::builtin_qualifier(BuiltIn builtin) return "instance_id"; case BuiltInBaseInstance: return "base_instance"; - case BuiltInDrawIndex: - SPIRV_CROSS_THROW("DrawIndex is not supported in MSL."); // Vertex function out case BuiltInClipDistance: @@ -18151,7 +18821,7 @@ string CompilerMSL::builtin_type_decl(BuiltIn builtin, uint32_t id) case BuiltInBaseInstance: return "uint"; case BuiltInDrawIndex: - SPIRV_CROSS_THROW("DrawIndex is not supported in MSL."); + return "uint"; // Vertex function out case BuiltInClipDistance: @@ -18273,17 +18943,17 @@ string CompilerMSL::built_in_func_arg(BuiltIn builtin, bool prefix_comma) return bi_arg; } -const SPIRType &CompilerMSL::get_physical_member_type(const SPIRType &type, uint32_t index) const +TypeID CompilerMSL::get_physical_member_type_id(const SPIRType &type, uint32_t index) const { if (member_is_remapped_physical_type(type, index)) - return get(get_extended_member_decoration(type.self, index, SPIRVCrossDecorationPhysicalTypeID)); + return get_extended_member_decoration(type.self, index, SPIRVCrossDecorationPhysicalTypeID); else - return get(type.member_types[index]); + return type.member_types[index]; } SPIRType CompilerMSL::get_presumed_input_type(const SPIRType &ib_type, uint32_t index) const { - SPIRType type = get_physical_member_type(ib_type, index); + SPIRType type = get(get_physical_member_type_id(ib_type, index)); uint32_t loc = get_member_decoration(ib_type.self, index, DecorationLocation); uint32_t cmp = get_member_decoration(ib_type.self, index, DecorationComponent); auto p_va = inputs_by_location.find({loc, cmp}); @@ -18293,7 +18963,7 @@ SPIRType CompilerMSL::get_presumed_input_type(const SPIRType &ib_type, uint32_t return type; } -uint32_t CompilerMSL::get_declared_type_array_stride_msl(const SPIRType &type, bool is_packed, bool row_major) const +uint32_t CompilerMSL::get_declared_type_array_stride_msl(TypeID type_id, const SPIRType *special_type, bool is_packed, bool row_major) const { // Array stride in MSL is always size * array_size. sizeof(float3) == 16, // unlike GLSL and HLSL where array stride would be 16 and size 12. @@ -18302,11 +18972,42 @@ uint32_t CompilerMSL::get_declared_type_array_stride_msl(const SPIRType &type, b // far more complicated. We'd rather just create the final type, and ignore having to create the entire type // hierarchy in order to compute this value, so make a temporary type on the stack. - auto basic_type = type; - basic_type.array.clear(); - basic_type.array_size_literal.clear(); - uint32_t value_size = get_declared_type_size_msl(basic_type, is_packed, row_major); + uint32_t value_size; + + // We don't always use proper type hierarchy for synthesized types, so be robust. + if (type_id && get(type_id).parent_type) + { + bool uses_declared_array_stride = false; + + uint32_t array_stride = 0; + TypeID basic_type_id = type_id; + while (is_array(get(basic_type_id))) + { + array_stride = get_decoration(basic_type_id, DecorationArrayStride); + auto parent_type_id = get(basic_type_id).parent_type; + // If the base struct itself has ArrayStride decoration, it will be padded on-demand. + uses_declared_array_stride = has_decoration(parent_type_id, DecorationArrayStride); + if (parent_type_id) + basic_type_id = parent_type_id; + else + break; + } + if (array_stride && uses_declared_array_stride) + value_size = array_stride; + else + value_size = get_declared_type_size_msl(basic_type_id, nullptr, is_packed, row_major); + } + else + { + // Old, broken path. + auto basic_type = type_id ? get(type_id) : *special_type; + basic_type.array.clear(); + basic_type.array_size_literal.clear(); + value_size = get_declared_type_size_msl(0, &basic_type, is_packed, row_major); + } + + auto &type = type_id ? get(type_id) : *special_type; uint32_t dimensions = uint32_t(type.array.size()); assert(dimensions > 0); dimensions--; @@ -18323,47 +19024,47 @@ uint32_t CompilerMSL::get_declared_type_array_stride_msl(const SPIRType &type, b uint32_t CompilerMSL::get_declared_struct_member_array_stride_msl(const SPIRType &type, uint32_t index) const { - return get_declared_type_array_stride_msl(get_physical_member_type(type, index), + return get_declared_type_array_stride_msl(get_physical_member_type_id(type, index), nullptr, member_is_packed_physical_type(type, index), has_member_decoration(type.self, index, DecorationRowMajor)); } uint32_t CompilerMSL::get_declared_input_array_stride_msl(const SPIRType &type, uint32_t index) const { - return get_declared_type_array_stride_msl(get_presumed_input_type(type, index), false, + auto presumed_type = get_presumed_input_type(type, index); + return get_declared_type_array_stride_msl(0, &presumed_type, false, has_member_decoration(type.self, index, DecorationRowMajor)); } -uint32_t CompilerMSL::get_declared_type_matrix_stride_msl(const SPIRType &type, bool packed, bool row_major) const +uint32_t CompilerMSL::get_declared_type_matrix_stride_msl(TypeID type_id, const SPIRType *special_type, + bool packed, bool row_major) const { + auto &type = type_id ? get(type_id) : *special_type; + // For packed matrices, we just use the size of the vector type. // Otherwise, MatrixStride == alignment, which is the size of the underlying vector type. if (packed) return (type.width / 8) * ((row_major && type.columns > 1) ? type.columns : type.vecsize); else - return get_declared_type_alignment_msl(type, false, row_major); + return get_declared_type_alignment_msl(type_id, special_type, false, row_major); } uint32_t CompilerMSL::get_declared_struct_member_matrix_stride_msl(const SPIRType &type, uint32_t index) const { - return get_declared_type_matrix_stride_msl(get_physical_member_type(type, index), + return get_declared_type_matrix_stride_msl(get_physical_member_type_id(type, index), nullptr, member_is_packed_physical_type(type, index), has_member_decoration(type.self, index, DecorationRowMajor)); } uint32_t CompilerMSL::get_declared_input_matrix_stride_msl(const SPIRType &type, uint32_t index) const { - return get_declared_type_matrix_stride_msl(get_presumed_input_type(type, index), false, + auto presumed_type = get_presumed_input_type(type, index); + return get_declared_type_matrix_stride_msl(0, &presumed_type, false, has_member_decoration(type.self, index, DecorationRowMajor)); } -uint32_t CompilerMSL::get_declared_struct_size_msl(const SPIRType &struct_type, bool ignore_alignment, - bool ignore_padding) const +uint32_t CompilerMSL::get_declared_struct_size_msl(const SPIRType &struct_type) const { - // If we have a target size, that is the declared size as well. - if (!ignore_padding && has_extended_decoration(struct_type.self, SPIRVCrossDecorationPaddingTarget)) - return get_extended_decoration(struct_type.self, SPIRVCrossDecorationPaddingTarget); - if (struct_type.member_types.empty()) return 0; @@ -18372,13 +19073,10 @@ uint32_t CompilerMSL::get_declared_struct_size_msl(const SPIRType &struct_type, // In MSL, a struct's alignment is equal to the maximum alignment of any of its members. uint32_t alignment = 1; - if (!ignore_alignment) + for (uint32_t i = 0; i < mbr_cnt; i++) { - for (uint32_t i = 0; i < mbr_cnt; i++) - { - uint32_t mbr_alignment = get_declared_struct_member_alignment_msl(struct_type, i); - alignment = max(alignment, mbr_alignment); - } + uint32_t mbr_alignment = get_declared_struct_member_alignment_msl(struct_type, i); + alignment = max(alignment, mbr_alignment); } // Last member will always be matched to the final Offset decoration, but size of struct in MSL now depends @@ -18389,16 +19087,19 @@ uint32_t CompilerMSL::get_declared_struct_size_msl(const SPIRType &struct_type, return msl_size; } -uint32_t CompilerMSL::get_physical_type_stride(const SPIRType &type) const +uint32_t CompilerMSL::get_physical_type_id_stride(TypeID type_id) const { // This should only be relevant for plain types such as scalars and vectors? // If we're pointing to a struct, it will recursively pick up packed/row-major state. - return get_declared_type_size_msl(type, false, false); + return get_declared_type_size_msl(type_id, nullptr, false, false); } // Returns the byte size of a struct member. -uint32_t CompilerMSL::get_declared_type_size_msl(const SPIRType &type, bool is_packed, bool row_major) const +uint32_t CompilerMSL::get_declared_type_size_msl(TypeID type_id, const SPIRType *special_type, + bool is_packed, bool row_major) const { + auto &type = type_id ? get(type_id) : *special_type; + // Pointers take 8 bytes each // Match both pointer and array-of-pointer here. if (type.pointer && type.storage == StorageClassPhysicalStorageBuffer) @@ -18431,10 +19132,27 @@ uint32_t CompilerMSL::get_declared_type_size_msl(const SPIRType &type, bool is_p default: { - if (!type.array.empty()) + if ((!type.parent_type || special_type) && !type.array.empty()) { + // Special case where the type hierarchy is not set up properly. + // Don't want to have to allocate a bunch of dummy type IDs just to make it work. + uint32_t array_size = to_array_size_literal(type); + return get_declared_type_array_stride_msl(type_id, special_type, is_packed, row_major) * max(array_size, 1u); + } + else if (is_array(type) && type.parent_type) + { + // For the proper case. Ideally all code paths should go through here, but + // would need a lot of cleanup to make that work ... + auto &parent_type = get(type.parent_type); + uint32_t effective_stride; + + if (parent_type.op == OpTypeStruct && has_decoration(parent_type.self, DecorationArrayStride)) + effective_stride = get_decoration(type_id, DecorationArrayStride); + else + effective_stride = get_declared_type_array_stride_msl(type_id, special_type, is_packed, row_major); + uint32_t array_size = to_array_size_literal(type); - return get_declared_type_array_stride_msl(type, is_packed, row_major) * max(array_size, 1u); + return effective_stride * max(array_size, 1u); } if (type.basetype == SPIRType::Struct) @@ -18464,20 +19182,24 @@ uint32_t CompilerMSL::get_declared_type_size_msl(const SPIRType &type, bool is_p uint32_t CompilerMSL::get_declared_struct_member_size_msl(const SPIRType &type, uint32_t index) const { - return get_declared_type_size_msl(get_physical_member_type(type, index), + return get_declared_type_size_msl(get_physical_member_type_id(type, index), nullptr, member_is_packed_physical_type(type, index), has_member_decoration(type.self, index, DecorationRowMajor)); } uint32_t CompilerMSL::get_declared_input_size_msl(const SPIRType &type, uint32_t index) const { - return get_declared_type_size_msl(get_presumed_input_type(type, index), false, + auto presumed_type = get_presumed_input_type(type, index); + return get_declared_type_size_msl(0, &presumed_type, false, has_member_decoration(type.self, index, DecorationRowMajor)); } // Returns the byte alignment of a type. -uint32_t CompilerMSL::get_declared_type_alignment_msl(const SPIRType &type, bool is_packed, bool row_major) const +uint32_t CompilerMSL::get_declared_type_alignment_msl(TypeID type_id, const SPIRType *special_type, + bool is_packed, bool row_major) const { + auto &type = type_id ? get(type_id) : *special_type; + // Pointers align on multiples of 8 bytes. // Deliberately ignore array-ness here. It's not relevant for alignment. if (type.pointer && type.storage == StorageClassPhysicalStorageBuffer) @@ -18531,14 +19253,15 @@ uint32_t CompilerMSL::get_declared_type_alignment_msl(const SPIRType &type, bool uint32_t CompilerMSL::get_declared_struct_member_alignment_msl(const SPIRType &type, uint32_t index) const { - return get_declared_type_alignment_msl(get_physical_member_type(type, index), + return get_declared_type_alignment_msl(get_physical_member_type_id(type, index), nullptr, member_is_packed_physical_type(type, index), has_member_decoration(type.self, index, DecorationRowMajor)); } uint32_t CompilerMSL::get_declared_input_alignment_msl(const SPIRType &type, uint32_t index) const { - return get_declared_type_alignment_msl(get_presumed_input_type(type, index), false, + auto presumed_type = get_presumed_input_type(type, index); + return get_declared_type_alignment_msl(0, &presumed_type, false, has_member_decoration(type.self, index, DecorationRowMajor)); } @@ -18799,6 +19522,28 @@ bool CompilerMSL::OpCodePreprocessor::handle(Op opcode, const uint32_t *args, ui break; } + case OpBitcast: + case OpConvertPtrToU: + case OpConvertUToPtr: + { + if (length < 3) + break; + + auto &result_type = self.get(args[0]); + auto *arg_type = get_expression_result_type(args[2]); + if (!arg_type) + arg_type = &self.expression_type(args[2]); + + if (opcode != OpBitcast || self.is_pointer(result_type) || (arg_type && self.is_pointer(*arg_type))) + { + uint32_t id = args[1]; + set(id, "", args[0], true); + self.register_read(id, args[2], true); + self.ir.ids[id].set_allow_type_rewrite(); + } + break; + } + case OpExtInst: { uint32_t extension_set = args[2]; @@ -18860,9 +19605,43 @@ bool CompilerMSL::OpCodePreprocessor::handle(Op opcode, const uint32_t *args, ui needs_helper_invocation = true; break; + case OpCooperativeMatrixLoadKHR: + case OpCooperativeMatrixMulAddKHR: + case OpCooperativeMatrixLengthKHR: + uses_cooperative_matrix = true; + break; + + case OpCooperativeMatrixStoreKHR: + uses_cooperative_matrix = true; + check_resource_write(args[0]); + break; + + case OpCompositeExtract: + case OpVectorExtractDynamic: + { + if (length >= 3) + { + auto *type = get_expression_result_type(args[2]); + if (type && type->op == OpTypeCooperativeMatrixKHR) + uses_cooperative_matrix = true; + } + break; + } + default: + { + // Any other operation producing a cooperative matrix is emulated by the backend. + bool has_result = false, has_result_type = false; + HasResultAndType(opcode, &has_result, &has_result_type); + if (has_result_type && length >= 1) + { + auto *type = self.maybe_get(args[0]); + if (type && type->op == OpTypeCooperativeMatrixKHR) + uses_cooperative_matrix = true; + } break; } + } return true; } @@ -19279,6 +20058,7 @@ void CompilerMSL::cast_from_variable_load(uint32_t source_id, std::string &expr, case BuiltInSubgroupSize: case BuiltInSubgroupLocalInvocationId: case BuiltInViewIndex: + case BuiltInDrawIndex: case BuiltInVertexIndex: case BuiltInInstanceIndex: case BuiltInBaseInstance: diff --git a/third_party/spirv-cross/spirv_msl.hpp b/third_party/spirv-cross/spirv_msl.hpp index 033cb903bf32..913cb7404c77 100644 --- a/third_party/spirv-cross/spirv_msl.hpp +++ b/third_party/spirv-cross/spirv_msl.hpp @@ -286,7 +286,8 @@ static const uint32_t kBufferSizeBufferBinding = ~(2u); // will start at max(kArgumentBufferBinding) + 1. static const uint32_t kArgumentBufferBinding = ~(3u); -static const uint32_t kMaxArgumentBuffers = 8; +// Somewhat arbitrary. Can't be too large or it starts eating into builtin magic buffers, etc. +static const uint32_t kMaxArgumentBuffers = 16; // Decompiles SPIR-V to Metal Shading Language class CompilerMSL : public CompilerGLSL @@ -317,6 +318,9 @@ class CompilerMSL : public CompilerGLSL uint32_t shader_input_buffer_index = 22; uint32_t shader_index_buffer_index = 21; uint32_t shader_patch_input_buffer_index = 20; + uint32_t draw_id_buffer_index = 19; + uint32_t reversed_depth_viewport_buffer_index = 18; + uint32_t depth_clip_state_buffer_index = 17; uint32_t shader_input_wg_index = 0; uint32_t device_index = 0; uint32_t enable_frag_output_mask = 0xffffffff; @@ -338,6 +342,8 @@ class CompilerMSL : public CompilerGLSL bool view_index_from_device_index = false; bool dispatch_base = false; bool texture_1D_as_2D = false; + bool emulate_reversed_depth_viewport = false; + bool emulate_depth_clip_enable = false; // Enable use of Metal argument buffers. // MSL 2.0 must also be enabled. @@ -611,6 +617,14 @@ class CompilerMSL : public CompilerGLSL return !buffers_requiring_array_length.empty(); } + // Provide feedback to calling API to determine if the vertex shader writes + // to PointSize. This allows the API to avoid declaring a point size output + // when it is not needed. + bool get_writes_to_point_size() const + { + return writes_to_point_size; + } + bool buffer_requires_array_length(VariableID id) const { return buffers_requiring_array_length.count(id) != 0; @@ -623,6 +637,17 @@ class CompilerMSL : public CompilerGLSL return msl_options.multiview && !msl_options.view_index_from_device_index; } + // Provide feedback to calling API to allow it to pass depth clip + // emulation state. + bool needs_depth_clip_state_buffer() const + { + if (!msl_options.emulate_depth_clip_enable || !stage_out_var_id || capture_output_to_buffer) + return false; + + return (is_vertex_like_shader() && !qual_pos_var_name.empty()) || + (get_execution_model() == ExecutionModelFragment && !qual_frag_depth_var_name.empty()); + } + // Provide feedback to calling API to allow it to pass a buffer // containing the dispatch base workgroup ID. bool needs_dispatch_base_buffer() const @@ -886,9 +911,11 @@ class CompilerMSL : public CompilerGLSL SPVFuncImplVariableSizedDescriptor, SPVFuncImplVariableDescriptorArray, SPVFuncImplPaddedStd140, + SPVFuncImplPaddedArrayElement, SPVFuncImplReduceAdd, SPVFuncImplImageFence, SPVFuncImplTextureCast, + SPVFuncImplDepthCast, SPVFuncImplMulExtended, SPVFuncImplSetMeshOutputsEXT, SPVFuncImplAssume, @@ -921,7 +948,6 @@ class CompilerMSL : public CompilerGLSL const std::string &qualifier = ""); void emit_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index, const std::string &qualifier = "", uint32_t base_offset = 0) override; - void emit_struct_padding_target(const SPIRType &type) override; std::string type_to_glsl(const SPIRType &type, uint32_t id, bool member); std::string type_to_glsl(const SPIRType &type, uint32_t id = 0) override; void emit_block_hints(const SPIRBlock &block) override; @@ -974,7 +1000,7 @@ class CompilerMSL : public CompilerGLSL bool is_patch_block(const SPIRType &type); bool is_non_native_row_major_matrix(uint32_t id) override; - bool member_is_non_native_row_major_matrix(const SPIRType &type, uint32_t index) override; + bool member_is_non_native_row_major_matrix(const SPIRType &type, uint32_t index, bool is_layout_disabled = false) override; std::string convert_row_major_matrix(std::string exp_str, const SPIRType &exp_type, uint32_t physical_type_id, bool is_packed, bool relaxed) override; @@ -1096,15 +1122,15 @@ class CompilerMSL : public CompilerGLSL uint32_t get_physical_tess_level_array_size(BuiltIn builtin) const; - uint32_t get_physical_type_stride(const SPIRType &type) const override; + uint32_t get_physical_type_id_stride(TypeID type_id) const override; // 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. // We need to make these rules match up with SPIR-V declared rules. - uint32_t get_declared_type_size_msl(const SPIRType &type, bool packed, bool row_major) const; - uint32_t get_declared_type_array_stride_msl(const SPIRType &type, bool packed, bool row_major) const; - uint32_t get_declared_type_matrix_stride_msl(const SPIRType &type, bool packed, bool row_major) const; - uint32_t get_declared_type_alignment_msl(const SPIRType &type, bool packed, bool row_major) const; + uint32_t get_declared_type_size_msl(TypeID type_id, const SPIRType *special_type, bool packed, bool row_major) const; + uint32_t get_declared_type_array_stride_msl(TypeID type_id, const SPIRType *special_type, bool packed, bool row_major) const; + uint32_t get_declared_type_matrix_stride_msl(TypeID type_id, const SPIRType *special_type, bool packed, bool row_major) const; + uint32_t get_declared_type_alignment_msl(TypeID type_id, const SPIRType *special_type, bool packed, bool row_major) const; uint32_t get_declared_struct_member_size_msl(const SPIRType &struct_type, uint32_t index) const; uint32_t get_declared_struct_member_array_stride_msl(const SPIRType &struct_type, uint32_t index) const; @@ -1116,11 +1142,10 @@ class CompilerMSL : public CompilerGLSL uint32_t get_declared_input_matrix_stride_msl(const SPIRType &struct_type, uint32_t index) const; uint32_t get_declared_input_alignment_msl(const SPIRType &struct_type, uint32_t index) const; - const SPIRType &get_physical_member_type(const SPIRType &struct_type, uint32_t index) const; + TypeID get_physical_member_type_id(const SPIRType &struct_type, uint32_t index) const; SPIRType get_presumed_input_type(const SPIRType &struct_type, uint32_t index) const; - uint32_t get_declared_struct_size_msl(const SPIRType &struct_type, bool ignore_alignment = false, - bool ignore_padding = false) const; + uint32_t get_declared_struct_size_msl(const SPIRType &struct_type) const; std::string to_component_argument(uint32_t id); void align_struct(SPIRType &ib_type, std::unordered_set &aligned_structs); @@ -1152,6 +1177,18 @@ class CompilerMSL : public CompilerGLSL bool emit_array_copy(const char *expr, uint32_t lhs_id, uint32_t rhs_id, StorageClass lhs_storage, StorageClass rhs_storage) override; void build_implicit_builtins(); + + // Emulates element-wise operations on simdgroup matrices, which Metal does not support natively. + std::string to_cooperative_matrix_component(uint32_t id, const std::string &index); + void emit_cooperative_matrix_unary_op(uint32_t result_type, uint32_t result_id, uint32_t op0, const char *op); + void emit_cooperative_matrix_binary_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, + const char *op); + void emit_cooperative_matrix_unary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, const char *op); + void emit_cooperative_matrix_select_op(uint32_t result_type, uint32_t result_id, uint32_t cond, uint32_t op0, + uint32_t op1); + bool maybe_emit_cooperative_matrix_op(const Instruction &instruction); + void validate_cooperative_matrix_type(const SPIRType &type); + void validate_cooperative_matrix_types(); uint32_t build_constant_uint_array_pointer(); void emit_entry_point_declarations() override; bool uses_explicit_early_fragment_test(); @@ -1181,6 +1218,7 @@ class CompilerMSL : public CompilerGLSL uint32_t swizzle_buffer_id = 0; uint32_t buffer_size_buffer_id = 0; uint32_t view_mask_buffer_id = 0; + uint32_t draw_index_buffer_id = 0; uint32_t dynamic_offsets_buffer_id = 0; uint32_t uint_type_id = 0; uint32_t shared_uint_type_id = 0; @@ -1287,6 +1325,9 @@ class CompilerMSL : public CompilerGLSL bool writes_to_depth = false; bool writes_to_point_size = false; std::string qual_pos_var_name; + std::string qual_viewport_idx_var_name; + std::string qual_frag_depth_var_name; + std::string depth_clip_viewport_idx_var_name; std::string stage_in_var_name = "in"; std::string stage_out_var_name = "out"; std::string patch_stage_in_var_name = "patchIn"; @@ -1401,6 +1442,7 @@ class CompilerMSL : public CompilerGLSL bool needs_subgroup_size = false; bool needs_sample_id = false; bool needs_helper_invocation = false; + bool uses_cooperative_matrix = false; }; // OpcodeHandler that scans for uses of sampled images diff --git a/third_party/spirv-cross/spirv_parser.cpp b/third_party/spirv-cross/spirv_parser.cpp index d2e7dfa5f65a..9a185507c3c2 100644 --- a/third_party/spirv-cross/spirv_parser.cpp +++ b/third_party/spirv-cross/spirv_parser.cpp @@ -151,8 +151,29 @@ void Parser::parse() SPIRV_CROSS_THROW("Function was not terminated."); if (current_block) SPIRV_CROSS_THROW("Block was not terminated."); + + // Now that all definitions are bound to a kind, we can filter the library + // exports and populate the exported functions. + for (uint32_t id : ir.library_exports) + { + if (ir.ids[id].get_type() == TypeFunction) + ir.library_exported_functions.push_back(id); + } + if (ir.default_entry_point == 0) - SPIRV_CROSS_THROW("There is no entry point in the SPIR-V module."); + { + if (ir.library_exported_functions.empty()) + SPIRV_CROSS_THROW("There is no entry point in the SPIR-V module."); + + // No OpEntryPoint, but the module exports functions. Treat as a library + // module: designate the first exported function as the default entry + // point so analyses keyed on default_entry_point can run. + ir.is_library_module = true; + ir.default_entry_point = ir.library_exported_functions.front(); + auto &name = ir.get_name(ir.default_entry_point); + ir.entry_points.insert(std::make_pair(ir.default_entry_point, + SPIREntryPoint(ir.default_entry_point, ExecutionModelGLCompute, name))); + } } const uint32_t *Parser::stream(const Instruction &instr) const @@ -317,7 +338,7 @@ void Parser::parse(const Instruction &instruction) spirv_ext = SPIRExtension::SPV_AMD_gcn_shader; else if (ext == "NonSemantic.DebugPrintf") spirv_ext = SPIRExtension::NonSemanticDebugPrintf; - else if (ext == "NonSemantic.Shader.DebugInfo.100") + else if (ext.find("NonSemantic.Shader.DebugInfo.") == 0) spirv_ext = SPIRExtension::NonSemanticShaderDebugInfo; else if (ext.find("NonSemantic.") == 0) spirv_ext = SPIRExtension::NonSemanticGeneric; @@ -604,6 +625,19 @@ void Parser::parse(const Instruction &instruction) else ir.set_decoration(id, decoration); + // Track exported functions so we can compile library modules that have no OpEntryPoint. + // LinkageAttributes layout: literal-string (variable words) followed by LinkageType. + if (decoration == DecorationLinkageAttributes && length >= 4 && + static_cast(ops[length - 1]) == LinkageTypeExport) + { + ir.library_exports.push_back(id); + + // If OpName was stripped (e.g. by spirv-opt --strip-debug), fall back + // to the linkage name so the emitted function keeps its export name. + if (ir.get_name(id).empty()) + ir.set_name(id, extract_string(ir.spirv, instruction.offset + 2)); + } + break; } @@ -616,6 +650,7 @@ void Parser::parse(const Instruction &instruction) } case OpMemberDecorate: + case OpMemberDecorateIdEXT: { uint32_t id = ops[0]; uint32_t member = ops[1]; @@ -859,6 +894,7 @@ void Parser::parse(const Instruction &instruction) break; } + case OpTypeUntypedPointerKHR: case OpTypePointer: { uint32_t id = ops[0]; @@ -866,7 +902,7 @@ void Parser::parse(const Instruction &instruction) // Very rarely, we might receive a FunctionPrototype here. // We won't be able to compile it, but we shouldn't crash when parsing. // We should be able to reflect. - auto *base = maybe_get(ops[2]); + auto *base = op == OpTypePointer ? maybe_get(ops[2]) : nullptr; auto &ptrbase = set(id, op); if (base) @@ -885,7 +921,10 @@ void Parser::parse(const Instruction &instruction) if (base && base->forward_pointer) forward_pointer_fixups.push_back({ id, ops[2] }); - ptrbase.parent_type = ops[2]; + if (op == OpTypePointer) + ptrbase.parent_type = ops[2]; + else + ptrbase.basetype = SPIRType::Void; // Do NOT set ptrbase.self! break; @@ -1005,6 +1044,27 @@ void Parser::parse(const Instruction &instruction) break; } + case OpUntypedVariableKHR: + { + uint32_t type = ops[0]; + uint32_t id = ops[1]; + auto storage = static_cast(ops[2]); + uint32_t data_type = length >= 4 ? ops[3] : 0; + uint32_t initializer = length >= 5 ? ops[4] : 0; + + if (storage == StorageClassFunction) + { + if (!current_function) + SPIRV_CROSS_THROW("No function currently in scope"); + current_function->add_local_variable(id); + } + + auto &v = set(id, type, storage, initializer); + v.untyped = true; + v.untyped_alloca_type = data_type; + break; + } + // OpPhi // OpPhi is a fairly magical opcode. // It selects temporary variables based on which parent block we *came from*. @@ -1086,20 +1146,17 @@ void Parser::parse(const Instruction &instruction) uint32_t type = ops[0]; auto &ctype = get(type); + uint32_t elements = length - 2; // We can have constants which are structs and arrays. // In this case, our SPIRConstant will be a list of other SPIRConstant ids which we // can refer to. - if (ctype.basetype == SPIRType::Struct || !ctype.array.empty()) + if (ctype.basetype == SPIRType::Struct || !ctype.array.empty() || elements > 4) { set(id, type, ops + 2, length - 2, op == OpSpecConstantComposite); } else { - uint32_t elements = length - 2; - if (elements > 4) - SPIRV_CROSS_THROW("OpConstantComposite only supports 1, 2, 3 and 4 elements."); - SPIRConstant remapped_constant_ops[4]; const SPIRConstant *c[4]; for (uint32_t i = 0; i < elements; i++) @@ -1135,6 +1192,24 @@ void Parser::parse(const Instruction &instruction) break; } + case OpConstantSizeOfEXT: + { + uint32_t id = ops[1]; + uint32_t type = ops[0]; + auto &c = set(id, type); + c.size_of_type = ops[2]; + break; + } + + case OpTypeBufferEXT: + { + uint32_t type = ops[0]; + auto &t = set(type, OpTypeBufferEXT); + t.basetype = SPIRType::DescriptorHeapBuffer; + t.ext.descriptor_heap_buffer.storage = static_cast(ops[1]); + break; + } + // Functions case OpFunction: { diff --git a/third_party/spirv-cross/test_shaders.py b/third_party/spirv-cross/test_shaders.py index 9ac4e14a7ec2..0cde8fa2073f 100755 --- a/third_party/spirv-cross/test_shaders.py +++ b/third_party/spirv-cross/test_shaders.py @@ -379,6 +379,12 @@ def cross_compile_msl(shader, spirv, opt, iterations, paths): msl_args.append('--msl-check-discarded-frag-stores') if '.force-frag-with-side-effects-execution.' in shader: msl_args.append('--msl-force-frag-with-side-effects-execution') + if '.emulate-reversed-depth-viewport.' in shader: + msl_args.append('--msl-emulate-reversed-depth-viewport') + if '.emulate-depth-clip-enable.' in shader: + msl_args.append('--msl-emulate-depth-clip-enable') + if '.fixup-clipspace.' in shader: + msl_args.append('--fixup-clipspace') if '.lod-as-grad.' in shader: msl_args.append('--msl-sample-dref-lod-array-as-grad') if '.agx-cube-grad.' in shader: @@ -438,6 +444,8 @@ def shader_model_hlsl(shader): return '-Tps_5_1' elif '.comp' in shader: return '-Tcs_5_1' + elif '.geom' in shader: + return '-Tgs_5_1' elif '.mesh' in shader: return '-Tms_6_5' elif '.task' in shader: @@ -468,6 +476,11 @@ def validate_shader_hlsl(shader, force_no_external_validation, paths): test_glslang = False if '.task' in shader or '.mesh' in shader: test_glslang = False + if shader_is_library(shader): + # Library HLSL output has no entry point; glslangValidator's -e main + # would fail. Skip the round-trip — the output is meant to be + # included by HLSL/GLSL source rather than compiled standalone. + test_glslang = False hlsl_args = [paths.glslang, '--amb', '-e', 'main', '-D', '--target-env', 'vulkan1.1', '-V', shader] if '.sm30.' in shader: @@ -476,12 +489,16 @@ def validate_shader_hlsl(shader, force_no_external_validation, paths): if test_glslang: subprocess.check_call(hlsl_args) + # FXC cannot compile shaders above shader model 5 + shader_model = shader_model_hlsl(shader) + is_valid_fxc_shader_model = shader_model and len(shader_model) >= 3 and int(shader_model[-3]) <= 5 + is_no_fxc = '.nofxc.' in shader global ignore_fxc - if (not ignore_fxc) and (not force_no_external_validation) and (not is_no_fxc): + if (not ignore_fxc) and (not force_no_external_validation) and (not is_no_fxc) and is_valid_fxc_shader_model: try: win_path = shader_to_win_path(shader) - args = ['fxc', '-nologo', shader_model_hlsl(shader), win_path] + args = ['fxc', '-nologo', shader_model, win_path] if '.nonuniformresource.' in shader: args.append('/enable_unbounded_descriptor_tables') subprocess.check_call(args) @@ -506,6 +523,8 @@ def shader_to_sm(shader): return '60' elif '.sm68.' in shader: return '68' + elif '.sm64.' in shader: + return '64' elif '.sm51.' in shader: return '51' elif '.sm30.' in shader: @@ -520,7 +539,12 @@ def cross_compile_hlsl(shader, spirv, opt, force_no_external_validation, iterati spirv_16 = '.spv16.' in shader spirv_14 = '.spv14.' in shader - if spirv_16: + if shader_is_library(shader): + # Library modules use the Linkage capability, which is rejected + # by Vulkan target envs. Use a universal/spv target instead. + spirv_env = 'spv1.5' + glslang_env = 'spirv1.5' + elif spirv_16: spirv_env = 'spv1.6' glslang_env = 'vulkan1.3' elif spirv_14: @@ -549,7 +573,13 @@ def cross_compile_hlsl(shader, spirv, opt, force_no_external_validation, iterati sm = shader_to_sm(shader) - hlsl_args = [spirv_cross_path, '--entry', 'main', '--output', hlsl_path, spirv_path, '--hlsl-enable-compat', '--hlsl', '--shader-model', sm, '--iterations', str(iterations)] + # Library SPIR-V modules have no OpEntryPoint. Skip the --entry flag for those so spirv-cross does not try to + # select an entry point that does not exist. + is_library = shader_is_library(shader) + hlsl_args = [spirv_cross_path] + if not is_library: + hlsl_args += ['--entry', 'main'] + hlsl_args += ['--output', hlsl_path, spirv_path, '--hlsl-enable-compat', '--hlsl', '--shader-model', sm, '--iterations', str(iterations)] if '.line.' in shader: hlsl_args.append('--emit-line-directives') if '.flatten.' in shader: @@ -611,13 +641,37 @@ def validate_shader(shader, vulkan, paths): else: subprocess.check_call([paths.glslang, shader]) +def validate_library_glsl(library_path, paths): + # Library GLSL output has no #version directive and no main(), since it is meant to be #include'd by GLSL + # source. Validate it by writing a minimal wrapper translation unit alongside it that does the include via + # the GL_GOOGLE_include_directive and runs glslang on the wrapper. Note, `-V` is required because glslang + # only processes GL_GOOGLE_include_directive under Vulkan semantics. + library_dir = os.path.dirname(library_path) + library_name = os.path.basename(library_path) + fd, wrapper_path = tempfile.mkstemp(suffix = '.frag', dir = library_dir) + try: + with os.fdopen(fd, 'w') as f: + f.write('#version 450\n') + f.write('#extension GL_GOOGLE_include_directive : require\n') + f.write('#include "' + library_name + '"\n') + f.write('void main() {}\n') + subprocess.check_call([paths.glslang, '-V', wrapper_path]) + finally: + remove_file(wrapper_path) + def cross_compile(shader, vulkan, spirv, invalid_spirv, eliminate, is_legacy, force_es, flatten_ubo, sso, flatten_dim, opt, push_ubo, iterations, paths): spirv_path = create_temporary() glsl_path = create_temporary(os.path.basename(shader)) spirv_16 = '.spv16.' in shader spirv_14 = '.spv14.' in shader - if spirv_16: + is_library = shader_is_library(shader) + if is_library: + # Library modules use the Linkage capability, which is rejected by + # Vulkan target envs. Use a universal/spv target instead. + spirv_env = 'spv1.5' + glslang_env = 'spirv1.5' + elif spirv_16: spirv_env = 'spv1.6' glslang_env = 'vulkan1.3' elif spirv_14: @@ -682,21 +736,33 @@ def cross_compile(shader, vulkan, spirv, invalid_spirv, eliminate, is_legacy, fo extra_args += ['--glsl-force-flattened-io-blocks'] if '.relax-nan.' in shader: extra_args.append('--relax-nan-checks') + if '.heap-legacy-mapping.' in shader: + extra_args += ['--glsl-descriptor-heap-set-binding', '1', '2'] spirv_cross_path = paths.spirv_cross + # Library SPIR-V modules have no OpEntryPoint. skip the --entry flag for those so spirv-cross does not try to + # select an entry point that does not exist. + entry_arg = [] if is_library else ['--entry', 'main'] + # A shader might not be possible to make valid GLSL from, skip validation for this case. if (not ('nocompat' in glsl_path)) or (not vulkan): - subprocess.check_call([spirv_cross_path, '--entry', 'main', '--output', glsl_path, spirv_path] + extra_args) + subprocess.check_call([spirv_cross_path] + entry_arg + ['--output', glsl_path, spirv_path] + extra_args) if not 'nocompat' in glsl_path: - validate_shader(glsl_path, False, paths) + if is_library: + validate_library_glsl(glsl_path, paths) + else: + validate_shader(glsl_path, False, paths) else: remove_file(glsl_path) glsl_path = None if (vulkan or spirv) and (not is_legacy): - subprocess.check_call([spirv_cross_path, '--entry', 'main', '-V', '--output', vulkan_glsl_path, spirv_path] + extra_args) - validate_shader(vulkan_glsl_path, True, paths) + subprocess.check_call([spirv_cross_path] + entry_arg + ['-V', '--output', vulkan_glsl_path, spirv_path] + extra_args) + if is_library: + validate_library_glsl(vulkan_glsl_path, paths) + else: + 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: remove_file(vulkan_glsl_path) @@ -841,6 +907,12 @@ def shader_is_eliminate_dead_variables(shader): def shader_is_spirv(shader): return '.asm.' in shader +def shader_is_library(shader): + # SPIR-V library module: no OpEntryPoint, exports declared via + # OpDecorate ... LinkageAttributes ... Export. Recognised by the + # `.lib` filename suffix (e.g. foo.asm.lib). + return shader.endswith('.lib') + def shader_is_invalid_spirv(shader): return '.invalid.' in shader diff --git a/web/filament-js/package.json b/web/filament-js/package.json index 031b6e795af4..a76bc7eddc59 100644 --- a/web/filament-js/package.json +++ b/web/filament-js/package.json @@ -1,6 +1,6 @@ { "name": "filament", - "version": "1.77.0", + "version": "1.77.1", "description": "Real-time physically based rendering engine", "main": "filament.js", "module": "filament.js",