Revision 50e7d9797d9bf4b98a056d5df128c24dde6e78bd authored by Yong He on 23 March 2023, 23:59:02 UTC, committed by GitHub on 23 March 2023, 23:59:02 UTC
* Fix optimization pass not converging.

* Fix.

* Fix tests.

---------

Co-authored-by: Yong He <yhe@nvidia.com>
1 parent 85f0058
Raw File
static-const-matrix-array.slang
// static-const-array.slang

//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -output-using-type -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-cpu -slang -compute -output-using-type -shaderobj

//TEST_INPUT:ubuffer(data=[0 0 0 0  0 0 0 0], stride=4):out, name outputBuffer
RWStructuredBuffer<float> outputBuffer;


static const matrix<float, 2, 3> kMatrix = { 1, 2, 4, -1, -2, -3 };
static const float3 kVector = { -1, -2, -3 };

static const matrix<float, 2, 3> kArray[2] =
{
    matrix<float, 2, 3>(0, 1, 2, 3, 4, 5),
    matrix<float, 2, 3>(float3(6, 7, 8), float3(9, 10, 11)),
};

float test(int inVal, int index)
{
    matrix<float, 2, 3> 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(int3 tid : SV_DispatchThreadID)
{
    int inVal = tid.x;
    float outVal = test(inVal, inVal & 1);
    outputBuffer[inVal] = outVal;
}
back to top