diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-06-20 14:38:50 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-06-20 14:38:50 -0700 |
| commit | 5148c594c19da9466b151ab3b6b11441f265823e (patch) | |
| tree | b575f4e7e08975d5eba6bdad74641d5197988f2a /source | |
| parent | 5170a56727c15da1443e8f9b0f21395861da9b0c (diff) | |
HLSL/Slang standard library additions
- Vector constructors that take two vectors that add up to the target size (`float4(float2, float2)`)
- I now realize I implemented the general case here, but there really is only the one case...
- Geometry shader output stream types now have `Append()` and `RestartStrip()` methods
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-stdlib.cpp | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/source/slang/slang-stdlib.cpp b/source/slang/slang-stdlib.cpp index 19827285c..387b6fbb2 100644 --- a/source/slang/slang-stdlib.cpp +++ b/source/slang/slang-stdlib.cpp @@ -230,9 +230,23 @@ __generic<T> __magic_type(HLSLRWStructuredBufferType) struct RWStructuredBuffer __intrinsic __subscript(uint index) -> T { get; set; } }; -__generic<T> __magic_type(HLSLPointStreamType) struct PointStream {}; -__generic<T> __magic_type(HLSLLineStreamType) struct LineStream {}; -__generic<T> __magic_type(HLSLLineStreamType) struct TriangleStream {}; +__generic<T> __magic_type(HLSLPointStreamType) struct PointStream +{ + void Append(T value); + void RestartStrip(); +}; + +__generic<T> __magic_type(HLSLLineStreamType) struct LineStream +{ + void Append(T value); + void RestartStrip(); +}; + +__generic<T> __magic_type(HLSLLineStreamType) struct TriangleStream +{ + void Append(T value); + void RestartStrip(); +}; )=", R"=( @@ -1203,6 +1217,21 @@ namespace Slang // 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) + { + int K = N - M; + assert(K >= 2); + + sb << "__init(vector<T," << M << "> " << kVectorNames[M]; + sb << ", vector<T," << K << "> "; + for (int ii = 0; ii < K; ++ii) + { + sb << kComponentNames[ii]; + } + sb << ");\n"; + } + sb << "}\n"; } |
