summaryrefslogtreecommitdiff
path: root/tests/bugs
AgeCommit message (Collapse)Author
2025-07-01Allow Link time constant array length sizing, warn on unsupported ↵Ellie Hermaszewska
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>
2025-06-30Implement IFloat.scale for vectors, matrices (#7545)James Helferty (NVIDIA)
* 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
2025-06-25Fix Phi elimination pass sometimes leaving broken insts in release builds ↵Julius Ikkala
(#7499) * Make phi elimination pass modify branches in-place * Add test and fix formatting * Avoid double removal of param insts
2025-06-13Skip processing import declarations after errors (#7393)James Helferty (NVIDIA)
* 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>
2025-06-12Fix issue of missing scope for 'Differential' type (#7433)kaizhangNV
* 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
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-04Disable 23 tests failing assertions (#7317)Jay Kwak
2025-06-03Fix specialization constants getting incorrectly folded (#7299)Julius Ikkala
2025-05-31Add check for the variable requirement (#6677)Gangzheng Tong
* Add check for the variable requirement This change adds the capability check for the variables requirement. With this check, the shader ``` [require(cpp_cuda_glsl_hlsl_metal_spirv)] Buffer<float> InputTyped; [require(cpp_cuda_glsl_hlsl_metal_spirv)] RWBuffer<float> OutputTyped; ``` will issue error if targeting to WSGL e.g. `.\build\Debug\bin\slangc .\tests\wgsl_no_buffer.slang -o wgsl_no_buffer.txt -target wgsl -entry Main -stage compute` .\tests\wgsl_no_buffer.slang(2): error 36108: 'InputTyped' has dependencies that are not compatible on the required target 'wgsl'. Buffer<float> InputTyped; ^~~~~~~~~~ .\tests\wgsl_no_buffer.slang(4): error 36108: 'OutputTyped' has dependencies that are not compatible on the required target 'wgsl'. RWBuffer<float> OutputTyped; ^~~~~~~~~~~ Fixes #6304 * Add var capability tests * Do capability checks for global var only * Add inferredCapabilityRequirements to var capability check * Add requirement to the intrinsic types Buffer/RWBuffer * format code * Update capabliity test * use DefaultDataLayout as default data layout * Use visitMemberExpr to check the capabilities * Update the cap tests to match the error messages * update test to use the ScalarDataLayout for hlsl target * Update tests check condition to use error number only * Add default push_constant data layout type --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-05-30Ensure we do not have an `initExpr` on a `VarDecl` inside an `InterfaceDecl` ↵ArielG-NV
(#7283) * Ensure we do not have an initExpr on a var inside an InterfaceDecl Ensure we do not have an initExpr on a var inside an InterfaceDecl. If we do, send an error. Ensure the language server does not segfault with this error as per the issue. * format code * split tests --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-05-25Fix #7232 (#7236)Julius Ikkala
2025-05-16Fix broken -emit-spirv-via-glsl test option (#7091)sricker-nvidia
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.
2025-05-15Re-enable spirv-validation, because the issue is no longer repro (#7082)Jay Kwak
2025-05-14Infer type while constant folding causes failure (#7090)ArielG-NV
Problem: * Infering type with `let` while using constant-foldable object's means we run in a circular loop of `ensureDecl`. Changes: * If we constant-fold we effectively are ready to check definition. If we are not a constant to fold, we run `setCheckState` after anyways.
2025-05-10Fix local constants in switch cases (#7053)Julius Ikkala
* Fix using local constants in switch cases * Add test * format code * Always lower switch cases with exprVal * Fix formatting --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com>
2025-05-03Add IREnumType to distinguish enums from ints and each other (#6973)Julius Ikkala
* Add IREnumType to distinguish enums from ints and each other * Add issue example as test * format code * Add expected test output * Fix peephole optimization hanging No idea why this PR triggered this, but there seems to have been a clear bug here anyway, so may just as well fix it now. * Move enum lowering later * Add linkage decoration to enum type * Use filecheck-buffer instead of expected.txt * Fix comment * Make enum casts actually use IR enum casts They were all BuiltinCasts by accident * Lower enum type before VM * Deal with rate-qualified types in enum cast * Allow any value marshalling for enum types * Handle new enum instructions in a couple more switches * Fix formatting --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-04-29Support use of `this` with Mesh Shader Outputs (`IRMeshOutputRef`) (#6920)16-Bit-Dog
* Support `this` use of `IRMeshOutputRef` * Fix SPIR-V val error There was a type mismatch causing a spir-v failiure: `store(var, var)` instead of `store(var, load(var))`
2025-04-25Fix attempt to construct an abstract AST node (#6905)Theresa Foley
Work on #6892 The function `tryInferLoopMaxIterations` in `slang-check-stmt.cpp` was doing: auto litExpr = m_astBuilder->create<LiteralExpr>(); but the declaration of `LiteralExpr` in `slang-ast-expr.h` had been marked as abstract, during the switch to using the `slang-fiddle` tool to generate code: FIDDLE(abstract) class LiteralExpr : public Expr { ... } In this case, the intention of the AST design is that `LiteralExpr` should be kept abstract, and only the concrete subclasses should ever be instantiated. Because of some historical design choices, the `ASTNodeType` enumeration includes both the concrete and abstract AST classes, so the code ended up constructing a `LiteralExpr` that had the tag `ASTNodeType::LiteralExpr`. Then attempts to use the `ASTNodeDispatcher` code on such a node caused crashes, because the dispatcher code only included `case` statements for the non-abstract `ASTNodeType`s. The quick fix here was to change the `tryInferLoopMaxIterations` function to instead do: auto litExpr = m_astBuilder->create<IntegerLiteralExpr>(); A test case was added to help catch any future regressions on this specific issue. A more long-term fix should involve introducing code that statically and/or dynamically prohibits the creation of instances of AST node classes that have been marked abstract.
2025-04-24update slang-rhi (#6587)Simon Kallweit
* update slang-rhi submodule * slang-rhi API changes * disable agility sdk * fix texture creation * update formats in tests * Extent3D rename * use 1 mip level for 1D textures for Metal * fix texture upload * update to latest slang-rhi * update slang-rhi * format code * update slang-rhi * do not run texture-intrinsics test on metal * update slang-rhi * deal with failing tests * fix more tests * update slang-rhi --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Simon Kallweit <simon.kallweit@gmail.com>
2025-04-21Allow simplifying self-referential Phi parameters (#6870)Julius Ikkala
2025-04-17Fix regression in partial specialization of existential arguments (#6818)kaizhangNV
Close #6589. In PR #6487, we support partial specialization. However there is a corner case we didn't handle correctly. For the IR like this: %val: specialize(...) = some inst; %arg1: specialize(...) = makeExistential(%val, ...); %arg2: %SomeConcreteType: load(...); call func(%arg1, %arg2); when we specialize the call func instruct, we will also specialize the function parameters. On our existing logic, when we find an argument is a makeExistential, we will always extract the existential value, and use its type as the new parameter. But in this case, %arg1 is not fully specialized yet, so it's type will still be a specialize. In this case, we will change the function's first parameter from an existential type to a specialize. This will result in that we lose the chance to specialize the first argument in the next iteration, because the first parameter of this function is not an existential type any more. The reason behind this is that we should always keep specializing the arguments and parameters at the same time. So this PR just does a check before specializing the parameters that if the argument cannot be fully specialized, we won't specialize the parameter this early. Instead, we will wait for the next iteration until the argument can be specialized.
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-12Add slang-test check for D3D11 double support (#6761)aidanfnv
Fixes #6171 This commit adds logic for reporting double support to the d3d11 backend, for running tests on GPUs that do not support D3D11_FEATURE_DOUBLES, and add checks for that support to tests that require the feature.
2025-04-09Get real value for typeAdapter (#6762)Gangzheng Tong
* Get real value for typeAdapter When the type is mismatch and typeAdapter is used, get the real value from typeAdapter so that we don't get nullptr for irValue. This fixes the assert if uint is used for SV_VertexID, which is an int in the system binding semantic. Fixes: #6525 * Add test case; add nullptr check
2025-04-04Do no fail on missing no_diff annotation on non-differentiable (inputs and ↵Ellie Hermaszewska
output) function outputs (#6737) Closes https://github.com/shader-slang/slang/issues/6632
2025-04-04fix(d3d11): correct parameter in VSSetConstantBuffers1 from uavCount … (#6690)Harsh Aggarwal (NVIDIA)
* fix(d3d11): correct parameter in VSSetConstantBuffers1 from uavCount to cbvCount (fixes #6531) Root cause - Incorrect parameter passing in slang-rhi 1. slang-rhi #281 - Add the correct cbvCount for setting Constant Buffer 2. Prevent render tests from overwriting reference images * Add missing tests/render/multiple-stage-io-locations.slang.3.expected.png * Add more expected images from texture2d-gather * Add new option: skipReferenceImageGeneration For Github CI we set this to true - So we don't overwrite the expected images --------- Co-authored-by: Jay Kwak <82421531+jkwak-work@users.noreply.github.com>
2025-03-12Migrate render-test away from deprecated compile request API (#6514)Anders Leino
* 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.
2025-03-06Fix lowering of `extern` types with defaults. (#6512)Yong He
* Fix lowering of `extern` types with defaults. * Fix test. * Fix test.
2025-03-06Update SPIRV-Tools and fix new validation errors. (#6511)Yong He
* Update SPIRV-Tools and fix new validation errors. * Implement pointers for glsl target. * Reworked packStorage/unpackStorage code gen to operate on pointers rather than values.
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-28Fix member lookup in left hand side of `where` clause. (#6490)Yong He
Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-02-27Fix regression in float to bool conversion. (#6497)Yong He
2025-02-27update slang-rhi (shader object refactor) (#6251)Simon Kallweit
* remove unused resource * define buffer data * add vs2022 build presets * update slang-rhi API usage * update slang-rhi --------- Co-authored-by: Yong He <yonghe@outlook.com>
2025-02-27Map `SV_InstanceID` to `gl_InstanceIndex-gl_BaseInstance` (#6468)Yong He
* Map `SV_InstanceID` to `gl_InstanceIndex-gl_BaseInstance` * Fix ci.
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-26Fix regression when using Atomic<T> in struct. (#6472)Yong He
2025-02-18Add warning for ignored binding attributes on uniforms (#6373)Mukund Keshava
Fixes #4251 When binding attributes (like [[vk::binding]]) are specified on uniforms that get packed into the default constant buffer, these binding attributes are effectively ignored since the uniform will always be placed at descriptor set 0, binding 0. This can be confusing for users who expect their explicit bindings to take effect. This change adds a new warning (71) that informs users when their binding attributes on uniforms will be ignored, and suggests declaring the uniform inside a constant buffer to preserve the explicit binding. The warning helps users understand: 1. Why their binding attribute isn't having the expected effect 2. That the uniform is being packed into the default constant buffer 3. How to fix it by using a constant buffer declaration Added test case in tests/bugs/binding-attribute-ignored.slang to verify the warning behavior. Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-02-12Allow LHS of `where` to be any type. (#6333)Yong He
* Allow LHS of `where` to be any type. * Register free-form extensions when loading precompiled module. * Fix test. * Fix. * Fix `as<IRType>`. * try fix precompiled module test.
2025-02-05Use two-stage parsing to disambiguate generic app and comparison. (#6281)Yong He
* Use two-stage parsing to disambiguate generic app and comparison. * Typo fix. * Update doc.
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-01-29Update SPIRV submodules and fix tests (#6222)Jay Kwak
2025-01-28Delete invalid ASSERT in `isTypeOperandEqual`. (#6196)Yong He
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 simplify if-else (#6077)cheneym2
* Fix simplify if-else The if-else optimization observes that at if at least one true/false block is merely an unconditional jump to the after block, that the whole if-else can be replaced with a jump to the after block. But it's important to copy the phi arguments from the aforementioned unconditional jump, rather than what is present in the 'true' block, since the 'true' block might actually just be the after block itself. Below, the ifElse() would be replaced with an unconditional jump to block %39, but with the `phi` arguments copied from the branch to %29, which is an unrelated block. ifElse(%38, %39, %40, %39) block %40: unconditionalBranch(%39) block %39: unconditionalBranch(%29, 0 : Float) block %29( [nameHint("ret")] param %ret : Float): Fixes issue #5972 * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com>
2025-01-07Lower varying parameters as pointers instead of SSA values. (#5919)Yong He
* Add executable test on matrix-typed vertex input. * Fix emit logic of matrix layout qualifier. * Pass fragment shader varying input by constref to allow EvaluateAttributeAtCentroid etc. to be implemented correctly.
2025-01-07 Check whether array element is fully specialized (#6000)kaizhangNV
* Check whether array element is fully specialized close #5776 When we start specialize a "specialize" IR, we should make sure all the elements are fully specialized, but we miss checking the elements of an array. This change will check the it. * add test * add all wrapper types into the check * add utility function to check if the type is wrapper type --------- Co-authored-by: zhangkai <zhangkai@zhangkais-MacBook-Pro.local> Co-authored-by: Yong He <yonghe@outlook.com>
2024-12-11Fix the logic to determine whether lower generic pass should run. (#5837)Yong He
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>
2024-12-10Create scope for synthesized property decl. (#5817)Yong He
Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2024-12-10Don't emit a warning when implicit casting from known in-range int lit to ↵Yong He
half. (#5814) Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>