Thanks for the comments, here is what I tried, but still getting black output from drawSomething.
`struct Context {
float3 outColor;
float2 uv;
};
thread Context ContextInit(float3 color, float2 uv) {
Context context;
context.outColor = color;
context.uv = uv;
return context;
}
void drawSomething(Context context) {
float d = length(context.uv);
context.outColor *= d;
}
fragment float4 pointer(VertexOut input[[stage_in]]) {
float2 uv = input.textureCoordinate;
thread Context context = ContextInit(float3(1, 0, 0), uv);
context.outColor = float3(0,1,0);
drawSomething(context);
return float4(context.outColor.x, context.outColor.y, 0, 1);
}`