summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-emit-spirv.cpp
Commit message (Collapse)AuthorAge
...
* cluster acceleration structure optix 6431 (#7028)Harsh Aggarwal (NVIDIA)2025-05-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add cluster geometry intrinsics for ray tracing - Added GetClusterID() method to HitObject class - Added CandidateClusterID() and CommittedClusterID() methods to RayQuery class - Added SPV_NV_cluster_acceleration_structure extension support - Added GL_NV_cluster_acceleration_structure extension support - Added test files for RayQuery and HitObject cluster methods Fixes #6431 * OpRayQueryGetIntersectionClusterIdNV - unrecognized spirv Disabling spirv backend for SPV_NV_cluster_acceleration_structure hlsl.meta.slang(18674): error 29100: unrecognized spirv opcode: OpRayQueryGetIntersectionClusterIdNV result:$$int = OpRayQueryGetIntersectionClusterIdNV &this $iCandidateOrCommitted; ^~~~~~ hlsl.meta.slang(18670): error 30019: expected an expression of type 'int', got 'void' return spirv_asm ^~~~~~~~~ ninja: build stopped: subcommand failed. * 6431 - Fix spirv opcode * Remove tests * Add relevant tests * Review - Simplify tests
* Add debug information for slang inling (#6621)Mukund Keshava2025-05-10
|
* Fix SPIRV unsigned to signed widening casts (#7051)Darren Wihandi2025-05-09
| | | | | | | * Fix unsigned to signed casts for SPIRV * Add test * Fix ICE crash
* Emit SPIRV NonReadable decoration for WTexture* (#6922)Darren Wihandi2025-04-27
|
* Add cooperative matrix 1 support (#6565)Darren Wihandi2025-04-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * initial wip for spirv * working tiled example * clean up store and load * minor fixes * fix loadAny name * add initial tests, including broken/unimplemented intrinsics * fix subscript * run tests at 16x16, remove not supported arithmetic tests * minor fixups on implementation * rename CoopMatMatrixUse * Update tests to pass validation layers locally * Add mat-mul-add test and minor fixes * Add more tests * Remove dead code * Add coopMatLoad function and tests, enforce constexpr for matrix layout * Use getVectorOrCoopMatrixElementType in place of getVectorElementType
* Add SV_PointCoord to match gl_PointCoord (#6795)Julius Ikkala2025-04-14
| | | | | | | | | | | * Add gl_PointCoord support in GLSL compat mode * Add SV_PointCoord * Test on metal as well * Update SPIRV system value semantics table in docs * Update metal docs for SV_PointCoord
* Fix SPV_KHR_maximal_reconvergence extension name spelling (#6687)Pavel Asyutchenko2025-03-26
| | | | | | | * Fix SPV_KHR_maximal_reconvergence extension name spelling Vulkan validation layers emit warnings on lowercase khr. * Move OpExtension check
* Support spirv ops added by multiple extensions (#6615)Dario Mylonopoulos2025-03-22
| | | | | | | | | | | | | | | | | | | | | | | | * spirv: add support for ops added by multiple extensions Some spirv ops are added by multiple extensions and capabilities. This commit adds support to avoid emitting unnecessary extensions and capabilities if one of the options is already required by some other op. * spirv: allow OpRaytracingAccelerationStructure to use multiple extensions This Op is provided by both SPV_KHR_ray_tracing and SPV_KHR_ray_query and the respective capabilities. Use one if already available and otherwise fall back to SPV_KHR_ray_tracing. * tests/vkray: add negative checks for RayTracingKHR and RayQueryKHR - Add new rayquery-compute.slang to test that only RayQueryKHR is needed in compute shaders. - Add checks for RayTracingKHR and RayQueryKHR capabilities and extensions in raygen.slang --------- Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
* Apply pixel interlock execution mode to entry-point functions only (#6661)Darren Wihandi2025-03-21
| | | Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
* Output SPV_KHR_compute_shader_derivatives extension string instead of the NV ↵Darren Wihandi2025-03-19
| | | | | | | extension (#6641) * Output SPV_KHR_compute_shader_derivatives instead of the NV extension * add alias for nv extension
* Add SPIRV atomic debug type (#6616)Darren Wihandi2025-03-19
| | | Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
* Add mesh shader output topology checks (#6592)Darren Wihandi2025-03-13
| | | | | | | | | | | | | | | | | | | * initial wip * more wip * add test * add unexpected for invalid target * fixups and improve error message * fixups and improve error message * remove incorrect comment --------- Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
* Fix SPIRV generator ID. (#6536)Yong He2025-03-07
|
* Update SPIRV-Tools and fix new validation errors. (#6511)Yong He2025-03-06
| | | | | | | * Update SPIRV-Tools and fix new validation errors. * Implement pointers for glsl target. * Reworked packStorage/unpackStorage code gen to operate on pointers rather than values.
* Add Slang-specific intrinsics for integer pack/unpack (#6459)Darren Wihandi2025-02-28
| | | | | | | | | | | | | | | | | | | | | * update hlsl meta * update test * use slang syntax in meta file * improve meta file * fix pack clamp u8 * remove builtin packed types, use typealias instead * fix wgsl pack clamp * fix formatting --------- Co-authored-by: Yong He <yonghe@outlook.com>
* Map `SV_InstanceID` to `gl_InstanceIndex-gl_BaseInstance` (#6468)Yong He2025-02-27
| | | | | * Map `SV_InstanceID` to `gl_InstanceIndex-gl_BaseInstance` * Fix ci.
* Fix regression when using Atomic<T> in struct. (#6472)Yong He2025-02-26
|
* [SPIRV]: Emit missing storage class in atomic insts. (#6456)Yong He2025-02-26
|
* Emit missing atomic64 capability, fix int-typed builtin used in both vs and ↵Yong He2025-02-11
| | | | | fs. (#6314) Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
* Declare `VariablePointers` capability when needed. (#6231)Yong He2025-01-30
|
* Support cooperative vector (#6223)Jay Kwak2025-01-30
| | | | | | | * Support cooperative vector without Vulkan-header update Adding a Slang support for cooperative vector. But this commit doesn't have Vulkan-header update.
* Update SPIRV submodules and fix tests (#6222)Jay Kwak2025-01-29
|
* Add bgra8 format (#6163)Darren Wihandi2025-01-24
| | | | | | | | | | | | | | | | | * 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>
* Implement Quad Control intrinsics (#5981)Darren Wihandi2025-01-17
|
* Implement specialization constant support in numthreads / local_size (#5963)Julius Ikkala2025-01-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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 <yonghe@outlook.com>
* Initial implementation of SP#015 `DescriptorHandle<T>`. (#6028)Yong He2025-01-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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 <186143334+slangbot@users.noreply.github.com>
* Support a storage class, NodePayloadAMDX, for SPIRV work-graphs (#6052)Jay Kwak2025-01-09
| | | | | | | | | | | | | | | 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 <yonghe@outlook.com>
* Use disassemble API from SPIRV-Tools (#6001)Jay Kwak2025-01-07
| | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Add packed 8bit builtin types (#5939)Darren Wihandi2024-12-26
| | | | | * Add packed bytes builtin type * fix test
* Add base vertex and base instance system values (#5918)Darren Wihandi2024-12-19
| | | | | * Add base vertex and base instance system values * Fixed incorrect stage in tests
* Report error when generated spirv is empty. (#5899)Yong He2024-12-19
| | | | | | | | | | * Report error when generated spirv is empty. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
* Allow `Optional`, `Tuple` and `bool` to be used in varying input/output. (#5889)Yong He2024-12-18
| | | | | | | | | | | | | | | | | | | | | | | * 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 <186143334+slangbot@users.noreply.github.com>
* Bit extract (#5847)kaizhangNV2024-12-12
| | | | | | | | | | | | * 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 <natemorrical@gmail.com> Co-authored-by: Yong He <yonghe@outlook.com>
* Fix anyvalue marshalling for matrix and 64 bit types. (#5827)Yong He2024-12-11
| | | | | | | | | * Fix anyvalue marshalling for matrix types. * Add support for 64bit types marshalling. --------- Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
* Add SV_DrawIndex. (#5787)Yong He2024-12-09
| | | Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
* Fix `SpvExecutionModeOutputLinesEXT`. (#5740)Yong He2024-12-03
|
* Add intrinsics for aligned load/store. (#5736)Yong He2024-12-03
| | | | | | | | | | | | | | | * Add intrinsics for aligned load/store. * Fix. * Update comment. * Implement aligned load/store as intrinsic_op. * Fix. * Add proposal doc. * fix typo.
* Emit OpExecutionMode SpacingEqual for Domain stage (#5696)Jay Kwak2024-11-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Domain stage should emit one more `OpExecutionMode` with `SpacingEqual`, similary to how Hull stage does. Currently Hull stage emits four OpExecutionMode as following: OpExecutionMode %hullMain SpacingEqual OpExecutionMode %hullMain OutputVertices 4 OpExecutionMode %hullMain VertexOrderCw OpExecutionMode %hullMain Quads And Domain stage emits only one OpExecutionMode: OpExecutionMode %domainMain Quads This commit adds the following instruction for Domain stage: OpExecutionMode %domainMain SpacingEqual It is because the Vulkan Validation Layer prints error when the Domain shader didn't have `OpeExecutionMode SpacingEqual`. `SpacingEqual` corresponds to an attribute, `[partitioning("integer")]`, given to the Hull stage. Although Domain stage is not marked with same attribute, it is assumed to use the same value used for matching Hull Stage. The error message from VVL is following: ``` vkCreateShadersEXT(): pCreateInfos[2].stage is VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, but spacing is not specified. The Vulkan spec states: If codeType is VK_SHADER_CODE_TYPE_SPIRV_EXT, and stage is VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, pCode must contain an OpExecutionMode instruction specifying the spacing of segments on the edges of tessellated primitives (https://vulkan.lunarg.com/doc/view/1.3.283.0/windows/1.3-extensions/vkspec.html#VUID-VkShaderCreateInfoEXT-codeType-08874) ``` Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
* Move switch statement bodies to their own lines (#5493)Ellie Hermaszewska2024-11-05
| | | | | | | | | * Move switch statement bodies to their own lines * format --------- Co-authored-by: Yong He <yonghe@outlook.com>
* Write only texture types. (#5454)Yong He2024-10-30
| | | | | | | | | | | | | | | | * 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>
* Precompiled SPIR-V import support (#5048)cheneym22024-10-29
| | | | | | | | | | | | | | | | | | | | * Precompiled SPIR-V import support Adds appropriate linkage and function declaration syntax for SPIR-V functions that are declared, to be imported from another SPIR-V module. Unlike DXIL, stripping the Slang IR for a function down to a declaration requires retaining a block of parameters, as the function declaration must be emitted to SPIR-V with the same parameters as a definition. Because that thwarts the logic in Slang to tell the difference between a declaration and definition, and explicit decoration is introduced to explicitly mark functions which need to be treated as declarations during emit phase. Fixes #4992 Co-authored-by: Yong He <yonghe@outlook.com>
* formatEllie Hermaszewska2024-10-29
| | | | | | | * format * Minor test fixes * enable checking cpp format in ci
* Use DebugDeclare instead of DebugValue. (#5404)Yong He2024-10-24
| | | | | | | | | | | | | * Use DebugDeclare instead of DebugValue. * Avoid generating illegal SPIRV. * Improve DebugLine output. * Fix. * Fix. * Misc improvements.
* Remove use of Variable Pointer capability. (#5352)Yong He2024-10-19
| | | * Remove use of Variable Pointer capability.
* Use `VariablePointersStorageBuffer` instead of `VariablePointer` spv … (#5340)Yong He2024-10-18
|
* Cleanup definition of `printf`. (#5330)Yong He2024-10-17
| | | | | | | | | | | * Cleanup definition of `printf`. * Fix. * Fix spirv generation. * Fix. * enhance test.
* Cleanup atomic intrinsics. (#5324)Yong He2024-10-17
| | | | | | | | | | | | | | | | | | | * Cleanup atomic intrinsics. * Fix. * Fix glsl. * Remove hacky intrinsic expansion logic for glsl image atomics. * Fix all tests. * Fix. * Add `InterlockedAddF16Emulated`. * Fix glsl intrinsic. * Fix.
* Fix spirv debug info for pointer types. (#5319)Yong He2024-10-16
| | | | | * Fix spirv debug info for pointer types. * fix comment.
* Initial `Atomic<T>` type implementation. (#5125)Yong He2024-09-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Initial Atomic<T> type implementation. * Update design doc. * Fix. * Add test. * Fixes and add tests. * Fix WGSL. * Fix glsl. * Fix metal. * experiemnt with github metal. * experiment github metal 2 * github metal experiment 3 * experiment with github metal 4. * experiment with metal 5. * experiment 7. * metal experiment 8. * Fix metal tests. --------- Co-authored-by: Yong He <yhe@nvidia.com>
* Initial -embed-spirv support (#4974)cheneym22024-09-05
| | | | | | | | | | | | | | | | | | | | | | | | | | * Initial -embed-spirv support Add support for SPIR-V precompilation using the framework established for DXIL. Work on #4883 * SLANG_UNUSED * Add linkage attributes to exported spirv functions * Combine DXIL and SPIRV paths * Whitespace fix * Merge remaining precompiled spirv/dxil paths * Change inst accessors to return codegentarget * Add unit test for precompiled spirv --------- Co-authored-by: Yong He <yonghe@outlook.com>