Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2019-01-22 18:30:17 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-01-25 17:02:30 +0300
commitaae2bf77351103b15e5a97daed7f396a546c001c (patch)
tree3ae216aa4de18d92c23b9e76203f0e68128331ea /source
parent3fb72a5432a722ac036e5b567940ace13e64705d (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/gpu/intern/gpu_framebuffer.c5
-rw-r--r--source/blender/gpu/intern/gpu_texture.c7
2 files changed, 12 insertions, 0 deletions
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);