The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Texture dimensions are limited to 8192x8192
dandago


Joined: 30 Aug 2013
Posts: 34
I'm writing an image viewer using SDL2. It loads an image into a surface, maps that to a texture, and renders it.

For larger images, I've run into a problem: the texture creation fails, with the error "Texture dimensions are limited to 8192x8192".

Why is there this limitation, and what am I supposed to do to display larger images in the window?

The source code (still early days) is available in case you need to reproduce this.
Texture dimensions are limited to 8192x8192
Alex Szpakowski
Guest

Video card hardware (and drivers) have a maximum limit on the dimensions of any texture. For DirectX 10-era GPUs that’s 8192x8192, and for DirectX 11-era GPUs it’s 16384x16384.

You can query the limit at runtime by looking at the max_texture_width and max_texture_height fields of the SDL_RendererInfo struct after populating it using SDL_GetRendererInfo.

One option for displaying extremely large images is to split it up into multiple textures and render each. Although keep in mind even an 8192x8192 texture uses 256 MB of video memory (plus 256 MB of regular RAM for the surface), assuming the texture is 32-bit RGBA.
Quote:
On Jan 12, 2016, at 6:33 PM, dandago wrote:
I'm writing an image viewer using SDL2. It loads an image into a surface, maps that to a texture, and renders it.For larger images, I've run into a problem: the texture creation fails, with the error "Texture dimensions are limited to 8192x8192".Why is there this limitation, and what am I supposed to do to display larger images in the window?The source code (still early days) is available in case you need to reproduce this.
Daniel D'Agostinohttp://gigi.nullneuron.net/gigilabs/
_______________________________________________SDL mailinghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
dandago


Joined: 30 Aug 2013
Posts: 34
Thanks for your reply, I understand the limitation now.

Still, from an API perspective I feel there should be an easier way to do this. While I understand it uses up a significant amount of memory to render a large image, I do not feel it is unreasonable to e.g. display an image that takes up the entire screen. This is pretty common when viewing photos, for instance.
Texture dimensions are limited to 8192x8192
Alex Szpakowski
Guest

Even a “4K” display is ‘only’ 3840x2160 – quite a ways away from 8192x8192 (and there’s almost no chance there’d be a DX10-era or older GPU driving that display).
Quote:
On Jan 12, 2016, at 6:43 PM, dandago wrote:
Thanks for your reply, I understand the limitation now.Still, from an API perspective I feel there should be an easier way to do this. While I understand it uses up a significant amount of memory to render a large image, I do not feel it is unreasonable to e.g. display an image that takes up the entire screen. This is pretty common when viewing photos, for instance.
Daniel D'Agostinohttp://gigi.nullneuron.net/gigilabs/
_______________________________________________SDL mailinghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
dandago


Joined: 30 Aug 2013
Posts: 34
You are actually quite right, and I thank you for putting things into perspective. The limitation is indeed reasonable. The image I was testing with is absolutely huge.