gl4es icon indicating copy to clipboard operation
gl4es copied to clipboard

gl4es_blitTexture: Need to handle `GL_TEXTURE_MIN_FILTER`

Open okuoku opened this issue 2 years ago • 3 comments

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.

  • GL_TEXTURE_MIN_FILTER of the texture set to any filter other than GL_NEAREST
  • Source framebuffer object bound to the (client-supplied) texture

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.

okuoku avatar Jan 02 '23 12:01 okuoku

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

ptitSeb avatar Jan 02 '23 12:01 ptitSeb

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.

okuoku avatar Jan 02 '23 15:01 okuoku

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.

ptitSeb avatar Jan 02 '23 15:01 ptitSeb