Workbench: Fix workbench broken on some config due to usuned fb slot
authorClément Foucault <foucault.clem@gmail.com>
Tue, 4 Dec 2018 19:29:30 +0000 (20:29 +0100)
committerClément Foucault <foucault.clem@gmail.com>
Wed, 5 Dec 2018 01:51:48 +0000 (02:51 +0100)
This seems to be a driver bug. Only windows + Radeon HD 7500M seems
to be affected. Fix can be extended to more config if necessary.

source/blender/draw/engines/workbench/workbench_deferred.c
source/blender/gpu/GPU_extensions.h
source/blender/gpu/intern/gpu_extensions.c

index a07c9f37ac9958e890d8c60a42b2f2b8ef8c45f3..1e401b278bece3ed9d1a1376f3b8a35e20908cb8 100644 (file)
@@ -403,6 +403,7 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata)
                const int size[2] = {(int)viewport_size[0], (int)viewport_size[1]};
                const GPUTextureFormat nor_tex_format = NORMAL_ENCODING_ENABLED() ? GPU_RG16 : GPU_RGBA32F;
                const GPUTextureFormat comp_tex_format = DRW_state_is_image_render() ? GPU_RGBA16F : GPU_R11F_G11F_B10F;
+               const GPUTextureFormat id_tex_format = OBJECT_ID_PASS_ENABLED(wpd) ? GPU_R32UI : GPU_R8;
 
                e_data.object_id_tx = NULL;
                e_data.color_buffer_tx = NULL;
@@ -412,8 +413,9 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata)
 
                e_data.color_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_RGBA8, &draw_engine_workbench_solid);
                e_data.composite_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], comp_tex_format, &draw_engine_workbench_solid);
-               if (OBJECT_ID_PASS_ENABLED(wpd)) {
-                       e_data.object_id_tx = DRW_texture_pool_query_2D(size[0], size[1], GPU_R32UI, &draw_engine_workbench_solid);
+
+               if (OBJECT_ID_PASS_ENABLED(wpd) || GPU_unused_fb_slot_workaround()) {
+                       e_data.object_id_tx = DRW_texture_pool_query_2D(size[0], size[1], id_tex_format, &draw_engine_workbench_solid);
                }
                if (NORMAL_VIEWPORT_PASS_ENABLED(wpd)) {
                        e_data.normal_buffer_tx = DRW_texture_pool_query_2D(size[0], size[1], nor_tex_format, &draw_engine_workbench_solid);
index 12a640747dada65beaed0254dadda00c260b8c8d..22eb917f0bd4608fc160ad8286fbf1c37d729012 100644 (file)
@@ -54,6 +54,7 @@ int GPU_color_depth(void);
 void GPU_get_dfdy_factors(float fac[2]);
 bool GPU_mip_render_workaround(void);
 bool GPU_depth_blitting_workaround(void);
+bool GPU_unused_fb_slot_workaround(void);
 
 bool GPU_mem_stats_supported(void);
 void GPU_mem_stats_get(int *totalmem, int *freemem);
index 99f770b4d03e0a54ea25cf0691d8228f013d4aea..92d91bd440d50c3d6450d867ce90380079b3eb72 100644 (file)
@@ -95,6 +95,9 @@ static struct GPUGlobal {
         * GPU_DEPTH32F_STENCIL8. Then Blitting depth will work but blitting stencil will
         * still be broken. */
        bool depth_blitting_workaround;
+       /* Crappy driver don't know how to map framebuffer slot to output vars...
+        * We need to have no "holes" in the output buffer slots. */
+       bool unused_fb_slot_workaround;
 } GG = {1, 0};
 
 
@@ -211,6 +214,11 @@ bool GPU_depth_blitting_workaround(void)
        return GG.depth_blitting_workaround;
 }
 
+bool GPU_unused_fb_slot_workaround(void)
+{
+       return GG.unused_fb_slot_workaround;
+}
+
 void gpu_extensions_init(void)
 {
        /* during 2.8 development each platform has its own OpenGL minimum requirements
@@ -262,6 +270,14 @@ void gpu_extensions_init(void)
                GG.device = GPU_DEVICE_ATI;
                GG.driver = GPU_DRIVER_OFFICIAL;
 
+#ifdef _WIN32
+               if (strstr(vendor, "Radeon HD 7500M") ||
+                   strstr(vendor, "Radeon HD 7570M"))
+               {
+                       GG.unused_fb_slot_workaround = true;
+               }
+#endif
+
 #if defined(__APPLE__)
                if (strstr(renderer, "AMD Radeon Pro") ||
                    strstr(renderer, "AMD Radeon R9") ||