summaryrefslogtreecommitdiff
path: root/source
AgeCommit message (Collapse)Author
2024-07-19Correctly parse multiple escaped newlines (#4672)Ellie Hermaszewska
closes https://github.com/shader-slang/slang/issues/4667
2024-07-18Add unexpected end of input error to lexer (#4673)Ellie Hermaszewska
* Add unexpected end of input error to lexer * Add end of input test * Simplify testcase
2024-07-18Adjust how `slang` and `slangc` uses a `profile` to manage the stage of an ↵ArielG-NV
entry-point (#4670) * Fixes #4656 Changes: 1. Setting a profile via slangc no-longer sets an entry-point target-stage, this is to allow slangc to follow how the SLANG-API works (else `main` is assumed to be the default entry-point) 2. If the stage specified by a profile is not equal to the stage specified by a entry-point, we throw a capability error. 3. Resolving the stage of an entry point was changed to function (mostly) equally for when 0 entry-points are specified versus to when there are 1 or more. 4. changed capabilitySet Iterator so it is invalid if backing data is nullptr (although this should never happen, it would stop crashes in the worst case). * remove the breaking change since it likely is going to be a lot more than just a simple change due to the implicit `main` and stage through `profile` code. * print out profile name with errors * use target's profile for printing * change logic to print warning in a different method (account for more cases) * set unknown stages
2024-07-18Reduce duplication in slang lib builds (#4651)Ellie Hermaszewska
* spelling * Reduce duplication in slang lib builds Closes (as much as possible) https://github.com/shader-slang/slang/issues/4615 The only case where we could actually make a difference would be an embedded stdlib and static slang, which isn't a configuration anyone actually uses. Nonetheless, clean up this bit
2024-07-17Squash warnings on gcc and clang (#4669)Ellie Hermaszewska
2024-07-18Remove generated file from source and build at build time (#4649)Ellie Hermaszewska
* Remove generated file from source and build at build time * comments
2024-07-18Add slang-llvm and slang-glslang readmes (#4646)Ellie Hermaszewska
* Add slang-llvm and slang-glslang readmes Just extraced and updated from the original repos * Remove redundant file
2024-07-17Use slang-glslang.dll for spirv-validation (#4642)Jay Kwak
* Use slang-glslang.dll for spirv-validation This change replaces the use of "spirv-val.exe" with an API call to "spvtools::SpirvTools::Validate()". Closes #4610
2024-07-17Move the file public header files to `include` dir (#4636)kaizhangNV
* Move the file public header files to `include` dir Close the issue (#4635). Move the following headers files to a `include` dir located at root dir of slang repo: slang-com-helper.h -> include/slang-com-helper.h slang-com-ptr.h -> include/slang-com-ptr.h slang-gfx.h -> include/slang-gfx.h slang.h -> include/slang.h Change cmake/SlangTarget.cmake to add include path to every target, and change the source file to use "#include <slang.h>" to include the public headers. The source code update is by the script like follow: ``` fileNames_slang=$(grep -r "\".*slang\.h\"" source/ -l) for fileName in "${fileNames_slang[@]}" do echo "$fileName" sed -i "s/\".*slang\.h\"/\"slang\.h\"/" $fileName done ``` * Fix the test issues * Fix cpu test issues by adding include seach path * Update cmake to not add include path for every target Also change "#include <slang.h>" to "include "slang.h" " to make the coding style consistent with other slang code. * Change public include to private include for unit-test and slang-glslang
2024-07-16Fix minimal-optimization flag with texture atomics (#4660)ArielG-NV
Co-authored-by: Yong He <yonghe@outlook.com>
2024-07-16Warnings function parameters (#4626)venkataram-nv
* Handle out/inout functions with separate consideration * Fixing bug with passing aliasable instructions * Handle autodiff functions (fwd and rev) in warning system * Handling interface methods * Handling ref parameters like out/inout * Temporary fix to remaining bugs * Refactoring methods and tests * Recursive check for empty structs * Using default initializable interface in tests * Resolving CI fail
2024-07-16Fix issue with synthesized `__init` methods not getting added to witness ↵Sai Praveen Bangaru
table (#4638)
2024-07-16SCCP instead of CFG since SCCP removes code of unused branches, not CFG (#4640)ArielG-NV
2024-07-12use `nullptr' for IRStructKey with `IRDerivativeMemberDecoration` (#4623)ArielG-NV
2024-07-12Change IDefaultInitializableType to IDefaultInitializable (#4620)ArielG-NV
2024-07-11Fix incorrect codegen when returning initializer list as existential value. ↵Yong He
(#4618) * Add `dev` cmake preset. * Fix incorrect codegen when returning initializer list as existential value. * Fix cmake. * Fixup.
2024-07-11Fix issue with synthesizing `Differential` type for self-differential ↵Sai Praveen Bangaru
generic types (#4602) * Fix issue with synthesizing `Differential` type for self-differential generic types The problem was that we were using the type that was performing the lookup for `.Differential` which can have substitutions based on the local context where the decl is being referenced. We need to synthesize the type local to the decl itself * Update auto-differential-type-generic.slang
2024-07-11Fix missing include for static slang (#4614)Ellie Hermaszewska
2024-07-11populate slang-tag-version with cmake (#4611)Ellie Hermaszewska
At the moment it is always "unknown"
2024-07-10Implement 64-bit version of clockARB (#4571)venkataram-nv
* Implement 64-bit version of clockARB * Fix capability versions * Corrections to capabilities --------- Co-authored-by: Yong He <yonghe@outlook.com>
2024-07-10Revert slang-tag-version include path.Yong He
2024-07-11Cope with failed version parsing (#4609)Ellie Hermaszewska
* Cope with failed version parsing * Better version parsing * populate slang-tag-version with cmake * Neaten cmake
2024-07-10Specialize address space during spirv legalization. (#4600)Yong He
* Specialize address space during spirv legalization. * Fix. * Fix building doc. * Fix cmake. * Update assert.
2024-07-10Fix the invalid spirv generation for matrix cast (#4588)kaizhangNV
Spirv doesn't have instruction to do the float cast for the matrix type. So we have to convert the matrix row by row, and then construct them to a new matrix. Update the unit test to make sure the cast won't miss any elements. Co-authored-by: Yong He <yonghe@outlook.com>
2024-07-10Add reflection API for functions. (#4587)Yong He
* Add reflection API for functions. This change adds `SlangFunctionReflection` type in the reflection API that provides methods for querying function result type, parameters and user-defined attributes. `ProgramLayout::findFunctionByName` can now find a function with the given name and returns a `FunctionReflection`. `IEntryPoint` now has a `getFunctionReflection` method that returns an `FunctionReflection` for the entrypoint. * More modifiers; make reflection API consistent.
2024-07-10Fix lowering of associated types and synthesis of dispatch functions. (#4568)Sai Praveen Bangaru
* Treat global variables and parameters as non-differentiable when checking derivative data-flow Global parameters are by-default not differentiable (even if they are of a differentiable type), because our auto-diff passes do not touch anything outside of function bodies. The solution is to use wrapper objects with differentiable getter/setter methods (and we should provide a few such objects in the stdlib). Fixes: #3289 This is a potentially breaking change: User code that was previously working with global variables of a differentiable type will now throw an error (previously the gradient would be dropped without warning). The solution is to use `detach()` to keep same behavior as before or rewrite the access using differentiable getter/setter methods. * Fix issues with lookup witness lowering * Update slang-ir-lower-witness-lookup.cpp * Add tests * Update slang-ir-lower-witness-lookup.cpp * Cleanup * Update nested-assoc-types.slang --------- Co-authored-by: Yong He <yonghe@outlook.com>
2024-07-10Implement non member function atomic texture support (#4544)ArielG-NV
* Implement non member function atomic texture support texture_buffer and texture1d Fixes: #4538 Related to: #4291, fixes `tests/compute/atomics-buffer.slang` Texture objects cannot use `__getMetalAtomicRef` to cast objects into atomic value type. [Texture objects mandate use of member functions](https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf#Texture%20Functions). The implementation is as follows: * We can detect texture object usage through checking for an `IRImageSubscript` Operation. `__isTextureAccess()` was added to evaluate if we have an `IRImageSubscript` operation at compile time (before `static_assert`). `__isTextureAccess()` only checks if we are targeting Metal. * We have all parameter data needed to call a texture atomic function embedded inside `IRImageSubscript`. `__extractTextureFromTextureAccess()` and `__extractCoordFromTextureAccess()` was added to extract this data for use with Metal atomics. Note: * Metal documentation has various incorrect details (function names) * Since we currently hardcode metal versions for compiling, the Metal compiler version was changed to target `Metal 3.1` (`slang-gcc-compiler-util.cpp`) * textures do not permit atomic float operations * add fallthrough attribute + fix bug with 'exchange instead of xor' + fix warning bug * incorrect function name fix * missing filecheck * disable atomics-buffer.slang compute test since GFX issue causing it to fail * Array support for metal interlockedAtomic and proper verification of texture with interlockedAtomic functions * Array support for metal interlockedAtomic * proper verification of texture with interlockedAtomic functions note: had to seperate many functions to allow forceInlining to run * missing getOperand(0) * push atomic fix for metal * fix atomic syntax for metal and hlsl emitting extra brackets (breaks tests) * test changes and meta changes 1. max is 8 rw textures with metal because Metal has this limit. Split up tests to not hit this limit 2. added back `[0]`...,`T` to test since this legalizes metal atomic intrinsic * macro'ify some of the atomic code 1. addresses review 2. makes code easier to modify in the future (rather than sifting through 1000 lines we can just look at ~10-30 * fix test 'check' * missing float support due to macro * add functions macro generates, `InternalAtomicOperationInfo` --------- Co-authored-by: Yong He <yonghe@outlook.com>
2024-07-10Fixes to Metal Input parameters and Output value input/output semantics (#4536)ArielG-NV
* initial change to test with CI for CPU/CUDA errors * Fixes to Metal Input parameters and Output values Note: 1. Flattening a struct is the process of making a struct have 0 struct/class members. Changes: 1. Separated `legalizeSystemValueParameters`. This was done to make it easier to run `legalizeSystemValue` 1 system-value at a time to simplify logic. This change is optional and can be undone if not preferred. 2. Wrap everything inside a Metal legalization context. This was done since it simplifies a lot of logic and will be required for #4375 3. Created `convertSystemValueSemanticNameToEnum` and expanded the existing System-Value Enum system. This allows (sometimes) faster comparisons and helps prepare code for porting into `slang-ir-legalize-varying-params.cpp` (#4375) 4. Added a more dynamic `legalizeSystemValue` system so more than 2 types can be targeted for legalization. This is required to legalize `output`. There is still no preference for any converted type, the first valid type will be converted to. 5. Flatten all input(`flattenInputParameters`)/output(part of `wrapReturnValueInStruct`) structs and assign semantics accordingly. 6. Semantics when legalized have no specific logic other than to: 1. avoid overlapping semantics 2. Prefer assigning explicit semantics specified by a user. 7. Fixed some issue with incorrect output semantics if not a fragment stage (when there are not any assigned semantics) * change metallib test to the correct metal test * comment code & cleanup -- Did not address all review Added comments for clarity + cleaned up some odd areas which were messy * Add comment to `fixFieldSemanticsOfFlatStruct` I found `fixFieldSemanticsOfFlatStruct` to still be confusing at a cursory glance. Added comments to make the function be more understandable. * white space * Address review comments 1. Fix semantic propegation. 2. Fix how we map struct fields of the flat struct to struct. This is specifically important for if reusing the same struct twice since struct member info is not unique per struct instance used. * Fix semantic legalization by adding TreeMap Add TreeMap to allow proper sorted-object data iteration. * Fix some compile issues * try to fix gcc compile error * compile error * fix logic bug in treeMap iterator next-semantic setter * fix vsproject filters * filter file syntax error * remove need of a context to make copies stable * Rename treemap to the more appropriate name of "treeset", adjust code comments accordingly. * remove custom type `TreeSet` and use `std::set` * remove TreeMap fully --------- Co-authored-by: Yong He <yonghe@outlook.com>
2024-07-10add GL_EXT_ray_tracing_position_fetch (#4566)ArielG-NV
2024-07-10Support status argument for GatherXXX (#4490)Jay Kwak
* Support status argument for GatherXXX This commit adds an argument to all texture GatherXXX functions. The new argument is for "status" as described in SM5.0 definision. Close #4466 Limit Gather with status to HLSL Exclude Gather-status test from VK * Fix capability errors --------- Co-authored-by: Yong He <yonghe@outlook.com>
2024-07-10Various fixes around differentiable member associations ↵Sai Praveen Bangaru
`[DerivativeMember(<diff-member>)]` (#4525) * Add diagnostic for missing diff-member associations + Automatically create diff member associations if differential type is the same as the primal type. + Move diff-member attribute checking to conformance-checking phase to avoid circularity issues. Fixes #4103 * Update slang-check-decl.cpp --------- Co-authored-by: Yong He <yonghe@outlook.com>
2024-07-10Emit spirv insts in the right sections. (#4590)Yong He
2024-07-09Warnings for uninitialized values (#4530)venkataram-nv
This extends the code for handling uninitialized output parameters. Still needs to handle generic templates and assignment of uninitialized values more carefully. The file containing the relevant code are now in source/slang/slang-ir-use-uninitialized-values.cpp rather than the previous source/slang/slang-ir-use-uninitialized-out-param.h and the top-level function is now checkForUsingUinitializedValues. Additionally a rudimentary test shader has been added for this case, which replaces the old file for out params only; tests/diagnositcs/uninitialized-out.slang becomes tests/diagnositcs/uninitialized.slang. What this does not implement (could be future PRs): * Checking uninitialized fields within constructors * Partially uninitialized values with respect to data structure (e.g. arrays/structs/vector types) * Partially uninitialized values with respect to control flow (e.g. if/else/loop)
2024-07-09Fix Lexer to recognize swizzling on an integer scalar value (#4515)Jay Kwak
* Fix Lexer to recognize swizzling on an integer scalar value Close #4413
2024-07-09Add intrinsic for clock2x32ARB (#4563)kaizhangNV
2024-07-08Fix the issue in emitFloatCast (#4559)kaizhangNV
* Fix the issue in emitFloatCast In emitFloatCast function, we only considered the input type is float scalar or float vector, so if the input type is a float matrix type, it will crash. We should also handle the float matrix type. Also, we add some diagnose info to point out the source location where there is error happened, so in the future it's easier to tell us what happens. * Add a unit test * Disable the test for metal Metal doesn't support 'double'. " metal 32023.35: /tmp/unknown-YgHAsJ.metal(15): error : 'double' is not supported in Metal matrix<double,int(3),int(4)> b_0 = matrix<double,int(3),int(4)> (a_0); "
2024-07-08Language server performance and document symbol fix. (#4561)Yong He
2024-07-08Treat global variables and parameters as non-differentiable when checking ↵Sai Praveen Bangaru
derivative data-flow (#4526) Global parameters are by-default not differentiable (even if they are of a differentiable type), because our auto-diff passes do not touch anything outside of function bodies. The solution is to use wrapper objects with differentiable getter/setter methods (and we should provide a few such objects in the stdlib). Fixes: #3289 This is a potentially breaking change: User code that was previously working with global variables of a differentiable type will now throw an error (previously the gradient would be dropped without warning). The solution is to use `detach()` to keep same behavior as before or rewrite the access using differentiable getter/setter methods.
2024-07-05Add vector overloads for or and and (#4529)Ellie Hermaszewska
* Add vector overloads for or and and Closes #4441 and #4434 * Disable cuda checks which use unsupported bool vectors * Add tests for 4531
2024-07-05Add specializations for 1 vectors in functions using the $N glsl intrinsic ↵Ellie Hermaszewska
placement (#4534) Closes #4533 Fixes part of #4531
2024-07-02Emit errors when invalid capabilities are used (#4510)ArielG-NV
* Fix invalid capabilities being allowed fixes: #4506 fixes: #4508 1. As per #4506, no longer allow invalid `[require(...)]` 2. As per #4508, no longer allow mismatch between `case` and `require` of a calling function 3. Fixes incorrect hlsl.meta capabilities 4. Added a ref to the parent function/decl for when erroring with capabilities to help debug meta.slang files for when weird source locations are generated. * rename vars and copy lambdas by value * fix some more capabilities * incorrect capabilities on a texture test * push capabilities fix note: seperated capabilities for glsl,spirv,cuda,hlsl since not all functions support all targets (source of capability error) * fix cmd line arg by using `xslang` to passthrough to slangc * let auto-infer run for certain capabilities to reduce simple mistakes --------- Co-authored-by: Jay Kwak <82421531+jkwak-work@users.noreply.github.com>
2024-07-01Fix the type error in kIROp_RWStructuredBufferLoad (#4523)kaizhangNV
* Fix the type error in kIROp_RWStructuredBufferLoad In StructuredBuffer::Load(), we allow any type of integer as the input. However, when emitting glsl code, StructuredBuffer::Load(index) will be translated to the subscript index of the buffer, e.g. buffer[index], however, glsl doesn't allow 64bit integer as the subscript. So the easiest fix is to convert the index to uint when emitting glsl. * Add commit
2024-07-01Support HLSL `.sample` operators for MS textures (#4524)venkataram-nv
* Add `.sample` operator for MS texture types * Adding filecheck tests for `.sample`
2024-07-01Supply SPIRV capability for textureQueryLod (#4522)venkataram-nv
2024-07-01Error out when constructing tensor views from tensors with 0 stride. (#4516)Sai Praveen Bangaru
This avoids a problem with broadcasted tensors. Our tensor-view platform is designed to allow unrestricted access to tensor memory, while broadcasted tensors were designed for 'read-only' use-cases. Trying to write into a broadcasted tensor needs re-allocation, which Slang is not designed to do. For now, we enforce contiguity on tensors with any 0 strides. In the future, we will introduce a ConstTensorView object to allow such tensors to be used as an input. This patch also propagates name-hint information through structs & arrays of tensors, to allow sensible names for the error messages (before this the error messages were temporary inst numbers, which is nearly impossible to debug)
2024-06-28Parse scope for local variable declaration (#4507)Jay Kwak
When a local variable is declaraed, a scope(::) was not properly parsed for its type name. This commit fixes it. Close #4457
2024-06-28Implement CheckAccessFullyMapped (#4509)Jay Kwak
* Implement CheckAccessFullyMapped Closes #4438 Closes #4445 Closes #1712 Related to #4495 This commit implements "CheckAccessFullyMapped()" for HLSL target. All of other "status" variants for Sample/Load are limited to HLSL by the capability system, because they not properly implemented yet.
2024-06-29Nested initialization list in struct crash fix (#4491)ArielG-NV
2024-06-28fix `WorkgroupSize()` compiler failiure (#4505)ArielG-NV
in some cases was not destroying the hoisted to global `WorkgroupSize()` function removed capability requirement on `gl_WorkGroupSize` since no longer appies (kIROp of `WorkgroupSize` is implemented for all targets) change when destroying inst
2024-06-28Implement HLSL resource bindings and default type `float4` to ↵ArielG-NV
`SubpassInput<T>` (#4462) * Add case to `emitVectorReshape` for `vector<>` type, `scalar` value 1. Add new case 2. Add test * fix warning * fix warning * Implement HLSL resource bindings and default type `float4` to `SubpassInput<T>` fixes: #4440 1. Removed GLSLInputAttachmentIndexLayout modifier and the somewhat 'hacky' binding model 'Input Attachment' previously relied upon. This was changed to work with the slang-type-layout rules system. This change allows Slang automatic bindings, HLSL bindings, GLSL bindings, and translation of GLSL to and from HLSL bindings to work. 2. Added default argument `float4` to SubpassInput<T>. 3. Merged glsl.meta and hlsl.meta SubpassInput logic. * fix InputAttachment attribute checks fix InputAttachment attribute checks for HLSL and GLSL syntax * remove unused var * validate attribute correctly Attributes do not have type information. We must check the type expression to validate attribute usage. * remove hacky validation type based validation before types are fully resolved is quite hacky and unstable to changes and wrapped types * fix warning * remove redundant `!= nullptr` * remove extra `!= nullptr` * fix some warnings/errors * subpass capability to limit to dxc & remove default values in some functions * revert logic to previous logic revert logic to return if we have a binding regardless of if a VarDecl is given the binding