cocos / cocos-engine

Cocos simplifies game creation and distribution with Cocos Creator, a free, open-source, cross-platform game engine. Empowering millions of developers to create high-performance, engaging 2D/3D games and instant web entertainment.
https://www.cocos.com/en/creator
Other
8.87k stars 2.06k forks source link

[3.8.3] PostProcess fails with GL error 0x501, 0x506 #17243

Open Skroopa opened 5 months ago

Skroopa commented 5 months ago

Cocos Creator version

3.8.3

System information

Android 5.1

Issue description

None of built-in PostProcess effects work on my DIGMA Linx A400 3G LT4001PG (Android 5.1) device. First, it fails with GL error: 0x501 and then GL error: 0x506 every update

Relevant error log output

D/Cocos: 21:47:46 [DEBUG]: JS: Cocos Creator v3.8.3
E/Cocos: 21:47:46 [ERROR]: [SE_ERROR]  (C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/bindings/manual/jsb_global.cpp, 1370): wrong number of arguments: 0, was expecting 1
E/Cocos: 21:47:46 [ERROR]: E/ [ERROR] Failed to invoke js_TextDecoder_decode
D/Cocos: 21:47:46 [DEBUG]: JS: Using custom pipeline
I/Cocos: 21:47:46 [INFO]: Shader 'util/splash-screen|splash-screen-vs:vert|splash-screen-fs:frag' compilation succeeded.
D/Cocos: 21:47:48 [DEBUG]: JS: Success to load scene: db://assets/scenes/main.scene
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 636 
E/Cocos: 21:47:48 [ERROR]: glTexImage2D(GL_TEXTURE_2D, i, gpuTexture->glInternalFmt, w, h, 0, gpuTexture->glFormat, gpuTexture->glType, nullptr) returned GL error: 0x501
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 1512 
E/Cocos: 21:47:48 [ERROR]: checkFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_ATTACHMENT
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 636 
E/Cocos: 21:47:48 [ERROR]: glTexImage2D(GL_TEXTURE_2D, i, gpuTexture->glInternalFmt, w, h, 0, gpuTexture->glFormat, gpuTexture->glType, nullptr) returned GL error: 0x501
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 1512 
E/Cocos: 21:47:48 [ERROR]: checkFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_ATTACHMENT
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 1512 
E/Cocos: 21:47:48 [ERROR]: checkFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_ATTACHMENT
I/Cocos: 21:47:48 [INFO]: Shader 'for2d/builtin-sprite|sprite-vs:vert|sprite-fs:frag|CC_USE_EMBEDDED_ALPHA0|USE_TEXTURE1|IS_GRAY0' compilation succeeded.
I/Cocos: 21:47:48 [INFO]: Shader 'pipeline/post-process/fxaa-hq|fxaa-vs|fxaa-edge-fs:frag' compilation succeeded.
I/Cocos: 21:47:48 [INFO]: Shader 'pipeline/post-process/post-final|vs|fs' compilation succeeded.
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 1512 
E/Cocos: 21:47:48 [ERROR]: checkFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_ATTACHMENT
I/Cocos: 21:47:48 [INFO]: Shader 'pipeline/post-process/blit-screen|vs|fs' compilation succeeded.
I/Cocos: 21:47:48 [INFO]: Shader 'util/profiler|profiler-vs:vert|profiler-fs:frag' compilation succeeded.
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 1793 
E/Cocos: 21:47:48 [ERROR]: glClear(glClears) returned GL error: 0x506
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 2605 
E/Cocos: 21:47:48 [ERROR]: glDrawElements(glPrimitive, drawInfo.indexCount, gpuInputAssembler->glIndexType, offset) returned GL error: 0x506
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 1793 
E/Cocos: 21:47:48 [ERROR]: glClear(glClears) returned GL error: 0x506
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 2605 
E/Cocos: 21:47:48 [ERROR]: glDrawElements(glPrimitive, drawInfo.indexCount, gpuInputAssembler->glIndexType, offset) returned GL error: 0x506
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 2605 
E/Cocos: 21:47:48 [ERROR]: glDrawElements(glPrimitive, drawInfo.indexCount, gpuInputAssembler->glIndexType, offset) returned GL error: 0x506
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 2605 
E/Cocos: 21:47:48 [ERROR]: glDrawElements(glPrimitive, drawInfo.indexCount, gpuInputAssembler->glIndexType, offset) returned GL error: 0x506
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 2605 
E/Cocos: 21:47:48 [ERROR]: glDrawElements(glPrimitive, drawInfo.indexCount, gpuInputAssembler->glIndexType, offset) returned GL error: 0x506
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 1793 
E/Cocos: 21:47:48 [ERROR]: glClear(glClears) returned GL error: 0x506
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 2605 
E/Cocos: 21:47:48 [ERROR]: glDrawElements(glPrimitive, drawInfo.indexCount, gpuInputAssembler->glIndexType, offset) returned GL error: 0x506
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 1793 
E/Cocos: 21:47:48 [ERROR]: glClear(glClears) returned GL error: 0x506
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 2605 
E/Cocos: 21:47:48 [ERROR]: glDrawElements(glPrimitive, drawInfo.indexCount, gpuInputAssembler->glIndexType, offset) returned GL error: 0x506
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 2605 
E/Cocos: 21:47:48 [ERROR]: glDrawElements(glPrimitive, drawInfo.indexCount, gpuInputAssembler->glIndexType, offset) returned GL error: 0x506
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 2605 
E/Cocos: 21:47:48 [ERROR]: glDrawElements(glPrimitive, drawInfo.indexCount, gpuInputAssembler->glIndexType, offset) returned GL error: 0x506
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 2605 
E/Cocos: 21:47:48 [ERROR]: glDrawElements(glPrimitive, drawInfo.indexCount, gpuInputAssembler->glIndexType, offset) returned GL error: 0x506
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 1793 
E/Cocos: 21:47:48 [ERROR]: glClear(glClears) returned GL error: 0x506
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 2605 
E/Cocos: 21:47:48 [ERROR]: glDrawElements(glPrimitive, drawInfo.indexCount, gpuInputAssembler->glIndexType, offset) returned GL error: 0x506
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 1793 
E/Cocos: 21:47:48 [ERROR]: glClear(glClears) returned GL error: 0x506
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 2605 
E/Cocos: 21:47:48 [ERROR]: glDrawElements(glPrimitive, drawInfo.indexCount, gpuInputAssembler->glIndexType, offset) returned GL error: 0x506
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 2605 
E/Cocos: 21:47:48 [ERROR]: glDrawElements(glPrimitive, drawInfo.indexCount, gpuInputAssembler->glIndexType, offset) returned GL error: 0x506
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 2605 
E/Cocos: 21:47:48 [ERROR]: glDrawElements(glPrimitive, drawInfo.indexCount, gpuInputAssembler->glIndexType, offset) returned GL error: 0x506
E/Cocos: 21:47:48 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 2605 
E/Cocos: 21:47:48 [ERROR]: glDrawElements(glPrimitive, drawInfo.indexCount, gpuInputAssembler->glIndexType, offset) returned GL error: 0x506
E/Cocos: 21:47:49 [ERROR]: [ERROR] file C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp: line 1793 
E/Cocos: 21:47:49 [ERROR]: glClear(glClears) returned GL error: 0x506

Screenshot_2024-06-27-22-03-23

Steps to reproduce

Run any PostProcess effect

Minimal reproduction project

Run any PostProcess effect

minggo commented 5 months ago

Do you have a demo to reproduce it?

Skroopa commented 5 months ago

just enable PostProcess for your project and on this specific Android device you will not see anything on the screen. In any case, I created an example for you: pp_bug.zip I could help with testing, if it will be required.

minggo commented 5 months ago

Have you tried on other Android devices? I don't have the specific Android device.

Skroopa commented 5 months ago

no problems on other Android devices that I have

minggo commented 5 months ago

The issue seems caused by it

E/Cocos: 21:47:46 [ERROR]: [SE_ERROR]  (C:/ProgramData/cocos/editors/Creator/3.8.3/resources/resources/3d/engine/native/cocos/bindings/manual/jsb_global.cpp, 1370): wrong number of arguments: 0, was expecting 1

Could you please print the javascript call stack by invoking ScriptEngine::getInstance()->getCurrentStackTrace()

Skroopa commented 4 months ago

Doesn't look like it, something wrong with GLES setup itself. Texture cannot be created:

glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8_OES, 800, 480, 0, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, nullptr)
Skroopa commented 4 months ago

This line causes the issue: https://github.com/cocos/cocos-engine/blob/983232bff571bae3ca4f78325a689c86d920afb8/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp#L141 And it must be:

        case Format::DEPTH_STENCIL: return GL_DEPTH_STENCIL_OES;

Since GL_DEPTH24_STENCIL8_OES is not supported on some devices with GLES2.0 backend (see Usage Example section). Could you make a PR? Or I could do this.

minggo commented 4 months ago

@Skroopa thanks a lot. We can make a PR if it is not convenient for you to do it.

Skroopa commented 4 months ago

yes please, create the PR. NOTE: PostProcess doesn't work still, but this fix will help only with 0x501, 0x506 GL errors on texture creation.

minggo commented 4 months ago

This line causes the issue:

https://github.com/cocos/cocos-engine/blob/983232bff571bae3ca4f78325a689c86d920afb8/native/cocos/renderer/gfx-gles2/GLES2Commands.cpp#L141

And it must be:

        case Format::DEPTH_STENCIL: return GL_DEPTH_STENCIL_OES;

Since GL_DEPTH24_STENCIL8_OES is not supported on some devices with GLES2.0 backend (see Usage Example section). Could you make a PR? Or I could do this.

As less bit will have less precision. So i am not sure if it is a good idea to modify it for all android devices.

minggo commented 4 months ago

I think we should check extension to do it.