summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAge
...
* Fix debug info generation for let variables in SPIR-V output (#7743)Copilot2025-07-18
| | | | | | | | | | | | | | | | | | | | | | | | | * Initial plan * Fix debug info for let variables Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix parameter count for emitDebugVar function call Fixed regression where let variable debug info generation was missing the optional argIndex parameter in emitDebugVar call. Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Add location validity check for debug info generation Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Don't insert debug value for nondebuggable types. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com>
* Lower int/uint/bool matrices to arrays for SPIRV (#7687)venkataram-nv2025-07-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add tests for expected behaviour * Allow matrix types in logical or/and * Legalize int/bool matrix types and construction with makeMatrix * Legalize uint matrices and operations * Limit testing to only SPIRV * Better tests for int and bool * Add test for uint * Remove GLSL tests * Remove old test for diagnosing int matrices * Emit SPIRV directly in tests * format code * Address PR comments * Improve testing * Address PR comments * format code * Add tests for matrix intrinsic operations * Move matrix lowering to dedicated legalization pass * Fix compiler warning * Remove signal again * Reorder matrix and vector legalization * Fix formatting * Add shift and comparison tests --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Add bounds checking for out-of-bounds array access with constant indices (#7814)Copilot2025-07-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Initial plan * Implement out-of-bounds array access checking Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Add tests and format code for array bounds checking Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Move checkForOutOfBoundAccess to separate file and refactor using InstPassBase Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Optimize out-of-bounds checker to use single IR traversal Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix DiagnosticSink forward declaration from struct to class Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Update 0-array-1 test to use runtime indices to avoid bounds checking diagnostic Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Use SV_DispatchThreadID for truly runtime array access in 0-array-1 test Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Fix GLSL global const diagnostic regression (#7808)Copilot2025-07-17
| | | | | | | | | | | | * Initial plan * Fix GLSL global const diagnostic regression - add test exclusion for GLSL module Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Perf improvements to IR serialization (#7751)Ellie Hermaszewska2025-07-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * option to use riff as serialization backend * option to use riff as serialization backend * perf * shuffle code * perf improvements to deserialization * formatting * remove bit_cast * correct IR verification * neaten serialized format * fix peek module info * formatting * remove temporary profiling code * cleanup * fix wasm build * more explicit sizes * deserialize via fossil on 32 bit wasm * Make serialized modules Int size agnostic * reorder stable names to allow range based check for 64 bit constants * format * review comments * fix build * fix * c++17 compat slang-common.h
* Fix duplicate DiffPair struct generation for row_major matrices in autodiff ↵Copilot2025-07-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#7728) * Initial plan * Fix duplicate DiffPair struct generation for row_major matrices in autodiff Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix matrix layout conversion to use BuiltinCastExpr Address root cause in slang-check-conversion.cpp by creating proper cast expressions for matrix layout conversions instead of reusing expressions. This ensures autodiff sees proper type conversions and generates consistent DiffPair structs. Reverted the band-aid fix in autodiff system and implemented the proper front-end fix as suggested in code review. Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix test to prevent dead code elimination and make it executable on CPU Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix spirv emit of matrix layout cast insts. * Update test. * cleanup test. * Improve test with meaningful values that verify correct gradient computation Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com>
* Fix CUDA issues with texture reads and surface writes (#7780)Mukund Keshava2025-07-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix 1D texture reads in CUDA target Fixes #7570: 1D surface writes don't work The issue was that the Load function for read-only textures (hlsl.meta.slang lines 3629-3656) only supported 2D and 3D textures for CUDA targets, causing 1D texture reads to fall through to <invalid intrinsic>. This affected the srcTexture[tid.x] read operation in the reproduction case. Changes: - Updated static_assert to include SLANG_TEXTURE_1D support - Added tex1DArrayfetch_int<T> for 1D array texture reads - Added tex1Dfetch_int<T> for regular 1D texture reads 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Mukund Keshava <mkeshavaNV@users.noreply.github.com> * Add 1D texture read support for CUDA target - Add tex1Dfetch_int template specializations for float2, float4, uint, uint2, uint4 - Remove TODO comment about 1D PTX not being supported - Enable 1D texture test in texture-subscript-cuda.slang - Fix assembly code issues in original template specializations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Mukund Keshava <mkeshavaNV@users.noreply.github.com> * Update slang-cuda-prelude.h * Fix texture3d ptx issue * undo 1D texture changes * Update hlsl.meta.slang * Update hlsl.meta.slang * Update hlsl.meta.slang * Update hlsl.meta.slang * Extend texture-subscript-cuda.slang test with uint and int format variants Add test cases for newly supported texture formats in CUDA: - 2D textures with uint, uint2, uint4 - 2D textures with int, int2, int4 - 3D textures with uint, uint2, uint4 - 3D textures with int, int2, int4 This ensures the texture subscript operations work correctly for all the format variants added in the CUDA texture fixes. Co-authored-by: Mukund Keshava <mkeshavaNV@users.noreply.github.com> * update expected file --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Mukund Keshava <mkeshavaNV@users.noreply.github.com>
* Diagnose on initExpr of a global `const` decl (#7711)Yong He2025-07-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add diagnostic for const/uniform global variables with initializers Global const and uniform variables without the static modifier are treated as uniform parameters in HLSL, which cannot have default values. This change adds error 31224 to catch this case early and provide clear guidance to users. Fixes #7701 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Yong He <csyonghe@users.noreply.github.com> * Add test case for global const/uniform variable diagnostic Add test for diagnostic 31224 which catches global const and uniform variables with initializers that aren't declared static. The test verifies both error cases and valid cases to ensure the diagnostic works correctly. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Yong He <csyonghe@users.noreply.github.com> * Fix failing tests due to new global const diagnostic Add 'static' keyword to global const variables with initializers to resolve diagnostic 31224: "global const variable with initializer must be declared static" Co-authored-by: Jay Kwak <jkwak-work@users.noreply.github.com> * Allow specialization constants with initializers without static - Modified diagnostic logic in slang-check-decl.cpp to allow specialization constants (SpecializationConstantAttribute and VkConstantIdAttribute) to have initializers without requiring the static keyword - Updated 8 SPIRV test files to remove unnecessary static keywords from specialization constant declarations - Enhanced diagnostic test case to include specialization constant examples - All tests passing with the new behavior 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Yong He <csyonghe@users.noreply.github.com> * format code (#7765) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Remove static keyword from specialization constants and add comprehensive test cases - Remove static from specialization constants in test files as they are semantically meaningless - Update tests to use existing diagnostic 31219 for static specialization constant errors - Add comprehensive test cases that verify the error occurs when static is used with specialization constants - Fixes suggested in PR review to make static specialization constants an error Co-authored-by: ArielG-NV <ArielG-NV@users.noreply.github.com> * Add error for static specialization constants Static specialization constants are semantically meaningless and should produce an error. This change adds logic to trigger diagnostic 31219 when both 'static' and specialization constant attributes are present. The existing diagnostic 31219 'push or specialization constants cannot be static' is now correctly triggered for: - [SpecializationConstant] static const variables - [vk::constant_id] static const variables Co-authored-by: ArielG-NV <ArielG-NV@users.noreply.github.com> * Update source/slang/slang-check-decl.cpp * Update tests/glsl/compute-shader-layout-id.slang * Update tests/glsl/compute-shader-layout-id.slang * Fix test case Claude broke * Update global-uniform.slang * Update global-uniform.slang.expected --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Yong He <csyonghe@users.noreply.github.com> Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Co-authored-by: Jay Kwak <jkwak-work@users.noreply.github.com> Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: ArielG-NV <ArielG-NV@users.noreply.github.com>
* Document why failing VVL coop-vec tests cannot be enabled & minor ↵ArielG-NV2025-07-16
| | | | | | | | | | | | | | | | | cleanup/bug-fix (#7754) * Changes Fix a coop-vec bug, fix incorrect test synax, clean up test, comment why some coop-vec tests are stil disabled * Changes Fix a coop-vec bug, fix incorrect test synax, clean up test, comment why some coop-vec tests are stil disabled * disable failing tests * push changes * add to failing GLSL test list
* Fix Metal pointer type emission in entry point parameters (#7759)Jay Kwak2025-07-16
| | | | | | | | | | | | | | * Fix Metal pointer type emission in entry point parameters Add missing default case in Metal emitter's address space switch to preserve pointer types. Previously, unrecognized address spaces would fall through without emitting pointer syntax, causing uint64_t* to become ulong instead of ulong constant*. Fixes #7605, #6174 * Treat AddressSpace::UserPointer as Global in Metal Also adding another test for `uniform` keyword
* Fix GLSL memory layout qualifiers not applied to uniform buffers or cbuffers ↵pdeayton-nv2025-07-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#7740) * Fix GLSL memory layout qualifiers not applied to uniform buffers or cbuffers The `layout(scalar)` qualifier was being ignored for GLSL `uniform` blocks and HLSL `cbuffer` declarations, causing them to use std140 layout instead of the requested scalar layout. **Root Cause**: The parsing logic in `slang-parser.cpp` handled layout qualifiers inconsistently: - GLSL `buffer` blocks correctly used `getLayoutArg()` to map layout modifiers - GLSL `uniform` blocks and HLSL `cbuffer` skipped layout arguments entirely **Solution**: - Enhanced `parseHLSLCBufferDecl()` to check for GLSL layout qualifiers - Added same `getLayoutArg()` logic used by buffer blocks - Modified uniform block parsing to pass layout arguments through **Testing**: - Added comprehensive test case: `tests/glsl/layout-scalar-qualifier.slang` - Verified fix works for both `uniform` blocks and `cbuffer` declarations - Confirmed no regressions in existing test suite **Before**: `layout(scalar) uniform {...}` → std140 layout (32 bytes, offset 0,16) **After**: `layout(scalar) uniform {...}` → scalar layout (16 bytes, offset 0,4) Fixes #7735 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: pdeayton-nv <pdeayton-nv@users.noreply.github.com> * Apply code formatting to slang-parser.cpp Fixed line wrapping, trailing whitespace, and parameter formatting according to repository style guidelines. Co-authored-by: Harsh Aggarwal (NVIDIA) <szihs@users.noreply.github.com> * format code (#7742) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: pdeayton-nv <pdeayton-nv@users.noreply.github.com> Co-authored-by: Harsh Aggarwal (NVIDIA) <szihs@users.noreply.github.com> Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com>
* Fix WGSL sign function to return correct int type instead of float (#7739)Copilot2025-07-16
| | | | | | | | | | | | | | | | | | | | * Initial plan * Fix WGSL sign function to return int type properly Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Add vector version check for WGSL sign function test Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix FileCheck order in WGSL sign test - use DAG for order-independent checking Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Add clear diagnostic for unsupported float types in generic value parameters ↵Copilot2025-07-16
| | | | | | | | | | | | | | (#7737) * Initial plan * Add validation and clear error message for float generic parameters Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Emit additional diagnostic for invalid pointer taking operations (#7663)Gangzheng Tong2025-07-15
| | | | | | | | | | | | | | | | | | | | | | | | | * Emit special diagnostic for invalid pointer taking operations * Update source/slang/slang-diagnostic-defs.h Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> * Add OperatorAddressOf KnownBuiltin modifier * update error message for non-l-value assignment * update the diagnostics in the tests * Use enum based KnownBuiltinDeclName * format code (#7772) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --------- Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Replace [KnownBuiltin] string-based comparisons with enum-based system (#7714)Copilot2025-07-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Initial plan * Implement enum-based KnownBuiltin system to replace string comparisons Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Add test for enum-based KnownBuiltin system and verify functionality Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Implement enum-based KnownBuiltin system with direct integer values Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix IntVal access and update tests for new enum-based KnownBuiltin system Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Replace hardcoded KnownBuiltin integers with preprocessor enum syntax - Updated all KnownBuiltin attributes to use $( (int)KnownBuiltinDeclName::EnumValue) syntax - Added space between parentheses to avoid preprocessor bug: $( (int) instead of $((int) - Updated both core.meta.slang and hlsl.meta.slang files - Eliminates preprocessor-time integer conversion, baking enum values directly into meta files - Maintains same functionality while using type-safe enum references Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix IDifferentiablePtr KnownBuiltin mapping regression Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Remove unused IDifferentiablePtrType enum case from KnownBuiltinDeclName Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Clean up temporary AST dump files from testing Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Replace hardcoded integer with descriptive constant in KnownBuiltin test Replace the hardcoded [KnownBuiltin(0)] with a descriptive named constant GEOMETRY_STREAM_APPEND_BUILTIN to improve code readability and maintainability. The test now clearly indicates which builtin enum value is being tested. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Gangzheng Tong <gtong-nv@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Gangzheng Tong <gtong-nv@users.noreply.github.com> Co-authored-by: Gangzheng Tong <tonggangzheng@gmail.com>
* Fix language server crash. (#7756)Yong He2025-07-15
| | | | | | | | | * Fix language server crash. * Fix tests. * Fix. * Revert changes.
* Add WorkgroupCount function (#7734)davli-nv2025-07-12
| | | | | | | | | Fixes #7733 Copy gl_NumWorkGroups into hlsl.meta.slang as WorkgroupCount function so that it can be used for GLSL and SPIR-V targets without GLSL syntax. Also change WorkgroupSize function to allow use with mesh shading capability. Update pipeline/rasterization/mesh/task-simple.slang to test it in task and mesh stages.
* Fixup address spaces after inlining. (#7731)Yong He2025-07-11
| | | | | * Fixup address spaces after inlining. * add -O0
* Enable (at least a sub-set of) CoopVec tests that are disabled (#7706)ArielG-NV2025-07-11
| | | | | | | | | | | | | * enable coop vec tests * disable tests which fail with reason * disable other failing tests * disable failing test * add to expected fail list * sort list
* Fix unnecessary Int64 SPIRV capability usage in pointer marshalling (#7717)Copilot2025-07-11
| | | | | | | | | | | | | | | | | | | | | | * Initial plan * Fix unnecessary Int64 SPIRV capability usage in pointer marshalling Replace uint64-based pointer marshalling with uint2-based approach to avoid requiring Int64 capability in SPIRV output. This affects both basic type marshalling and resource handle marshalling for pointer types. Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Replace test cases with user-provided test case Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix test case to avoid unrelated pointer casting operations that require Int64 Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Fix segfault with Ptr<T> extension using 'This' type reference (#7719)Yong He2025-07-11
| | | | | | | | | | | | | | | | | | | | | | | | | * Fix segfault with Ptr<T> extension using 'This' type reference Set LookupOptions::NoDeref when looking up target type members within extension declarations to prevent automatic pointer dereferencing that was causing breadcrumb handling issues and segfaults. Fixes #7656 Co-authored-by: Yong He <csyonghe@users.noreply.github.com> * Enhance test for ptr-extension-this-type to verify correctness with interpreter - Changed function to return sizeof(This) - sizeof(Ptr<int>) + 1 - Modified test to use interpreter with filecheck to verify result equals 1 - Added main() function that calls the extension method and prints result - Verifies that 'This' correctly refers to Ptr<int> in extension context Co-authored-by: Yong He <csyonghe@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Yong He <csyonghe@users.noreply.github.com>
* Add DebugGlobalVariable instructions to SPIR-V output (#7686)Jay Kwak2025-07-11
| | | | | | | | | | | | | | | | | | | | | | | | * Add DebugGlobalVariable instructions to SPIR-V output Implements generation of DebugGlobalVariable instructions for global variables like Texture2D and SamplerState in SPIR-V debug information output. Adds debug type support for texture and sampler types using DebugTypeComposite. * Handle two more types for DebugGlobalVariable kIROp_RaytracingAccelerationStructureType and kIROp_SamplerComparisonStateType had to be handled in `emitDebugTypeImpl()` * Fix format * Refactor debug type emission to reduce duplication Use IRSamplerStateTypeBase type check and fallback pattern instead of separate cases for each opcode type. * Fix compiler warning * Simplify `emitDebugTypeImpl()` more
* Fix metal segfault by check vectorValue before accessing (#7688)Gangzheng Tong2025-07-11
| | | | | | | | | | | | | | | | | | | | | | | | * Check vectorValue before accessing * Fix metal segfault by using IRElementExtract for general vector handling Address review comments by replacing IRMakeVector-specific code with IRElementExtract to handle any vector instruction type (IRIntCast, etc). This makes the code more robust and fixes cases where float2(1,2) creates IRIntCast instead of IRMakeVector. Co-authored-by: Yong He <csyonghe@users.noreply.github.com> * Fix sign comparison warning in metal legalize Cast originalElementCount->getValue() to UInt to avoid comparison between signed and unsigned integers. Co-authored-by: Yong He <csyonghe@users.noreply.github.com> --------- Co-authored-by: Yong He <yonghe@outlook.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Yong He <csyonghe@users.noreply.github.com>
* Fix IEEE 754 NaN comparisons in constant folding (#7721)Jay Kwak2025-07-11
| | | | | | | | | | | | | | | | | * Fix IEEE 754 NaN comparisons in constant folding Added proper NaN handling in SCCP optimization pass to follow IEEE 754 standard: - NaN \!= any value returns true - All other NaN comparisons return false - Added double precision NaN detection support - Fixed type detection to check operands instead of result type * Avoid differentiating NaN and non-NaN cases * format code (#76) --------- Co-authored-by: slangbot <ellieh+slangbot@nvidia.com>
* Ensure generic constraints are checked before inner extension. (#7685)Yong He2025-07-11
| | | | | | | | | | | | | * Ensure generic constraints are checked before inner extension. * Add warning for non-standard generic extension. * Fix tests. * Fix test. * Ban interface types from equality constraints. * Fix.
* Fix issue in match parameter type that depend on an associatedtype. (#7707)Yong He2025-07-11
|
* Fix int16_t/uint16_t support for WGSL target (#7692)Copilot2025-07-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Initial plan * Implement int16_t/uint16_t support for WGSL target Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Change int16_t/uint16_t to emit proper diagnostics instead of auto-promoting Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Implement diagnoseOnce to prevent duplicate diagnostics Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Optimize diagnoseOnce to use HashSet::add() return value Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Apply code formatting to slang-emit-c-like.h Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix diagnoseOnce to use all parameters instead of first parameter only Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Fix SV_VertexID and SV_InstanceID crash with -preserve-params in SPIR-V ↵Copilot2025-07-10
| | | | | | | | | | | | | | | | | | | | | | | | emitter (#7691) * Initial plan * Fix SV_VertexID and SV_InstanceID crash with -preserve-params in SPIR-V emitter Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix transformation layer to handle unused builtin params properly This ensures that builtin decorations are correctly transformed for unused parameters with -preserve-params, preventing the SPIR-V emitter from seeing un-translated builtins like sv_vertexid. Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Format code according to project style Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Fix internal error when a generic in an extension is unused (#7665)Copilot2025-07-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Initial plan * Add diagnostic for unreferenced generic parameters in extensions Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Use GenericTypeParamDeclBase and eliminate intermediate list Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Update test to use filecheck format for better verification Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Update extension validation to use getMembersOfType for better constraint collection Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Add temporary workaround for inheritance constraints but issue persists Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix inheritance constraint validation by moving to SemanticsDeclConformancesVisitor Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix inheritance constraint validation by removing inheritance declaration checks Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Move extension generic parameter validation back to SemanticsDeclBasesVisitor Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix test. * format code (#7671) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Fix and update. * Refine fix. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com> Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* no_diff diagnostics improvement (#7655)kaizhangNV2025-07-09
| | | | | | | | | | | close #6286. This PR is to improve the diagnostics for no_diff usage. In a differentiable function, any calls to a non-diff function with constant arguments should not require no_diff attribute. This PR adds this extra check at `checkAutoDiffUsages` where it checks the differentiability on IR. In a differentiable method, we will force to use `[NoDiffThis]` attribute if there is access to non-differentiable `This` type. Once this access is detected we will report a warning to bring users attention that this access won't generate any derivative, they have to use `[NoDiffThis]` to suppress that warning. This PR adds this check at type checking stage, because it's the easiest way to find out all the `This` accesses.
* Avoid adding underscore to _snorm format if it has one (#7664)aidanfnv2025-07-09
|
* Convert gfx unit tests and examples to use slang-rhi (#7577)Gangzheng Tong2025-07-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Port first gfx unit test to slang-rhi * port triangle example to use slang-rhi * port platform-test to slang-rhi * Update platform-test to throttle mouse move events * port gpu-printing example to use slang-rhi * port model-viewer example to use slang-rhi * port ray-tracing example to use slang-rhi * port ray-tracing pipeline example to use slang-rhi * port reflection parameter blocks example to use slang-rhi * port shader-object example to use slang-rhi * port shader-toy example to use slang-rhi * Port most of tests to slang-rhi * port link-time-constant-array-size to use slang-rhi * Fix tests and find matching tests in slang-rhi * port autodiff-texture * remove gfx target; port nv-aftermath-example * update include path for shader-cursor.h * Disabled 2 more ported tests * fix build error * remove gfx test * put slang-rhi (static-lib) before slang (shared) * format code (#7621) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * add debug callback * format code (#7649) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Address review comments; revert back to use SLANG_CHECK_MSG --------- Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Stable names and backwards compat for serialized IR modules (#7644)Ellie Hermaszewska2025-07-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable names * tests, options and ci for stable names * Add back compat design document * fix warnings * formatting * comment * neaten * regenerate command line reference * consolidate ci scripts * faster ci * remove libreadline * Move new function to end of interface --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Generate OpExecutionMode PointMode for tessellation shaders (#7662)pdeayton-nv2025-07-09
| | | | | | | * Generate "OpExecutionMode PointMode" for tessellation shaders instead of the incorrect geometry and mesh shader specific "OpExecutionMode OutputPoints". * Add a test case verifying the OpExecutionMode is correct. Fixes #7660
* Fix `extension` incorrectly interacting with `equality` and `type-coercion` ↵ArielG-NV2025-07-09
| | | | | | | | | | | | | | | | | | | | | | | | | constraints (#7578) * fix problem * cleanup comment * format code * make change more restrictive * format code * push logic update * format code * push test fix * make test more general --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Add error for forward references in generic constraints (#7615)sricker-nvidia2025-07-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add error for forward references in generic constraints Change addresses issue #6545. The slang compiler's type checker is unable to support cases where a generic type parameter is referenced as a constraint before it is declared. For example code like: ```` interface IFoo<T : IFloat> { } void bar<Foo : IFoo<T>, T : IFloat>() { } ```` Is not supported, but will currently report a generic error like, "(0): error 99999: Slang compilation aborted due to an exception of class Slang::InternalError: unexpected: generic type constraint during lowering" This change adds a new check for this kind of code and reports an error like, "error 30117: generic constraint for parameter 'Foo' references type parameter 'T' before it is declared" when detected. Basic testing of this error is also added in a new diagnostic test. * Add error for forward refs in generic constiants update 1 * Add error for forward refs in generic constraints update 2 Revised algo in checkForwardReferencesInGenericConstraint to run in O(n) instead of the previous O(n^2) using HashSets. * Add error for forward refs in generic constraints update 3 -Update logic adding referenced decl's in collectReferencedDecls. -Simplified error string logic. * Add error for forward refs in generic constraints update 4 -Declare collectReferencedDecls in slang-check.h such that it can be used as a general utility function. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Language server: sort completion candidate by relevance. (#7626)Yong He2025-07-07
| | | | | * Language server: sort completion candidate by relevance. * Small adjustment.
* Make copysign function differentiable (#7585)Copilot2025-07-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Initial plan * Implement copysign forward and backward derivatives Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix copysign test format to use expected.txt file Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Add wgsl support to copysign and fix y==0 derivative case Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Add wgsl support to copysign helper functions Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix copysign derivative to return 0 when either x or y is 0 Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Language Server Enhancements (#7604)Yong He2025-07-03
| | | | | | | | | | | | | | | | | | | | | | | * Language Server: auto-select the best candidate in signature help. * Fix constructor call highlighting + goto definition. * Add test. * format code * Improve ctor signature help. * Add tests. * Fix decl path printing for extension children. * Allow goto definition to show core module source. * c++ compile fix. --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Replace SLANG_ALIGN_OF with C++11 alignof (#7523)Julius Ikkala2025-07-03
| | | | | * Replace SLANG_ALIGN_OF with C++11 alignof * Fix formatting (again)
* Fix for mixed block/embedded usage of structs in SPIRV (#7608)James Helferty (NVIDIA)2025-07-03
| | | | | | | | | | | | | | | | | | | | | | * Add test for mixed use of uniform/ParameterBlock Adds a test that uses the same struct as a parameter and as a ParameterBlock. * Fix for SPIRV block declaration issue Fixes #7431 * Fix formatting * Collect struct param usage in first pass Reduces number of iterations over the entire program. * more formatting fixes * formatting * Remove unused variable
* Remove a test from expected-failure-github for MacOS (#7526)Jay Kwak2025-07-03
| | | | | This commit removes the following test from expected-failure-github.txt because the issue is addressed on slang-rhi side. tests/compute/cbuffer-legalize.slang.2 syn (mtl)
* Don't use access::sample for multisample texture in metal (#7601)Gangzheng Tong2025-07-03
| | | | | | | | | | | | | | * don't use access::sample for multisample texture * Add test case * format code (#7603) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --------- Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Enable tests for CUDA (#7593)Mukund Keshava2025-07-03
| | | | | | | | Enable intrinsic tests for cuda. Most of these tests were either disabled or just not enabled for cuda. Fixes #7592 Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
* Fix crash when using wrong type for inout parameter with WGSL target (#7588)Copilot2025-07-02
| | | | | | | | | | | | | | | | | | | | | * Initial plan * Fix crash in WGSL L-value cast lowering with type mismatches Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Apply formatting to fix Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Update test to verify successful compilation instead of error checking Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com>
* [HLSL, SPIRV_1_3] Hoist OpSelect returning a composite into `if`/`else` (#7594)ArielG-NV2025-07-02
| | | | | | | | | | | | | | | | | | | * emit var and hoist out OpSelect if Composite * cleanup comment * address review check for version in spv context use phi node instead of using var move inst's using a list (not in-place modification) * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Fix spurious vk::binding warnings when attribute is present (#7581)Copilot2025-07-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Initial plan * Fix spurious vk::binding warnings when attribute is present - Modified _maybeDiagnoseMissingVulkanLayoutModifier to check for GLSLBindingAttribute before warning - Changed function to return bool indicating if warning was actually issued - Updated call sites to properly track warning state to reduce duplicates - Tested fix resolves the issue while preserving correct warnings when needed Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Add test case for vk::binding spurious warning fix Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Update test to use filecheck format as requested Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Remove full file path from CHECK directives as requested Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix code formatting with clang-format Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix behavioral regression in vk-bindings test caused by warning flag logic Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com>
* Fix for emitting ArrayStride decoration for arrays of opaque types (#7568)Jerran Schmidt2025-07-02
| | | | | | | | | * WIP opaque type decoration fix * Clearer intent * Formatting * Added test for fix
* Defer immutable buffer loads when emitting spirv. (#7579)Yong He2025-07-02
| | | | | | | | | | | | | * Defer immutable buffer loads when emitting spirv. * Fix. * Fix. * Fix. * Fix tests. * Fix test.
* Misc language server improvements. (#7569)Yong He2025-07-01
| | | | | | | | | | | | | * Misc language server improvements. * Fix. * Fix decl path printing for existential lookup. * More existential decl path fix. * Polish. * Fix test.