[Bf-blender-cvs] [9ef1a6b] viewport_experiments: Move fx_flag into the GPUFXSettings struct (simplifies things a bit)

Campbell Barton noreply at git.blender.org
Thu Feb 12 18:10:32 CET 2015


Commit: 9ef1a6b2f20f853e9ede1f034a0a415e7b85bd0c
Author: Campbell Barton
Date:   Fri Feb 13 04:09:52 2015 +1100
Branches: viewport_experiments
https://developer.blender.org/rB9ef1a6b2f20f853e9ede1f034a0a415e7b85bd0c

Move fx_flag into the GPUFXSettings struct (simplifies things a bit)

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

M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/blenkernel/BKE_screen.h
M	source/blender/blenkernel/intern/screen.c
M	source/blender/editors/include/ED_view3d.h
M	source/blender/editors/render/render_opengl.c
M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/gpu/GPU_compositing.h
M	source/blender/gpu/intern/gpu_compositing.c
M	source/blender/makesdna/DNA_gpu_types.h
M	source/blender/makesdna/DNA_view3d_types.h
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 3207c7e..82d285b 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -2936,16 +2936,16 @@ class VIEW3D_PT_view3d_shading(Panel):
 
             fx_settings = view.fx_settings
 
-            col.prop(view, "use_fx_dof")
-            if view.use_fx_dof:
+            col.prop(fx_settings, "use_dof")
+            if fx_settings.use_dof:
                 if view.region_3d.view_perspective == 'CAMERA':
                     col.label("check dof properties in camera settings", icon='INFO')
 
-            col.prop(view, "use_fx_ssao")
-            if view.use_fx_ssao:
+            col.prop(fx_settings, "use_ssao")
+            if fx_settings.use_ssao:
                 ssao_settings = fx_settings.ssao
                 subcol = col.column(align=True)
-                subcol.prop(ssao_settings, "darkening")
+                subcol.prop(ssao_settings, "darken")
                 subcol.prop(ssao_settings, "distance_max")
                 subcol.prop(ssao_settings, "attenuation")
                 subcol.prop(ssao_settings, "samples")
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index f2a273c..af8948e 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -52,6 +52,7 @@ struct wmKeyConfig;
 struct wmNotifier;
 struct wmWindow;
 struct wmWindowManager;
+struct GPUFXSettings;
 
 #include "BLI_compiler_attrs.h"
 
@@ -294,7 +295,7 @@ void BKE_screen_view3d_scene_sync(struct bScreen *sc);
 void BKE_screen_view3d_main_sync(ListBase *screen_lb, struct Scene *scene);
 void BKE_screen_view3d_twmode_remove(struct View3D *v3d, const int i);
 void BKE_screen_view3d_main_twmode_remove(ListBase *screen_lb, struct Scene *scene, const int i);
-void BKE_screen_view3d_ensure_FX(struct View3D *v3d);
+void BKE_screen_gpu_validate_fx(struct GPUFXSettings *fx_settings);
 
 /* zoom factor conversion */
 float BKE_screen_view3d_zoom_to_fac(float camzoom);
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index e6e5735..2679bd1 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -599,14 +599,25 @@ float BKE_screen_view3d_zoom_from_fac(float zoomfac)
 	return ((sqrtf(4.0f * zoomfac) - (float)M_SQRT2) * 50.0f);
 }
 
-void BKE_screen_view3d_ensure_FX(View3D *v3d)
+void BKE_screen_gpu_validate_fx(GPUFXSettings *fx_settings)
 {
-	if (!v3d->fx_settings.ssao) {
-		v3d->fx_settings.ssao = MEM_callocN(sizeof(GPUSSAOSettings), "view3d ssao options");
+	if ((fx_settings->dof == NULL) &&
+	    (fx_settings->fx_flag & GPU_FX_FLAG_DOF))
+	{
+		GPUDOFSettings *fx_dof;
+		fx_dof = fx_settings->dof = MEM_callocN(sizeof(GPUDOFSettings), __func__);
+		(void)fx_dof;
+	}
+
+	if ((fx_settings->ssao == NULL) &&
+	    (fx_settings->fx_flag & GPU_FX_FLAG_SSAO))
+	{
+		GPUSSAOSettings *fx_ssao;
+		fx_ssao = fx_settings->ssao = MEM_callocN(sizeof(GPUSSAOSettings), __func__);
 
-		v3d->fx_settings.ssao->darkening = 1.0f;
-		v3d->fx_settings.ssao->distance_max = 0.2f;
-		v3d->fx_settings.ssao->attenuation = 1.0f;
-		v3d->fx_settings.ssao->samples = 4;
+		fx_ssao->darkening = 1.0f;
+		fx_ssao->distance_max = 0.2f;
+		fx_ssao->attenuation = 1.0f;
+		fx_ssao->samples = 4;
 	}
 }
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index a3d04c0..e6434a1 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -311,7 +311,7 @@ void ED_view3d_draw_offscreen(
         struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int winx, int winy, float viewmat[4][4],
         float winmat[4][4], bool do_bgpic, bool do_sky, bool is_persp,
         struct GPUOffScreen *ofs,
-        struct GPUFX *fx, struct GPUFXSettings *fx_settings, enum eGPUFXFlags fx_flag);
+        struct GPUFX *fx, struct GPUFXSettings *fx_settings);
 
 struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int sizex, int sizey, unsigned int flag,
                                              bool draw_background, int alpha_mode, char err_out[256]);
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index bf9025b..3d549f5 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -243,7 +243,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
 			ED_view3d_draw_offscreen(
 			        scene, v3d, ar, sizex, sizey, NULL, winmat,
 			        draw_bgpic, draw_sky, is_persp,
-			        oglrender->ofs, oglrender->fx, &fx_settings, v3d->fx_flag);
+			        oglrender->ofs, oglrender->fx, &fx_settings);
 			GPU_offscreen_read_pixels(oglrender->ofs, GL_UNSIGNED_BYTE, rect);
 		}
 		else {
@@ -259,7 +259,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
 			ED_view3d_draw_offscreen(
 			        scene, v3d, ar, sizex, sizey, NULL, winmat,
 			        draw_bgpic, draw_sky, is_persp,
-			        oglrender->ofs, oglrender->fx, &fx_settings, v3d->fx_flag);
+			        oglrender->ofs, oglrender->fx, &fx_settings);
 			GPU_offscreen_read_pixels(oglrender->ofs, GL_UNSIGNED_BYTE, rect);
 
 			for (i = 0; i < sizex * sizey * 4; i++)
@@ -275,7 +275,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
 				ED_view3d_draw_offscreen(
 				        scene, v3d, ar, sizex, sizey, NULL, winmat_jitter,
 				        draw_bgpic, draw_sky, is_persp,
-				        oglrender->ofs, oglrender->fx, &fx_settings, v3d->fx_flag);
+				        oglrender->ofs, oglrender->fx, &fx_settings);
 				GPU_offscreen_read_pixels(oglrender->ofs, GL_UNSIGNED_BYTE, rect);
 
 				for (i = 0; i < sizex * sizey * 4; i++)
@@ -468,7 +468,7 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
 		 * running notifiers again will overwrite */
 		oglrender->scene->customdata_mask |= oglrender->scene->customdata_mask_modal;
 
-		if (oglrender->v3d->fx_flag & (GPU_FX_FLAG_DOF | GPU_FX_FLAG_SSAO)) {
+		if (oglrender->v3d->fx_settings.fx_flag & (GPU_FX_FLAG_DOF | GPU_FX_FLAG_SSAO)) {
 			oglrender->fx = GPU_fx_compositor_create();
 		}
 	}
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 71713cd..49bd9c5 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -2534,8 +2534,9 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d)
 
 		/* no need to call ED_view3d_draw_offscreen_init since shadow buffers were already updated */
 		ED_view3d_draw_offscreen(
-		            scene, v3d, &ar, winsize, winsize, viewmat, winmat, false, false, true,
-		            NULL, NULL, NULL, 0);
+		            scene, v3d, &ar, winsize, winsize, viewmat, winmat,
+		            false, false, true,
+		            NULL, NULL, NULL);
 		GPU_lamp_shadow_buffer_unbind(shadow->lamp);
 		
 		v3d->drawtype = drawtype;
@@ -3057,7 +3058,7 @@ void ED_view3d_draw_offscreen(
         float viewmat[4][4], float winmat[4][4],
         bool do_bgpic, bool do_sky, bool is_persp,
         GPUOffScreen *ofs,
-        GPUFX *fx, GPUFXSettings *fx_settings, eGPUFXFlags fx_flag)
+        GPUFX *fx, GPUFXSettings *fx_settings)
 {
 	struct bThemeState theme_state;
 	int bwinx, bwiny;
@@ -3095,8 +3096,8 @@ void ED_view3d_draw_offscreen(
 	view3d_main_area_setup_view(scene, v3d, ar, viewmat, winmat);
 
 	/* framebuffer fx needed, we need to draw offscreen first */
-	if (v3d->fx_flag && fx) {
-		do_compositing = GPU_fx_compositor_initialize_passes(fx, &ar->winrct, NULL, fx_settings, fx_flag);
+	if (v3d->fx_settings.fx_flag && fx) {
+		do_compositing = GPU_fx_compositor_initialize_passes(fx, &ar->winrct, NULL, fx_settings);
 	}
 
 	/* clear opengl buffers */
@@ -3186,13 +3187,13 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, in
 		ED_view3d_draw_offscreen(
 		        scene, v3d, ar, sizex, sizey, NULL, params.winmat,
 		        draw_background, draw_sky, !params.is_ortho,
-		        ofs, NULL, &fx_settings, GPU_FX_FLAG_NONE);
+		        ofs, NULL, &fx_settings);
 	}
 	else {
 		ED_view3d_draw_offscreen(
 		        scene, v3d, ar, sizex, sizey, NULL, NULL,
 		        draw_background, draw_sky, true,
-		        ofs, NULL, NULL, GPU_FX_FLAG_NONE);
+		        ofs, NULL, NULL);
 	}
 
 	/* read in pixels & stamp */
@@ -3515,9 +3516,9 @@ static void view3d_main_area_draw_objects(const bContext *C, Scene *scene, View3
 #endif
 
 	/* framebuffer fx needed, we need to draw offscreen first */
-	if (v3d->fx_flag) {
+	if (v3d->fx_settings.fx_flag) {
 		GPUFXSettings fx_settings;
-		BKE_screen_view3d_ensure_FX(v3d);
+		BKE_screen_gpu_validate_fx(&v3d->fx_settings);
 		fx_settings = v3d->fx_settings;
 		if (!rv3d->compositor)
 			rv3d->compositor = GPU_fx_compositor_create();
@@ -3529,7 +3530,7 @@ static void view3d_main_area_draw_objects(const bContext *C, Scene *scene, View3
 		}
 		do_compositing = GPU_fx_compositor_initialize_passes(
 		        rv3d->compositor, &ar->winrct, &ar->drawrct,
-		        &fx_settings, v3d->fx_flag);
+		        &fx_settings);
 	}
 	
 	/* clear the background */
diff --git a/source/blender/gpu/GPU_compositing.h b/source/blender/gpu/GPU_compositing.h
index 2b35f1f..e56b65c 100644
--- a/source/blender/gpu/GPU_compositing.h
+++ b/source/blender/gpu/GPU_compositing.h
@@ -73,7 +73,7 @@ void GGPU_fx_compositor_destroy(GPUFX *fx);
 /* initialize a framebuffer with size taken from the viewport */
 bool GPU_fx_compositor_initialize_passes(
         GPUFX *fx, const struct rcti *rect, const struct rcti *scissor_rect,
-        const struct GPUFXSettings *fx_settings, enum eGPUFXFlags fx_flag);
+        const struct GPUFXSettings *fx_settings);
 
 /* do compositing on the fx passes that have been initialized */
 bool GPU_fx_do_composite_pass(GPUFX *fx, float projmat[4][4], bool is_persp, struct Scene *scene, struct GPUOffScreen *ofs);
diff --git a/source/blender/gpu/intern/gpu_compositing.c b/source/

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list