summaryrefslogtreecommitdiff
path: root/source
AgeCommit message (Collapse)Author
2023-08-09Various fixes in GLSL emit. (#3074)Yong He
* Fix name mangling of modified types. * Add `InterlockedAdd(__ref uint, int)` overload. * Fix. * Fix type error in ImageStore legalization. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-08-09Clean up and improve Val deduplication performance. (#3069)Yong He
* Clean up and improve Val deuplication performance. * Fix. * Fix. * Fix. * Fix. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-08-08Support `-fvk-use-gl-layout` for ByteAddressBuffer load/store. (#3068)Yong He
* Support `-fvk-use-gl-layout` for ByteAddressBuffer load/store. * Fix. * Fix. * Add test for unaligned load. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-08-07Add warning on mutation of function parameter (#3067)Theresa Foley
By default, function parameters in HLSL are mutable, but any changes to a parameter do not affect the values of the arguments after a call: void f(int a) { a++; // allowed, but kind of useless } ... int b = 0; f(b); // b is still zero Because the above behavior is a part of HLSL, we cannot easily diagnose such cases as errors without breaking backward compatibility with existing code. This change makes it an error to invoke a `[mutating]` method on a function parameter, which cannot affect backward compatibility since the notion of `[mutating]` methods is not present in existing HLSL code: struct Counter { int _state; [mutating] void increment() { _state++; } } void f(Counter a) { a.increment(); // ERROR } ... Counter b = { 0 }; f(b); // b is still zero The compiler will also diagnose calls to `[mutating]` methods on a field or array element extracted out of a function parameter. This change does not affect code that directly mutates a function parameter via assignment, or via passing the parameter onward as an argument to an `out` or `inout` call (or, equivalently, as the left-hand operand to a compound assignment operator). This is a breaking change to existing Slang code, since it could diagnose an error on code that used to be allowed. Indeed, two tests in the Slang test suite had to be updated to avoid such errors. It would be possible to turn this diagnostic into a warning, and simply encourage users to enable it as an error. On balance, though, it seems best to not allow this idiom since it has such a high probability to be an error. Note: the specific case that motivated this change is use of `RayQuery` values as function parameters. The root of the problem there is that dxc treats `RayQuery` values as copyable handles to mutable state, while Slang prefers to capture the mutation that occurs through marking the appropriate methods as `[mutating]`. The Slang approach makes portable codegen for D3D/Vulkan simpler, but requires that we *also* treat a type like `RayQuery` as non-copyable. This change does not address the problem that the Slang compiler does not enforce the requirement that values of non-copyable types do not get copied. Instead, the diagnostic here just happens to issue a diagnostic in one important case where a copy would typically occur. Co-authored-by: Yong He <yonghe@outlook.com>
2023-08-07Add spirv-dis as a downstream compiler (#3059)Ellie Hermaszewska
* Add spirv-dis as a downstream compiler * Add TODO for spirv-dis downstream compiler * Do not use SpirvDis by default * tabs to spaces * regenerate vs projects * correct test * correct calling convention --------- Co-authored-by: Yong He <yonghe@outlook.com>
2023-08-07Default target intrinsic should not apply to SPIR-V (#3054)Ellie Hermaszewska
* Default target intrinsic should not apply to SPIR-V * CapabilitySet is a conjunction * Add TEXTUAL_SOURCE capability class
2023-08-07Fix -fvk-use-entrypoint-name. (#3066)Yong He
* Fix -fvk-use-entrypoint-name. * Remove irrelevant changes. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-08-07Validate generated SPIR-V on output (#3061)Ellie Hermaszewska
* Validate generated SPIR-V * regenerate vs projects * Do not fail compiles if spirv-val is not available --------- Co-authored-by: Yong He <yonghe@outlook.com>
2023-08-07Unify Type and Constant sections for SPIR-V (#3057)Ellie Hermaszewska
Types can depend on constants (for example fixed sized arrays) Co-authored-by: Yong He <yonghe@outlook.com>
2023-08-07Casting and vector/scalar correct arithmetic ops for SPIR-V (#3056)Ellie Hermaszewska
* types for cast instructions * Information getting functions for int and float types * Implement spirv casting * Broadcast operands for SPIR-V arithmetic SPIR-V doesn't allow vector/sclar arithmetic ops * Simplify spirv int/float type generation --------- Co-authored-by: Yong He <yonghe@outlook.com>
2023-08-07Add missing header in slang-glslang (#3055)Ellie Hermaszewska
Required for memcpy (not sure why this has started being important, but it is the correct thing to do) Co-authored-by: Yong He <yonghe@outlook.com>
2023-08-07Diagnostic improvements for direct spirv (#3053)Ellie Hermaszewska
* Fail on an unhandled spv operand * Diagnose on emitting a function with no definition or intrinsic * clearer error message * Add assert * Add assert * remove unused assert * Disagnostic on snippet parsing failure * Mention unimplemented instruction in error message * mention unhandled local instruction for spirv in error message * Allow specifying dump options in dumpIRToString --------- Co-authored-by: Yong He <yonghe@outlook.com>
2023-08-07Fix `Val` deduplication bug. (#3050)Yong He
* Fix `Val` deduplication bug. * Fix * Concat stdlib files into a single module. * Remove unnecessary logic in `resolve`. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-08-08Add missing empty case to Array::makeArray (#3058)Ellie Hermaszewska
2023-08-08Allow parsing some SPIR-V enums in intrinsics (#3062)Ellie Hermaszewska
* Add TokenReader::AdvanceIf overlaod for TokenType * Add some spirv defs to parser * Add comment
2023-08-08Simplify SpvTypeInstKey (#3063)Ellie Hermaszewska
2023-08-08sv_groupindex support for spirv (#3060)Ellie Hermaszewska
2023-08-08Fail on an unhandled spv operand (#3052)Ellie Hermaszewska
Co-authored-by: Yong He <yonghe@outlook.com>
2023-08-07Correct return type for emitFieldAddress (#3051)Ellie Hermaszewska
2023-08-04Add option to use original entrypoint in spirv output. (#3047)Yong He
* Add option to use original entrypoint in spirv output. * Fix. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-08-04Redesign `DeclRef` and systematic `Val` deduplication (#3049)Yong He
* Redesign DeclRef + Deduplicate Val. * Update project files * Fix warning. * Fix. * Fix. * Remove `Val::_equalsImplOverride`. * Rmove `Val::_getHashCodeOverride`. * Remove `semanticVisitor` param from `resolve`. * Cleanups. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-08-03Fix around texture footprint support for NVAPI. (#3046)jsmall-nvidia
2023-08-03Disable code motion for expensive insts (call & div) (#3042)Sai Praveen Bangaru
* Disable code motion for expensive insts (call & div) The current redundancy removal pass does not consider control-flow within loops and as a result can sometimes move dynamic dispatch code outside their switch blocks, if they are nested in a single-iter-loop. * Update liveness.slang.expected
2023-08-01Fix literals needing cast (#3039)jsmall-nvidia
* Cast integer literals. * Fix expected output. * For CUDA, search global instructions to see what types are used. Improve lookup for fp16 header in CUDA. * Fix issue with f16tof32 * Small improvement around finding used base types.
2023-08-01Generalize collectInductionValues (#3031)Ellie Hermaszewska
* Generalize collectInductionValues * Support affine transformations of loop index as induction variables * Test for generalized induction value collection * Neaten inductive variable finding * Store the type of implication success when finding inductive variables * Test that loop induction finding does not alway succeed * Support chains of additions and branches of additions in induction variable finding * Use c++17 for downstream compilers
2023-07-31Fix for #elif evaluation issue (#3038)jsmall-nvidia
* A more way robust way to handle resource consumption might use multiple `kind`s on GLSL emit. * Improve method naming and some comments. * Small consistency fix. * Fix issue with #elif evaluation. * Add a test.
2023-07-27Fix push constant on global variables. (#3034)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>
2023-07-27Fix -fvk-u-shift not applying to global constant buffer. (#3033)Yong He
* Fix -fvk-u-shift not applying to global constant buffer. * Fix test. * Fix. * Fix. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-07-27Include NonSemanticDebugInfo when calling glslang (#3030)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>
2023-07-26Refactor `dmul(This, Differential)` to `dmul<T:Real>(T, Differential)` (#3029)Sai Praveen Bangaru
* Refactor `dmul(This, Differential)` to `dmul<T:Real>(T, Differential)` - Add AST synthesis support for generic containers - Refactor relevant tests * Merge dmul synthesis with dadd and dzero, and disambiguate using an enum * Fix trailing spaces
2023-07-26Fix scalar swizzle causes invalid glsl output. (#3028)Yong He
* Fix -fvk-u-shift not applying to RWStructuredBuffer on glsl output. * Add `transpose` to `ObjectToWorld4x3`. * Fix scalar swizzle causes invalid glsl output. Fixes #3026. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-07-26Fix -fvk-u-shift not applying to RWStructuredBuffer on glsl output. (#3027)Yong He
* Fix -fvk-u-shift not applying to RWStructuredBuffer on glsl output. * Add `transpose` to `ObjectToWorld4x3`. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-07-26Add glsl intrinsics for CalculateLevelOfDetail (#3023)Ellie Hermaszewska
Translates to textureQueryLod().x (with the Unclameped variant being returned in the .y component) Co-authored-by: Yong He <yonghe@outlook.com>
2023-07-26Add GatherCmp* for texture objects (#3024)Ellie Hermaszewska
The translation to GLSL is incomplete as intrinsics only exist for some combination of comparison and channel (just channel 0) Closes https://github.com/shader-slang/slang/issues/3021
2023-07-25Add slang.natjmc. (#3018)Yong He
This allows Visual Studio debugger to skip over AST visitor dispatch functions and stop directly at the `visit*` functions when stepping into a `dispatch*` call. Co-authored-by: Yong He <yhe@nvidia.com>
2023-07-25Allow parsing more than 10 intrinsic arguments (#3014)Ellie Hermaszewska
2023-07-24Remove [__readNone] on clip. (#3016)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>
2023-07-21Don't error on disabled warnings when treatWarnAsErr. (#3013)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>
2023-07-21Add support for `-fvk-invert-y`. (#3012)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>
2023-07-21Add sampleCount parameter for read-only textures. (#3011)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>
2023-07-21Fix data-flow analysis not propagating diff property through differentiable ↵Sai Praveen Bangaru
calls (#3010) * Add test for nodiff diagnostic for non-diff call propagated through diff call * Add logic to disambiguate calls to differentiable and non-differentiable methods * Add expected results for test * Simplify test * Update slang-ir-check-differentiability.cpp * Added comments for TreatAsDifferentiableExpr flavors --------- Co-authored-by: Yong He <yonghe@outlook.com>
2023-07-21Better handling of bindings with multiple resource kind "aliases" for GLSL ↵jsmall-nvidia
emit (#3009) * A more way robust way to handle resource consumption might use multiple `kind`s on GLSL emit. * Improve method naming and some comments. * Small consistency fix.
2023-07-20Fix issue with loop elimination not working on certain side-effect-free ↵Sai Praveen Bangaru
loops (#3005) Co-authored-by: Yong He <yonghe@outlook.com>
2023-07-20Fix for vk-shift-* GLSL emit issue (#3004)jsmall-nvidia
* Handle different resource kinds that can appear via the vk-shift-* allowing some HLSL kinds in GLSL emit. * Determine the used kind for emit. * Added vk-shift-uniform-issue.slang * Use a better function name. Improve comments.
2023-07-19Add `sampleCount` parameter for MS textures. (#3001)Yong He
* Add `sampleCount` parameter for MS textures. * Fix test. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-07-19Support for vk-shift-* without explicit bindings (#3000)jsmall-nvidia
* Improvements to HLSLToVulkanLayoutOptions. * WIP vk-shift-* with HLSL like binding. Detecting clashes. * Shift example seems to be working correctly. One oddness is that "used" data is now reflected, as we only enable for D3D shader resource types. Now we use those with inferred VK mode they appear. * Implicit seems to work. * Disable inference with Sampler/CombinedTextureSampler. I guess? we could just use the HLSL texture register binding to infer. * Report overlapping ranges in diagnostic. The hlsl-to-vulkan-shift-diagnostic result might be surprising but it is correct, because u is automatically laid out so consumes DescriptorSlot 0, but that's already consumed by c. * First attempt at array layout with infer on Vulkan. * Fix the vulkan shift output. * Array example.
2023-07-19Optimize specialization, and remove unnecessary calls to `simplifyIR`. (#2999)Yong He
* Remove unneccessary calls to `simplifyIR`. * fix. * Delete obsolete hoistConst pass. * Fix. * Small improvements. * Fix. * Fix enum lowering. * fix * tweaks. * tweaks. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-07-18nsight Aftermath crash example (#2984)jsmall-nvidia
* Small fixes and improvements around reflection tool. * Make PrettyWriter printing a class. * Aftermath crash demo WIP. * Enable aftermath in test project. * Setting failCount. * Dumping out of source maps. * Improve comments. Simplify handling of compile products. * Other small fixes to aftermath example. * Added Emit SourceLocType. Track sourcemap association meaning. Improved documentation. * Small improvements. * Capture debug information for D3D11/D3D12/Vulkan. * Enable debug info. * Small improvements. * Improve aftermath example README.md.
2023-07-18Simplify Lookup and improve compiler performance. (#2996)Yong He
* Simplify lookup. * Various bug fixes. * Report type dictionary size in perf benchmark. * Remove type duplication. * increase initial dict size. * Bug fix. * Fix bugs. * Fixup. * Revert type legalization looping. * Fix specialization pass. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-07-14Fix vk-shift-* mapping issue (#2993)jsmall-nvidia
* Fix vk-shift-* mappings. * Add some doc info about vk-shift. * Fix diagnostic test.