KhronosGroup/WebGL

Why the multiple of 4 size limitation in WEBGL_compressed_texture_s3tc?

Closed this issue · 5 comments

In the WEBGL_compressed_texture_s3tc spec (https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_s3tc/) there is a limitation on the size of the texture:

"width << level and height << level must be a multiple of 4."

Why is there this restriction in WebGL?

In desktop OpenGL, there is no such restriction. (e.g. in https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_s3tc.txt)

Is it because of ANGLE and implementation of WebGL with Direct3d? In that case it's pretty disappointing that a restriction is added to WebGL just because of Direct3D.

My use case is compressing user-generated textures at runtime. As such I can't guarantee texture dimensions are multiples of power of 4.

Direct3D 11, which is used as a WebGL backend on all Windows devices, requires level 0 dimensions of compressed textures to be multiples of 4. To ensure application portability, this limitation is enforced on all platforms. Technically, all BCn formats internally use 4x4 blocks even if the perceived texture dimensions are not divisible by 4.

As I suspected, that is very disappointing that it is due to Direct3D. Maybe some kind of flag or extension can be added to WebGL to allow dimensions that are not multiples of 4?

Btw I use non-multiple of 4 dimension compressed textures on desktop OpenGL and it works great.

Maybe some kind of flag or extension can be added to WebGL to allow dimensions that are not multiples of 4?

Such an extension would make your app not work on lots of machines.

Maybe some kind of flag or extension can be added to WebGL to allow dimensions that are not multiples of 4?

Such an extension would make your app not work on lots of machines.

This could be solved in a couple of ways: Browsers could stop using Angle, or browsers could do some work to avoid Direct3D texture limitations (OpenGL <-> Direct3D interop?).
Or maybe the best way is that someone improves Direct3D to allow non-multiple-of-4 textures. Then WebGL can detect that capability and expose it to the client code in some way. Anyone here work at Microsoft?

It's a shame to impose restrictions when GPUs clearly have the capabilities.

It is not reasonable to suggest that WebGL implementations on Windows stop using ANGLE. OpenGL drivers on Windows never achieved the ubiquity and quality of Direct3D drivers, which ship with the operating system.

I agree with @greggman that it is not a good idea to encourage application authors to create non-portable content, especially between Windows and non-Windows platforms.

There are easy facilities in the browser for resizing incoming users' textures to widths and heights that are a multiple of 4, for example by drawing the image to a 2D canvas and stretching it slightly, and then uploading the 2D canvas to a WebGL texture. This is a fine application-level workaround which would be inappropriate to add to the browser's WebGL implementation.

Because the suggestions provided are unworkable, I am closing this as WontFix.