When I begin a compute pass from a MTLComputePassDescriptor with sampleBufferAttachments on macOS 11.6, it cannot sample correct values from counters on Apple M1 device, which work well for render pass.
Device: MacBook Pro (12-inch, M1, 2020)
MacOS: 11.6
NSRef<MTLComputePassDescriptor> descriptor = [MTLComputePassDescriptor computePassDescriptor];
descriptor.sampleBufferAttachments[0].sampleBuffer = counterSampleBuffer;
descriptor.sampleBufferAttachments[0].startOfEncoderSampleIndex = NSUInteger(0);
descriptor.sampleBufferAttachments[0].endOfEncoderSampleIndex = NSUInteger(1);
After the compute pass is completed, the values in sample buffer are zeros.
Another issue is MTLCounterDontSample, if we don't need to sample counter at the end of passes, we can set endOfEncoderSampleIndex to MTLCounterDontSample following the document, but it occurs validation layer error:
failed assertion 'endOfEncoderSampleIndex (4294967295) must be < sample buffer count (2)'