hajimehoshi / ebiten

Ebitengine - A dead simple 2D game engine for Go
https://ebitengine.org
Apache License 2.0
10.8k stars 650 forks source link

Firefox warns WebGL program #629

Closed hajimehoshi closed 5 years ago

hajimehoshi commented 6 years ago
Error: WebGL warning: drawElements: This operation requires zeroing texture data. This is slow.

Version 60.0.2 (64-bit)

hajimehoshi commented 5 years ago

https://github.com/pixijs/pixi.js/issues/3897

This usually is logged in firefox when you try to read pixels from an out-of-viewport location and render them. Because there are no out-of-viewport pixels to read the browser has to create a buffer filled with zeroes for you, which is slow.

Hmm, I don't understand... Viewport specifies the region of the render target and how is this related to the texture to be read?

hajimehoshi commented 5 years ago

This happens whatever viewport size is.

hajimehoshi commented 5 years ago

https://dxr.mozilla.org/mozilla-central/source/dom/canvas/WebGLTexture.cpp#636-640

    // This has two usecases:
    // 1. Lazy zeroing of uninitialized textures:
    //    a. Before draw, when FakeBlack isn't viable. (TexStorage + Draw*)
    //    b. Before partial upload. (TexStorage + TexSubImage)
    // 2. Zero subrects from out-of-bounds blits. (CopyTex(Sub)Image)

OK so probably texture is not initialized when it is used. However, not-initializing is intentional in Ebiten for performance.