summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2025-05-14support specialization constant sized array (#6871)kaizhangNV
Close #6859 Goal of this PR We want to support an array whose size can be specialization constant for shared/global variable e.g. layout (constant_id = 0) const uint BLOCK_SIZE = 64; shared float buf_a[(BLOCK_SIZE + 5) * 4]; Overview of the solution: During IndexExpr check, we will loose the restriction to allow SpecConst passing, but the size parameter will not be a constant value because it cannot be folded into a constant, so we will make it follow the same logic as generic parameter value, and the size will be represented by FuncCallIntVal/PolynomialIntVal/DeclRefIntVal. During IR lowering, we will detect whether there is spec constant in the IntVal, and wrap the IRInst with a SpecConstRateType, and propagate the type though the lowering logic, such that the IntVal representing the array size will have SpecConstRateType. During spirv emit stage, if we detect that a IRInst has SpecConstRateType, we will emit it as SpecConstantOp. We have to implement new logic to emit OpSpecConstantOp, the existing emit logic doesn't support emitting OpSpecConstantOp, especially this op can embed arithmetic operation at global scope, where we can only emit arithmetic instruct at local. But there are only few instructs we need to support. Overview of the solution: This PR doesn't support generic, and we will create a separate PR to extend that, tracked in #6840.
2025-05-14Make Command Line Reference readthedocs compatible (#7048)aidanfnv
This change modifies the code that generates the Command Line Reference doc to output H2 headings in place of H1 headings, and H3 in place of existing H2, so that readthedocs will not treat the additional H1 headings as titles. This change also regenerates the Command Line Reference doc, as the current copy in the repo appears to be quite out-of-date. The existing copy is also encoded as UTF-16LE, whereas the other docs are all UTF-8. The regenerated doc is also UTF-8, and all I did to generate that was run slangc.exe -help-style markdown -h > docs\command-line-slangc-reference.md 2>&1 after building slangc on Windows. This change also adds GitHub actions workflows to check the contents of the doc, fail if a regenerated version needs to be checked in, and provide an option to regenerate it with a bot, all in a similar manner to User Guide TOC regeneration. The doc writer was producing different results from my local build until I changed how the writer sorts the shader stages. In the action, the order of pixel and fragment was reversed, despite the only difference from my local build being the OS. --------- Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-05-14Add explanation for SV_InstanceID usage difference from SPIR-V (#7072)aidanfnv
Closes https://github.com/shader-slang/slang/issues/6805 This change adds a note to the SPIR-V target specific doc that SV_InstanceID does not map directly to SPIR-V's BuiltIn InstanceIndex, and adds a more detailed explanation of the difference, its motivation, and how to derive the actual value equivalent to BuiltIn InstanceIndex with an example. --------- Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-05-14Error out on invalid vector sizes (#7076)Darren Wihandi
* Error out on invalid vector sizes * Remove unnecessary include * Fix incorrect assert * Add test
2025-05-13Add Payload Access Qualifiers to the raytracing examples (#7092)Gangzheng Tong
2025-05-13Fix invalid memory dereference in lower-to-ir (#7080)Jay Kwak
A reference-counting pointer type released a heap memory object when it return from the function and we are trying to dereference it later. We should increment the ref-count by one by assigning it to the context before returning.
2025-05-13Support Array Sizes using Generic arguments to be initialized via {} (#6720)Sruthik P
* Add support for Array Sizes using Generic arguments to be initialized via {} Fixes one subissue of #6138 This change adds support for initializing Arrays with Generic size arguments via {} and adds a test to verify it. The change checks for an array whose size parameter is a GenericParamIntVal and since the size of such an array will be known at link time, is not considered as a case of the size not being known statically. * Add support for Array Sizes using Generic arguments to be initialized via {} Fixes one subissue of #6138. Fixes the issue #6958. This change adds support for initializing Arrays with Generic size arguments via {} and adds a test to verify it. Support is added by means of adding a new AST Expr node that lowers down to the IR MakeArrayFromElement and the emission of a diagnostic is replaced with the creation of this new AST Expr node. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-05-13Add half-precision matrix type aliases in GLSL (#7066)James Helferty (NVIDIA)
Fixes #6708 This commit adds type aliases for half-precision matrices, including f16mat3x2, f16mat3x3, f16mat3x4, f16mat4x2, f16mat4x3, and f16mat4x4. Convenience aliases for square matrices (f16mat2, f16mat3, f16mat4) are also added. This commit introduces a new test file that validates the usage of half-precision types in a compute shader context.
2025-05-12Make CUDA version capabilities reach NVRTC (#7074)Theresa Foley
Fixes #7049 The root cause of the problem in #7049 is simply that newer NVRTC versions produce a warning when asked to generate code for older CUDA SM versions, and the default that Slang was requesting compilation for was old enough to trigger that warning, and thus trip up the test case (which only looks at the first diagnostic produced by the downstream compiler). Superficially, the fix was easy: change the test case in question (`tests/diagnostics/local-line.slang`) to request `-capability cuda_sm_8_0`, the minimum version supported by current NVRTC. Unfortunately, the simple fix required some other fixes in order to actually work. The capability system includes capability names of the form `cuda_sm_*_*`, but specifying such a capability had *no* impact on the CUDA SM version passed in when invoking NVRTC. Instead, only the CUDA SM versions requested in the implementation of intrinsics in the core module were affecting the version number passed down. This change adds logic to `slang-compiler.cpp` to take explicitly requested capabilities into account when inferring the CUDA SM version to be passed downstream. A more complete fix would also add similar logic for all the other targets. Unfortunately... yet again... that fix wasn't enough to make things work as expect. Now I had the problem that requesting `-capability cuda_sm_8_0` was actually causing the NVRTC invocation to request CUDA SM version **9.0**! The underlying problem *there* was that the `slang-capabilities.capdef` file has defined certain capability names in a way that implies atomic capabilities much higher than one would expect. E.g., the `cuda_sm_8_0` alias was including HLSL `sm_5_0`, but then `sm_5_0` in turn included `_cuda_sm_9_0`. The fix, for now, is to change the definitions in `slang-capabilities.capdef` to not have the counter-intuitive definitions for `cuda_sm_*_*`. With this set of fixes, the test failure in the original bug report no longer occurs. The work that went into this change suggests several larger-scope fixes that would be good to pursue: * Ideally the capability definitions would have some sort of validation checking to make sure that counter-intuitive results like `cuda_sm_8_0` requesting CUDA SM 9.0 do not occur. * The translation of capabilities over to version numbers for a downstream compiler should be expanded to cover other targets, and not just CUDA. It might be better/simpler to just pass the capabilities themselves to the downstream compiler, since it is possible that a downstream compiler could have more fine-grained enable/disable options than a simple version number. * The entire approach to computing version numbers required for downstream compilation should be cleaned up so that we don't have this duplication between the capabilities that represent those versions and separate syntactic constructs that are used to "request" those versions as part of code generation. * We are very much at the point where we should consider dropping the current behavior where a profile name or capability like `sm_5_0`, that is specific to a single target or a subset of targets, also implies a set of comparable capabilities for other targets.
2025-05-12Ensure to emit 32-bit type for bitfield operations for SPIRV (#7046)kaizhangNV
Close #7014
2025-05-12Cleanups related to RIFF support (#7041)Theresa Foley
2025-05-12add missing namespace std:: for nullptr_t (error while building with clang) ↵Pierre EVEN
(#7059) Co-authored-by: Julius Ikkala <julius.ikkala@gmail.com>
2025-05-12cluster acceleration structure optix 6431 (#7028)Harsh Aggarwal (NVIDIA)
* Add cluster geometry intrinsics for ray tracing - Added GetClusterID() method to HitObject class - Added CandidateClusterID() and CommittedClusterID() methods to RayQuery class - Added SPV_NV_cluster_acceleration_structure extension support - Added GL_NV_cluster_acceleration_structure extension support - Added test files for RayQuery and HitObject cluster methods Fixes #6431 * OpRayQueryGetIntersectionClusterIdNV - unrecognized spirv Disabling spirv backend for SPV_NV_cluster_acceleration_structure hlsl.meta.slang(18674): error 29100: unrecognized spirv opcode: OpRayQueryGetIntersectionClusterIdNV result:$$int = OpRayQueryGetIntersectionClusterIdNV &this $iCandidateOrCommitted; ^~~~~~ hlsl.meta.slang(18670): error 30019: expected an expression of type 'int', got 'void' return spirv_asm ^~~~~~~~~ ninja: build stopped: subcommand failed. * 6431 - Fix spirv opcode * Remove tests * Add relevant tests * Review - Simplify tests
2025-05-12cuda: Add more formats for texture read/write (#7012)Mukund Keshava
* WiP: Add more formats for texture reads * fix test * format code * add float2/float4 versions for 1D and 3D as well * fixed review comment * fix review comments --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2025-05-11Add a new option "-capability" to slang-test and render-test (#7054)Jay Kwak
2025-05-10Fix local constants in switch cases (#7053)Julius Ikkala
* Fix using local constants in switch cases * Add test * format code * Always lower switch cases with exprVal * Fix formatting --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Yong He <yonghe@outlook.com>
2025-05-10Add debug information for slang inling (#6621)Mukund Keshava
2025-05-09Fix SPIRV unsigned to signed widening casts (#7051)Darren Wihandi
* Fix unsigned to signed casts for SPIRV * Add test * Fix ICE crash
2025-05-10Update build to allow setting more external paths (#7044)lujinwangnv
* Update build to allow setting more external paths Update the build to allow setting user-specific paths for the external modules: glm, imgui, slang-rhi, and tinyobjloader.
2025-05-09Fix various intptr_t issues by defining its width in `getIntTypeInfo` (#6786)Julius Ikkala
* Define a bit size for the intptr types * Fix intptr_t sign * Extend intptr test to check for previously broken operations * Fix intptr vector test on CUDA * Handle intptr size in getAnyValueSize * Fix formatting * Try with __ARM_ARCH_ISA_64 * On macs, int64_t != intptr_t Yikes * Move define to prelude header * Also check apple in host-prelude * Fix define location
2025-05-09Fixed name mangling of generic extensions (#6671)Ronan
* Fixed name mangling of generic extensions * Added tests for generic extensions linking. - Disabled bugs/gh-6331.slang since it now triggers an assertion error revealed by the new version of the mangler. * Re-enabled test gh-6331 (fixed by a5efbb1b775afb2f6b29b37d39947c41744bb005) --------- Co-authored-by: Yong He <yonghe@outlook.com>
2025-05-09Destroy unused witness table after hoisting (#7009)Gangzheng Tong
* Destroy unused witness table after hoisting
2025-05-09Restore Properties section name in stdlib reference (#7042)aidanfnv
2025-05-08Fix broken links in Slang docs (#7039)aidanfnv
This change fixes some broken links/anchors in the Slang docs that I found after running a link checker tool on the readthedocs site. Some of these were broken on GitHub Pages as well, such as anchors with apostrophes or docs that were moved. The doc writer change adds an explicit .html extension to Parameter links, so that Sphinx/RTD does not treat it as an anchor.
2025-05-07Add new Valve vfx sections for mesh shaders. (#7030)Dan Ginsburg
2025-05-07[CUDA] Fix surface write intrinsics (#7004)Simon Kallweit
* fix cuda surface write intrinsics * format code (#7023) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --------- Co-authored-by: Mukund Keshava <mkeshava@nvidia.com> Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-05-06bitcast require the input has same width with result type (#7018)kaizhangNV
bitcast requires the input has same width with result type, this PR ensures that we always lower the bitcast IR instruction satisfies this requirement. Close #7017.
2025-05-07Output default parameter values on language server hover (#6902)Ellie Hermaszewska
* Output default parameter values on language server hover Closes https://github.com/shader-slang/slang/issues/5782 * Add parens around binay expressions in ast print * More cases in ast print test * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-05-06Parse char literals as integers (#6989)Julius Ikkala
* Parse char literals as integers * Fix formatting * Parse escaped chars correctly --------- Co-authored-by: Yong He <yonghe@outlook.com>
2025-05-06Add interger pack/unpack intrinsic to glsl (#6997)kaizhangNV
* Add interger pack/unpack intrinsic to glsl Add unpack8, unpack16 and pack32 intrinsics to glsl. * add unit test * fix lowering logic for 'bitcast' * format
2025-05-06Retry when a few unit tests failed. (#6912)Jay Kwak
This PR allows the failed unit-tests to be retried at the end as in a single threaded manner. The purpose of the retry is to increase the stability of CI.
2025-05-06Update C++ standard to C++20 (#6980)Ellie Hermaszewska
* Correct incorrect enum usage on metal * Update C++ standard to C++20 Closes https://github.com/shader-slang/slang/issues/6945 * use bit_cast
2025-05-05Remove extra User Guide readthedocs TOC entries by turning extra H1 headings ↵aidanfnv
into H2 (#6986) readthedocs treats H1 headings as document titles in the sidebar table of contents. This change turns all extra H1 headings into H2 in the "Metal-Specific Functionalities" doc. These extra H1 headings seem to be errors, given that they are inconsistent, and the H2s after them do not belong. For examples, the heading "Resource Types" is H2, but "Array Types" is H1, and "Mesh Shader Support" is H1, but the following "Header Inclusions and Namespace" is not a subtopic of the Mesh Shader Support.
2025-05-05Fix the intermittent failures of tests/autodiff/auto-differential-type (#7006)Jay Kwak
The use of `_wfopen_s()` was incorrect in a way the the result value had to be checked. However, even with a proper handling of the failed case, the repro-rate was same. The issue was reproduced at 5%~20% rate with the following commands, build/Release/bin/slang-test.exe tests/autodiff/auto-differential-type -api dx11 -use-test-server -server-count 8 Co-authored-by: Yong He <yonghe@outlook.com>
2025-05-05Add a new capability hlsl_2018 that avoid using select/and/or (#7003)Jay Kwak
Co-authored-by: Yong He <yonghe@outlook.com>
2025-05-05Add countbits 16-bit and 8-bit support (#6433) (#6897)sricker-nvidia
Change adds 16-bit and 8-bit support for countbits intrinsic. In cases where a backend's native counbits lacks support, support is emulated. New tests are added for 16-bit and 8-bit support. Additional testing added for 32-bit and minor updates made to 64-bit countbits.
2025-05-05Correct incorrect enum usage on metal (#6994)Ellie Hermaszewska
2025-05-03Add IREnumType to distinguish enums from ints and each other (#6973)Julius Ikkala
* Add IREnumType to distinguish enums from ints and each other * Add issue example as test * format code * Add expected test output * Fix peephole optimization hanging No idea why this PR triggered this, but there seems to have been a clear bug here anyway, so may just as well fix it now. * Move enum lowering later * Add linkage decoration to enum type * Use filecheck-buffer instead of expected.txt * Fix comment * Make enum casts actually use IR enum casts They were all BuiltinCasts by accident * Lower enum type before VM * Deal with rate-qualified types in enum cast * Allow any value marshalling for enum types * Handle new enum instructions in a couple more switches * Fix formatting --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-05-02Fix seg-fault in cudaCodeGenBug test (#6985)Jay Kwak
`cudaCodeGenBug` is expected to fail on Linux, because the variable `code` is nullptr. When the next test tried to dereference, it causes a seg-fault.
2025-05-02Fix build on GCC 15 (#6971)Julius Ikkala
* Fix build on GCC 15 * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-05-02Fix intermittent failure of slang-unit-test-tool/ReplayRecord (#6981)Jay Kwak
* Fix intermittent failure of slang-unit-test-tool/ReplayRecord Three problems are addressed: 1. the graphics driver sometimes returns nullptr from GetShaderIdentifier 2. `findRecordFileName()` may not find any records at all. 3. the return value from cleanupRecordFiles() overwrote the error value in `res` and it returned SLANG_OK even when there were errors. * Fix compiler warnings on Windows
2025-05-02Disable an always failing test, partial resident test with dx12 (#6983)Jay Kwak
2025-05-02Add tables of contents to user guide for use on readthedocs (#6979)aidanfnv
This change adds hidden (commented out) tables of contents to the index of the User Guide, as well as each of the additional chapters, so that readthedocs will render the User Guide structure.
2025-05-01Fix comment typos in the triangle's main.cpp example (#6976)FeuFeve
* Fix comment typos in the triangle's main.cpp example * 2nd fix
2025-05-01Add fwidth_coarse and fwidth_fine functions (#6941)pdeayton-nv
Fixes #6940. Add new Slang fwidth_coarse and fwidth_fine functions, similar to GLSL's fwidthCoarse and fwidthFine. Move the implementation of the GLSL functions from glsl.meta.slang to hlsl.meta.slang. Update the existing spirv/fwidth.slang test with the new functions, and add a new hlsl-intrinsic/fragment-derivative.slang test to test HLSL, SPIR-V, and GLSL targets for the new functions.
2025-05-01Update falcor perf test path (#6975)jarcherNV
Update the falcor perf test path environment variable so that it checks existing paths only after the build path. This is needed to prevent it from accidentally using a previously installed version of Slang.
2025-05-01Modify markdown writing to produce readthedocs pages (#6904)aidanfnv
This commit makes multple changes to the slang doc markdown writer to make the stdlib reference pages usable with readthedocs. - Adds tables of contents at the bottom of every page with children. TOCs contain category landing pages where applicable and contain uncategorized child pages - Changes links on the pages to use relative paths instead of absolute paths - Changes anchor tags to use HTML syntax instead of markdown syntax The overall TOC on readthedocs will look the same as the TOC seen on the existing docs website, and I have verfified that links and anchors will still work. The tables of contents generated for use on readthedocs would be visible on the existing docs website. This change wraps the TOCs in a comment block, so that it will be hidden from view. The readthedocs build script can filter out the comments to unhide the TOC inside and still properly render it there with it remaining hidden when viewed elsewhere. --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
2025-05-01Smoke test WASM as a part of CI (#6969)Jay Kwak
* Simplify build of slang-wasm * Add smoke-test for slang-wasm in ci * Avoid git-clone playground
2025-04-30Add `IOpaqueDescriptor::descriptorAccess`. (#6967)Yong He
* Add `IOpaqueHandle::descriptorAccess`. * Update doc. * fix.
2025-04-30Initial support for immutable lambda expressions. (#6914)Yong He
* Initial support for immutable lambda expressions. * More diagnostics, and langauge server fix. * Language server fix. * Fix bug identified in review. * Add expected result. * Update expected result.