Commit: fbffd6d3645af8364ede5b1b900eed10adb83ca3
Author: Clément Foucault
Date:   Fri Jun 23 01:33:28 2017 +0200
Branches: blender2.8
https://developer.blender.org/rBfbffd6d3645af8364ede5b1b900eed10adb83ca3

Eevee: Fix OpenGl errors.

Also assert if texture does not exists in draw manager. Keeping it sane.

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

M       source/blender/draw/engines/eevee/eevee_lightprobes.c
M       source/blender/draw/engines/eevee/eevee_materials.c
M       source/blender/draw/intern/draw_manager.c

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

diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c 
b/source/blender/draw/engines/eevee/eevee_lightprobes.c
index 0d6f589f8a5..98f9c12b37e 100644
--- a/source/blender/draw/engines/eevee/eevee_lightprobes.c
+++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c
@@ -135,12 +135,15 @@ static void planar_pool_ensure_alloc(EEVEE_Data *vedata, 
int num_planar_ref)
        int height = (int)(viewport_size[1] * screen_percentage);
 
        /* We need an Array texture so allocate it ourself */
-       if (!txl->planar_pool && (num_planar_ref > 0)) {
-               txl->planar_pool = DRW_texture_create_2D_array(width, height, 
max_ff(1, num_planar_ref),
-                                                                
DRW_TEX_RGB_11_11_10, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
-       }
-       else if (txl->planar_pool && (num_planar_ref == 0)) {
-               DRW_TEXTURE_FREE_SAFE(txl->planar_pool);
+       if (!txl->planar_pool) {
+               if (num_planar_ref > 0) {
+                       txl->planar_pool = DRW_texture_create_2D_array(width, 
height, max_ff(1, num_planar_ref),
+                                                                        
DRW_TEX_RGB_11_11_10, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
+               }
+               else if (num_planar_ref == 0) {
+                       /* Makes Opengl Happy : Create a placeholder texture 
that will never be sampled but still bound to shader. */
+                       txl->planar_pool = DRW_texture_create_2D_array(1, 1, 1, 
DRW_TEX_RGB_11_11_10, DRW_TEX_FILTER | DRW_TEX_MIPMAP, NULL);
+               }
        }
 
        if (num_planar_ref > 0) {
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c 
b/source/blender/draw/engines/eevee/eevee_materials.c
index 1043915c894..98f85f32910 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -217,7 +217,7 @@ static void add_standard_uniforms(DRWShadingGroup *shgrp, 
EEVEE_SceneLayerData *
        DRW_shgroup_uniform_buffer(shgrp, "shadowCubes", 
&sldata->shadow_depth_cube_pool);
        DRW_shgroup_uniform_buffer(shgrp, "shadowCascades", 
&sldata->shadow_depth_cascade_pool);
        if (vedata->stl->effects->use_ao) {
-               DRW_shgroup_uniform_vec4(shgrp, "viewvecs[0]", (float 
*)e_data.viewvecs, 3);
+               DRW_shgroup_uniform_vec4(shgrp, "viewvecs[0]", (float 
*)e_data.viewvecs, 2);
                DRW_shgroup_uniform_buffer(shgrp, "minMaxDepthTex", 
&vedata->stl->g_data->minmaxz);
                DRW_shgroup_uniform_float(shgrp, "aoDistance", 
&vedata->stl->effects->ao_dist, 1);
                DRW_shgroup_uniform_float(shgrp, "aoSamples", 
&vedata->stl->effects->ao_samples, 1);
diff --git a/source/blender/draw/intern/draw_manager.c 
b/source/blender/draw/intern/draw_manager.c
index c8434b114b3..bcbd4e5eb31 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -1727,6 +1727,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, 
DRWState pass_state)
                                break;
                        case DRW_UNIFORM_TEXTURE:
                                tex = (GPUTexture *)uni->value;
+                               BLI_assert(tex);
                                GPU_texture_bind(tex, uni->bindloc);
 
                                bound_tex = 
MEM_callocN(sizeof(DRWBoundTexture), "DRWBoundTexture");
@@ -1740,10 +1741,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, 
DRWState pass_state)
                                        break;
                                }
                                tex = *((GPUTexture **)uni->value);
-                               if (tex == NULL) {
-                                       /* In case texture is not yet available 
*/
-                                       break;
-                               }
+                               BLI_assert(tex);
                                GPU_texture_bind(tex, uni->bindloc);
 
                                bound_tex = 
MEM_callocN(sizeof(DRWBoundTexture), "DRWBoundTexture");

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to