I want to pass array data from Swift to Metal's fragment shader in Uniform

I am trying to pass array data in Uniform from Swift to Metal's fragment shader. I am able to pass normal Float numbers that are not arrays with no problem. The structure is as follows

struct Uniforms {
    var test: [Float]
}

The values are as follows

let floatArray: [Float] = [0.5]

As usual, we are going to write and pass the following As mentioned above, normal Float values can be passed without any problem.

commandEncoder.setFragmentBytes(&uniforms, length: MemoryLayout<Uniforms>.stride, index: 0)

The shader side should be as follows


// uniform

struct Uniforms {
    float test[1];
};

Fragment Shader

// in fragment shader
float testColor = 1.0;
 // for statement
for (int i = 0; i < 1; i++) {
    testColor *= uniforms.test[i];
}

float a = 1.0 - testColor;

return float4(1.0,0.0,0.0,a);

I thought that 0.5 in the array was passed, but no value is passed.
I think I am writing something wrong, but how should I write it?

I want to pass array data from Swift to Metal's fragment shader in Uniform
 
 
Q