diff options
author | Dalai Felinto <dalai@blender.org> | 2020-03-12 19:21:58 +0300 |
---|---|---|
committer | Dalai Felinto <dalai@blender.org> | 2020-03-13 17:40:20 +0300 |
commit | 5593efec01c211a55324b0e96ab6773aa713bd40 (patch) | |
tree | da3c327f873da540279ae0f92b55526f54f81481 /source/blender/blenkernel/intern/image.c | |
parent | 93ac4709ebe8c3be3d26b376248ce263ecc1974e (diff) |
Fix stereoscopy drawing for camera background
Part of the fix was to get gputexture to use an array to accomodate each
eye. This takes care of viewports showing individual Left or Right
views.
For the combined view the fix was in overlay_image.c:camera_background_images_stereo_setup.
Note 1: Referece images are still not supporting stereo.
Note 2: For painting, and getting image bindcode I'm hardcording a
single-view experience.
Note 3: Without D6922 stereo is too broken to even test this patch.
With D6922 + this patch the fullscreen modes work (anaglyph/interlace
not yet).
Differential Revision: D7143
Diffstat (limited to 'source/blender/blenkernel/intern/image.c')
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 37e05977450..22ec1fe1b98 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -145,8 +145,10 @@ static void image_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, c BLI_duplicatelist(&image_dst->tiles, &image_src->tiles); - for (int i = 0; i < TEXTARGET_COUNT; i++) { - image_dst->gputexture[i] = NULL; + for (int eye = 0; eye < 2; eye++) { + for (int i = 0; i < TEXTARGET_COUNT; i++) { + image_dst->gputexture[i][eye] = NULL; + } } if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) { @@ -529,9 +531,11 @@ bool BKE_image_scale(Image *image, int width, int height) bool BKE_image_has_opengl_texture(Image *ima) { - for (int i = 0; i < TEXTARGET_COUNT; i++) { - if (ima->gputexture[i] != NULL) { - return true; + for (int eye = 0; eye < 2; eye++) { + for (int i = 0; i < TEXTARGET_COUNT; i++) { + if (ima->gputexture[i][eye] != NULL) { + return true; + } } } return false; @@ -3318,9 +3322,11 @@ static void image_free_tile(Image *ima, ImageTile *tile) continue; } - if (ima->gputexture[i] != NULL) { - GPU_texture_free(ima->gputexture[i]); - ima->gputexture[i] = NULL; + for (int eye = 0; eye < 2; eye++) { + if (ima->gputexture[i][eye] != NULL) { + GPU_texture_free(ima->gputexture[i][eye]); + ima->gputexture[i][eye] = NULL; + } } } @@ -3587,14 +3593,16 @@ ImageTile *BKE_image_add_tile(struct Image *ima, int tile_number, const char *la BLI_strncpy(tile->label, label, sizeof(tile->label)); } - /* Reallocate GPU tile array. */ - if (ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY] != NULL) { - GPU_texture_free(ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY]); - ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY] = NULL; - } - if (ima->gputexture[TEXTARGET_TEXTURE_TILE_MAPPING] != NULL) { - GPU_texture_free(ima->gputexture[TEXTARGET_TEXTURE_TILE_MAPPING]); - ima->gputexture[TEXTARGET_TEXTURE_TILE_MAPPING] = NULL; + for (int eye = 0; eye < 2; eye++) { + /* Reallocate GPU tile array. */ + if (ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY][eye] != NULL) { + GPU_texture_free(ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY][eye]); + ima->gputexture[TEXTARGET_TEXTURE_2D_ARRAY][eye] = NULL; + } + if (ima->gputexture[TEXTARGET_TEXTURE_TILE_MAPPING][eye] != NULL) { + GPU_texture_free(ima->gputexture[TEXTARGET_TEXTURE_TILE_MAPPING][eye]); + ima->gputexture[TEXTARGET_TEXTURE_TILE_MAPPING][eye] = NULL; + } } return tile; |