-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Compatibility Rendering (GLES3) on old and low budget devices. #87352
Conversation
Notes:
|
All the shaders in your screenshot are in the RD renderer (meaning Vulkan or DirectX), so they won't have an effect on the GLES3 renderer. |
Might be worth noting in a comment that this is to handle non-compliant devices so no one sees it and "fixes" the unnecessary divide |
f438fea
to
c6088ed
Compare
@Alex2782 about the "rotation bug" I have tested your Until I'll receive some help about the possible "Wrong Rotation Bug" cause, I'll work on doing more 2D/3D tests. |
@joined72 Could you please test with On Shader debug/logging (I think there are no other possibilities, not for GLES3) |
@joined72: Can you also see this error?
|
@Alex2782 I'm currently at home so I can't do more tests here, but from my last investigations I found this...
It doesn't seem to be a problem directly linked to a negative exponent in the PS: can you share the project used to generate the |
@joined72: ShaderTest.zip And a 3D scene is loaded after 6 seconds.
Unfortunately not, there is no 'freeze' because the shader code is invalid and video, test 'moto e5 play', empty 3D sceneweb-build_20240121_xbm8_pettyl-27-en_US-portrait_video.mp4logcat, USER ERROR: SceneShaderGLES3 on Samsung Tab S7.
The 3D scene is also not displayed as in the video. However, these logs are not output on 'moto e5 play', only UPDATE: also found the error output Rotation Bug UPDATE: I was also able to flip the 2D output using shaders. gl_Position = screen_transform * vec4(vertex, 0.0, 1.0);
gl_Position.y *= -1.0; //<--- new code maybe |
c6088ed
to
e010bb8
Compare
@joined72: android_release-2024-01-22.apk (42 MB) Can you see the 3D scene on your hardware? If you find time again...
//TODO: Dev-Tests
//++++++++++++++++++++++++++++++++
DISABLE_LIGHTMAP = true
DISABLE_LIGHT_DIRECTIONAL = true
DISABLE_LIGHT_OMNI = true
DISABLE_LIGHT_SPOT = true
DISABLE_FOG = true
//-------------------------------- !!! and !!! return nd * pow(max(distance, 0.0001), -decay); If you find time again, set these flags to |
@Alex2782 is this editor error relevant?
|
I think can be ignored, only works with Vulkan (button "Compute") |
on moto e5 play 01-22 06:13:15.736: E/godot(20576): USER ERROR: CanvasShaderGLES3: Fragment shader compilation failed:
01-22 06:13:15.736: E/godot(20576): Fragment shader compilation failed.
01-22 06:13:15.736: E/godot(20576): ERROR: 0:405: '' : Case label has to be a constant integer expression
01-22 06:13:15.736: E/godot(20576): ERROR: 0:408: '' : Case label has to be a constant integer expression
01-22 06:13:15.736: E/godot(20576): ERROR: 0:411: '' : Case label has to be a constant integer expression
01-22 06:13:15.736: E/godot(20576): ERROR: 3 compilation errors. No code generated. maybe here 01-22 06:13:15.460: I/godot(20576): 85: #define LIGHT_FLAGS_BLEND_MODE_ADD uint(0 << 16)
01-22 06:13:15.460: I/godot(20576): 86: #define LIGHT_FLAGS_BLEND_MODE_SUB uint(1 << 16)
01-22 06:13:15.460: I/godot(20576): 87: #define LIGHT_FLAGS_BLEND_MODE_MIX uint(2 << 16)
01-22 06:13:15.471: I/godot(20576): 403: switch (blend_mode) {
01-22 06:13:15.471: I/godot(20576): 404: case LIGHT_FLAGS_BLEND_MODE_ADD: {
01-22 06:13:15.471: I/godot(20576): 405: color.rgb += light_color.rgb * light_color.a;
01-22 06:13:15.471: I/godot(20576): 406: } break;
01-22 06:13:15.471: I/godot(20576): 407: case LIGHT_FLAGS_BLEND_MODE_SUB: {
01-22 06:13:15.471: I/godot(20576): 408: color.rgb -= light_color.rgb * light_color.a;
01-22 06:13:15.471: I/godot(20576): 409: } break;
01-22 06:13:15.471: I/godot(20576): 410: case LIGHT_FLAGS_BLEND_MODE_MIX: {
01-22 06:13:15.471: I/godot(20576): 411: color.rgb = mix(color.rgb, light_color.rgb, light_color.a);
01-22 06:13:15.471: I/godot(20576): 412: } break;
01-22 06:13:15.471: I/godot(20576): 413: } |
I have spent a lot of time trying to identify the real issue with the return nd * (1 / pow(max(distance, 0.0001), decay); // <== Just known solution! nd *= 1; // <== This fix the issue!!!
return nd * pow(max(distance, 0.0001), -decay; return float(uint(nd * pow(max(distance, 0.0001), -decay) * 10000.0) / 10000.0); // <= This solution WORKS! As you can see, the latest solution converts the result into an unsigned integer and, after reconverts it to a float, loses precision after the 4th decimal digit. The latest solution let me think could be an internal I think I to continuing to use the first and more concise solution, only adding a detailed comment to prevent others to change it. What do you think about it? PS: I'm continuing my tests... |
What is the |
and
#87352 (comment). (check logcat + video hidden in the |
I'll investigate on it. I think to have find a viable workaround for the the following code... glBlitFramebuffer(0, 0, rt->size.x, rt->size.y,
p_screen_rect.position.x, flip_y ? screen_rect_end.y : p_screen_rect.position.y, screen_rect_end.x, flip_y ? p_screen_rect.position.y : screen_rect_end.y,
GL_COLOR_BUFFER_BIT, GL_NEAREST);
become... bool flip_x = false;
bool landscape = screen_rect_end.x > screen_rect_end.y;
if (landscape && RenderingServer::get_singleton()->get_video_adapter_name() == "Adreno (TM) 308") {
flip_y = false;
flip_x = true;
}
glBlitFramebuffer(0, 0, rt->size.x, rt->size.y,
flip_x ? screen_rect_end.x : p_screen_rect.position.x, flip_y ? screen_rect_end.y : p_screen_rect.position.y,
flip_x ? p_screen_rect.position.x : screen_rect_end.x, flip_y ? p_screen_rect.position.y : screen_rect_end.y,
GL_COLOR_BUFFER_BIT, GL_NEAREST); On all my tests seems to works fine, try on |
The unique working solution I found currently is set |
|
218601f
to
3476bc0
Compare
I just tested this PR on the latest 4.3dev3, with a very old Samsung Galaxy S4 (I9505 - Adreno 320) Device (11 years old) and the godot-demo-projects 2D Platform Game: Standard 4.3dev3... FREEZE... :( Yes, the FPS aren't 60, but we can work on this aspect too, maybe with another PR! ;) |
3476bc0
to
ddd36ea
Compare
I have removed Mysterious things happen that I can't explain. 😃 (mostly 'freeze' or 'crash' at |
@Alex2782 I just find this... glLinkProgram crashes on Adreno 3xx EDIT: and this... |
@joined72 yes, the open source projects are full of them, with Adreno workarounds. --> Godot + Adreno Yesterday I tried new version: godot4-bunnymark-gdscript.zip some details# bunnymark
var bunnymark_target = 45.0 #60.0
var bunnymark_target_error = 1.5 #0.5 Settings for older devices. When the app is freshly installed, slightly better results are achieved. After 3 starts at the latest, the results are somewhat worse, terminating the app via system settings or deactivating the shader cache did not help. Reproduced this behavior on both devices.
|
Yes, but what I intend is that we can try to study and reproduce all the Google Filament Adreno Fixes and Workaround! ;) |
Currently, perhaps a maximum of 4% of PlayStore users have Adreno 3xx. At some point, the effort will not be worth it. For example, I had to solve a conflict on the But I would like to see at least a Godot 4 version that doesn't cause problems on old Adreno GPUs. If someone really needs it, they can always fall back on the one version. |
@Alex2782 today I tested 4.3dev3 standard (without out PR), on an Honor 7A (Adreno 505) just to test the speed on old devices, and I see another crash with the following
after I remember one of the issue out PR fixes... #86565 ... PS: in the next few days I'll receive some old/used Adreno 4XX and Adreno 5XX devices, just ordered to can do much deep tests, I'll update you as soon as I have them in my hands. ;) PPS: disabling the "Shader Compiler/Shader Cache" option I was able to run the Demo without our PR. Are always Shader related issues... EDIT: anyway the speed of the 2D Platform Demo on the Adreno 505 device is of about 57/58 FPS, that is a more that respectable speed to can play the game. |
Oh ok, I think in the |
I left comments in the code on what is supposed to happen, but basically the white triangle is testing that adding material to a mesh surface in 2D doesn't cause a crash. That operation was never actually supported in 2D, so triangle is white. |
@Alex2782 the commit 08f4560 caused a new crash:
To fix it we have to replace: fog_amount = 1 - exp(min(0.0, -length(vertex) * scene_data.fog_density)); with... fog_amount = 1.0 - exp(min(0.0, -length(vertex) * scene_data.fog_density)); |
Co-Authored-By: joined72 <[email protected]>
0636f78
to
e17cecf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me! I can't validate the android platform changes, but they look safe. The rendering changes all seem fine from my perspective, so I would go ahead and merge this now
So does this PR fixes shader-related crashes too (using even the simplest .glsl shader), such as #74954 or the last two mentioned below #82602 and #79760? (not sure about #86037 which doesn't mention a shader in description), on devices that do not crash when not using a shader?
I have compiled Godot recently so I could try a quick recompile with this PR and test on my Fairphone 3, which crashed on even the simple shader above (Sprite + ShaderMaterial using it). |
Fixes #86112
Fixes #86565
Tested devices:
(Adreno 3xx)
(Adreno 3xx)
(Adreno 320)
(Adreno 418)
(Adreno 505)
(Adreno 505)
(Adreno 650)
Mali-T830
TODOs
glLinkProgram
shader freeze bug