Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_manager_texture.c
| Show First 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | GPUTexture *DRW_texture_pool_query_2d(int w, | ||||
| return tex; | return tex; | ||||
| } | } | ||||
| void DRW_texture_ensure_fullscreen_2d(GPUTexture **tex, | void DRW_texture_ensure_fullscreen_2d(GPUTexture **tex, | ||||
| eGPUTextureFormat format, | eGPUTextureFormat format, | ||||
| DRWTextureFlag flags) | DRWTextureFlag flags) | ||||
| { | { | ||||
| if (*(tex) == NULL) { | |||||
| const float *size = DRW_viewport_size_get(); | const float *size = DRW_viewport_size_get(); | ||||
| *(tex) = DRW_texture_create_2d((int)size[0], (int)size[1], format, flags, NULL); | DRW_texture_ensure_2d(tex, (int)size[0], (int)size[1], format, flags); | ||||
| } | } | ||||
| void DRW_texture_ensure_render_fullscreen_2d(GPUTexture **tex, | |||||
| eGPUTextureFormat format, | |||||
| DRWTextureFlag flags) | |||||
| { | |||||
| const float *size = DRW_viewport_render_size_get(); | |||||
| DRW_texture_ensure_2d(tex, (int)size[0], (int)size[1], format, flags); | |||||
| } | } | ||||
| void DRW_texture_ensure_2d( | void DRW_texture_ensure_2d( | ||||
| GPUTexture **tex, int w, int h, eGPUTextureFormat format, DRWTextureFlag flags) | GPUTexture **tex, int w, int h, eGPUTextureFormat format, DRWTextureFlag flags) | ||||
| { | { | ||||
| if (*(tex) == NULL) { | if (*tex) { | ||||
| *(tex) = DRW_texture_create_2d(w, h, format, flags, NULL); | int old_size[2]; | ||||
| GPU_texture_get_mipmap_size(*tex, 0, old_size); | |||||
| if (old_size[0] == w && old_size[1] == h) { | |||||
| return; | |||||
| } | |||||
| DRW_texture_free(*tex); | |||||
| } | } | ||||
| *tex = DRW_texture_create_2d(w, h, format, flags, NULL); | |||||
| } | } | ||||
| void DRW_texture_generate_mipmaps(GPUTexture *tex) | void DRW_texture_generate_mipmaps(GPUTexture *tex) | ||||
| { | { | ||||
| GPU_texture_bind(tex, 0); | GPU_texture_bind(tex, 0); | ||||
| GPU_texture_generate_mipmap(tex); | GPU_texture_generate_mipmap(tex); | ||||
| GPU_texture_unbind(tex); | GPU_texture_unbind(tex); | ||||
| } | } | ||||
| void DRW_texture_free(GPUTexture *tex) | void DRW_texture_free(GPUTexture *tex) | ||||
| { | { | ||||
| GPU_texture_free(tex); | GPU_texture_free(tex); | ||||
| } | } | ||||