iOS Metal sampling texture3d problem

I want to implement a HDR filter, and then use 3D slicing image to sampling from original texture.

It worked well on Mac, but get wrong result on iPhone.

It seems to have problems in sampling texture3d<float>, either texture3d<half>, I don't know what to do now.

I modified Apple's sample code "Creating and Sampling Textures".

And I pushed my code to GitHub,MyGitRepo->After modified about apple sample code.

By shader-debugger, I found iOS get wrong result at 'texture3d-sample', even if I replace with texture3d<half> ,still wrong.

Accepted Reply

Hi. Can you file a Feedback Assistant report with the sample you linked here and results you expect? We will take a closer look on this on our end. Please share the Feedback Assistant report ID here.

  • Hi,I want to get the right HDR-image,but iOS get the image with obviously square color block upon right image.

    In fact , I finally found the key reason and solve the problem by myself: iOS can't support texture-sample for RGBA32Float format . in Metal ,it's MTLPixelFormatRGBA32Float , to solve this problem ,should use MTLPixelFormatRGBA16Float in instead.

    Part of my code below:

        texDesc.textureType  = MTLTextureType3D;     texDesc.pixelFormat  = MTLPixelFormatRGBA16Float; In Metal shader, sampling with texture3d<half>.

    In addition, transform my origin float-array data to float-16bit data; ==> use float16_from_float32.

    Then send data to my MTLTexture with "- (void)replaceRegion: ..." .

    Ps: That's all, I hope it will help others who encounter this problem.

Add a Comment

Replies

Hi. Can you file a Feedback Assistant report with the sample you linked here and results you expect? We will take a closer look on this on our end. Please share the Feedback Assistant report ID here.

  • Hi,I want to get the right HDR-image,but iOS get the image with obviously square color block upon right image.

    In fact , I finally found the key reason and solve the problem by myself: iOS can't support texture-sample for RGBA32Float format . in Metal ,it's MTLPixelFormatRGBA32Float , to solve this problem ,should use MTLPixelFormatRGBA16Float in instead.

    Part of my code below:

        texDesc.textureType  = MTLTextureType3D;     texDesc.pixelFormat  = MTLPixelFormatRGBA16Float; In Metal shader, sampling with texture3d<half>.

    In addition, transform my origin float-array data to float-16bit data; ==> use float16_from_float32.

    Then send data to my MTLTexture with "- (void)replaceRegion: ..." .

    Ps: That's all, I hope it will help others who encounter this problem.

Add a Comment

Ahhhh, why does Apple forum's reply comment board not support Markdown syntax. The mess of layout....

I just wanna enter new line....