![]() |
Texture dimensions are limited to 8192x8192 | ![]() |
dandago
![]() |
![]() |
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.
|
||||||||||||
|
![]() |
![]() |
![]() |
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).
|
||||||||||||
|
![]() |
![]() |
dandago
![]() |
![]() |
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.
|
||||||||||
|