google / google/filament

Add ability to query GPU maximum texture size

Open
#6,923 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
20.5k
Forks
2.3k
Avg merge
2d 16h
Merged PRs (30d)
74

Description

**Is your feature request related to a problem? Please describe.**
When running on the WebGL backend under Chrome on Android, I am getting the following error when trying to load a 8192x4096 `Texture::InternalFormat::ETC2_SRGB8` compressed texture:
`[.WebGL-0x200346200]GL ERROR :GL_INVALID_VALUE : glTexStorage2D: dimensions out of range`
This is understandable considering both mobile platforms and the WebGL back end are less capable than say a native desktop app with a modern GPU. The problem is I am unable to know ahead of time that this will fail on the host device and resort to loading smaller texture dimensions instead.

**Describe the solution you'd like**
It would be nice to be able to query the GPU for it's maximum texture dimension. Something analogous to OpenGL's `GL_MAX_TEXTURE_SIZE`. I'd suggest putting it in `filament::Texture`, something like a static function `getMaxTextureDimension()` to compliment `isTextureFormatSupported()`.

**Describe alternatives you've considered**
Alternatively, if the dimensions are too large, it would be fine if I got a specific and graceful error out of `filament::Texture::Builder::build()`. Having a new exception class for indicating texture dimensions too large could be thrown from here, caught and retried with small texture dimensions.

**OS and backend**
The problem seems to be specific to the web platform, however this could be useful on all OSes and backends, especially when running on lower end GPUs or when using extremely large textures on capable GPUs.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.