| Age | Commit message (Collapse) | Author |
|
differentiable args (#4901)
* Explicitly detach derivative when forming a non-differentiable struct out of differentiable args
This fixes an issue where initializer lists get optimized out and lose information about non-differentiability.
There are 2 places where this could have been fixed:
1. When coercing initializer-list exprs, we can check for non-differentiable aggregate types and use a detach derivative on all the args.
2. Add an extra case in the peephole optimization step that adds detach-derivative when simplifying a make-struct of a non-differentiable type.
Even though solution 2 is more elegant, this PR goes with solution 1 simply to avoid having to use a differentiable-type-conformance-context that is used in the auto-diff IR passes to check for differentiability.
* Change test name + add expected vals
|
|
* Migrate cpu-hello-world to new slang API
Migrate cpu-hello-world to new slang API, and also convert this example
as one of the unit test.
* Add 'shader-object' to slang-unit-test
* Convert ray-tracing example into unit-test
Convert ray-tracing example into unit-test
* Fix some replay bugs:
- Wrong decode type in 'getEntryPointHostCallable'.
- Mistakes in computing the output buffer size.
- Wrong decode type in array size in specialize() call.
- When capture entrypoint, we should increase the reference count
for the allocated entrypoint recorder object, because that is
allocated by record layer, it should be owned by the layer, user
should not be able to free it.
- Improve json consumer on the prelude text.
* Test verify change:
In our test, we add a "callIdx" string at beginning of the hash-code
string, as there could be more than one modules in the example, so they
could call 'getEntryPointHash' multiple times, in order for the test
can identify them, add "callIdx: <number>" as the key word.
|
|
* Fix Varying Variable Location Assignments With Hull Shaders
Fixes: #4913
Fixes: #4540
Changes:
1. Added `kIROp_ControlBarrier` to HLSL/GLSL emitting.
2. Added a method to track 'used' and 'unused' varyings for when legalizing GLSL. This allows us to assign correct offsets to automatically added varyings
* Added a `ZeroLSB` check to UIntSet for this purpose
* add missing return
* code comment adjustment
* cleanup
* comment and HLSL controlBarrier mistake
* assume space for glsl/spriv varying is irrelevant
|
|
* Implement `-fvk-use-dx-layout`
Fixes: #4126
Changes:
* Added fvk-use-dx-layout
* Modified `HLSLConstantBufferLayoutRulesImpl` for correctness (ex: Array is always 16 byte aligned)
* Added kFXCShaderResourceLayoutRulesFamilyImpl and kFXCConstantBufferLayoutRulesFamilyImpl to handle fvk-use-dx-layout
* Added `ConstantBufferLayoutRules` to manage constant buffer rules
* Added `alignCompositeElementOfNonAggregate`/`alignCompositeElementOfAggregate` to handle forced alignment of composites for ConstantBuffers
* `StructuredBuffer` rules are mostly equal to `scalar` layout, not much was needed to be changed to support this behavior.
* seperate legacy constant buffer and how Slang does constant-buffer normally
* undo an addition
* remove accidental test
* Address review and fix
Address review and remove GLSL support since GLSL requires a seperate legalization (need to linearlize structs like with `legalizeMetalIR` to assign explicit offsets)
* comments
* remove aggregate and non-aggregate logic
We don't need this distinction for the logic
---------
Co-authored-by: Yong He <yonghe@outlook.com>
|
|
* Fix the slang-test bug
Since we reorganize the build directory, now the libraries are
located at different directory with executables in non-Windows
platform, we have to change the code on how to find the dll directory.
* Integrate the record/replay test into slang-unit-test
We create a unit-test-record-replay.cpp to run the converted slang
examples in child process as our tests for the record-replay layer.
* Disable the test on Apple
Due to the limitation of current examples, we temporarily disable them
on apples.
Change the ci to make this test only be run on the gpu-equipped runners,
for other runners we add a white-list file
"expected-failure-record-replay-tests.txt".
* Remove 'hello-world' example from unit test
"hello-world" doesn't use gfx abstract library, instead it uses vk directly, it's
not a preferable way. So we will drop this test, instead, we will use cpu-hello-world
example.
|
|
|
|
* record/replay: Add tests
Modify the hello-world example to generate the hash code for the
entry point spirv code, so that we can compare it with replaying
the example.
Add the test script to run the example and compare the hash code
with replaying it.
* Check nullptr for out Diagnostics
We need to check whether the output Diagnostics is a nullptr,
because it's allowed.
* Fix the double free pointers
* Add triangle example as the new test for record-replay
Change the example base to add the offline rendering path
because we don't want to display anything when we're in the
test mode.
This change involves introducing a TestBase that will parse
the command line option. It will decide whether we are in
the test mode.
Disable all the swapchain and windows related creation, instead
we will only create one single framebuffer for the render target.
* Address comments
TODO:
In the follow up patches, I will add more tests and integrate the test flow into slang-unit-test.
|
|
* Support dependent generic constraints.
* Fix warning.
* Update comment.
* Fix.
* Add a test case to verify fix of #3804.
* Address review.
|
|
* Exclude synthesized code from code auto documentation system
Fixes #4888
Changes to exclude synthesized code from code-auto-documentation system
* syntax change for cleanup
|
|
hang (#4885)
* Track uninitialized values of `Ptr<Specialize<T>>` inside type `T` without hang
Fixes #4878
Track uninitialized values of `Ptr<Specialize<T>>` inside type `T` without hang
* change method used to resolve base of specialization
|
|
track containor-decl with `DifferentialType` scope varaible synthesized
|
|
* Implement Path::createDirectoryRecursive
Implement Path::createDirectoryRecursive with existing Path::createDirectory
that uses system call instead of c++ standard lib.
* Change the use of 'while(1)' to 'for(;;)'
|
|
* Remove using SpvStorageClass values casted into AddressSpace values
Also removes support for specific storage classes in __target_intrinsic snippets
* remove SLANG_RETURN_NEVER macro
* squash warnings
* Make nonexhaustive switch statement error on gcc
* Add SLANG_EXHAUSTIVE_SWITCH_BEGIN/END macros
---------
Co-authored-by: Yong He <yonghe@outlook.com>
|
|
* Tuple swizzling and element access.
* Update proposal status.
* Cleanup.
* Fix merrge error.
* Address review.
|
|
* Variadic Generics Part 2: IR lowering and specialization.
* Update design doc status.
* Update design doc.
* Resolve review comments.
|
|
|
|
|
|
Previously, the warnings were:
```
environment.slang(22): warning 41022: inout parameter 'seed' is never written to
public float3 environment_sample(StructuredBuffer <Environment_sample_data> sample_buffer, inout int seed)
^~~~~~~~~~~~~~~~~~
hit.slang(5): warning 41022: inout parameter 'seed' is never written to
float3 sample_lights(inout uint seed)
^~~~~~~~~~~~~
```
With this commit they should not be emitted.
|
|
|
|
* Make precompileForTargets work with Slang API
precompileForTargets, renamed to precompileForTarget, does not need
an EndToEndCompileRequest and some objects created from it are not
necessary either.
Take only a target enum and a diagnostic blob as input and handle
everything else internally, such as creating the TargetReq with
chosen profile.
Fixes #4790
* Update slang-module.cpp
* Update slang-module.cpp
|
|
|
|
* Do not zero-initialize groupshared and rayquery variables
Fixes: #4824
`-zero-initialize` option will explicitly not:
1. Set any groupshared values to defaults
2. Set any rayQuery object to a default state (currently invalid code generation)
* grammer
* disallow groupshared initializers
disallow groupshared initializers & adjust tests accordingly
* remove disallowed groupshared-init expression
* do not default init if non-copyable
---------
Co-authored-by: Yong He <yonghe@outlook.com>
|
|
* Fix the issue that NonUniformResourceIndex is ignored
Fix the issue that after `specializeFunctionCalls`,
`NonUniformResourceIndex` is ignored in the generated specialized
function.
The reason is that if the function has a non-uniform resource parameter,
we will legalize it by replacing the resource parameter with a index,
and indexing of the resource will be moved inside the specialized function.
e.g.
```
void func(ResourceType resource) { ... }
func(resource[NonUniformResourceIndex(0)])
```
will be specialized into
```
void func(int index) { resource[index]; }
func(0);
```
In this case, inside the function, we will loose the information about
whether the resource is a non-uniform. So we add the handling for this
corner case by adding insert a `NonUniformResourceIndex` into the
specialized function:
```
void func(int index) {
int nonUniformIdx = NonUniformResourceIndex(index);
resource[nonUniformIdx];
}
```
* Fix the issue that arguments mismatch after specilization callsite
specializeCall() call could cause arguments mismatch with the parameters
of the specialized function.
For example, if the function parameter contains a resource type
```
void func(ResourceType res) { ... }
int index = ...
func(resources[index]);
```
This will be specialized into
```
void func(int index) { resources[index] }
int index = ...
func(index);
```
However, if we have more than 1 call sites, and the other call site
doesn't use `int` as the index, e.g.
```
uint index = ...
func(resources[index]);
```
this call site will be specialized into
```
uint index = ...
func(index);
```
this will be invalid, because the argument doesn't match the parameter.
so we just add the data type of the new arguments into the function key such that
For the uniformity info, we add a new attribute "IROp_NonUniformAttr",
so we will form a IRAttributedType that encodes both uniformity and data
type, and use it as the key of call info. So if there is call site using the different
data type for the resource index, we will specialize a new function for this.
* Handle the intCast and uintCast operation
Since after intCast/uintCast of nonuniformIndex, it's still a
nonuniformIndex. So we will handle this case as well.
Also, add a new test to cover this.
|
|
Adds a new Github CI action for benchmarking the slangc compiler on the MDL shaders. For now, the results are only dumped to the output of the CI, which can be later viewed through raw logs. The next step is to use github-action-benchmark to push these results into a page which will show the benchmark results over time as commits are pushed.
|
|
|
|
Fixes #4818
Emit memory qualifier once for GLSL targets.
Co-authored-by: Yong He <yonghe@outlook.com>
|
|
* Support unicode identifier names.
* Fix.
* Fix language server.
* Fix build errors.
* Fix.
* Fix offset translation in language server.
|
|
Addresses #4698 as one approach to diagnose the potential problem.
Emit warnings when a user marks a parameter as `inout` but never writes to it in the function. A new intrinsic function `unmodified(out T)` has been added to explicitly indicate that an `inout` variable will not be modified in the function.
This is only one way to address the specific validation error in #4698. In general it seems that DXC does some more extensive checks on actual struct fields (as opposed to observing arbitrary struct writes), so that will be the next step.
|
|
|
|
* More reflection API features.
+ Lookup methods and members (by string) on types
+ Fix issue with looking up non-static members through the scope operator '::'
+ `GenericReflection`: Cast a decl to generic to access unspecialized generic parameter names and constraints
+ `GenericReflection`: Use `getGenericContainer()` from function, variable or type to access the 'nearest' generic parent along with specialization info
+ `GenericReflection::getConcreteType` and `GenericReflection::getConcreteIntVal`: to get the concrete type of a param in the context of the reflection object
+ `GenericReflection::getOuterGenericContainer` to go up one level and get the outer generic declarations (if there are more than one enclosing generic scopes)
+ `DeclReflection::getParent`: go to parent declaration.
+ Change `VariableReflection` to be a `DeclRef` rather than a decl (allows us to return properly substituted types for methods, members, and more)
* Fix Falcor issue
|
|
* Fix auto-diff synthesized method naming conventions
* Update tests; remove unused var
|
|
Some debug code was left in by accident which called DXC to
disassemble the DXIL it produced.
|
|
Closes #4746.
This commit adds a support for "NumThreads" and "Shader" attribute keyword, which is in CamelCasing starting with an upper case letter.
The attribute keywords in HLSL are case-insensitive. As an example, one of D3D documents says,
"The attribute name "Shader" is case insensitive."
https://microsoft.github.io/DirectX-Specs/d3d/WorkGraphs.html
Slang, however, doesn't support the case-insensitivity. They should be all lower-case or CamelCasing starting with an upper case.
|
|
* Add embedded precompiled binary IR ops
Add IR operations to embed precompiled DXIL or SPIR-V blobs
into IR. Adds a BlobLit literal that is mostly identical to
StringLit except for its inability to be displayed, e.g.
in dumped IR. In the future, the blob might be dumped as
hexadecimal, but for now it is summarized as "<binary blob>".
* EmbeddedDXIL and SPIR-V options
The options, '-embed-dxil' and '-embed-spirv' in slangc, will
cause a target dxil or spirv to be compiled and stored in the
translation unit IR when written to a slang-module. Subsequent
changes actually implement the options.
* Per-translation unit DXIL precompilation
When -embed-dxil is specified, perform a precompilation to DXIL of
each TU, linked only with stdlib. Embed the resulting DXIL for
the TU in a IR op. Being part of IR, the precompiled DXIL can be
serialized to disk in a slang-module.
Upon loading slang-modules, the new IR op will be searched for and
the precompiled DXIL blob is saved with the loaded Module. During
linking, if all the Modules have precompiled blobs they will be
sent to the downstream compile commands as libraries instead of
source, skipping the downstream compilation, using DXC only for
linking.
Fixes Issue #4580
* Remove placeholder embedded SPIRV support
Code was added only to sketch out how other precompiled bins
will be supported.
* Remove the rest of the SPIRV placeholder support
* Fix warnings, test error on non-windows
* Remove lib_6_6 hack, add dxil_lib capability
* Allocate blob value from irmodule memarena
* Add null check after memarena allocation
* Restore the request->e2erequest code path for generatewholeprogram
* Update capability handling, move EmbedDXIL enum to end to preserve abi
* Remove lib_6_6 hack
* Move ICompileRequest functions to end
|
|
|
|
|
|
* Allow impliocit 'uniform' entrypoint parameters.
* Fix.
* Fix.
* Fix.
* Fix.
|
|
* Allow generic type deduction from ParameterBlock arguments.
* Fix test.
* Update expected failure list.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
|
|
* record/replay: Implement the json consumer
Finish the implementation of json consumer.
Fix some bug in the block processing as Tailer is not a necessary block
so if the Magic bit is "HEAD", we should keep processing.
* record/replay: Implement the replayer component
Implement the replayer consumer, and also finish the slang-replay
standalone app that will run the while replayer.
It can take an option "--convert-json | -cj" which will convert
the record binary file to a human readable json file.
If there is no option provided, it will replay the record file by
default.
TODO: #4764 is created to remove the std::filesystem usage.
|
|
* Proper warning generation for target switches and intrinsic asm
* Relaxing terminators
* Fix compiler warnings
* Rectified target switch reachability check
* Simplify target switch reachability check
* Refactoring variable names
* Using getBlocks
* Moving ad hoc special case to diagnostics source
* Using the LINE directive for testing
* Simplifying reliance on target switches
* Skipping IR generation for empty target switches
---------
Co-authored-by: Yong He <yonghe@outlook.com>
|
|
* Fix IR lowering for generic interface types.
* Fix.
* Fix.
|
|
|
|
|
|
(#4751)
|
|
|
|
* Fix SPIRV emit for small-integer texture types.
* Disable -emit-spirv-via-glsl test.
|
|
|
|
* Disable warnings for input global variables
* Update comment to reflect actual check
Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com>
* Update comments in uninitialized-globals.slang
* Update uninitialized-globals.slang
* Refactoring test variable
* Typo in test
---------
Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com>
|
|
|
|
This commit makes the memory leaks harder to miss by triggering an
assertion failure for memory leaks. It works only for Windows Debug
build.
SLANG_ASSERT doesn't print the info where the assertion failure
happens, for an unknown reason. Using the system assert as a
workaround.
|