Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2022-08-19 21:11:21 +0300
committerBrecht Van Lommel <brecht@blender.org>2022-08-19 21:40:44 +0300
commit51b79e4775e1f661df9aac60b7d355b72aa8b748 (patch)
treedf9903deed89aa795a9ba3f9dfef64e60f543aeb /intern
parent4b62970dd378164a9f5d4592f923ae92a894da87 (diff)
Fix T96133: Cycles viewport render crash with NVIDIA GPUs on macOS
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/blender/CMakeLists.txt1
-rw-r--r--intern/cycles/blender/display_driver.cpp24
2 files changed, 23 insertions, 2 deletions
diff --git a/intern/cycles/blender/CMakeLists.txt b/intern/cycles/blender/CMakeLists.txt
index 63d89221d20..a64bcc43191 100644
--- a/intern/cycles/blender/CMakeLists.txt
+++ b/intern/cycles/blender/CMakeLists.txt
@@ -9,6 +9,7 @@ set(INC
../../../source/blender/makesdna
../../../source/blender/makesrna
../../../source/blender/blenlib
+ ../../../source/blender/gpu
${CMAKE_BINARY_DIR}/source/blender/makesrna/intern
)
diff --git a/intern/cycles/blender/display_driver.cpp b/intern/cycles/blender/display_driver.cpp
index 61cd88fb433..30ad3ecad51 100644
--- a/intern/cycles/blender/display_driver.cpp
+++ b/intern/cycles/blender/display_driver.cpp
@@ -7,6 +7,8 @@
#include "util/log.h"
#include "util/opengl.h"
+#include "GPU_platform.h"
+
extern "C" {
struct RenderEngine;
@@ -507,6 +509,7 @@ class DrawTileAndPBO {
DrawTile tile;
GLPixelBufferObject buffer_object;
+ bool need_update_texture_pixels = false;
};
/* --------------------------------------------------------------------
@@ -585,6 +588,8 @@ void BlenderDisplayDriver::next_tile_begin()
/* Moving to the next tile without giving render data for the current tile is not an expected
* situation. */
DCHECK(!need_clear_);
+ /* Texture should have been updated from the PBO at this point. */
+ DCHECK(!tiles_->current_tile.need_update_texture_pixels);
tiles_->finished_tiles.tiles.emplace_back(std::move(tiles_->current_tile.tile));
}
@@ -702,8 +707,18 @@ void BlenderDisplayDriver::update_end()
* One concern with this approach is that if the update happens more often than drawing then
* doing the unpack here occupies GPU transfer for no good reason. However, the render scheduler
* takes care of ensuring updates don't happen that often. In regular applications redraw will
- * happen much more often than this update. */
- update_tile_texture_pixels(tiles_->current_tile);
+ * happen much more often than this update.
+ *
+ * On some older GPUs on macOS, there is a driver crash when updating the texture for viewport
+ * renders while Blender is drawing. As a workaround update texture during draw, under assumption
+ * that there is no graphics interop on macOS and viewport render has a single tile. */
+ if (use_gl_context_ &&
+ GPU_type_matches_ex(GPU_DEVICE_NVIDIA, GPU_OS_MAC, GPU_DRIVER_ANY, GPU_BACKEND_ANY)) {
+ tiles_->current_tile.need_update_texture_pixels = true;
+ }
+ else {
+ update_tile_texture_pixels(tiles_->current_tile);
+ }
gl_upload_sync_ = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
glFlush();
@@ -953,6 +968,11 @@ void BlenderDisplayDriver::draw(const Params &params)
glEnableVertexAttribArray(texcoord_attribute);
glEnableVertexAttribArray(position_attribute);
+ if (tiles_->current_tile.need_update_texture_pixels) {
+ update_tile_texture_pixels(tiles_->current_tile);
+ tiles_->current_tile.need_update_texture_pixels = false;
+ }
+
draw_tile(zoom_,
texcoord_attribute,
position_attribute,