ptitSeb / gl4es

GL4ES is a OpenGL 2.1/1.5 to GL ES 2.0/1.1 translation library, with support for Pandora, ODroid, OrangePI, CHIP, Raspberry PI, Android, Emscripten and AmigaOS4.
http://ptitseb.github.io/gl4es/
MIT License
694 stars 159 forks source link

gl4es_blitTexture: Need to handle `GL_TEXTURE_MIN_FILTER` #406

Open okuoku opened 1 year ago

okuoku commented 1 year ago

at: https://github.com/ptitSeb/gl4es/commit/f5dda93ac7eaf1e3a44b1ee5585a6bf61d0656c5 Found by: wined3d (GLSL backend) + https://github.com/google/angle/commit/4a4ae726c449b719fc3d2ff258c0cded8adb07bd (Vulkan backend) on Win32

When gl4es_blitTexture called for glBlitFramebuffer, it will simply try to render associated texture with drawArrays. It can fail if following conditions met.

They're true for FBO emulation of wined3d https://github.com/wine-mirror/wine/blob/a8c1d5c108fc57e4d78e9db126f395c89083a83d/dlls/wined3d/texture.c#L553-L554 so we need this to be fixed to see any screen from it.

I have confirmed some DX8 game can show swapchain image by forcibly setting GL_NEAREST https://github.com/okuoku/gl4es/commit/c6cc375607b46ec71c5bd36392c4fd8d42f03263 but maybe we'd need more serious solution for performance.

ptitSeb commented 1 year ago

An FBO attached color texture must have a min (and mag?) filter set to GL_NEAREST? Is that what you are saying here?

okuoku commented 1 year ago

An FBO attached color texture must have a min (and mag?) filter set to GL_NEAREST?

No. When a framebuffer object had a attached texture, glBlitFramebuffer should work with any GL_TEXTURE_MIN_FILTER parameter of it. ie.) you can attach GL_TEXTURE_MIN_FILTER = LINEAR_MIPMAP_LINEAR texture and use it with glBlitFramebuffer as source. glBlitFramebuffer command will ignore MIN_FILTER setting and just honor parameter given the command.

Since GLES defaults it as NEAREST_MIPMAP_LINEAR, most of the time we have to set it NEAREST (or LINEAR) temporary during emulating glBlitFramebuffer, strictly speaking.

ptitSeb commented 1 year ago

Ah ok. I think I get it. It's just the glBlitFramebuffer(...) FBO source filter that should be ignored because there is a parameter defined in the function call.