diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2020-04-09 15:43:09 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-09 15:43:09 -0400 |
| commit | a01c09c3934d3f859bf4bea6b4e583f25291b643 (patch) | |
| tree | 47b01ad7a3b138c46ca0f7904415a5ad6a74bb72 /tests/compute/static-const-vector-array.slang | |
| parent | 78acd326a0dd684dd16f1db55bd53937fc38d467 (diff) | |
Literal folding on other operators (#1314)
* Fold prefix operators if they prefix an int literal.
* Make test case a bit more convoluted.
* Remove ++ and -- as not appropriate for folding of literals.
* Set output buffer name.
Diffstat (limited to 'tests/compute/static-const-vector-array.slang')
| -rw-r--r-- | tests/compute/static-const-vector-array.slang | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/compute/static-const-vector-array.slang b/tests/compute/static-const-vector-array.slang new file mode 100644 index 000000000..4d9234a70 --- /dev/null +++ b/tests/compute/static-const-vector-array.slang @@ -0,0 +1,33 @@ +// 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<float> outputBuffer; + +static const float3 kArray[8] = +{ + float3(-0.4706069, -0.4427112, - - + 0.6461146), + float3(-0.9057375, +0.3003471, +0.9542373), + float3(-0.3487388, +0.4037880, +0.5335386), + float3(+0.1023042, +0.6439373, +0.6520134), + float3(+0.5699277, +0.3513750, +0.6695386), + float3(+0.2939128, -0.1131226, +0.3149309), + float3(+0.7836658, -0.4208784, +0.8895339), + float3(+0.1564120, -0.8198990, +0.8346850) +}; + +float test(int val) +{ + return kArray[val].x + kArray[val].y + kArray[val].z; +} + +[numthreads(8, 1, 1)] +void computeMain(uint3 tid : SV_DispatchThreadID) +{ + int inVal = tid.x; + float outVal = test(inVal); + outputBuffer[inVal] = outVal; +}
\ No newline at end of file |
