#version 450 core
#extension GL_KHR_memory_scope_semantics : enable
#extension GL_KHR_cooperative_matrix : enable
#extension GL_EXT_shader_explicit_arithmetic_types : enable

layout (local_size_x = 64, local_size_y = 1, local_size_z = 1) in;

float<16> ftemplate16;

coopmat fnoparams;

struct S
{
    int s;
};

coopmat<void, gl_ScopeSubgroup, 8, 8, gl_MatrixUseA> fbadtype;
coopmat<S, gl_ScopeSubgroup, 8, 8, gl_MatrixUseA> fbadtype2;
coopmat<16, gl_ScopeSubgroup, 8, 8, gl_MatrixUseA> fbadtype3;

coopmat<float16_t, gl_ScopeSubgroup, 8, gl_MatrixUseA> fbadnumparams;

int X = 8;

coopmat<float16_t, gl_ScopeSubgroup, 8, X, gl_MatrixUseA> fbadparam;

layout(constant_id = 0) const int Y = 1;

shared coopmat<float16_t, gl_ScopeSubgroup, 16, 16> sharedmat;

layout(set = 0, binding = 0) buffer InvBlock {
    coopmat<float16_t, gl_ScopeSubgroup, 16, 16, gl_MatrixUseA> bufmat;
} invblock;

void main()
{
    coopmat<float, gl_ScopeSubgroup, 16, 8, gl_MatrixUseA> f32_16_8;
    coopmat<float16_t, gl_ScopeSubgroup, 16, 8, gl_MatrixUseA> f16_16_8;

    // invalid implicit conversions
    f32_16_8 = f16_16_8;
    f32_16_8 = f16_16_8 + f16_16_8;

    coopmat<float16_t, gl_ScopeSubgroup, 8, 8, gl_MatrixUseA> f16_8_8;

    // mismatching dimensions
    f16_16_8 = f16_8_8;

    coopmat<float16_t, gl_ScopeSubgroup, 8, Y, gl_MatrixUseA> f16_8_Y;
    coopmat<float16_t, gl_ScopeSubgroup, 8, (Y+1), gl_MatrixUseA> f16_8_Y1;

    // mismatching dimensions with specialization constants
    f16_8_Y = f16_8_Y1;

    // wrong arguments for constructor
    f16_8_8 = coopmat<float16_t, gl_ScopeSubgroup, 8, 8, gl_MatrixUseA>(1, 1);

    // can't construct from a builtin type
    mat4 m4;
    coopmat<float, gl_ScopeSubgroup, 4, 4, gl_MatrixUseA> f32_4_4 = coopmat<float, gl_ScopeSubgroup, 4, 4, gl_MatrixUseA>(m4);

    // only support a single array subscript
    f16_16_8[0][0];

    // don't support scalar component selection
    f16_16_8.x;

    transpose(f16_8_8);
}
