Search Unity

Texture Arrays not available on modern Android?

Discussion in 'General Graphics' started by perholmes, Jul 7, 2022.

  1. perholmes

    perholmes

    Joined:
    Dec 29, 2017
    Posts:
    296
    Hi,

    I'm confused about the docs regarding Texture Arrays, which indicate that these are not available on Android/Vulkan: https://docs.unity3d.com/Manual/class-Texture2DArray.html

    However, I see mention in Vulkan tutorials about Texture Arrays, and I see lots of Unity assets using Texture Arrays that claim to work on Android. Does this in fact mean that you're forced to run OpenGL ES on Android, and you can't build to Android/Vulkan? Or are the Unity docs simply behind? What am I missing?

    Thanks,

    Per
     
  2. perholmes

    perholmes

    Joined:
    Dec 29, 2017
    Posts:
    296
    This may answer my own question. D3D11.hlsl has array samplers under the SHADER_API_VULKAN definition.

    So it seems that it does support it. I can't figure out why the Unity documentation goes out of its way to say that it doesn't.

    Code (CSharp):
    1.  
    2. #elif defined(SHADER_API_VULKAN)
    3.  
    4. ...
    5. ...
    6.  
    7.    #define SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index)                  textureName.Sample(samplerName, float3(coord2, index))
    8.    #define SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod)         textureName.SampleLevel(samplerName, float3(coord2, index), lod)
    9.    #define SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias)       textureName.SampleBias(samplerName, float3(coord2, index), bias)
    10.    #define SAMPLE_TEXTURE2D_ARRAY_GRAD(textureName, samplerName, coord2, index, dpdx, dpdy) textureName.SampleGrad(samplerName, float3(coord2, index), dpdx, dpdy)
    11.  
    12.  
     
  3. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,882
    The docs are either wrong or the Unity renderer simply does not support it on Android, even though it is technically available if you were to program against Vulkan directly.

    Try making a simple test case with 2d array and build it for Android, then you know for sure whether it works or not.