summaryrefslogtreecommitdiffstats
path: root/source/slang
Commit message (Collapse)AuthorAge
...
* 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>
* Debugging code improvement for IR tracking (#7770)Jay Kwak2025-07-15
| | | | | | | | | | | | | | When you track IR creation with `_debugUID` or `_slangIRAllocBreak`, you had to set a break point near `_slangIRAllocBreak` is used and unset it after changing the value of `_slangIRAllocBreak`. Then, when you re-run slangc for more debuggin, you have to set the break-point again, because it was unset. With this change, you can keep the break-point in the new line, and it will hit only once per debugging session. Not a big improvement, but I found this useful because it requires less manual handling of the break-points.
* Fix `slang-generate` segfault when parsing `$(()...)` (#7683)ArielG-NV2025-07-15
| | | | | | | | | | | | | | | | | * Fix `slang-generate` segfault when parsing `(...)` Currently the following code causes a failure: * `myFunc($((int)val))` * This fails since we parse it as `int)val` due to trying to find a body with repeating `(`. The primary issue here is that auto-format prefers `$((...))` over `$( (...))`, making this an annoying bug. * only read first char with `(` * format code --------- 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
* 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>
* Use stdout for --help text instead of stderr (#7730)aidanfnv2025-07-11
| | | | | | | | | | | | * Use stdout for --help text instead of stderr * format code (#13) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --------- Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Add 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 CommittedRayInstanceCustomIndex generating wrong SPIR-V opcode (#7659)Julius Ikkala2025-07-10
|
* 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 `slangc --help` text for `-reflection-json` (#7653)Sam Estep2025-07-09
|
* 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
|
* 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 typo in image format table (#7661)aidanfnv2025-07-09
|
* 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>
* Add <help-category> list and hint on usage in slangc -h (#7638)aidanfnv2025-07-08
| | | | | | | | | | | | | | | | * Add category list at end of slangc -h output * Use value category for categories * format code (#12) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> * Regenerate cmdline reference --------- Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Use fossil for IR serialization (#7619)Ellie Hermaszewska2025-07-08
| | | | | | | | | | | | | | | | | | | | | | | * bottleneck ir module reading and writing * compute/simple working * more complex tests working * neaten * factor out SourceLoc serialization * document changes * Appease clang * Correct name serialization * remove unnecessary code * neaten * neaten
* Language server: sort completion candidate by relevance. (#7626)Yong He2025-07-07
| | | | | * Language server: sort completion candidate by relevance. * Small adjustment.
* Catch abort exception from leaking from loadModule (#7627)aidanfnv2025-07-07
|
* 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
* 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>
* 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>
* add task shader alias (#7372)Sirox2025-07-02
| | | | | | | | | | | * alias amplification shader as task shader and add mesh shader profile * add task shader stage alias to capabilities * regenerate command line reference --------- 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 diagnostics not appearing when semantic tokens are disabled (#7477) (#7532)Harsh Aggarwal (NVIDIA)2025-07-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix diagnostics not appearing when semantic tokens are disabled (#7477) Previously, the language server only triggered module loading and compilation through semantic token requests. When semantic tokens were disabled, didOpenTextDocument and didChangeTextDocument would only update the workspace without compiling modules, meaning no diagnostics were generated. This change: - Adds module loading to didOpenTextDocument for .slang/.hlsl files - Adds module loading to didChangeTextDocument for .slang/.hlsl files - Triggers diagnostic updates via resetDiagnosticUpdateTime for Slang files - Ensures diagnostics appear immediately when opening/editing files - Maintains backward compatibility with existing LSP features Additionally fixes JSON serialization to properly handle NullResponse types by serializing them as JSON null instead of empty objects, improving LSP protocol compliance. Now diagnostics work correctly regardless of semantic token settings. * Revert: Remove unrelated change - will pick up in seprate PR * Fix module state corruption when checkAllTranslationUnits throws Add try/catch in Linkage::loadParsedModule to properly clean up module maps when checkAllTranslationUnits() fails with an exception. This prevents incorrect state in WorkspaceVersion::getOrLoadModule where failed modules remained in the loaded modules map, causing subsequent calls to return stale/invalid module references. * Update to address review comments * update: remove explicit checking for .slang and .hlsl
* 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.
* extend fiddle to allow custom lua splices in more places (#7559)Ellie Hermaszewska2025-07-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add fkYAML submodule * Generate slang-ir-inst-defs.h from slang-ir-inst-defs.yaml * generate ir-inst-defs.h * neaten things * neaten inst def parser * add rapidyaml submodule * remove fkyaml * remove fkyaml submodule * remove use of ir-inst-defs.h * format and warnings * fix wasm build * tidy * remove rapidyaml * Extend fiddle to allow custom splices in more places * Use lua to describe ir insts * fix * neaten * neaten * neaten * spelling * neaten * comment comment out assert * merge
* 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>
* Remove some cruft/complexity from IR serialization (#7483)Theresa Foley2025-07-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Remove some cruft/complexity from IR serialization This is a very simple cleanup to unnecessary code paths and remove some flexibility that isn't actually needed, to hopefully simplify the task of more completely overhauling the approach to IR serialization in a later change. The concrete feature that gets removed here is a debug-only feature (which thus shouldn't be affecting any users of Slang) that was added long ago in the life of the compiler as we were working to truly separate the front- and back-ends. At the time there was a lot of code in the compiler back-end that still made use of AST-level data structures, and thus got in the way of our goal to support separate compilation and linking (such that final code generation can only depend on the IR, and not the AST). The option was used to cause the Slang IR to be serialized out and then read back in as part of compilation, to try and enforce that only the wanted constructs could pass through that bottleneck. The idea was only ever half implemented, however, because it made use of a secondary implementation path in IR serialization that supported serializing the "raw" source locations (which are heavily dependent on AST-level information, even down to the number of bytes in source files). This change removes the feature entirely, since it is no longer useful for its intended purpose, and its presence causes there to be entire second code path for source locations in IR serialization that would need to have test coverage if we wanted to be sure it kept working. In addition, our pre-existing infrastructure for module serialization had various options that have either stopped being useful, or were not really useful at the time they were introduced. For example: there are no places in the code today where we attempt to serialize out a module without including both the serialized AST and IR. If that was a feature that we ever supported, the relevant code got removed at some preceding point without breaking any of our tests or (seemingly) upsetting users. Similarly, the options being passed into writing of a serialized module included both a flag to control whether source locations should be serialized *and* a pointer to the `SourceManager` to use in that case... but it was only ever meaningful to set both, or neither. The option has been changed to just be the `SourceManager` pointer, and the name has been updated to reflect its very narrow intended use case. * format code * fixup * regenerate command line reference --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com>
* Remove redundant [payload] attribute (Fix #7528) (#7555)Harsh Aggarwal (NVIDIA)2025-06-30
| | | | | | | | | | | | Removes the PayloadAttribute class and related infrastructure that was made redundant by PR #6595, which added ray payload access qualifiers (PAQs) per the DXR spec. The new [raypayload] attribute with access qualifiers provides the same functionality. Changes: - Remove PayloadAttribute class from slang-ast-modifier.h - Remove [payload] attribute syntax from core.meta.slang - Remove PayloadDecoration IR instruction and related processing - Remove HLSL emission of [payload] attribute - Remove IR lowering support for old PayloadAttribute The new [raypayload] attribute with PAQ support remains unchanged.