diff options
author | Jeroen Bakker <jeroen@blender.org> | 2022-03-01 12:45:19 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2022-03-01 12:45:19 +0300 |
commit | d743ef91df743941a859a98fb6a94e3982c234b5 (patch) | |
tree | eefa923fb1dadc025ef7f1e69b9c8d06f27402f6 /source | |
parent | 4a4701b43c53d1a4946e224821ba398548b22043 (diff) |
Fix 3d texture painting artifacts.
When dimension of images aren't a multifold of 256 parts of the gpu
textures are not updated. This patch will calculate the correct part of
the image that needs to be reuploaded.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/image_gpu.cc | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/source/blender/blenkernel/intern/image_gpu.cc b/source/blender/blenkernel/intern/image_gpu.cc index 42dcfcd7aa9..d854c043a3e 100644 --- a/source/blender/blenkernel/intern/image_gpu.cc +++ b/source/blender/blenkernel/intern/image_gpu.cc @@ -338,19 +338,25 @@ static void image_gpu_texture_partial_update_changes_available( Image *image, PartialUpdateChecker<ImageTileData>::CollectResult &changes) { while (changes.get_next_change() == ePartialUpdateIterResult::ChangeAvailable) { - const int tile_offset_x = changes.changed_region.region.xmin; - const int tile_offset_y = changes.changed_region.region.ymin; - const int tile_width = min_ii(changes.tile_data.tile_buffer->x, - BLI_rcti_size_x(&changes.changed_region.region)); - const int tile_height = min_ii(changes.tile_data.tile_buffer->y, - BLI_rcti_size_y(&changes.changed_region.region)); + /* Calculate the clipping region with the tile buffer. + * TODO(jbakker): should become part of ImageTileData to deduplicate with image engine. */ + rcti buffer_rect; + BLI_rcti_init( + &buffer_rect, 0, changes.tile_data.tile_buffer->x, 0, changes.tile_data.tile_buffer->y); + rcti clipped_update_region; + const bool has_overlap = BLI_rcti_isect( + &buffer_rect, &changes.changed_region.region, &clipped_update_region); + if (!has_overlap) { + continue; + } + image_update_gputexture_ex(image, changes.tile_data.tile, changes.tile_data.tile_buffer, - tile_offset_x, - tile_offset_y, - tile_width, - tile_height); + clipped_update_region.xmin, + clipped_update_region.ymin, + BLI_rcti_size_x(&clipped_update_region), + BLI_rcti_size_y(&clipped_update_region)); } } |