summaryrefslogtreecommitdiff
path: root/source
AgeCommit message (Collapse)Author
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.
2025-02-27Fix overload resolution for `ModuleDeclarationDecl` (#6483)Sai Praveen Bangaru
* Fix overload resolution for `MemberExp`r's base expression Also fixed an issue where `ModuleDeclarationDecl` priority during overload resolution was inverted. * Made the fix slightly simpler.. * Update overload-resolve.slang
2025-02-27Bump glslang to vulkan-tmp-1.4.309 (#6477)Ellie Hermaszewska
* hotfix slang-rhi * Fix missing include * external/glslang: 15.0.0-37-ga0995c49 -> vulkan-tmp-1.4.309 external/spirv-tools: v2024.4.rc2-44-g3364b982 -> v2024.4.rc2-48-gce37fd67"
2025-02-26Fix regression when using Atomic<T> in struct. (#6472)Yong He
2025-02-26Fix precompiledTargetModule tests (#6455)cheneym2
* Fix precompiledTargetModule tests Add SPIRV-Tool linker support to gfx unit tests and use the linker in precompileModule tests that use precompiled modules to reconstitute SPIRV shaders that were modularly compiled. Fix a Slang reference count bug in the precompile service. * Use sm_6_6 New DXC requires higher version for linkability. * Rename helper function, pass by reference * Link through slang-glslang * Add missing files * Fix metal * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com>
2025-02-26[SPIRV]: Emit missing storage class in atomic insts. (#6456)Yong He
2025-02-26expose value of constant integers in module reflection (#6367)Alexandre Bléron
* Expose value of constant integers in module reflection This commit adds `VariableReflection::getDefaultValueInt` to get the value of a variable if it is a compile-time constant integer. TODO: currently it works only if the initializer expression is an integer literal, references to other constant values are not handled. * Update VarDecl folded constant value during DeclBodyVisitor Constant folding for integer values is already done internally by _validateCircularVarDefinition, this just reuses the result. * Address review comments & formatting * Formatting --------- Co-authored-by: Yong He <yonghe@outlook.com>
2025-02-26Enable friendly-name option for SPIRV dump and validation (#6465)Jay Kwak
2025-02-25Fix a bug with hoisting 'IRVar' insts that are used outside the loop (#6446)Sai Praveen Bangaru
* Fix a bug with hoisting 'IRVar' insts that are used outside the loop - We introduce a 'CheckpointObject' inst and use that to split loop state insts into two pieces (one for within-loop uses and one for outside-loop uses. - This allows the two kinds of uses to be handled separately by the hoisting mechanism - CheckpointObject is then lowered to a no-op after hoisting is complete. * Update slang-ir-autodiff-primal-hoist.cpp * Update slang-ir-autodiff-primal-hoist.cpp
2025-02-25Fix `UseGraph::replace` (#6395)Sai Praveen Bangaru
* Fix `UseGraph::isTrivial()` test. * Fix. * Fix. * Refactor `UseGraph` and `UseChain` * Update slang-ir-autodiff-primal-hoist.cpp * Update all auto-diff locations that handle pointers to treat user pointers as regular values * Update test to use direct-SPIRV only --------- Co-authored-by: Yong He <yonghe@outlook.com>
2025-02-25Fix loading empty structs from structured buffers (#6439)Ellie Hermaszewska
Closes https://github.com/shader-slang/slang/issues/5751
2025-02-24Clone name hint decoration when emiting Undefined (#6415)Jay Kwak
* Clone name hint decoration when emiting Undefined When emiting "Undefined", we lost the information of where it was synthasized from. This prevents us from providing more helpful error messages. The issue was the when we handle "IRLoop", the inputs parameters to the Phi didn't clone the name hint decoration. This commit clones them when emiting "Undefined". * Adding more test case --------- Co-authored-by: Yong He <yonghe@outlook.com>
2025-02-24Legalize array size of SV_TessFactor and SV_InsideTessFactor (#6409)Jay Kwak
* Legalize array size of SV_TessFactor and SV_InsideTessFactor When targeting SPIR-V or GLSL, the type for SV_TessFactor must be float[4]; note that it is not a vector but an array. Similarly the type of SV_InsideTessFactor has to be an array of float[2]. When the user shader declare them as arrays smaller than the required size, Slang will legalize them to the required sizes. Note that it is not the user mistake to declare floar[3] when the hull mode is in "tri", as an example. The unused components are expected to be ignored. Note also that HLSL allows the type to be float[2|3|4] whereas GLSL and SPIR-V requires it to be always float[4]. * Change from "quad" domain mode to "tri" * Handle error case --------- Co-authored-by: Yong He <yonghe@outlook.com>
2025-02-24Fix TypeCheckingCache concurrency and candidate lifetime. (#6444)Yong He
* Fix TypeCheckingCache concurrency. * Fix.
2025-02-24Remove noise() from core library (#6421)cheneym2
noise() is currently marked "unsupported" in Slang documentation, and has also been unsupported in HLSL since SM 2.0 Until now, noise() was present only to prevent compilation errors, but not for any actual use since it returns 0.0 always. Closes #5775
2025-02-23Improve performance when compiling small shaders. (#6396)Yong He
Improve performance when compiling small shaders. Avoid copying witness table entries that are not getting used during linking. Avoid copying auto-diff related decorations and derivative functions during linking, if the user modules doesn't use autodiff. Cache operator overload resolution results on global session, so each new Session doesn't need to repetitively run through overload resolution from scratch.
2025-02-20Fix gradient behavior for min() and max() functions at boundaries. When ↵Sai Praveen Bangaru
input values are equal, the gradient is split evenly between both inputs. (#6411) Co-authored-by: Yong He <yonghe@outlook.com>
2025-02-20Metal fix (#6413)kaizhangNV
Partially fix #6378 * Fix invalid access mode for texture_buffer * Fix texture view create issue in metal In newTextureView, levelRange should represent the mipmap level range, while sliceRange should represent the texture layer range for texture array. But the implement inverse those two wrongly.
2025-02-20Simplify implicit cast ctors for vector & matrix. (#6408)Yong He
* Simplify implicit cast ctors for vector & matrix. * Fix formatting. * Fix tests. * Fix Falcor test. * Mark __builtin_cast as internal.
2025-02-20HLSL: Add 'f' suffix to float literals in code generation (#6381)Mukund Keshava
* HLSL: Add 'f' suffix to float literals in code generation Fixes #6078 1) Previously, Slang would emit HLSL float literals without a suffix (e.g.,"1.5"), which caused DXC to interpret them as 64-bit doubles by default unless the -HV 202x flag was used. This could cause validation errors when these literals were used with intrinsics that only accept 32-bit floats (like ddx, ddy). This change modifies the HLSL emitter to explicitly add 'f' suffix to 32-bit float literals, ensuring they are correctly typed regardless of DXC's version or flags. For example: - "1.5" becomes "1.5f" - "(0.0 / 0.0)" becomes "(0.0f / 0.0f)" for NaN - "float4(1.0, 2.0, 3.0, 4.0)" becomes "float4(1.0f, 2.0f, 3.0f, 4.0f)" 2) Added a test case to verify the behavior with various float literal scenarios including basic literals, intrinsic calls, and vector construction. 3) Remove some tests that were marked as known failures * Add dxil test as suggested by jkwak-work
2025-02-19Support for dynamic array of textures access for Texture footprint. (#6392)Jay Kwak
* Support for dynamic array of textures access for Texture footprint. * Do a check for DXIL for dynamic array/footprint. * format code (#40) --------- Co-authored-by: jsmall-nvidia <jsmall@nvidia.com> Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: Yong He <yonghe@outlook.com>
2025-02-19Force inline functions that takes InputPatch and OutputPatch (#6407)Jay Kwak
This commit inlines functions that takes InputPatch and OutputPatch as the function parameter. Co-authored-by: Yong He <yonghe@outlook.com>
2025-02-19Fix issue with `clamp`'s derivatives at the boundary. (#6403)Sai Praveen Bangaru
2025-02-19Fix zero size array handling in slangc (#6399)Mukund Keshava
* Fix zero size array handling in slangc Fixes #2890 1. Fix zero size array handling in slangc 2. Add new zero size array diagnostic test. * format code * fix review comments --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-02-19Add userAttribs to entryPoints in reflection JSON (#6366)David A Roberts
2025-02-18Add two DXC implementation for CoopVec (#6393)Jay Kwak
2025-02-18Add warning for ignored binding attributes on uniforms (#6373)Mukund Keshava
Fixes #4251 When binding attributes (like [[vk::binding]]) are specified on uniforms that get packed into the default constant buffer, these binding attributes are effectively ignored since the uniform will always be placed at descriptor set 0, binding 0. This can be confusing for users who expect their explicit bindings to take effect. This change adds a new warning (71) that informs users when their binding attributes on uniforms will be ignored, and suggests declaring the uniform inside a constant buffer to preserve the explicit binding. The warning helps users understand: 1. Why their binding attribute isn't having the expected effect 2. That the uniform is being packed into the default constant buffer 3. How to fix it by using a constant buffer declaration Added test case in tests/bugs/binding-attribute-ignored.slang to verify the warning behavior. Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-02-17slang: Fix empty VARARGS issue(#6332) (#6372)Mukund Keshava