diff options
| author | kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> | 2025-02-05 12:37:03 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-05 10:37:03 -0800 |
| commit | 9ec6b91686b651d959fd9ffbec283845bd725dd6 (patch) | |
| tree | 2c48202cb04b76e5ddcb274be35529378ddf8f31 /tests | |
| parent | 4b350645042b8e8fbdad19784ee745d11c7bc616 (diff) | |
Feature/initialize list side branch (#6058)
* SP004: implement initialize list translation to ctor
- We synthesize a member-wise constructor for each struct follow
the rules described in SP004.
- Add logic to translate the initialize list to constructor invoke
- Add cuda-host decoration for the synthesized constructor
- Remove the default constructor when we have a valid member init constructor
- Disable -zero-initialize option, will re-implement it in followup (#6109).
- Fix the overload lookup issue
When creating invoke expression for ctor, we need to call
ResolveInvoke() to find us the best candidates, however
the existing lookup logic could find us the base constructor
for child struct, we should eliminate this case by providing
the LookupOptions::IgnoreInheritance to lookup, this requires
us to create a subcontext on SemanticsVisitor to indicate that
we only want to use this option on looking the constructor.
- Do not implicit initialize a struct that doesn't have explicit default
constructor.
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'tests')
68 files changed, 824 insertions, 146 deletions
diff --git a/tests/autodiff/differential-type-constructor.slang b/tests/autodiff/differential-type-constructor.slang index 9afff878d..96cf1272e 100644 --- a/tests/autodiff/differential-type-constructor.slang +++ b/tests/autodiff/differential-type-constructor.slang @@ -14,12 +14,12 @@ RWStructuredBuffer<float> outputBuffer; void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) { { - var dp = diffPair(MyStruct(), MyStruct.Differential()); + var dp = diffPair(MyStruct(0.0, 0), MyStruct.Differential(0.0)); outputBuffer[0] = dp.d.a; - var dp2 = diffPair<MyStruct>(MyStruct(), MyStruct.Differential(1.f)); + var dp2 = diffPair<MyStruct>(MyStruct(0.0, 0), MyStruct.Differential(1.f)); outputBuffer[1] = dp2.d.a; } -}
\ No newline at end of file +} diff --git a/tests/autodiff/generic-constructor.slang b/tests/autodiff/generic-constructor.slang index aad9824ec..a5b098ac2 100644 --- a/tests/autodiff/generic-constructor.slang +++ b/tests/autodiff/generic-constructor.slang @@ -19,6 +19,16 @@ struct Impl : IFoo { x = v.x; } + + // We have to add this __init so that the following code can still work: + // Impl.Differential v0 = { (float)x }; + // because when there is a explicit constructor defined, we will not fall back + // to legacy constructor. So this construction will fail. + [Differentiable] + __init(float v) + { + x = v; + } } [Differentiable] diff --git a/tests/autodiff/generic-impl-jvp.slang b/tests/autodiff/generic-impl-jvp.slang index e5999b4ae..000c14248 100644 --- a/tests/autodiff/generic-impl-jvp.slang +++ b/tests/autodiff/generic-impl-jvp.slang @@ -161,6 +161,16 @@ struct lineardvector : IDifferentiable val.values[i] = a[i]; } } + + // Add a new constructor for dadd() function. + __init(Real a[N]) + { + [ForceUnroll] + for (int i = 0; i < N; i++) + { + val.values[i] = a[i]; + } + } }; __generic<let N : int> @@ -204,12 +214,24 @@ struct linearvector : MyLinearArithmeticType, IDifferentiable static Differential dadd(Differential a, Differential b) { - return { myvector<Real, N>.dadd(a.val, b.val) }; + // return { myvector<Real, N>.dadd(a.val, b.val) }; + // + // Above code will not work because + // myvector<Real, N>.dadd will return dvector<T.Differential, N> type + // while Differential == lineardvector<N> type + // and the constructor of lineardvector<N> requires a vector<Real.Differential, N> type + // and dvector<T.Differential, N> != vector<Real.Differential, N>, though they have the + // same members. + // + // In our new design, generic will not be C-Style struct anymore. + dvector<Real.Differential, N> d = myvector<Real, N>.dadd(a.val, b.val); + return {d.values}; } static Differential dmul<T: __BuiltinRealType>(T a, Differential b) { - return { myvector<Real, N>.dmul<T>(a, b.val) }; + dvector<Real.Differential, N> d = myvector<Real, N>.dmul<T>(a, b.val); + return {d.values}; } [ForwardDifferentiable] diff --git a/tests/autodiff/self-differential-generic-type-synthesis.slang b/tests/autodiff/self-differential-generic-type-synthesis.slang index 8d225dec2..7883188f6 100644 --- a/tests/autodiff/self-differential-generic-type-synthesis.slang +++ b/tests/autodiff/self-differential-generic-type-synthesis.slang @@ -17,7 +17,7 @@ struct Ray<let N: int> : IDifferentiable { [numthreads(1, 1, 1)] void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) { - Ray<4> ray = Ray<4>(); + Ray<4> ray = Ray<4>(0.0, float4(0.0), float4(0.0));; Ray<4>.Differential ray2; ray.a = 1.f; diff --git a/tests/autodiff/self-differential-type-synthesis.slang b/tests/autodiff/self-differential-type-synthesis.slang index 7f95891c6..6faa2175a 100644 --- a/tests/autodiff/self-differential-type-synthesis.slang +++ b/tests/autodiff/self-differential-type-synthesis.slang @@ -17,7 +17,7 @@ struct Ray : IDifferentiable { [numthreads(1, 1, 1)] void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) { - Ray ray = Ray(); + Ray ray = {}; Ray.Differential ray2; ray.a = 1.f; diff --git a/tests/bugs/addr-scope-fix.slang b/tests/bugs/addr-scope-fix.slang index 8a58b7daf..3b0059417 100644 --- a/tests/bugs/addr-scope-fix.slang +++ b/tests/bugs/addr-scope-fix.slang @@ -1,4 +1,5 @@ //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type +//TEST(compute):COMPARE_COMPUTE_EX:-vk -slang -compute -shaderobj -output-using-type //TEST_INPUT:ubuffer(data=[0 0 0], stride=4):out,name=outputBuffer RWStructuredBuffer<float> outputBuffer; @@ -73,4 +74,4 @@ void func(int x) void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) { func(4); -}
\ No newline at end of file +} diff --git a/tests/bugs/generic-default-value.slang b/tests/bugs/generic-default-value.slang index 32dc07cdc..2a223e8c2 100644 --- a/tests/bugs/generic-default-value.slang +++ b/tests/bugs/generic-default-value.slang @@ -1,4 +1,5 @@ //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj +//TEST(compute):COMPARE_COMPUTE_EX:-vk -slang -compute -shaderobj //TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer RWStructuredBuffer<int> outputBuffer; @@ -8,6 +9,10 @@ works with a generic */ struct Check<T> { + // T is not default initialize type, because it's a generic type parameter. + // Therefore, when we synthesize the contructor, we won't create a default value + // for it. + // __init(T v); T v; }; @@ -16,7 +21,7 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) { int index = int(dispatchThreadID.x); - Check<float> v = {}; + Check<float> v = {0}; outputBuffer[index] = index + int(v.v); } diff --git a/tests/bugs/gh-4863.slang b/tests/bugs/gh-4863.slang index e1f4e1d2d..b1de7134f 100644 --- a/tests/bugs/gh-4863.slang +++ b/tests/bugs/gh-4863.slang @@ -29,8 +29,8 @@ void doThing(inout Foo foo, uint2 ipos) [numthreads(1, 1, 1)] void computeMain(uint2 ipos : SV_DispatchThreadID) { - Foo foo; + Foo foo = {}; doThing(foo, ipos); // BUFFER: 3 outputBuffer[0] = (int)foo.bar1; -}
\ No newline at end of file +} diff --git a/tests/bugs/overload-ambiguous-2.slang b/tests/bugs/overload-ambiguous-2.slang index 46af9f091..785db7b31 100644 --- a/tests/bugs/overload-ambiguous-2.slang +++ b/tests/bugs/overload-ambiguous-2.slang @@ -57,7 +57,7 @@ void computeMain(uint3 threadID: SV_DispatchThreadID) { using namespace A; - Struct2<10> input = {threadID.x}; + Struct2<10> input = {{threadID.x}}; Struct2<20> output; output = myFunc<10, 20>(input); diff --git a/tests/compute/empty-struct2.slang b/tests/compute/empty-struct2.slang index 303cfd234..4476bcaa1 100644 --- a/tests/compute/empty-struct2.slang +++ b/tests/compute/empty-struct2.slang @@ -48,7 +48,7 @@ void test<Obj : IInterface>(Obj obj) [numthreads(4, 1, 1)] void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) { - Empty<EmptyS> obj; + Empty<EmptyS> obj = {}; test(obj); outputBuffer[dispatchThreadID.x] = dispatchThreadID.x; } diff --git a/tests/compute/struct-default-init.slang b/tests/compute/struct-default-init.slang index 236fff57f..ce8979164 100644 --- a/tests/compute/struct-default-init.slang +++ b/tests/compute/struct-default-init.slang @@ -1,5 +1,6 @@ // struct-default-init.slang //TEST(compute):COMPARE_COMPUTE: -shaderobj +//TEST(compute):COMPARE_COMPUTE: -vk -shaderobj struct Test { diff --git a/tests/compute/type-legalize-global-with-init.slang b/tests/compute/type-legalize-global-with-init.slang index 573ac9849..7316cad1d 100644 --- a/tests/compute/type-legalize-global-with-init.slang +++ b/tests/compute/type-legalize-global-with-init.slang @@ -5,6 +5,7 @@ // resources. // //TEST(compute):COMPARE_COMPUTE: -shaderobj +//TEST(compute):COMPARE_COMPUTE: -vk -shaderobj // //TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer RWStructuredBuffer<uint> outputBuffer; diff --git a/tests/cpu-program/gfx-smoke.slang b/tests/cpu-program/gfx-smoke.slang index 41c87ca19..3ed04877e 100644 --- a/tests/cpu-program/gfx-smoke.slang +++ b/tests/cpu-program/gfx-smoke.slang @@ -14,7 +14,7 @@ export __extern_cpp int main() return -1; } - gfx.CommandQueueDesc queueDesc = {}; + gfx.CommandQueueDesc queueDesc = {gfx::QueueType::Graphics}; queueDesc.type = gfx.QueueType.Graphics; Optional<gfx.ICommandQueue> queue; device.value.createCommandQueue(&queueDesc, queue); @@ -42,12 +42,12 @@ export __extern_cpp int main() device.value.createProgram2(&programDesc, program, diagBlob); Optional<gfx.IPipelineState> pipeline; - gfx.ComputePipelineStateDesc pipelineDesc = {}; + gfx.ComputePipelineStateDesc pipelineDesc; pipelineDesc.program = NativeRef<gfx.IShaderProgram>(program.value); device.value.createComputePipelineState(&pipelineDesc, pipeline); Optional<gfx.ITransientResourceHeap> transientHeap; - gfx.TransientResourceHeapDesc transientHeapDesc = {}; + gfx.TransientResourceHeapDesc transientHeapDesc; transientHeapDesc.constantBufferDescriptorCount = 64; transientHeapDesc.constantBufferSize = 1024; transientHeapDesc.srvDescriptorCount = 1024; @@ -67,7 +67,7 @@ export __extern_cpp int main() device.value.createBufferResource(&bufferDesc, nullptr, buffer); Optional<gfx.IResourceView> bufferView; - gfx.ResourceViewDesc viewDesc = {}; + gfx.ResourceViewDesc viewDesc; viewDesc.type = gfx.ResourceViewType.UnorderedAccess; device.value.createBufferView(buffer.value, none, &viewDesc, bufferView); diff --git a/tests/diagnostics/interfaces/anyvalue-size-validation.slang b/tests/diagnostics/interfaces/anyvalue-size-validation.slang index f2ed52d0c..ffe968c67 100644 --- a/tests/diagnostics/interfaces/anyvalue-size-validation.slang +++ b/tests/diagnostics/interfaces/anyvalue-size-validation.slang @@ -26,6 +26,6 @@ RWStructuredBuffer<uint> output; [numthreads(4, 1, 1)] void main() { - S s = S(); + S s = S(1, 2, 3); output[0] = test(s).a; } diff --git a/tests/diagnostics/mismatching-types.slang b/tests/diagnostics/mismatching-types.slang index 15fc1d0e3..ead1d34ff 100644 --- a/tests/diagnostics/mismatching-types.slang +++ b/tests/diagnostics/mismatching-types.slang @@ -49,19 +49,26 @@ void main(uint3 dispatchThreadID : SV_DispatchThreadID) // expected an expression of type 'GenericOuter<int>', got 'int' a = 0; + // expected an expression of type 'GenericOuter<int>.GenericInner<int>', got 'int' + // explicit conversion from 'int' to 'GenericOuter<int>.GenericInner<int>' is possible a.g = 0; + // expected an expression of type 'GenericOuter<int>.NonGenericInner', got 'int' + // explicit conversion from 'int' to 'GenericOuter<int>.GenericInner<int>' is possible a.ng = 0; // expected an expression of type 'GenericOuter<int>.GenericInner<int>', got 'GenericOuter<float>.GenericInner<float>' a.g = b.g; // expected an expression of type 'GenericOuter<int>.NonGenericInner', got 'GenericOuter<float>.NonGenericInner' a.ng = b.ng; // expected an expression of type 'NonGenericOuter.GenericInner<int>', got 'int' + // explicit conversion from 'int' to 'GenericInner<int>' is possible c.i = 0; // expected an expression of type 'NonGenericOuter.GenericInner<int>', got 'NonGenericOuter.GenericInner<float>' c.i = c.f; + // expected an expression of type 'NonGenericOuter.GenericInner<int>.ReallyNested', got 'int' + // explicit conversion from 'int' to 'GenericInner<int>.ReallyNested' is possible c.i.n = 0; // OK c.i.n.val = 0; @@ -74,4 +81,4 @@ void main(uint3 dispatchThreadID : SV_DispatchThreadID) Texture1D<int> t1 = tex; // expected an expression of type 'Texture2D<float>', got 'Texture1D<float>' Texture2D<float> t2 = tex; -}
\ No newline at end of file +} diff --git a/tests/diagnostics/mismatching-types.slang.expected b/tests/diagnostics/mismatching-types.slang.expected index 65a6df32e..a706e30e6 100644 --- a/tests/diagnostics/mismatching-types.slang.expected +++ b/tests/diagnostics/mismatching-types.slang.expected @@ -3,31 +3,34 @@ standard error = { tests/diagnostics/mismatching-types.slang(51): error 30019: expected an expression of type 'GenericOuter<int>', got 'int' a = 0; ^ -tests/diagnostics/mismatching-types.slang(53): error 30019: expected an expression of type 'GenericOuter<int>.GenericInner<int>', got 'int' +tests/diagnostics/mismatching-types.slang(55): error 30019: expected an expression of type 'GenericOuter<int>.GenericInner<int>', got 'int' a.g = 0; ^ -tests/diagnostics/mismatching-types.slang(55): error 30019: expected an expression of type 'GenericOuter<int>.NonGenericInner', got 'int' +tests/diagnostics/mismatching-types.slang(55): note: explicit conversion from 'int' to 'GenericOuter<int>.GenericInner<int>' is possible +tests/diagnostics/mismatching-types.slang(59): error 30019: expected an expression of type 'GenericOuter<int>.NonGenericInner', got 'int' a.ng = 0; ^ -tests/diagnostics/mismatching-types.slang(57): error 30019: expected an expression of type 'GenericOuter<int>.GenericInner<int>', got 'GenericOuter<float>.GenericInner<float>' +tests/diagnostics/mismatching-types.slang(59): note: explicit conversion from 'int' to 'GenericOuter<int>.NonGenericInner' is possible +tests/diagnostics/mismatching-types.slang(61): error 30019: expected an expression of type 'GenericOuter<int>.GenericInner<int>', got 'GenericOuter<float>.GenericInner<float>' a.g = b.g; ^ -tests/diagnostics/mismatching-types.slang(59): error 30019: expected an expression of type 'GenericOuter<int>.NonGenericInner', got 'GenericOuter<float>.NonGenericInner' +tests/diagnostics/mismatching-types.slang(63): error 30019: expected an expression of type 'GenericOuter<int>.NonGenericInner', got 'GenericOuter<float>.NonGenericInner' a.ng = b.ng; ^~ -tests/diagnostics/mismatching-types.slang(61): error 30019: expected an expression of type 'NonGenericOuter.GenericInner<int>', got 'int' +tests/diagnostics/mismatching-types.slang(66): error 30019: expected an expression of type 'NonGenericOuter.GenericInner<int>', got 'int' c.i = 0; ^ -tests/diagnostics/mismatching-types.slang(63): error 30019: expected an expression of type 'NonGenericOuter.GenericInner<int>', got 'NonGenericOuter.GenericInner<float>' +tests/diagnostics/mismatching-types.slang(68): error 30019: expected an expression of type 'NonGenericOuter.GenericInner<int>', got 'NonGenericOuter.GenericInner<float>' c.i = c.f; ^ -tests/diagnostics/mismatching-types.slang(65): error 30019: expected an expression of type 'NonGenericOuter.GenericInner<int>.ReallyNested', got 'int' +tests/diagnostics/mismatching-types.slang(72): error 30019: expected an expression of type 'NonGenericOuter.GenericInner<int>.ReallyNested', got 'int' c.i.n = 0; ^ -tests/diagnostics/mismatching-types.slang(74): error 30019: expected an expression of type 'Texture1D<int>', got 'Texture1D<float>' +tests/diagnostics/mismatching-types.slang(72): note: explicit conversion from 'int' to 'NonGenericOuter.GenericInner<int>.ReallyNested' is possible +tests/diagnostics/mismatching-types.slang(81): error 30019: expected an expression of type 'Texture1D<int>', got 'Texture1D<float>' Texture1D<int> t1 = tex; ^~~ -tests/diagnostics/mismatching-types.slang(76): error 30019: expected an expression of type 'Texture2D<float>', got 'Texture1D<float>' +tests/diagnostics/mismatching-types.slang(83): error 30019: expected an expression of type 'Texture2D<float>', got 'Texture1D<float>' Texture2D<float> t2 = tex; ^~~ } diff --git a/tests/diagnostics/uninitialized-fields.slang b/tests/diagnostics/uninitialized-fields.slang index f3c7b1a36..efa62cc36 100644 --- a/tests/diagnostics/uninitialized-fields.slang +++ b/tests/diagnostics/uninitialized-fields.slang @@ -56,16 +56,16 @@ struct Partial // Warnings here should be a bit different struct Implicit { - //CHK-DAG: warning 41021: default initializer for 'Implicit' will not initialize field 'a' int a; int b = 1; - //CHK-DAG: warning 41021: default initializer for 'Implicit' will not initialize field 'c' int c; int d = 1 + 1; } int using_implicit(int x) { + // no default constructor will be called, because there is no __init() synthesized for `Implicit` + // so no warnings will be reported on members of `Implicit` Implicit impl; impl.a = x; return impl.c; diff --git a/tests/diagnostics/variable-redeclaration.slang b/tests/diagnostics/variable-redeclaration.slang index bbd6a07c0..d238442e8 100644 --- a/tests/diagnostics/variable-redeclaration.slang +++ b/tests/diagnostics/variable-redeclaration.slang @@ -37,7 +37,7 @@ int testLocalShadowing(int x) } // Structure fields - +// Note: more diagnostics will be reported here because of the constructor synthesis struct S { int f; diff --git a/tests/diagnostics/variable-redeclaration.slang.expected b/tests/diagnostics/variable-redeclaration.slang.expected index 1998c13c8..842038180 100644 --- a/tests/diagnostics/variable-redeclaration.slang.expected +++ b/tests/diagnostics/variable-redeclaration.slang.expected @@ -30,6 +30,30 @@ tests/diagnostics/variable-redeclaration.slang(21): error 30200: declaration of tests/diagnostics/variable-redeclaration.slang(20): note: see previous declaration of 'y' int y = x; ^ +tests/diagnostics/variable-redeclaration.slang(41): error 30200: declaration of 'f' conflicts with existing declaration +struct S + ^ +tests/diagnostics/variable-redeclaration.slang(41): note: see previous declaration of 'f' +struct S + ^ +tests/diagnostics/variable-redeclaration.slang(43): error 39999: ambiguous reference to 'f' + int f; + ^ +tests/diagnostics/variable-redeclaration.slang(44): note 39999: candidate: float S.f + float f; + ^ +tests/diagnostics/variable-redeclaration.slang(43): note 39999: candidate: int S.f + int f; + ^ +tests/diagnostics/variable-redeclaration.slang(44): error 39999: ambiguous reference to 'f' + float f; + ^ +tests/diagnostics/variable-redeclaration.slang(44): note 39999: candidate: float S.f + float f; + ^ +tests/diagnostics/variable-redeclaration.slang(43): note 39999: candidate: int S.f + int f; + ^ tests/diagnostics/variable-redeclaration.slang(53): error 39999: ambiguous reference to 'size' return size; ^~~~ diff --git a/tests/initializer-list/c-style-type.slang b/tests/initializer-list/c-style-type.slang new file mode 100644 index 000000000..500bf37bb --- /dev/null +++ b/tests/initializer-list/c-style-type.slang @@ -0,0 +1,44 @@ +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-shaderobj -vk +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-shaderobj + +struct CLike +{ + int x; + int y; + // compiler synthesizes: + // __init(int x, int y); +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; +void test() +{ + // case 1: initialized with synthesized ctor call using legacy logic to form arguments, + // and `c1` is now `{0,0}`. + CLike c1 = {}; + + // case 2: initialized with legacy initializaer list logic, `c1` is now `{1,0}`: + CLike c2 = {1}; + + // case 3: initilaized with ctor call `CLike(1,2)`, `c3` is now `{1,2}`: + CLike c3 = {1, 2}; + + // BUFFER: 0 + outputBuffer[0] = c1.x; + // BUFFER-NEXT: 0 + outputBuffer[1] = c1.y; + // BUFFER-NEXT: 1 + outputBuffer[2] = c2.x; + // BUFFER-NEXT: 0 + outputBuffer[3] = c2.y; + // BUFFER-NEXT: 1 + outputBuffer[4] = c3.x; + // BUFFER-NEXT: 2 + outputBuffer[5] = c3.y; +} + +[shader("compute")] +void computeMain() +{ + test(); +} diff --git a/tests/initializer-list/default-member.slang b/tests/initializer-list/default-member.slang new file mode 100644 index 000000000..8a6a0dc7f --- /dev/null +++ b/tests/initializer-list/default-member.slang @@ -0,0 +1,35 @@ +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-shaderobj -vk +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-shaderobj + +struct DefaultMember { + int x = 0; + int y = 1; + // compiler synthesizes: + // __init(int x = 0, int y = 1); +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; +void test() +{ + DefaultMember m1 = {1}; // calls `__init(1)`, initialized to `{1,1}`. + + // BUFFER: 1 + outputBuffer[0] = m1.x; + + // BUFFER-NEXT: 1 + outputBuffer[1] = m1.y; + + DefaultMember m2 = {1,2}; // calls `__init(1,2)`, initialized to `{1,2}`. + + // BUFFER-NEXT: 1 + outputBuffer[2] = m2.x; + // BUFFER-NEXT: 2 + outputBuffer[3] = m2.y; +} + +[shader("compute")] +void computeMain() +{ + test(); +} diff --git a/tests/initializer-list/explicit-ctor-diagnostic.slang b/tests/initializer-list/explicit-ctor-diagnostic.slang new file mode 100644 index 000000000..a9d0e9858 --- /dev/null +++ b/tests/initializer-list/explicit-ctor-diagnostic.slang @@ -0,0 +1,19 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): + +struct ExplicitCtor +{ + int x; + int y; + __init(int x) + { + this.x = x; + this.y = 0; + } + // compiler does not synthesize any ctors. +} + +void test() +{ + // CHECK: error 39999: too many arguments to call (got 2, expected 1) + ExplicitCtor e = {1, 2}; // error, no ctor matches initializer list. +} diff --git a/tests/initializer-list/explicit-ctor.slang b/tests/initializer-list/explicit-ctor.slang new file mode 100644 index 000000000..c587bcce4 --- /dev/null +++ b/tests/initializer-list/explicit-ctor.slang @@ -0,0 +1,41 @@ +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-shaderobj -vk +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-shaderobj + +struct ExplicitCtor +{ + int x; + int y; + __init(int x) + { + this.x = x; + this.y = x + 5; + } +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; +void test() +{ + // case 1: initialized with synthesized ctor call using legacy logic to form arguments, + // and `c1` is now `{0,0}`. + ExplicitCtor c1 = {4}; + + // BUFFER: 4 + outputBuffer[0] = c1.x; + // BUFFER-NEXT: 9 + outputBuffer[1] = c1.y; + + + ExplicitCtor c2 = ExplicitCtor(10); + + // BUFFER: A + outputBuffer[2] = c2.x; + // BUFFER-NEXT: F + outputBuffer[3] = c2.y; +} + +[shader("compute")] +void computeMain() +{ + test(); +} diff --git a/tests/initializer-list/extension-overload-1.slang b/tests/initializer-list/extension-overload-1.slang new file mode 100644 index 000000000..1c3189f84 --- /dev/null +++ b/tests/initializer-list/extension-overload-1.slang @@ -0,0 +1,49 @@ + +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-shaderobj -vk +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-shaderobj + +import modulea; + +// Definition of the Foo struct +// struct Foo +// { +// int a; +// int b; +// } + +// This test demonstrates that whether struct is a C-Style type only depends on the definition of the struct, not the extension. +// Even we have an explicit constructor defined in extension of Foo, it is still a C-Style type. + +extension Foo +{ + __init(int a) + { + this.a = a + 5; + this.b = 3; + } +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; + +[shader("compute")] +[numthreads(1, 1, 1)] +void computeMain() +{ + + // This will miss both synthesized constructor and explicit constructor in extension, but it will still fall back + // to legacy initializer list because Foo is a C-Style type. + Foo foo = {}; + //CHECK: BUFFER: 0 + //CHECK: BUFFER-NEXT: 0 + outputBuffer[0] = foo.a; + outputBuffer[1] = foo.b; + + + // When providing 1 parameter, it will lookup for the explicit constructor in extension. + Foo foo1 = {1}; + //CHECK: BUFFER: 6 + //CHECK: BUFFER-NEXT: 3 + outputBuffer[2] = foo1.a; + outputBuffer[3] = foo1.b; +} diff --git a/tests/initializer-list/extension-overload-2.slang b/tests/initializer-list/extension-overload-2.slang new file mode 100644 index 000000000..3937127f4 --- /dev/null +++ b/tests/initializer-list/extension-overload-2.slang @@ -0,0 +1,28 @@ +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-shaderobj -vk +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-shaderobj + +struct Foo +{ + int a; +} + +extension Foo +{ + __init(int a) + { + this.a = a + 5; + } +} + +//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; + +[shader("compute")] +[numthreads(1, 1, 1)] +void computeMain() +{ + // it will prefer the explicit constructor defined in the extension instead of the synthesized one in the struct + Foo foo = {1.0f}; + //CHECK: BUFFER: 6 + outputBuffer[0] = foo.a; +} diff --git a/tests/initializer-list/modulea.slang b/tests/initializer-list/modulea.slang new file mode 100644 index 000000000..48a4a5d6a --- /dev/null +++ b/tests/initializer-list/modulea.slang @@ -0,0 +1,5 @@ +export struct Foo +{ + int a; + int b; +} diff --git a/tests/initializer-list/partial-init-diagnostic.slang b/tests/initializer-list/partial-init-diagnostic.slang new file mode 100644 index 000000000..ea3acb2c7 --- /dev/null +++ b/tests/initializer-list/partial-init-diagnostic.slang @@ -0,0 +1,19 @@ +//DISABLE_DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): + +struct PartialInit +{ + int x = 1; + int y; + // compiler synthesizes: + // __init(int x, int y); +} + +void test() +{ + // TODO: Because we have a legacy logic that will always convert the one arugment ctor call to + // initializer list, and that initializer list will fall back to the legacy C-Style initialization. + // We need to remove that logic. + + // CHECK: error 33070: expected a function, got 'typeof(PartialInit)' + PartialInit p = PartialInit(2); // error, no ctor match. +} diff --git a/tests/initializer-list/partial-init.slang b/tests/initializer-list/partial-init.slang new file mode 100644 index 000000000..55f3816fb --- /dev/null +++ b/tests/initializer-list/partial-init.slang @@ -0,0 +1,47 @@ +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-shaderobj -vk +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-shaderobj + +struct PartialInit { + // warning: not all members are initialized. + // members should either be all-uninitialized or all-initialized with + // default expr. + int x; + int y = 1; + // compiler synthesizes: + // __init(int x, int y = 1); +} + +struct PartialInit2 { + int x = 1; + int y; + // __init(int x, int y); +} +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; +void test() +{ + PartialInit p1 = {2}; // calls `__init`, result is `{2,1}`. + // BUFFER: 2 + outputBuffer[0] = p1.x; + // BUFFER-NEXT: 1 + outputBuffer[1] = p1.y; + + + PartialInit p2 = {2, 3}; // calls `__init`, result is {2, 3} + // BUFFER-NEXT: 2 + outputBuffer[2] = p2.x; + // BUFFER-NEXT: 3 + outputBuffer[3] = p2.y; + + PartialInit2 p3 = {4, 5}; // calls `__init`, result is {4, 5} + // BUFFER-NEXT: 4 + outputBuffer[4] = p3.x; + // BUFFER-NEXT: 5 + outputBuffer[5] = p3.y; +} + +[shader("compute")] +void computeMain() +{ + test(); +} diff --git a/tests/initializer-list/struct-visibility-1.slang b/tests/initializer-list/struct-visibility-1.slang new file mode 100644 index 000000000..691e8c991 --- /dev/null +++ b/tests/initializer-list/struct-visibility-1.slang @@ -0,0 +1,105 @@ + +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-shaderobj -vk +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-shaderobj + +public struct Visibility +{ + internal int x = 1; + public int y = 5; + + int getX() { return x; } +} + + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; +void test(inout uint index) +{ + Visibility t1 = {}; // OK, initialized to {1,5} via ctor call. + // BUFFER: 1 + outputBuffer[index++] = t1.getX(); + // BUFFER-NEXT: 5 + outputBuffer[index++] = t1.y; + + Visibility t2 = {1}; // OK, initialized to {1,1} via ctor call. + // BUFFER-NEXT: 1 + outputBuffer[index++] = t2.getX(); + // BUFFER-NEXT: 1 + outputBuffer[index++] = t2.y; +} + +internal struct Visibility2 +{ + // Visibility3 type is considered as C-style struct. + // Because all members have the same visibility as the type. + // Therefore we will attempt the legacy fallback logic for + // initializer-list syntax. + // Note that c-style structs can still have init exprs on members. + internal int x; + internal int y = 2; + // compiler synthesizes: + // internal __init(int x, int y = 2); +} + +internal void test2(inout uint index) +{ + Visibility2 t = {3, 4}; // OK, initialized to {3,4} via ctor call. + // BUFFER-NEXT: 3 + outputBuffer[index++] = t.x; + // BUFFER-NEXT: 4 + outputBuffer[index++] = t.y; + + Visibility2 t1 = {1}; // OK, initialized to {1,2} via ctor call. + // BUFFER-NEXT: 1 + outputBuffer[index++] = t1.x; + // BUFFER-NEXT: 2 + outputBuffer[index++] = t1.y; + + Visibility2 t2 = {}; // OK, initialized to {0, 2} via legacy logic. + // BUFFER-NEXT: 0 + outputBuffer[index++] = t2.x; + // BUFFER-NEXT: 2 + outputBuffer[index++] = t2.y; +} + +internal struct Visibility3 +{ + // Visibility4 type is considered as C-style struct. + // And we still synthesize a ctor for member initialization. + // Because Visibility4 has no public members, the synthesized + // ctor will take 0 arguments. + internal int x = 1; + internal int y = 2; + // compiler synthesizes: + // internal __init(int x = 1, int y = 2); +} + +internal void test3(inout uint index) +{ + Visibility3 t = {0, 0}; // OK, initialized to {0,0} via ctor call. + // BUFFER-NEXT: 0 + outputBuffer[index++] = t.x; + // BUFFER-NEXT: 0 + outputBuffer[index++] = t.y; + + Visibility3 t1 = {3}; // OK, initialized to {3,2} via ctor call. + // BUFFER-NEXT: 3 + outputBuffer[index++] = t1.x; + // BUFFER-NEXT: 2 + outputBuffer[index++] = t1.y; + + Visibility3 t2 = {}; // OK, initialized to {1,2} via ctor call. + // BUFFER-NEXT: 1 + outputBuffer[index++] = t2.x; + // BUFFER-NEXT: 2 + outputBuffer[index++] = t2.y; +} + +[shader("compute")] +void computeMain() +{ + uint index = 0; + test(index); + test2(index); + test3(index); +} diff --git a/tests/initializer-list/struct-visibility-diagnostic-1.slang b/tests/initializer-list/struct-visibility-diagnostic-1.slang new file mode 100644 index 000000000..ab11933ae --- /dev/null +++ b/tests/initializer-list/struct-visibility-diagnostic-1.slang @@ -0,0 +1,21 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): + +public struct Visibility +{ + internal int x; + public int y = 0; + // the compiler does not synthesize any ctor. + // the compiler will try to synthesize: + // public __init(int y); + // but then it will find that `x` cannot be initialized. + // so this synthesis will fail and no ctor will be added + // to the type. +} + +void test() +{ + // CHECK: error 39999: too many arguments to call (got 2, expected 1) + Visibility t1 = {1, 2}; // error, no matching ctor +} + + diff --git a/tests/initializer-list/struct-visibility-diagnostic-2.slang b/tests/initializer-list/struct-visibility-diagnostic-2.slang new file mode 100644 index 000000000..a3255de5e --- /dev/null +++ b/tests/initializer-list/struct-visibility-diagnostic-2.slang @@ -0,0 +1,21 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): + +public struct Visibility +{ + internal int x; + public int y = 5; + // the compiler does not synthesize any ctor. + // the compiler will try to synthesize: + // public __init(int y); + // but then it will find that `x` cannot be initialized. + // so this synthesis will fail and no ctor will be added + // to the type. +} + +void test() +{ + // CHECK: warning 41021: default initializer for 'Visibility' will not initialize field 'x' + Visibility t1 = {}; +} + + diff --git a/tests/initializer-list/struct-visibility-diagnostic-3.slang b/tests/initializer-list/struct-visibility-diagnostic-3.slang new file mode 100644 index 000000000..75ac5919d --- /dev/null +++ b/tests/initializer-list/struct-visibility-diagnostic-3.slang @@ -0,0 +1,21 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): + +public struct Visibility +{ + internal int x; + public int y; + // the compiler does not synthesize any ctor. + // the compiler will try to synthesize: + // public __init(int y); + // but then it will find that `x` cannot be initialized. + // so this synthesis will fail and no ctor will be added + // to the type. +} + +void test() +{ + //CHECK: error 39999: not enough arguments to call (got 0, expected 1) + Visibility t1 = {}; +} + + diff --git a/tests/initializer-list/struct-visibility-diagnostic-4.slang b/tests/initializer-list/struct-visibility-diagnostic-4.slang new file mode 100644 index 000000000..9bc3a76f0 --- /dev/null +++ b/tests/initializer-list/struct-visibility-diagnostic-4.slang @@ -0,0 +1,16 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): + +public struct Visibility +{ + internal int x = 1; + public int y = 5; + // compiler synthesizes: + // public __init(int y = 0); +} + +void test() +{ + //CHECK: error 39999: too many arguments to call (got 2, expected 1) + Visibility t1 = {1, 2}; +} + diff --git a/tests/initializer-list/unintialize-warning.slang b/tests/initializer-list/unintialize-warning.slang new file mode 100644 index 000000000..b8f2867ee --- /dev/null +++ b/tests/initializer-list/unintialize-warning.slang @@ -0,0 +1,85 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): + +struct CLike +{ + int x; + int y; + // compiler synthesizes: + // __init(int x, int y); +} + +struct ExplicitCtor +{ + int x; + int y; + __init(int x) + { + this.x = x; + this.y = 0; + } + // compiler does not synthesize any ctors. +} + +struct DefaultMember { + int x = 0; + int y = 1; + // compiler synthesizes: + // __init(int x = 0, int y = 1); +} + +struct PartialInit1 { + int x; + int y = 1; + // compiler synthesizes: + // __init(int x, int y = 1); +} + +struct PartialInit2 { + int x = 1; + int y; // warning: not all members are initialized. + // compiler synthesizes: + // __init(int x, int y); +} + +void func1(CLike c) +{ +} + +void func2(ExplicitCtor e) +{ +} + +void func3(DefaultMember d) +{ +} + +void func4(PartialInit1 p) +{ +} + +void func5(PartialInit2 p) +{ +} + +void test() +{ + CLike c; // `c` is uninitialized. + // CHECK: warning 41016: use of uninitialized variable 'c' + func1(c); + + ExplicitCtor e; // `e` is uninitialized. + // CHECK: warning 41016: use of uninitialized variable 'e' + func2(e); + + DefaultMember d; // `d` is uninitialized. + // CHECK: warning 41016: use of uninitialized variable 'd' + func3(d); + + PartialInit1 p1; // `p` is uninitialized. + // CHECK: warning 41016: use of uninitialized variable 'p1' + func4(p1); + + PartialInit2 p2; // `p` is uninitialized. + // CHECK: warning 41016: use of uninitialized variable 'p2' + func5(p2); +} diff --git a/tests/language-feature/extensions/interface-extension.slang b/tests/language-feature/extensions/interface-extension.slang index 50bbbe22a..88ef908d8 100644 --- a/tests/language-feature/extensions/interface-extension.slang +++ b/tests/language-feature/extensions/interface-extension.slang @@ -3,6 +3,7 @@ // Test that an `extension` applied to an interface type works as users expect //TEST(compute):COMPARE_COMPUTE: -shaderobj +//TEST(compute):COMPARE_COMPUTE: -vk -shaderobj interface ICounter { diff --git a/tests/language-feature/extensions/this-in-extension.slang b/tests/language-feature/extensions/this-in-extension.slang index 374eabe6f..f9cc31fca 100644 --- a/tests/language-feature/extensions/this-in-extension.slang +++ b/tests/language-feature/extensions/this-in-extension.slang @@ -3,6 +3,7 @@ // Test that an `This` type works correctly when there is an extension. //TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj -vk interface IFoo { @@ -31,7 +32,7 @@ RWStructuredBuffer<int> outputBuffer; [numthreads(1, 1, 1)] void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) { - FooImpl foo; + FooImpl foo = {}; var ident = foo.getIdentity(); // CHECK: 1 outputBuffer[0] = ident.v; diff --git a/tests/language-feature/generics/struct-generic-value-param.slang b/tests/language-feature/generics/struct-generic-value-param.slang index 7b3b847d5..df79b834d 100644 --- a/tests/language-feature/generics/struct-generic-value-param.slang +++ b/tests/language-feature/generics/struct-generic-value-param.slang @@ -17,6 +17,7 @@ // when trying out the feature. //TEST(compute):COMPARE_COMPUTE: -shaderobj +//TEST(compute):COMPARE_COMPUTE: -vk -shaderobj import struct_generic_value_param_import; diff --git a/tests/language-feature/inheritance/derived-struct-init-list.slang b/tests/language-feature/inheritance/derived-struct-init-list.slang index 978fea904..51d3a9b6d 100644 --- a/tests/language-feature/inheritance/derived-struct-init-list.slang +++ b/tests/language-feature/inheritance/derived-struct-init-list.slang @@ -1,6 +1,7 @@ // derived-struct-init-list.slang //TEST(compute):COMPARE_COMPUTE: +//TEST(compute):COMPARE_COMPUTE: -vk -shaderobj // Test that use of an initializer list (especially // an empty initializer list) is still possible diff --git a/tests/language-feature/inheritance/struct-inherit-interface-requirement.slang b/tests/language-feature/inheritance/struct-inherit-interface-requirement.slang index fbf3405ff..84446aec3 100644 --- a/tests/language-feature/inheritance/struct-inherit-interface-requirement.slang +++ b/tests/language-feature/inheritance/struct-inherit-interface-requirement.slang @@ -1,6 +1,7 @@ // struct-inherit-interface-requirement.slang //TEST(compute):COMPARE_COMPUTE: -shaderobj +//TEST(compute):COMPARE_COMPUTE: -vk -shaderobj // Test that a `struct` type can use an inherited // member to satisfy an interface requirement. diff --git a/tests/language-feature/inheritance/struct-inheritance.slang b/tests/language-feature/inheritance/struct-inheritance.slang index e50b1268b..d1611ddfc 100644 --- a/tests/language-feature/inheritance/struct-inheritance.slang +++ b/tests/language-feature/inheritance/struct-inheritance.slang @@ -1,6 +1,7 @@ // struct-inheritance.slang //TEST(compute):COMPARE_COMPUTE: -shaderobj +//TEST(compute):COMPARE_COMPUTE: -vk -shaderobj // Test that we can define a `struct` type // that inherits from another `struct`. diff --git a/tests/language-feature/initializer-lists/inheritance-generic.slang b/tests/language-feature/initializer-lists/inheritance-generic.slang index c916178b8..d5b923afe 100644 --- a/tests/language-feature/initializer-lists/inheritance-generic.slang +++ b/tests/language-feature/initializer-lists/inheritance-generic.slang @@ -19,7 +19,10 @@ RWStructuredBuffer<int> result; [numthreads(1, 1, 1)] void computeMain() { - Derived<3> d; + // Previously, this test is just test we can handle the base constructor invoke correctly, + // so we don't construct the Derived object, since #6058, there will not be implicit constructor + // to construct the struct, we will have to invoke the constructor explicitly. + Derived<3> d = {1,1,1}; // BUFFER: 1 result[0] = d.a; diff --git a/tests/language-feature/interfaces/zero-init-interface.slang b/tests/language-feature/interfaces/zero-init-interface.slang index ee38f4d83..ed3b1eaa4 100644 --- a/tests/language-feature/interfaces/zero-init-interface.slang +++ b/tests/language-feature/interfaces/zero-init-interface.slang @@ -1,6 +1,7 @@ // Test that we can zero-init a struct with interface typed member. //TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER): -shaderobj +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER): -vk -shaderobj //TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer RWStructuredBuffer<int> outputBuffer; diff --git a/tests/language-feature/overloaded-subscript.slang b/tests/language-feature/overloaded-subscript.slang index f396f4f66..68ad1111a 100644 --- a/tests/language-feature/overloaded-subscript.slang +++ b/tests/language-feature/overloaded-subscript.slang @@ -38,7 +38,7 @@ RWStructuredBuffer<int> outputBuffer; [numthreads(1,1,1)] void computeMain() { - MyArray<int> arr = {}; + MyArray<int> arr = {{1, 2, 3, 4}}; arr[0] = 1; arr[1] = 2; // CHECK: 1 diff --git a/tests/language-feature/properties/property-in-interface.slang b/tests/language-feature/properties/property-in-interface.slang index 9f9e7ff50..2ef050624 100644 --- a/tests/language-feature/properties/property-in-interface.slang +++ b/tests/language-feature/properties/property-in-interface.slang @@ -1,6 +1,6 @@ // property-in-interface.slang -//TEST(compute):COMPARE_COMPUTE: -shaderobj +//TEST(compute):COMPARE_COMPUTE: -shaderobj -vk // Test that interfaces can include property declarations. diff --git a/tests/language-feature/struct-field-initializers/struct-field-initializer-import.slang b/tests/language-feature/struct-field-initializers/struct-field-initializer-import.slang index 6c8b6fee1..1478fae0b 100644 --- a/tests/language-feature/struct-field-initializers/struct-field-initializer-import.slang +++ b/tests/language-feature/struct-field-initializers/struct-field-initializer-import.slang @@ -15,12 +15,12 @@ void modifyOut(out DefaultStructNoInit2 noInit2) [numthreads(1, 1, 1)] void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) { - DefaultStructNoInit noInit; - DefaultStructNoInit2 noInit2; + DefaultStructNoInit noInit = {}; + DefaultStructNoInit2 noInit2 = {}; modifyOut(noInit2); // BUF: 1 outputBuffer[0] = true && noInit.data0 == 2 && noInit2.data0 == 2 ; -}
\ No newline at end of file +} diff --git a/tests/language-feature/struct-field-initializers/struct-field-initializer-inherited-chain.slang b/tests/language-feature/struct-field-initializers/struct-field-initializer-inherited-chain.slang index ef21a452f..e6f856a21 100644 --- a/tests/language-feature/struct-field-initializers/struct-field-initializer-inherited-chain.slang +++ b/tests/language-feature/struct-field-initializers/struct-field-initializer-inherited-chain.slang @@ -29,10 +29,10 @@ struct DefaultStruct_top : DefaultStruct_middle2 [numthreads(1, 1, 1)] void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) { - DefaultStruct_bottom s1; - DefaultStruct_middle1 s2; - DefaultStruct_middle2 s3; - DefaultStruct_top s4; + DefaultStruct_bottom s1 = {}; + DefaultStruct_middle1 s2 = {}; + DefaultStruct_middle2 s3 = {}; + DefaultStruct_top s4 = {}; // BUF: 1 outputBuffer[0] = true @@ -50,4 +50,4 @@ void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) && s4.data2 == 1 && s4.data3 == 1 ; -}
\ No newline at end of file +} diff --git a/tests/language-feature/struct-field-initializers/struct-field-initializer-inherited.slang b/tests/language-feature/struct-field-initializers/struct-field-initializer-inherited.slang index 8edb98447..954a1edbe 100644 --- a/tests/language-feature/struct-field-initializers/struct-field-initializer-inherited.slang +++ b/tests/language-feature/struct-field-initializers/struct-field-initializer-inherited.slang @@ -46,10 +46,10 @@ struct DefaultStruct4 : DefaultStruct_base [numthreads(1, 1, 1)] void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) { - DefaultStruct1 s1; + DefaultStruct1 s1 = {}; DefaultStruct2 s2; DefaultStruct3 s3; - DefaultStruct4 s4; + DefaultStruct4 s4 = {}; // BUF: 1 outputBuffer[0] = true && s1.data0 == 1 @@ -63,4 +63,4 @@ void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) && s4.data0 == 1 && s4.data1 == 1 ; -}
\ No newline at end of file +} diff --git a/tests/language-feature/struct-field-initializers/struct-field-initializer-static.slang b/tests/language-feature/struct-field-initializers/struct-field-initializer-static.slang index b2ed006be..d6f9d3612 100644 --- a/tests/language-feature/struct-field-initializers/struct-field-initializer-static.slang +++ b/tests/language-feature/struct-field-initializers/struct-field-initializer-static.slang @@ -23,7 +23,7 @@ struct DefaultStructNoInit : DefaultStructNoInit_base void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) { DefaultStructNoInit::data4 = 0; - DefaultStructNoInit noInit; + DefaultStructNoInit noInit = {}; // BUF: 1 outputBuffer[0] = true && noInit.data0 == 2 @@ -32,4 +32,4 @@ void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) && noInit.data3 == 2 && noInit.data4 == 0; ; -}
\ No newline at end of file +} diff --git a/tests/language-feature/types/is-on-type.slang b/tests/language-feature/types/is-on-type.slang index 728f759ad..35b0a3b23 100644 --- a/tests/language-feature/types/is-on-type.slang +++ b/tests/language-feature/types/is-on-type.slang @@ -1,5 +1,6 @@ //TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-slang -compute +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-slang -compute -vk // Test that `is` operator works on generic type param. @@ -39,7 +40,7 @@ func test<T : I>(T t) -> int [numthreads(1,1, 1)] void computeMain() { - B b; + B b = {}; // CHECK: 2 outputBuffer[0] = test(b); } diff --git a/tests/language-feature/zero-initialize/IDefaultExplicit-wrapper-type.slang b/tests/language-feature/zero-initialize/IDefaultExplicit-wrapper-type.slang index c2781d3eb..a01961674 100644 --- a/tests/language-feature/zero-initialize/IDefaultExplicit-wrapper-type.slang +++ b/tests/language-feature/zero-initialize/IDefaultExplicit-wrapper-type.slang @@ -1,11 +1,11 @@ -//TEST:SIMPLE(filecheck=CHECK): -target glsl -stage compute -entry computeMain +//DISABLE_TEST:SIMPLE(filecheck=CHECK): -target glsl -stage compute -entry computeMain // CHECK: {{.* }}= 0; // CHECK-NOT: {{.* }}= 0; -//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -emit-spirv-directly -allow-glsl -//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute -entry computeMain -allow-glsl -//TEST(smoke,compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-dx12 -use-dxil -compute -entry computeMain -allow-glsl -profile sm_6_2 -xslang -DDX12 +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -emit-spirv-directly -allow-glsl +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute -entry computeMain -allow-glsl +//DISABLE_TEST(smoke,compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-dx12 -use-dxil -compute -entry computeMain -allow-glsl -profile sm_6_2 -xslang -DDX12 //TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer RWStructuredBuffer<int> outputBuffer; diff --git a/tests/language-feature/zero-initialize/IDefaultExplicit.slang b/tests/language-feature/zero-initialize/IDefaultExplicit.slang index b196335e9..c0001e8a9 100644 --- a/tests/language-feature/zero-initialize/IDefaultExplicit.slang +++ b/tests/language-feature/zero-initialize/IDefaultExplicit.slang @@ -1,10 +1,10 @@ -//TEST:SIMPLE(filecheck=CHECK): -target glsl -stage compute -entry computeMain +//DISABLE_TEST:SIMPLE(filecheck=CHECK): -target glsl -stage compute -entry computeMain // CHECK-COUNT-6: {{.* }}= 0U; -//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -emit-spirv-directly -allow-glsl -//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute -entry computeMain -allow-glsl -//TEST(smoke,compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-dx12 -use-dxil -compute -entry computeMain -allow-glsl -profile sm_6_2 -xslang -DDX12 +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -emit-spirv-directly -allow-glsl +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute -entry computeMain -allow-glsl +//DISABLE_TEST(smoke,compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-dx12 -use-dxil -compute -entry computeMain -allow-glsl -profile sm_6_2 -xslang -DDX12 //TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer RWStructuredBuffer<int> outputBuffer; diff --git a/tests/language-feature/zero-initialize/IDefaultExplicitGenerics.slang b/tests/language-feature/zero-initialize/IDefaultExplicitGenerics.slang index 5b17a908b..9f6b8c460 100644 --- a/tests/language-feature/zero-initialize/IDefaultExplicitGenerics.slang +++ b/tests/language-feature/zero-initialize/IDefaultExplicitGenerics.slang @@ -1,10 +1,10 @@ -//TEST:SIMPLE(filecheck=CHECK): -target glsl -stage compute -entry computeMain +//DISABLE_TEST:SIMPLE(filecheck=CHECK): -target glsl -stage compute -entry computeMain // CHECK: vec4(0.0 -//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -emit-spirv-directly -allow-glsl -//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute -entry computeMain -allow-glsl -//TEST(smoke,compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-dx12 -use-dxil -compute -entry computeMain -allow-glsl -profile sm_6_2 +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -emit-spirv-directly -allow-glsl +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute -entry computeMain -allow-glsl +//DISABLE_TEST(smoke,compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-dx12 -use-dxil -compute -entry computeMain -allow-glsl -profile sm_6_2 //TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer RWStructuredBuffer<int> outputBuffer; diff --git a/tests/language-feature/zero-initialize/generic.slang b/tests/language-feature/zero-initialize/generic.slang index 25f52238c..dc2d5d608 100644 --- a/tests/language-feature/zero-initialize/generic.slang +++ b/tests/language-feature/zero-initialize/generic.slang @@ -1,7 +1,7 @@ -//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -xslang -zero-initialize -//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -emit-spirv-directly -allow-glsl -xslang -zero-initialize -//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute -entry computeMain -allow-glsl -xslang -zero-initialize -//TEST(smoke,compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-dx12 -use-dxil -compute -entry computeMain -allow-glsl -profile sm_6_2 -xslang -zero-initialize -xslang -DDX12 +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -xslang -zero-initialize +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -emit-spirv-directly -allow-glsl -xslang -zero-initialize +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute -entry computeMain -allow-glsl -xslang -zero-initialize +//DISABLE_TEST(smoke,compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-dx12 -use-dxil -compute -entry computeMain -allow-glsl -profile sm_6_2 -xslang -zero-initialize -xslang -DDX12 //TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer RWStructuredBuffer<int> outputBuffer; diff --git a/tests/language-feature/zero-initialize/missing-zero-init.slang b/tests/language-feature/zero-initialize/missing-zero-init.slang index f9d715e10..a3deeabe3 100644 --- a/tests/language-feature/zero-initialize/missing-zero-init.slang +++ b/tests/language-feature/zero-initialize/missing-zero-init.slang @@ -1,5 +1,5 @@ -//TEST:SIMPLE(filecheck=CHECK): -target hlsl -stage compute -entry computeMain -//TEST:SIMPLE(filecheck=CHECK): -target glsl -stage compute -entry computeMain +//DISABLE_TEST:SIMPLE(filecheck=CHECK): -target hlsl -stage compute -entry computeMain +//DISABLE_TEST:SIMPLE(filecheck=CHECK): -target glsl -stage compute -entry computeMain // CHECK-NOT: {{.* }}= 0; // CHECK-NOT: return 0; diff --git a/tests/language-feature/zero-initialize/rayquery.slang b/tests/language-feature/zero-initialize/rayquery.slang index 6c48d3c65..72309b770 100644 --- a/tests/language-feature/zero-initialize/rayquery.slang +++ b/tests/language-feature/zero-initialize/rayquery.slang @@ -1,5 +1,5 @@ -//TEST:SIMPLE(filecheck=HLSL): -target hlsl -stage compute -entry computeMain -zero-initialize -//TEST:SIMPLE(filecheck=GLSL): -target glsl -stage compute -entry computeMain -zero-initialize +//DISABLE_TEST:SIMPLE(filecheck=HLSL): -target hlsl -stage compute -entry computeMain -zero-initialize +//DISABLE_TEST:SIMPLE(filecheck=GLSL): -target glsl -stage compute -entry computeMain -zero-initialize // HLSL-NOT: RayQuery{{.*}} {{.*}} = // GLSL-NOT: rayQueryEXT {{.*}} = diff --git a/tests/language-feature/zero-initialize/regular.slang b/tests/language-feature/zero-initialize/regular.slang index 5627762c3..462a436b2 100644 --- a/tests/language-feature/zero-initialize/regular.slang +++ b/tests/language-feature/zero-initialize/regular.slang @@ -1,7 +1,7 @@ -//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -xslang -zero-initialize -//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -emit-spirv-directly -allow-glsl -xslang -zero-initialize -//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute -entry computeMain -allow-glsl -xslang -zero-initialize -//TEST(smoke,compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-dx12 -use-dxil -compute -entry computeMain -allow-glsl -profile sm_6_2 -xslang -zero-initialize -xslang -DDX12 +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -xslang -zero-initialize +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -emit-spirv-directly -allow-glsl -xslang -zero-initialize +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute -entry computeMain -allow-glsl -xslang -zero-initialize +//DISABLE_TEST(smoke,compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-dx12 -use-dxil -compute -entry computeMain -allow-glsl -profile sm_6_2 -xslang -zero-initialize -xslang -DDX12 //TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer RWStructuredBuffer<int> outputBuffer; diff --git a/tests/language-feature/zero-initialize/shared-memory.slang b/tests/language-feature/zero-initialize/shared-memory.slang index 39243f796..401009eda 100644 --- a/tests/language-feature/zero-initialize/shared-memory.slang +++ b/tests/language-feature/zero-initialize/shared-memory.slang @@ -1,5 +1,5 @@ -//TEST:SIMPLE(filecheck=HLSL): -target hlsl -stage compute -entry computeMain -zero-initialize -//TEST:SIMPLE(filecheck=GLSL): -target glsl -stage compute -entry computeMain -zero-initialize +//DISABLE_TEST:SIMPLE(filecheck=HLSL): -target hlsl -stage compute -entry computeMain -zero-initialize +//DISABLE_TEST:SIMPLE(filecheck=GLSL): -target glsl -stage compute -entry computeMain -zero-initialize RWStructuredBuffer<uint> outputBuffer; diff --git a/tests/language-feature/zero-initialize/static-struct-field-init-list.slang b/tests/language-feature/zero-initialize/static-struct-field-init-list.slang index e40ca7e56..ca9f59b5e 100644 --- a/tests/language-feature/zero-initialize/static-struct-field-init-list.slang +++ b/tests/language-feature/zero-initialize/static-struct-field-init-list.slang @@ -1,4 +1,4 @@ -//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -xslang -zero-initialize +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -xslang -zero-initialize //TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer RWStructuredBuffer<uint> outputBuffer; diff --git a/tests/language-feature/zero-initialize/static-struct-field-init.slang b/tests/language-feature/zero-initialize/static-struct-field-init.slang index ad2db5027..566cd2f1d 100644 --- a/tests/language-feature/zero-initialize/static-struct-field-init.slang +++ b/tests/language-feature/zero-initialize/static-struct-field-init.slang @@ -1,7 +1,7 @@ -//TEST:SIMPLE(filecheck=CHECK): -target glsl -stage compute -entry computeMain -zero-initialize +//DISABLE_TEST:SIMPLE(filecheck=CHECK): -target glsl -stage compute -entry computeMain -zero-initialize // CHECK: {{.* }}= 0U; -//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -xslang -zero-initialize +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -xslang -zero-initialize //TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer RWStructuredBuffer<uint> outputBuffer; diff --git a/tests/language-feature/zero-initialize/struct-array-some-member-missing-init.slang b/tests/language-feature/zero-initialize/struct-array-some-member-missing-init.slang index cdd3f703f..1be88862f 100644 --- a/tests/language-feature/zero-initialize/struct-array-some-member-missing-init.slang +++ b/tests/language-feature/zero-initialize/struct-array-some-member-missing-init.slang @@ -1,5 +1,5 @@ -//TEST:SIMPLE(filecheck=CHECK): -target hlsl -stage compute -entry computeMain -xslang -zero-initialize -//TEST:SIMPLE(filecheck=CHECK): -target glsl -stage compute -entry computeMain -xslang -zero-initialize +//DISABLE_TEST:SIMPLE(filecheck=CHECK): -target hlsl -stage compute -entry computeMain -xslang -zero-initialize +//DISABLE_TEST:SIMPLE(filecheck=CHECK): -target glsl -stage compute -entry computeMain -xslang -zero-initialize // CHECK-NOT: {{.* }}= 0; diff --git a/tests/language-feature/zero-initialize/struct-array.slang b/tests/language-feature/zero-initialize/struct-array.slang index 1f1b8eede..6454cd493 100644 --- a/tests/language-feature/zero-initialize/struct-array.slang +++ b/tests/language-feature/zero-initialize/struct-array.slang @@ -1,7 +1,7 @@ -//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -xslang -zero-initialize -//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -emit-spirv-directly -allow-glsl -xslang -zero-initialize -//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute -entry computeMain -allow-glsl -xslang -zero-initialize -//TEST(smoke,compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-dx12 -use-dxil -compute -entry computeMain -allow-glsl -xslang -zero-initialize +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -xslang -zero-initialize +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -emit-spirv-directly -allow-glsl -xslang -zero-initialize +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute -entry computeMain -allow-glsl -xslang -zero-initialize +//DISABLE_TEST(smoke,compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-dx12 -use-dxil -compute -entry computeMain -allow-glsl -xslang -zero-initialize //TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer RWStructuredBuffer<int> outputBuffer; diff --git a/tests/language-feature/zero-initialize/struct-no-zero-init.slang b/tests/language-feature/zero-initialize/struct-no-zero-init.slang index 3a4a5f945..f7d8722ca 100644 --- a/tests/language-feature/zero-initialize/struct-no-zero-init.slang +++ b/tests/language-feature/zero-initialize/struct-no-zero-init.slang @@ -1,5 +1,5 @@ -//TEST:SIMPLE(filecheck=CHECK): -target hlsl -stage compute -entry computeMain -//TEST:SIMPLE(filecheck=CHECK): -target glsl -stage compute -entry computeMain +//DISABLE_TEST:SIMPLE(filecheck=CHECK): -target hlsl -stage compute -entry computeMain +//DISABLE_TEST:SIMPLE(filecheck=CHECK): -target glsl -stage compute -entry computeMain // CHECK-NOT: {{.* }}= 0; diff --git a/tests/language-feature/zero-initialize/struct-some-member-init-missing-zero-init.slang b/tests/language-feature/zero-initialize/struct-some-member-init-missing-zero-init.slang index 2b584ad00..903afb144 100644 --- a/tests/language-feature/zero-initialize/struct-some-member-init-missing-zero-init.slang +++ b/tests/language-feature/zero-initialize/struct-some-member-init-missing-zero-init.slang @@ -1,5 +1,5 @@ -//TEST:SIMPLE(filecheck=CHECK): -target hlsl -stage compute -entry computeMain -//TEST:SIMPLE(filecheck=CHECK): -target glsl -stage compute -entry computeMain +//DISABLE_TEST:SIMPLE(filecheck=CHECK): -target hlsl -stage compute -entry computeMain +//DISABLE_TEST:SIMPLE(filecheck=CHECK): -target glsl -stage compute -entry computeMain // CHECK-NOT: {{.* }}= 0; diff --git a/tests/language-feature/zero-initialize/struct-some-zero-init.slang b/tests/language-feature/zero-initialize/struct-some-zero-init.slang index 9bbb1f49e..b2a1be8a3 100644 --- a/tests/language-feature/zero-initialize/struct-some-zero-init.slang +++ b/tests/language-feature/zero-initialize/struct-some-zero-init.slang @@ -1,10 +1,10 @@ -//TEST:SIMPLE(filecheck=CHECK): -target glsl -stage compute -entry computeMain -zero-initialize +//DISABLE_TEST:SIMPLE(filecheck=CHECK): -target glsl -stage compute -entry computeMain -zero-initialize // CHECK-COUNT-2: {{.* }}= 0; -//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -xslang -zero-initialize -//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -emit-spirv-directly -allow-glsl -xslang -zero-initialize -//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute -entry computeMain -allow-glsl -xslang -zero-initialize -//TEST(smoke,compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-dx12 -use-dxil -compute -entry computeMain -allow-glsl -xslang -zero-initialize +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -xslang -zero-initialize +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -emit-spirv-directly -allow-glsl -xslang -zero-initialize +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute -entry computeMain -allow-glsl -xslang -zero-initialize +//DISABLE_TEST(smoke,compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-dx12 -use-dxil -compute -entry computeMain -allow-glsl -xslang -zero-initialize //TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer RWStructuredBuffer<int> outputBuffer; diff --git a/tests/language-feature/zero-initialize/struct.slang b/tests/language-feature/zero-initialize/struct.slang index efb1d8fc3..bd6b399e0 100644 --- a/tests/language-feature/zero-initialize/struct.slang +++ b/tests/language-feature/zero-initialize/struct.slang @@ -1,9 +1,9 @@ -//TEST:SIMPLE(filecheck=CHECK): -target glsl -stage compute -entry computeMain -zero-initialize +//DISABLE_TEST:SIMPLE(filecheck=CHECK): -target glsl -stage compute -entry computeMain -zero-initialize // CHECK-COUNT-3: {{.* }}= 0; -//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -xslang -zero-initialize -//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute -entry computeMain -allow-glsl -xslang -zero-initialize -//TEST(smoke,compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-dx12 -use-dxil -compute -entry computeMain -allow-glsl -xslang -zero-initialize +//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -xslang -zero-initialize +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute -entry computeMain -allow-glsl -xslang -zero-initialize +//DISABLE_TEST(smoke,compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-dx12 -use-dxil -compute -entry computeMain -allow-glsl -xslang -zero-initialize //TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer RWStructuredBuffer<int> outputBuffer; diff --git a/tests/pipeline/rasterization/mesh/hlsl-syntax.slang.glsl b/tests/pipeline/rasterization/mesh/hlsl-syntax.slang.glsl index 01e29f879..0d7a201ef 100644 --- a/tests/pipeline/rasterization/mesh/hlsl-syntax.slang.glsl +++ b/tests/pipeline/rasterization/mesh/hlsl-syntax.slang.glsl @@ -2,27 +2,40 @@ #extension GL_EXT_mesh_shader : require layout(row_major) uniform; layout(row_major) buffer; -const vec3 colors_0[3] = { vec3(1.0, 1.0, 0.0), vec3(0.0, 1.0, 1.0), vec3(1.0, 0.0, 1.0) }; -const vec2 positions_0[3] = { vec2(0.0, -0.5), vec2(0.5, 0.5), vec2(-0.5, 0.5) }; -layout(location = 0) -out vec3 verts_color_0[3]; out gl_MeshPerVertexEXT { vec4 gl_Position; } gl_MeshVerticesEXT[3]; +const vec3 colors_0[3] = { vec3(1.0, 1.0, 0.0), vec3(0.0, 1.0, 1.0), vec3(1.0, 0.0, 1.0) }; +const vec2 positions_0[3] = { vec2(0.0, -0.5), vec2(0.5, 0.5), vec2(-0.5, 0.5) }; + +struct Vertex_0 +{ + vec4 pos_0; + vec3 color_0; +}; + +Vertex_0 Vertex_x24init_0(vec4 pos_1, vec3 color_1) +{ + Vertex_0 _S1; + + _S1.pos_0 = pos_1; + _S1.color_0 = color_1; + return _S1; +} +layout(location = 0) +out vec3 verts_color_0[3]; out uvec3 gl_PrimitiveTriangleIndicesEXT[1]; void foo_0(uint _S2) { if(_S2 < 3U) { - gl_MeshVerticesEXT[_S2].gl_Position = vec4(positions_0[_S2], 0.0, 1.0); - verts_color_0[_S2] = colors_0[_S2]; - } - else - { + Vertex_0 _S3 = Vertex_x24init_0(vec4(positions_0[_S2], 0.0, 1.0), colors_0[_S2]); + gl_MeshVerticesEXT[_S2].gl_Position = _S3.pos_0; + verts_color_0[_S2] = _S3.color_0; } return; } @@ -39,8 +52,5 @@ void main() { gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex] = uvec3(0U, 1U, 2U); } - else - { - } return; } diff --git a/tests/pipeline/ray-tracing/trace-ray-inline.slang.hlsl b/tests/pipeline/ray-tracing/trace-ray-inline.slang.hlsl index 4ed4c9966..df78f3c79 100644 --- a/tests/pipeline/ray-tracing/trace-ray-inline.slang.hlsl +++ b/tests/pipeline/ray-tracing/trace-ray-inline.slang.hlsl @@ -2,7 +2,11 @@ #ifdef SLANG_HLSL_ENABLE_NVAPI #include "nvHLSLExtns.h" #endif -#pragma warning(disable: 3557) + +#ifndef __DXC_VERSION_MAJOR +// warning X3557: loop doesn't seem to do anything, forcing loop to unroll +#pragma warning(disable : 3557) +#endif struct SLANG_ParameterGroup_C_0 { @@ -23,21 +27,45 @@ RaytracingAccelerationStructure myAccelerationStructure_0 : register(t0); RWStructuredBuffer<int > resultBuffer_0 : register(u0); -struct MyProceduralHitAttrs_0 +struct MyRayPayload_0 { int value_0; }; -bool myProceduralIntersection_0(inout float tHit_0, inout MyProceduralHitAttrs_0 hitAttrs_0) +MyRayPayload_0 MyRayPayload_x24init_0(int value_1) { - return true; + MyRayPayload_0 _S1; + _S1.value_0 = value_1; + return _S1; } -struct MyRayPayload_0 +RayDesc RayDesc_x24init_0(float3 Origin_0, float TMin_0, float3 Direction_0, float TMax_0) +{ + RayDesc _S2; + _S2.Origin = Origin_0; + _S2.TMin = TMin_0; + _S2.Direction = Direction_0; + _S2.TMax = TMax_0; + return _S2; +} + +struct MyProceduralHitAttrs_0 { - int value_1; + int value_2; }; +MyProceduralHitAttrs_0 MyProceduralHitAttrs_x24init_0(int value_3) +{ + MyProceduralHitAttrs_0 _S3; + _S3.value_2 = value_3; + return _S3; +} + +bool myProceduralIntersection_0(inout float tHit_0, inout MyProceduralHitAttrs_0 hitAttrs_0) +{ + return true; +} + bool myProceduralAnyHit_0(inout MyRayPayload_0 payload_0) { return true; @@ -50,61 +78,59 @@ bool myTriangleAnyHit_0(inout MyRayPayload_0 payload_1) void myTriangleClosestHit_0(inout MyRayPayload_0 payload_2) { - payload_2.value_1 = int(1); + payload_2.value_0 = int(1); return; } void myProceduralClosestHit_0(inout MyRayPayload_0 payload_3, MyProceduralHitAttrs_0 attrs_0) { - payload_3.value_1 = attrs_0.value_0; + payload_3.value_0 = attrs_0.value_2; return; } void myMiss_0(inout MyRayPayload_0 payload_4) { - payload_4.value_1 = int(0); + payload_4.value_0 = int(0); return; } [shader("compute")][numthreads(1, 1, 1)] -void main(uint3 tid_0 : SV_DISPATCHTHREADID) +void main(uint3 tid_0 : SV_DispatchThreadID) { uint index_0 = tid_0.x; - MyRayPayload_0 payload_5; - payload_5.value_1 = int(-1); - RayDesc ray_0 = { C_0.origin_0, C_0.tMin_0, C_0.direction_0, C_0.tMax_0 }; + MyRayPayload_0 payload_5 = MyRayPayload_x24init_0(int(-1)); RayQuery<512U > query_0; - query_0.TraceRayInline(myAccelerationStructure_0, C_0.rayFlags_0, C_0.instanceMask_0, ray_0); + query_0.TraceRayInline(myAccelerationStructure_0, C_0.rayFlags_0, C_0.instanceMask_0, RayDesc_x24init_0(C_0.origin_0, C_0.tMin_0, C_0.direction_0, C_0.tMax_0)); MyProceduralHitAttrs_0 committedProceduralAttrs_0; + MyProceduralHitAttrs_0 _S4 = MyProceduralHitAttrs_x24init_0(int(0)); for(;;) { - bool _S1 = query_0.Proceed(); - if(!_S1) + bool _S5 = query_0.Proceed(); + if(!_S5) { break; } - uint _S2 = query_0.CandidateType(); + uint _S6 = query_0.CandidateType(); MyProceduralHitAttrs_0 committedProceduralAttrs_1; - switch(_S2) + switch(_S6) { case 1U: { - MyProceduralHitAttrs_0 candidateProceduralAttrs_0; - candidateProceduralAttrs_0.value_0 = int(0); + MyProceduralHitAttrs_0 candidateProceduralAttrs_0 = _S4; float tHit_1 = 0.0; - bool _S3 = myProceduralIntersection_0(tHit_1, candidateProceduralAttrs_0); - if(_S3) + bool _S7 = myProceduralIntersection_0(tHit_1, candidateProceduralAttrs_0); + if(_S7) { - bool _S4 = myProceduralAnyHit_0(payload_5); - if(_S4) + bool _S8 = myProceduralAnyHit_0(payload_5); + if(_S8) { query_0.CommitProceduralPrimitiveHit(tHit_1); - MyProceduralHitAttrs_0 _S5 = candidateProceduralAttrs_0; - if(C_0.shouldStopAtFirstHit_0 != 0U) + MyProceduralHitAttrs_0 _S9 = candidateProceduralAttrs_0; + if((C_0.shouldStopAtFirstHit_0) != 0U) { query_0.Abort(); } - committedProceduralAttrs_1 = _S5; + committedProceduralAttrs_1 = _S9; } else { @@ -119,11 +145,11 @@ void main(uint3 tid_0 : SV_DISPATCHTHREADID) } case 0U: { - bool _S6 = myTriangleAnyHit_0(payload_5); - if(_S6) + bool _S10 = myTriangleAnyHit_0(payload_5); + if(_S10) { query_0.CommitNonOpaqueTriangleHit(); - if(C_0.shouldStopAtFirstHit_0 != 0U) + if((C_0.shouldStopAtFirstHit_0) != 0U) { query_0.Abort(); } @@ -139,8 +165,8 @@ void main(uint3 tid_0 : SV_DISPATCHTHREADID) } committedProceduralAttrs_0 = committedProceduralAttrs_1; } - uint _S7 = query_0.CommittedStatus(); - switch(_S7) + uint _S11 = query_0.CommittedStatus(); + switch(_S11) { case 1U: { @@ -162,6 +188,7 @@ void main(uint3 tid_0 : SV_DISPATCHTHREADID) break; } } - resultBuffer_0[index_0] = payload_5.value_1; + resultBuffer_0[index_0] = payload_5.value_0; return; } + diff --git a/tests/spirv/debug-type-pointer.slang b/tests/spirv/debug-type-pointer.slang index 62bd4fda1..d6e8019cb 100644 --- a/tests/spirv/debug-type-pointer.slang +++ b/tests/spirv/debug-type-pointer.slang @@ -1,5 +1,5 @@ //TEST(compute, vulkan):SIMPLE(filecheck=SPV): -stage compute -entry computeMain -target spirv -emit-spirv-directly -g2 -//TEST(compute, vulkan):SIMPLE(filecheck=SPV): -stage compute -entry computeMain -target spirv -emit-spirv-directly -g2 -zero-initialize +//DISABLE_TEST(compute, vulkan):SIMPLE(filecheck=SPV): -stage compute -entry computeMain -target spirv -emit-spirv-directly -g2 -zero-initialize // This test is to check if DebugTypePointer is emitted when "-g2" option is used |
