[PATCH] D127802: [HLSL] Support HLSL vector initializers
Chris Bieneman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 15 08:20:41 PDT 2022
beanz added inline comments.
================
Comment at: clang/test/SemaHLSL/BuiltIns/vector-constructors-erros.hlsl:8
+void entry() {
+ float2 LilVec = float2(1.0, 2.0);
+ float2 BrokenVec = float2(1.0, 2.0, 3.0); // expected-error{{excess elements in vector initializer}}
----------------
aaron.ballman wrote:
> beanz wrote:
> > python3kgae wrote:
> > > Could we have test case for array/struct when initialize vector?
> > > Like
> > > float a[2] = {1.2, 3.2};
> > > float4 arrayVec = float4(a, 1.0, 2.0);
> > This change does not support all of HLSL's odd initialization features. It only supports initializing vectors from scalars and vectors.
> I'm surprised to see `float(1.0, 2.0)` work -- that's not list initialization, it's using round parens instead of curly braces so I'm pretty sure that's a function-style cast/constructor. Is that intentional?
Yea, it's a bit gross. HLSL supports function cast for vector construction, by converting the parameters inside to an initialization list.
HLSL also has some super odd initialization list behaviors that I'm trying to figure out a reasonable way to handle (while also hoping to remove them from the language).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127802/new/
https://reviews.llvm.org/D127802
More information about the cfe-commits
mailing list