From 6be8b6af4006e088ac4a2cd8c1adc8f18c04035b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 4 Aug 2020 19:52:18 +0200 Subject: EEVEE: LightCache: Prevent crash when using a lightcache too big Some implementation have different maximum texture size. This patch avoid crash when texture allocation fails when: - trying to bake a lightcache too big for the OpenGL imeplementaion. - loading a cache from file that is too big for the OpenGL imeplementation. --- source/blender/draw/intern/draw_manager_texture.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source/blender/draw/intern') diff --git a/source/blender/draw/intern/draw_manager_texture.c b/source/blender/draw/intern/draw_manager_texture.c index 77b0462303d..b94a6db3bad 100644 --- a/source/blender/draw/intern/draw_manager_texture.c +++ b/source/blender/draw/intern/draw_manager_texture.c @@ -61,6 +61,10 @@ static bool drw_texture_format_supports_framebuffer(eGPUTextureFormat format) void drw_texture_set_parameters(GPUTexture *tex, DRWTextureFlag flags) { + if (tex == NULL) { + return; + } + if (flags & DRW_TEX_MIPMAP) { GPU_texture_mipmap_mode(tex, true, flags & DRW_TEX_FILTER); GPU_texture_bind(tex, 0); @@ -119,7 +123,6 @@ GPUTexture *DRW_texture_create_cube(int w, { GPUTexture *tex = GPU_texture_create_cube(w, format, fpixels, NULL); drw_texture_set_parameters(tex, flags); - return tex; } @@ -128,7 +131,6 @@ GPUTexture *DRW_texture_create_cube_array( { GPUTexture *tex = GPU_texture_create_cube_array(w, d, format, fpixels, NULL); drw_texture_set_parameters(tex, flags); - return tex; } -- cgit v1.2.3