summaryrefslogtreecommitdiff
path: root/source
AgeCommit message (Collapse)Author
2024-08-27Explicitly detach derivative when forming a non-differentiable struct out of ↵Sai Praveen Bangaru
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
2024-08-27Migrate examples (#4920)kaizhangNV
* 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.
2024-08-26Fix Varying Variable Location Assignments With Hull Shaders (#4915)ArielG-NV
* 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
2024-08-26Implement `-fvk-use-dx-layout` (#4912)ArielG-NV
* 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>
2024-08-26Feature/record unit test (#4910)kaizhangNV
* 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.
2024-08-23Make variadic generics work with interfaces and forward autodiff. (#4905)Yong He
2024-08-22Feature/capture unit test (#4898)kaizhangNV
* 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.
2024-08-20Support dependent generic constraints. (#4870)Yong He
* Support dependent generic constraints. * Fix warning. * Update comment. * Fix. * Add a test case to verify fix of #3804. * Address review.
2024-08-20Exclude synthesized code from code auto documentation system (#4889)ArielG-NV
* Exclude synthesized code from code auto documentation system Fixes #4888 Changes to exclude synthesized code from code-auto-documentation system * syntax change for cleanup
2024-08-20Track uninitialized values of `Ptr<Specialize<T>>` inside type `T` without ↵ArielG-NV
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
2024-08-20Fixes #4879 (#4881)ArielG-NV
track containor-decl with `DifferentialType` scope varaible synthesized
2024-08-20Implement Path::createDirectoryRecursive (#4871)kaizhangNV
* 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(;;)'
2024-08-19Remove using SpvStorageClass values casted into AddressSpace values (#4861)Ellie Hermaszewska
* 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>
2024-08-19Tuple swizzling, concat, comparison and `countof`. (#4856)Yong He
* Tuple swizzling and element access. * Update proposal status. * Cleanup. * Fix merrge error. * Address review.
2024-08-18Variadic Generics Part 2: IR lowering and specialization. (#4849)Yong He
* Variadic Generics Part 2: IR lowering and specialization. * Update design doc status. * Update design doc. * Resolve review comments.
2024-08-18Make sure to resolve overloaded expr for call args. (#4864)Yong He
2024-08-16Avoiding the use of the global AST builder in DeclRefType::create (#4866)venkataram-nv
2024-08-16Include inout cast operation as an aliasing instruction (#4859)venkataram-nv
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.
2024-08-15Variadic Generics Part 3: language server (#4850)Yong He
2024-08-15Make precompileForTargets work with Slang API (#4845)cheneym2
* 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
2024-08-14Variadic Generics Part 1: parsing and type checking. (#4833)Yong He
2024-08-14Do not zero-initialize groupshared and rayquery variables (#4838)ArielG-NV
* 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>
2024-08-14Issue/legalize resource (#4769)kaizhangNV
* 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.
2024-08-13GitHub action benchmark (#4804)venkataram-nv
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.
2024-08-13FIx issue with specializing witness tables (#4839)Sai Praveen Bangaru
2024-08-12Emit memory qualifier once for GLSL targets (#4819)ArielG-NV
Fixes #4818 Emit memory qualifier once for GLSL targets. Co-authored-by: Yong He <yonghe@outlook.com>
2024-08-12Support unicode identifier names. (#4772)Yong He
* Support unicode identifier names. * Fix. * Fix language server. * Fix build errors. * Fix. * Fix offset translation in language server.
2024-08-12Warn when inout parameter is never written (#4777)venkataram-nv
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.
2024-08-07Reduce dependency on std library (#4785)skallweitNV
2024-08-07More reflection API features. (#4740)Sai Praveen Bangaru
* 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
2024-08-06Fix auto-diff synthesized method naming conventions (#4714)Sai Praveen Bangaru
* Fix auto-diff synthesized method naming conventions * Update tests; remove unused var
2024-08-06Remove disassemle debug code (#4779)cheneym2
Some debug code was left in by accident which called DXC to disassemble the DXIL it produced.
2024-08-06Support an Upper-case variant of [NumThreads] and [Shader] (#4780)Jay Kwak
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.
2024-08-05Initial support for precompiled DXIL in slang-modules (#4755)cheneym2
* 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
2024-08-01Allow a enum case to reference a previously defined value. (#4768)Yong He
2024-08-01Perform type legalization on StructuredBuffer element. (#4767)Yong He
2024-08-01Allow implicit 'uniform' entrypoint parameters. (#4765)Yong He
* Allow impliocit 'uniform' entrypoint parameters. * Fix. * Fix. * Fix. * Fix.
2024-07-31Allow generic type deduction from ParameterBlock arguments. (#4766)Yong He
* Allow generic type deduction from ParameterBlock arguments. * Fix test. * Update expected failure list. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2024-07-31Feature/replayer (#4750)kaizhangNV
* 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.
2024-07-31Warnings target switch intrinsic asm (#4727)venkataram-nv
* 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>
2024-07-31Fix IR lowering for generic interface types. (#4761)Yong He
* Fix IR lowering for generic interface types. * Fix. * Fix.
2024-07-30Fixes for Metal ParameterBlock support. (#4752)Yong He
2024-07-30Move SPIRV global variables into a context variable (#4741)ArielG-NV
2024-07-30Fix invalid code generation for when using nested resource specialization ↵ArielG-NV
(#4751)
2024-07-30Set `nullptr` to the default value of the target VarDeclBase (#4757)ArielG-NV
2024-07-30Fix SPIRV emit for small-integer texture types. (#4753)Yong He
* Fix SPIRV emit for small-integer texture types. * Disable -emit-spirv-via-glsl test.
2024-07-26Allow passing sized array to unsized array parameter. (#4744)Yong He
2024-07-26Disable warnings for input global variables (#4745)venkataram-nv
* 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>
2024-07-26Add reflection of inout modifiers (#4711)ccummingsNV
2024-07-25Assertion failure on debug build for memory leaks (#4733)Jay Kwak
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.