Commit: 4ef26d98d33d026f010da27d97dd0929023589ba Author: Nick Wu Date: Fri Jul 27 11:37:14 2018 +0800 Branches: soc-2018-npr https://developer.blender.org/rB4ef26d98d33d026f010da27d97dd0929023589ba
Fixed intersection calculation memory leak, fixed snake UI error, added F12 supporting functions. =================================================================== M release/scripts/startup/bl_ui/properties_scene.py M source/blender/draw/engines/lanpr/lanpr_all.h M source/blender/draw/engines/lanpr/lanpr_dpix.c M source/blender/draw/engines/lanpr/lanpr_engine.c M source/blender/draw/engines/lanpr/lanpr_ops.c M source/blender/draw/engines/lanpr/lanpr_snake.c =================================================================== diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py index 09216661665..b609e2322b6 100644 --- a/release/scripts/startup/bl_ui/properties_scene.py +++ b/release/scripts/startup/bl_ui/properties_scene.py @@ -818,7 +818,7 @@ class SCENE_PT_lanpr_snake_settings(SceneButtonsPanel, Panel): def poll(cls, context): scene = context.scene lanpr = scene.lanpr - return lanpr.master_mode == "SNAKE" and lanpr.enable_vector_trace == "ENABLE" + return lanpr.master_mode == "SNAKE" and lanpr.enable_vector_trace == "ENABLED" def draw(self, context): layout = self.layout diff --git a/source/blender/draw/engines/lanpr/lanpr_all.h b/source/blender/draw/engines/lanpr/lanpr_all.h index 330df6aa6de..faffecf4b9f 100644 --- a/source/blender/draw/engines/lanpr/lanpr_all.h +++ b/source/blender/draw/engines/lanpr/lanpr_all.h @@ -50,7 +50,7 @@ ((L) * (1.0f - (T)) + (R)*(T)) -typedef struct LANPROneTimeInit { +typedef struct LANPRSharedResource { /* Snake */ GPUShader *multichannel_shader; @@ -66,17 +66,17 @@ typedef struct LANPROneTimeInit { GPUShader *software_shader; GPUShader *software_chaining_shader; - /* For Debug... */ - GPUShader *debug_shader; + void *ved_viewport; + void *ved_render; - void *ved; + int init_complete; - /* for default value assignment */ + SpinLock render_flag_lock; + int during_render; // get/set using access funcion which uses render_flag_lock to lock. + // this prevents duplicate too much resource. (no render preview in viewport while rendering) - int InitComplete; - -} LANPROneTimeInit; +} LANPRSharedResource; #define TNS_DPIX_TEXTURE_SIZE 2048 @@ -114,9 +114,6 @@ typedef struct LANPR_PassList { /* SOFTWARE */ struct DRWPass *software_pass; - /* DEBUG */ - struct DRWPass *debug_pass; - } LANPR_PassList; typedef struct LANPR_FramebufferList { @@ -327,6 +324,8 @@ typedef struct LANPR_RenderBuffer { //render status + int cached_for_frame; + real ViewVector[3]; int TriangleSize; @@ -802,9 +801,13 @@ int lanpr_feed_atlas_data_intersection_cache(void *vedata, int lanpr_feed_atlas_trigger_preview_obj(void *vedata, Object *ob, int begin_index); void lanpr_create_atlas_intersection_preview(void *vedata, int begin_index); -void lanpr_dpix_draw_scene(LANPR_TextureList *txl, LANPR_FramebufferList *fbl, LANPR_PassList *psl, LANPR_PrivateData *pd, SceneLANPR *lanpr, GPUFrameBuffer *DefaultFB); +void lanpr_dpix_draw_scene(LANPR_TextureList *txl, LANPR_FramebufferList *fbl, LANPR_PassList *psl, LANPR_PrivateData *pd, SceneLANPR *lanpr, GPUFrameBuffer *DefaultFB, int is_render); -void lanpr_snake_draw_scene(LANPR_TextureList *txl, LANPR_FramebufferList *fbl, LANPR_PassList *psl, LANPR_PrivateData *pd, SceneLANPR *lanpr, GPUFrameBuffer *DefaultFB); +void lanpr_snake_draw_scene(LANPR_TextureList *txl, LANPR_FramebufferList *fbl, LANPR_PassList *psl, LANPR_PrivateData *pd, SceneLANPR *lanpr, GPUFrameBuffer *DefaultFB, int is_render); void lanpr_software_draw_scene(void *vedata, GPUFrameBuffer *dfb); +void lanpr_set_render_flag(); +void lanpr_clear_render_flag(); +int lanpr_during_render(); + diff --git a/source/blender/draw/engines/lanpr/lanpr_dpix.c b/source/blender/draw/engines/lanpr/lanpr_dpix.c index db9210b3947..b400a3f9a89 100644 --- a/source/blender/draw/engines/lanpr/lanpr_dpix.c +++ b/source/blender/draw/engines/lanpr/lanpr_dpix.c @@ -25,14 +25,14 @@ #include <math.h> -extern struct LANPROneTimeInit OneTime; +extern LANPRSharedResource lanpr_share; extern char datatoc_lanpr_dpix_project_passthrough_vert_glsl[]; extern char datatoc_lanpr_dpix_project_clip_frag_glsl[]; extern char datatoc_lanpr_dpix_preview_geom_glsl[]; extern char datatoc_lanpr_dpix_preview_frag_glsl[]; void lanpr_init_atlas_inputs(void *ved){ - OneTime.ved = ved; + lanpr_share.ved_viewport = ved; LANPR_Data *vedata = (LANPR_Data *)ved; LANPR_TextureList *txl = vedata->txl; LANPR_FramebufferList *fbl = vedata->fbl; @@ -76,15 +76,15 @@ void lanpr_init_atlas_inputs(void *ved){ GPU_ATTACHMENT_LEAVE }); - if (!OneTime.dpix_transform_shader) { - OneTime.dpix_transform_shader = + if (!lanpr_share.dpix_transform_shader) { + lanpr_share.dpix_transform_shader = GPU_shader_create( datatoc_lanpr_dpix_project_passthrough_vert_glsl, datatoc_lanpr_dpix_project_clip_frag_glsl, NULL, NULL, NULL); } - if (!OneTime.dpix_preview_shader) { - OneTime.dpix_preview_shader = + if (!lanpr_share.dpix_preview_shader) { + lanpr_share.dpix_preview_shader = GPU_shader_create( datatoc_lanpr_dpix_project_passthrough_vert_glsl, datatoc_lanpr_dpix_preview_frag_glsl, @@ -93,7 +93,7 @@ void lanpr_init_atlas_inputs(void *ved){ } } void lanpr_destroy_atlas(void *ved){ - OneTime.ved = ved; + lanpr_share.ved_viewport = ved; LANPR_Data *vedata = (LANPR_Data *)ved; LANPR_TextureList *txl = vedata->txl; LANPR_FramebufferList *fbl = vedata->fbl; @@ -361,7 +361,7 @@ void lanpr_create_atlas_intersection_preview(void *vedata, int begin_index) { } -void lanpr_dpix_draw_scene(LANPR_TextureList *txl, LANPR_FramebufferList *fbl, LANPR_PassList *psl, LANPR_PrivateData *pd, SceneLANPR *lanpr, GPUFrameBuffer *DefaultFB) { +void lanpr_dpix_draw_scene(LANPR_TextureList *txl, LANPR_FramebufferList *fbl, LANPR_PassList *psl, LANPR_PrivateData *pd, SceneLANPR *lanpr, GPUFrameBuffer *DefaultFB, int is_render) { float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f}; float clear_depth = 1.0f; uint clear_stencil = 0xFF; diff --git a/source/blender/draw/engines/lanpr/lanpr_engine.c b/source/blender/draw/engines/lanpr/lanpr_engine.c index 11b7bbf0d0e..7d24e76348f 100644 --- a/source/blender/draw/engines/lanpr/lanpr_engine.c +++ b/source/blender/draw/engines/lanpr/lanpr_engine.c @@ -44,11 +44,11 @@ extern char datatoc_lanpr_software_passthrough_vert_glsl[]; extern char datatoc_gpu_shader_2D_smooth_color_vert_glsl[]; extern char datatoc_gpu_shader_2D_smooth_color_frag_glsl[]; -LANPROneTimeInit OneTime; +LANPRSharedResource lanpr_share; static void lanpr_engine_init(void *ved){ - OneTime.ved = ved; + lanpr_share.ved_viewport = ved; LANPR_Data *vedata = (LANPR_Data *)ved; LANPR_TextureList *txl = vedata->txl; LANPR_FramebufferList *fbl = vedata->fbl; @@ -60,31 +60,8 @@ static void lanpr_engine_init(void *ved){ SceneLANPR *lanpr = &scene->lanpr; View3D *v3d = draw_ctx->v3d; - if (!OneTime.InitComplete) { - //lanpr->depth_clamp = 0.01; - //lanpr->depth_strength = 800; - //lanpr->normal_clamp = 2; - //lanpr->normal_strength = 10; - //lanpr->line_thickness = 2; - //lanpr->taper_left_distance = 20; - //lanpr->taper_left_strength = 0.9; - //lanpr->taper_right_distance = 20; - //lanpr->taper_right_strength = 0.9; - - //lanpr->line_color[0] = 0.22; - //lanpr->line_color[1] = 0.29; - //lanpr->line_color[2] = 0.53; - //lanpr->line_color[3] = 1; - - //lanpr->background_color[0] = 0.59; - //lanpr->background_color[1] = 0.90; - //lanpr->background_color[2] = 0.51; - //lanpr->background_color[3] = 1; - - lanpr->reloaded = 1; - - OneTime.InitComplete = 1; - } + if(!lanpr_share.init_complete) + BLI_spin_init(&lanpr_share.render_flag_lock); /* SNAKE */ @@ -128,29 +105,29 @@ static void lanpr_engine_init(void *ved){ }); - if (!OneTime.multichannel_shader) { - OneTime.multichannel_shader = + if (!lanpr_share.multichannel_shader) { + lanpr_share.multichannel_shader = GPU_shader_create( datatoc_gpu_shader_3D_normal_smooth_color_vert_glsl, datatoc_lanpr_snake_multichannel_frag_glsl, NULL, NULL, NULL); } - if (!OneTime.edge_detect_shader) { - OneTime.edge_detect_shader = + if (!lanpr_share.edge_detect_shader) { + lanpr_share.edge_detect_shader = GPU_shader_create( datatoc_common_fullscreen_vert_glsl, datatoc_lanpr_snake_edge_frag_glsl, NULL, NULL, NULL); } - if (!OneTime.edge_thinning_shader) { - OneTime.edge_thinning_shader = + if (!lanpr_share.edge_thinning_shader) { + lanpr_share.edge_thinning_shader = GPU_shader_create( datatoc_common_fullscreen_vert_glsl, datatoc_lanpr_snake_image_peel_frag_glsl, NULL, NULL, NULL); } - if (!OneTime.snake_connection_shader) { - OneTime.snake_connection_shader = + if (!lanpr_share.snake_connection_shader) { + lanpr_share.snake_connection_shader = GPU_shader_create( datatoc_lanpr_snake_line_connection_vert_glsl, datatoc_lanpr_snake_line_connection_frag_glsl, @@ -162,8 +139,8 @@ static void lanpr_engine_init(void *ved){ lanpr_init_atlas_inputs(ved); /* SOFTWARE */ - if (!OneTime.software_shader) { - OneTime.software_shader = + if (!lanpr_share.software_shader) { + lanpr_share.software_shader = GPU_shader_create( datatoc_lanpr_software_passthrough_vert_glsl, datatoc_lanpr_dpix_preview_frag_glsl, @@ -171,8 +148,8 @@ static void lanpr_engine_init(void *ved){ NULL, NULL); } - if (!OneTime.software_chaining_shader) { - OneTime.software_chaining_shader = + if (!lanpr_share.software_chaining_shader) { + lanpr_share.software_chaining_shader = GPU_shader_create( datatoc_lanpr_software_passthrough_vert_glsl, datatoc_lanpr_dpix_preview_frag_glsl, @@ -190,19 +167,11 @@ static void lanpr_engine_init(void *ved){ GPU_ATTACHMENT_LEAVE }); - /* Debug */ - if (!OneTime.debug_shader) { - OneTime.debug_shader = - GPU_shader_create( - datatoc_gpu_shader_2D_smooth_color_vert_glsl, - datatoc_gpu_shader_2D_smooth_color_frag_glsl, - NULL, - NULL, NULL); - } + lanpr_share.init_complete = 1; } static void lanpr_engine_free(void){ - void *ved = OneTime.ved; + void *ved = lanpr_share.ved_viewport; LANPR_Data *vedata = (LANPR_Data *)ved; LANPR_TextureList *txl = vedata->txl; LANPR_FramebufferList *fbl = vedata->fbl; @@ -263,14 +232,14 @@ static void lanpr_cache_init(void *vedata){ View3D *v3d = draw_ctx->v3d; psl->color_pass = DRW_pass_create("color Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_WRITE_DEPTH); - stl->g_data->multipass_shgrp = DRW_shgroup_create(OneTime.multichannel_shader, psl->color_pass); + stl->g_data->multipass_shgrp = DRW_shgroup_create(lanpr_share. @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs