Fix the invalid SPIRV decoration issue#7527
Merged
kaizhangNV merged 3 commits intoshader-slang:masterfrom Jun 26, 2025
Merged
Conversation
Contributor
|
I think this fix #7492 as well |
Contributor
|
I updated Source 2 to v2025.11 and started getting this validation error on a bunch of our shaders so this was a regression. This PR seems to fix it from my testing so far. I wonder if you should pull the release and update it with this fix? |
csyonghe
previously approved these changes
Jun 26, 2025
Close shader-slang#7508. SPIRV doesn't allow decoration on type with Private or Function storage class. In our lowering logic, if the array type is used by buffer type it will always have stride operand after lowering, so if the array is not used by buffer type, it must be used only by thread_local or group_shared variable, and it will not have stride operand. For this case, we don't need to emit stride decoration for SPIRV.
102b031 to
9bb9e4d
Compare
fairywreath
approved these changes
Jun 26, 2025
Contributor
fairywreath
left a comment
There was a problem hiding this comment.
My change here #6822 caused the regression, thanks for the fix.
Swoorup
added a commit
to Swoorup/slang
that referenced
this pull request
Jul 4, 2025
* Require `override` keyword for overriding default interface methods. (shader-slang#7458) * Require `override` keyword for overriding default interface methods. * Update doc. * Fix test. * Fix for missing signedness cast in SwizzleIR (shader-slang#7448) * Cast if there is a signedness mismatch on the swizzle * Move isSignedType to slang-util and add test --------- Co-authored-by: Yong He <yonghe@outlook.com> * AD cleanup for 'break' replacement (shader-slang#7456) close shader-slang#4187. This PR makes some cleanup on the variable name. During CFG normalization, we introduce a variable to replace the break, but the variable indicates that we should continue running the loop if it's true, and break the loop if it's false. Previously we named this variable as 'breakVar', which is opposite to its purpose. So rename it to keepRunning. * Fix slangpy not using correct slang backend (shader-slang#7334) - fix path conversion from linux to windows - add exit on fail for lib copy This ensures the slang backend built in CI is indeed the one used for tests. * Update CMake version to 3.26 (shader-slang#7459) Fixes: shader-slang#7453 * LanguageServer: Enhance auto completion for override. (shader-slang#7465) * Add additional completion keywords. * LanguageServer: Enhance auto completion for `override`. * Fix out of bound buffer access in the preprocessor. (shader-slang#7475) * Fix out of bound buffer access in the preprocessor. * Fix test regression. --------- Co-authored-by: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> * Fix false negative result for CUDA with recent versions (shader-slang#7409) * Fix false negative result for CUDA with recent versions From CUDA version 12.8 and above, nvrtc returns an exit code treated as an error. Some of slang-test test cases had to change from TEST to DIAGONOSTIC_TEST to handle it properly. * Fix additional VVL violations (shader-slang#7377) * fix: add sampleCount and mipMaps to st2DMS_f32v4 Fix VUID-VkImageCreateInfo-samples-02257: The Vulkan spec states: If an OpTypeImage has an MS operand 1, its bound image must not have been created with VkImageCreateInfo::samples as VK_SAMPLE_COUNT_1_BIT * Fix VUID-VkShaderModuleCreateInfo-pCode-08740 Rename VK_KHR_COMPUTE_SHADER_DERIVATIVES_EXTENSION_NAME to VK_NV_COMPUTE_SHADER_DERIVATIVES_EXTENSION_NAME * fix: add sampleCount and mipMaps to st2DMS_f32v4 Fix VUID-VkImageCreateInfo-samples-02257: The Vulkan spec states: If an OpTypeImage has an MS operand 1, its bound image must not have been created with VkImageCreateInfo::samples as VK_SAMPLE_COUNT_1_BIT * Fix VUID-VkShaderModuleCreateInfo-pCode-08740 Rename VK_KHR_COMPUTE_SHADER_DERIVATIVES_EXTENSION_NAME to VK_NV_COMPUTE_SHADER_DERIVATIVES_EXTENSION_NAME * Fix VUID-vkCmdDispatch-None-06479 Use correct format for combined depth texture. * Fix VUID-vkCmdDispatch-format-07753 by setting format Parse filtering mode for sampler because the RGBA8* formats do not support linear filtering * Create MS texture type for sample count > 1 * Use different texture formats for depth compare and gather ops * Use clearTexture for init the data for MS textures * Delete GFX User Guide (shader-slang#7474) Closes shader-slang#6817 This change deletes the GFX User Guide, as GFX is being deprecated. It also removes the rebuild of its TOC from the TOC rebuilding scripts and replaces the link to the guide in the README with a note that it is being deprecated in favor of slang-rhi. Co-authored-by: Gangzheng Tong <tonggangzheng@gmail.com> * Use 1-based argument index for DebugLocalVariable (shader-slang#7438) * Use 1-based argument index for DebugLocalVariable GLSLANG/DXC NSDI uses 1-based index of the argument. Slang should follow this convention like other SPIR-V generators. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Fix coopvector neg intrinsic. (shader-slang#7481) * Fix coopvector neg intrinsic. * Add test case. * Fix retry logic for unit test (shader-slang#7471) * Fix the ignored unit-tests on retry * Retrigger CI * Add more error messages * Don't use test-server for retry of unit-test to see error messages * Clean up cl.yml Remove 'has-gpu' because it is unused after debug became full-gpu-test. Renamed files to make the meaning more clear: - Renamed expected-failure.txt to expected-failure-via-glsl.txt - Renamed expected-failure-github-runner.txt to expected-failure-no-gpu.txt * Rename cpu-hello-world.slang to avoid name conflict to example We have an example whose executable name is cpu-hello-world.exe. It gets built when you run `cmake --build`, but it gets overwritten by slang-test when it tests `tests/cpu-program/cpu-hello-world.slang`. This PR renames to avoid the name conflict. * Remove debug code --------- Co-authored-by: Yong He <yonghe@outlook.com> * Add merge queue CI trigger. (shader-slang#7485) * Add support for on-demand AST deserialization (shader-slang#7482) Note that this change does not actually *enable* on-demand deserialization of ASTs, because doing so is incompatible with the current compiler architecture where we have both an `ASTBuilder` and a `SharedASTBuilder`, and there are important invariants about how all AST nodes related to the core module must be created before those of any module using the core module. Instead, this change simply adds the *infrastructure* for on-demand deserialization, and ensures that those code paths get used at runtime, but actually "demands" all of the nodes in a given serialized AST immediately as part of the deserialization process. Important notes about the implementation approach: * PR shader-slang#7242 ensured that all of the code accessing the direct member declarations of a `ContainerDecl` went through a small(-ish) set of accessor methods. This change takes advantage of that work by further abstracting the storage of the direct member declarations out in a type, `ContainerDeclDirectMemberDecls`, which makes it easy to add custom serialization logic for just that type. * The `ContainerDeclDirectMemberDecls` type also stores two pointers (one a `RefPtr` and the other a plain pointer) that are only used in the case where the members of a given `ContainerDecl` are being accessed through on-demand deserialization. This can be queried using the `isUsingOnDemandDeserialization()` method but any code accessing a `ContainerDecl` through the intended public API should never need to care about that detail. * Many of the accessor methods that were added in PR shader-slang#7242 now branch on whether `isUsingOnDemandDeserialization()` is set. The normal code path is unchanged, and the implementation logic for the on-demand-deserialization case is largely held in `slang-serialize-ast.cpp`, to keep it close to the definitions of the serialized data structures themselves. * A few types in the `slang-ast-*.h` headers have had `FIDDLE()` annotations added to them, so that they can be used to synthesize some of the serialization logic that was previously hand-written. * The `_registerBuiltinDeclsRec()` function (which is used to scan the built-in module ASTs for the various "magic" declarations that the `SharedASTBuilder` needs to know about) was factored a bit to support the way that registration needs to behave differently in the case of loading a serialized module (if we kept using the existing recursive search, then it would force every declaration in the core module to be loaded right away). The new `_collectBuiltinDeclsThatNeedRegistrationRec()` function mirrors the overall traversal pattern to produce a flat list that gets included in the serialized AST module. Note in particular that we no longer call `registerBuiltinDecls()` from within `_readBuiltinModule()`. * The interface of the `Module` type was slightly expanded so that there is a more complete API for accessing the declarations exported from the module. Previously they could only be queried by their mangled name, but the new API also allows the entire list to be iterated over. The `ensureLookupAcceleratorBuilt()` method factors out the logic for building those data structures for a module. Note that in the case where on-demand deserialization is being used for a module, the `findExportedDeclByMandledName()` query will use serialized data directly, rather than build the lookup accelerators as C++ data structures (this is required if we are to avoid immediately deserializing all of the (exported) declarations in the core module as soon as it is loaded). * A few methods related to loading serialized modules (e.g., `loadSerializedModule()`) have been updated so that along with a pointer to the serialized `ModuleChunk` (which, for those who aren't aware, is a pointer directly into the serialized bytes of the module file), they receive an `ISlangBlob` that refers to the entire blob holding the serialized data (which the `ModuleChunk` is part of). Passing this pointer down allows code running under these methods to retain a reference-counted pointer to the blob to stop the memory of the serialized module from being released until deserialization has been completed. * The data types defined in `slang-fossil.h` have been overhauled significantly: * The most important change that is relevant to this work is the introduction of the `Fossilized<T>` template, which is used to statically map a "live" C++ type `T` to its binary fossilized representation. The `slang-fossil.h` file provides infrastructure allowing `Fossilized<T>` to be specialized for user-defined types, and also provides the necessary mappings for the core types like strings, arrays, and dictionaries. * A key point is that in C++ code, one can take a value of some type `Foo`, serialize it using a `Fossil::SerialWriter`, get a pointer to that serialized data, and then directly cast it to a `Fossilized<Foo>*` and navigate the serialized data directly (without deserializing it back into a `Foo`). For that process to work, any specialization of `Fossilized<T>` must be sure to match the layout that will be produced by the `serialize()` implementation for `T`, when writing to a `Fossil::SerialWriter`. * Another key change in the public interface of `slang-fossil.h` is that dynamically-typed traversal of the data used to be handled just with `FossilizedValRef`, but now uses a few different types. The `Fossil::ValRef<T>` and `Fossil::AnyValRef` types are used to capture the use cases that want reference-like behavior (basically a `Fossil::ValRef<T>` can be thought of as sort of like a `T&`), while `Fossil::ValPtr<T>` and `Fossil::AnyValPtr` are used for cases that want pointer like behavior (akin to `T*`). * Then there are related changes in `slang-serialize-fossil.*`: * The implementation of `Fossil::SerialReader` has been changed to use `Fossil::AnyValPtr` in most places where it formerly used `FossilizedValRef`. Using pointers (that can be null) instead of a weird kind of pseudo-reference (that could still be null) to traverse things was making the code harder to follow than it ought to be, in terms of understanding the levels of indirection in various places. * Some of the state that was previously in `Fossil::SerialReader` has been split into `Fossil::ReadContext`. This type allows multiple `Fossil::SerialReader`s to be created to read from the same serialized blob(s), while maintaining a persistent mapping from fossilized data pointers to live object pointers. The `ReadContext` also maintains the work list of deferred deserialization actions waiting to be performed, and only flushes that list when the last currently-open `SerialReader` is about to go out of scope. * In order to support the split of `Fossil::SerialReader` described above (and also to clean up something that didn't quite feel right in the original serialization design) the base serialization framework in `slang-serialize.h` has been tweaked so that a `Serializer` now wraps *two* pointers instead of just one. The first pointer continues to be an implementation of `ISerializerImpl`, which handles the actual reading/writing of data, while the other pointer is an explicit "context" pointer for operations that need additional user-defined context. * Similar to the changes made to the accessors for direct member declarations in a `ContainerDecl`, the `Module::findExportedDeclByMangledName()` method was updated to conditionally execute a different code path in the case of a module that has been loaded from serialized data. * Some improvements have been made to the fiddle tool: * Most importantly, the error-handling logic around Lua script execution has been cleaned up to better match correct Lua idiom. Native functions exposed to the Lua scripts have been changed to just use `lua_call` instead of `lua_pcall`, so rather than attempt to intercept Lua errors they will just automatically propagate them. * All Lua-related errors are caught at the top level, and reported in a way that uses the source location of the fiddle template that was being evaluated when the error was raised. In most cases, a Lua error should be accompanied by a stack trace of the Lua evluation state. The file paths and line numbers given should be accurate, but aren't directly double-clickable in the Visual Studio output panel, because they use a different format (a good future change might be to process the Lua stack trace and rewrite it into a format that is better for our needs). * Fixed a subtle bug where having "raw" content (parts of the template that should neither be evaluated nor emitted into the output) that consisted of only whitespace could result in a template being translated to invalid Lua code. * The bulk of the change is, unsurprisingly, in `slang-serialize-ast.cpp`. * This file has been refactored enough to look like a complete rewrite. A lot of work has been put into comments that describe the overall approach being taken, so hopefully it can be understood even by somebody who wasn't familiar with the previous code. Some of these are just plain cleanups, rather than being directly related to on-demand serialization. * Where possible, the code for reading and writing types that needed custom serialization has been moved so that the read/write functions are next to one another, making it easier to visually confirm that the serialized representations match on the read and write sides. * Where possible, the serialization logic for all types (not just the AST nodes, as was the case before) is being generated via fiddle. * Rather than just defining `serialize()` overloads for each of the relevant types, the code now defines `Fossilized<...>` specializations for these types as well, to enable statically-typed in-memory traversal of the serialized data. Note, however, that for the most part the `Fossilized<...>` representation types are *not* being used by the code (really only the `ASTModuleInfo` and `ContainerDeclDirectMemberDeclsInfo` types are traversed directly). This can be considered more as work to prove out the design of the `Fossil<...>` template approach, and it may or may not end up being relevant in the future. * The trivial bit of work to enable on-demand deserialization is in `ASTSerialReadContext::handleContainerDeclDirectMemberDecls()` where, rather than recursively reading the contained declarations, the method effectively just grabs the current cursor of the `Fossil::SerialReader` (which is pointed into the fossilized data) and stashes it into the `ContainerDeclDirectMemberDecls`, along with a `RefPtr` to the `ASTSerialReadContext` itself. Those stashed pointers are what enables the accessors on `ContaienrDeclDirectMemberDecls` to look up information on-demand. * The more interesting bits of the approach mostly come at the end of the file, where the accessor operations for on-demand deserialization are implemented. Once all the relevant work has been done to write the data structures, and produce `Fossilized<...>` types with the right layout, the work itself may seem almost trivial: a little bit of array iteration, and a little bit of binary-search lookup. * As a reminder, all of this infrastructure for on-demand deserialization is now in place and able to be invoked by the rest of the compiler, but declarations are currently all being loaded eagerly. The `SLANG_DISABLE_ON_DEMAND_AST_DESERIALIZATION` macro is being used to enable a small bit of extra logic in `ASTSerialReadContext::_cleanUpASTNode` so that the "cleanup" on a just-deserialized `ContainerDecl` includes eagerly querying its list of direct member declarations, which will cause them to be recursively deserialized. * Update slang-rhi (shader-slang#7457) * update slang-rhi * enable all slang-rhi tests * Always emit DepthReplacing execution mode when writing to FragDepth (shader-slang#7450) * Fix cuda_fp16 header issue (shader-slang#7476) * Fix cuda_fp16 header issue This fixes the header include issue. However, it does not add a diagnostic. That will be added in a separate PR. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Fix wasm releases (shader-slang#7313) * Update ci.yml * Update ci.yml --------- Co-authored-by: Harsh Aggarwal (NVIDIA) <haaggarwal@nvidia.com> Co-authored-by: Yong He <yonghe@outlook.com> * remove sccache due to the instability (shader-slang#7484) * Enabling optix ci pipeline (shader-slang#7311) * Revert "Disable OptiX tests by default. (shader-slang#1331)" This reverts commit e45f8c1. * Enable optix submodule to build Add support for default entry points in compilation Implemented logic to check for defined entry points in the module when no explicit entry points are provided. If found, these entry points are added to the `specializedEntryPoints` list, with the assumption that no specialization is needed for them at this time. * Disable optix if cuda is not enabled * Add submodule OptixSDK path in search * Distinguish user-explicit vs auto-detected SLANG_ENABLE_OPTIX When SLANG_ENABLE_OPTIX is explicitly set by user and CUDA is not available, show SEND_ERROR to maintain strict validation. When OptiX is auto-detected (e.g., local submodule present) but CUDA unavailable, gracefully disable with STATUS message to allow builds to continue. This addresses review feedback to keep error for explicit requests while handling auto-detection gracefully. * Apply CMake formatting to SLANG_ENABLE_OPTIX validation logic * revert: slang-rhi changes as those are merged independently as in PR # slang-rhi#400 * Update spirv-tools and spirv-headers (shader-slang#7500) Update spirv-tools to commit: 108b19e5c6979f496deffad4acbe354237afa7d3 Update spirv-headers to commit: 2a611a970fdbc41ac2e3e328802aed9985352dca Update spirv-tools-generated from the spirv-tools build. * Fix a small typo in CPU target docs (shader-slang#7507) Compiler word was missing after C/C++ in CPU target documentation. Thank you in advance! * Add default implementation for determinant (shader-slang#7505) Co-authored-by: Nathan V. Morrical <natemorrical@gmail.com> * Document supported compiler versions in building.md (shader-slang#7512) * Document supported compiler versions in building.md Closes shader-slang#7376 * multiple checked versions * Fix generation of wgsl case arms (shader-slang#7374) * Fix generation of wgsl case arms * Added test case to test generation of switch case --------- Co-authored-by: Harsh Aggarwal (NVIDIA) <haaggarwal@nvidia.com> * Fix ambiguous reference for 'extern' and 'export' (shader-slang#7515) Close shader-slang#7509. When there are both `export` and `extern` decls in lookup result, we should remove all `extern` decls. * Fix Phi elimination pass sometimes leaving broken insts in release builds (shader-slang#7499) * Make phi elimination pass modify branches in-place * Add test and fix formatting * Avoid double removal of param insts * Add matrix operand for OpCooperativeVectorMatrixMulAddNV (shader-slang#7524) * Add matrix operand for OpCooperativeVectorMatrixMulAddNV * update tests to use the supported UINT32 input component type * Add MatrixCSignedComponentsKHR for coopVecMatMulAddPacked --------- Co-authored-by: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> * Set current astbuilder for reflection API (shader-slang#7488) With the test code in the issue, a crash was observed inside Slang::DeclRefBase::getParent() while accessing the astbuilder which was nullptr. This PR adds a fix for that. For the test code in the issue, we now get: ================================================ found Outer<float>::Inner: true found foo function: true function name: "foo" parameter count: 1 attempting getParameterByIndex(0): true getParameterByIndex(0) succeeded: true parameter name: "param" parameter type: "float" ================================================ Fixes shader-slang#6546 * Update spirv-tools to for SDK v2025.3 (shader-slang#7519) * Use LoadLibraryExA instead of LoadLibraryA (shader-slang#7535) Slangpy uses AddDllDirectory to specify locations of Slang DLL files. LoadLibraryA ignores this so instead use LoadLibraryExA. * Correct the scope for DebugLocalVariable (shader-slang#7516) * Correct the scope for DebugLocalVariable All of the DebugLocalVariable instructions have their scope set to DebugCompilationUnit. The scope should instead be set to a DebugFunction, or a DebugLexicalBlock which is recursively inside a DebugFunction. Register the debug info for the function instructions, which helps findDebugScope() to find the right DebugFunction scope for DebugLocalVariable. * Add a test for DebugLocalVariable To check the scope, which should be a DebugFunction. * Fix tuple AST & IR layout size queries (shader-slang#7502) * Fix tuple AST & IR layout size queries * Don't peephole sizeof if size is still indeterminate * Support `mad` in WGSL (shader-slang#7538) * Hide atomics struct from reflection api (shader-slang#7520) * Atomic reflection unit test Test that Atomic<int> is reflected as a scalar/int instead of a struct named Atomic. * Hide AtomicType from reflection Leverage the fact that returned variables go through convert() to centralize the unwrapping of the AtomicType struct. Fixes shader-slang#6257 * Clean up unit test a bit - rename bar to buf (since one of them is not Atomic and thus not a barrier) - validate deeper into the fields of bufC - remove debug code * Fix the invalid SPIRV decoration issue (shader-slang#7527) * Fix the invalid SPIRV decoration issue Close shader-slang#7508. SPIRV doesn't allow decoration on type with Private or Function storage class. In our lowering logic, if the array type is used by buffer type it will always have stride operand after lowering, so if the array is not used by buffer type, it must be used only by thread_local or group_shared variable, and it will not have stride operand. For this case, we don't need to emit stride decoration for SPIRV. * Fix for OpUConvert producing invalid opcode when to/from signs differ (shader-slang#7398) * Fix for OpUConvert outputting scalar type for mixed sign vector type conversions * Fix compiler warning * Added regression test for UConvert vector fix * Formatting * getUnsignedType helper * Formatting * Fix for addtional int types * Helper function to convert signed type to unsigned type * Update spirv-tool submodule to include the debug instruct fix (shader-slang#7541) * Update spirv-tool submodule to include the debug instruct fix Update spirv-tool to our forked repo that include the fix of spirv-val bug. It mistakenly relocates the `DebugFunctionDefinition`. The upstream PR is: KhronosGroup/SPIRV-Tools#6198 But it's still pending on review. Issue shader-slang#7491 will keep track the process, when the upstream PR is merged, we need to restore the repo back to upstream repo. * Move separate-debug-info arg to target options (shader-slang#7540) * Move separate-debug-info arg to target options The separate-debug-info command line option is listed under debugging options, move this to the target options section which includes other similar flags like -g and -emit-spirv-directly. * regenerate command line reference --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Don't call destructor, it causes UB when reading inst afterwards (shader-slang#7544) * Enable Vulkan Validation Layer in CI (shader-slang#7543) * Disable spirv-opt for the tests with debugfunction VVL errors * Enable VVL in CI * Add 2 expected failure tests until we update VVL to 1.4.319 which contains the fix * update slang-rhi * Revert "Disable spirv-opt for the tests with debugfunction VVL errors" This reverts commit 5327460. * Minimal optional constraints (shader-slang#7422) * Parse optional witness syntax * Allow failing optional constraint * Make `is` work with optional constraint * Allow using optional constraint in checked if statements * Fix tests * Make it work with structs * Fix MSVC build error * Disallow using `as` with optional constraints * Update test to match split is/as errors * Add tests * Fix uninitialized variables in tests * Add tests of incorrect uses & fix related bugs * Mention optional constraints in docs * format code * Fix type unification with NoneWitness * Fix formatting --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Nathan V. Morrical <natemorrical@gmail.com> * Support the GLSL/SPIR-V Built-in variable `DeviceIndex` (shader-slang#7552) * Support DeviceIndex * format code * regenerate command line reference --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Implement IFloat.scale for vectors, matrices (shader-slang#7545) * Test for IFloat.scale usage Test that using IFloat.scale doesn't cause an internal compiler error. * Generic implementation of IFloat.scale() Fixes shader-slang#7156 * Implement IFloat.scale for matrix Adds matrix implementation and test coverage. * Avoid explicitly constructing a matrix * Remove intrinsicOp from IFloat.scale impls Updates IFloat.scale implementations: - Remove __intrinsic_op($(kIROp_Mul)) since we're providing an implementation - Add [__unsafeForceInlineEarly] where missing * Reset minimum cmake version to 3.22 (shader-slang#7548) * Reset minimum cmake version to 3.22 * update slang-rhi * Add MLP training examples. (shader-slang#7550) * Add MLP training examples. * Formatting fix. * Fix. * Improve documentation on coopvector. * Improve doc. * Update doc. * Fix typo. * Cleanup shader. * Cleanup. * Fix test. * Fix type check recursion. * Fix. * Fix. * Fix override check. * Emit sample index when constructing a `OpImageTexelPointer` (shader-slang#7563) * fix shader-slang#7554 * format code * test ms and non ms texture --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Remove redundant [payload] attribute (Fix shader-slang#7528) (shader-slang#7555) Removes the PayloadAttribute class and related infrastructure that was made redundant by PR shader-slang#6595, which added ray payload access qualifiers (PAQs) per the DXR spec. The new [raypayload] attribute with access qualifiers provides the same functionality. Changes: - Remove PayloadAttribute class from slang-ast-modifier.h - Remove [payload] attribute syntax from core.meta.slang - Remove PayloadDecoration IR instruction and related processing - Remove HLSL emission of [payload] attribute - Remove IR lowering support for old PayloadAttribute The new [raypayload] attribute with PAQ support remains unchanged. * Allow a compiler warning on MacOS (shader-slang#7561) This PR is to allow a compiler warning even when all warnings are requested to be treated as errors. The following pattern is very common in Slang code base: if (auto var = as<...>(...)) And when `var` is not used, the compiler prints a warning. Alternatively we can remove `auto var =` part but there are too many. Co-authored-by: Jay Kwak <jkwak@jkwak-mlt.client.nvidia.com> * fix spirv-opt bug (shader-slang#7565) Close shader-slang#7491. As the PR KhronosGroup/SPIRV-Tools#6198 is already merged, we can switch spirv-tools repo to upstream repo now. * Remove some cruft/complexity from IR serialization (shader-slang#7483) * Remove some cruft/complexity from IR serialization This is a very simple cleanup to unnecessary code paths and remove some flexibility that isn't actually needed, to hopefully simplify the task of more completely overhauling the approach to IR serialization in a later change. The concrete feature that gets removed here is a debug-only feature (which thus shouldn't be affecting any users of Slang) that was added long ago in the life of the compiler as we were working to truly separate the front- and back-ends. At the time there was a lot of code in the compiler back-end that still made use of AST-level data structures, and thus got in the way of our goal to support separate compilation and linking (such that final code generation can only depend on the IR, and not the AST). The option was used to cause the Slang IR to be serialized out and then read back in as part of compilation, to try and enforce that only the wanted constructs could pass through that bottleneck. The idea was only ever half implemented, however, because it made use of a secondary implementation path in IR serialization that supported serializing the "raw" source locations (which are heavily dependent on AST-level information, even down to the number of bytes in source files). This change removes the feature entirely, since it is no longer useful for its intended purpose, and its presence causes there to be entire second code path for source locations in IR serialization that would need to have test coverage if we wanted to be sure it kept working. In addition, our pre-existing infrastructure for module serialization had various options that have either stopped being useful, or were not really useful at the time they were introduced. For example: there are no places in the code today where we attempt to serialize out a module without including both the serialized AST and IR. If that was a feature that we ever supported, the relevant code got removed at some preceding point without breaking any of our tests or (seemingly) upsetting users. Similarly, the options being passed into writing of a serialized module included both a flag to control whether source locations should be serialized *and* a pointer to the `SourceManager` to use in that case... but it was only ever meaningful to set both, or neither. The option has been changed to just be the `SourceManager` pointer, and the name has been updated to reflect its very narrow intended use case. * format code * fixup * regenerate command line reference --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com> * Add arguments for controlling floating point denormal mode (shader-slang#7461) * Implement -fp-denorm-mode slangc arg * Split fp-denorm-mode into 3 args for fp16/32/64 * Remove redundant option categories * Use emitInst for multiple of the same OpExecutionMode * Fix formatting * Remove -denorm any * Re-add option categories * emitinst for ftz * Use enums for type text * Remove extra categories again * Add tests for denorm mode * Move denorm mode to post linking * format code (#8) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * regenerate command line reference (#9) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Clean up tests * Fix option text * format code (#10) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Add tests for "any" mode * Return "any" enum if option not set * Simplify emission logic * Add support for generic entrypoints * Move denorm modes to end of CompilerOptionName enum * format code (#11) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Move new enum members to before CountOf * Add not checks to tests, fix generic test, add functionality tests * Rename denorm to fpDenormal * Clean up functional test * Rename denorm test dir * Fix formatting, regenerate cmdline ref * Fold simple tests into functional tests, add more dxil checks * Remove no-op DX tests, make tests more consistent * Disable VK functionality tests that will fail on the CI configs * Fix formatting * Add comments to disabled tests explaining why --------- Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Allow Link time constant array length sizing, warn on unsupported functionality (shader-slang#7067) * Add link time array layout test * Add link time constant array size compilation test * Link time constant array size test * Allow getting link time array size Closes shader-slang#6753 * format * Switch to SIMPLE test and check output * Implement without binary api changes * diagnose on link time constant sized array * fix test --------- Co-authored-by: Yong He <yonghe@outlook.com> * update slang-rhi (shader-slang#7494) * extend fiddle to allow custom lua splices in more places (shader-slang#7559) * Add fkYAML submodule * Generate slang-ir-inst-defs.h from slang-ir-inst-defs.yaml * generate ir-inst-defs.h * neaten things * neaten inst def parser * add rapidyaml submodule * remove fkyaml * remove fkyaml submodule * remove use of ir-inst-defs.h * format and warnings * fix wasm build * tidy * remove rapidyaml * Extend fiddle to allow custom splices in more places * Use lua to describe ir insts * fix * neaten * neaten * neaten * spelling * neaten * comment comment out assert * merge * Misc language server improvements. (shader-slang#7569) * Misc language server improvements. * Fix. * Fix decl path printing for existential lookup. * More existential decl path fix. * Polish. * Fix test. * Comment SLANG_OVERRIDE options (shader-slang#7584) Closes shader-slang#7309 * Defer immutable buffer loads when emitting spirv. (shader-slang#7579) * Defer immutable buffer loads when emitting spirv. * Fix. * Fix. * Fix. * Fix tests. * Fix test. * Add copilot environment configuration. (shader-slang#7586) * Add copilot environment configuration. * Add instructions. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Fix for emitting ArrayStride decoration for arrays of opaque types (shader-slang#7568) * WIP opaque type decoration fix * Clearer intent * Formatting * Added test for fix * Fix diagnostics not appearing when semantic tokens are disabled (shader-slang#7477) (shader-slang#7532) * Fix diagnostics not appearing when semantic tokens are disabled (shader-slang#7477) Previously, the language server only triggered module loading and compilation through semantic token requests. When semantic tokens were disabled, didOpenTextDocument and didChangeTextDocument would only update the workspace without compiling modules, meaning no diagnostics were generated. This change: - Adds module loading to didOpenTextDocument for .slang/.hlsl files - Adds module loading to didChangeTextDocument for .slang/.hlsl files - Triggers diagnostic updates via resetDiagnosticUpdateTime for Slang files - Ensures diagnostics appear immediately when opening/editing files - Maintains backward compatibility with existing LSP features Additionally fixes JSON serialization to properly handle NullResponse types by serializing them as JSON null instead of empty objects, improving LSP protocol compliance. Now diagnostics work correctly regardless of semantic token settings. * Revert: Remove unrelated change - will pick up in seprate PR * Fix module state corruption when checkAllTranslationUnits throws Add try/catch in Linkage::loadParsedModule to properly clean up module maps when checkAllTranslationUnits() fails with an exception. This prevents incorrect state in WorkspaceVersion::getOrLoadModule where failed modules remained in the loaded modules map, causing subsequent calls to return stale/invalid module references. * Update to address review comments * update: remove explicit checking for .slang and .hlsl * Don't run full gpu tests on merge queue. (shader-slang#7587) * Don't run full gpu tests on merge queue. * Fix yml. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Fix spurious vk::binding warnings when attribute is present (shader-slang#7581) * Initial plan * Fix spurious vk::binding warnings when attribute is present - Modified _maybeDiagnoseMissingVulkanLayoutModifier to check for GLSLBindingAttribute before warning - Changed function to return bool indicating if warning was actually issued - Updated call sites to properly track warning state to reduce duplicates - Tested fix resolves the issue while preserving correct warnings when needed Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Add test case for vk::binding spurious warning fix Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Update test to use filecheck format as requested Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Remove full file path from CHECK directives as requested Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix code formatting with clang-format Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix behavioral regression in vk-bindings test caused by warning flag logic Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com> * add task shader alias (shader-slang#7372) * alias amplification shader as task shader and add mesh shader profile * add task shader stage alias to capabilities * regenerate command line reference --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Run full check on merge_queue, but not on push. (shader-slang#7596) * Run full check on merge_queue, but not on push. * Fix. * Update copilot instructions. * [HLSL, SPIRV_1_3] Hoist OpSelect returning a composite into `if`/`else` (shader-slang#7594) * emit var and hoist out OpSelect if Composite * cleanup comment * address review check for version in spv context use phi node instead of using var move inst's using a list (not in-place modification) * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Fix crash when using wrong type for inout parameter with WGSL target (shader-slang#7588) * Initial plan * Fix crash in WGSL L-value cast lowering with type mismatches Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Apply formatting to fix Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Update test to verify successful compilation instead of error checking Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com> * Remove swiftshader (shader-slang#7600) * Enable tests for CUDA (shader-slang#7593) Enable intrinsic tests for cuda. Most of these tests were either disabled or just not enabled for cuda. Fixes shader-slang#7592 Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com> * Don't use access::sample for multisample texture in metal (shader-slang#7601) * don't use access::sample for multisample texture * Add test case * format code (shader-slang#7603) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --------- Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Remove a test from expected-failure-github for MacOS (shader-slang#7526) This commit removes the following test from expected-failure-github.txt because the issue is addressed on slang-rhi side. tests/compute/cbuffer-legalize.slang.2 syn (mtl) * Fix for mixed block/embedded usage of structs in SPIRV (shader-slang#7608) * Add test for mixed use of uniform/ParameterBlock Adds a test that uses the same struct as a parameter and as a ParameterBlock. * Fix for SPIRV block declaration issue Fixes shader-slang#7431 * Fix formatting * Collect struct param usage in first pass Reduces number of iterations over the entire program. * more formatting fixes * formatting * Remove unused variable * Replace SLANG_ALIGN_OF with C++11 alignof (shader-slang#7523) * Replace SLANG_ALIGN_OF with C++11 alignof * Fix formatting (again) * Language Server Enhancements (shader-slang#7604) * Language Server: auto-select the best candidate in signature help. * Fix constructor call highlighting + goto definition. * Add test. * format code * Improve ctor signature help. * Add tests. * Fix decl path printing for extension children. * Allow goto definition to show core module source. * c++ compile fix. --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Make copysign function differentiable (shader-slang#7585) * Initial plan * Implement copysign forward and backward derivatives Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix copysign test format to use expected.txt file Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Add wgsl support to copysign and fix y==0 derivative case Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Add wgsl support to copysign helper functions Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix copysign derivative to return 0 when either x or y is 0 Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --------- Co-authored-by: Yong He <yonghe@outlook.com> Co-authored-by: Jerran Schmidt <jerranschmidt@gmail.com> Co-authored-by: kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> Co-authored-by: amey asgaonkar <160177341+aasgaonkar@users.noreply.github.com> Co-authored-by: Gangzheng Tong <tonggangzheng@gmail.com> Co-authored-by: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> Co-authored-by: aidanfnv <aidanf@nvidia.com> Co-authored-by: Lujin Wang <143145775+lujinwangnv@users.noreply.github.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Theresa Foley <10618364+tangent-vector@users.noreply.github.com> Co-authored-by: Simon Kallweit <64953474+skallweitNV@users.noreply.github.com> Co-authored-by: dubiousconst282 <87553666+dubiousconst282@users.noreply.github.com> Co-authored-by: Mukund Keshava <mkeshava@nvidia.com> Co-authored-by: Elie Michel <eliemichel@users.noreply.github.com> Co-authored-by: Harsh Aggarwal (NVIDIA) <haaggarwal@nvidia.com> Co-authored-by: jarcherNV <jarcher@nvidia.com> Co-authored-by: Mehmet Oguz Derin <mehmetoguzderin@mehmetoguzderin.com> Co-authored-by: Julius Ikkala <julius.ikkala@gmail.com> Co-authored-by: Nathan V. Morrical <natemorrical@gmail.com> Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com> Co-authored-by: Swoorup Joshi <swoorupj@gmail.com> Co-authored-by: James Helferty (NVIDIA) <jhelferty@nvidia.com> Co-authored-by: Jerran Schmidt <jerrans@nvidia.com> Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Co-authored-by: Jay Kwak <jkwak@jkwak-mlt.client.nvidia.com> Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> Co-authored-by: Sirox <71220271+Sirox0@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Close #7508.
SPIRV doesn't allow decoration on type with Private or Function storage class.
In our lowering logic, since if the array type is used by buffer type it will always have stride operand after lowering. So if the array is not used by buffer type, it must be used only by thread_local or group_shared variable, and it will not have stride operand. For this case, we don't need to emit stride decoration for SPIRV.