summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/enums
Commit message (Collapse)AuthorAge
* Allow 1D SV_DispatchThreadID in CPU targets (#8612)Julius Ikkala2025-10-08
| | | | | | | | | | | | | | | | | | | | The varying param legalization pass didn't deal with this 1D form of SV_DispatchThreadID for CPU targets: ```slang void computeMain(int i : SV_DispatchThreadID) ``` Instead, it just overrode the type of `i` with a `uint3`, breaking lots of code that attempted to use `i` for something, like a `switch` statement for example. I ran across this when going through `language-feature` tests for the LLVM target, which will also use this legalization pass. I'm separately submitting this now because this also fixes the existing CPU target. The test I enable in this PR is one that was previously generating broken code on CPU. (somewhat related issue: #7468)
* Fix incorrect binding index assignment for StructuredBuffer and ↵Copilot2025-10-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ByteAddressBuffer with DescriptorHandle (#8252) - [x] Fix segmentation fault in wrapConstantBufferElement for DescriptorHandle types - [x] Split DescriptorKind.Buffer into ConstantBuffer and StorageBuffer - [x] Update binding enums with descriptive names (ConstantBuffer_Read, StorageBuffer_Read, etc.) - [x] Update resource type mappings for correct binding assignments - [x] Update template logic to handle ConstantBuffer and StorageBuffer kinds separately - [x] Update tests to reflect correct binding assignments - [x] Split DescriptorKind.TexelBuffer into UniformTexelBuffer and StorageTexelBuffer - [x] Update TextureBuffer<T> to use UniformTexelBuffer kind - [x] Update _Texture extension to determine texel buffer kind based on access mode - [x] Update test desc-handle-1.slang to handle new DescriptorKind enum cases <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/shader-slang/slang/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Co-authored-by: Yong He <yonghe@outlook.com>
* Fix enum array indexing by adding implicit conversion support (#7815)Copilot2025-07-18
| | | | | | | | | | | | | | | | * Initial plan * Fix enum array indexing by adding implicit conversion support Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Update enum array indexing test to support GPU backends Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Fix cyclic lookups with UnscopedEnums (#6110)Julius Ikkala2025-01-17
| | | | | | | | | * Fix cyclic lookups with UnscopedEnums * Add test with multiple unscoped enums with explicit types --------- Co-authored-by: Yong He <yonghe@outlook.com>
* wgsl: signedness mismatch fixes (#5692)Anders Leino2024-11-28
| | | | | | | | | | | | | | | | | * Enable tests/language-feature/enums/strongly-typed-id.slang * Fix operator signedness mismatch issue This helps to address issue #5606. * wgsl: Insert casts for integer type return values This closes #5606. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Refresh of disabled WGPU tests (#5614)Anders Leino2024-11-21
| | | | | | | | | Some tests are now passing and are enabled. Other tests are still failing, but are given comments categorizing the failures. Tests in the 'Not supported in WGSL' category are also removed from the expected failures list. (Though they are still kept disabled for WebGPU, of course.) This closes #5519.
* Enable a bunch of WGPU tests (#5513)Anders Leino2024-11-07
| | | This closes issue #5505.
* Allow enum cases to be used in attribute arguments. (#5478)Yong He2024-11-02
|
* Properly check switch case. (#5341)Yong He2024-10-20
|
* Enable WebGPU tests in CI (#5239)Anders Leino2024-10-15
|
* Allow a enum case to reference a previously defined value. (#4768)Yong He2024-08-01
|
* Allow implicitly casting enum types to bool. (#4739)Yong He2024-07-25
| | | | | * Allow implicitly casting enum types to bool. * Fix.
* Add compiler option to treat enum types as unscoped. (#4354)Yong He2024-06-12
|
* enable more metal tests (#4326)skallweitNV2024-06-10
|
* Metal compute tests (#4292)skallweitNV2024-06-07
|
* Fix for unscoped enums circular reference causing an error, #3959 (#3962)ArielG-NV2024-04-16
|
* 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.
* Allow bit operators on enum types. (#3862)Yong He2024-04-01
| | | | | * Allow bit operators on enum types. * Fix.
* Support unscoped enums. (#3771)Yong He2024-03-14
|
* Add mnemonic parsing for `intrinsic_type` modifier. (#3306)Yong He2023-11-01
| | | Co-authored-by: Yong He <yhe@nvidia.com>
* Warning on lossy implicit casts. (#2367)Yong He2022-08-17
| | | | | | | | | | | | | | | * Warning on bool to float conversion. * Fix test cases. * Improve. * LanguageServer: don't show constant value for non constant variables. * Fix tests. * Fix warnings in tests. Co-authored-by: Yong He <yhe@nvidia.com>
* Fix a bug for enumerations with explicit "tag type" (#1856)T. Foley2021-05-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The basic bug here was that `enum` types with an explicit tag type: enum Color : int32_t { ... } would have an `InheritanceDecl` implying that `Color` inherits from `int32_t`. The problem is that this is *not* actually an inheritance relationship, since a `Color` needs to be explicitly cast to/from an `int32_t`. Various parts of the compiler currently treat this case like real inheritance, and as a result the operations taht would apply to an `int32_t` end up applying to a `Color` as well. This particularly leads to an ambiguity between applying the `==` operator, because it has overloads for both the `__EnumType` and `__Builtin{something}` interfaces. The fix here is to explicitly exclude the `InheritanceDecl` that represents an enumeration tag type when considering declared subtype relationships. A more complete version of this fix would need to go through all places in the code where `InheritanceDecl`s are used and make sure that any places using them for true inheritnace relationships ignore those that represent an enumeration tag type. (An alternative option would be to use a distinct kind of `Decl` to represent the tag-type relationship, perhaps even going so far as to modifying the type of the relevant AST node as part of semantic checking) This change includes a regression test for the way this bug surfaced in user code. Co-authored-by: jsmall-nvidia <jsmall@nvidia.com>
* Convert more tests to use shader objects (#1659)Tim Foley2021-01-15
| | | | | | | | | | | | | | | | | | | | | | | This change converts a large number of our existing tests to use the `ShaderObject` support that was added to the `gfx` layer. In many cases, tests were just updated to pass `-shaderobj` and the result Just Worked. In other cases, a `name` attribute had to be added to one or more `TEST_INPUT` lines. For tests that did not work with shader objects "out of the box," I spent a little bit of time trying to get them work, but fell back to letting those tests run in the older mode. Future changes to the infrastructure will be needed to get those additional tests working in the new path. Along with the changes to test files, the following implementation changes were made to get additional tests working: * Because the shader object mode uses explicit register bindings (from reflection), the hacky logic that was offseting `u` registers for D3D12 based on the number of render targets gets disabled (by another hack). * The "flat" reflection information coming from Slang was not correctly reporting "binding ranges" for things that consumed only uniform data (which would be everything on CUDA/CPU), so it was refactored to properly include binding ranges for anything where the type of the field/variable implied a binding range should be created (even if the `LayoutResourceKind` was `::Uniform`). * A few fixes were made to the CUDA implementation of `Renderer`, in order to get additional tests up and running. Most of these changes had to do with texture bindings, which hadn't really been tested previously. In addition, a few changes were made that were attempts at getting more tests working, but didn't actually help. These could be dropped if requested: * As a quality-of-life feature (not being used) the `object` style of `TEST_INPUT` line is upgraded to support inferring the type to use from the type of the input being set. * Any `object` shader input lines get ignored in non-shader-object mode.
* Fix an issue with explicit enum tag types (#1495)Tim Foley2020-08-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The basic problem here was that in a declaration like: ```hlsl enum Color : uint { Red, Orange, ... } ``` The `: uint` bit is represented as an `InheritanceDecl`, because that is what we use to represent the syntactic form of inheritance clauses like that. At the point where we parse the `InheritanceDecl` we don't yet know whether it represents a base interface or a "tag type" like `uint` in this case. The root problem that is then created is: an `enum` type is *not* a subtype of its "tag type," and treating it like a subtype can create problems. The main problem that arises is that looking in a type like `Color` will find both the members of color *and* the members of `uint`. In the case of things like `__init` declarations, that creates a problem where the `Color` type has two different `__init`s that take a `uint`: * The one it inherits from `uint` via that `InheritanceDecl` (even though it shouldn't) * The one it gets via an extension just for conforming to `__EnumType` (a non-user-exposed `interface` in the standard library) Because both of those `__init`s are inherited, neither is preferred over the other one and they create an ambiguity if somebody tries to write: ```hlsl uint u = ...; Colorc = Color(u); ``` The solution used in this PR is to add a compiler-internal modifier to the `InheritanceDecl` that introduces a "tag type" to an `enum`, in an early phase of checking (one of the ones that occurs before it is legal to enumerate the bases of a type). Then the lookup process is modified to ignore `InheritanceDecl`s with that modifier when doing lookup in super-types (since the declaration does *not* indicate a subtype/supertype relationship). This appears to get the basic feature working again, although it is possible that there are other parts of the compiler that use `InheritanceDecl`s and mistakently assume that all `InheritanceDecl`s introduce subtype/supertype relationships. We probably need to do a significant audit of the code to start being more clear about the nature of the relationships such declarations introduce. Such steps are left to future changes. Co-authored-by: Yong He <yonghe@outlook.com>
* Improvements to Casting (#1483)jsmall-nvidia2020-08-11
| | | | | | | | | | | | | | | | | | | | | | | | * Improve handling of cast detection when have a more complex cast than just a single identifier. * Improve comments around heuristic for casting * Added nested enum test. * Improve comments * Define function like - output change. * Use lookup for types in determining if cast or not. * Add _isCast function * Add heuristic test to nested-enum.slang that works if the type test fails. * Change hueristic based on review. Allow (..)( to always be an expression, because if it's a type it will be turned into a cast later. * Fix output of define-function-like.slang - which changes again with improved casting support. * Improve testing for type in cast - if we find a decl and it's not a type, then we know it's not a cast.
* Add != operator for enum types (#1394)Tim Foley2020-06-17
This was an oversight in the stdlib, and the `!=` definition follows the `==` in a straightforward fashion.