My MTKView is in BGRA and I setup my pipelineDescriptor in BGRA like below :
pipelineDescriptor.colorAttachments.objectAtIndexedSubscript(0).setPixelFormat(MTLPixelFormatBGRA8Unorm);
now the problem is that if I send data encoded in RGBA (I mean color is a 16 bytes encoded in R(4bytes)+G(4bytes)+B(4bytes)+A(4bytes)) to the shader below then it's work well!
RenderCommandEncoder.setVertexBuffer(LvertexBuffer{buffer}, 0{offset}, 0{atIndex})
and
#include <metal_stdlib>
using namespace metal;
#include <simd/simd.h>
struct VertexIn {
vector_float4 color;
vector_float2 pos;
};
struct VertexOut {
float4 color;
float4 pos [[position]];
};
vertex VertexOut vertexShader(
const device VertexIn *vertexArray [[buffer(0)]],
unsigned int vid [[vertex_id]],
constant vector_uint2 *viewportSizePointer [[buffer(1)]]
)
{
// Get the data for the current vertex.
VertexIn in = vertexArray[vid];
VertexOut out;
...
out.color = in.color;
....
return out;
}
fragment float4 fragmentShader(
VertexOut interpolated [[stage_in]],
texture2d<half> colorTexture [[ texture(0) ]]
)
{
return interpolated.color;
}
How it's possible? is it about little and big endian ?