diff options
Diffstat (limited to 'source/slang/core.meta.slang.h')
| -rw-r--r-- | source/slang/core.meta.slang.h | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/source/slang/core.meta.slang.h b/source/slang/core.meta.slang.h index 864196944..900d05b61 100644 --- a/source/slang/core.meta.slang.h +++ b/source/slang/core.meta.slang.h @@ -110,6 +110,9 @@ sb << " __implicit_conversion(" << kConversionCost_ScalarToVector << ")\n"; sb << " __intrinsic_op(" << kIROp_constructVectorFromScalar << ")\n"; sb << " __init(T value);\n"; +// Allow initialization from same type +sb << " __init(vector<T,N> value);\n"; + sb << "};\n"; // TODO: Probably need to do similar @@ -193,13 +196,6 @@ for (int N = 2; N <= 4; ++N) sb << ");\n"; } - // initialize from another vector of the same size - // - // TODO(tfoley): this overlaps with implicit conversions. - // We should look for a way that we can define implicit - // conversions directly in the stdlib instead... - sb << "__generic<U> __init(vector<U," << N << ">);\n"; - // Initialize from two vectors, of size M and N-M for(int M = 2; M <= (N-2); ++M) { @@ -233,16 +229,20 @@ for (int tt = 0; tt < kBaseTypeCount; ++tt) { if(kBaseTypes[ff].tag == BaseType::Void) continue; - // We need a constructor to make a vector from a scalar - // of another type. if( tt != ff ) { auto cost = getBaseTypeConversionCost( kBaseTypes[tt], kBaseTypes[ff]); - cost += kConversionCost_ScalarToVector; + // Implicit conversion from a vector of the same + // size, but different element type. + sb << " __implicit_conversion(" << cost << ")\n"; + sb << " __init(vector<" << kBaseTypes[ff].name << ",N> value);\n"; + + // Constructor to make a vector from a scalar of another type. + cost += kConversionCost_ScalarToVector; sb << " __implicit_conversion(" << cost << ")\n"; sb << " __init(" << kBaseTypes[ff].name << " value);\n"; } @@ -560,8 +560,16 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) if(baseShape != TextureType::ShapeCube) { + // TODO: In the case where `access` includes writeability, + // this should have both `get` and `set` accessors. + // subscript operator - sb << "__intrinsic_op __subscript(uint" << kBaseTextureTypes[tt].coordCount + isArray << " location) -> T;\n"; + sb << "__intrinsic_op __subscript(uint"; + if(kBaseTextureTypes[tt].coordCount + isArray > 1) + { + sb << kBaseTextureTypes[tt].coordCount + isArray; + } + sb << " location) -> T;\n"; } if( !isMultisample ) |
