Bug 231354
Summary: | ANGLE Metal RGB textures are slow to initialise compared to RGBA textures when uploading video contents | ||
---|---|---|---|
Product: | WebKit | Reporter: | Kimmo Kinnunen <kkinnunen> |
Component: | ANGLE | Assignee: | Nobody <webkit-unassigned> |
Status: | NEW | ||
Severity: | Normal | CC: | dino, dustin.kerstein, geofflang, jonahr, kbr, kkinnunen, kpiddington, webkit-bug-importer |
Priority: | P2 | Keywords: | InRadar |
Version: | WebKit Local Build | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Bug Depends on: | |||
Bug Blocks: | 231031 |
Kimmo Kinnunen
ANGLE Metal RGB textures are slow to initialise compared to RGBA textures
The emulated alpha channel forces very slow path for textures that are initialized as undefined.
This causes very slow video texture uploads, 1ms vs 5ms on macOS Intel.
Video textures allocate texture memory via texImage2D(.., nullptr) and then fully draw over it with a FBO draw.
Sample Count, Samples %, Normalized CPU %, Symbol
1426, 23.6%, 2.0%, WebCore::GraphicsContextGLOpenGL::copyTextureFromMedia(WebCore::MediaPlayer&, unsigned int, unsigned int, int, unsigned int, unsigned int, unsigned int, bool, bool) (in WebCore)
1287, 21.3%, 1.8%, WebCore::GraphicsContextGLCVANGLE::copyPixelBufferToTexture(__CVBuffer*, unsigned int, int, unsigned int, unsigned int, unsigned int, WebCore::GraphicsContextGL::FlipY) (in WebCore)
1287, 21.3%, 1.8%, WebCore::GraphicsContextGLOpenGL::texImage2DDirect(unsigned int, int, unsigned int, int, int, int, unsigned int, unsigned int, void const*) (in WebCore)
1287, 21.3%, 1.8%, gl::TexImage2D(unsigned int, int, int, int, int, int, unsigned int, unsigned int, void const*) (in libANGLE-shared.dylib)
1287, 21.3%, 1.8%, gl::Context::texImage2D(gl::TextureTarget, int, int, int, int, int, unsigned int, unsigned int, void const*) (in libANGLE-shared.dylib)
1285, 21.3%, 1.8%, gl::Texture::setImage(gl::Context*, gl::PixelUnpackState const&, gl::Buffer*, gl::TextureTarget, int, unsigned int, gl::Extents const&, unsigned int, unsigned int, unsigned char const*) (in libANGLE-shared.dylib)
1283, 21.3%, 1.8%, rx::TextureMtl::setImageImpl(gl::Context const*, gl::ImageIndex const&, gl::InternalFormat const&, gl::Extents const&, unsigned int, unsigned int, gl::PixelUnpackState const&, gl::Buffer*, unsigned char const*) (in libANGLE-shared.dylib)
1282, 21.3%, 1.8%, rx::TextureMtl::redefineImage(gl::Context const*, gl::ImageIndex const&, rx::mtl::Format const&, gl::Extents const&) (in libANGLE-shared.dylib)
1272, 21.1%, 1.8%, rx::TextureMtl::checkForEmulatedChannels(gl::Context const*, rx::mtl::Format const&, std::__1::shared_ptr<rx::mtl::Texture> const&) (in libANGLE-shared.dylib)
1233, 20.4%, 1.7%, rx::mtl::InitializeTextureContents(gl::Context const*, std::__1::shared_ptr<rx::mtl::Texture> const&, rx::mtl::Format const&, rx::mtl::ImageNativeIndex const&) (in libANGLE-shared.dylib)
1029, 17.1%, 1.4%, rx::mtl::Texture::replaceRegion(rx::ContextMtl*, MTLRegion const&, gl::LevelIndexWrapper<unsigned int> const&, unsigned int, unsigned char const*, unsigned long, unsigned long) (in libANGLE-shared.dylib)
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Kenneth Russell
There's a chance the core ANGLE folks (Geoff, Jonah) might have some advice on how to optimize this.
Geoff Lang
There are a couple options we've done on different backends:
- Clear with a GPU clear when possible
- Use swizzled samplers to always sample 1.0 from the alpha channel of these textures. I think it's still recommended to clear first even with this, there are many paths that need to be aware of this emulated alpha (ReadPixels, CopyTexImage, Blit)
- If this is a glTexImage2D call with non-null data, you can add a new data upload function that writes the 1.0 alpha.
Otherwise, just try to avoid re-initializing textures too frequently. Caching the allocated textures would avoid this issue.
Radar WebKit Bug Importer
<rdar://problem/84245586>