Commit 8db2d61a815cd5b6b1261e28f4c85546914a0897

Le Hoang Quyen 2024-05-14T00:39:47

Metal: properly handle base/max level for immutable textures. Previously, we treat every texture the same as a non-immutable texture. Every texture has a native mtl::Texture containing mipmap levels from base GL level to max GL level. And base GL level would be mapped to level 0 of the native texture. However, this is not correct for immutable textures, pbuffer or EGLImage bound textures. Such textures have mipmaps pre-allocated either via glTexStorage calls or externally. Base and max GL levels don't affect their allocated mipmap levels, only limit the levels a shader can sample. For example, a texture has 8 levels allocated via glTexStorage. Its base level is set 1, and max level is set to 2. Shaders will only be able to sample from level 1 to level 2 of this texture. However, it's valid to attach level 0 or level > 2 of this texture to an FBO. This CL addresses this bug by separating internal mtl::Texture into two main objects: - A native storage will contain the actual mipmap levels of the texture. FBO attachment or data uploads can refer to a level in this object. - A view of the native storage from base GL level to max GL level. This view will be used in shader sampling and mipmap generations. Bug: angleproject:6447 Bug: angleproject:8355 Bug: b/42265945 Change-Id: I186b69f02e9e40c75830ffe4b48bd5a3c8d49cf2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5531392 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Quyen Le <lehoangquyen@chromium.org> Auto-Submit: Quyen Le <lehoangquyen@chromium.org>