[Bf-blender-cvs] [aae2bf77351] master: T60745: GPU texture alloc failed when opening Preference Windows

Clément Foucault noreply at git.blender.org
Fri Jan 25 15:13:34 CET 2019


Commit: aae2bf77351103b15e5a97daed7f396a546c001c
Author: Clément Foucault
Date:   Tue Jan 22 16:30:17 2019 +0100
Branches: master
https://developer.blender.org/rBaae2bf77351103b15e5a97daed7f396a546c001c

T60745: GPU texture alloc failed when opening Preference Windows

Was generating INVALID_FRAMEBUFFER here instead of failled texture alloc.

Add safety asserts in gpu_texture.c and clamp minimum size to 1 inside
GPU_offscreen_create.

===================================================================

M	source/blender/gpu/intern/gpu_framebuffer.c
M	source/blender/gpu/intern/gpu_texture.c

===================================================================

diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c
index b6c8dae2b37..6bb5d668e62 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.c
+++ b/source/blender/gpu/intern/gpu_framebuffer.c
@@ -792,6 +792,11 @@ GPUOffScreen *GPU_offscreen_create(int width, int height, int samples, bool dept
 
 	ofs = MEM_callocN(sizeof(GPUOffScreen), "GPUOffScreen");
 
+	/* Sometimes areas can have 0 height or width and this will
+	 * create a 1D texture which we don't want. */
+	height = max_ii(1, height);
+	width  = max_ii(1, width);
+
 	ofs->color = GPU_texture_create_2D_multisample(
 	        width, height,
 	        (high_bitdepth) ? GPU_RGBA16F : GPU_RGBA8, NULL, samples, err_out);
diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c
index 028d1fe1a8f..93ef6fca485 100644
--- a/source/blender/gpu/intern/gpu_texture.c
+++ b/source/blender/gpu/intern/gpu_texture.c
@@ -994,6 +994,7 @@ GPUTexture *GPU_texture_from_preview(PreviewImage *prv, int mipmap)
 GPUTexture *GPU_texture_create_1D(
         int w, eGPUTextureFormat tex_format, const float *pixels, char err_out[256])
 {
+	BLI_assert(w > 0);
 	eGPUDataFormat data_format = gpu_get_data_format_from_tex_format(tex_format);
 	return GPU_texture_create_nD(w, 0, 0, 1, pixels, tex_format, data_format, 0, false, err_out);
 }
@@ -1001,6 +1002,7 @@ GPUTexture *GPU_texture_create_1D(
 GPUTexture *GPU_texture_create_1D_array(
         int w, int h, eGPUTextureFormat tex_format, const float *pixels, char err_out[256])
 {
+	BLI_assert(w > 0 && h > 0);
 	eGPUDataFormat data_format = gpu_get_data_format_from_tex_format(tex_format);
 	return GPU_texture_create_nD(w, h, 0, 1, pixels, tex_format, data_format, 0, false, err_out);
 }
@@ -1008,6 +1010,7 @@ GPUTexture *GPU_texture_create_1D_array(
 GPUTexture *GPU_texture_create_2D(
         int w, int h, eGPUTextureFormat tex_format, const float *pixels, char err_out[256])
 {
+	BLI_assert(w > 0 && h > 0);
 	eGPUDataFormat data_format = gpu_get_data_format_from_tex_format(tex_format);
 	return GPU_texture_create_nD(w, h, 0, 2, pixels, tex_format, data_format, 0, false, err_out);
 }
@@ -1015,6 +1018,7 @@ GPUTexture *GPU_texture_create_2D(
 GPUTexture *GPU_texture_create_2D_multisample(
         int w, int h, eGPUTextureFormat tex_format, const float *pixels, int samples, char err_out[256])
 {
+	BLI_assert(w > 0 && h > 0);
 	eGPUDataFormat data_format = gpu_get_data_format_from_tex_format(tex_format);
 	return GPU_texture_create_nD(w, h, 0, 2, pixels, tex_format, data_format, samples, false, err_out);
 }
@@ -1022,6 +1026,7 @@ GPUTexture *GPU_texture_create_2D_multisample(
 GPUTexture *GPU_texture_create_2D_array(
         int w, int h, int d, eGPUTextureFormat tex_format, const float *pixels, char err_out[256])
 {
+	BLI_assert(w > 0 && h > 0 && d > 0);
 	eGPUDataFormat data_format = gpu_get_data_format_from_tex_format(tex_format);
 	return GPU_texture_create_nD(w, h, d, 2, pixels, tex_format, data_format, 0, false, err_out);
 }
@@ -1029,6 +1034,7 @@ GPUTexture *GPU_texture_create_2D_array(
 GPUTexture *GPU_texture_create_3D(
         int w, int h, int d, eGPUTextureFormat tex_format, const float *pixels, char err_out[256])
 {
+	BLI_assert(w > 0 && h > 0 && d > 0);
 	eGPUDataFormat data_format = gpu_get_data_format_from_tex_format(tex_format);
 	return GPU_texture_create_nD(w, h, d, 3, pixels, tex_format, data_format, 0, true, err_out);
 }
@@ -1036,6 +1042,7 @@ GPUTexture *GPU_texture_create_3D(
 GPUTexture *GPU_texture_create_cube(
         int w, eGPUTextureFormat tex_format, const float *fpixels, char err_out[256])
 {
+	BLI_assert(w > 0);
 	const float *fpixels_px, *fpixels_py, *fpixels_pz, *fpixels_nx, *fpixels_ny, *fpixels_nz;
 	const int channels = gpu_get_component_count(tex_format);



More information about the Bf-blender-cvs mailing list