| Commit message (Collapse) | Author | Age |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(#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>
|
| |
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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`.
|
| |
|
|
|
|
|
|
|
| |
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 helper functions to create ISlangBlob and load module data from
source.
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
|
| |
|
|
|
|
| |
from API (#8119)
Closes #8110.
Closes #8011.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
* Fix API.
* Fix.
* Update build.
* Update test.
* Update formatting.
|
| | |
|
| |
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
(#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.
* Add unit test.
* Fix test.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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 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>
|
| |
|
|
|
|
| |
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
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.
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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
|
| | |
|
| | |
|
| |
|
|
|
| |
`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
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.
* 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>
|
| |
|
|
| |
generic expressions) (#6787)
|
| |
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
* 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>
|
| |
|
|
|
|
|
|
|
|
|
| |
* Fix 6317.
* Fixes #6316.
* Fix cmake preset.
---------
Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
* Cleanup.
* Delete obselete test.
* Enable geometryShader test on windows only.
* Fix test.
|
| |
|
| |
Co-authored-by: Anders Leino <aleino@nvidia.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
* Cache and reuse glsl module.
* Fix.
* Implement record/replay for the new api.
* Fix record replay.
* Fix test.
|
| | |
|
| |
|
|
|
|
|
|
|
| |
* Create DirectDeclRef when creating Decl to prevent invalid dedup.
* Fix test.
* fix
* update slang-rhi
|
| | |
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
| |
* Fix entrypoint auto discovery logic.
* format code
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
|
| |
|
|
|
|
|
|
|
| |
* Fix `getArgumentValueFloat` when arg is int.
* format code
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
|
| |
|
|
|
|
|
| |
* Fix attribute reflection.
* Fix.
* Fix.
|
| |
|
|
|
|
|
|
|
| |
* Fix reflection for pointer element types.
* Fix.
---------
Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
|
| |
|
|
|
|
|
| |
* 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
|
| |
|
|
|
|
|
|
| |
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
* format
---------
Co-authored-by: Yong He <yonghe@outlook.com>
|
| |
|
|
|
|
|
| |
* format
* Minor test fixes
* enable checking cpp format in ci
|
| |
|
|
|
| |
* Fix several bugs with `specializeWithArgTypes()`
* Make all types L-values for the purposes of reflection API resolution
|
| | |
|
| |
|
| |
Add fcpw library to test suite.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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>
|