8 Replies
      Latest reply on Jan 10, 2020 1:04 PM by rnikander
      rnikander Level 1 Level 1 (20 points)

        I have some code that used to run on my iPad Pro. Today I compiled it for iOS 13, with Xcode 11, and I get errors like this:

         

           validateComputeFunctionArguments:834: failed assertion `Compute Function(merge_layer):

           Shader uses texture(outTexture[1]) as read-write, but hardware does not support read-write texture of this pixel format.'

         

        The pixel format is showing as `MTLPixelFormatBGRA8Unorm`. That's what I expected.

         

        The debugger says the device has no support for writeable textures.

         

           (lldb) p device.readWriteTextureSupport

           (MTLReadWriteTextureTier) $R25 = tierNone

         

        Did some devices lose support for texture writing in iOS 13?

         

        Rob

        • Re: iOS 13, iPad Pro now says hardware does not support read-write texture?
          3DWizard Level 1 Level 1 (0 points)

          Same thing here. But it has to do with read_write support, write is supported. Maybe before there has been no warning and read_write was interpreted as just write in cases where this was possible. But I think I used a texture in read_write mode and actually read and wrote to it in a compute kernel on my IPad Pro (1st Gen.) on IOS 12. So I am confused about what is going on here.

           

          BTW: Harware is IPad Pro (1st Gen.) on IPadOS 13.1.2, using XCode 11.2 Beta.

          • Re: iOS 13, iPad Pro now says hardware does not support read-write texture?
            grk Level 1 Level 1 (0 points)

            I am seeing the same issue on my MBP with a single internal card ( Intel(R) Iris(TM) Plus Graphics 640)  . Read-Write with RGBAFloat32 pixel format was working on MacOS Mojave and Xcode 10.3. But since upgrading to Catalina and Xcode 11 I am getting the following error:  "Shader uses texture(output[0]) as read-write, but hardware does not support read-write texture of this pixel format." Looks like a regression to me.

            • Re: iOS 13, iPad Pro now says hardware does not support read-write texture?
              rnikander Level 1 Level 1 (20 points)

              I'm experimenting with a possible work around: pass the texture in twice, once as 'read' and once as 'write'. So my shader function looks like this now:

               

                 kernel void

                 merge_layer(texture2d<half, access::read>  inTexture  [[texture(0)]],

                                    texture2d<half, access::read> outTexture [[texture(1)]],

                                    texture2d<half, access::write> outTexture2 [[texture(2)]],

                                    uint2                          gid        [[thread_position_in_grid]])

               

              Swift code passes the same texture for 1 and 2 ...

               

                  let cenc = commandBuffer.makeComputeCommandEncoder()!

                  ...

                  cenc.setTexture(layerTexture, index: 1)      

                  cenc.setTexture(layerTexture, index: 2)

               

              It seems to work so far, but I haven't tested it much. It makes me nervous. Don't know if that kind of memory aliasing will cause problems later.

              • Re: iOS 13, iPad Pro now says hardware does not support read-write texture?
                rnikander Level 1 Level 1 (20 points)

                According to developer tech support, the current behavior is correct. Some of these devices, like 2nd generation iPad Pro, don't support read-write textures. I was a little confused that they wouldn't admit that it was behaving differently before, but I don't have time to do all the extra work to prove that to them.

                 

                You can see the "function texture read-write" feature in the Metal feature table here: https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf

                 

                You can detect the function texture read-write support like this:

                 

                 if #available(iOS 11, *) {
                    if self.device.supportsFamily(.common3) || self.device.supportsFamily(.apple4) {
                        print("supported")
                    } else {
                        print("not supported")
                    }
                } else {
                    print("Needs iOS 11 or higher")
                }
                
                  • Re: iOS 13, iPad Pro now says hardware does not support read-write texture?
                    4k4 Apple Staff Apple Staff (10 points)

                    Hi rnikander,

                     

                    We're not sure why you're confused as there is nothing here to admit. You've claimed to have used the feature on a device that doesn't support it yet have never provided any actual evidence of that. That said the burden of proof remains unambiguosly yours.

                     

                    Otherwise, thank you for sharing this information.

                     

                    Here is a general article on the topic that all Metal developers should find helpful.

                    "Detecting GPU Features and Metal Software Versions" - https://developer.apple.com/documentation/metal/mtldevice/detecting_gpu_features_and_metal_software_versions

                      • Re: iOS 13, iPad Pro now says hardware does not support read-write texture?
                        rnikander Level 1 Level 1 (20 points)

                        Hi 4k4,

                         

                        Here’s why I was confused. I gave Apple sample code that produces the error on iOS 13. Apple could run it on iOS 11 (maybe compiled with Xcode 9), on the device in question (iPad Pro gen 2), and get the proof (for or against), but they didn’t do that. Or at least, they didn’t tell me they did.

                         

                        I imagined it was relatively easy for Apple to do such a thing. For me as a solo developer it’s certainly not easy; I’d have to wipe my only device or buy another, download old Xcodes. Maybe I assumed incorrectly that Apple would be set up for running such a test, and that 3 people here saying they have a similar problem would be motive enough to do it. But if that's not the case, then I totally understand why neither I nor Apple want to spend time testing this!

                         

                        It's not a big deal, since we see how it works now and can move forward. I'm just curious what happened.

                         

                        take care,

                        R