Hi, I want to use TextureArray in my project

public class TextureArray : Texture2D
  public TextureArray(GraphicsDevice graphicsDevice, int width, int height, int arraySize) : 
            base(graphicsDevice, width, height, true, SurfaceFormat.Color, SurfaceType.Texture, false, arraySize)

when I instantiate the TextureArray with an arraySize > 0,
I got an ArgumentException: “Texture arrays are not supported on this graphics device”.

I tried DX/GL on two different pcs with standard Monogame library and the compute fork, always with the same result.
The tool GLviewer shows that texture array is supported on both systems.

Does anyone have an idea?

At least in 3.8.1 DesktopGL, Texture Arrays are not supported. The relevant line, in GraphicsCapabilities.OpenGL:

// TODO: Implement OpenGL support for texture arrays
// once we can author shaders that use texture arrays.
SupportsTextureArrays = false;

This variable isn’t set to true anywhere else in the solution.

The regular Texture2D has a Constructor which takes the array size - this works as a TextureArray in Shader (I only use DX tho)

public Texture2D(GraphicsDevice graphicsDevice, int width, int height, bool mipmap, SurfaceFormat format, int arraySize)

(the last parameter)

everx .SetData has an overload which takes an array Index so you can access it

you just handle it like every other Texture2D, but in in the shader you access it with


so each sample takes a vec3 instead of vec2 where the z = the index in the array

(using a slightly older MG version, so maybe things changed since then)

The 3.8.2.* DesktopGL supports Texture Arrays in the compute fork. I mean I could write the shader without having errors. I also can load the Effect.

I tried:
Texture2D texture2D = new Texture2D(device, 512, 512, true, SurfaceFormat.Color, 2);
The error occurs also with the WindowsDX Version.

This does not appear to be the case. In the compute branch, just like in the main branch, SupportsTextureArrays is set to false in PlatformInitialize and never set to true anywhere else in the DesktopGL solution.

There’s a PR on Github to support texture arrays in OpenGL.

It’s currently unsupported in anything but DirectX, but for DirectX build you also need to put the GraphicsProfille into HiDef mode.

_graphics.GraphicsProfile = GraphicsProfile.HiDef;