diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-02-18 15:23:49 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-02-18 18:52:01 +0300 |
commit | 0e3a2acbfa6998b3a1ec967f3c25f7e12e0cf8fb (patch) | |
tree | dde289c6fbe219951ae5618866b33dfcfa3325e4 /source/blender/gpu | |
parent | 286c34b4abb0436fb370c8d49fd73738dabc0fcf (diff) |
Fix T57457: animated image sequences not working in Eevee.
The dependency graph now handles updating image users to point to the current
frame, and tags images to be refreshed on the GPU. The image editor user is
still updated outside of the dependency graph.
We still do not support multiple image users using a different current frame
in the same image, same as 2.7. This may require adding a GPU image texture
cache to keep memory usage under control. Things like rendering an animation
while the viewport stays fixed at the current frame works though.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/GPU_texture.h | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 34 |
2 files changed, 21 insertions, 15 deletions
diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h index 8efd721b800..5732bad81a9 100644 --- a/source/blender/gpu/GPU_texture.h +++ b/source/blender/gpu/GPU_texture.h @@ -174,7 +174,7 @@ GPUTexture *GPU_texture_create_buffer( GPUTexture *GPU_texture_from_bindcode(int textarget, int bindcode); GPUTexture *GPU_texture_from_blender( - struct Image *ima, struct ImageUser *iuser, int textarget, bool is_data, double time); + struct Image *ima, struct ImageUser *iuser, int textarget, bool is_data); GPUTexture *GPU_texture_from_preview(struct PreviewImage *prv, int mipmap); void GPU_texture_add_mipmap(GPUTexture *tex, eGPUDataFormat gpu_data_format, int miplvl, const void *pixels); diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index a3a220ad530..f6654ecfd0b 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -75,6 +75,8 @@ # include "smoke_API.h" #endif +static void gpu_free_image_immediate(Image *ima); + //* Checking powers of two for images since OpenGL ES requires it */ #ifdef WITH_DDS static bool is_power_of_2_resolution(int w, int h) @@ -262,13 +264,18 @@ GPUTexture *GPU_texture_from_blender( Image *ima, ImageUser *iuser, int textarget, - bool is_data, - double UNUSED(time)) + bool is_data) { if (ima == NULL) { return NULL; } + /* currently, gpu refresh tagging is used by ima sequences */ + if (ima->gpuflag & IMA_GPU_REFRESH) { + gpu_free_image_immediate(ima); + ima->gpuflag &= ~IMA_GPU_REFRESH; + } + /* Test if we already have a texture. */ GPUTexture **tex = gpu_get_image_gputexture(ima, textarget); if (*tex) { @@ -283,12 +290,6 @@ GPUTexture *GPU_texture_from_blender( return *tex; } - /* currently, tpage refresh is used by ima sequences */ - if (ima->gpuflag & IMA_GPU_REFRESH) { - GPU_free_image(ima); - ima->gpuflag &= ~IMA_GPU_REFRESH; - } - /* check if we have a valid image buffer */ ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL); if (ibuf == NULL) { @@ -1128,13 +1129,8 @@ void GPU_free_unused_buffers(Main *bmain) BLI_thread_unlock(LOCK_OPENGL); } -void GPU_free_image(Image *ima) +static void gpu_free_image_immediate(Image *ima) { - if (!BLI_thread_is_main()) { - gpu_queue_image_for_free(ima); - return; - } - for (int i = 0; i < TEXTARGET_COUNT; i++) { /* free glsl image binding */ if (ima->gputexture[i]) { @@ -1146,6 +1142,16 @@ void GPU_free_image(Image *ima) ima->gpuflag &= ~(IMA_GPU_MIPMAP_COMPLETE | IMA_GPU_IS_DATA); } +void GPU_free_image(Image *ima) +{ + if (!BLI_thread_is_main()) { + gpu_queue_image_for_free(ima); + return; + } + + gpu_free_image_immediate(ima); +} + void GPU_free_images(Main *bmain) { if (bmain) { |