summaryrefslogtreecommitdiff
path: root/tests/diagnostics
AgeCommit message (Collapse)Author
2025-07-02Defer immutable buffer loads when emitting spirv. (#7579)Yong He
* Defer immutable buffer loads when emitting spirv. * Fix. * Fix. * Fix. * Fix tests. * Fix test.
2025-06-18Fix false negative result for CUDA with recent versions (#7409)Jay Kwak
* 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.
2025-06-17LanguageServer: Enhance auto completion for override. (#7465)Yong He
* Add additional completion keywords. * LanguageServer: Enhance auto completion for `override`.
2025-06-16Require `override` keyword for overriding default interface methods. (#7458)Yong He
* Require `override` keyword for overriding default interface methods. * Update doc. * Fix test.
2025-06-12Diagnose on use of struct inheritance. (#7419)Yong He
* Diagnose on use of struct inheritance. * fix test. * Fix tests. * fix. --------- Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com>
2025-06-12Fix intermittent debug failures with Debug build (#7369)Jay Kwak
This PR replaces enable/disable style C function calls with C++ RAII style code. In debug build, when an assertion failed in between enable and disable functions, an exception is thrown and the disable function is not called. RAII style code is safer for an exception
2025-06-05 Fix crash when loading modules with syntax errors (#6993) (#7288)Harsh Aggarwal (NVIDIA)
* Fix#6993 - Emit Diagnostic Warning and Fix SIGSEGV * Update external/slang-rhi submodule * Add checks for valid stage names for paq in SemanticsVisitor check * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-06-04Add legalization for 0-sized arrays. (#7327)Yong He
* Add legalization for 0-sized arrays. * Allow 0-sized arrays in the front-end. * More tests. * Add `Conditional<T, hasValue>` type to core module. * Update toc. * Fix wording. * Update test.
2025-06-04Disable 23 tests failing assertions (#7317)Jay Kwak
2025-05-27Add check for subscript operator return type (#7244)Mukund Keshava
Fixes #6987
2025-05-22Implement default initializer list for C-Style type member (#7079)kaizhangNV
* Implement default initializer list for C-Style type member Close #6189. Previsouly, for the C-Style member in a struct, if it doesn't have any initialize expression, when we synthesize the ctor, we will not associate the default value for the parameter corresponding to that member. This bring some trouble that existing slang users has to add '= {}' to every struct fields in order to make all the parameters in the synthesized ctor having a default value, so people can still use `Struct a = {}` to create a struct. To make this use case convenience, we will automatically associated a '= {}' as the default value for this case. This PR also add support for empty initializing link-time sized vector/matrix by "= {}". In addition, this PR also fix a bug in auto diff where we should not report error when proccessing transpose on an empty struct.
2025-05-16Support Vulkan memory model (#7057)Jay Kwak
The user can explicitly use Vulkan memory model, or it will be automatically used when cooperative-matrix is used. When vulkan memory model is used, two keywords, "Coherent" and "Volatile", are not allowed. There are many differences regarding atomic and texture but this PR has changes limited to support `globallycoherent` keyword. When variables with `globallycoherent` is used with `OpLoad`, it will use additional options, `MakePointerAvailable|NonPrivatePointer`, that will provide the same effect. For `OpStore`, it will use `MakePointerVisible|NonPrivatePointer`.
2025-05-15Add checking for hlsl register semantic. (#7118)Yong He
* Add checking for hlsl register semantic. * Fix. * Fix test. * Fix switch error. * Fix tests.
2025-05-15Rename 'main' on some backends (#7105)Mukund Keshava
* Rename 'main' on some backednds Fixes #5542 Some backends like cuda, metal, cpu do not allow 'main' as the entry point. This commit adds a new warning that is emitted when a program uses main as the entry point. In addition to emitting the warning, it internally renames the entry point to "main_". It also adds a test to check these for the three backends. * format code * move test to diagnostics * rename test to diagnostic * generate unique name --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-05-14Error out on invalid vector sizes (#7076)Darren Wihandi
* Error out on invalid vector sizes * Remove unnecessary include * Fix incorrect assert * Add test
2025-05-12Make CUDA version capabilities reach NVRTC (#7074)Theresa Foley
Fixes #7049 The root cause of the problem in #7049 is simply that newer NVRTC versions produce a warning when asked to generate code for older CUDA SM versions, and the default that Slang was requesting compilation for was old enough to trigger that warning, and thus trip up the test case (which only looks at the first diagnostic produced by the downstream compiler). Superficially, the fix was easy: change the test case in question (`tests/diagnostics/local-line.slang`) to request `-capability cuda_sm_8_0`, the minimum version supported by current NVRTC. Unfortunately, the simple fix required some other fixes in order to actually work. The capability system includes capability names of the form `cuda_sm_*_*`, but specifying such a capability had *no* impact on the CUDA SM version passed in when invoking NVRTC. Instead, only the CUDA SM versions requested in the implementation of intrinsics in the core module were affecting the version number passed down. This change adds logic to `slang-compiler.cpp` to take explicitly requested capabilities into account when inferring the CUDA SM version to be passed downstream. A more complete fix would also add similar logic for all the other targets. Unfortunately... yet again... that fix wasn't enough to make things work as expect. Now I had the problem that requesting `-capability cuda_sm_8_0` was actually causing the NVRTC invocation to request CUDA SM version **9.0**! The underlying problem *there* was that the `slang-capabilities.capdef` file has defined certain capability names in a way that implies atomic capabilities much higher than one would expect. E.g., the `cuda_sm_8_0` alias was including HLSL `sm_5_0`, but then `sm_5_0` in turn included `_cuda_sm_9_0`. The fix, for now, is to change the definitions in `slang-capabilities.capdef` to not have the counter-intuitive definitions for `cuda_sm_*_*`. With this set of fixes, the test failure in the original bug report no longer occurs. The work that went into this change suggests several larger-scope fixes that would be good to pursue: * Ideally the capability definitions would have some sort of validation checking to make sure that counter-intuitive results like `cuda_sm_8_0` requesting CUDA SM 9.0 do not occur. * The translation of capabilities over to version numbers for a downstream compiler should be expanded to cover other targets, and not just CUDA. It might be better/simpler to just pass the capabilities themselves to the downstream compiler, since it is possible that a downstream compiler could have more fine-grained enable/disable options than a simple version number. * The entire approach to computing version numbers required for downstream compilation should be cleaned up so that we don't have this duplication between the capabilities that represent those versions and separate syntactic constructs that are used to "request" those versions as part of code generation. * We are very much at the point where we should consider dropping the current behavior where a profile name or capability like `sm_5_0`, that is specific to a single target or a subset of targets, also implies a set of comparable capabilities for other targets.
2025-04-24Fix #6544: Properly format nested type names in extensions (#6769)Harsh Aggarwal (NVIDIA)
* Fix #6544: Properly format nested type names in extensions Modify DeclRefBase::toText to properly handle types defined in extensions by qualifying them with their parent type name. This ensures getFullName() returns the full name like 'FullPrecisionOptimizer<half>.State' instead of just '.State'. Also handle other nested types in structs/classes similarly. * Update extension reflection handling - with generics args and namespaces - stopping namespace inclusion for extension members - Update to use getTargetType() to handle the generic arguments - update test cases * Simplify code to remove using parentDecl
2025-04-22Implement shader subgroup rotate intrinsics (#6878)Darren Wihandi
* Initial implementation for SPIRV, GLSL and Metal * test add bool test * Fix and improve subgroup rotate tests * Add proper GLSL extensions and proper Metal type checking * Clean up tests and add diagnostics test for subgroup type for Metal * Update wave-intrinsics docs
2025-04-21Add `vk::offset` to specify member offsets for push constants (#6797)Darren Wihandi
* Add struct member offset qualifier for SPIRV * Implement for GLSL target and add tests * clean up * fix formatting * fix typo * renamed GLSLStructOffset to VkStructOffset and added emit-spirv-via-glsl test case
2025-04-14Fix matrix division by scalar for Metal and WGSL targets (#6752)Darren Wihandi
* Fix matrix division by scalar for Metal and WGSL targets * Add tests * Minor fix * Fix compilation error * Convert to multiplication for WGSL * Minor cleanup --------- Co-authored-by: Yong He <yonghe@outlook.com>
2025-04-11Add a more specific diagnostic message when passing concrete value to ↵Julius Ikkala
interface-typed output parameter (#6788) * More specific diagnostic for invalid concrete-to-interface arg coercion * Add test for the new error message * Fix typo in expected test result
2025-04-07Support for Payload Access Qualifiers (#3448) (#6595)Harsh Aggarwal (NVIDIA)
* Add support for Ray Payload Access Qualifiers (PAQs) (#3448) - Added [raypayload] attribute for struct declarations - Implemented field validation requiring read/write access qualifiers - Added diagnostic error for missing qualifiers - Enabled PAQs in DXC compiler and HLSL emission - Added new test demonstrating PAQ syntax - Implemented proper handling of ray payload attributes in IR generation * format code * Cleanup: Remove unused vars * Add check to enablePAQ only for profile >= lib_6_7 * Review Fix - Add PAQ support for DX Raytracing add enablePAQ flag to DownstreamCompileOpitons, improve PAQ handling update raypayload-attribute-paq.slang to ensure hlsl and dxil is validated * Add diagnostic test for missing paq for lib_6_7 Compile using `-disable-payload-qualifiers` aka lib_6_6 profile raypayload-attribute-no-struct.slang and raypayload-attribute.slang --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-03-21Emit errors for missing returns on unsupported targets (#6633)Darren Wihandi
* initial wip * more WIP * preserve old lower behavior * remove unnecessary includes * add test * add no target case in test * fix broken test --------- Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-03-13Add mesh shader output topology checks (#6592)Darren Wihandi
* initial wip * more wip * add test * add unexpected for invalid target * fixups and improve error message * fixups and improve error message * remove incorrect comment --------- Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-02-28Allow partial specialization of existential arguments. (#6487)Yong He
* Allow partial specialization of existential arguments. * Fix. * Add test case for improved diagnostics. * Fix compile error. * Fix tests. * Fix. * Fix test. * Fix compile issue. * Fix typo. * Address comment.
2025-02-27Make capability diagnostic message more friendly. (#6474)Yong He
* Make capability diagnostic message more friendly. * Fix. * Fix. * Fix. * Fix test. * Update expected fail setting for aarch64/linux * Fix.
2025-02-27Allow `.member` syntax on vector and scalars. (#6424)Yong He
* Allow `.member` syntax on vector and scalars. * Fix. * fix. * Fix. * update comment. * Fix tests. * Fix warning. * Add more tests.
2025-02-24Clone name hint decoration when emiting Undefined (#6415)Jay Kwak
* Clone name hint decoration when emiting Undefined When emiting "Undefined", we lost the information of where it was synthasized from. This prevents us from providing more helpful error messages. The issue was the when we handle "IRLoop", the inputs parameters to the Phi didn't clone the name hint decoration. This commit clones them when emiting "Undefined". * Adding more test case --------- Co-authored-by: Yong He <yonghe@outlook.com>
2025-02-24Legalize array size of SV_TessFactor and SV_InsideTessFactor (#6409)Jay Kwak
* Legalize array size of SV_TessFactor and SV_InsideTessFactor When targeting SPIR-V or GLSL, the type for SV_TessFactor must be float[4]; note that it is not a vector but an array. Similarly the type of SV_InsideTessFactor has to be an array of float[2]. When the user shader declare them as arrays smaller than the required size, Slang will legalize them to the required sizes. Note that it is not the user mistake to declare floar[3] when the hull mode is in "tri", as an example. The unused components are expected to be ignored. Note also that HLSL allows the type to be float[2|3|4] whereas GLSL and SPIR-V requires it to be always float[4]. * Change from "quad" domain mode to "tri" * Handle error case --------- Co-authored-by: Yong He <yonghe@outlook.com>
2025-02-19Fix zero size array handling in slangc (#6399)Mukund Keshava
* Fix zero size array handling in slangc Fixes #2890 1. Fix zero size array handling in slangc 2. Add new zero size array diagnostic test. * format code * fix review comments --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-02-18Add new zero size array test. (#6379)Mukund Keshava
Closes #2890 Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-02-13Disallow only resources in constant buffers in parameterblocks on metal (#6342)Ellie Hermaszewska
* Neaten metal parameter block checking * Disallow only resources in constant buffers in parameterblocks on metal closes https://github.com/shader-slang/slang/issues/6200 * add unit test for metal parameterblock cbuffer --------- Co-authored-by: Yong He <yonghe@outlook.com>
2025-02-12Fix crash when handling uninitialized resource type (#6338)kaizhangNV
* Fix crash when handling uninitialized resource type close #6328. When declare a var with struct type, if the struct has a resource type field and it doesn't provide explicit constructor, because slang won't implicit construct such variable at declare site if user doesn't explicitly call the initializer list, we should report the resource type field uninitialized as an error to prevent future possible crash when legalize any use of such variable.
2025-02-11Add checking for differentiability of the primal substitute function. (#6277)Sai Praveen Bangaru
Co-authored-by: Yong He <yonghe@outlook.com> Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-02-05Feature/initialize list side branch (#6058)kaizhangNV
* 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>
2025-02-04Fix warning about push constants, shaderRecordEXT (#6269)cheneym2
* Fix warning about push constants, shaderRecordEXT These resources should not warn about missing vk::binding. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-01-29Fix combined sampler documentation and warning (#6207)cheneym2
* Fix combined sampler documentation and warning * Update comment, show detailed '-fvk-t-shift' message in warning instead of generic '-fvk-xxx-shift' * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-01-24Add bgra8 format (#6163)Darren Wihandi
* add brga8 format * add tests * minor fixes * cleanup * maybe fix broken quad control test * add missing xslang flag on test --------- Co-authored-by: Yong He <yonghe@outlook.com>
2025-01-24improve error message on generic value decls (#6169)Darren Wihandi
Co-authored-by: Yong He <yonghe@outlook.com>
2025-01-23Fix incorrect resolve of specialization instance (#6162)Jay Kwak
* Fix incorrect resolve of specialization instance While checking the uninitialized variables, we were not resolving the specialized instance correctly. This commit repeats the resolve while the result is a specialization instance. A new test is added for this: tests/diagnostics/uninitialized-generic.slang After the problem is fixed, it revealed another problem in existing tests: tests/compute/nested-generics2.slang tests/diagnostics/uninitialized-local-variables.slang When a struct has a member variable whose type is a generic type, we cannot iterate over its member variables yet, because the type is unknown until the generic function/struct is specialized. We will have to give up checking for these cases.
2025-01-17Refactor _Texture to constrain on texel types. (#6115)Yong He
* Refactor _Texture to constrain on texel types. * Fix tests. * Fix. * Disable glsl texture test because rhi can't run it correctly.
2025-01-15Inline global constants that contains opaque handles for legalization. (#6098)Yong He
* Inline global constants that contains opaque handles for legalization. * Add diagnostics on opaque type global variables. * Fix. * Fix test.
2025-01-14Fix #5354, change diagnostic definition error message and expect output in ↵wij
test (#6067) Co-authored-by: Yong He <yonghe@outlook.com>
2025-01-10Fix potential test failures due to SPIRV validation failure (#6047)Jay Kwak
There are a few tests that are currently passing but could fail when conditions change little bit. When slang-test runs with `test-server`, the spirv validation fails and the test gets reported as failed even though they are actually passing. To avoid the potential problem, this commit adds an empty entry point. Co-authored-by: Yong He <yonghe@outlook.com>
2025-01-07Use disassemble API from SPIRV-Tools (#6001)Jay Kwak
* 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.
2024-12-30Check for undefined %id in spirv_asm block. (#5966)Yong He
2024-12-30Check mismatching method parameter direction against interface declaration. ↵Yong He
(#5964)
2024-12-18Check decl nesting for namespaces. (#5910)Yong He
2024-12-17Add verification logic on push and specialization constants. (#5887)Yong He
* Add verification logic on push and specialization constants. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2024-12-10Enable exprs for GLSL binding layout qualifiers (#5807)Darren
* Allow glsl set and binding layout qualifiers to be compile time integer exprs * add new tests * add comments * cleanup on asserts * addressed review comments and cleanup * fix missing set expr in test * fixed tests and cleanup --------- Co-authored-by: Yong He <yonghe@outlook.com>