| Age | Commit message (Collapse) | Author |
|
* Cope with failed version parsing
* Better version parsing
* populate slang-tag-version with cmake
* Neaten cmake
|
|
* Specialize address space during spirv legalization.
* Fix.
* Fix building doc.
* Fix cmake.
* Update assert.
|
|
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>
|
|
* 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.
|
|
* 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>
|
|
* 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>
|
|
* 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>
|
|
|
|
* 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>
|
|
`[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>
|
|
|
|
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)
|
|
* Fix Lexer to recognize swizzling on an integer scalar value
Close #4413
|
|
|
|
* 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);
"
|
|
|
|
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.
|
|
* Add vector overloads for or and and
Closes #4441 and #4434
* Disable cuda checks which use unsupported bool vectors
* Add tests for 4531
|
|
placement (#4534)
Closes #4533
Fixes part of #4531
|
|
* 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>
|
|
* 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
|
|
* Add `.sample` operator for MS texture types
* Adding filecheck tests for `.sample`
|
|
|
|
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)
|
|
When a local variable is declaraed, a scope(::) was not properly parsed
for its type name. This commit fixes it.
Close #4457
|
|
* 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.
|
|
|
|
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
|
|
`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
|
|
* Extend `countbits` intrinsic for vector types
This commit implements the overloading function for `countbits` function.
Because HLSL has following overloadings,
```
uint count_bits(uint value);
uint2 count_bits(uint2 value);
uint3 count_bits(uint3 value);
uint4 count_bits(uint4 value);
```
https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/countbits
|
|
* Cache address-space-legalization of `kIROp_Store`
without caching we will infinetly loop re-processing the same `kIROp_Store`
* uncomment tests which should now work with metal
* disable gfx backend failing tests
|
|
* Add API for querying dependency files on IModule
* return nullptr
|
|
* Implement asdouble2 intrinsic and tests
Fixes #4437
Adds a new asdouble2 intrinsic for all platforms except Metal.
Extends the test for asdouble to test asdouble2 as well.
|
|
* disable return array optimization pass for metal targets
fixes: #4468
|
|
* Fix Texture2DMSArray
Close #4427
We had the postfix order wrong for the keyword MS. This commit changes
the incorrect name Texture2DArrayMS to Texture2DMSArray.
|
|
* Add additional `ImageSubscript` features:
1. Added ImageSubscript support for Metal & a test case
* Merge GLSL/SPIRV/Metal `ImageSubscript` legalization pass
2. Added multisample support to glsl/spirv/metal for when using ImageSubscript
* Added in this PR since the overhaul of the code merges together GLSL/SPIRV/Metal implementation
3. Fixed minor metal texture `Load`/`Read` bugs
* [HLSL methods of access do not support subscript accessor for texture cube array](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/texturecubearray)
* removed swizzling of uint/int/float
* other odd bugs which were causing compile errors
note: Compute tests do not work due to what seems to be the GFX backend (causes crash without error report). The tests are disabled.
* disable LOD with texture 1d
seems that LOD for 1d textures need to be a compile time constant as per an error metal throws
* syntax error in hlsl.meta
* static_assert alone with intrinsic_asm error
provides cleaner errors
Note: `static_assert` seems to be unstable and not be fully respected (still require `intrinsic_asm` to avoid a stdlib compile error)
* change comment to `// lod is not supported for 1D texture
* add `static_assert` in related code gen paths
* address review
* address review
* add asserts as per review comment, NOTE: unclear if these should be release 'asserts' as well
|
|
* Support atomic intrinsics for Metal
This commit adds a support for the atomic intrinsics in Metal.
The atomic member functions for buffers is not implemented yet.
Metal requires the first argument for the atomic functions to be an
atomic data type. This implementation rely on the fact that we can do a
C-style type casting from a regular data type to an atomic data type.
|
|
solves: `func-resource-result-simple.slang`, related to #4291
when getting the address space of a function return we now check the return address of the inst if the return type is a non pointer type.
|
|
Add InHelperLane() intrinsic for HLSL, GLSL, Metal and Spirv.
|
|
`T` value (#4419)
* Add case to `emitVectorReshape` for `vector<>` type, `scalar` value
1. Add new case
2. Add test
* fix warning
* fix warning
|
|
* added float4x4<->float4 casting (and related)
Note: not adding `matrix<1,N>` and `matrix<N,1>` translations since this will bloat stdlib with many expensive to process `extension` operations. `matrix<N,1>` is already planned to be treated as vectors (which should solve this problem by proxy).
* address review
* explicit cast mat to vec
|
|
* Implementing `tbuffer` layouts.
1. Add to layout options 'TextureBuffer' layouts.
2. Add on to existing logic a way to allocate appropriate registers for TextureBufferType (this was made to work with parameter block logic).
3. Added asserts so objects missing a layout will gracefully crash
This means `tbuffer` now works for hlsl,glsl,metal targets, spirv has yet to implement logic for `TextureBufferType`.
* disable metal tests and fix emitting code a bit
fixing the emitting code means metal compilation emits a useful error (help point users/developers to #4435)
* fix warning
|
|
* Add capture logic to other interfaces.
Add capture logics to ISession, IModule, ITypeConformance, IEntryPoint
ICompositeComponentType.
Add few encode methods to encode the array.
Fix some capture logic in global session. We will not need to encode
the null_ptr output before actual actual of the captured APIs.
Previously we used this as a place holder, but it's actually not
necessary, it can be detected if the output is not captured during
replay.
* capture/replay: dump the shader files to disk
Dump the shader files to disk.
Also set a default directory for the capture files.
|
|
Closes #4414
|
|
* Metal: Implement fix for non vector4 texture Load/Sample
1. Fixes buffer-swizzle-store
2. Added test cases to texture.slang to cover all types
* remove 1d lod support and buffer swizzle store
this can be enabled later
|
|
* Add the function tailer for appending the output
- The basic format for the capture encode is as follow:
Header:
4 bytes: magic number ('H' 'E' 'A' 'D' )
4 bytes: call id - specify the method name
8 bytes: handle id - specify 'this' pointer
8 bytes: payload size in bytes - specify the data size of parameters
8 bytes: thread id
Payload:
Encode for all the parameters.
Tailer (optional):
Tailer is an optional, it only used when the output of the method is
also stored in the method. Usually it just the opaque handle allocated
by slang.
4 bytes: magic number ('T' 'A' 'I' 'L')
4 bytes: payload size in bytes.
- Fix some issues in checking the result of write of output stream.
* Encoding methods of IGlobalSession
Add encoding logic for all the member functions of IGlobalSession,
except those query functions that do not impact the internal state
of slang.
Because some get functions will invoke allocations by slang, these
functions are account for the "query functions". Therefore those
functions are still captured.
All the allocations are stored by using their address, because those
allocations are opaque and will finally be used as inputs for other
APIs, there is no need to store the data. We just need to track
those address and know which APIs will consume them.
* Add SLANG_CAPTURE_CHECK macro
Add SLANG_CAPTURE_CHECK macro to check SLANG_OK is returned.
* Fix build error
|
|
|
|
|
|
'raytracing' and 'texture-footprint' tests
fixed texture-footprint bug
changed when we emit raytracing/rayquery extensions with glsl backend (to reduce incorrect extension emitting)
|
|
* [Metal] Fix global constant array emit.
* Try enable more tests.
|