Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/intern/gpu_viewport.c
| Show First 20 Lines • Show All 349 Lines • ▼ Show 20 Lines | |||||
| * Try to find a texture corresponding to params into the texture pool. | * Try to find a texture corresponding to params into the texture pool. | ||||
| * If no texture was found, create one and add it to the pool. | * If no texture was found, create one and add it to the pool. | ||||
| */ | */ | ||||
| GPUTexture *GPU_viewport_texture_pool_query( | GPUTexture *GPU_viewport_texture_pool_query( | ||||
| GPUViewport *viewport, void *engine, int width, int height, int format) | GPUViewport *viewport, void *engine, int width, int height, int format) | ||||
| { | { | ||||
| GPUTexture *tex; | GPUTexture *tex; | ||||
| for (ViewportTempTexture *tmp_tex = viewport->tex_pool.first; tmp_tex; tmp_tex = tmp_tex->next) { | LISTBASE_FOREACH (ViewportTempTexture *, tmp_tex, &viewport->tex_pool) { | ||||
| if ((GPU_texture_format(tmp_tex->texture) == format) && | if ((GPU_texture_format(tmp_tex->texture) == format) && | ||||
| (GPU_texture_width(tmp_tex->texture) == width) && | (GPU_texture_width(tmp_tex->texture) == width) && | ||||
| (GPU_texture_height(tmp_tex->texture) == height)) { | (GPU_texture_height(tmp_tex->texture) == height)) { | ||||
| /* Search if the engine is not already using this texture */ | /* Search if the engine is not already using this texture */ | ||||
| for (int i = 0; i < MAX_ENGINE_BUFFER_SHARING; i++) { | for (int i = 0; i < MAX_ENGINE_BUFFER_SHARING; i++) { | ||||
| if (tmp_tex->user[i] == engine) { | if (tmp_tex->user[i] == engine) { | ||||
| break; | break; | ||||
| } | } | ||||
| Show All 40 Lines | if (no_user) { | ||||
| GPU_texture_free(tmp_tex->texture); | GPU_texture_free(tmp_tex->texture); | ||||
| BLI_freelinkN(&viewport->tex_pool, tmp_tex); | BLI_freelinkN(&viewport->tex_pool, tmp_tex); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void gpu_viewport_texture_pool_free(GPUViewport *viewport) | static void gpu_viewport_texture_pool_free(GPUViewport *viewport) | ||||
| { | { | ||||
| for (ViewportTempTexture *tmp_tex = viewport->tex_pool.first; tmp_tex; tmp_tex = tmp_tex->next) { | LISTBASE_FOREACH (ViewportTempTexture *, tmp_tex, &viewport->tex_pool) { | ||||
| GPU_texture_free(tmp_tex->texture); | GPU_texture_free(tmp_tex->texture); | ||||
| } | } | ||||
| BLI_freelistN(&viewport->tex_pool); | BLI_freelistN(&viewport->tex_pool); | ||||
| } | } | ||||
| /* Takes an NULL terminated array of engine_handle. Returns true is data is still valid. */ | /* Takes an NULL terminated array of engine_handle. Returns true is data is still valid. */ | ||||
| bool GPU_viewport_engines_data_validate(GPUViewport *viewport, void **engine_handle_array) | bool GPU_viewport_engines_data_validate(GPUViewport *viewport, void **engine_handle_array) | ||||
| ▲ Show 20 Lines • Show All 504 Lines • Show Last 20 Lines | |||||