I have a question about texture3d sampling on M1.
I create a 3D texture from 33x33x33 buffer:
It is then of course passed to my Metal compute kernel and then I sample it:
This code worked fine on Intel, but on M1 the sampling seems to always return 0.0f, no matter where I sample, as if the texture was not created or sampling didn't work.
I create a 3D texture from 33x33x33 buffer:
Code Block Objective-C id<MTLTexture> tex = [device newTextureWithDescriptor:texDescriptor]; [tex replaceRegion:MTLRegionMake3D( 0, 0, 0, 33, 33, 33 ) mipmapLevel:0 slice:0 withBytes:GetRawBuffer() bytesPerRow:sizeof(vector_float4) * 33 bytesPerImage:sizeof(vector_float4) * 33 * 33)];
It is then of course passed to my Metal compute kernel and then I sample it:
Code Block metal float4 apply3DLut(const float4 pixel, const float3 coords, texture3d<float, access::sample> lut) { constexpr sampler smp (mag_filter::linear, min_filter::linear); float4 out = float4( lut.sample(smp, pixel.rgb) ); return float4( out.rgb, pixel.a ); }
This code worked fine on Intel, but on M1 the sampling seems to always return 0.0f, no matter where I sample, as if the texture was not created or sampling didn't work.
All right, so this is what happened:
After setting the texture in the compute encoder and ending the encoding, but before committing the command buffer, I was flagging the texture as purgeable. For some reason Intel did not purge the texture before rendering, while M1 did.
After setting the texture in the compute encoder and ending the encoding, but before committing the command buffer, I was flagging the texture as purgeable. For some reason Intel did not purge the texture before rendering, while M1 did.