| Commit message (Collapse) | Author | Age |
| |
|
|
| |
Random drive-by test fix, this was reading past the end of the buffer
but usually succeeded because the expected result is 0.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add built-in type aliases for DepthTexture* and unify Sampler*Shadow
Add the following type aliases:
- DepthTexture1D, DepthTexture1DArray
- DepthTexture2D, DepthTexture2DArray
- DepthTexture2DMS, DepthTexture2DMSArray
- DepthTexture3D
- DepthTextureCube, DepthTextureCubeArray
These match with the type aliases for non-depth textures.
Also, unify the Sampler*Shadow type aliases with DepthTexture*
ones. This adds the following:
- Sampler2DMSShadow
- Sampler2DMSArrayShadow
and removes the Sampler3DArrayShadow type alias. As a side-effect, the
descriptions of Sampler*ArrayShadow type aliases are fixed
("texture-sampler for shadow" ==> "texture-sampler array for shadow").
Update the slang tests to use the newly introduced type aliases instead
of
the custom type aliases that use _Texture<> directly.
Add DepthTexture testing in
hlsl-intrinsic/texture/texture-intrinsics. Do this by extracting the
test logic of computeMain() in a separate function and parametrize it
for non-depth/depth texture types. This adds basic coverage for the
following types:
- DepthTexture1D
- DepthTexture2D
- DepthTexture3D
- DepthTextureCube
- DepthTexture1DArray
- DepthTexture2DArray
- DepthTextureCubeArray
Issue #6166
Issue #8503
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(#8547)
This allows us to specialize functions whose argument is a sub element
of a constant buffer, instead of being only applicable to entire buffer
element. Closes #8421.
This change also implements a proper heuristic to determine when to
specialize the calls and defer the buffer loads.
This PR addresses a pathological case exposed in
`slangpy\slangpy\benchmarks\test_benchmark_tensor.py`, which used to
take 27ms to finish, and now takes 1.25ms.
For example, given:
```
struct Bottom
{
float bigArray[1024];
[mutating]
void setVal(int index, float value) { bigArray[index] = value; }
}
struct Root
{
Bottom top[2];
[mutating]
void setTopVal(int x, int y, float value)
{
top[x].setVal(y, value);
}
}
RWStructuredBuffer<Root> sb;
[shader("compute")]
[numthreads(1, 1, 1)]
void compute_main(uint3 tid: SV_DispatchThreadID)
{
sb[0].setTopVal(1, 2, 100.0f);
}
```
We are now able to specialize the call to `setTopVal` into:
```
void compute_main(uint3 tid: SV_DispatchThreadID)
{
setTopVal_specialized(0, 1, 2, 100.0f);
}
void setTopVal_specialized(int sbIdx, int x, int y, float value)
{
Bottom_setVal_specialized(sbIdx, x, y, value);
}
void Bottom_setVal_specialized(int sbIdx, int x, int y, float value)
{
sb[sbIdx].top[x].bigArray[y] = value;
}
```
And get rid of all unnecessary loads. Achieving this requires a
combination of function call specialization and buffer-load-defer pass.
The buffer-load-defer pass has been completely rewritten to be more
correct and avoid introducing redundant loads.
This PR also adds tests to make sure pointers, bindless handles, and
loads from structured buffer or constant buffers works as expected.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When we legalize the entry point param, there are cases where we need to
reconstruct a struct for the parameter and the original struct wouldn't
be used. But if the user tries to use the origianl struct as a type for
a function parameter, we will end up using both the original struct and
the synthesized struct at the same time.
On Metal and WGSL, it causes an error when an identical semtaic is used
on more than one variable.
This commit removes the semantics from the original struct after cloning
the type.
Fixes https://github.com/shader-slang/slang/issues/8141
Related to https://github.com/shader-slang/slang/issues/7693
---------
Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add emit cases for WGSL and GLSL
* Fix compilation warnings
Modify short cutting test to reflect change in emit logic
Lower matrix for metal as well
Add emit matrix logic for metal
Fix compiler warning
Brace initializer for lowered matrices
Fix compiler warnings
* Tests for metal
* Fix mult, any, and determinant
* Fix matrix-matrix multiplication
* Fix mat mul to be element-wise
* Fix compiler warning
* Move makeMatrix to legalization
* Move unary and binary arithmetic operator lowering to legalization
* Remove emit logic and move final comparison operators to legalization
* Handle vector/matrix negation for WGSL
* Restore older SPIR-V emit logic
* Address PR comments
* Revert to zero minus for negation
* format code
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Initial plan
* Implement int16_t/uint16_t support for WGSL target
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Change int16_t/uint16_t to emit proper diagnostics instead of auto-promoting
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Implement diagnoseOnce to prevent duplicate diagnostics
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Optimize diagnoseOnce to use HashSet::add() return value
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Apply code formatting to slang-emit-c-like.h
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Fix diagnoseOnce to use all parameters instead of first parameter only
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Initial plan
* Fix crash in WGSL L-value cast lowering with type mismatches
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Apply formatting to fix
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Update test to verify successful compilation instead of error checking
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
Co-authored-by: Yong He <yonghe@outlook.com>
|
| |
|
|
|
|
|
|
|
| |
* Fix generation of wgsl case arms
* Added test case to test generation of switch case
---------
Co-authored-by: Harsh Aggarwal (NVIDIA) <haaggarwal@nvidia.com>
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* update slang-rhi submodule
* slang-rhi API changes
* disable agility sdk
* fix texture creation
* update formats in tests
* Extent3D rename
* use 1 mip level for 1D textures for Metal
* fix texture upload
* update to latest slang-rhi
* update slang-rhi
* format code
* update slang-rhi
* do not run texture-intrinsics test on metal
* update slang-rhi
* deal with failing tests
* fix more tests
* update slang-rhi
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Co-authored-by: Simon Kallweit <simon.kallweit@gmail.com>
|
| |
|
|
|
|
| |
Fixes issue #6533
This patch updates handling of Array and ConstantBuffer types for WGSL
transpiling, giving correct syntax for arrays of buffers in WGSL.
|
| |
|
|
|
| |
* Add WGSL to list of formats supporting multiple entry points
* Add a test for generating multiple WGSL entrypoints
|
| |
|
|
|
|
| |
This case now parses after the following PR was merged.
https://github.com/shader-slang/slang/pull/6281
Co-authored-by: Yong He <yonghe@outlook.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* add brga8 format
* add tests
* minor fixes
* cleanup
* maybe fix broken quad control test
* add missing xslang flag on test
---------
Co-authored-by: Yong He <yonghe@outlook.com>
|
| |
|
|
|
|
|
|
|
| |
* Refactor _Texture to constrain on texel types.
* Fix tests.
* Fix.
* Disable glsl texture test because rhi can't run it correctly.
|
| |
|
| |
Co-authored-by: Yong He <yonghe@outlook.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
* Add test that reproduces the issue in #5986
* Call moveGlobalVarInitializationToEntryPoints for WGSL as well
This closes #5986.
---------
Co-authored-by: Yong He <yonghe@outlook.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* WGSL: Fixes for signed shift amounts
- Handle the case of vector shift amounts
- Closes #5985
- Move handling of scalar case from emit to legalization
- Add tests for bitshifts.
* Move the binary operator legalization function to a common place
* Metal: Legalize binary operations
Closes #6029.
* Fix Metal filecheck test
The int shift amounts are now converted to unsigned.
* format code
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Co-authored-by: Yong He <yonghe@outlook.com>
|
| |
|
| |
This closes #6005.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
* Add parentheses to make precedence explicit
Add parentheses for a few cases that Dawn/Tint (WGSL compiler) complains about.
Closes #6005.
* format code
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Co-authored-by: Yong He <yonghe@outlook.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Respect explicit bindings in wgsl emit.
* Implement explciit binding generation for metal and wgsl.
* Update toc.
* Fix warnings in tests.
* Fix tests.
---------
Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Closes https://github.com/shader-slang/slang/issues/5067
New tests, covering what's declared supported in the WGSL support docs
- tests/wgsl/semantic-coverage.slang
- tests/wgsl/semantic-depth.slang
- tests/wgsl/semantic-dispatch-thread-id.slang
- tests/wgsl/semantic-group-id.slang
- tests/wgsl/semantic-group-index.slang
- tests/wgsl/semantic-group-thread-id.slang
- tests/wgsl/semantic-instance-id.slang
- tests/wgsl/semantic-is-front-face.slang
- tests/wgsl/semantic-position.slang
- tests/wgsl/semantic-sample-index.slang
- tests/wgsl/semantic-vertex-id.slang
WGSL enabled existing tests:
- tests/compute/compile-time-loop.slang
- tests/compute/constexpr.slang
- tests/compute/discard-stmt.slang
- tests/metal/nested-struct-fragment-input.slang
- tests/metal/nested-struct-fragment-output.slang
- tests/metal/nested-struct-multi-entry-point-vertex.slang
- tests/metal/no-struct-vertex-output.slang
- tests/metal/sv_target-complex-1.slang
- tests/metal/sv_target-complex-2.slang
- tests/bugs/texture2d-gather.hlsl
- tests/render/cross-compile-entry-point.slang
- tests/render/nointerpolation.hlsl
- tests/render/render0.hlsl
- tests/render/cross-compile0.hlsl
- tests/render/imported-parameters.hlsl
- tests/render/unused-discard.hlsl
Can't be enabled due to missing wgsl features
- tests/compute/texture-sampling.slang
Co-authored-by: Yong He <yonghe@outlook.com>
|
| |
|
|
|
| |
* Fix wgsl legalization around __ref parameter.
* Add intrinsic and test case.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* [WGSL] Enable arbitrary arrays in uniform buffers.
* format code
* Undo irrelevant change and fixups.
* Update expected failure list.
* Fix.
* Rename.
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Legalize the Entry-point for WGSL
The return type of the entry-point needs to be legalized when targeting
WGSL.
This commit flattens the nested-structs of the return type and the input
parameters of the entry-point.
Most of code is copied from the legalization code for Metal. The
following functions are exactly same to the implementation for Metal or
almost same.
- flattenInputParameters() : 136 lines
- reportUnsupportedSystemAttribute() : 7 lines
- ensureResultStructHasUserSemantic() : 46 lines
- struct MapStructToFlatStruct : 176 lines
- flattenNestedStructs() : 95 lines
- maybeFlattenNestedStructs() : 42 lines
- _replaceAllReturnInst() : 19 lines
- _returnNonOverlappingAttributeIndex() : 16 lines
- _replaceAttributeOfLayout() : 23 lines
- tryConvertValue() : 41 lines
- legalizeSystemValueParameters() : 11 lines
They need to be refactored to reduce the duplication later.
The test case, `tests/compute/assoctype-lookup.slang`, had a bug that
the compute shader was trying to use the varying input/output with the
user defined semantics.
This commit removes the user defined semantics, because the compute
shaders cannot use the user defined semantics.
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add support for write-only textures.
* Fix capabilities.
* Fix implementation.
* Fix.
* format code
---------
Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Overhaul docgen tool and setup CI to generate stdlib reference.
* Fix build error.
* Write parsed doc for all decls.
* fix.
* fix callout.
* Fix.
* Fix comment.
* Fix.
* Delete obsolete doc tests.
* Fix.
* Categorize functions and types.
* Fix CI.
* Update comments.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Use the assembly description as target when disassembling
I believe this is a bugfix.
It seems to have worked before because up until the WGSL case, the disassembler has been
the same executable as the one producing the binary to be disassembled.
* Add Tint as a downstream compiler
This closes issue #5104.
* Add downstream compiler for Tint.
* Tint is wrapped in a shared library, 'slang-tint' available from [1].
* The header file for slang-tint.dll is added in external/slang-tint-headers.
* Add some boilerplate for WGSL targets.
* Add an entry point test for WGSL.
[1] https://github.com/shader-slang/dawn/releases/tag/slang-tint-0
* Add WGSL_SPIRV as supported target for Glslang
* Add WebGPU support to slang-test
This helps to address issue #5051.
* Disable lots of crashing compute tests for 'wgpu'
This closes issue #5051.
---------
Co-authored-by: Yong He <yonghe@outlook.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Implement texture_storage_Xd in WGSL
This commit implements `texture_storage_Xd` in WGSL, which is similar
to RWTextureXD in HLSL.
It is intresting that `texture_storage_Xd` doesn't take the shader
type as its input argument at all.
Instead, it takes "texel format" enum value as its first template
parameter, which can be found here:
https://www.w3.org/TR/WGSL/#storage-texel-formats
As an example, `texture_storage_2d<rg32uint, read_write>` expects
vec4<u32> as a value type for `Load` and `Store`, where Z-component
will be ignored and treated as zero and W-component will be treated
always as 1. The type `u32` is inferred from the enum value `rg32uint`.
Note that the number of component is always fixed to 4 regardless how
many components are actually stored.
|
| |
|
|
|
|
|
|
|
| |
* WGSL texture support for depth and multisampled
This commit fixes a few issues with WGSL texture intrinsics.
- static_assert-s are corrected.
- Gather functions work properly with depth textures
- Load functions work properly with depth textures and multisampled
textures
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
This PR implements the texture gather functions for WGSL.
The pattern was very similar to how Metal was implemented.
Before copy and paste from the Metal implementation, I had to
clean up the Metal implementation to make it more readable
and maintainable.
Gather functions are available only for 2D and 3D textures.
Their `array` and `depth` variants may or may not be supported depending on the target.
`static_assert` ensures that Gather functions are available only for 2D and 3D textures.
Removed incorrect use of "$p" argument for targeting GLSL.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
* Implemented Combined-texture for WGSL
* Remove unnecessary comment
* Limit to std430 layout
* Fix compiler warning for unused variable
---------
Co-authored-by: Yong He <yonghe@outlook.com>
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
This commit implements all of the texture intrinsics for WGSL except "Gather" and sampler-less.
They will be implemented in a separate PR.
A few things to note:
- texture sampling functions are available only for the fragment shader stage; not for compute
- WGSL doesn't have any functions similar to CalculateLevelOfDetail or CalculateLevelOfDetailUnclamped.
- WGSL doesn't have a function overlaoding for textureSample with "clamp" or "status" arguments.
- WGSL doesn't support Load operation with offset for texture_multisampled_XX and texture_storage_XX.
- WGSL supports only four types of depth textures: 2D, 2D_array, cube and cube_array.
- WGSL doesn't support "offset" variants for cube and cube_array.
|
|
|
* Implement math intrinsics for WGSL
This commit implements math related intrinsics and a few others for
WGSL.
The implementation is based on the following doc,
https://www.w3.org/TR/WGSL
slang-test was looking for the downstream compiler for WGSL even though
it is not used.
This commit adds a minimal change to avoid the crash.
|