[Bf-blender-cvs] [db7c7486fd8] blender-v2.83-release: GPU: Add HQ normals workaround.

Jeroen Bakker noreply at git.blender.org
Wed Jan 13 11:41:51 CET 2021


Commit: db7c7486fd88a48543abea01538e9b8026103e39
Author: Jeroen Bakker
Date:   Mon Jan 4 11:41:54 2021 +0100
Branches: blender-v2.83-release
https://developer.blender.org/rBdb7c7486fd88a48543abea01538e9b8026103e39

GPU: Add HQ normals workaround.

This change makes it possible for platforms to only support high quality
normal rendering. This is part of {T82856} where current AMD drivers
running on the polaris architecture does not support the low quality
setting due to a driver bug.

In a next commit the work around will be enabled.

===================================================================

M	source/blender/draw/intern/draw_cache_extract_mesh.c
M	source/blender/draw/intern/draw_cache_impl_curve.c
M	source/blender/draw/intern/draw_cache_impl_displist.c
M	source/blender/draw/intern/draw_cache_impl_volume.c
M	source/blender/gpu/GPU_extensions.h
M	source/blender/gpu/intern/gpu_extensions.c

===================================================================

diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.c b/source/blender/draw/intern/draw_cache_extract_mesh.c
index 780e4fdea7c..6eeb3c7abdc 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh.c
+++ b/source/blender/draw/intern/draw_cache_extract_mesh.c
@@ -4543,7 +4543,8 @@ static void extract_task_create(TaskPool *task_pool,
                                 int32_t *task_counter)
 {
   BLI_assert(scene != NULL);
-  const bool do_hq_normals = (scene->r.perf_flag & SCE_PERF_HQ_NORMALS) != 0;
+  const bool do_hq_normals = (scene->r.perf_flag & SCE_PERF_HQ_NORMALS) != 0 ||
+                             GPU_use_hq_normals_workaround();
   if (do_hq_normals && (extract == &extract_lnor)) {
     extract = &extract_lnor_hq;
   }
diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c
index 4a8c19f0839..8da40ba95f2 100644
--- a/source/blender/draw/intern/draw_cache_impl_curve.c
+++ b/source/blender/draw/intern/draw_cache_impl_curve.c
@@ -36,6 +36,7 @@
 #include "BKE_font.h"
 
 #include "GPU_batch.h"
+#include "GPU_extensions.h"
 #include "GPU_material.h"
 #include "GPU_texture.h"
 
@@ -633,11 +634,11 @@ static void curve_create_edit_curves_nor(CurveRenderData *rdata,
                                          GPUVertBuf *vbo_curves_nor,
                                          const Scene *scene)
 {
-  const bool do_hq_normals = (scene->r.perf_flag & SCE_PERF_HQ_NORMALS) != 0;
+  const bool do_hq_normals = (scene->r.perf_flag & SCE_PERF_HQ_NORMALS) != 0 ||
+                             GPU_use_hq_normals_workaround();
 
   static GPUVertFormat format = {0};
   static GPUVertFormat format_hq = {0};
-  /* TODO(jeroen): add support for high quality normals */
   static struct {
     uint pos, nor, tan, rad;
     uint pos_hq, nor_hq, tan_hq, rad_hq;
diff --git a/source/blender/draw/intern/draw_cache_impl_displist.c b/source/blender/draw/intern/draw_cache_impl_displist.c
index ccaedc09444..b8e5d1a09e7 100644
--- a/source/blender/draw/intern/draw_cache_impl_displist.c
+++ b/source/blender/draw/intern/draw_cache_impl_displist.c
@@ -177,7 +177,8 @@ static int displist_indexbufbuilder_tess_set(
 
 void DRW_displist_vertbuf_create_pos_and_nor(ListBase *lb, GPUVertBuf *vbo, const Scene *scene)
 {
-  const bool do_hq_normals = (scene->r.perf_flag & SCE_PERF_HQ_NORMALS) != 0;
+  const bool do_hq_normals = (scene->r.perf_flag & SCE_PERF_HQ_NORMALS) != 0 ||
+                             GPU_use_hq_normals_workaround();
 
   static GPUVertFormat format = {0};
   static GPUVertFormat format_hq = {0};
@@ -485,7 +486,8 @@ void DRW_displist_vertbuf_create_loop_pos_and_nor_and_uv_and_tan(ListBase *lb,
                                                                  GPUVertBuf *vbo_tan,
                                                                  const Scene *scene)
 {
-  const bool do_hq_normals = (scene->r.perf_flag & SCE_PERF_HQ_NORMALS) != 0;
+  const bool do_hq_normals = (scene->r.perf_flag & SCE_PERF_HQ_NORMALS) != 0 ||
+                             GPU_use_hq_normals_workaround();
 
   static GPUVertFormat format_pos_nor = {0};
   static GPUVertFormat format_pos_nor_hq = {0};
diff --git a/source/blender/draw/intern/draw_cache_impl_volume.c b/source/blender/draw/intern/draw_cache_impl_volume.c
index 64d6bbdd474..a2e343322e9 100644
--- a/source/blender/draw/intern/draw_cache_impl_volume.c
+++ b/source/blender/draw/intern/draw_cache_impl_volume.c
@@ -40,6 +40,7 @@
 #include "BKE_volume_render.h"
 
 #include "GPU_batch.h"
+#include "GPU_extensions.h"
 #include "GPU_texture.h"
 
 #include "DRW_render.h"
@@ -151,7 +152,8 @@ static void drw_volume_wireframe_cb(
   Scene *scene = data->scene;
   Volume *volume = data->volume;
   VolumeBatchCache *cache = volume->batch_cache;
-  const bool do_hq_normals = (scene->r.perf_flag & SCE_PERF_HQ_NORMALS) != 0;
+  const bool do_hq_normals = (scene->r.perf_flag & SCE_PERF_HQ_NORMALS) != 0 ||
+                             GPU_use_hq_normals_workaround();
 
   /* Create vertex buffer. */
   static GPUVertFormat format = {0};
diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h
index ab54148a2ff..6d46ae9fcf4 100644
--- a/source/blender/gpu/GPU_extensions.h
+++ b/source/blender/gpu/GPU_extensions.h
@@ -50,6 +50,7 @@ bool GPU_depth_blitting_workaround(void);
 bool GPU_unused_fb_slot_workaround(void);
 bool GPU_context_local_shaders_workaround(void);
 bool GPU_texture_copy_workaround(void);
+bool GPU_use_hq_normals_workaround(void);
 bool GPU_crappy_amd_driver(void);
 
 bool GPU_mem_stats_supported(void);
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c
index 6d997e3381a..9a114c7cde5 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -99,6 +99,7 @@ static struct GPUGlobal {
   /* Intel drivers exhibit artifacts when using glCopyImageSubData & workbench antialiasing.
    * (see T76273) */
   bool texture_copy_workaround;
+  bool use_hq_normals_workaround;
 } GG = {1, 0};
 
 static void gpu_detect_mip_render_workaround(void)
@@ -238,6 +239,11 @@ bool GPU_crappy_amd_driver(void)
   return GG.broken_amd_driver;
 }
 
+bool GPU_use_hq_normals_workaround(void)
+{
+  return GG.use_hq_normals_workaround;
+}
+
 void gpu_extensions_init(void)
 {
   /* during 2.8 development each platform has its own OpenGL minimum requirements



More information about the Bf-blender-cvs mailing list