summaryrefslogtreecommitdiffstats
path: root/tests/language-feature
Commit message (Collapse)AuthorAge
...
* Implement MapElement for CoopMat (#7159)Jay Kwak2025-05-29
| | | | | | | | | With this PR, MapElement works for the following signatures: - CoopMat<...>::MapElement(functype(...)); - CoopMat<...>::MapElement(capturing-lambda); - CoopMat<...>::MapElement(not-capturing-lambda); - Tuple<CoopMat<...>,...>::MapElement(functype(...)); - Tuple<CoopMat<...>,...>::MapElement(capturing-lambda); - Tuple<CoopMat<...>,...>::MapElement(not-capturing-lambda);
* Language version + tuple syntax. (#7230)Yong He2025-05-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Language version + tuple syntax. * Fix compile error. * regenerate documentation Table of Contents * Fix. * regenerate command line reference * Fix. * Fix. * Fix more test failures. * revert empty line change, * Retrigger CI * #version->#lang * Update source/core/slang-type-text-util.cpp Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> * Remove comments. * Fix parsing logic. * Fix parser. * Fix parser. * update test comment * Update options. * regenerate documentation Table of Contents * regenerate command line reference --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com>
* Change default descriptor binding to be VkMutable (#7224)ArielG-NV2025-05-28
| | | * change default descriptor binding to be VkMutable
* Add full support for SPV_NV_shader_subgroup_partitioned (#7103)Darren Wihandi2025-05-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Properly implement WaveMask* variants of WaveMultiPrefix* intrinsics * More partitioned intrinsics * More partitioned intrinsics and cleaned up non-prefixed WaveMask* implementations * Refactor HLSL WaveMultiPrefix* implementations * fix cap atoms * Clean up implementation * Add GLSL intrinsics and cleanup * Add tests * Fix affected capability test * Update and fix tests * Move expected.txt file * Refactor WaveMask* to call WaveMulti* * Refactor SPIRV/GLSL preamble code * Enable emit-via-glsl tests * remove wave_multi_prefix capability in favor of subgroup_partitioned * Update docs * Update cap atoms doc
* Implement throw & catch statements (#6916)Julius Ikkala2025-05-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Implement throw statement It already existed in the IR, so only parsing, checking and lowering was missing. * Initial catch implementation Likely very broken. * Error out when catch() isn't last in scope * Prevent accessing variables from scope preceding catch As those may actually not be available at that point. * Add IError and use it in Result type lowering * Add diagnostic tests * Allow caught throws in non-throw functions * Fix catch propagating between functions & SPIR-V merge issue * Add test for non-trivial error types * Fix MSVC build * Fix invalid value type from Result lowering * Also lower error handling in templates * Lower result types only after specialization * Attempt to disambiguate error enums by witness table * Revert matching by witness, types should be distinct too * Don't assert valueField when getting Result's error value It may not exist if the function returns void, but getting the error value is still legitimate. * Update tests for new error numbers & get rid of expected.txt * Change catch lowering to resemble breaking a loop ... To make SPIR-V happy. * Fix dead catch blocks and invalid cached dominator tree * More SPIR-V adjustment * Lower catch as two nested loops * Add defer interaction test and revert broken defer changes * Fix enum type when throwing literals * Cleanup and bikeshedding * Document error handling mechanism * Fix table of contents * Use boolean tag in Result<T, E> * Use anyValue storage for Result<T,E> * Remove IError * Fix formatting * Eradicate success values from docs and tests * Use parseModernParamDecl for catch parameter * Implement do-catch syntax * Implement catch-all * Fix formatting * Fix marshalling native calls that throw --------- Co-authored-by: Yong He <yonghe@outlook.com>
* Enable Windows full debug testsuite in CI (#7085)Gangzheng Tong2025-05-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Unify Debug Layer Control Logic and Add Disable Option for Debug Builds This PR refactors and unifies the debug layer control logic in slang-test. A new `-disable-debug-layers` option is introduced, allowing debug builds to skip enabling the validation (debug) layer. This is currently needed to ensure stability in the debug test suite. Previously, different toggles such as ENABLE_VALIDATION_LAYER, ENABLE_DEBUG_LAYER, and debugLayerEnabled were used inconsistently across different components of slang-test. This PR standardizes the logic by using a single variable, debugLayerEnabled, to control the enabling/disabling of the debug layer internally. Notes: By default, the debug/validation layer is enabled in debug builds and is not supported in release builds of slang-test. Fixes: #7132 * Disable spirv-opt for the DebugFunctionDefinition issue * Run debug build only in GCP machines * Fix VUID-vkCmdPipelineBarrier-pBufferMemoryBarriers-02818 dstAcessMask can't include VK_ACCESS_TRANSFER_READ_BIT when stage mask has VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR * Set failed retry limit to 32 --------- Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Fix correct bindings for bindless resource model [SPIRV and GLSL] (#7131)ArielG-NV2025-05-16
| | | | | | | | | | | | | | | | | | | | | | | | | | Fix correct bindings for bindless resource model [spirv and glsl] fixes: #6952 Problem: * Currently all bindless objects are placed in the same set (fine) and same binding (incorrect behavior for vulkan). This is incorrect since as per [spec](https://registry.khronos.org/vulkan/specs/latest/man/html/VkDescriptorType.html), only 1 resource type may be written to each index inside a set (these rules are loosened with VK_EXT_mutable_descriptor_type) * This means currently generated bindings do not work in practice if we (for example) use `Sampler2D.Handle` and `Texture1D.Handle` in a shader since we would place 2 incompatible objects in the same binding-index and set. Solution: * `__getDynamicResourceHeap` was modified to allow bindings to chosen dynamically for a descriptor * use `IOpaqueDescriptor` to check compile-time information of resource types so that we can identify different resources * Using this information of `IOpaqueDescriptor`, we modify `defaultGetDescriptorFromHandle` to provide a binding model (1 resource per binding-index) which produces legal spirv/glsl. * To support `VK_EXT_mutable_descriptor_type` the function `defaultGetDescriptorFromHandle` has a set of options (`BindlessDescriptorOptions`) for a user to pick-from to support their binding model. Capabilities are not used here for flexibility purposes (specifically old shaders mixed with modern vulkan extensions). Other changes: * Added `TexelBuffer` DescriptorKind to aid in generating correct bindings * format code * Add to docs bindless changes, make AccelerationStructure use its handle directly, adjust tests accordingly --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Enforce rule that `export`/`extern` (non cpp) must be `const` (#7113)ArielG-NV2025-05-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Enforce rule that `export`/`extern` (non cpp) must be `const` fixes: #5570 Problem: 1. we allow non-const-link-time-var to be linked to a const-link-time-var. 2. problem is that: module use site has const var, so, we emit OpStore %Ptr %Const in IR, this is expected, this is good. We fail because we in reality have a OpStore %Ptr %Var (fails since we need a OpLoad in-between) in IR since the module with our link-time-variable-value is a regular variable. 3. We loose the float_litteral talked about inside the github issue since, we technically don't use our variable "VAL" (we never OpLoad from it), so spirv-opt removes the float_litteral, this is a byproduct of the actual issue. Solution: * `export`/`extern` variables must always be `const`. This excludes `__extern_cpp` since `cpp` does not exhibit this issue and works differently. * format code * changel logic and tests to only ensure `static const` with `export`/`extern` * changing the rules: only reqirement is that if we have const we must have static * remove a spirrious change made * fix merge --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com>
* Allow lambda exprs without captures to coerce to `functype`. (#7129)Yong He2025-05-16
|
* Fix broken -emit-spirv-via-glsl test option (#7091)sricker-nvidia2025-05-16
| | | | | | | | | | | | | | | | | | | | | | | | Fixes issue #6898 The -emit-spirv-via-glsl slang-test option has been broken for some amount of time. Tests that were using it were operating as if using -emit-spirv-directly, leading to many duplicated tests. After fixing the test option, there were an number of errors that appeared as a result. This change fixes the broken test option and the resulting test errors. Some of the test errors revealed some legitimate issues, such as: -The GLSL bitCount instrinsic only supports 32-bit integers and requires emulation for other bit widths. -Emitting GLSL 8-bit and 16-bit glsl integer types did not emit the proper extension requirements -Emitting GLSL and casting for 16-bit integers was missing a closing parenthesis. -Missing profile for GL_EXT_shader_explicit_arithmetic_types -Missing toType cases for UInt8/Int8 for the kIROp_BitCast case in tryEmitInstExprImpl.
* Do not print errors in _coerce when "JustTrying". (#7064)Jay Kwak2025-05-15
| | | | | | | | | | | | | | | | | | | | * Do not print errors in _coerce when "JustTrying". While figuring out which generic-overload works best, `_coerce()` is printing errors and Slang compilation terminates prematurely. When `TryCheckGenericOverloadCandidateTypes()` is calling `_coerce()` in "JustTrying" mode, the error messages should be snoozed. The following logic shows the intention of how to silence the error messages, but the chain of `sink` was broken in the middle and `_coerce()` was using `getSink()` from the SemanticVisitor. val = ExtractGenericArgInteger( arg, getType(m_astBuilder, valParamRef), context.mode == OverloadResolveContext::Mode::JustTrying ? nullptr : getSink()); * Use tempSink when available.
* Ensure to emit 32-bit type for bitfield operations for SPIRV (#7046)kaizhangNV2025-05-12
| | | Close #7014
* Add debug information for slang inling (#6621)Mukund Keshava2025-05-10
|
* Fix various intptr_t issues by defining its width in `getIntTypeInfo` (#6786)Julius Ikkala2025-05-09
| | | | | | | | | | | | | | | | | | | | | | | | | * Define a bit size for the intptr types * Fix intptr_t sign * Extend intptr test to check for previously broken operations * Fix intptr vector test on CUDA * Handle intptr size in getAnyValueSize * Fix formatting * Try with __ARM_ARCH_ISA_64 * On macs, int64_t != intptr_t Yikes * Move define to prelude header * Also check apple in host-prelude * Fix define location
* Fixed name mangling of generic extensions (#6671)Ronan2025-05-09
| | | | | | | | | | | | | * Fixed name mangling of generic extensions * Added tests for generic extensions linking. - Disabled bugs/gh-6331.slang since it now triggers an assertion error revealed by the new version of the mangler. * Re-enabled test gh-6331 (fixed by a5efbb1b775afb2f6b29b37d39947c41744bb005) --------- Co-authored-by: Yong He <yonghe@outlook.com>
* bitcast require the input has same width with result type (#7018)kaizhangNV2025-05-06
| | | | | | | bitcast requires the input has same width with result type, this PR ensures that we always lower the bitcast IR instruction satisfies this requirement. Close #7017.
* Add `IOpaqueDescriptor::descriptorAccess`. (#6967)Yong He2025-04-30
| | | | | | | * Add `IOpaqueHandle::descriptorAccess`. * Update doc. * fix.
* Initial support for immutable lambda expressions. (#6914)Yong He2025-04-30
| | | | | | | | | | | | | * Initial support for immutable lambda expressions. * More diagnostics, and langauge server fix. * Language server fix. * Fix bug identified in review. * Add expected result. * Update expected result.
* Add subscript operator support in cuda (#6830)Mukund Keshava2025-04-30
| | | | | | | | | | | | | | | | | | | * cuda: Add support for subscript operator This CL adds support for the subscript operator for Read Only textures in cuda. Also adds a test for this. Fixes #6781 * format code * fix review comments * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
* Added getCanonicalGenericConstraints2 (sorts constraints and allows more ↵Ronan2025-04-26
| | | | generic expressions) (#6787)
* Update spirv-tools to for SDK v2025.2 (#6893)Gangzheng Tong2025-04-25
| | | | | | | | | | | | | | | | | | | | * Update spirv-tools to for SDK v2025.2 Fixes: #6850 * bump spirv version to 1.4 for op linkage * skip-spirv-validation for coop mat * add skip-spirv-validation option to slang session desc * use SPV_ENV_UNIVERSAL_1_6 for spirv-tool env target 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>
* Add defer statement (#6619)Julius Ikkala2025-04-06
|
* Fixed generic interface specialization crashes (#6601): (#6688)Ronan2025-04-03
| | | | | | | | | | | | | | | | | | | | * Fixed generic interface specialization crashes: - Add an export decoration to specialized generic interfaces. * Fixed generic interface specialization crashes: - Add an export decoration to specialized generic interfaces. - Use getTypeNameHint(...) instead of a manual mangler. * In cloneInstDecorationsAndChildren: specialize all linkage decorations, not just the exports. - If a linkage decoration is already present, it is not specialized and replaced by the specialized one. - If a specialization uses the TypeNameHint, sanitize it to be used as an identifier. - Use the identifier name sanitizer from slang-mangle. * Added tests/generics/generic-interface-linkage.slang - See #6601 and #6688
* Fix mul operator followed by global scope (#6686)Gangzheng Tong2025-03-25
| | | | | | | | | | | | | | | * Fix mul operator followed by global scope This should fix expr like `2.0f * ::a::b::c`. But it will no longer parse something like ``` extension<T> Ptr<T> { static void foo(); } int*::foo() // won't work, but this is a less common case ``` Fixes #6684 * Update simpe-namespace.slang to test global scope
* Fix reinterpret and bitcast and generic arg parsing. (#6627)Yong He2025-03-19
| | | | | | | | | | | | | * Fix reinterpret and bitcast. * Fix warning. * Fix. * Fix. --------- Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
* Migrate render-test away from deprecated compile request API (#6514)Anders Leino2025-03-12
| | | | | | | | | | | | | | | | | | * Add a simple interface parameter test Since there's no documentation, it's nice to have a simple test case in order to experiment with this feature of the testing framework. * Add shader entry point attributes to tests * Fix specialization arguments for tests - Add some missing arguments - Rremove one extraneous argument. * Stop using deprecated compile request in render-test Use a session object instead of the deprecated compile request object. This closes issue #4760.
* Fix a bug in default ctor synthesizing (#6527)kaizhangNV2025-03-06
| | | | | | | | | | | | | | | | * Fix a bug in default ctor synthesizing - This is fix for the implementation bug, when a struct has explicit ctor we should not synthesize the default ctor anymore. - When invoke the synthesized ctor converted from initializer list, we should check if the struct is a c-style type if it struct has no synthesized ctor. In this case we should report error because it's invalid to use initializer list here. - The only exception is the unsized array, we still have to fall back to use the legacy initializer list logic to initialize the unsized array until we formalize a proper solution. - update test.
* Make capability diagnostic message more friendly. (#6474)Yong He2025-02-27
| | | | | | | | | | | | | | | * Make capability diagnostic message more friendly. * Fix. * Fix. * Fix. * Fix test. * Update expected fail setting for aarch64/linux * Fix.
* Fix overload resolution for `ModuleDeclarationDecl` (#6483)Sai Praveen Bangaru2025-02-27
| | | | | | | | | * Fix overload resolution for `MemberExp`r's base expression Also fixed an issue where `ModuleDeclarationDecl` priority during overload resolution was inverted. * Made the fix slightly simpler.. * Update overload-resolve.slang
* Improve performance when compiling small shaders. (#6396)Yong He2025-02-23
| | | | | | | Improve performance when compiling small shaders. Avoid copying witness table entries that are not getting used during linking. Avoid copying auto-diff related decorations and derivative functions during linking, if the user modules doesn't use autodiff. Cache operator overload resolution results on global session, so each new Session doesn't need to repetitively run through overload resolution from scratch.
* Support stage_switch. (#6311)Yong He2025-02-06
| | | | | | | | | * Support stage_switch. * Update proposal status. * Fix gl_InstanceID. * Fix.
* Feature/initialize list side branch (#6058)kaizhangNV2025-02-05
| | | | | | | | | | | | | | | | | | | | | | * SP004: implement initialize list translation to ctor - We synthesize a member-wise constructor for each struct follow the rules described in SP004. - Add logic to translate the initialize list to constructor invoke - Add cuda-host decoration for the synthesized constructor - Remove the default constructor when we have a valid member init constructor - Disable -zero-initialize option, will re-implement it in followup (#6109). - Fix the overload lookup issue When creating invoke expression for ctor, we need to call ResolveInvoke() to find us the best candidates, however the existing lookup logic could find us the base constructor for child struct, we should eliminate this case by providing the LookupOptions::IgnoreInheritance to lookup, this requires us to create a subcontext on SemanticsVisitor to indicate that we only want to use this option on looking the constructor. - Do not implicit initialize a struct that doesn't have explicit default constructor. Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Fix the type coerce issue (#6215)kaizhangNV2025-01-29
| | | | | | | | * Fix the type coerce issue When synthesize the default ctor, if there is a base type we will synthesize an InvokeExpr to call base type's default ctor as well. But we should use the type of the inheritanceDecl instead of base struct decl.
* Implement WaveMultiPrefix* for SPIRV and GLSL (#6182)Darren Wihandi2025-01-29
|
* Fix exact-match witness synthesis for static functions (#6204)Darren Wihandi2025-01-29
| | | | | | | | | | | | | * fix non-static methods when trying to synthesize method requirement witness * add tests * update test * improve test --------- Co-authored-by: Yong He <yonghe@outlook.com>
* Fix UIntSet calcSubtract to handle mismatched buffer sizes (#6205)Darren Wihandi2025-01-28
| | | | | | | | | * fix calcSubtract on UIntSet * add test --------- Co-authored-by: Yong He <yonghe@outlook.com>
* Allow requiring glsl language extensions on structs (#6173)Ellie Hermaszewska2025-01-28
| | | | | | | | | | * Allow requiring glsl language extensions on structs * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com>
* Fix circularity issue when checking multiple generic interface constraints. ↵Sai Praveen Bangaru2025-01-17
| | | | | | | | | | | | | | | (#6121) * Fix circularity issue with checking multiple generic interface constraints * Create multi-generic-interface-constraint.slang * Update multi-generic-interface-constraint.slang * Update slang-check-inheritance.cpp --------- Co-authored-by: Yong He <yonghe@outlook.com>
* Add diagnostic for function body followed by a `;`;. (#6122)Yong He2025-01-17
|
* Allow __subscript<T> syntax. (#6124)Yong He2025-01-17
| | | | | * Allow __subscript<T> syntax. * Fix.
* Refactor _Texture to constrain on texel types. (#6115)Yong He2025-01-17
| | | | | | | | | * Refactor _Texture to constrain on texel types. * Fix tests. * Fix. * Disable glsl texture test because rhi can't run it correctly.
* Fix prebound parameter pack - argument list matching logic. (#6111)Yong He2025-01-17
| | | | | | | * Fix prebound parameter pack - argument list matching logic. * Move tests. * Fix.
* Fix cyclic lookups with UnscopedEnums (#6110)Julius Ikkala2025-01-17
| | | | | | | | | * Fix cyclic lookups with UnscopedEnums * Add test with multiple unscoped enums with explicit types --------- Co-authored-by: Yong He <yonghe@outlook.com>
* Initial implementation of SP#015 `DescriptorHandle<T>`. (#6028)Yong He2025-01-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Initial implementation of `ResourcePtr<T>`. * Update docs * Fix build error. * Add more discussion. * Update documentation. * Update TOC. * Fix. * Fix. * Add test case for custom `getResourceFromBindlessHandle`. * Add namehint to generated descriptor heap param. * Fix. * Fix. * format code * Rename to `DescriptorHandle`, and add `T.Handle` alias. * Fix compiler error. * Fix. * Fix build. * Renames. * Fix documentation. * Documentation fix. --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Use disassemble API from SPIRV-Tools (#6001)Jay Kwak2025-01-07
| | | | | | | | | | | | | | | | | | | | | | | | | | * Use disassemble API from SPIRV-Tools This commit uses C API version of SPIRV disassemble function rather than calling spirv-dis.exe. This allows us to use a correct version of SPIRV disassble function that Slangc.exe is using. The implementation is mostly copied from external/spirv-tools/tools/dis/dis.cpp, which is a source file for building spirv-dis.exe. This commit also includes a fix for a bug in RPC communication to `test-server`. When an RPC connection to `test-server.exe` is reused and the second test abruptly fails due to a compile error or SPIRV validation error, the output from the first test run was incorrectly reused as the output for the second test. This commit resets the RPC result before waiting for the response so that even when the RPC connection is erratically disconnected, the result from the previous run will not be reused incorrectly. Some of the tests appear to be relying on this type of behavior. By using an option, `-skip-spirv-validation`, the RPC connection will continue without an interruption.
* Fix `getInheritanceInfo` for `ExtractExistentialType`. (#5971)Yong He2024-12-31
|
* Check mismatching method parameter direction against interface declaration. ↵Yong He2024-12-30
| | | | (#5964)
* Fix requirement candidate lookup to prefer decls in the same paraent as the ↵Yong He2024-12-30
| | | | inheritance decl. (#5965)
* Bit extract (#5847)kaizhangNV2024-12-12
| | | | | | | | | | | | * promoting bitfield extraction and insertion to become intrinsics for internal compiler use * removing duplicate intrinsics from glsl.meta.slang * refactor: update function signatures of bitfield extraction and insertion to use uint as the parameter type for offset and bits. --------- Co-authored-by: Nate Morrical <natemorrical@gmail.com> Co-authored-by: Yong He <yonghe@outlook.com>
* WGSL: Fix issue where global calls are generated (#5768)Anders Leino2024-12-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Split out SPIR-V -specific legalization of global functions This is a refactoring and should not affect generated code. * Move global inst inlining code into separate function This is a refactoring and should not affect generated code. * Take SPIR-V -specific parts out of GlobalInstInliningContext This is a refactoring and should not affect generated code. * Move 'inlineGlobalValues' to generic inlining context This is a refactoring and should not affect generated code. * Move 'setInsertBeforeOutsideASM' to generic inlining context This is a refactoring and should not affect generated code. * Move generic inlining context into own file This is a refactoring and should not affect generated code. * Run global inlining for WGSL as well * Make the 'getOutsideASM' function generic as well * Enable language-feature/constants/static-const-in-generic-interface.slang for WebGPU * Clarify when it's safe to remove and deallocate an IRInst * Remove globals if they're left unused after inlining This closes #5607. * Handle IRGlobalValueRef in C-like emitter * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>