From fbac017938343724407ab036abd736c942b4e187 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 14 Apr 2020 17:00:11 -0400 Subject: CUDA global scope initialization of arrays without function calls. (#1320) * Fix CUDA output of a static const array if values are all literals. * Fix bug in Convert definition. * Output makeArray such that is deconstructed on CUDA to fill in based on what the target type is. Tries to expand such that there are no function calls so that static const global scope definitions work. * Fix unbounded-array-of-array-syntax.slang to work correctly on CUDA. * Remove tabs. * Check works with static const vector/matrix. * Fix typo in type comparison. * Shorten _areEquivalent test. * Rename _emitInitializerList. Some small comment fixes. Co-authored-by: Tim Foley --- tests/compute/static-const-matrix-array.slang | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/compute/static-const-matrix-array.slang (limited to 'tests/compute/static-const-matrix-array.slang') diff --git a/tests/compute/static-const-matrix-array.slang b/tests/compute/static-const-matrix-array.slang new file mode 100644 index 000000000..2ac132121 --- /dev/null +++ b/tests/compute/static-const-matrix-array.slang @@ -0,0 +1,36 @@ +// static-const-array.slang + +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -output-using-type +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type +//TEST(compute):COMPARE_COMPUTE_EX:-cpu -slang -compute -output-using-type + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out, name outputBuffer +RWStructuredBuffer outputBuffer; + + +static const matrix kMatrix = { 1, 2, 4, -1, -2, -3 }; +static const float3 kVector = { -1, -2, -3 }; + +static const matrix kArray[2] = +{ + matrix(0, 1, 2, 3, 4, 5), + matrix(float3(6, 7, 8), float3(9, 10, 11)), +}; + +float test(int inVal, int index) +{ + matrix mat = kArray[index] + kMatrix; + mat[0] =+ kVector; + + float2 a = { inVal, inVal + 1}; + float3 v = mul(a, mat); + return v.x + v.y + v.z; +} + +[numthreads(8, 1, 1)] +void computeMain(uint3 tid : SV_DispatchThreadID) +{ + int inVal = tid.x; + float outVal = test(inVal, inVal & 1); + outputBuffer[inVal] = outVal; +} \ No newline at end of file -- cgit v1.2.3