summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAge
...
* Allow Link time constant array length sizing, warn on unsupported ↵Ellie Hermaszewska2025-07-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | functionality (#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 https://github.com/shader-slang/slang/issues/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>
* Add arguments for controlling floating point denormal mode (#7461)aidanfnv2025-07-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Emit sample index when constructing a `OpImageTexelPointer` (#7563)ArielG-NV2025-06-30
| | | | | | | | | | | * fix #7554 * format code * test ms and non ms texture --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Add MLP training examples. (#7550)Yong He2025-06-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Implement IFloat.scale for vectors, matrices (#7545)James Helferty (NVIDIA)2025-06-30
| | | | | | | | | | | | | | | | | | | | | | | * Test for IFloat.scale usage Test that using IFloat.scale doesn't cause an internal compiler error. * Generic implementation of IFloat.scale() Fixes #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
* Support the GLSL/SPIR-V Built-in variable `DeviceIndex` (#7552)ArielG-NV2025-06-29
| | | | | | | | | | | * Support DeviceIndex * format code * regenerate command line reference --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Minimal optional constraints (#7422)Julius Ikkala2025-06-28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Enable Vulkan Validation Layer in CI (#7543)Gangzheng Tong2025-06-27
| | | | | | | | | | | | | * 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 5327460057f533af81ea60a556e43abe805d5816.
* Fix tuple AST & IR layout size queries (#7502)Julius Ikkala2025-06-26
| | | | | * Fix tuple AST & IR layout size queries * Don't peephole sizeof if size is still indeterminate
* Fix for OpUConvert producing invalid opcode when to/from signs differ (#7398)Jerran Schmidt2025-06-26
| | | | | | | | | | | | | | | | | * 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
* Fix the invalid SPIRV decoration issue (#7527)kaizhangNV2025-06-26
| | | | | | | | | | | | | | * Fix the invalid SPIRV decoration issue Close #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.
* Correct the scope for DebugLocalVariable (#7516)Lujin Wang2025-06-26
| | | | | | | | | | | | | | | | * 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.
* Add matrix operand for OpCooperativeVectorMatrixMulAddNV (#7524)Gangzheng Tong2025-06-26
| | | | | | | | | | | * 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>
* Fix Phi elimination pass sometimes leaving broken insts in release builds ↵Julius Ikkala2025-06-25
| | | | | | | | | (#7499) * Make phi elimination pass modify branches in-place * Add test and fix formatting * Avoid double removal of param insts
* Fix ambiguous reference for 'extern' and 'export' (#7515)kaizhangNV2025-06-25
| | | | | | Close #7509. When there are both `export` and `extern` decls in lookup result, we should remove all `extern` decls.
* Fix generation of wgsl case arms (#7374)Swoorup Joshi2025-06-25
| | | | | | | | | * Fix generation of wgsl case arms * Added test case to test generation of switch case --------- Co-authored-by: Harsh Aggarwal (NVIDIA) <haaggarwal@nvidia.com>
* Always emit DepthReplacing execution mode when writing to FragDepth (#7450)dubiousconst2822025-06-19
|
* Fix retry logic for unit test (#7471)Jay Kwak2025-06-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Fix coopvector neg intrinsic. (#7481)Yong He2025-06-18
| | | | | * Fix coopvector neg intrinsic. * Add test case.
* Fix additional VVL violations (#7377)Gangzheng Tong2025-06-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* Fix false negative result for CUDA with recent versions (#7409)Jay Kwak2025-06-18
| | | | | | | * 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.
* LanguageServer: Enhance auto completion for override. (#7465)Yong He2025-06-17
| | | | | * Add additional completion keywords. * LanguageServer: Enhance auto completion for `override`.
* Fix for missing signedness cast in SwizzleIR (#7448)Jerran Schmidt2025-06-16
| | | | | | | | | * 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>
* Require `override` keyword for overriding default interface methods. (#7458)Yong He2025-06-16
| | | | | | | * Require `override` keyword for overriding default interface methods. * Update doc. * Fix test.
* Skip processing import declarations after errors (#7393)James Helferty (NVIDIA)2025-06-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add test case for missing import attribution Add a test case that imports a non-existent file, followed by a valid file. Tests for absence of a bug where slang reports existent files as non-existent if they're imported after a non-existent file. * Skip processing imports after errors Skip processing additional imports after the first error. This behavior is already observed in Linkage::loadSourceModuleImpl, but since that happenes after import processing already started, a false diagnostic gets generated for a missing import. By hoisting this check out before the import is processed, the diagnostic message for a missing file is no longer erroneously generated. Fixes #6453 * Revert "Skip processing imports after errors" This reverts commit 6b2fef09782414de4c5e017c4ecb5f2affa0c199. * Remove early abort of import processing Partial revert of commit 04f1bad Reverts an early return in Linkage::loadSourceModuleImpl() whenever any error diagnostic message has already been generated. This was causing earlier errors to prevent subsequent imports from succeeding, and was misattributing them to a missing file. Fixes #6453 --------- Co-authored-by: Yong He <yonghe@outlook.com>
* Allow interface methods to have default implementations. (#7439)Yong He2025-06-13
|
* Fix a bug in empty array legalization. (#7444)Yong He2025-06-13
|
* Fix issue that struct with member is not its Differential type (#7434)kaizhangNV2025-06-13
| | | | | | Close #6176. If the struct has a `no_diff` member, it should not be its Differential type. We miss this check.
* Add new capdef for lss intrinsics (#7427)Mukund Keshava2025-06-13
| | | | | | | | | | | | | | * Add new capdef for lss intrinsics Fixes #7426 Raygen shaders need to be supported for only hitobject APIs. So we need a special capability for that, instead of a common one. * regenerate command line reference --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Fix issue of missing scope for 'Differential' type (#7433)kaizhangNV2025-06-12
| | | | | | | | | | | | | | * Fix issue of missing scope for 'Differential' type When we synthesize the struct decl for Differential type, we should add the ownedScope for this decl, because the scope is used in lots of locations in the following synthesized processes, e.g. constructor synthesize. And that could cause surprising behavior, e.g. the 'this' expression could access the members of parent struct decl. Fix the issue by adding the scope. The containerDecl will be the Differential struct decl itself, parent scope will be the parent struct. * Add a unit-test
* Fix argument to float3 cbuffer tests (#7391)James Helferty (NVIDIA)2025-06-12
| | | | | | | | Results of these tests had been marked ignored, because they failed on VK with the GLSL backend. This change removes them from the expected-failure.txt file and adds the correct command line option to avoid using the GLSL target. Addresses concern raised on #7282
* Diagnose on use of struct inheritance. (#7419)Yong He2025-06-12
| | | | | | | | | | | | | * Diagnose on use of struct inheritance. * fix test. * Fix tests. * fix. --------- Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com>
* Fix intermittent debug failures with Debug build (#7369)Jay Kwak2025-06-12
| | | | | 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
* Fix an issue in extension override. (#7402)Yong He2025-06-11
| | | | | * Fix an issue in extension override. * Fix typo in comment.
* Fix reflection to json issue (#7379)kaizhangNV2025-06-10
| | | | | Apply argument buffer tier2 rule when using parameter block for Metal target. Close #6803.
* Allow checking capabilities in specific stages (#7375)jarcherNV2025-06-10
| | | | | | | This allows checking capabilities in any stage, needed specifically for the hlsl_2018 capability which is defined for sm_5_1 and above. Stage specific capabilities such as cs_5_1 would not find this in any stage other than compute, so we need to restrict the check to only desired stages.
* Fix IR layout of 3-element vectors in cbuffers for -fvk-use-dx-layout (#7282)James Helferty (NVIDIA)2025-06-10
| | | | | | | | | | | | | | | | | | | * Better handling for 16-byte boundary of d3d cbuffer Fixes #6921 D3D cbuffers have slightly different packing rules that allow packing vectors into a 16-byte slot at element alignments, except when a field would cross a 16-byte boundary. In that case, we need to realign the field to the next 16-byte boundary. In particular, this impacts vec3s, which are not a power of two in size and thus require slightly different alignment logic, compared to std430 and std140. (Example: a float and float3 should fit together in that order in a single slot.) Adds test cases. Adds documentation page for GLSL target
* Legalise out parameters for vertex shaders on metal (#6943)Ellie Hermaszewska2025-06-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Handle pointer types when getting type cast style Closes https://github.com/shader-slang/slang/issues/6025 * Move vertex shader out parameters to return type for Metal Closes https://github.com/shader-slang/slang/issues/6025 * More asserts * Make struct instead of tuple * More layout preservation * Handle same function result * more layout * remove layout * a * more debug code * more debug code * a * layout working * refactored * more tests * more tests * fuse loops * remove unused comments * Correct filecheck usage * debug code * correct name and order of filecheck vars * simplify * Address review comments fix warning * simplify handling of simple vertex shaders
* Add optix support for coopvec (#7286)Mukund Keshava2025-06-10
| | | | | | | | | | | | | * WiP: Add coopvec support for Optix * format code * fix minor issues * Fix review comments --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Fix interface types as RHS of is/as operators (#7234)Jay Kwak2025-06-08
| | | | | Added error checking to reject interface types as the right-hand side of is and as operators. Enhanced semantic analysis with new diagnostic 30301 and comprehensive test coverage.
* Add command line option for separate debug info (#7178)jarcherNV2025-06-06
| | | | | | | | | | | | | * Add command line option for separate debug info Add command line arg -separate-debug-info which, if provided, produces both a .spv and a .dbg.spv file. The .dbg.spv file contains full debug info and the .spv file has all debug info stripped out. Also add a DebugBuildIdentifier instruction to store a unique hash in both the output files, so they can be more easily matched together. A matching API is provided to allow using the Slang API to retrieve a base and debug SPIRV as well as the debug build identifier string.
* Address issues with GLSL style global in/out vars (#6669) (#6998)sricker-nvidia2025-06-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Address issues with GLSL style global in/out vars (#6669) Asserts and segfaults were observed trying to compile a simple vertex shader like: ```` in int2 inPos; [shader("vertex")] main(uniform int2 test1, int2 test2, out float4 pos: SV_Position) void main() { // Bogus use of all input vars to prevent optimizing out. pos = float4(inPos.x, test1.x, test2.y, 0); } ```` Further investigation found that while replacing "uniform int2 test1" with "int2 test1" allowed for successful compilation, the resulting output shader would have overlapping location qualifiers. For example, compiling the above with "int2 test1" to glsl might give: ```` ... layout(location = 0) in ivec2 test1_0; layout(location = 1) in ivec2 test2_0; layout(location = 0) in ivec2 translatedGlobalParams_inPos_0; ... ```` This was because Slang does not actually support mixing GLSL style global in/out vars and entry point params. However, this is never checked for or noted in documentation. Slang source also assumes input shaders do not mix these and these assumptions ultimately led to the observed asserts and seg faults when using uniform entry point params. This change makes updates to throw an error when the compiler detects that it is trying to translate global in/out variables into entry point params when an entry point already contains parameters, allowing for compilation to fail gracefully. Certain tests have been updated to avoid mixing GLSL style global in/out vars and entry point params. This was mostly for tests that were using functions like WaveGetLaneIndex which use global in vars for certain platforms (see __builtinWaveLaneIndex). * Address issues with GLSL style global in/out vars - updates 1 (#6669) Update addresses review feedback to support mixing GLSL-flavored global in/out vars and entrypoint parameters when either all global in/out vars or all entry point params have a system value binding semantic. * Address issues with GLSL style global in/out vars - updates 2 (#6669) This update attempts to actually allow mixing GLSL style global in vars and entry point vars. Change attempts to recalculate offsets when adding the global input vars into the recreated entry point params layout. Additional updates were made to: -resolve further issues uncovered with entry point uniform params. -Address improper use of SV_DispatchThreadID in wave-get-lane-index.slang for metal. "thread_position_in_grid" is not supported for signed integer scalars or vectors. -Fix a spirv casting conflict due to the implementation of gl_PrimitiveID.get conflicting with PrimitiveIndex(). -Add a call to remove a global var in replaceUsesOfGlobalVar(). The global var is already replaced in this function and keeping it around can prevent it from being cleaned up by DCE if it still has decorations. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Disable coopvec while using Agility SDK and until graphics driver supports ↵Jay Kwak2025-06-06
| | | | | | | it (#7357) * Disable coopvec tests until we have the driver support * Remove conflicting agility sdk binaries
* Check the supported backends in CI (#7346)Jay Kwak2025-06-05
| | | | | slang-test is ran with a simple test, tests/render/check-backend-support-on-ci.slang. And the github CI,yaml will check if certain keywords are found. This is to prevent the regression on the CI server where a set of backend was supported at some point and it stopped supporting it siliently.
* Implement isnan and isinf for WGSL with bitwise operations (#7344)Jay Kwak2025-06-05
| | | | | | | | WGSL doesn't support isnan and isinf, because it assumes that it always uses fast-math and fast-math doesnt' handle NaN as defined in IEEE standard. The initial implementation used a clever workaround but it stopped working from some point. This PR implemented isnan and isinf with a bitwise operation, which can be expensive. But that seems to be an only option at the moment.
* Fix crash when loading modules with syntax errors (#6993) (#7288)Harsh Aggarwal (NVIDIA)2025-06-05
| | | | | | | | | | | | | | * 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>
* Add legalization for 0-sized arrays. (#7327)Yong He2025-06-04
| | | | | | | | | | | | | | | * 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.
* Make interface types non c-style in Slang2026. (#7260)Yong He2025-06-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Make interface types non c-style. * Make Optional<T> work with autodiff and existential types. * Fix. * patch behind slang 2026. * Fix warnings. * cleanup. * Fix tests. * Fix. * Fix com interface lowering. * Add comment to test. * regenerate command line reference * Add test for passing `none` to autodiff function. * Fix recording of `getDynamicObjectRTTIBytes`. * Fix nested Optional types. --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Break down record replay to individual tests to avoid timeout (#7340)Jay Kwak2025-06-04
| | | | | | | | | | | | | | | | * Break down RecordReply to individual tests to avoid timeout In Debug build, RecordReplay unit-test was timing out. It was running six tests all in one unit-test, but this commit breaks it down to individual test so that each unit test can be done within the timeout limit. This issue has seen only in Debug build but it has been unnoticed because even when the test failed with test-server, it was still passing on its retry because the time-out applies only when using test-server. * Reduce the retry from 2 times to 1 time * Remove RecordReplay from expected failure
* Disable 23 tests failing assertions (#7317)Jay Kwak2025-06-04
|