| Age | Commit message (Collapse) | Author |
|
* 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>
|
|
* Destroy unused witness table after hoisting
|
|
|
|
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.
|
|
|
|
* 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>
|
|
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.
|
|
* 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>
|
|
* Parse char literals as integers
* Fix formatting
* Parse escaped chars correctly
---------
Co-authored-by: Yong He <yonghe@outlook.com>
|
|
* Add interger pack/unpack intrinsic to glsl
Add unpack8, unpack16 and pack32 intrinsics to glsl.
* add unit test
* fix lowering logic for 'bitcast'
* format
|
|
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.
|
|
* Correct incorrect enum usage on metal
* Update C++ standard to C++20
Closes https://github.com/shader-slang/slang/issues/6945
* use bit_cast
|
|
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.
|
|
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>
|
|
Co-authored-by: Yong He <yonghe@outlook.com>
|
|
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.
|
|
|
|
* 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>
|
|
`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 build on GCC 15
* format code
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
|
|
* 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
|
|
|
|
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.
|
|
* Fix comment typos in the triangle's main.cpp example
* 2nd fix
|
|
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.
|
|
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.
|
|
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>
|
|
* Simplify build of slang-wasm
* Add smoke-test for slang-wasm in ci
* Avoid git-clone playground
|
|
* Add `IOpaqueHandle::descriptorAccess`.
* Update doc.
* fix.
|
|
* 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.
|
|
|
|
* cuda: Improve entry handling for SV_DispatchThreadID
Fixes #6780
This commit improves CUDA entry point handling by extracting appropriate
components from DispatchThreadID based on parameter type. It now
properly handles uint scalar (x component only) and uint2 vector (x,y
components) instead of always using the full uint3 value.
Add a new test case to check for this.
* format code
* fix CI failure
* Handle review comments
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
|
|
* cuda: Add support for subscript operator
This CL adds support for the subscript operator for Read Only
textures in cuda. Also adds a test for this.
Fixes #6781
* format code
* fix review comments
* format code
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
|
|
* Fixes related to AST serialization change
There are two fixes included here.
The smaller fix is in `slang-ast-decl.h`, where the `CallableDecl::primaryDecl` and `::nextDecl` fields need to be serialized to make sure that we can properly deserialize a module that contains any function redeclarations.
The larger fix is that the `Encoder` and `Decoder` types used to serialize out the AST nodes in a JSON-like hierarchy were being very strict about matching of integer types, which causes problems in any case where serialization code might use a type that is 32-bit on some targets and 64-bit on others, if serialized modules are ever created on one of those targets and consumed on the other (which happens for the core module for some of our targets).
The fix that this change implements is to make the serialization logic there more forgiving, and thus more robust:
* In the writing/encoding direction, the logic now looks at the actual value being encoded to decide whether to write it as a 32- or 64-bit value.
* In the reading/decoding direction, the logic handles the presence of *any* of the FOURCCs that are used to encode integers, for whatever type is being read. As a small bit of safety, there is a dynamic check made for cases where a value would be read with a different sign than it was written with.
The actual logic in `slang-serialize-ast.cpp` is largely unchanged (it continues to use pointer-sized integers in certain cases), but it should not cause problems because it bottlenecks through the `Encoder`/`Decoder` methods that were changed. The only fix made in the AST serialization itself is to account for all of the FOURCCs that can represent integers when peeking at the input to decide whether a `DeclBase` is represented as an indirection to a `Decl`, or is serialized inline (as a `DeclGroup`).
* format code
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
|
|
* Support `this` use of `IRMeshOutputRef`
* Fix SPIR-V val error
There was a type mismatch causing a spir-v failiure: `store(var, var)` instead of `store(var, load(var))`
|
|
* 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)
|
|
* Update spirv-tools to for SDK v2025.2
Fixes: #6850
* bump spirv version to 1.4 for op linkage
* skip-spirv-validation for coop mat
* add skip-spirv-validation option to slang session desc
* use SPV_ENV_UNIVERSAL_1_6 for spirv-tool env target
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
---------
Co-authored-by: slangbot <ellieh+slangbot@nvidia.com>
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
|
|
Co-authored-by: Yong He <yonghe@outlook.com>
|
|
* Implemented #pragma warning
Based on https://learn.microsoft.com/en-us/cpp/preprocessor/warning?view=msvc-170
* Make #pragma warning work with #includes.
- SourceLoc are not sorted by inclusion order.
- Construct a mapping from SourceLoc to "absolute locations" that are sorted by inclusion order (roughly represents a location in a raw file with all #include resolved).
- The absolute location can be used in the pragma warning timeline
* Added preprocessor #pragma warning tests.
- Fixed #pragma warning (push / pop) SourceLoc
- Fixed unused directiveLoc in #pragma warning parsing
* #pragma warning: Added some comments and fixed some typos
* Cleaned #pragma warning preprocessor implementation.
---------
Co-authored-by: Yong He <yonghe@outlook.com>
|
|
Co-authored-by: Yong He <yonghe@outlook.com>
|
|
Co-authored-by: Yong He <yonghe@outlook.com>
|
|
Work on #6892
The function `tryInferLoopMaxIterations` in `slang-check-stmt.cpp` was
doing:
auto litExpr = m_astBuilder->create<LiteralExpr>();
but the declaration of `LiteralExpr` in `slang-ast-expr.h` had been
marked as abstract, during the switch to using the `slang-fiddle` tool
to generate code:
FIDDLE(abstract)
class LiteralExpr : public Expr
{ ... }
In this case, the intention of the AST design is that `LiteralExpr`
should be kept abstract, and only the concrete subclasses should
ever be instantiated.
Because of some historical design choices, the `ASTNodeType`
enumeration includes both the concrete and abstract AST classes, so
the code ended up constructing a `LiteralExpr` that had the tag
`ASTNodeType::LiteralExpr`. Then attempts to use the `ASTNodeDispatcher`
code on such a node caused crashes, because the dispatcher code only
included `case` statements for the non-abstract `ASTNodeType`s.
The quick fix here was to change the `tryInferLoopMaxIterations`
function to instead do:
auto litExpr = m_astBuilder->create<IntegerLiteralExpr>();
A test case was added to help catch any future regressions on this
specific issue.
A more long-term fix should involve introducing code that statically
and/or dynamically prohibits the creation of instances of AST node
classes that have been marked abstract.
|
|
|
|
* update slang-rhi submodule
* slang-rhi API changes
* disable agility sdk
* fix texture creation
* update formats in tests
* Extent3D rename
* use 1 mip level for 1D textures for Metal
* fix texture upload
* update to latest slang-rhi
* update slang-rhi
* format code
* update slang-rhi
* do not run texture-intrinsics test on metal
* update slang-rhi
* deal with failing tests
* fix more tests
* update slang-rhi
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Co-authored-by: Simon Kallweit <simon.kallweit@gmail.com>
|
|
* Fix #6544: Properly format nested type names in extensions
Modify DeclRefBase::toText to properly handle types defined
in extensions by qualifying them with their parent type name.
This ensures getFullName() returns the full name like
'FullPrecisionOptimizer<half>.State' instead of just '.State'.
Also handle other nested types in structs/classes similarly.
* Update extension reflection handling - with generics args and namespaces
- stopping namespace inclusion for extension members
- Update to use getTargetType() to handle the generic arguments
- update test cases
* Simplify code to remove using parentDecl
|
|
* Fix: Improper implementation in RendererBase::queryInterface
In the case an arbitrary uuid was passed to RendererBase::QueryInterface it would return SLANG_OK while the outObject is null. This is improper and unexpected from an IUnkown implementation. Additionally, the function did not call addRef() when concerning an IDevice interface.
* Fix: DebugTransientResourceHeap::queryInterface returns wrong interface
When trying to query for the transient heap if the debug layer is enabled, queryInterface would set the outObject to the inner api specific heap (ex: vk::TransientResourceImpl) and NOT the debug heap. This causes a side effect when creating a command buffer that debug wrappers would not be used. The debug version will not be returned, and this snowballs causing an access violation when trying to bind a compute pipeline state. After this fix, debug wrappers for transient heaps, command buffers, encoders, etc... wil be used correctly.
* fix weird whitespace change
|
|
* A new approach to AST serialization
This change completely overhauls the way that AST nodes are being serialized, and the offline source-code generation steps that enable that serialization.
In practice, this ends up being a complete overhaul of the way that *modules* are being serialized (not just the AST part), although things like the serialization format for the Slang IR and for source locations are not affected.
The rest of this commit message is broken down in to sections, in an attempt to help guide anybody looking at the code in how to make sense of all the changes.
The Old C++ Extractor
---------------------
AST serialization used to be driven by information scraped using the `slang-cpp-extractor` tool, which did an ad hoc parse of the C++ declarations of the AST node types and then generated a set of "X macros" that could be for macro-based code generation within the rest of the compiler.
While the existing approach was functional, it wasn't easy to understand or maintain, and it has been getting in the way of forward progress on other features we'd like to work on in the language and compiler.
This change removes the `slang-cpp-extractor` tool entirely.
Marking Up the AST Declarations
-------------------------------
The most notable change that contributors to the compiler may notice is the large number of invocations of a macro `FIDDLE()` on the declarations of the AST node types.
The basic idea is that only declarations (namespaces, types, fields) that are preceded by `FIDDLE()` are visible to the code generator tool.
So if somebody is working with the AST and wondering why a new node type isn't working, or why a field they added isn't being serialized correctly, it is probably because they need to add `FIDDLE()` in front of it.
Generating the Boilerplate Code
-------------------------------
The file `slang-ast-boilerplate.cpp` provides a good example of how the information extracted from the marked-up AST declarations gets used.
In that file, the `FIDDLE TEMPLATE` construct is used to generate type information for each of the AST node types.
Similar logic is used in `slang-ast-forward-declarations.h` to generate the declaration of the `ASTNodeType` enumeration, and forward-declare all the AST node classes.
For many parts of the code, simply including that file replaces the need for the old `slang-generated-*.h` files.
Replacing Visitors and Related Logic
------------------------------------
The old visitor types for the AST used the macros that were generated by `slang-cpp-extractor`, so something new was needed to replace them.
The same goes for the `SLANG_AST_NODE_VIRTUAL_CALL` macros.
The core of the solution implemented here is in `slang-ast-dispatch.h`.
Given a "dispatchable" AST node type (say, `Expr`), a call like:
```
ASTNodeDispatcher<Expr,R>(expr, [&](auto e) { return doSomething(e); })
```
is an expression of type `R`, which does the equivalent of something like:
```
switch(expr->getTag())
{
case ASTNodeType::VarExpr: return doSomething(static_cast<VarExpr*>(expr));
// ...
}
```
The `SLANG_AST_NODE_VIRTUAL_CALL` macro is now implemented in terms of `ASTNodeDispatcher`.
The implementation of the visitor types is more involved.
The code in this change retains some of the macro names from the original version, just to try and make the parallels more clear.
The visitor types are all implemented on top of the `ASTNodeDispatcher` approach, and use `FIDDLE TEMPLATE` to generate all the boilerplate `visit*()` method declarations.
Refactoring of `Linkage` Module Loading
---------------------------------------
Needing to revisit all the places where modules get deserialized made it clear that there is a lot of complexity and apparent duplication in the core routines on the `Linkage` that get used for loading modules.
This change tries to clean up some of that logic, but it is worth noting that there are two legacy features that get in the way of making things as clean as they should be:
* The `LoadedModuleDictionary` type that gets passed around a lot exists entirely to handle the corner case where somebody uses the Slang API to perform a compilation with multiple `TranslationUnitRequest`s in the same `FrontEndCompileRequest`, and one of the translation units `import`s the module defined by another of the translation units.
* There are a lot of special-case behaviors and routines entirely there to support the `ModuleLibrary` feature, although that feature should be considered deprecated (or at least subject to getting entirely re-designed down the line).
The basic idea of the cleanup is that all of the (non-deprecated) ways load a module from a serialized binary, or compile one from source should now bottleneck through `loadModuleImpl`, which then bifurcates into `loadSourceModuleImpl` for the compilation case and `loadBinaryModuleImpl` for the deserialization case.
High-Level Serialization Approach
---------------------------------
The old serialization logic used the [RIFF](https://en.wikipedia.org/wiki/Resource_Interchange_File_Format) format to encode the high-level structure of things, and this change retains that usage (and actually doubles down on the RIFF usage).
The old serialization system relied on the idea that for any given type `Foo` that wants to support serialization, there should be something like a `SerialFooData` type in C++, that can represent the state of a `Foo`, and then the actual serialization applied to that `SerialFooData`. This means that in most cases there are four pieces of code written:
* During serialization:
* Copying the data of a `Foo` in memory over to a `SerialFooData` in memory
* Writing the state of a `SerialFooData` into the serialized data stream
* During deserialization:
* Reading the state of a `SerialFooData` from a serialized data stream
* Copying the data of the `SerialFooData` in memory over to a `Foo`
The new logic gets rid of the intermediate `SerialFooData`.
In the serialization direction, we take a `Foo` and write it to the `RIFFContainer` directly, or using some other utilities layered on top of it.
In the deserialization direction, we have additional flexibility. Given a `RIFFContainer::Chunk*` that represents a serialized `Foo`, we often navigate through the in-memory representation of the RIFF data to get to the parts of the serialized value that we actually want/need, without needing to deserialize the entire `Foo`.
To support this kind of operation, this change introduces a few helper types like `ContainerChunkRef` an `ModuleChunkRef`, that are little more than typed wrappers around a `RIFFContainer::Chunk*`.
The Module "Container" Part
---------------------------
A serialized `Module` is encoded as a RIFF chunk, using logic in `slang-serialize-container.cpp` - both before and after this change.
This change reorganizes a lot of the code in that file, to account for the way that eliminating the intermediate `SerialContainerData` type streamlines the overall task of writing out the parts of the module.
In the deserialization logic... there isn't really much to do in `slang-serialize-container.cpp`. Most of the logic in `slang.cpp` and `slang-module-library.cpp` that pertains to deserializing modules uses the `ModuleChunkRef`-based approach, and simply extracts the pieces of the serialized module that it needs.
The Actual Serialization of the AST
-----------------------------------
The actual AST serialization logic is in `slang-serialize-ast.cpp`.
The basic approach in both the writing and reading directions is:
* Use the `FIDDLE TEMPLATE` system to generate a set of functions, one for each AST node type, that recursively invoke the read/write logic on each field of that node (after recursively invoking the case for its direct superclass)
* Use the `ASTNodeDispatcher` system to dispatch out to those functions whene reading or writing anything derived from `NodeBase`
* For now, handle all types *not* derived from `NodeBase` by hand.
There's a lot of room for improvement around that last item: it should be just as easy to generate the serialization and deserialization logic for other types that don't inherit from `NodeBase`, but the current change tries to err on the side of making the logic as explicit and simplistic as possible, rather than trying to get too clever too soon.
The actual serialization *format* used for the AST is almost comically simplistic: the code uses hierarchical RIFF chunks to emulate a JSON-like structure. This is a very wasteful representation (e.g., a `bool` or a null pointer each take up *8 bytes*), but the goal for now is to start with the simplest thing that could possibly work, and only add more cleverness once we are sure it won't get in the way of important future improvements (like lazy/on-demand deserialization or IR and AST, to improve compiler startup times).
The files `slang-serialize.{h,cpp}` have been co-opted to define a new pair of types `Encoder` and `Decoder` that are used for a more-or-less stream-oriented way or reading or writing RIFF chunks for the JSON-like structure.
Almost everything related to the actual AST serialization could do with a cleanup pass, and some time spent on picking good/better names for everything.
Smaller Stuff
-------------
* Cleaned up a lot of code that was using bare `ASTNodeType` or the extractor's `ReflectClassInfo` type to consistently use `SyntaxClass`.
* Fixed an apparent bug in how the destination-driven code genarator was handling `TryExpr`s
* Fixed an apparent bug in how the GLSL legalization pass was handling translation of certain `SV_*` semantics.
* format code
* fixup: template errors caught by non-VS compilers
* format code
* fixup: more template errors
* fixup: more stuff VS didn't catch
* fixup: it's amazing VS doesn't catch these...
* fixup: yet more template stuff VS ignores
* fixup: more VS template nonsense
* fixup: unreachable return macro usage
* fixup: more unreacable returns
* fixup: unused parameter
* fixup: strict aliasing
* fixup: allow missing entry point list chunk
* fixup: wasm build script
* fixup: AST changes since this PR was created
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Co-authored-by: Yong He <yonghe@outlook.com>
|
|
* Initial implementation for SPIRV, GLSL and Metal
* test add bool test
* Fix and improve subgroup rotate tests
* Add proper GLSL extensions and proper Metal type checking
* Clean up tests and add diagnostics test for subgroup type for Metal
* Update wave-intrinsics docs
|