diff options
| author | Yong He <yonghe@outlook.com> | 2024-09-18 13:46:20 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-18 13:46:20 -0700 |
| commit | 2d83875f4b376f047c4541a6f6c13d36e5aa228b (patch) | |
| tree | ba41c6faa6e97b6821ac8ea635f2ae52ca8d1f4c /source/slang/core.meta.slang | |
| parent | 85b996a75683b5364456d731a9cb4aee5c3fada2 (diff) | |
Add `IRWArray` interface, and make StructuredBuffer conform to them. (#5097)
* Add `IRWArray` interface, and make StructuredBuffer conform to them.
* Update user guide.
* Fix.
* Fixes.
Diffstat (limited to 'source/slang/core.meta.slang')
| -rw-r--r-- | source/slang/core.meta.slang | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang index 03dda0fe5..afcff8e65 100644 --- a/source/slang/core.meta.slang +++ b/source/slang/core.meta.slang @@ -396,6 +396,15 @@ interface IArray<T> } } +interface IRWArray<T> : IArray<T> +{ + __subscript(int index)->T + { + get; + set; + } +} + // The "comma operator" is effectively just a generic function that returns its second // argument. The left-to-right evaluation order guaranteed by Slang then ensures that // `left` is evaluated before `right`. @@ -1148,21 +1157,15 @@ extension int16_t : IRangedValue __generic<T, let N:int> __magic_type(ArrayExpressionType) -struct Array : IArray<T> +struct Array : IRWArray<T> { __intrinsic_op($(kIROp_GetArrayLength)) int getCount(); - - __subscript(int index) -> T - { - __intrinsic_op($(kIROp_GetElement)) - get; - } } /// An `N` component vector with elements of type `T`. __generic<T = float, let N : int = 4> __magic_type(VectorExpressionType) -struct vector : IArray<T> +struct vector : IRWArray<T> { /// The element type of the vector typedef T Element; @@ -1182,8 +1185,6 @@ struct vector : IArray<T> [ForceInline] int getCount() { return N; } - - __subscript(int index) -> T { __intrinsic_op($(kIROp_GetElement)) get; } } const int kRowMajorMatrixLayout = $(SLANG_MATRIX_LAYOUT_ROW_MAJOR); @@ -1192,7 +1193,7 @@ const int kColumnMajorMatrixLayout = $(SLANG_MATRIX_LAYOUT_COLUMN_MAJOR); /// A matrix with `R` rows and `C` columns, with elements of type `T`. __generic<T = float, let R : int = 4, let C : int = 4, let L : int = $(SLANG_MATRIX_LAYOUT_MODE_UNKNOWN)> __magic_type(MatrixExpressionType) -struct matrix : IArray<vector<T,C>> +struct matrix : IRWArray<vector<T,C>> { __intrinsic_op($(kIROp_MakeMatrixFromScalar)) __implicit_conversion($(kConversionCost_ScalarToMatrix)) @@ -1207,8 +1208,6 @@ struct matrix : IArray<vector<T,C>> [ForceInline] int getCount() { return R; } - - __subscript(int index) -> vector<T,C> { __intrinsic_op($(kIROp_GetElement)) get; } } __intrinsic_op($(kIROp_Eql)) |
