summaryrefslogtreecommitdiffstats
path: root/tests/language-feature
Commit message (Collapse)AuthorAge
...
* Fix IR lowering for generic interface types. (#4761)Yong He2024-07-31
| | | | | | | * Fix IR lowering for generic interface types. * Fix. * Fix.
* Fix invalid code generation for when using nested resource specialization ↵ArielG-NV2024-07-30
| | | | (#4751)
* Allow passing sized array to unsized array parameter. (#4744)Yong He2024-07-26
|
* Add `_Internal`/`External` atom enforcement and validation. (#4702)ArielG-NV2024-07-25
| | | | | | | | | | | | | | | | | | | | | | * Add `_Internal`/`External` atom validation and use enforcement. Fixes: #4676 Changes: * Added `validateInternalAtomExternalAtomPair` to the capability generator to ensure all `_Internal` atoms have a corresponding `External` atom. * Validation of 'RequireCapabilityAttribute' warns if a user uses an '_Internal' atom. * Added 'External' atoms to atoms with an already existing '_Internal' atom. * Printing an atom removes '_'. * Fixed some incorrect which were checking for the incorrect warning/error (capability4.slang, capability5.slang, capability6.slang). * switch capability name to use `UnownedStringSlice` instead of `const char*` switch capability name to use `UnownedStringSlice` instead of `const char*`, this includes using functions like `.startsWith`. * grammer --------- Co-authored-by: Yong He <yonghe@outlook.com>
* Allow implicitly casting enum types to bool. (#4739)Yong He2024-07-25
| | | | | * Allow implicitly casting enum types to bool. * Fix.
* Simplify `CapabilitySet` Diagnostic Printing (#4678)ArielG-NV2024-07-23
| | | | | | | | | | | | | | | | | Fixes: #4675 Fixes: #4683 Fixes: #4443 Fixes: #4585 Fixes: #4172 Made the following changes: 1. All capability diagnostic printing logic tries to simplify before printing. This means that we do not print atoms which imply another atom. 2. Do not print the `_` prefix part of atom names since it is misleading users on what they should use to solve a capability issue encountered. (`_Internal` `External` atom changes are not in this PR) 3. Bundle together printing of all sets which contain exactly the same atoms (excluding abstract atoms). This allows printing the following `vertex/fragment/hull/domain/... + glsl` instead of `vertex + glsl | fragment + glsl | hull + glsl | domain + glsl | ....` 4. Rework how entry-point errors are reported to users (example at bottom of PR comment) 5. Rework how atom-provenance data is collected to be leaner and more useful so we can rework the errors. There are 2 notable changes here: * We no longer store a list which describes where the first of an `CapabilityAtom` comes from. This heavily simplifies AST logic for the capability system. AST parsing of capabilities is much faster. The trade-off is faster AST parsing and correct AST node data for slower diagnostics if an error is found * atom-provenance data now stores a reference to an atom's use-site to provide information on **where** and **what** is wrong with user code versus only sharing **what** and not where.
* Support parameter block in metal shader objects. (#4671)Yong He2024-07-19
| | | | | | | | | | | | | * Support parameter block in metal shader objects. * Ingore parameter block tests on devices without tier2 argument buffer. * Fix warning. * Fix texture subscript test. --------- Co-authored-by: Yong He <yhe@nvidia.com>
* Warnings for uninitialized fields in constructors (#4680)venkataram-nv2024-07-18
| | | | | | | | | | | | | * Detect uninitialized fields in constructors * Reachability check for early returns * Specialized warnings for synthesized default initializers * Handling quirks with constructors * Addressing review comments * Ignore synthesized constructors if they are not used
* Adjust how `slang` and `slangc` uses a `profile` to manage the stage of an ↵ArielG-NV2024-07-18
| | | | | | | | | | | | | | | | | | | | | entry-point (#4670) * Fixes #4656 Changes: 1. Setting a profile via slangc no-longer sets an entry-point target-stage, this is to allow slangc to follow how the SLANG-API works (else `main` is assumed to be the default entry-point) 2. If the stage specified by a profile is not equal to the stage specified by a entry-point, we throw a capability error. 3. Resolving the stage of an entry point was changed to function (mostly) equally for when 0 entry-points are specified versus to when there are 1 or more. 4. changed capabilitySet Iterator so it is invalid if backing data is nullptr (although this should never happen, it would stop crashes in the worst case). * remove the breaking change since it likely is going to be a lot more than just a simple change due to the implicit `main` and stage through `profile` code. * print out profile name with errors * use target's profile for printing * change logic to print warning in a different method (account for more cases) * set unknown stages
* Warnings function parameters (#4626)venkataram-nv2024-07-16
| | | | | | | | | | | | | | | | | | | | | * Handle out/inout functions with separate consideration * Fixing bug with passing aliasable instructions * Handle autodiff functions (fwd and rev) in warning system * Handling interface methods * Handling ref parameters like out/inout * Temporary fix to remaining bugs * Refactoring methods and tests * Recursive check for empty structs * Using default initializable interface in tests * Resolving CI fail
* Change IDefaultInitializableType to IDefaultInitializable (#4620)ArielG-NV2024-07-12
|
* Fix incorrect codegen when returning initializer list as existential value. ↵Yong He2024-07-11
| | | | | | | | | | | (#4618) * Add `dev` cmake preset. * Fix incorrect codegen when returning initializer list as existential value. * Fix cmake. * Fixup.
* Emit errors when invalid capabilities are used (#4510)ArielG-NV2024-07-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix invalid capabilities being allowed fixes: #4506 fixes: #4508 1. As per #4506, no longer allow invalid `[require(...)]` 2. As per #4508, no longer allow mismatch between `case` and `require` of a calling function 3. Fixes incorrect hlsl.meta capabilities 4. Added a ref to the parent function/decl for when erroring with capabilities to help debug meta.slang files for when weird source locations are generated. * rename vars and copy lambdas by value * fix some more capabilities * incorrect capabilities on a texture test * push capabilities fix note: seperated capabilities for glsl,spirv,cuda,hlsl since not all functions support all targets (source of capability error) * fix cmd line arg by using `xslang` to passthrough to slangc * let auto-infer run for certain capabilities to reduce simple mistakes --------- Co-authored-by: Jay Kwak <82421531+jkwak-work@users.noreply.github.com>
* Nested initialization list in struct crash fix (#4491)ArielG-NV2024-06-29
|
* Cache address-space-legalization of `kIROp_Store` (#4480)ArielG-NV2024-06-27
| | | | | | | | | * Cache address-space-legalization of `kIROp_Store` without caching we will infinetly loop re-processing the same `kIROp_Store` * uncomment tests which should now work with metal * disable gfx backend failing tests
* Implement for metal `SV_GroupIndex` (#4385)ArielG-NV2024-06-13
| | | | | | | | | | | | | | | | | | | | | | | | * Implement for metal `SV_GroupIndex` 1. If we don't have `sv_GroupThreadId` available we create one using `SV_GroupIndex`s location data. 2. We emit code emulating `sv_GroupThreadId` from the same logic that CUDA/CPP uses. * address most review comments Addressed all but two: [1](https://github.com/shader-slang/slang/pull/4385#discussion_r1639058473) and [2](https://github.com/shader-slang/slang/pull/4385#issuecomment-2166934855) I want to enable tests and be sure there is no bugs using CI before I redesign the code so I have a working fallback. * address comment, enable tests enable now functioning tests due to `SV_GroupIndex` working with metal * syntax error with groupThreadID search did `= param` instead of `= i.param` * add `sv_groupid` for test + test fixes * disable test that won't work regardless
* Metal: misc fixes and enable more tests. (#4374)Yong He2024-06-13
| | | | | | | | | | | | | | | | | * Fix and enable tests for metal. * Fix. * Fix. * Fix tests. * Fix warnings. * Fix. --------- Co-authored-by: Yong He <yonghe@Yongs-Mac-mini.local>
* Capability System: Implicit capability upgrade warning/error (#4241)ArielG-NV2024-06-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * capability upgrade warning/error adjusted implementation + tests to support a warning/error if capabilities are implicitly upgraded and test accordingly. * add glsl profile caps * add GLSL and HLSL capabilities to the associated capability * syntax error in capdef * only error if user explicitly enables capabilities 1. changed testing infrastructure to not set a `profile` explicitly, 2. Added tests to be sure this works as intended with user API and with slangc command line * Change capability atom definitions and how Slang manages them to fix errors 1. most `glsl_spirv` version atoms have been removed from `.capdef`, instead we will translate `spirv` version atoms into `glsl_spirv` since there is no point in writing the same code twice in `.capdef` files to define `spirv` versions. 2. add spirv version, and hlsl sm version (and equivlent) capability dependencies 3. removed some stage requirments which were set on objects, keep the wrapper capabilities. I am keeping the wrapper capabilities since I am unaware on if there are stage limitations (spec says code in practice does not work). * check internal version instead of version profile (_spirv_1_5 vs. spirv_1_5) * remove unused OpCapability. adjust SPIRV version'ing again for glsl_spirv * apply workaround for glslang bug with rayquery usage * ensure capabilities targetted by a profile and added together by a user are valid * remove additions to `spirv_1_*` wrapper * spirv_* -> glsl_spirv fix * fix bug where incompatable profiles would cause invalid target caps * try to avoid joining invalid capabilities * fix the warning/error & printing * run through tests to fix capability system and test mistakes many mistakes were mesh shaders doing `-profile glsl_450+spirv_1_4`. This is not allowed for a few reasons 1. the test tooling does not handle arguments the same as `slangc` 2. glsl_450 core profile does not support mesh shaders, nor does spirv_1_4. sm_6_5 does work in this senario * set some sm_4_1 intrinsics to sm_4_0 * replace `GLSL_` defs with `glsl_` * swap the unsupported render-test syntax for working syntax * set d3d11/d3d12 profile defaults this is required since sm version changes compiled code & behavior * adjusted nvapi capabilities with atomics + d3d11 set to use sm_5_0 as per default * cleanup * address review * incorrect styling * change `bitscanForward` to work as intended on 32 bit targets --------- Co-authored-by: Yong He <yonghe@outlook.com>
* Add slangc flag to `-zero-initialize` all variables (#3987)ArielG-NV2024-06-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Default (zero'd) values with `-zero-initialize` flag Adds `-zero-initialize` flag to set values to a __default() expression if they are missing a initExpr. * address review and ensure __default calls ctor + zero's fields. 1. We must keep zero-initialize in SemanticsDeclHeaderVisitor. This is done because else a ctor will be initialized before we can set struct fields to `__default`. 2. IRDefaultCtorDecoration was added to track default ctor's with parent struct. 3. ParentAggTypeModifier was added to track ChildOfStruct->IRType for sharing data such as with functions. This is required to ensure we associate a lowered function with a lowered struct type * Removed decoration to track defaultCtor in favor of field. This was done since decorations are checked for IR objects, storing auxillary info does not work here as a result if usable object. * address some review comments Since `IDefaultInitializable` is taking a considerabley larger amount of time than anticipated I am pushing some of the other fixes requested. I did not remove the "IRStruct storing a default Ctor" hack yet. mostly renamed/adjusted tests to work as intended added test to ensure we don't synthisize a junk `= 0` when not in `zero initialize` mode removed member in favor of sharedContext+dictionary. * a working but incorrect impl * default init without any IR hacks (fully working aside from generic/containored-types) * Finish zero init code 1. IDefaultInitializer interface was added. If conforming, your type may be zero-initialized. To Conform a `__init()` is required 2. `[OnlyAutoInitIfForced]` was added. This attribute states that a default initializer should only be implicitly called if forced by the compiler (`zero-initialize` for example). This allows types which implicitly/explicitly conform to IDefaultInitialize to have optional auto-init behavior (which is Slang's default for user structs) to be disabled. * note about `[OnlyAutoInitIfForced]`. This is required for std-lib to not automatically resolve init-expressions for std-lib, but it has the added benifit of allowing user made structs/classes to control the default behavior of initializing * fix ErrType assumption * testing why dx12 fails local but passes CI * push vector changes to generic test * push syntax adjustment, still figuring out what is wrong with cuda. * remove debug changes & adjust style * fix field-init expressions with structs initializers don't init a static in a ctor. This would be illegal code and wrong code (init list in lower-to-ir) * minor adjustments temporarily while the rest of the issue is discussed * fix * implement IDefaultInitializable * remove a unneeded whitespace change * fix type checking error should be checking if a valid type is `Type`, not `BasicExpressionType` * needs to be DeclRefType, not Type * fix langguage server error * change findinheritance for correctness + cleanup * remove return false verified the issue was `findInheritance` * push attempt at language server fix * still trying to fix inheritance * added extension support, remove redundant code Did not address all review comments yet, want to see if CI also passes my changes * undo a change which caused CI to fail * change logic + DefaultConstructExpr setup code to use defaultConstructExpr when possible to construct a default without overhead of invoke/related also changed code so parent's defaultInitializable propegates to derived member * 1. fix error in `isSubtype` 2. add flag to isSubtype `subtypeInheritanceIsNotFullyResolved` was added since we may not be done the lookup stage but still require `isSubtype` checking to verify usage of inheritance while working with inheritance. In This case we will just skip `ensureLookup` and "caching" (since we don't have a cache invalidation system, nor need) * fix bug in logic + add test to better catch the bug * address comment + isSubTypeOption + wrapper type test, * fix wrong code adjustment I checked on the CI and realized I caused a failure, mistake was made not negating some code * syntax, class naming capital * remove stdlib default initialize changes, replace with `__default()` for init * remove redundant code + fix defaultConstruct emitting previously defaultConstruct emitting was crashing due to having generics unresolved. By not resolving the default construct immediately, everything works. * remove a coment * add test to ensure static variables dont `init` inside a struct's `__init` * fix Ptr members breaking struct use * address review and add -zero-initialize test `-zero-initialize` test was added to be sure debug pointers are not broken with default init values --------- Co-authored-by: Yong He <yonghe@outlook.com>
* Add compiler option to treat enum types as unscoped. (#4354)Yong He2024-06-12
|
* Partial implementation of static_assert (#4294)Jay Kwak2024-06-10
| | | | | | | | | | | | | | | | | | | | | | | * Error out for types not supported by texture sample functions This commit prints errors with a new keyword, `static_assert`, when the given texture type is not supported for the target. * Moving the check to linkAndOptimizeIR after specialization is done * Remove unnecessary change * Adding test * Remove kIROp_StaticAssert once processed * Do not remove StaticAssert because it is needed for the next specialization * Remove after iteration of child is done --------- Co-authored-by: Yong He <yonghe@outlook.com>
* enable more metal tests (#4326)skallweitNV2024-06-10
|
* Support all integer typed indices in StructuredBuffer Load/Store/[]. (#4311)Yong He2024-06-10
| | | | | | | | | * Support all integer typed indices in StructuredBuffer Load/Store/[]. * Fix tests. --------- Co-authored-by: Jay Kwak <82421531+jkwak-work@users.noreply.github.com>
* Metal compute tests (#4292)skallweitNV2024-06-07
|
* Fix a bug on default initialization of interface typed value. (#4249)Yong He2024-05-31
| | | | | * Fix a bug on default initialization of interface typed value. * Fix.
* Improve compile time performance. (#3857)Yong He2024-05-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Handle type check cache update on extensions more gracefully. * Correctness fix. * Cache implcit cast overload resolution results. * Fix. * More optimizations. * Cache implicit default ctor resolution. * Disable redundancy removal. * Fix. * Fix test. * Fix. * Correctness fix. * Fix. * Fix, * Fix test. * Small tweak.
* ignore capability system skips the capability pass 100% now (#4183)ArielG-NV2024-05-16
|
* Capabilities System, CapabilitySet Logic Overhaul (#4145)ArielG-NV2024-05-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Capabilities System, Backing Logic Overhaul Fixes #4015 Problems to address: 1. Currently the capabilities system spends anywhere from 25-50% of compile time on the CapabilityVisitor. Most of this time is spent on join logic: 1. Finding abstract atoms 2. Comparing list1<->list2. This should and can be made significantly faster. 2. Error system does not produce errors with auxiliary information. This will require a partial redesign to provide more useful semantic information for debugging. What was addressed: 1. Array backed `CapabilityConjunctionSet` was replaced in-favor for a `UIntSet` backed `CapabilityTargetSets`. The design is described below. Design: * `CapabilityTargetSets` is a `Dictionary<targetAtom, CapabilityTargetSet>`. This is not an array for 2 reasons: 1. Easy to figure out which target is missing between two `CapabilityTargetSets` 2. To statically allocate an array requires the preprocessor to manually annotate which Capability is a target and link that Capability to an index. This means a dictionary is required for lookup regardless of implementation. * `CapabilityTargetSet` is an intermediate representation of all capabilities for a singular `target` atom (`glsl`, `hlsl`, `metal`, ...). This structure contains a dictionary to all stage specific capability sets for fast lookup of stage capabilities supported by a `CapabilitySet` for a `target` atom. This reduces number of sets searched. * `CapabilityStageSet` is an intermediate representation of all capabilities for a singular `stage` atom (`vertex`, `fragment`, ...). This structure holds all disjoint capability sets for a `stage`. A disjoint set is rare, but may exist in some scenarios (as an example): `{glsl, EXT_GL_FOO}{glsl, _GLSL_130, _GLSL_150}`. This reduces the number of sets searched. * `UIntSet` is the main reason for the redesign for better performance and memory usage. All set operations only require a few operations, making all set logic trivial and with minimal cost to run. All algorithms were modified to focus around `UIntSet` operations. 2. Errors * Semantic information are now better linked to the calling function to provide a connection of function<->function_body for when saving semantic information for errors. * Missing targets now print errors much like other error code by finding code which could be a cause of incompatibility. What is missing: 1. Add non naive support for non-stage specific capabilities such as `{hlsl, _sm_5_0}`. Currently non stage specific targets emulate the behavior through assigning such capabilities to every stage: `{hlsl, _sm_5_0, vertex} {hlsl, _sm_5_0, fragment}...`. Removal of this behavior would remove redundant shader stage sets being made at construction time (~80% of new implementation runtime). This is an addition, not an overhaul. 2. Optionally: `UIntSet` should be modified to support SIMD operations for significantly faster operations. This is not required immediately since `UIntSet` is already not a performance constraint. Notes: * UIntSet had implementation bugs which were fixed in this PR. * The old capabilities system had bugs which were fixed in this PR when transforming to the new implementation. * fix .natvis debug view * Small optimizations I found while working on the addition the AST building pass looks like so now: 1% = ~capabilitySet 2% = capabilitySet() 1.5% capabilitySet::unionWith() 0.8% capabilitySet::join() 1.5% auxillary info for debugging ~0.5-1% extra visitor overhead ~5% total for the visitor ~6.5% for total runtime costs * fix caps which were wrong but worked * push minor syntax fix (still looking for why other tests fail) * perf & bug fixes 1. did not properly remake isBetterForTarget for this->empty case with that as Invalid. This is best case in this senario. 2. Remade seralizer for stdlib generation. Faster (more direct) & cleaner code. NOTE: did not address review comments * fix glsl.meta caps error * fixing findBest logic again & UIntSet wrapper findBest was not checking for 'more specialized' targets & was element counter was flawed * faster getElements algorithm + natvis for UIntSet + wrong warning * type incompatability of bitscanForward implementations * try to fix warnings again * remove ptr for clang intrinsic * add missing header * ifdef to allow clang compile * compiler hackery to fix up platform/type independent operations * bracket * fix MSVC error * missing template * change types out again * changes to fix compiling * adjustment to parameter for Clang/GCC * added iterator to delay processing all atomSets of a CapabilitySet * add a few missing consts's * ensure we never have more than 1 disjointSet Added a wrapper + assert + union functionality to all possible disjoint sets. This was done in favor of a removal of the LinkedList for 2 reasons: 1. We still need 0-1 set functionality. 2. Might as well keep the code, just disallow the problematic functionality. * address review comments non linked-list refactor review comments addressed; add doc comments + remove redundant code * comments + remove isValid for bool operator * push removal of linkedlist for capabilities * add missing break * address review comments minor adjustments of syntax * push a fix to the `CapabilitySet({shader, missing target})` code * quality + error 1. add iterator to UIntSet 2. do not specialize target_switch if profile is derived from case (GLSL_150 is not compatable with GLSL_400) * fix target_switch erroring + temporarily remove UIntSet::Interator temporarily remove UIntSet::Interator. It will be added after, testing code on CI first so I can multi-task fixing the UIntSet Iterator * fix the UIntSet iterator * Revert "fix the UIntSet iterator" temporarily to pull from master * add metal error as per texture.slang (took a while I realize this was why things were breaking, likely should adjust errors to reflect this) * Rework UIntSet to have a template for output type This is done so it is reasonable to debug the iterator output and not just dealing with messy int's Fix problems with the iterators implemented + invalid capabilities handling * removed incorrect `__target_switch` capability barycentric was being used with anticipation of `profile glsl450`, this does not expand into `GL_EXT_fragment_shader_barycentric`, this instead caused an error which is hidden during cross-compile. * remove some uses of getElements * remove undeclared_stage for now * remove redundant code associated with `undeclared_stage` * remove unused variable * address review specifically to note removed static in a thread dangerous scope. Now using a `const static` for read only (thread safe) which precompile steps generate * move GLSL_150 capdef change to sm_4_1 (more accurate) * address most review comments did not address: https://github.com/shader-slang/slang/pull/4145#discussion_r1602256776 * revert incorrect code review suggestion * push changes for all code review suggestions
* Support generic constraints that are dependent on another generic param. (#4091)Yong He2024-05-02
|
* WIP: Force Inline If RefType (#4005)ArielG-NV2024-04-26
| | | | | | | | | | | | | | | | | | | | * Force Inline if reftype Fixes #3997. If we are using a refType, we now ForceInline. remarks: 1. Modifications were made in slang-ir-glsl-legalize to change how we translate GlobalParam proxy's into GlobalParam. a. We now handle the senario where a globalParam is used in multiple disjoint blocks (like 2 different functions). * try to figure out why CI fails but local works try to inline DispatchMesh, works locally, may fail on CI(?) * try another fix * add task tests + don't allow semi-early task-shader inline Task shader uses DispatchMesh which is a very big 'hack' where we check for the function name and modify the callees in very large ways. This function does inline, but it cannot inline early due to future mangling that this operation requires todo. This is reflected with the `[noRefInline]` modifier. It is a modifier so users may stop mandatory inlines with `__ref` parameter.
* use memberExpr instead of varExpr (#4008)ArielG-NV2024-04-23
|
* bit_cast & reinterpret warning if src->dst type not equally sized. (#3988)ArielG-NV2024-04-22
| | | | | | | | | * bit_cast & reinterpret warning if src->dst type not equally sized. bit_cast & reinterpret warning if src->dst type not equally sized. --------- Co-authored-by: Yong He <yonghe@outlook.com>
* Flag to prevent packing of cbuffer elements in HLSL backend. (#3993)Pema Malling2024-04-21
|
* Initial pass to add capability declarations to stdlib intrinsics. (#3912)ArielG-NV2024-04-19
|
* add `-ignore-capabilities` flag (#3984)ArielG-NV2024-04-19
| | | | | `-ignore-capabilities` flag allows ignoring capability incompatibilities/discontinuity errors/warnings. We still process capabilities (needed for stdlib). Added to capability tests to ensure everything is working as intended. More will be added in the full stdlib capabilities implementation.
* Implement if(let ...) syntax (#3673) (#3958)kaizhangNV2024-04-17
|
* Fix for unscoped enums circular reference causing an error, #3959 (#3962)ArielG-NV2024-04-16
|
* Init expressions for struct fields support, #3738 (#3907)ArielG-NV2024-04-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Init expressions for struct members Following commit handles init expressions of struct's. The general implementation follows C++ init expression rules for classes & inherited classes. The logic was implemented after type resolution (`SemanticsDeclAttributesVisitor`): 1. Create a default constructor if missing. 2. Check all member variables (`this` and `super`) for if a member has an init expression, continue to *3* if found. 3. For each constructor, insert a member variable's init expression at the beginning of a constructor. This is to follow how C++ does construction of objects. Some important notes about implementation: * We must handle the scenario that there is inheritance. To handle the inheritance information processing `findLevelsOfInheritance` was created. * If a user manually sets overload rank's of constructor expression's we have no way to assume new default constructor overload ranks. * address feedback - moved all scope bound variables into if statment initializers - added indent - changed logic for overloadRank to be centered around positive numbers rather than negative * Inheritance fixes universally & for struct field init 1. reimplemented struct field logic 2. implemented inheritance through calling a "super->init()" inisde a constructor for each "this". 3. implemented support for multi level inheritance (4+) and accessing members without a crash. * add a way to ignore Forward declared constructors. * a test and fix for a falcor failiure the following case was not handled: creating an default Ctor due to a non L-Value struct field. Having an empty Ctor causes a warning. * remove texture/sampler from test since it will break glsl * get inheritance info using existing lookup logic modified Facet lookups to store relative depth rather than arbitrary ::Self or' ::Direct for inheritance (which was 'wong' since depth 2 is not Direct, but was considered a Direct inheritance) * cleanup unused * cleanup unused functions and whitespace * fix compile warning * clean up, reorder, addressed language server fail changed logic to safeguard bad code --> no longer breaks language server if code is incomplete. remove the "semi-ordering" logic because caused a crash (and this code does nothing functionally, just thought it would be nice to add if '0 cost'). Remove rank setting for constructors, in place use an addition to the overload system: "this" expressions have calling priority over "super" expressions. * undo all inheritance depth checks & code added to the inheritance checking algorithm Reorder default ctor creation and auto-generation of constructor body. * Handle same struct types during overload resolution Changed overload resolution logic to properly handle same struct types; added test to check for multi-param same type function overload. * remove unused ast object Used unused object in an incorrect way. This caused the compiler to not flag a warning. * extension support for default constructors specialization is not supported with default constructors yet. * fix bugs Fix bug in override/overload logic with type comparisons. used wrong type for ctor list construction Specialization has not been added yet * disallow default ctor inside extension * adjust comment, add new tests * add explicit types to invoke, use faster default ctor lookup. * adjust syntax & naming as recomended
* Fix __init() functions that returns an existing value (#3866)sriramm-nv2024-04-05
| | | | | | | | | | | | | | | | | | Fixes the issue #3671 * The __init constructors are not expected to return a value like other member functions, but must construct a new value and return the struct type or none. * This patch enables this behavior in the IR lowering without complaining about illegal situations where the user returns an invalid type or none at all. Translate ordinary struct `return ...;` to `this = ...; return this;` Translate NonCopyableType struct `return ...;` to `return this;` * This patch also fixes the issue with type checking when __init() returns a void that mismatches the base type of the struct/ class Translate ordinary struct `return;` to `return this;` Translate NonCopyableType struct `return;` to `return;` * Add end-to-end test and compile only tests to check the above behavior.
* Allow enum values to be used as generic arguments. (#3874)Yong He2024-04-02
| | | | | * Allow enum values to be used as generic arguments. * Fix constant folding.
* Fix static member lookup in pointer types. (#3869)Yong He2024-04-01
|
* Allow bit operators on enum types. (#3862)Yong He2024-04-01
| | | | | * Allow bit operators on enum types. * Fix.
* Fix peephole optimization of `TypeEquals`. (#3865)Yong He2024-04-01
| | | Closes #3861.
* Allow anonymous struct. (#3822)Yong He2024-03-23
|
* Make `-no-mangle` option work, add `-no-hlsl-binding`. (#3817)Yong He2024-03-23
|
* Support unscoped enums. (#3771)Yong He2024-03-14
|
* Add documentation for uniformity analysis. (#3721)Yong He2024-03-08
|
* Parser and module finding logic fixes. (#3720)Yong He2024-03-08
| | | | | | | | | * Fix parsing logic of `struct` decl. Fixes #3716. * Allow `loadModule` to find modules with underscores. * Fix test.
* Uniformity analysis. (#3704)Yong He2024-03-07
| | | | | * Uniformity analysis. * Add [NonUniformReturn] decorations to some hlsl intrinsic functions.
* Extend `as` and `is` operator to work on generic types. (#3672)Yong He2024-03-04
|