summaryrefslogtreecommitdiff
path: root/source
AgeCommit message (Collapse)Author
2025-03-22Add GLSL array length syntax support (#6665)DarrelFW321
2025-03-22Support spirv ops added by multiple extensions (#6615)Dario Mylonopoulos
* spirv: add support for ops added by multiple extensions Some spirv ops are added by multiple extensions and capabilities. This commit adds support to avoid emitting unnecessary extensions and capabilities if one of the options is already required by some other op. * spirv: allow OpRaytracingAccelerationStructure to use multiple extensions This Op is provided by both SPV_KHR_ray_tracing and SPV_KHR_ray_query and the respective capabilities. Use one if already available and otherwise fall back to SPV_KHR_ray_tracing. * tests/vkray: add negative checks for RayTracingKHR and RayQueryKHR - Add new rayquery-compute.slang to test that only RayQueryKHR is needed in compute shaders. - Add checks for RayTracingKHR and RayQueryKHR capabilities and extensions in raygen.slang --------- Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-03-21Emit errors for missing returns on unsupported targets (#6633)Darren Wihandi
* initial wip * more WIP * preserve old lower behavior * remove unnecessary includes * add test * add no target case in test * fix broken test --------- Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-03-21Apply pixel interlock execution mode to entry-point functions only (#6661)Darren Wihandi
Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-03-20Correct modifier isConst initialization (#6645)Gangzheng Tong
The previous implementation had two issues in the modifier processing loop: 1. isConst was incorrectly initialized to true, making the const check redundant 2. Premature loop break could skip processing important modifiers. e.g. isExtern Changes: - Initialize isConst to false by default - Remove early break condition to process all modifiers Fixes: #6606 Co-authored-by: Yong He <yonghe@outlook.com>
2025-03-20Add -dump-module command to slangc (#6638)cheneym2
* Add -dump-module command to slangc The new -dump-module command to slangc will load and disassemble a slang module, similar to what would be seen by the -dump-ir command, except that -dump-ir tells slangc to print IR as it performs some compilation command. That is, -dump-ir requires some larger compilation task. -dump-module on the otherhand requires no additional goal and will simply load a module and print its IR to stdout independently from other compilation steps. Its intended purpose is to inspect .slang-module files on disk. It can also be used on .slang files which will be parsed and lowered if slang does not find an associated ".slang-module" version of the module on disk. The compilation API is extended with a new IModule::disassemble() method which retrieves the string representation of the dumped IR. Closes #6599 * format code * Use FileStream not FILE * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-03-20Make image format reflection easier (#6550)Devon
* image format json reflection * format code * use direct include --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-03-19Output SPV_KHR_compute_shader_derivatives extension string instead of the NV ↵Darren Wihandi
extension (#6641) * Output SPV_KHR_compute_shader_derivatives instead of the NV extension * add alias for nv extension
2025-03-19Add SPIRV atomic debug type (#6616)Darren Wihandi
Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-03-19Fix reinterpret and bitcast and generic arg parsing. (#6627)Yong He
* Fix reinterpret and bitcast. * Fix warning. * Fix. * Fix. --------- Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-03-18Implement floating-point pack/unpack intrinsics for all targets (#6503)Darren Wihandi
* Implement floating-point pack/unpack intrinsics * remove unused functions and update caps in glsl meta file * rename pack capability
2025-03-18Fix `IRVar` hoisting when its already in the right block. (#6626)Sai Praveen Bangaru
Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-03-17Add auto-diff support for `GetOffsetPtr` (#6625)Sai Praveen Bangaru
2025-03-17Fix crash when swizzling non-differentiable types (#6613)Sai Praveen Bangaru
* Fix crash when swizzling non-differentiable types * Update slang-ir-autodiff-fwd.cpp
2025-03-17Add error diagnostic vectors and matrices with disallowed element types (#6596)Anders Leino
- Add the diagnostic messages, and code to emit them - Add some tests This helps to address issue #6183.
2025-03-15Fix lowering of associated types in generic interfaces (#6600)Sai Praveen Bangaru
* Fix lowering of associated types in generic interfaces. * Update diff-assoctype-generic-interface.slang * Fix-up lowering of differentiable witnesses for implicit ops * Update slang-ir-autodiff-transcriber-base.cpp * Fix issue with differentiating type-packs
2025-03-14Implement GetDimensions for structured buffers on WGSL (#6609)Darren Wihandi
* Implement structured buffer GetDimensions for WGSL * byte address buffer fix * enable wgsl test and minor fixups * maybe fix get equivalent structured buffer * remove unnecessary include * clean up some code in meta file
2025-03-13Use an explicit dependency for generated headers instead of source file ↵Ellie Hermaszewska
dependency (#6594) * Simplify text writing for core module headers * Use an explicit dependency for generated headers instead of source file dependency From the CMake Docs > Do not list the output in more than one independent target that may build in parallel or the instances of the rule may conflict. Instead, use the add_custom_target() command to drive the command and make the other targets depend on that one. See the Example: Generating Files for Multiple Targets below. --------- Co-authored-by: Yong He <yonghe@outlook.com>
2025-03-13Correct buffer length calculation in dumpSourceBytes (#6593)Ellie Hermaszewska
No functional change as overallocating was ok, but this was wrong Co-authored-by: Yong He <yonghe@outlook.com>
2025-03-13Add mesh shader output topology checks (#6592)Darren Wihandi
* initial wip * more wip * add test * add unexpected for invalid target * fixups and improve error message * fixups and improve error message * remove incorrect comment --------- Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-03-12Add referenced modules as libraries when creating a session (#6569)Anders Leino
In the legacy compile request based API, the referenced modules are added to the request's linkage libraries as part of compiler option parsing. In the non-legacy compilation API, the argument parsing creates a temprary compile request and so those libraries only survive as options. This change will look for such options when creating an ISession object, and again add the referenced modules to the libraries of the new linkage that's contained in the ISession object. This is done in two steps: 1. Factor out a helper to create a referenced module artifact in the same way as it's done during legacy option parsing. 2. Use the helper function to create artifacts to add to the linkage libararies, when the session is created. This helps to address issue #4760, because it enables passing in downstream modules via options, as is required for the following tests: tests/library/library-test.slang.2 (dx12) tests/library/export-test.slang.2 (dx12)
2025-03-11Set the HLSL supported compiler version to 2018 (#6502)Tony (Atanas) Zlatinski
Co-authored-by: Jay Kwak <82421531+jkwak-work@users.noreply.github.com>
2025-03-11Don't crash when precompiling twice (#6576)cheneym2
Abort precompileForTarget if it's already done. Fixes #6516
2025-03-11IR: Add SPIR-V disassembly for embedded downstream IR dumps (#6529)Mukund Keshava
* IR: Add SPIR-V disassembly for embedded downstream IR dumps When dumping IR that contains embedded downstream SPIR-V code (via EmbeddedDownstreamIR instructions), display the disassembled SPIR-V instead of just showing "<binary blob>". This CL also does: - Adds a new interface for disassembly and get result. - Modify export-library-generics.slang test test to check for the disassembled SPIR-V Fixes #6513 * Add module-dual-target-verify test Fixes #6517 Adds a new test to verify that dxil and spirv targets are stored separately in the precompiled blob. * Fix review comments from cheneym2 * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-03-10UseHighestVersion when calling spirv-link (#6559)cheneym2
Precompiled SPIR-V bits can independently resolve to different versions of SPIR-V. To avoid a linker error about mismatched versions, use a linker feature to automatically use the highest version listed in the modules. Fixes #6548
2025-03-10Add module reference options to options list when parsing them (#6539)Anders Leino
* Add module reference options to options list when parsing them Previously, the module was just added to the compile request directly. This is a problem because the non-deprecated command line option parsing interface IGlobalSession::parseCommandLineArguments just creates a temporary compile request. Therefore these options are currently not detected by the API. This helps to address issue #4760 since it will need to access these modules in order to supply all of the required code. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-03-10Sharpen condition on warning about used capabilities relative to selected ↵Anders Leino
profile (#6538) If the profile/capability in options set, but set to unknown, then don't count the setting as requesting a particular profile/capability. This helps in addressing issue #4760 because the new session-based compilation API always adds a profile setting via Linkage::addTarget, even if the profile is unknown. That caused lots of tests to fail due to unexpected output: "warning 41012: entry point 'computeMain' uses additional capabilities that are not part of the specified profile..." The old compilation request -based API did not add profile/capabiltiy to the options, and so did not generate this warning.
2025-03-07Fix SPIRV generator ID. (#6536)Yong He
2025-03-06Fix a bug in default ctor synthesizing (#6527)kaizhangNV
* Fix a bug in default ctor synthesizing - This is fix for the implementation bug, when a struct has explicit ctor we should not synthesize the default ctor anymore. - When invoke the synthesized ctor converted from initializer list, we should check if the struct is a c-style type if it struct has no synthesized ctor. In this case we should report error because it's invalid to use initializer list here. - The only exception is the unsized array, we still have to fall back to use the legacy initializer list logic to initialize the unsized array until we formalize a proper solution. - update test.
2025-03-07Update build to allow setting external paths (#6528)jarcherNV
* Update build to allow setting external paths Update the build to allow setting user-specific paths for the external modules. This allows building Slang without also fetching the external modules, assuming they are already present elsewhere locally.
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-03-06Get options also from the default target (#6530)Anders Leino
This helps to address issue #4760. The particular issue motivating this fix is that IGlobalSession::parseCommandLineArguments uses a temporary compile request to parse options. The compile request only adds the OptionKind::ForceDXLayout (-fvk-use-dx-layout) to the "current target" which may be the default target, which IGlobalSession::parseCommandLineArguments didn't look for, meaning that options like ForceDXLayout were just ignored. This leads to test failures in tests that rely on this option, e.g. tests/spirv/cbuffer-dx-layout-1.slang.
2025-03-05Support SPIR-V deferred linking option (#6500)cheneym2
The new option "SkipDownstreamLinking" will defer final downstream IR linking to the user application. This option only has an effect if there are modules that were precompiled to the target IR using precompileForTarget(). Until now, the default behavior for SPIR-V was to use deferred linking, and the default behavior for DXIL was to use immediate/internal linking in Slang. This change only affects the SPIR-V behavior such that both deferred and non-deferred linking is supported based on the new option. To support the non-deferred option, Slang will internally call into SPIRV-Tools-link to reconstitute a complete SPIR-V shader program when necessary (due to modules having been precompiled to target IR). Otherwise, if SkipDownstreamLinking is enabled, the shader returned by e.g. getTargetCode() or getEntryPointCode() may have import linkage to the SPIR-V embedded in the constituent modules. Closes #4994 Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-03-05Fix codegen bug when targeting PTX with new API (#6506)Anders Leino
* Add cuda codegen bug repro This just compiles tests/compute/simlpe.slang for PTX with the new compilation API, in order to reproduce a code generation bug. * Detect entrypoint more robustly when applying ConstRef hack during lowring For shaders like tests/compute/simple.slang, which have a 'numthreads' attribute but no 'shader' attribute, the old compile request API would add an EntryPointAttribute to the AST node of the entry point. However, the new API doesn't, and so a certain ConstRef hack doesn't get applied when using the new API, leading to subsequent code generation issues. This patch also checks for a 'numthreads' attribute when deciding whether to apply the ConstRef hack. This closes issue #6507 and helps to resolve issue #4760. * Add expected failure list for GitHub runners Our GitHub runners don't have the CUDA toolkits installed, so they can't run all tests.
2025-03-04Fix option set serialization bug (#6515)Anders Leino
This helps to address issue #4760.
2025-02-28Consolidate multiple inouts/outs into struct (#6435)Mukund Keshava
* Consolidate multiple inout/outs into struct Fixes #5121 VUID-StandaloneSpirv-IncomingRayPayloadKHR-04700 requires that there be only one IncomingRayPayloadKHR per entry point. This change does two things: 1. If an entry point has the one inout or out, or has only ins, then stay with current implementation. 2. If there are multiple outs/inouts, then create a new structure to consolidate these fields and emit this structure. These two code paths are split into two separate functions for clarity. This patch also adds a new test: multipleinout.slang to test this. * Address review comments * Refactor code as per review comments * format code * fix failing tests --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com>
2025-02-28Allow partial specialization of existential arguments. (#6487)Yong He
* Allow partial specialization of existential arguments. * Fix. * Add test case for improved diagnostics. * Fix compile error. * Fix tests. * Fix. * Fix test. * Fix compile issue. * Fix typo. * Address comment.
2025-02-28Implement sparse texture Sample* intrinsics for SPIRV (#6377)Darren Wihandi
* implement sparse residency samples for spirv * udpate test * separate tests to non-combined and combined sampler * remove expected failure * add expected failure for dx12 combined sampler test * remove expected failure * fix submodule merge * add back dx12 test failure --------- Co-authored-by: Yong He <yonghe@outlook.com>
2025-02-28Add Slang-specific intrinsics for integer pack/unpack (#6459)Darren Wihandi
* update hlsl meta * update test * use slang syntax in meta file * improve meta file * fix pack clamp u8 * remove builtin packed types, use typealias instead * fix wgsl pack clamp * fix formatting --------- Co-authored-by: Yong He <yonghe@outlook.com>
2025-02-28Resolve 'extern' types during type layout generation if possible (#6450)Ellie Hermaszewska
* Resolve 'extern' types during type layout generation if possible Closes https://github.com/shader-slang/slang/issues/5994 Closes https://github.com/shader-slang/slang/issues/6437 * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com>
2025-02-28Add WaveGetLane* support for Metal and WGSL (#6371)Darren Wihandi
* support WaveGetLane* for WGSL and Metal * update test and glsl support * address review comments and fix metal test * add missing pragma guard * update test * Revert "update test" This reverts commit f2b97e91c29de154190710580c343bd0764aedbb. * update failing glsl metal test and added new test * make hlsl and glsl outputs similar * update test * disable tests for Metal and cleanup * comment fix * add expected failures * correct expected failures list * remove expected failure * add tests to expected failure --------- Co-authored-by: Yong He <yonghe@outlook.com>
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-27Don't add multiple matrix layout options when creating a session (#6476)Anders Leino
The default matrix layout mode was applied in addition to any related options, and this caused the wrong matrix layout mode to be used. For example, tests/compute/column-major was failing when attempting to migrate to the new compilation API. This helps to address issue #4760
2025-02-27Fix a bug where Session::parseCommandLineArguments returns invalid data (#6461)Anders Leino
This helps to address issue #4760. Co-authored-by: Yong He <yonghe@outlook.com>
2025-02-27Add inner texture type to reflection json (#6416)Devon
* Add inner texture type to reflection json * Add expected result of test * Adjust test expected results * Fix ci test result --------- 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-27Make capability diagnostic message more friendly. (#6474)Yong He
* Make capability diagnostic message more friendly. * Fix. * Fix. * Fix. * Fix test. * Update expected fail setting for aarch64/linux * Fix.
2025-02-27Allow `.member` syntax on vector and scalars. (#6424)Yong He
* Allow `.member` syntax on vector and scalars. * Fix. * fix. * Fix. * update comment. * Fix tests. * Fix warning. * Add more tests.