Added switch to test viewport cache
authorClément Foucault <foucault.clem@gmail.com>
Fri, 27 Jan 2017 11:44:41 +0000 (12:44 +0100)
committerClément Foucault <foucault.clem@gmail.com>
Fri, 27 Jan 2017 16:17:01 +0000 (17:17 +0100)
source/blender/draw/DRW_engine.h
source/blender/draw/engines/clay/clay.c
source/blender/draw/intern/DRW_render.h
source/blender/draw/intern/draw_manager.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/gpu/intern/gpu_viewport.c

index ad05cf625f8947d9494bb7993ac6c720c49df389..d58e2406faaad8924c028e73379278904fbab65a 100644 (file)
@@ -26,6 +26,8 @@
 #ifndef __DRW_ENGINE_H__
 #define __DRW_ENGINE_H__
 
+//#define WITH_VIEWPORT_CACHE_TEST
+
 struct DRWPass;
 
 void DRW_engines_init(void);
index f741cb54b9c0c20184241b986e19569c71a25645..cf5720b911ef3a9c48732906e4ff0d0d447576ee 100644 (file)
@@ -577,11 +577,18 @@ static void CLAY_view_draw(RenderEngine *UNUSED(engine), const struct bContext *
        /* TODO : tag to refresh by the deps graph */
        /* ideally only refresh when objects are added/removed */
        /* or render properties / materials change */
-       //static bool once = false;
+#ifdef WITH_VIEWPORT_CACHE_TEST
+       static bool once = false;
+       printf("AA\n");
+#endif
        if (DRW_viewport_cache_is_dirty()
-               //&& !once
+#ifdef WITH_VIEWPORT_CACHE_TEST
+               && !once
+#endif
                ) {
-               //once = true;
+#ifdef WITH_VIEWPORT_CACHE_TEST
+               once = true;
+#endif
                CLAY_create_cache(passes, context);
        }
 
index 8daf97875b5a362ac2b101e486da3455b6c37279..75f5a124a1ce761fe464de2af3862daa5e887cf0 100644 (file)
@@ -50,6 +50,8 @@
 
 #include "RE_engine.h"
 
+//#define WITH_VIEWPORT_CACHE_TEST
+
 struct GPUFrameBuffer;
 struct GPUShader;
 struct GPUTexture;
index a2ddf07079991d4f7d88572406187bff53f880f0..0bb651897b4e2d399f5cc2fa54e3cce978ebcd86 100644 (file)
@@ -446,6 +446,10 @@ static void shgroup_dynamic_batch_from_calls(DRWShadingGroup *shgroup)
        int nbr = BLI_listbase_count(&shgroup->calls);
        GLenum type;
 
+#ifdef WITH_VIEWPORT_CACHE_TEST
+       if (shgroup->dyngeom) return;
+#endif
+
        if (nbr == 0) {
                if (shgroup->dyngeom) {
                        Batch_discard(shgroup->dyngeom);
@@ -457,7 +461,6 @@ static void shgroup_dynamic_batch_from_calls(DRWShadingGroup *shgroup)
        /* Gather Data */
        float *data = MEM_mallocN(sizeof(float) * 3 * nbr , "Object Center Batch data");
 
-       /* TODO do something more generic usable for other things than obj center */
        for (DRWCall *call = shgroup->calls.first; call; call = call->next, i++) {
                copy_v3_v3(&data[i*3], call->obmat[3]);
        }
@@ -506,6 +509,7 @@ void DRW_pass_free(DRWPass *pass)
        BLI_freelistN(&pass->shgroups);
 }
 
+/* TODO this is slow we should not have to use this (better store shgroup pointer somewhere) */
 DRWShadingGroup *DRW_pass_nth_shgroup_get(DRWPass *pass, int n)
 {
        int i = 0;
index c8f0a4e32569a607e30166bb937bc9c905ebd2b5..f428b2cec4796c80a5c0d7edf5094ca1be488c30 100644 (file)
@@ -2109,7 +2109,7 @@ static void view3d_render_pass(const bContext *C, ARegion *ar)
        }
 }
 
-static void view3d_draw_view_new(const bContext *C, ARegion *ar, DrawData *draw_data)
+static void view3d_draw_view_new(const bContext *C, ARegion *ar, DrawData *UNUSED(draw_data))
 {
 
        view3d_draw_setup_view(C, ar);
index 015d71ac56123353ee1e26640adf81f34280ac75..b1964857ab104af360d5e19bda4057a4a08625b8 100644 (file)
@@ -87,8 +87,10 @@ void GPU_viewport_bind(GPUViewport *viewport, const rcti *rect)
        /* add one pixel because of scissor test */
        int rect_w = BLI_rcti_size_x(rect) + 1, rect_h = BLI_rcti_size_y(rect) + 1;
 
+#ifndef WITH_VIEWPORT_CACHE_TEST
        /* TODO for testing only, we need proper cache invalidation */
        GPU_viewport_passes_free(viewport);
+#endif
 
        if (viewport->fbl->default_fb) {
                if (rect_w != viewport->size[0] || rect_h != viewport->size[1]) {