I am new to Metal compute shaders so have a doubt. When we use vertex/fragment shaders in render pipeline, it is possible for output texture to have a different size than input, we could simply specify sampler in the render pipeline as follows and it does the job to rescale output texture.
constexpr sampler s(s_address::clamp_to_edge, t_address::clamp_to_edge, min_filter::linear, mag_filter::linear)
But how do we achieve the same thing in compute shader, is it even possible? For instance, in this kernel how do we write to a outputTexture which has a different size than input texture?
kernel void rosyEffect(texture2d<half, access::read> inputTexture [[ texture(0) ]],
texture2d<half, access::write> outputTexture [[ texture(1) ]],
uint2 gid [[thread_position_in_grid]])
{
/
if ((gid.x >= inputTexture.get_width()) || (gid.y >= inputTexture.get_height())) {
return;
}
half4 inputColor = inputTexture.read(gid);
/
half4 outputColor = half4(inputColor.r, 0.0, inputColor.b, 1.0);
outputTexture.write(outputColor, gid);
}