Skip to content

Commit

Permalink
Merge/vsdk 1.4.304 (#6199)
Browse files Browse the repository at this point in the history
* Fix prebuilt dependencies filenames on non-windows platforms (#5848)

* Correct casing of windows includes (#5849)

* Bump imgui for include fix (#5854)

* Add missing header for _getpid() (#5852)

* Set default hidden visibility for all source on gcc (#5850)

* Correctly distinguish between windows and MSVC (#5851)

Partially sorts #5843

* Add SLANG_ENABLE_DXIL (#5853)

* WGSL: Fix issue where global calls are generated (#5768)

* Split out SPIR-V -specific legalization of global functions

This is a refactoring and should not affect generated code.

* Move global inst inlining code into separate function

This is a refactoring and should not affect generated code.

* Take SPIR-V -specific parts out of GlobalInstInliningContext

This is a refactoring and should not affect generated code.

* Move 'inlineGlobalValues' to generic inlining context

This is a refactoring and should not affect generated code.

* Move 'setInsertBeforeOutsideASM' to generic inlining context

This is a refactoring and should not affect generated code.

* Move generic inlining context into own file

This is a refactoring and should not affect generated code.

* Run global inlining for WGSL as well

* Make the 'getOutsideASM' function generic as well

* Enable language-feature/constants/static-const-in-generic-interface.slang for WebGPU

* Clarify when it's safe to remove and deallocate an IRInst

* Remove globals if they're left unused after inlining

This closes #5607.

* Handle IRGlobalValueRef in C-like emitter

* format code

---------

Co-authored-by: slangbot <[email protected]>

* Add an example for using the reflection API (#5839)

* Add an example for using the reflection API

The example program is meant to accompany a document that goes into more detail about the mental model behind the reflection API and the way this program drives it.
Ideally this program can land before the document goes live, and then the document can be published with a link to the example.
After that, the example could be updated to include links into the live document.

Along with adding the example program, this change also adds some convenience functions to the reflection API to avoid cases where the program would otherwise need to cast between
`slang::ParameterCategory` and `SlangParameterCategory`.

* format code

* fixup: error noticed by clang

---------

Co-authored-by: slangbot <[email protected]>

* use Release over RelWithDebInfo for ci (#5846)

This will necessetate changing the "required tests" setting on the GitHub repo

Co-authored-by: Yong He <[email protected]>

* Bit extract (#5847)

* promoting bitfield extraction and insertion to become intrinsics for internal compiler use

* removing duplicate intrinsics from glsl.meta.slang

* refactor: update function signatures of bitfield extraction and insertion to use uint as the parameter type for offset and bits.

---------

Co-authored-by: Nate Morrical <[email protected]>
Co-authored-by: Yong He <[email protected]>

* Make slang-rhi's NVAPI support conditional on SLANG_ENABLE_NVAPI (#5855)

* bump slang-rhi

* More precise slang-rhi settings

---------

Co-authored-by: Yong He <[email protected]>

* Update reflection API chapter in User Guide (#5868)

* Update reflection API chapter in User guide

The new version of the chapter is intended to
accompany the `reflection-api` example program,
and reflects (pun intended) the best practices
that the Slang project team wants to encourage
for interacting with the reflection API.

* Rebuild TOCs

* Enable exprs for all supported GLSL layout qualifiers (#5857)

* install mono for toc generation (#5877)

Closes #5876

* Support matrix negation in metal backend. (#5891)

* Fix `getArgumentValueFloat` when arg is int. (#5888)

* Fix `getArgumentValueFloat` when arg is int.

* format code

---------

Co-authored-by: slangbot <[email protected]>

* Update 09-reflection.md (#5886)

* Fix entrypoint auto discovery logic. (#5885)

* Fix entrypoint auto discovery logic.

* format code

---------

Co-authored-by: slangbot <[email protected]>

* Implement bitcast for 64-bit date type (#5895)

Close #5470

* implement bitcast for 64-bit date type
* Move 'ensurePrelude' to base class to remove duplication
* Assert on 'double' type for Metal target, as Metal doesn't have 'double' support

* Support specializing generic entrypoints in `findAndCheckEntryPoint`. (#5890)

* Add verification logic on push and specialization constants. (#5887)

* Add verification logic on push and specialization constants.

* format code

---------

Co-authored-by: slangbot <[email protected]>

* Add slang example tests to CI (#5879)

* Examples: Don't proceed if 'initializeBase' fails

* Examples: Only access gWindow if it's been initialized

* Examples: Free memory from CommandLineToArgvW

* Add example run step to CI

Lots of examples are still unexpectedly failing, but is one small step towards addressing
issue #5520.

* Allow `Optional`, `Tuple` and `bool` to be used in varying input/output. (#5889)

* Allow `Optional` and `Tuple` to be used in varying input/output.

* Fix.

* format code

* Fix.

* Fix test.

* Fix.

* enhance test.

* Fix.

* format code

---------

Co-authored-by: slangbot <[email protected]>

* Fix metadata of register space and varying params. (#5906)

* Support explicit `[vk::location(n)]` binding on metal/wgsl. (#5907)

* Check decl nesting for namespaces. (#5910)

* Fix the parser issue for not recognize Generic<T>[N] (#5912)

Close #5911.

In this issue, if we define the generic in source file 1,
and import it into source file 2, then when parsing the
reference of that generic in source file 2, we will not parse
the generic directly, instead we have a logic to speculate it
as generics first with a fake diagnostic sink, and if there is
no error report, we will consider it as a actual generic and will
parse it again.

In this logic, we will also disambiguate the expression based on
the following token, but we didn't consider the token '[', so we
will finally not treat the expression as generic.

The fix is just simply add '[' here.

Co-authored-by: Yong He <[email protected]>

* Refresh list of failing examples (#5904)

This helps to address issue #5520.

* Fix issues reported by 'shellcheck' (#5913)

* Fix issues reported by 'shellcheck'

This helps to address issue #5520.

* format code

---------

Co-authored-by: slangbot <[email protected]>

* Report error when generated spirv is empty. (#5899)

* Report error when generated spirv is empty.

* format code

---------

Co-authored-by: slangbot <[email protected]>
Co-authored-by: Ellie Hermaszewska <[email protected]>

* Readme corrections (#5874)

Closes #4806

* Add HLSL texture sample with status intrinsics (#5901)

* Implement HLSL texture sample with status intrinsics

* fix test and cleanup

---------

Co-authored-by: Yong He <[email protected]>

* Enable more examples in CI (#5915)

* CI: examples: Add support for filtering on platform

* Add platform field to example run IDs

- Remove the reflection-api entry for Windows.
- Add 'aarch64' as platform for all 'macos' entries.
- Add 'x86_64' as platform for all other entries.
 - This will implicitly enable all aarch64 tests for Linux.

This helps to address issue #5520.

* Add base vertex and base instance system values (#5918)

* Add base vertex and base instance system values

* Fixed incorrect stage in tests

* Fix crash during loop unrolling. (#5920)

* Check subscript/property accessor for differentiability. (#5922)

* Fix WASM build (#5925)

There is no objcopy and strip for WASM, so disable debug info stripping.

This closes #5924.

* Fixed stage and result field names in json reflection (#5927)

* update CTS package (#5935)

* Reflection API Wasm Bindings Part1 (#5936)

* add a lot of missing classes, functios and enums

* typescript defintion generation

* formatting

* format code

---------

Co-authored-by: slangbot <[email protected]>

* Support dispatchComputeIndirect and draw(Indexed)Indirect with count buffer for Vulkan (#5929)

* Support gfx ComputeCommandEncoder::dispatchComputeIndirect for Vulkan

* Support count buffer for Vulkan in gfx RenderCommandEncoder::drawIndirect and RenderCommandEncoder::drawIndexedIndirect

* Fix an unintended change

* Fix format issue

---------

Co-authored-by: Yong He <[email protected]>

* Add packed 8bit builtin types (#5939)

* Add packed bytes builtin type

* fix test

* Fix parsing GLSL SSBO arrays / bindless descriptors (#5932)

* Fix parsing GLSL SSBO arrays / bindless descriptors

* Clean up SSBO array parsing

* Fix mutable SSBO arrays not being detected as such

* Allow sized SSBO arrays

* format code

---------

Co-authored-by: slangbot <[email protected]>
Co-authored-by: Yong He <[email protected]>

* Fix tiny typos (#5944)

* Implement HLSL pack/unpack math intrinsics (#5934)

* Prevent constant folding for specialization constants (#5953)

* Skip uninitialized-use warning on hitAttributeEXT-decorated globals (#5952)

* Add a basic WebGPU example (#5923)

* Add a basic WebGPU example

This helps to address #5656.

* Use serial await rather than Promise.all

* Fix requirement candidate lookup to prefer decls in the same paraent as the inheritance decl. (#5965)

* Check mismatching method parameter direction against interface declaration. (#5964)

* Add `RaytracingAccelerationStructure::__init(uint64_t)`. (#5967)

* LanguageServer: fix highlighting of wrapper type. (#5968)

* Check for undefined %id in spirv_asm block. (#5966)

* Fix `getInheritanceInfo` for `ExtractExistentialType`. (#5971)

* Add terminateRayEXT & ignoreIntersectionEXT (#5974)

* Fix reflection for metal vector [[id]] location. (#5943)

* add missing IR_LEAF_ISA for MetalMeshType (#5975)

Co-authored-by: Yong He <[email protected]>

* Fixed incorrect condition in Session::queryInterface. (#5978)

An AND operator was used where an OR should have been used.

* Allow explicit test root (#5980)

* Correct IR generation for no-diff pointer type (#5976)

* Correct IR generation for no-diff pointer type

Close #5805 

There is an issue on checking whether a pointer type parameter
is no_diff, we should first check whether this parameter is
an Attribute type first, then check the data type.

In the back-propagate pass, for the pointer type parameter, we should
load this parameter to a temp variable, then pass it to the primal
function call. Otherwise, the temp variable will no be initialized,
which will cause the following calculation wrong.

* Fix parameter location reflection for pure data paramblocks. (#5956)

* Create DirectDeclRef when creating Decl to prevent invalid dedup. (#5945)

* Create DirectDeclRef when creating Decl to prevent invalid dedup.

* Fix test.

* fix

* update slang-rhi

* Make 'shared' keyword map to 'groupshared' in GLSL mode (#6003)

* CI: Build the full slang-wasm.[js|wasm] targets instead of just the slang library. (#5998)

A recent build breakage for slang-wasm.[js|wasm] was not noticed by CI since it built the
slang library target instead of the slang-wasm.js "executable" target.
(We added a that used objcopy to split debug info from executables. objcopy does not
report errors when it finds object files with unexpected format inside static libraries,
but it *does* report errors when it's run on an exceutable of unexpected format, such as
in the case of slang-wasm.js.)

This closes #5959.

* Fix GLSL mix(T,T,bool) SPIR-V output (#6006)

* Add support for textureLod with sampler2DArrayShadow (#6009)

* Add `Bindless<T>` proposal. (#6002)

* Add `Bindless<T>` proposal.

* Clarify on what happesn if native bindless T has different size/alignment.

* Add discussion on alternatives.

* Update reviewer.

* Properly set D3D12SDKPath (#5993)

* Properly set D3D12SDKPath

Closes #5992

This commit have an effect on slang-test.exe and test-server.exe.

When we run slang-test.exe, it uses D3D12Core.DLL located at
`build/{Release,Debug}/bin/D3D12`, which is `D3D12` from where the
executable file is located at.

This has been working fine but we found a case where it doesn't work
properly.  This commit sets D3D12SDKPath value explicitly to avoid
potential problems.

* Use disassemble API from SPIRV-Tools (#6001)

* Use disassemble API from SPIRV-Tools

This commit uses C API version of SPIRV disassemble function rather than
calling spirv-dis.exe.

This allows us to use a correct version of SPIRV disassble function that
Slangc.exe is using.

The implementation is mostly copied from external/spirv-tools/tools/dis/dis.cpp, which is a source file for building spirv-dis.exe.

This commit also includes a fix for a bug in RPC communication to `test-server`.

When an RPC connection to `test-server.exe` is reused and the second
test abruptly fails due to a compile error or SPIRV validation error,
the output from the first test run was incorrectly reused as the output
for the second test.

This commit resets the RPC result before waiting for the response so
that even when the RPC connection is erratically disconnected, the
result from the previous run will not be reused incorrectly.

Some of the tests appear to be relying on this type of behavior. By
using an option, `-skip-spirv-validation`, the RPC connection will
continue without an interruption.

* Fix some robustness issues in the examples (#5984)

* examples: Make hello-world example exit gracefully if VK cannot be initialized

- Check if VK API function pointers are valid before using them
- Return 0 and exit if VK initialization fails
- Enable hello-world example

* examples: Fixes for ray-tracing examples

- Assert that accelleration structure buffer is not nullptr
- Check if buffer creation succeeded before proceeding
 - This makes initialization not hang, but it still fails.
   Therefore, the test expectations are just updated to point to another issue.
- Enable ray-tracing tests on Windows

* Add example showing how to use Slang/WASM (#5996)

This closes #5656.

* Check whether array element is fully specialized (#6000)

* Check whether array element is fully specialized

close #5776

When we start specialize a "specialize" IR, we should
make sure all the elements are fully specialized, but
we miss checking the elements of an array. This change
will check the it.

* add test

* add all wrapper types into the check

* add utility function to check if the type is wrapper type

---------

Co-authored-by: zhangkai <[email protected]>
Co-authored-by: Yong He <[email protected]>

* Lower varying parameters as pointers instead of SSA values. (#5919)

* Add executable test on matrix-typed vertex input.
* Fix emit logic of matrix layout qualifier.
* Pass fragment shader varying input by constref to allow EvaluateAttributeAtCentroid etc. to be implemented correctly.

* Add backtraces to examples (#5973)

* examples: Log stack trace on exceptions

For now, this is only implemented on Windows.
This helps to address #5520.

* examples: Print log file if there is any

* format code

---------

Co-authored-by: slangbot <[email protected]>
Co-authored-by: Yong He <[email protected]>

* slang-test: Ensure runtime is consistent (#6021)

I hit issue #5305 again after re-generating the build directory, building and then running
slang-test.
In other words, D3D12 and Slang-RHI/WebGPU/D3D12 failed to create a device due to the
runtime being incosistent. Bilding copy-prebuilt-binaries fixed it, and so it's best to
make this step a dependency of slang-test.

* Add SampleCmpLevel intrinsics (#6004)

* add SampleCmpLevel intrinsics

* update tests

* fix typo

* fix broken glsl test

* refactor SampleCmpLevelZero

* fix metallib test

* fix broken test on dx12

---------

Co-authored-by: Yong He <[email protected]>

* Add parentheses to make precedence explicit (#6030)

* 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 <[email protected]>
Co-authored-by: Yong He <[email protected]>

* Pass compiler specific args to GCC and Visual Studio too (#6019)

Co-authored-by: Yong He <[email protected]>

* update slang-rhi (#6045)

* [Auto-diff] Overhaul auto-diff type tracking + Overhaul dynamic dispatch for differentiable functions (#5866)

* Overhauled the auto-diff system for dynamic dispatch

* More fixes

* remove intermediate dumps

* Update slang-ast-type.h

* More fixes + add a workaround for existential no-diff

* Update reverse-control-flow-3.slang

* remove dumps

* remove more dumps

* Delete working-reverse-control-flow-3.hlsl

* Cleanup comments + unused variables

* More comment cleanup

* Add support for lowering `DiffPairType(TypePack)` & `MakePair(MakeValuePack, MakeValuePack)`

* Fix array of issues in Falcor tests.

* Update slang-ir-autodiff-pairs.cpp

* More fixes for Falcor image tests

* Small fixups.

---------

Co-authored-by: Yong He <[email protected]>

* Upgrade actions/upload-artifact from v3 to v4 (#6051)

The version 3 of actions/upload-artifact will be deprecated soon.
https://github.blog/changelog/2024-04-16-deprecation-notice-v3-of-the-artifact-actions/

This commit upgrades to v4.
There is a document describing how to migrate/upgrade:
https://github.com/actions/upload-artifact/blob/main/docs/MIGRATION.md

The breaking change on v4 is that the uploaded files are immutable and
we can no longer append files with the same name. We don't seem to be
doing it so it should be fine for us.

Closes #6050

* Fix implicit string conversion breaking NativeStrings (#6035)

* Fix implicit string conversion breaking NativeStrings

* Allow string literals to coerce to either string type

* Add test for CPU string passing

---------

Co-authored-by: Yong He <[email protected]>

* `[[shader_record]] / [[push_constant]]` Param Annotations Proposal (#6053)

* Add files via upload

Adding first draft at proposal to disambiguate the use of uniform with ray tracing entry points.

* Update and rename 000-shader-record.md to 017-shader-record.md

* Support a storage class, NodePayloadAMDX, for SPIRV work-graphs (#6052)

In order to unblock experiments with SPIRV work-graphs, Slang
needs to support the storage class, `NodePayloadAMDX`.

Note that this commit is only to support a storage class,
`NodePayloadAMDX`. There are many parts required for work-graphs
hasn't been implemented yet.

The implementation of `DispatchNodeInputRecord` is not required, but it
is implemented mostly for a testing purpose.

Closes #6049

Co-authored-by: Yong He <[email protected]>

* Add CalculateLevelOfDetail* overloads for comparison samplers (#6018)

* add CalculateLevelOfDetail* intrinsics for comparison samplers

* fix dx12 test

* fix metallib test

* fix merge conflict

---------

Co-authored-by: Yong He <[email protected]>

* Add exhaustive associativity test for WGSL (#6056)

This closes #6005.

* Initial implementation of SP#015 `DescriptorHandle<T>`. (#6028)

* Initial implementation of `ResourcePtr<T>`.

* Update docs

* Fix build error.

* Add more discussion.

* Update documentation.

* Update TOC.

* Fix.

* Fix.

* Add test case for custom `getResourceFromBindlessHandle`.

* Add namehint to generated descriptor heap param.

* Fix.

* Fix.

* format code

* Rename to `DescriptorHandle`, and add `T.Handle` alias.

* Fix compiler error.

* Fix.

* Fix build.

* Renames.

* Fix documentation.

* Documentation fix.

---------

Co-authored-by: slangbot <[email protected]>

* Fix Metal type layout reflection for nested parameter blocks. (#6042)

* Fix potential test failures due to SPIRV validation failure (#6047)

There are a few tests that are currently passing but could fail when
conditions change little bit.

When slang-test runs with `test-server`, the spirv validation fails and
the test gets reported as failed even though they are actually passing.

To avoid the potential problem, this commit adds an empty entry point.

Co-authored-by: Yong He <[email protected]>

* WGSL: Convert signed vector shift amounts to unsigned (#6023)

* 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 <[email protected]>
Co-authored-by: Yong He <[email protected]>

* Add overload for select to handle Optional<T> (#6022)

Fixes #6020

Co-authored-by: Yong He <[email protected]>

* Fix `markNonContextParamsAsSideEffectFree`. (#6054)

* Fix CUDA reflection for acceleration structure handle size. (#6055)

* Find OptiX headers (#6071)

* add support for finding OptiX headers

* add documentation

* fix linux path

* Don't initialize temp var for out parameters. (#6076)

* Fix simplify if-else (#6077)

* Fix simplify if-else

The if-else optimization observes that at if at least one
true/false block is merely an unconditional jump to the
after block, that the whole if-else can be replaced with
a jump to the after block. But it's important to copy
the phi arguments from the aforementioned unconditional
jump, rather than what is present in the 'true' block,
since the 'true' block might actually just be the after
block itself.

Below, the ifElse() would be replaced with an unconditional
jump to block %39, but with the `phi` arguments copied from
the branch to %29, which is an unrelated block.

ifElse(%38, %39, %40, %39)

block %40:
    unconditionalBranch(%39)

block %39:
    unconditionalBranch(%29, 0 : Float)

block %29(
        [nameHint("ret")]
        param %ret  : Float):

Fixes issue #5972

* format code

---------

Co-authored-by: slangbot <[email protected]>
Co-authored-by: Yong He <[email protected]>

* Fix inaccurate documentation in member function mutability. (#6065)

* Fix inaccurate documentation in member function mutability.

* Change throw to result in for specificity.

---------

Co-authored-by: Yong He <[email protected]>

* update slang-rhi + fix nvrtc options (#6080)

* update slang-rhi

* pass --dopt=on to nvrtc when enabling debug information

* fix leaks in slang-rhi

* update slang-rhi

* only use --dopt when available

---------

Co-authored-by: Yong He <[email protected]>

* Fix #5354, change diagnostic definition error message and expect output in test (#6067)

Co-authored-by: Yong He <[email protected]>

* Implement specialization constant support in numthreads / local_size (#5963)

* Allow using specialization constants in numthreads attribute

* Add support for GLSL local_size_x_id syntax

* Fix overeager specialization constant parsing

* Add diagnostics for specialization constant numthreads

* Remove unused variable

* Fix local_size_x_id not finding existing specialization constant

* Allow materializeGetWorkGroupSize to reference specialization constants

* Use SpvOpExecutionModeId for modes that require it

* Cleanup specialization constant numthreads code

* Add tests for specialization constant work group sizes

* Fix implicit Slang::Int -> int32_t cast

* Fix querying thread group size in reflection API

---------

Co-authored-by: Yong He <[email protected]>

* Fix documentation on DescriptorHandle. (#6062)

* Fix documentation on DescriptorHandle.

* Fix.

* format code

---------

Co-authored-by: slangbot <[email protected]>

* Fix issue with specialization using arithmetic expressions (#6084)

* Fix optix varying legalization. (#6089)

* Fix optix varying legalization.

* Add test.

* Reuse code for Metal and WGSL entry point legalization (#6063)

* Refactor to reuse common for metal and wgsl entry point legalization

* refactor system val work item

* refactor simplify user names

* clean up fix semantic field of struct

* improve code layout

* split wgsl/metal to seperate classes and cleanup

* remove extra includes

* remove dead code comments

* minor cleanup

* squash merge from master and resolve conflict

* apply metal spec const thread count changes

* Revert "apply metal spec const thread count changes"

This reverts commit c42d707.

* Revert "squash merge from master and resolve conflict"

This reverts commit 06db88e.

* Merge remote-tracking branch 'origin/master'

* apply metal spec const thread count changes

* Revert "apply metal spec const thread count changes"

This reverts commit 3b9e6f5.

* Revert "Merge remote-tracking branch 'origin/master'"

This reverts commit 99869d5.

* apply metal spec const thread count changes

---------

Co-authored-by: Yong He <[email protected]>

* Implement AnyValue marshalling for 8-bit integers (#6059)

* Implement anyvalue marshalling for 8-bit integers

* Fix missing offset from int8/uint8 case

* Disable anyvalue 8-bit test for DXIL

Because it doesn't support 8-bit values anyway.

---------

Co-authored-by: Yong He <[email protected]>

* Emit errors when seeing a matrix with row/col count of 1 (#6044)

Such matrices aren't well supported except by D3D targets.
Therefore, generate an error rather than outputting invalid code for non-D3D targets.

This closes #5987.

Co-authored-by: Yong He <[email protected]>

* Inline global constants that contains opaque handles for legalization. (#6098)

* Inline global constants that contains opaque handles for legalization.

* Add diagnostics on opaque type global variables.

* Fix.

* Fix test.

* Fix argument buffer tier2 layout computation. (#6101)

* support SV_ViewIndex for Metal (#6103)

Co-authored-by: Yong He <[email protected]>

* Implement Packed Dot Product intrinsics (#6068)

* implement dot acc intrinsics

* fix sm version

* fix test

* improve comment

---------

Co-authored-by: Yong He <[email protected]>

* C-like emitter: Add parenthesis when combining relational and bitwise… (#6070)

* C-like emitter: Add redundant parentheses in several cases

This is required since the Dawn WGSL compiler requires parentheses even though precedence
rules could resolve order of operations.

This closes #6005.

* Fix tests/metal/byte-address-buffer

The output now includes parentheses around shift expressions appearing as operands in
bitwise expressions, so update the test accordingly.

* format code

---------

Co-authored-by: slangbot <[email protected]>
Co-authored-by: Yong He <[email protected]>

* Fix cyclic lookups with UnscopedEnums (#6110)

* Fix cyclic lookups with UnscopedEnums

* Add test with multiple unscoped enums with explicit types

---------

Co-authored-by: Yong He <[email protected]>

* Fix resource specialization issue where store insts from inlined calls are not considered properly. (#6099)

* Fix resource specialization issue where stores from inlined calls are not considered.

* Format

* Move global variable initialization into entry points for WGSL (#6106)

* Add test that reproduces the issue in #5986

* Call moveGlobalVarInitializationToEntryPoints for WGSL as well

This closes #5986.

---------

Co-authored-by: Yong He <[email protected]>

* Fix prebound parameter pack - argument list matching logic. (#6111)

* Fix prebound parameter pack - argument list matching logic.

* Move tests.

* Fix.

* Fix `-capability` arg in SPIRV debug command line output. (#6114)

* hoist entry point params for wgsl (#6116)

Co-authored-by: Yong He <[email protected]>

* Fix nullptr in generic specialization (#6066)

* Fix nullptr in generic specialization

* Fix formatting

* Revert "Fix nullptr in generic specialization" and add emitPtrLit instead

* Add type parameter to getPtrValue()

---------

Co-authored-by: Yong He <[email protected]>

* Avoid using the backend validation when using test server (#6094)

* Avoid using the backend validation when using test server

Currently with a debug build, the backend validation such
as Vulkan-Validation-Layer or DXC validation is enabled all the time.
It means there is a higher chance that we see warning messages while
running slang-test with a debug build.

However, those warning messages incorrectly treated as the testing
result when using test-server. This is mainly because of the fact that
the Slang implemention for the RPC commucation expects only one time
output result. As soon as any warning is printed, the testing process is
incorrectly considered as completed even though it might be still in the
middle of initializing the device.

This commit disables the backend validation when using the test-server.

* format code (#31)

Co-authored-by: slangbot <[email protected]>

---------

Co-authored-by: slangbot <[email protected]>
Co-authored-by: slangbot <[email protected]>
Co-authored-by: Yong He <[email protected]>

* Fix interface requirement lowering for generic accessors (#6123)

* Refactor _Texture to constrain on texel types. (#6115)

* Refactor _Texture to constrain on texel types.

* Fix tests.

* Fix.

* Disable glsl texture test because rhi can't run it correctly.

* Allow __subscript<T> syntax. (#6124)

* Allow __subscript<T> syntax.

* Fix.

* Add groupshared atomic array test. (#6107)

* Add groupshared atomic array test.

* Fix test.

* Add diagnostic for function body followed by a `;`;. (#6122)

* Fix circularity issue when checking multiple generic interface constraints. (#6121)

* Fix circularity issue with checking multiple generic interface constraints

* Create multi-generic-interface-constraint.slang

* Update multi-generic-interface-constraint.slang

* Update slang-check-inheritance.cpp

---------

Co-authored-by: Yong He <[email protected]>

* Create CNAME

* Delete CNAME

* test-server should use d3d12core.dll from bin directory (#6095)

* Implement Quad Control intrinsics (#5981)

* Make -depfile work for binary modules output too (#6126)

* Fix upper 32 bits of 64-bit AnyValue packing (#6127)

* Fix def-use issue from multi-level break elimination (#6134)

* Generate IDs for every witness table (#6129)

Co-authored-by: Yong He <[email protected]>

* Fix gcc downstream compiler optimization level corresponding to OptimizationLevel::Maximal (#6137)

* Fix bug: IgnoreInheritance in lookup (#6146)

* Fix bug: IgnoreInheritance in lookup

When specifying IgnoreInheritance in lookup, it will ignore
all members in the self extension for generic, the reason is
that it doesn't specialize the target type of the extension
decl when comparing with self type, so it will result that every
type is unequal to the target type.

* Catch all exceptions from loadModule* and link API calls. (#6143)

This closes #5950.

* Bump spirv-tools to 9295a8b94ed0751565fa9cda6d949f5e388b32d9 (#6145)

Pick up fix to #5859

* Remove unnecessary parameters from Metal entry point signature (#6131)

* fix metal entry point global params

* address review comments, cleanup and test

* remove dead code

* undo accidental change

* address review comments and cleanup

* minor fix and cleanup

---------

Co-authored-by: Yong He <[email protected]>

* Use SPIRV integer vector dot product instructions (#6141)

* Use SPIRV integer vector dot product instructions

* fix test

---------

Co-authored-by: Yong He <[email protected]>

* Add validation for destination of atomic operations (#6093)

* Reimplement the GLSL atomic* functions in terms of __intrinsic_op

Many of these functions map directly to atomic IR instructions.
The functions taking atomic_uint are left as they are.

This helps to address #5989, since the destination pointer type validation can then be
written only for the atomic IR instructions.

* Add validation for atomic operations

Diagnose an error if the destination of the atomic operation is not appropriate, where
appropriate means it's either:
- 'groupshared'
- from a device buffer

This closes #5989.

* Add tests for GLSL atomics destination validation

Attempting to use the GLSL atomic functions on destinations that are neither groupshared
nor from a device buffer should fail with the following error:

error 41403: cannot perform atomic operation because destination is neither groupshared
             nor from a device buffer.

* Validate atomic operations after address space specialization

Address space specialization for SPIR-V is not done as part of `linkAndOptimizeIR`, as it
is for e.g. Metal, so opt out and add a separate call for SPIR-V.

* Allow unchecked in/inout parameters for non-SPIRV targets

* Clean up callees left without uses during address space specialziation

* format code

---------

Co-authored-by: slangbot <[email protected]>
Co-authored-by: Yong He <[email protected]>

* Cache and reuse glsl module. (#6152)

* Cache and reuse glsl module.

* Fix.

* Implement record/replay for the new api.

* Fix record replay.

* Fix test.

* Fix incorrect resolve of specialization instance (#6162)

* Fix incorrect resolve of specialization instance

While checking the uninitialized variables, we were not resolving the
specialized instance correctly. This commit repeats the resolve while
the result is a specialization instance. A new test is added for this:
  tests/diagnostics/uninitialized-generic.slang

After the problem is fixed, it revealed another problem in existing
tests:
  tests/compute/nested-generics2.slang
  tests/diagnostics/uninitialized-local-variables.slang

When a struct has a member variable whose type is a generic type,
we cannot iterate over its member variables yet, because the type
is unknown until the generic function/struct is specialized. We will
have to give up checking for these cases.

* Fix static build and install (#6158)

* Add SLANG_ENABLE_RELEASE_LTO cmake option

* Fix cmake static build

* Disable install SlangTargets to avoid static build failing

* improve error message on generic value decls (#6169)

Co-authored-by: Yong He <[email protected]>

* Add bgra8 format (#6163)

* 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 <[email protected]>

* Add intptr_t abs/min/max operations for CPU & CUDA targets (#6160)

* Add intptr_t abs/min/max operations for CPU & CUDA targets

* Define intptr_t and uintptr_t with CUDACC_RTC

---------

Co-authored-by: Yong He <[email protected]>

* Some usability improvements to formatting script (#6153)

* Sharpen the requirements for formatting

* Add option to only format files changed since a given revision

* Avoid divison-by-zero when total is zero

* format code

---------

Co-authored-by: slangbot <[email protected]>

* Fix depth texture sampling on Metal. (#6168)

* DNI: try using sparse checkout for MDL-SDK (#6190)

* Fix an incorrect iteration with a workList (#6177)

* Fix an incorrect iteration with a workList

We cannot modify workList while iterating it, because its type `List` is
actually an array container.

* Change based on the feedback

* Use `Index` instead of `int` for for-loop index

---------

Co-authored-by: Yong He <[email protected]>

---------

Co-authored-by: Ellie Hermaszewska <[email protected]>
Co-authored-by: Anders Leino <[email protected]>
Co-authored-by: slangbot <[email protected]>
Co-authored-by: Theresa Foley <[email protected]>
Co-authored-by: Yong He <[email protected]>
Co-authored-by: kaizhangNV <[email protected]>
Co-authored-by: Nate Morrical <[email protected]>
Co-authored-by: Darren <[email protected]>
Co-authored-by: Stan <[email protected]>
Co-authored-by: arya <[email protected]>
Co-authored-by: AdamYuan <[email protected]>
Co-authored-by: Julius Ikkala <[email protected]>
Co-authored-by: Yuki Nishidate <[email protected]>
Co-authored-by: Pétur Darri Pétursson <[email protected]>
Co-authored-by: bspeice <[email protected]>
Co-authored-by: Jay Kwak <[email protected]>
Co-authored-by: zhangkai <[email protected]>
Co-authored-by: Simon Kallweit <[email protected]>
Co-authored-by: Sai Praveen Bangaru <[email protected]>
Co-authored-by: mTvare <[email protected]>
Co-authored-by: Entropy Lost <[email protected]>
Co-authored-by: wij <[email protected]>
Co-authored-by: slangbot <[email protected]>
Co-authored-by: Khronos Group Web Services <[email protected]>
Co-authored-by: spking11 <[email protected]>
Co-authored-by: Dario Mylonopoulos <[email protected]>
  • Loading branch information
1 parent 772c48a commit 839bc9a
Show file tree
Hide file tree
Showing 476 changed files with 24,705 additions and 8,051 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:
with:
repository: "shader-slang/MDL-SDK"
path: "external/MDL-SDK"
sparse-checkout: |
./examples/mdl_sdk/dxr/content/slangified
- name: Run benchmark
run: |
cd tools/benchmark
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/check-toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Mono
run: |
sudo apt-get update
sudo apt-get install -y mono-complete
- run: ./docs/build_toc.sh --check-only
216 changes: 216 additions & 0 deletions .github/workflows/ci-examples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
#!/usr/bin/env bash
set -e

show_help() {
me=$(basename "$0")
cat <<EOF
$me: Run all of the examples in test mode
Usage: $me --os <os> --config <config> --bin-dir <path> --skip-file <path> [--dry-run]
Options:
--help Show this help message
--dry-run Skip running the examples.
--bin-dir <path> Path to binary directory.
Must contain all of the example binaries.
--skip-file <path> Path to file containing skip patterns.
See the 'Skip file' section, below.
--os <os> Operating system.
Valid <os> values: 'macos', 'windows', 'linux'
--config <config> Build configuration.
Valid <config> values: 'debug', 'release'.
--platform <platform> Target platform.
Valid <platform> values: 'x86_64', 'aarch64'.
Skip file:
The skip patterns are regexp patterns on the following format:
<os>:<platform>:<config>:<sample> # Some comment describing why test is disabled
For example:
# Bug 123: foo-example fails (both debug and release)
windows:x86_64(debug|release):foo-example
# Bug 456: bar-example fails in release mode on Linux
linux:aarch64:release:bar-example
EOF
}

function user_error() {
echo "error: $1" >&2
echo "" >&2
show_help >&2
exit 1
}

while [[ "$#" -gt 0 ]]; do
case $1 in
-h | --help)
show_help
exit 0
;;
--dry-run)
dry_run=true
;;
--bin-dir)
bin_dir="$2"
shift
;;
--skip-file)
skip_file="$2"
shift
;;
--os)
case $2 in
windows | linux | macos) ;;
*)
user_error "Unrecognized os: '$2'"
;;
esac
os="$2"
shift
;;
--config)
case $2 in
debug | release) ;;
*)
user_error "Unrecognized config: '$2'"
;;
esac
config="$2"
shift
;;
--platform)
case $2 in
x86_64 | aarch64) ;;
*)
user_error "Unrecognized platform: '$2'"
;;
esac
platform="$2"
shift
;;
*)
user_error "Unrecognized argument: '$1'"
;;
esac
shift
done

if [[ "$os" == "" ]]; then
user_error "No OS specified."
fi

if [[ "$config" == "" ]]; then
user_error "No build configuration specified."
fi

if [[ "$bin_dir" == "" ]]; then
user_error "No binary directory specified."
fi

if [[ "$skip_file" == "" ]]; then
user_error "No skip file specified."
fi

if [[ "$platform" == "" ]]; then
user_error "No platform specified."
fi

if [[ ! -f "$skip_file" ]]; then
user_error "Skip file '$skip_file' does not exist."
fi

if [[ ! -d "$bin_dir" ]]; then
user_error "Binary directory '$bin_dir' does not exist."
fi

summary=()
failure_count=0
skip_count=0
sample_count=0

function skip {
local p
local line_index
p="$1"
line_index=1
while read -r pattern; do
pat=$pattern
if [[ ! $pat =~ .*# ]]; then
user_error "Skip pattern on line $line_index is missing a comment!"
fi
pat="${pattern%% *#*}"
if [[ $p =~ ^$pat$ ]]; then
return 0
fi
line_index=$((line_index + 1))
done <"$skip_file"

return 1
}

function run_sample {
local sample
local args
sample="$1"
shift
args=("$@")
sample_count=$((sample_count + 1))
summary=("${summary[@]}" "$sample: ")
if skip "$os:$platform:$config:$sample"; then
echo "Skipping $sample..."
summary=("${summary[@]}" " skipped")
skip_count=$((skip_count + 1))
return
fi
echo "Running '$sample ${args[*]}'..."
result=0
pushd "$bin_dir" 1>/dev/null 2>&1
if [[ ! "$dry_run" = true ]]; then
./"$sample" "${args[@]}" || result=$?
if [[ -f ./"log-$sample.txt" ]]; then
cat ./"log-$sample.txt"
fi
fi
if [[ $result -eq 0 ]]; then
summary=("${summary[@]}" " success")
else
summary=("${summary[@]}" " failure (exit code: $result)")
failure_count=$((failure_count + 1))
fi
popd 1>/dev/null 2>&1
}

sample_commands=(
'platform-test --test-mode'
'ray-tracing-pipeline --test-mode'
'ray-tracing --test-mode'
'shader-toy --test-mode'
'triangle --test-mode'
'model-viewer --test-mode'
'shader-object'
'reflection-api'
'hello-world'
'gpu-printing'
'cpu-hello-world'
'cpu-com-example'
)

for sample_command in "${sample_commands[@]}"; do
run_sample ${sample_command}
echo ""
done

echo ""
echo "Summary: "
echo
for line in "${summary[@]}"; do
printf ' %s\n' "$line"
done
echo ""
echo "$failure_count failed, and $skip_count skipped, out of $sample_count tests"
if [[ $failure_count -ne 0 ]]; then
exit 1
fi
26 changes: 17 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [linux, macos, windows]
config: [debug, releaseWithDebugInfo]
config: [debug, release]
compiler: [gcc, clang, cl]
platform: [x86_64, aarch64, wasm]
exclude:
Expand Down Expand Up @@ -44,14 +44,14 @@ jobs:
# quick or full conditionally otherwise
- test-category: smoke
- { os: windows, test-category: quick }
- { config: releaseWithDebugInfo, test-category: full }
- { config: release, test-category: full }
# default not full gpu tests
- full-gpu-tests: false
# The runners don't have a GPU by default except for the self-hosted ones
- has-gpu: false
# Self-hosted aarch64 build
- os: linux
config: releaseWithDebugInfo
config: release
compiler: gcc
platform: aarch64
test-category: smoke
Expand All @@ -60,7 +60,7 @@ jobs:
has-gpu: true
# Self-hosted full gpu build
- os: windows
config: releaseWithDebugInfo
config: release
compiler: cl
platform: x86_64
test-category: full
Expand Down Expand Up @@ -125,10 +125,9 @@ jobs:
mkdir generators
cmake --install build --prefix generators --component generators
emcmake cmake -DSLANG_GENERATORS_PATH=generators/bin --preset emscripten -DSLANG_SLANG_LLVM_FLAVOR=DISABLE
cmake --build --preset emscripten --config "$cmake_config" --target slang
[ -f "build.em/$cmake_config/lib/libslang.a" ]
[ -f "build.em/$cmake_config/lib/libcompiler-core.a" ]
[ -f "build.em/$cmake_config/lib/libcore.a" ]
cmake --build --preset emscripten --config "$cmake_config" --target slang-wasm
[ -f "build.em/$cmake_config/bin/slang-wasm.wasm" ]
[ -f "build.em/$cmake_config/bin/slang-wasm.js" ]
else
if [[ "${{ matrix.os }}" =~ "windows" && "${{ matrix.config }}" != "release" && "${{ matrix.config }}" != "releaseWithDebugInfo" ]]; then
# Doing a debug build will try to link against a release built llvm, this
Expand Down Expand Up @@ -176,6 +175,15 @@ jobs:
-expected-failure-list tests/expected-failure-github.txt \
-expected-failure-list tests/expected-failure-record-replay-tests.txt
fi
- name: Run Slang examples
if: steps.filter.outputs.should-run == 'true' && matrix.platform != 'wasm'
run: |
.github/workflows/ci-examples.sh \
--bin-dir "$bin_dir" \
--os "${{matrix.os}}" \
--platform "${{matrix.platform}}" \
--config "${{matrix.config}}" \
--skip-file tests/expected-example-failure-github.txt
- name: Test Slang via glsl
if: steps.filter.outputs.should-run == 'true' && matrix.full-gpu-tests && matrix.platform != 'wasm'
run: |
Expand All @@ -188,7 +196,7 @@ jobs:
-emit-spirv-via-glsl \
-api vk \
-expected-failure-list tests/expected-failure.txt
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: steps.filter.outputs.should-run == 'true' && ! matrix.full-gpu-tests
with:
name: slang-build-${{matrix.os}}-${{matrix.platform}}-${{matrix.compiler}}-${{matrix.config}}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/push-benchmark-results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ jobs:
with:
repository: "shader-slang/MDL-SDK"
path: "external/MDL-SDK"
sparse-checkout: |
./examples/mdl_sdk/dxr/content/slangified
- name: Run benchmark
run: |
cd tools/benchmark
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/regenerate-toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ jobs:
ref: ${{ github.event.client_payload.pull_request.base.ref }}
path: target-branch

- name: Install Mono
run: |
sudo apt-get update
sudo apt-get install -y mono-complete
- name: Regenerate Table of Contents
id: regen
run: |
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/vk-gl-cts-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
with:
latest: true
repository: "shader-slang/VK-GL-CTS"
fileName: "VK-GL-CTS_WithSlang-0.0.3-win64.zip"
fileName: "VK-GL-CTS_WithSlang-0.0.4-win64.zip"
- uses: actions/checkout@v4
with:
repository: "shader-slang/VK-GL-CTS"
Expand All @@ -68,25 +68,25 @@ jobs:
- name: vkcts setup
shell: pwsh
run: |
Expand-Archive VK-GL-CTS_WithSlang-0.0.3-win64.zip
Expand-Archive VK-GL-CTS_WithSlang-0.0.4-win64.zip
copy ${{ github.workspace }}\build\Release\bin\slang.dll ${{ github.workspace }}\VK-GL-CTS_WithSlang-0.0.3-win64\VK-GL-CTS_WithSlang-0.0.3-win64\slang.dll
copy ${{ github.workspace }}\build\Release\bin\slang-glslang.dll ${{ github.workspace }}\VK-GL-CTS_WithSlang-0.0.3-win64\VK-GL-CTS_WithSlang-0.0.3-win64\slang-glslang.dll
copy ${{ github.workspace }}\build\Release\bin\test-server.exe ${{ github.workspace }}\VK-GL-CTS_WithSlang-0.0.3-win64\VK-GL-CTS_WithSlang-0.0.3-win64\test-server.exe
copy ${{ github.workspace }}\build\Release\bin\slang.dll ${{ github.workspace }}\VK-GL-CTS_WithSlang-0.0.4-win64\slang.dll
copy ${{ github.workspace }}\build\Release\bin\slang-glslang.dll ${{ github.workspace }}\VK-GL-CTS_WithSlang-0.0.4-win64\slang-glslang.dll
copy ${{ github.workspace }}\build\Release\bin\test-server.exe ${{ github.workspace }}\VK-GL-CTS_WithSlang-0.0.4-win64\test-server.exe
copy ${{ github.workspace }}\test-lists\test-lists\slang-passing-tests.txt ${{ github.workspace }}\VK-GL-CTS_WithSlang-0.0.3-win64\VK-GL-CTS_WithSlang-0.0.3-win64\slang-passing-tests.txt
copy ${{ github.workspace }}\test-lists\test-lists\slang-waiver-tests.xml ${{ github.workspace }}\VK-GL-CTS_WithSlang-0.0.3-win64\VK-GL-CTS_WithSlang-0.0.3-win64\slang-waiver-tests.xml
copy ${{ github.workspace }}\test-lists\test-lists\slang-passing-tests.txt ${{ github.workspace }}\VK-GL-CTS_WithSlang-0.0.4-win64\slang-passing-tests.txt
copy ${{ github.workspace }}\test-lists\test-lists\slang-waiver-tests.xml ${{ github.workspace }}\VK-GL-CTS_WithSlang-0.0.4-win64\slang-waiver-tests.xml
- name: vkcts run
shell: pwsh
working-directory: ${{ github.workspace }}\VK-GL-CTS_WithSlang-0.0.3-win64\VK-GL-CTS_WithSlang-0.0.3-win64
working-directory: ${{ github.workspace }}\VK-GL-CTS_WithSlang-0.0.4-win64
run: |
.\deqp-vk.exe --deqp-archive-dir=${{ github.workspace }}\VK-GL-CTS_WithSlang-0.0.3-win64\VK-GL-CTS_WithSlang-0.0.3-win64 --deqp-caselist-file=${{ github.workspace }}\VK-GL-CTS_WithSlang-0.0.3-win64\VK-GL-CTS_WithSlang-0.0.3-win64\slang-passing-tests.txt --deqp-waiver-file=${{ github.workspace }}\VK-GL-CTS_WithSlang-0.0.3-win64\VK-GL-CTS_WithSlang-0.0.3-win64\slang-waiver-tests.xml
.\deqp-vk.exe --deqp-archive-dir=${{ github.workspace }}\VK-GL-CTS_WithSlang-0.0.4-win64 --deqp-caselist-file=${{ github.workspace }}\VK-GL-CTS_WithSlang-0.0.4-win64\slang-passing-tests.txt --deqp-waiver-file=${{ github.workspace }}\VK-GL-CTS_WithSlang-0.0.4-win64\slang-waiver-tests.xml
- name: Dump TestResults.qpa if failed
shell: pwsh
if: ${{ !success() }}
working-directory: ${{ github.workspace }}\VK-GL-CTS_WithSlang-0.0.3-win64\VK-GL-CTS_WithSlang-0.0.3-win64
working-directory: ${{ github.workspace }}\VK-GL-CTS_WithSlang-0.0.4-win64
run: Get-Content TestResults.qpa -Tail 1000
- name: success notification
id: slack-notify-success
Expand Down
Loading

0 comments on commit 839bc9a

Please sign in to comment.