Skip to content

Commit

Permalink
Fix Adreno 3xx compatibility for devices with newer driver versions
Browse files Browse the repository at this point in the history
Co-Authored-By: Hugo Locurcio <[email protected]>
Co-Authored-By: Clay John <[email protected]>
  • Loading branch information
3 people committed Jun 11, 2024
1 parent 5f1184e commit aed6b02
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
6 changes: 3 additions & 3 deletions drivers/gles3/rasterizer_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ void RasterizerGLES3::initialize() {
Engine::get_singleton()->print_header(vformat("OpenGL API %s - Compatibility - Using Device: %s - %s", RS::get_singleton()->get_video_adapter_api_version(), RS::get_singleton()->get_video_adapter_vendor(), RS::get_singleton()->get_video_adapter_name()));

// FLIP XY Bug: Are more devices affected?
// Confirmed so far: all Adreno 3xx
// Confirmed so far: all Adreno 3xx with old driver (until 2018)
// ok on some tested Adreno devices: 4xx, 5xx and 6xx
flip_xy_bugfix = GLES3::Config::get_singleton()->adreno_3xx_compatibility;
flip_xy_workaround = GLES3::Config::get_singleton()->flip_xy_workaround;
}

void RasterizerGLES3::finalize() {
Expand Down Expand Up @@ -411,7 +411,7 @@ void RasterizerGLES3::_blit_render_target_to_screen(RID p_render_target, Display
// Adreno (TM) 3xx devices have a bug that create wrong Landscape rotation of 180 degree
// Reversing both the X and Y axis is equivalent to rotating 180 degrees
bool flip_x = false;
if (flip_xy_bugfix && screen_rect_end.x > screen_rect_end.y) {
if (flip_xy_workaround && screen_rect_end.x > screen_rect_end.y) {
flip_y = !flip_y;
flip_x = !flip_x;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/gles3/rasterizer_gles3.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class RasterizerGLES3 : public RendererCompositor {
float delta = 0;

double time_total = 0.0;
bool flip_xy_bugfix = false;
bool flip_xy_workaround = false;

static bool gles_over_gl;

Expand Down
27 changes: 25 additions & 2 deletions drivers/gles3/storage/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,31 @@ Config::Config() {

//Adreno 3xx Compatibility
const String rendering_device_name = String::utf8((const char *)glGetString(GL_RENDERER));
//TODO: Check the number between 300 and 399(?)
adreno_3xx_compatibility = (rendering_device_name.left(13) == "Adreno (TM) 3");
if (rendering_device_name.left(13) == "Adreno (TM) 3") {
flip_xy_workaround = true;
disable_particles_workaround = true;

// ignore driver version 331+
const String gl_version = String::utf8((const char *)glGetString(GL_VERSION));
// Adreno 3xx examples (https://opengles.gpuinfo.org/listreports.php):
// ===========================================================================
// OpenGL ES 3.0 [email protected] AU@ (CL@)
// OpenGL ES 3.0 [email protected] AU@ (GIT@I96aee987eb)
// OpenGL ES 3.0 [email protected] AU@ (GIT@Ifd751822f5)
// OpenGL ES 3.0 [email protected] [email protected] (GIT@Ie4790512f3)
// OpenGL ES 3.0 [email protected] AU@ (GIT@I109c45a694)
// OpenGL ES 3.0 [email protected] (GIT@35e467f, Ice9844a736) (Date:04/15/19)
// OpenGL ES 3.0 [email protected] (GIT@d39f783, I79de86aa2c, 1591296226) (Date:06/04/20)
// OpenGL ES 3.0 [email protected] (GIT@09fef447e8, I1fe547a144, 1661493934) (Date:08/25/22)
String driver_version = gl_version.get_slice("V@", 1).get_slice(" ", 0);
if (driver_version.is_valid_float() && driver_version.to_float() >= 331.0) {
flip_xy_workaround = false;

//TODO: also 'GPUParticles'?
//https://github.com/godotengine/godot/issues/92662#issuecomment-2161199477
//disable_particles_workaround = false;
}
}
}

Config::~Config() {
Expand Down
4 changes: 3 additions & 1 deletion drivers/gles3/storage/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ class Config {
bool rt_msaa_multiview_supported = false;
bool multiview_supported = false;

bool adreno_3xx_compatibility = false;
// Adreno 3XX compatibility
bool disable_particles_workaround = false; // set to 'true' to disable 'GPUParticles'
bool flip_xy_workaround = false;

#ifdef ANDROID_ENABLED
PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC eglFramebufferTextureMultiviewOVR = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions drivers/gles3/storage/particles_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void ParticlesStorage::particles_set_mode(RID p_particles, RS::ParticlesMode p_m
}

void ParticlesStorage::particles_set_emitting(RID p_particles, bool p_emitting) {
ERR_FAIL_COND_MSG(GLES3::Config::get_singleton()->adreno_3xx_compatibility, "Due to driver bugs, GPUParticles are not supported on Adreno 3XX devices. Please use CPUParticles instead.");
ERR_FAIL_COND_MSG(GLES3::Config::get_singleton()->disable_particles_workaround, "Due to driver bugs, GPUParticles are not supported on Adreno 3XX devices. Please use CPUParticles instead.");

Particles *particles = particles_owner.get_or_null(p_particles);
ERR_FAIL_NULL(particles);
Expand All @@ -131,7 +131,7 @@ void ParticlesStorage::particles_set_emitting(RID p_particles, bool p_emitting)
}

bool ParticlesStorage::particles_get_emitting(RID p_particles) {
if (GLES3::Config::get_singleton()->adreno_3xx_compatibility) {
if (GLES3::Config::get_singleton()->disable_particles_workaround) {
return false;
}

Expand Down

0 comments on commit aed6b02

Please sign in to comment.