diff options
author | Jason Fielder <jason_apple> | 2022-03-30 21:24:39 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-03-30 21:31:12 +0300 |
commit | 922d53a791d53b77e5ffcf65003555fae0a0e883 (patch) | |
tree | 7804945d62f0c6366678efdffd4dffe98e5988e8 /source/blender/draw/intern/draw_manager.c | |
parent | 84fde382e43cff6407bfa3587fec9bd570cf9123 (diff) |
Metal: Adding alternative support for GPU_PRIM_TRI_FAN/LINE_LOOP For Metal backend.
- Metal uniform array compatibility in DRW module.
- Guard OpenGL-specific workarounds and flushes behind GPU_type_matches_ex API guard. Add further render boundaries for render paths called outside of the main loop.
Authored by Apple: Michael Parkin-White
Ref: T96261
Reviewed By: fclem
Differential Revision: https://developer.blender.org/D14438
Diffstat (limited to 'source/blender/draw/intern/draw_manager.c')
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 39ae01697a1..75c27937f25 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -55,6 +55,7 @@ #include "GPU_framebuffer.h" #include "GPU_immediate.h" #include "GPU_matrix.h" +#include "GPU_platform.h" #include "GPU_shader_shared.h" #include "GPU_state.h" #include "GPU_uniform_buffer.h" @@ -1706,7 +1707,9 @@ void DRW_draw_render_loop_ex(struct Depsgraph *depsgraph, drw_engines_draw_scene(); /* Fix 3D view "lagging" on APPLE and WIN32+NVIDIA. (See T56996, T61474) */ - GPU_flush(); + if (GPU_type_matches_ex(GPU_DEVICE_ANY, GPU_OS_ANY, GPU_DRIVER_ANY, GPU_BACKEND_OPENGL)) { + GPU_flush(); + } DRW_stats_reset(); @@ -1938,6 +1941,9 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph) }; drw_context_state_init(); + /* Begin GPU workload Boundary */ + GPU_render_begin(); + const int size[2] = {engine->resolution_x, engine->resolution_y}; drw_manager_init(&DST, NULL, size); @@ -1993,6 +1999,9 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph) /* Reset state after drawing */ DRW_state_reset(); + + /* End GPU workload Boundary */ + GPU_render_end(); } void DRW_render_object_iter( @@ -2072,7 +2081,10 @@ void DRW_custom_pipeline(DrawEngineType *draw_engine_type, * resources as the main thread (viewport) may lead to data * races and undefined behavior on certain drivers. Using * GPU_finish to sync seems to fix the issue. (see T62997) */ - GPU_finish(); + eGPUBackendType type = GPU_backend_get_type(); + if (type == GPU_BACKEND_OPENGL) { + GPU_finish(); + } drw_manager_exit(&DST); } @@ -2173,7 +2185,9 @@ void DRW_draw_render_loop_2d_ex(struct Depsgraph *depsgraph, drw_engines_draw_scene(); /* Fix 3D view being "laggy" on macos and win+nvidia. (See T56996, T61474) */ - GPU_flush(); + if (GPU_type_matches_ex(GPU_DEVICE_ANY, GPU_OS_ANY, GPU_DRIVER_ANY, GPU_BACKEND_OPENGL)) { + GPU_flush(); + } if (DST.draw_ctx.evil_C) { DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); @@ -3094,6 +3108,7 @@ void DRW_opengl_context_enable_ex(bool UNUSED(restore)) * This shall remain in effect until immediate mode supports * multiple threads. */ BLI_ticket_mutex_lock(DST.gl_context_mutex); + GPU_render_begin(); WM_opengl_context_activate(DST.gl_context); GPU_context_active_set(DST.gpu_context); } @@ -3105,7 +3120,9 @@ void DRW_opengl_context_disable_ex(bool restore) #ifdef __APPLE__ /* Need to flush before disabling draw context, otherwise it does not * always finish drawing and viewport can be empty or partially drawn */ - GPU_flush(); + if (GPU_type_matches_ex(GPU_DEVICE_ANY, GPU_OS_MAC, GPU_DRIVER_ANY, GPU_BACKEND_OPENGL)) { + GPU_flush(); + } #endif if (BLI_thread_is_main() && restore) { @@ -3116,6 +3133,10 @@ void DRW_opengl_context_disable_ex(bool restore) GPU_context_active_set(NULL); } + /* Render boundaries are opened and closed here as this may be + * called outside of an existing render loop. */ + GPU_render_end(); + BLI_ticket_mutex_unlock(DST.gl_context_mutex); } } |