summaryrefslogtreecommitdiff
path: root/source
AgeCommit message (Collapse)Author
2024-05-08Support `[__ref]` attribute to make `this` pass by reference. (#4139)Yong He
Fixes #4110.
2024-05-08`slangc` tool experience improvements. (#4140)Yong He
* `slangc` tool experience improvements. Fixes #4123. Fixes #4127. * Update doc.
2024-05-08Fix legalization of `kIROp_GetLegalizedSPIRVGlobalParamAddr`. (#4141)Yong He
2024-05-08Fix crash in obfuscation (#4134)kaizhangNV
Slang crashes during obfuscation because of referencing the nullptr pointer. Add the checking. In addition, above situation happens when user provide an empty slang shader with '-obfuscate' option, we shouldn't do anything in that case. So add an early return in obfuscateModuleLocs if no IR code is actually generated.
2024-05-08Fix NonUniformResourceIndex legalization for SPIRV. (#4133)Yong He
* Fix NonUniformResourceIndex legalization for SPIRV. * Update gh-4131.slang
2024-05-08capture/replay: interface implementation 1 (#4122)kaizhangNV
* capture/replay: interface implementation 1 - Add global session, filesystem, and session capture interface classes: GlobalSessionCapture for IGlobalSession FileSystemCapture for ISlangFileSystemExt SessionCapture for ISession - Add environment variables to enable it The 2 variables are SLANG_CAPTURE_LAYER and SLANG_CAPTURE_LOG_LEVEL SLANG_CAPTURE_LAYER: In slang_createGlobalSession(), after the compiling/loading stdlib, we will check the capture environment variable, if it's set to 1, we will create a GlobalSessionCapture object and return to user code. SLANG_CAPTURE_LOG_LEVEL: This is to set the log level, user can choose the loglevel to debug. (We can remove this when the feature is fully implemented). - Update premake file and cmake file to add the capture/replay source folder * Fix Windows build error Fix windows build error by adding the "SLANG_MCALL" keyword. Change to use Slang::ComPtr for those captured object pointers to simplify the resource management. Use __func__ macro to print the function name in the log.
2024-05-07Make sure pointer local vars have `AliasedPointer` decoration. (#4132)Yong He
2024-05-07Support Metal math functions (#4118)Jay Kwak
* Support Metal math functions Closes #4024 Note that Metal document says Metal doesn't support "double" type; "Metal does not support the double, long long, unsigned long long, and long double data types." According to Metal document, math functions are not defined for integer types. That leaves only two types to test: half and float. As a code clean up, __floatCast is replaced with __realCast. But I had to add a new signature that can convert from integer to float. Some of GLSL functions are moved to hlsl.meta.slang. For those functions, there isn't builtin functions for HLSL but there are for GLSL and Metal. "nextafter(T,T)" is currently not working because it requires Metal version 3.1 and we invoke metal compiler with a profile version lower than 3.1. * Changes based on review comments.
2024-05-06Support groupshared variables for Metal. (#4116)Yong He
2024-05-06Delete `wrap-global-context` pass. (#4114)Yong He
* Delete `wrap-global-context` pass. The pass was added for the metal backend without realizing that the existing `explicit-global-context` does 99% of the job. Instead of duplicating the logic in a different pass for metal, we extend same explicit-global-context pass to work for metal. * Fix build.
2024-05-03Fix mistake in WaveMatch intrinsic. (#4105)Yong He
2024-05-03Add host shared library target. (#4098)Yong He
* Add host shared library target. * Attempt fix. * Fix warnings. * try fix. * Fix test. * Fix.
2024-05-03Don't bottleneck Wave intrinsics through `WaveMask*` for spirv. (#4099)Yong He
* Don't bottleneck Wave intrinsics through `WaveMask*` for spirv. * Fix.
2024-05-03Fix `Ptr::__subscript` to accept any integer index. (#4100)Yong He
* Fix `Ptr::__subscript` to accept any integer index. * Fix `Ptr::__subscript` to allow 64bit indices.
2024-05-03Utilize vector operations over scalar if possible (#4092)Jay Kwak
* Utilize vector operations over scalar if possible Closes #4085 * Fix for the failing CI [ForceUnroll] is removed because it changed the emitted SPIR-V code a little differently for half-conversion.slang. SPIR-V code style is changed to a more preferred style, from "OpXX $$T result $x" to "result:$$T = OpXX $x"
2024-05-02Support generic constraints that are dependent on another generic param. (#4091)Yong He
2024-05-02Fix unzipping logic for inout non-diff parameters and adjust tests (#4090)Sai Praveen Bangaru
* Fix unzipping logic for inout non-diff parameters and adjust tests + Removed `-g0` from `struct-this-parameter.slang` test. Works correctly with the new unzipping logic. + Removed `-g0` from `was/warped-sampling-1d.slang` test. Works correctly with DX12 & CS_5_1. CS_5_0 appears to run into an FXC compiler bug with detecting infinite loops where there don't appear to be any. * Update slang-ir-autodiff-unzip.h * Update warped-sampling-1d.slang
2024-05-02Handle case where types can be used as their own `Differential` type. (#4057)Sai Praveen Bangaru
* Avoid synthesis for when types can be used as their own differenial + Add test * Add missing files.. * Fix issue with method synthesis for self-differential types + Add a generic test * Fix * Fix issue with out-of-date type resolution cache. Witness tables created during the conformance checking phase not being taken into account during the decl type resolution phase because the epoch is not updated after conformance checking. This leads to certain complex associated-type lookup chains (such as the one in tests/compute/assoctype-nested-lookup) not resolving properly and causing errors. * Delete self-differential-type-synthesis-extension.slang * Quick fix to repopulate stdlib cache for deferred stdlib loading * Update slang-check-decl.cpp
2024-05-02Allow multiple _AttributeTargets for attribute declaration (#4087)kaizhangNV
The syntax like: [__AttributeUsage(_AttributeTargets.Var)] [__AttributeUsage(_AttributeTargets.Param)] struct DefaultValueAttribute { int iParam; }; is allowed. For user-defined attribute, we can specify more attribute targets on the attribute declaration. So one attribute can be used in more than one situations.
2024-05-02Fix fmod behavior targetting GLSL and SPIR-V (#4080)Jay Kwak
* Fix fmod behavior targetting GLSL and SPIR-V The default implementation of fmod was doing "Modulo" operation when "fmod" in HLSL should do "remainder" operation. * Fix a mistake in `fmod` GLSL target When using __intrinsic_asm, the "if" logic wasn't emitted. "__intrinsic_asm" had to be called from a new function and `fmod` had to call it. Alternatively, I am using `operator?()` to workaround. A similar modification is made to `roundEven()` hoping for a better performance.
2024-05-02Implement SPIR-V target for GLSL functions (#4083)Jay Kwak
Fixes #4051 This commit implements SPIR-V target for GLSL functions. It also fixes a few problesm of GLSL targetting implemention too.
2024-05-01Delete out-of-date assert. (#4079)Yong He
2024-05-01Fix/replace target intrinsic to target switch part 2 (#4058)Jay Kwak
* Fix texture capabilities * Remove more __target_intrinsic and fix capability for texture Fixes #3906 With this commit, following functions will use __target_switch: - abs - asdouble - clamp - min - max - EvaluateAttributeSnapped - frexp - log10 - modf - __glsl_textureXXX For an unknown reason, I couldn't get "min(int,int)" working with __target_switch. It causes a test failure in Falcore unit test. --------- Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com>
2024-05-01Copy default target's optionSet to code-gen target's optionSet (#4073)kaizhangNV
In current implementation, the some options will be to added to the target that is only specified by command line "-target". But if user specifies the target by just using slang API, e.g. 'spAddCodeGenTarget', those options will be missed. To fix the problem, we copy the default target's options to the code-gen target's option set. The default target will only be useful when there is no target specified in the command line.
2024-05-01Fix compile failures when using debug symbol. (#4069)Yong He
* Fix compile failures when using debug symbol. * Various fixes. * Fix intrinsic. * Fix test.
2024-05-01SPIRV: Fix performance issue when handling large arrays. (#4064)Yong He
* SPIRV: Fix performance issue when handling large arrays. * Add test for packing. * Fix clang.
2024-05-01SPIRV: Fix storage class for unwrapped pointers (#4068)cheneym2
In SPIRV legalization, a struct wrapper is created around push constants but is not itself legalized. Putting the struct type into the work list causes the storage access of the push constant pointer to be PhysicalStorageBuffer as expected, instead of Function scope that was produced without the added struct legalization. Adds a SPIRV test that exercises the fix. Fixes #3946 Co-authored-by: Yong He <yonghe@outlook.com>
2024-05-01Add ParamDecl as the attribute target (#4067)kaizhangNV
Currently we only allow variable, struct, and function as the target for the user-defined attribute, this change adds the function parameter to the target as well.
2024-05-01Adds functionality to dump IR to stdout (#4065)Sriram Murali
Adds a member dump() to IRInst that can writes the immediate value or IR inst value to stdout to help with debugging
2024-04-30Avoid classifying methods with `[numthreads]` as entry points for ↵Sai Praveen Bangaru
CUDA-related targets (#4063)
2024-04-30Added diagnostics & built-in type lowering for `[CUDAKernel]` functions (#4042)Sai Praveen Bangaru
* Added diagnostics & built-in type lowering for `[CUDAKernel]` functions This PR adds - Diagnostics for non-void return from a cuda kernel entry point - Diagnostics for using differentiable types in a differentiable cuda kernel entry point - Logic for converting built-in types (float3, float3x3, etc..) to portable struct types and unpacks the parameter back into a built-in type on the CUDA side. This is because built-in types have different implementations in CUDA & CPP targets, which causes signature mis-match when linking. * Fix error codes * Add ability to lower structs and arrays that contain built-in types. + Added tests + Fix issue where the host-side was not marshalling data to lowered types. * Update slang-ir-pytorch-cpp-binding.cpp --------- Co-authored-by: Yong He <yonghe@outlook.com>
2024-04-30Generate vectorized version of byteaddress load/store methods (#4036)Sriram Murali
Fixes #3533 - Add logic to perform aligned memory operations for loading from and storing to composite resources, like vectors within the ByteAddress legalize pass. - Checks Added a new test for byte address with/without alignment. --------- Co-authored-by: Yong He <yonghe@outlook.com>
2024-04-30Change stdlib to not depend on short-circuit (#4056)kaizhangNV
Do not use "&&" to implement the intrinsic kIROp_And, instead define a 'and' function in stdlib. So it will be up to us to determine whether we want to use 'short-circuit' behavior in stdlib.
2024-04-30Add option -disable-short-circuit (#4054)kaizhangNV
Add option -disable-short-circuit to disable short circuit for logic operators && and ||. Also, disable the short circuit by default in the stdlib.
2024-04-30Metal: Vertex/Fragment builtin and layouts. (#4044)Yong He
* Metal: Vertex/Fragment builtin and layouts. * Fix. * Fix test. * Emit user semantic on vertex/fragment attributes.
2024-04-29Replace __target_intrinsics and __specialize_for_target, part 1 (#4050)Jay Kwak
* Replace __target_intrinsics and __specialize_for_target Partially resolves #3906 Most but not all __target_intrinsics are replaced with __target_switch. All __specialize_for_target are replaced with __target_switch. This change is mostly processed by a temporary c++ program mechanically. Because the change is already too big, the remaining __target_intrinsics will be replaced later in another commit. * Fix indentations * Add diff.meta.slang * Revert the change in __sizeOf<>(). "$G0" doesn't seem to work. It needs to be addressed later. * Revert more functions that use `$G0` keyword
2024-04-29Do not mangle the name of identifiers when __extern_cpp is added (#4052)kaizhangNV
Do not mange the name of identifiers decorated by "__extern_cpp". For a slang files that are included by the library module and entry point module, slang could generated two different mangled names for the same functions, because the function with a struct parameter will make the mangled function name contains the file name. Therefore, we allow using "__extern_cpp" on such struct, such that no file name is associated in the mangled name.
2024-04-26Fix invoke resolution when dealing with overloded type expressions (#4043)Sai Praveen Bangaru
2024-04-26WIP: Force Inline If RefType (#4005)ArielG-NV
* Force Inline if reftype Fixes #3997. If we are using a refType, we now ForceInline. remarks: 1. Modifications were made in slang-ir-glsl-legalize to change how we translate GlobalParam proxy's into GlobalParam. a. We now handle the senario where a globalParam is used in multiple disjoint blocks (like 2 different functions). * try to figure out why CI fails but local works try to inline DispatchMesh, works locally, may fail on CI(?) * try another fix * add task tests + don't allow semi-early task-shader inline Task shader uses DispatchMesh which is a very big 'hack' where we check for the function name and modify the callees in very large ways. This function does inline, but it cannot inline early due to future mangling that this operation requires todo. This is reflected with the `[noRefInline]` modifier. It is a modifier so users may stop mandatory inlines with `__ref` parameter.
2024-04-25Fix unpackUnorm4x8 and unpackSnorm4x8 (#4033)Jay Kwak
Fixes #4031 Each component of unpackU/Snorm4x8 had to be masked for 8bits.
2024-04-25Keep const-ness in generic functions (#4028)Jay Kwak
* Keep const-ness in generic functions Closes #3834 The issue was that "const" variables inside of generic functions became non-const variables. This issue prevented some of GLSL texture functions from being called inside of generic functions. When `propagateConstExpr()` iterates the global functions, the generic functions had to be handled little differently. This commit allows the iteration to happen for the generic functions. * Adding an explantion of the test as a comment
2024-04-25Support derivative functions in compute & capabilities adjustments (#4014)ArielG-NV
* Support derivative functions in compute & capabilities adjustments fixes #4000 PR implements derivative functions in compute shaders properly so we have the functionality for SPIR-V & GLSL. Tests reflect fragment and compute paths. PR also adjusts capabilities to correct wrong SPRI-V target capabilities for when using textures. Remarks: 1. __requireComputeDerivative(); is a intrinsic_op and not modifier since inlining will destroy the modifier. 2. Derivative mode is tied to an entry point decoration `[DerivativeGroupQuad]`/`[DerivativeGroupLinear]` or GLSL syntax ``derivative_group_linearNV`. Default is to set the mode to `[DerivativeGroupQuad]` * remove -emit-spirv-directly * fixes 1. fix minor issue fwidth change where I returned the wrong type 2. fix issue where glslang{glsl->spirv} is wrong, so we don't run that test and just run the glsl test & direct spir-v test for intrinsic-texture.slang * adjust as per review and refine code 1. add test to ensure multi-diverging-in-logic entry points work -- 2 functions which may cause computeDerivatives + 1 that uses, 1 that does not. 2. naming 3. use entry point ref graph for c-like-targets 4. reordered some code to util's and removed `static linline` since that was just for ease of coding on my end (should not have been pushed). * Grammer * split up source file + issolate GLSL emit path change. --------- Co-authored-by: Yong He <yonghe@outlook.com>
2024-04-24Parameter layout and reflection for Metal bindings. (#4022)Yong He
2024-04-24Fix macos CI and clang warnings. (#4019)Yong He
* Fix macos CI. * Fix. * Fix. * Fix. * Fix clang warnings. * Fix more warnings.
2024-04-24Silent compiler warning about missing override keywords (#4018)Jay Kwak
Adding "override" keywords for member functions whereever they need. The compiler warning was visible on CI build but not visible on local visual studio build.
2024-04-24Avoid DXC warnings for missing bitwise op parantheses (#4004)Jay Kwak
Resolves #3980 Based on the operator precedence, Slang may omits the parentheses if they are not needed. DXC prints warnings for such cases and some applications may treat the warnings as errors. This commit emits parentheses to avoid the DXC warning even when they are not needed.
2024-04-23Do not diagnose error when a symbols is defined as 'extern' and 'export' (#4010)kaizhangNV
Fix the issue (#3999). For a function is defined as extern and export at the same time, don't report error, we can use the 'export' function to overload the 'extern' function.
2024-04-23Switch to direct-to-spirv backend as default. (#4002)Yong He
* Switch to direct-to-spirv backend as default. * Fix slang-test. * Fix. * Fix.
2024-04-23Fix a bug in the forward derivative of cross product (#4006)Lifan Wu
* Fix a bug in fwd-diff for cross product * Also add a test for the reverse-mode AD --------- Co-authored-by: Yong He <yonghe@outlook.com>
2024-04-23use memberExpr instead of varExpr (#4008)ArielG-NV