diff options
author | Jeroen Bakker <jeroen@blender.org> | 2021-06-30 09:59:54 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2021-06-30 10:01:10 +0300 |
commit | c5c4727d6ed730644786abcac554ac8ee1e12b73 (patch) | |
tree | ff7bea30900987af8bb7cd9cb6bb37b0b8191f3f | |
parent | 8dd18a77e72444c5a9cc60c1043fa96b28260d9a (diff) |
Fix T89405: Viewport Render Preview glitching (AMD)
AMD Drivers didn't report an additional space in the renderer. This made
testing for the HQ workaround fail and the issue appeared back on
certain cards.
This fix will test with surrounding spaces or if the renderer name
endswith the given string. If any of these are the case the hq normals
workaround will be enabled.
Original patch {2262d6c45adf}.
-rw-r--r-- | source/blender/gpu/intern/gpu_extensions.c | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index 57243f4c62d..16d3d858b27 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -26,6 +26,7 @@ #include "BLI_math_base.h" #include "BLI_math_vector.h" +#include "BLI_string.h" #include "BLI_utildefines.h" #include "BKE_global.h" @@ -244,6 +245,19 @@ bool GPU_use_hq_normals_workaround(void) return GG.use_hq_normals_workaround; } +static bool match_renderer(const char *renderer, int items_len, const char **items) +{ + char wrapped[16]; + for (int i = 0; i < items_len; i++) { + const char *item = items[i]; + BLI_snprintf(wrapped, sizeof(wrapped), " %s ", item); + if (strstr(renderer, wrapped) || BLI_str_endswith(renderer, item)) { + return true; + } + } + return false; +} + void gpu_extensions_init(void) { /* during 2.8 development each platform has its own OpenGL minimum requirements @@ -330,15 +344,28 @@ void gpu_extensions_init(void) * Vertex and Face normals would still render resulting in undefined behavior during selection * and rendering. */ if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_OFFICIAL)) { - /* On Linux the driver does not report its version. Test the OpenGL version in stead. */ - if (strstr(renderer, " RX 460 ") || strstr(renderer, " RX 470 ") || - strstr(renderer, " RX 480 ") || strstr(renderer, " RX 490 ") || - strstr(renderer, " RX 560 ") || strstr(renderer, " RX 560X ") || - strstr(renderer, " RX 570 ") || strstr(renderer, " RX 580 ") || - strstr(renderer, " RX 580X ") || strstr(renderer, " RX 590 ") || - strstr(renderer, " RX550/550 ") || strstr(renderer, "(TM) 520 ") || - strstr(renderer, "(TM) 530 ") || strstr(renderer, "(TM) 535 ") || - strstr(renderer, " R5 ") || strstr(renderer, " R7 ") || strstr(renderer, " R9 ")) { + static const char *failing_renderers[] = { + "RX 460", + "RX 470", + "RX 480", + "RX 490", + "RX 560", + "RX 560X", + "RX 570", + "RX 580", + "RX 580X", + "RX 590", + "RX550/550", + "(TM) 520", + "(TM) 530", + "(TM) 535", + "R5", + "R7", + "R9", + }; + static const int num_failing_renderers = 17; + + if (match_renderer(renderer, num_failing_renderers, failing_renderers)) { GG.use_hq_normals_workaround = true; } } |