summaryrefslogtreecommitdiffstats
path: root/tools/slang-unit-test
Commit message (Collapse)AuthorAge
* Use symbol alias instead of wrapper synthesis to implement link-time types. ↵Yong He2025-10-07
| | | | | | | | | | | | | | | | | | | | | | | | | | (#8603) This change achieves link-time type resolution with a different mechanism. For `extern struct Foo : IFoo = FooImpl;`, instead of synthesizing a wrapper type `Foo` that has a `FooImpl inner` field and dispatches all interface method calls to `inner.method()`, this PR completely removes this synthesis step, and instead just lower such `extern`/`export` types as `IRSymbolAlias` instructions that is just a reference to the type being wrapped. Then we extend the linker logic to clone the referenced symbol instead of the SymbolAlias insts itself during linking. By doing so, we greatly simply the logic need to support link-time types, and achieves higher robustness by not having to deal with many AST synthesis scenarios. Closes #8554. --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Add check for NVRTC backend in unit test cudaCodeGenBug (#8611)Sami Kiminki (NVIDIA)2025-10-06
| | | | | | | Test `slang-unit-test-tool/cudaCodeGenBug.internal` requires that the CUDA toolkit is available. Add a check for the NVRTC backend to avoid a failure when this is not the case. Fixes #6636
* Fix crash when compiling specialized generic entrypoint containing a static ↵Yong He2025-09-10
| | | | | | | | | | | | | | | | | | | | | const decl. (#8392) Closes #8184. We fixed three issues with this regression test: 1. After generating IR for a `SpecializeComponentType`, we should also strip the frontend decorations from the IR so there is no HighLevelDeclDecoration that will go into the backend. 2. When lowering a static const inside a generic function, we should not give the static const a linkage, because it won't such constant will not appear in global scope. Trying to give it a linkage decoration will lead to the parent generic (for the function) to have two duplicate Export/Import decorations with different mangle names, and confuses the linker. 3. Make sure internal exceptions does not leak through `IComponentType::getEntryPointCode`/`getTargetCode`.
* Relax restriction on using link-time types for shader parameters. (#8387)Yong He2025-09-05
| | | | | | | | | This change relaxes a previous restriction on link-time types and constants, so that we now allow them to be used to define shader parameters. Doing so will result in a parameter layout that is incomplete prior to linking. The PR added a test to call the reflection API on a fully linked program and ensure that we can report correct binding info.
* Add static functions to create blobs from data (#8179)jarcherNV2025-08-15
| | | | | | | | Add helper functions to create ISlangBlob and load module data from source. --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Allow specializing entrypoints with generic value args or variadic types ↵Yong He2025-08-09
| | | | | | from API (#8119) Closes #8110. Closes #8011.
* Fix FunctionReflection getName() returning null for overloaded functions (#8113)Copilot2025-08-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using Slang reflection API to find functions by name in a type, `FunctionReflection::getName()` would return `nullptr` for overloaded functions instead of the expected function name. The issue occurred in `spReflectionFunction_GetName` when `findFunctionByNameInType` returned a `SlangReflectionFunction` wrapping an `OverloadedExpr` (for overloaded functions) instead of a single `DeclRef<FunctionDeclBase>`. The `convertToFunc()` function would fail for `OverloadedExpr` objects, causing `getName()` to return `nullptr`. **Example of the bug:** ```cpp // This code would fail before the fix public interface IBase { public void step(inout float f); } public struct Impl : IBase { public void step(inout float f) { f += 1.0f; } } // Using reflection API: auto implType = reflection->findTypeByName("Impl"); auto stepFunction = reflection->findFunctionByNameInType(implType, "step"); auto name = stepFunction->getName(); // Would return nullptr ``` **Fix:** Modified `spReflectionFunction_GetName` to handle overloaded functions by falling back to the name of the first overload candidate when `convertToFunc` fails. This follows the same pattern already used by `spReflectionFunction_specializeWithArgTypes`. The fix ensures that: - Overloaded function containers return the correct function name - Individual overload candidates also return their names correctly - Non-overloaded functions continue to work as before - No regression in existing functionality **Testing:** Added comprehensive test cases covering both the original issue scenario and explicit function overloading. All existing reflection tests continue to pass. Fixes #8047. <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- 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: 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>
* Add reflection api for overload candidate filtering. (#8066)Yong He2025-08-06
| | | | | | | | | | | | | * Add reflection api for overload candidate filtering. * Fix API. * Fix. * Update build. * Update test. * Update formatting.
* disable ray-tracing-pipeline test (#8023)Jay Kwak2025-08-01
|
* Fix bug in ci test (#8005)Jay Kwak2025-07-31
| | | | | | | | | | This commit fixes two problems. 1. uninitialized file handle for lock-file test 2. uninitialized static variable for lock-file test The first bug is more of speculartive rather than actual bug. The second bug was causing heap corruption when it was retried, because the counter was not reset to zero on "retry" and it wrote data to an invalida range in an array.
* Fix findFunctionByNameInType to preserve functions with different signatures ↵Copilot2025-07-22
| | | | | | | (#7827) findFunctionByNameInType was only returning one function when multiple functions existed with the same name but different signatures. This broke reflection functionality for extension methods. Fix the issue by changing findDeclFromStringInType by not calling maybeResolveOverloadedExpr if checkedTerm is overloaded functions. We still call maybeResolveOverloadedExpr when any candidates in the overloaded list is not DeclRefExpr referencing a function.
* Fix Conditioanl<T, false> fields with a semantic. (#7855)Yong He2025-07-22
| | | | | | | * Fix Conditioanl<T, false> fields with a semantic. * Add unit test. * Fix test.
* Hide atomics struct from reflection api (#7520)James Helferty (NVIDIA)2025-06-26
| | | | | | | | | | | | | | | | | | | | * Atomic reflection unit test Test that Atomic<int> is reflected as a scalar/int instead of a struct named Atomic. * Hide AtomicType from reflection Leverage the fact that returned variables go through convert() to centralize the unwrapping of the AtomicType struct. Fixes #6257 * Clean up unit test a bit - rename bar to buf (since one of them is not Atomic and thus not a barrier) - validate deeper into the fields of bufC - remove debug code
* Fix retry logic for unit test (#7471)Jay Kwak2025-06-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix the ignored unit-tests on retry * Retrigger CI * Add more error messages * Don't use test-server for retry of unit-test to see error messages * Clean up cl.yml Remove 'has-gpu' because it is unused after debug became full-gpu-test. Renamed files to make the meaning more clear: - Renamed expected-failure.txt to expected-failure-via-glsl.txt - Renamed expected-failure-github-runner.txt to expected-failure-no-gpu.txt * Rename cpu-hello-world.slang to avoid name conflict to example We have an example whose executable name is cpu-hello-world.exe. It gets built when you run `cmake --build`, but it gets overwritten by slang-test when it tests `tests/cpu-program/cpu-hello-world.slang`. This PR renames to avoid the name conflict. * Remove debug code --------- Co-authored-by: Yong He <yonghe@outlook.com>
* Fix API changes from separate debugging support (#7397)jarcherNV2025-06-12
| | | | | | Recent separate debugging support added two new functions which broke backwards compatibility. This change restores the old API and moves the new functions to an IComponentType2 interface which can be used if separate debug files are needed.
* Add command line option for separate debug info (#7178)jarcherNV2025-06-06
| | | | | | | | | | | | | * Add command line option for separate debug info Add command line arg -separate-debug-info which, if provided, produces both a .spv and a .dbg.spv file. The .dbg.spv file contains full debug info and the .spv file has all debug info stripped out. Also add a DebugBuildIdentifier instruction to store a unique hash in both the output files, so they can be more easily matched together. A matching API is provided to allow using the Slang API to retrieve a base and debug SPIRV as well as the debug build identifier string.
* Clean up a dead code forgot to delete (#7358)Jay Kwak2025-06-05
|
* Break down record replay to individual tests to avoid timeout (#7340)Jay Kwak2025-06-04
| | | | | | | | | | | | | | | | * Break down RecordReply to individual tests to avoid timeout In Debug build, RecordReplay unit-test was timing out. It was running six tests all in one unit-test, but this commit breaks it down to individual test so that each unit test can be done within the timeout limit. This issue has seen only in Debug build but it has been unnoticed because even when the test failed with test-server, it was still passing on its retry because the time-out applies only when using test-server. * Reduce the retry from 2 times to 1 time * Remove RecordReplay from expected failure
* fix the break to make sure only valid data will be accessed (#7148)Gangzheng Tong2025-05-17
|
* Cleanups related to RIFF support (#7041)Theresa Foley2025-05-12
|
* Fix seg-fault in cudaCodeGenBug test (#6985)Jay Kwak2025-05-02
| | | | | `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.
* Fix intermittent failure of slang-unit-test-tool/ReplayRecord (#6981)Jay Kwak2025-05-02
| | | | | | | | | | | * 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
* Add Slang Byte Code generation and interpreter. (#6896)Yong He2025-04-28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add Slang Byte Code generation and interpreter. * Fix compile issues. * format code * More compile fix. * Fix clang issue. * Fix more clang issues. * Another clang fix. * Fix clang issues. * Fix another clang issue. * Fix wasm build. * Update building.md * Fix test-server. * Fix compile error. * Fix bug. --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Added getCanonicalGenericConstraints2 (sorts constraints and allows more ↵Ronan2025-04-26
| | | | generic expressions) (#6787)
* Return non-escaped strings from user-defined attributes (#6735)aidanfnv2025-04-07
| | | | | | | | | Fixes #6624 This commit changes the behavior of getArgumentValueString() to return the string's value, instead of returning the string's token, as that token also contains the surrounding quotation marks. This commit also modifies the relevant unit test accordingly, to not check for the surrounding quotations.
* Fix codegen bug when targeting PTX with new API (#6506)Anders Leino2025-03-05
| | | | | | | | | | | | | | | | | | | | | | * 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.
* Improve performance when compiling small shaders. (#6396)Yong He2025-02-23
| | | | | | | 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.
* Disallow only resources in constant buffers in parameterblocks on metal (#6342)Ellie Hermaszewska2025-02-13
| | | | | | | | | | | | | * Neaten metal parameter block checking * Disallow only resources in constant buffers in parameterblocks on metal closes https://github.com/shader-slang/slang/issues/6200 * add unit test for metal parameterblock cbuffer --------- Co-authored-by: Yong He <yonghe@outlook.com>
* Reflection Fixes. (#6346)Yong He2025-02-13
| | | | | | | | | | | * Fix 6317. * Fixes #6316. * Fix cmake preset. --------- Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
* Feature/initialize list side branch (#6058)kaizhangNV2025-02-05
| | | | | | | | | | | | | | | | | | | | | | * SP004: implement initialize list translation to ctor - We synthesize a member-wise constructor for each struct follow the rules described in SP004. - Add logic to translate the initialize list to constructor invoke - Add cuda-host decoration for the synthesized constructor - Remove the default constructor when we have a valid member init constructor - Disable -zero-initialize option, will re-implement it in followup (#6109). - Fix the overload lookup issue When creating invoke expression for ctor, we need to call ResolveInvoke() to find us the best candidates, however the existing lookup logic could find us the base constructor for child struct, we should eliminate this case by providing the LookupOptions::IgnoreInheritance to lookup, this requires us to create a subcontext on SemanticsVisitor to indicate that we only want to use this option on looking the constructor. - Do not implicit initialize a struct that doesn't have explicit default constructor. Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Fix geometry shader related modifier lowering. (#6197)Yong He2025-01-28
| | | | | | | | | | | * Fix geometry shader related modifier lowering. * Cleanup. * Delete obselete test. * Enable geometryShader test on windows only. * Fix test.
* Add a unit test to cover type-conformance compilation API. (#6178)Yong He2025-01-28
| | | Co-authored-by: Anders Leino <aleino@nvidia.com>
* Cache and reuse glsl module. (#6152)Yong He2025-01-22
| | | | | | | | | | | * Cache and reuse glsl module. * Fix. * Implement record/replay for the new api. * Fix record replay. * Fix test.
* Fix argument buffer tier2 layout computation. (#6101)Yong He2025-01-15
|
* Create DirectDeclRef when creating Decl to prevent invalid dedup. (#5945)Yong He2025-01-03
| | | | | | | | | * Create DirectDeclRef when creating Decl to prevent invalid dedup. * Fix test. * fix * update slang-rhi
* Fix parameter location reflection for pure data paramblocks. (#5956)Yong He2025-01-03
|
* Fix metadata of register space and varying params. (#5906)Yong He2024-12-18
|
* Support specializing generic entrypoints in `findAndCheckEntryPoint`. (#5890)Yong He2024-12-17
|
* Fix entrypoint auto discovery logic. (#5885)Yong He2024-12-17
| | | | | | | | | * Fix entrypoint auto discovery logic. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Fix `getArgumentValueFloat` when arg is int. (#5888)Yong He2024-12-18
| | | | | | | | | * Fix `getArgumentValueFloat` when arg is int. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Fix attribute reflection. (#5823)Yong He2024-12-11
| | | | | | | * Fix attribute reflection. * Fix. * Fix.
* Fix reflection for pointer element types. (#5797)Yong He2024-12-09
| | | | | | | | | * Fix reflection for pointer element types. * Fix. --------- Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
* Change how DeclRef::toText works (#5592)Sai Praveen Bangaru2024-11-20
| | | | | | | * Change how DeclRef::toText works We now ignore the decl-ref heirarchy since that only includes nodes with specialization info & simply walk up the tree of decls, while emitting any specializations present in the decl-ref. * Update some tests. Add cases for direct refs to generic params & Lookup decl refs
* Correct include dir for libslang (#5539)Ellie Hermaszewska2024-11-13
| | | | | | | | This stops adding the repo root to the include path for anything linking with slang. This enabled a bunch of convenient includes, but might lead to confusing behavior for anyone including slang. Not to mention differences including it from an install vs source. Co-authored-by: Yong He <yonghe@outlook.com>
* Move switch statement bodies to their own lines (#5493)Ellie Hermaszewska2024-11-05
| | | | | | | | | * Move switch statement bodies to their own lines * format --------- Co-authored-by: Yong He <yonghe@outlook.com>
* formatEllie Hermaszewska2024-10-29
| | | | | | | * format * Minor test fixes * enable checking cpp format in ci
* Fix several bugs with `specializeWithArgTypes()` (#5365)Sai Praveen Bangaru2024-10-23
| | | | | * Fix several bugs with `specializeWithArgTypes()` * Make all types L-values for the purposes of reflection API resolution
* Fix entrypoint naming in glsl backend. (#5320)Yong He2024-10-16
|
* Fix type checking on generic extensions. (#5316)Yong He2024-10-15
| | | Add fcpw library to test suite.
* Move C interface from slang.h to slang-deprecated.h (#5301)Ellie Hermaszewska2024-10-15
| | | | | | | | | | | | | | | | | | | | | | | | | * Squash redundant move warnings * Move C interface from slang.h to slang-deprecated.h spGetBuildTagString remains, because it's useful to have before the global session exists. This C API is used quite pervasively in the C++ helpers (for example slang::UserAttribute. It's not trivial to move these to slang-deprecated.h as they're entangled with some enums which are themselves used elsewhere in the compiler. The fact that these helpers use the C API can be viewed as an implementation detail for now, and this usage moved to slang-deprecated in due course. Closes https://github.com/shader-slang/slang/issues/4758 * Squash warnings for our usage of our deprecated API --------- Co-authored-by: Yong He <yonghe@outlook.com>