summaryrefslogtreecommitdiff
path: root/source
AgeCommit message (Collapse)Author
2023-08-23Misc. SPIRV Fixes. (#3146)Yong He
* Lower all ByteAddressBuffer uses for SPIRV. * Misc. SPIRV Fixes. --------- Co-authored-by: Yong He <yhe@nvidia.com> Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
2023-08-23Lower all ByteAddressBuffer uses for SPIRV. (#3143)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>
2023-08-23Retain int casts when unifying generic params (#3145)Ellie Hermaszewska
2023-08-22Make `-fvk-u-shift` work on AppendStructuredBuffer. (#3144)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>
2023-08-22color spirv-val output (#3132)Ellie Hermaszewska
* s/invalid code/todo * comment debug disassembled spirv * more convenient spirv-val output * color spirv-val output
2023-08-21Compile append and consume structured buffers to glsl. (#3142)Yong He
* Compile append and consume structured buffers to glsl. * Fix. * Update CI config. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-08-18Allow loop counters to be used as constexpr arguments. (#3139)Yong He
* Allow loop counters to be used as constexpr arguments. * Fix. * Fix. * Fix. * Fix. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-08-18SPIRV: Fix matrix layout tests. (#3137)Yong He
* SPIRV: Fix matrix layout tests. * Remove spaces. * Disable debug output. * Fix. * Update expected-failure list. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-08-17Be more careful about merge blocks during loop inversion (#3136)Ellie Hermaszewska
* fix block eater * Be more careful about merge blocks during loop inversion * Restrict loop inversion to loops without continue jumps * Remove multiple back-edges from loops for SPIR-V * Wiggle cross compile test output * Make loop-inversion more conservative * Allow loops on false side in cfg normalization * Do not set loop continue block during inversion * Add loop inversion test to failing test list for spirv * Simplify single use continue blocks in spirv legalization * wobble expected failure list --------- Co-authored-by: Yong He <yonghe@outlook.com>
2023-08-17Initial support for differentiating existential types (#3111)Sai Praveen Bangaru
* Merge * WIP: Complete auto-diff logic for existential types * Revert "Add compiler option for generating representative hash" This reverts commit 13b09ef4621e73844c96d64d9c111a8ed0d45aae. * More fixes for fwd-mode AD on existential types * Add anyValueSize inference pass * Fix checking of `Differential.Differential==Differential` * In-progress: infer any-value-size for existential types * Existentials now work in forward-mode * Overhaul handling of existential AD types. Fwd-mode works, reverse-mode requires front-end changes * Reverse-mode now works on existentials * Cleanup * Remove diff rules for create existential object for now * Revert treat-as-differentiable changes * Fixes * More fixes * Cleanup * more cleanup * signed/unsigned * Revert "Cleanup" This reverts commit e4f7d71f07bb207736f90708961eeecd09a1b652. * Cleanup (again) * Remove public/export/keep-alive on null differential after AD pass * Minor fix * Update dictionary accessors * Keep export decoration * More fixes + Support for `kIROp_PackAnyValue` * Merge upstream * Update expected-failure.txt
2023-08-17Create storage types of different layouts for SPIRV emit. (#3116)Yong He
* Create storage types of different layouts for SPIRV emit. * Fix. * Fix. * Fix. * Update expected failure list. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-08-17Add loop inversion pass (#2899)Ellie Hermaszewska
* Generalize collectInductionValues * Support affine transformations of loop index as induction variables * Test for generalized induction value collection * Neaten inductive variable finding * Make types more specific * Add loop inversion pass * Test output changes after loop inversion * 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 * Wiggle expected output for cross compile test after loop inversion * Add loop inversion test * Simplify IfElse instructions with a single trivial block * Invert loops with a user inserted break * Limit loop inversion to loops with a 4 instruction or less comparison block * regenerate vs projects
2023-08-16Run vk tests on spirv backend with expected failure list. (#3128)Yong He
2023-08-16Correct check for empty target flags (#3115)Ellie Hermaszewska
Co-authored-by: Yong He <yonghe@outlook.com>
2023-08-16Simplify IfElse instructions with a single trivial block (#3114)Ellie Hermaszewska
2023-08-15squash warnings (#3113)Ellie Hermaszewska
* Remove unused variables * Silence gcc out of bounds warnings * Squash strict-aliasing warnings It is still a naughty thing to be casting to T like this though * Correct equality check when val is nullptr --------- Co-authored-by: Yong He <yonghe@outlook.com>
2023-08-15SPIRV: debug source and debug line. (#3109)Yong He
2023-08-16Fix a bug that warning 39001 can't be fully disabled. (#3112)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>
2023-08-16Use ankerl/unordered_dense as a hashmap implementation (#3036)Ellie Hermaszewska
* Correct namespace for getClockFrequency * missing const * Add missing assignment operator * Remove unused variables * Return correct modified variable * Use stable hash code for file system identity * terse static_assert * Structured binding for map iteration * Make (==) and getHashCode const on many structs * Add ConstIterator for LinkedList * Replace uses of ItemProxy::getValue with Dictionary::at * Extract list of loads from gradientsMap before updating it * Const correctness in type layout * Add unordered_dense hashmap submodule * Use wyhash or getHashCode in slang-hash.h * refactor slang-hash.h * Use ankerl/unordered_dense as a hashmap implementation Notable changes: - The subscript operator returns a reference directly to the value, rather than a lazy ItemProxy (pair of dict pointer and key) slang-profile time (95% over 10 runs): - Before: 6.3913906 (±0.0746) - After: 5.9276123 (±0.0964) * 64 bit hash for strings So they have the same hash as char buffers with the same contents * Narrowing warnings for gcc to match msvc * revert back to c++17 * Correct c++ version for msvc * Use path to unordered_dense which keeps tests happy * Do not assign to and read from map in same expression * Remove redundant map operations in primal-hoist * Split out stable hash functions into slang-stable-hash.h * 64 bit hash by default * regenerate vs projects * Correct return type from HashSetBase::getCount() * correct width for call to Dictionary::reserve * Use stable hash for obfuscated module ids * Signed int for reserve * clearer variable naming * Parameterize Dictionary on hash and equality functors * Allow heterogenous lookup for Dictionary * missing const * Use set over operator[] in some places * Remove unused function * s/at/getValue
2023-08-15Fix ByteAddressBuffer array legalization. (#3106)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>
2023-08-15Disable strict aliasing for gcc (#3105)Ellie Hermaszewska
Co-authored-by: Yong He <yonghe@outlook.com>
2023-08-15Fix bug with overload resolution under nested generics (#3107)Sai Praveen Bangaru
* Add test for generic param inference bug for nested generics * Change description & simplify test * Add expected file * Check parent decl before unifying type parameters
2023-08-15SPIR-V WIP (#3064)Ellie Hermaszewska
* Add type layout for structured buffer * Default to generating spirv directly * vk test for compute simple * Add spirv-dis as a downstream compiler * Emit Array types in SPIR-V * makevector for spirv * Dump whole spirv module on validation failure * register array types todo, use emitTypeInst * Neater formatting for unhandled inst printing * break out emitCompositeConstruct * Correct array type generation * neaten * Allow getElement for vector * Remove unused * Allow predicating target intrinsics on types * Consider functions with intrinsics to have definitions We need to specialize these if they are predicated on types * Correct array type generation * makeArray for spir-v * replace getElement with getElementPtr for spirv * Correct translation of field access for spirv * Push layouts to types for spirv * Spirv intrinsics * operator now makes a pointer * Add structured buffer of struct test * Preserve type layout in spirv structured buffer legalization * neaten * makeVectorFromScalar for SPIRV * placeholder for layouts on param groups * More type safe spirv op construction * Know that constants and types only go in one section * Remove emitTypeInst * Add todo for spirv sampling * Add links to spirv documentation on emit functions * OpTypeImage support for SPIR-V * Add simpler texture test for spirv * s/spirv_direct/spirv/g * Allow several string literals in target_intrinsic * Handle global params without a var layour for SPIR-V For example groupshared vars * uint spirv asm type * Add todo for isDefinition It is currently too broad * Some atomic op spirv intrinsics * Strip ConstantBuffer wrappers for spirv * Add todo for matrix annotations * Do not associate decorations insts with spirv counterparts * Correct entry point parameter generation * Spelling * Assert that fieldAddress is returning a pointer * Add error for existential type layout getting to spir-v emit * Add IRTupleTypeLayout Unused so far * Allow getElementPtr to work with vectors * Correct target name in test * Hide default spirv direct behind a premake option --default-spirv-direct=true * Do not insert space at start of intrinsic def * Correct asm rendering in tests * remove redundant option * Emit directly from direct test * Add source language options for spirv-dis * Add comments to spirv dis * Add dead debug print for before spirv module * Correct asm rendering in tests * s/spirv_direct/spirv/g * Only specialize intrinsic functions with predicates * regenerate vs projects * squash warnings * squash warnings * remove duplication * Silence warnings from msvc * squash warnings * Overload for zero sized array * More msvc warnings * warnings * Add spirv-tools to path for tests * Do not be specific about dxc version for diag test * Normalize line endings from spirv-dis * Correct filecheck matches * Temporarily disable two spirv tests Failing on CI, undebuggable hang :/ * Do not emit storage class more than once for spirv snippet * Do not pass spir-v to spirv-dis by stdin * Do not get spirv-dis output via stream, use file * normalize file endings in spirv-dis output
2023-08-14Add auto-diff support for `IRSwizzleStore` (#3102)Sai Praveen Bangaru
* Add auto-diff support for `IRSwizzleStore` - Lower IRSwizzleStore to multiple stores during AD preprocess. - Fix typo in `transcribeNonDiffInst` * Remove unnecessary file & add more robust check for 'local' addresses * Fix. * Update slang-ir-autodiff-fwd.cpp --------- Co-authored-by: Yong He <yonghe@outlook.com>
2023-08-14Support per field matrix layout (#3101)Yong He
* Support per field matrix layout * Fix warnings. * Fix. * Fix tests. * Fix spiv gen. * Fix. * More test fixes. * Fix. * Run only GPU tests on self-hosted servers. * Remove -use-glsl-matrix-layout-modifier. * Fix. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-08-14Fix issue with nested loop unrolling (#3100)Sai Praveen Bangaru
* Do not eliminate single-iter-loops that have inner loops using their break label. * Add test * Delete out-old.hlsl * Update slang-ir-autodiff-cfg-norm.cpp * Fix whitespace
2023-08-11Make sure glsl source in spirv is included when compiling with -g3 (#3099)Yong He
* Make sure glsl source in spirv is included when compiling with -g3. * Exclude vulkan tests on github linux CI. * Fix. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-08-10Add scalar version of `distance`. (#3096)Yong He
2023-08-10Fix `Texture2D.Load()` with offset. (#3094)Yong He
Co-authored-by: Yong He <yhe@nvidia.com>
2023-08-10Add support for ConstBufferPointer on Vulkan. (#3089)Yong He
* Add support for `ConstBufferPointer` on Vulkan. * Add spv compilation test. * Fix. * Fix code review issues. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-08-10Allow member lookup through modified type. (#3091)Yong He
* Allow member lookup through modified type. * Disable `lockFileSync` test. --------- Co-authored-by: Yong He <yhe@nvidia.com>
2023-08-09Support nested structs in function bodies. (#3078)Yong He
2023-08-09Support implciit casted swizzled lvalue. (#3077)Yong He
* Support implciit casted swizzled lvalue. * Fix warnings. * Fix. * fix comment. * Prefer mangled linkage name for global params. * Update tests. --------- Co-authored-by: Yong He <yhe@nvidia.com>
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