[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58533] branches/soc-2013-viewport_fx/ source/blender: Implemented replacement for DrawPixels so that icons and images draw on OpenGL ES and started working on the 'aspect' module, the heart of ViewportFX (finally...)

Jason Wilkins Jason.A.Wilkins at gmail.com
Tue Jul 23 09:54:06 CEST 2013


Revision: 58533
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58533
Author:   jwilkins
Date:     2013-07-23 07:54:05 +0000 (Tue, 23 Jul 2013)
Log Message:
-----------
Implemented replacement for DrawPixels so that icons and images draw on OpenGL ES and started working on the 'aspect' module, the heart of ViewportFX (finally...)

Modified Paths:
--------------
    branches/soc-2013-viewport_fx/source/blender/blenfont/intern/blf.c
    branches/soc-2013-viewport_fx/source/blender/blenkernel/intern/cdderivedmesh.c
    branches/soc-2013-viewport_fx/source/blender/blenkernel/intern/editderivedmesh.c
    branches/soc-2013-viewport_fx/source/blender/blenkernel/intern/subsurf_ccg.c
    branches/soc-2013-viewport_fx/source/blender/editors/include/BIF_glutil.h
    branches/soc-2013-viewport_fx/source/blender/editors/interface/interface_icons.c
    branches/soc-2013-viewport_fx/source/blender/editors/interface/interface_regions.c
    branches/soc-2013-viewport_fx/source/blender/editors/screen/glutil.c
    branches/soc-2013-viewport_fx/source/blender/editors/sculpt_paint/paint_cursor.c
    branches/soc-2013-viewport_fx/source/blender/editors/space_file/file_draw.c
    branches/soc-2013-viewport_fx/source/blender/editors/space_view3d/drawarmature.c
    branches/soc-2013-viewport_fx/source/blender/editors/space_view3d/view3d_draw.c
    branches/soc-2013-viewport_fx/source/blender/gpu/CMakeLists.txt
    branches/soc-2013-viewport_fx/source/blender/gpu/GPU_compatibility.h
    branches/soc-2013-viewport_fx/source/blender/gpu/GPU_matrix.h
    branches/soc-2013-viewport_fx/source/blender/gpu/GPU_object.h
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_extensions.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_immediate.h
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_immediate_glsl.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_material.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_matrix.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_object.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_object_gles.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_object_gles.h
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_pixels.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_state_latch.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_state_latch.h
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_view.h
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_view_gl.c
    branches/soc-2013-viewport_fx/source/blender/windowmanager/intern/wm_dragdrop.c
    branches/soc-2013-viewport_fx/source/blender/windowmanager/intern/wm_draw.c
    branches/soc-2013-viewport_fx/source/blender/windowmanager/intern/wm_init_exit.c
    branches/soc-2013-viewport_fx/source/blender/windowmanager/intern/wm_operators.c

Added Paths:
-----------
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_aspect.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_aspect.h
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_aspectfuncs.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_aspectfuncs.h

Modified: branches/soc-2013-viewport_fx/source/blender/blenfont/intern/blf.c
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/blenfont/intern/blf.c	2013-07-23 07:40:07 UTC (rev 58532)
+++ branches/soc-2013-viewport_fx/source/blender/blenfont/intern/blf.c	2013-07-23 07:54:05 UTC (rev 58533)
@@ -502,6 +502,8 @@
 	}
 
 	if (font->locked == 0) {
+		gpuAspectBegin(GPU_ASPECT_FONT, NULL);
+
 		if (font->shadow || font->blur) {
 			gpuImmediateFormat_T2_C4_V2(); // DOODLE: blurred and/or shadowed text
 		}
@@ -542,6 +544,8 @@
 #endif
 
 		gpuImmediateUnformat();
+
+		gpuAspectEnd(GPU_ASPECT_FONT, NULL);
 	}
 }
 

Modified: branches/soc-2013-viewport_fx/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/blenkernel/intern/cdderivedmesh.c	2013-07-23 07:40:07 UTC (rev 58532)
+++ branches/soc-2013-viewport_fx/source/blender/blenkernel/intern/cdderivedmesh.c	2013-07-23 07:54:05 UTC (rev 58533)
@@ -693,6 +693,8 @@
 
 	cdDM_update_normals_from_pbvh(dm);
 
+	gpuAspectBegin(GPU_ASPECT_TEXTURE, NULL);
+
 	if (GPU_buffer_legacy(dm)) {
 		DEBUG_VBO("Using legacy code. cdDM_drawFacesTex_common\n");
 		gpuImmediateFormat_T2_C4_N3_V3();
@@ -858,6 +860,8 @@
 			}
 		}
 
+		gpuAspectEnd(GPU_ASPECT_TEXTURE, NULL);
+
 		GPU_buffer_unbind();
 		gpuShadeModel(GL_FLAT);
 	}

Modified: branches/soc-2013-viewport_fx/source/blender/blenkernel/intern/editderivedmesh.c
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/blenkernel/intern/editderivedmesh.c	2013-07-23 07:40:07 UTC (rev 58532)
+++ branches/soc-2013-viewport_fx/source/blender/blenkernel/intern/editderivedmesh.c	2013-07-23 07:54:05 UTC (rev 58533)
@@ -599,6 +599,8 @@
 
 	BM_mesh_elem_index_ensure(bm, BM_FACE);
 
+	gpuAspectBegin(GPU_ASPECT_TEXTURE, NULL);
+
 	gpuImmediateFormat_T2_C4_N3_V3();
 
 	/* call again below is ok */
@@ -743,6 +745,8 @@
 
 	gpuImmediateUnformat();
 
+	gpuAspectEnd(GPU_ASPECT_TEXTURE, NULL);
+
 	gpuShadeModel(GL_FLAT);
 }
 

Modified: branches/soc-2013-viewport_fx/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/blenkernel/intern/subsurf_ccg.c	2013-07-23 07:40:07 UTC (rev 58532)
+++ branches/soc-2013-viewport_fx/source/blender/blenkernel/intern/subsurf_ccg.c	2013-07-23 07:54:05 UTC (rev 58533)
@@ -2228,6 +2228,8 @@
 	if (!mcol)
 		mcol = dm->getTessFaceDataArray(dm, CD_TEXTURE_MCOL);
 
+	gpuAspectBegin(GPU_ASPECT_TEXTURE, NULL);
+
 	gpuImmediateFormat_T2_C4_N3_V3(); // DOODLE: heavy textured face drawing
 
 	totface = ccgSubSurf_getNumFaces(ss);
@@ -2354,6 +2356,8 @@
 	}
 
 	gpuImmediateUnformat();
+
+	gpuAspectBegin(GPU_ASPECT_TEXTURE, NULL);
 }
 
 static void ccgDM_drawFacesTex(DerivedMesh *dm,

Modified: branches/soc-2013-viewport_fx/source/blender/editors/include/BIF_glutil.h
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/editors/include/BIF_glutil.h	2013-07-23 07:40:07 UTC (rev 58532)
+++ branches/soc-2013-viewport_fx/source/blender/editors/include/BIF_glutil.h	2013-07-23 07:54:05 UTC (rev 58533)
@@ -115,7 +115,7 @@
 void glaDrawPixelsAuto(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect);
 
 
-void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect, float scaleX, float scaleY);
+void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, const void *rect, float scaleX, float scaleY);
 
 /* 2D Drawing Assistance */
 

Modified: branches/soc-2013-viewport_fx/source/blender/editors/interface/interface_icons.c
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/editors/interface/interface_icons.c	2013-07-23 07:40:07 UTC (rev 58532)
+++ branches/soc-2013-viewport_fx/source/blender/editors/interface/interface_icons.c	2013-07-23 07:54:05 UTC (rev 58533)
@@ -1091,6 +1091,8 @@
 	glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, -0.5f);
 #endif
 
+	gpuAspectBegin(GPU_ASPECT_TEXTURE, NULL);
+
 	gpuImmediateFormat_T2_V2(); // DOODLE: icon, single quad with texture
 	gpuBegin(GL_TRIANGLE_FAN);
 
@@ -1110,6 +1112,8 @@
 	gpuEnd();
 	gpuImmediateUnformat();
 
+	gpuAspectEnd(GPU_ASPECT_TEXTURE, NULL);
+
 #if defined(WITH_GL_PROFILE_COMPAT)
 	glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, 0.0f);
 #endif

Modified: branches/soc-2013-viewport_fx/source/blender/editors/interface/interface_regions.c
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/editors/interface/interface_regions.c	2013-07-23 07:40:07 UTC (rev 58532)
+++ branches/soc-2013-viewport_fx/source/blender/editors/interface/interface_regions.c	2013-07-23 07:54:05 UTC (rev 58533)
@@ -367,12 +367,17 @@
 
 	float background_color[3];
 	float tone_bg;
-	int i, multisample_enabled;
+	int i;
 
+#if defined(WITH_GL_PROFILE_COMPAT) || defined(WITH_GL_PROFILE_CORE)
 	/* disable AA, makes widgets too blurry */
+	int  multisample_enabled;
 	multisample_enabled = glIsEnabled(GL_MULTISAMPLE);
 	if (multisample_enabled)
 		glDisable(GL_MULTISAMPLE);
+#else
+	// XXX jwilkins: multisampling can only be controlled during context creation with ES
+#endif
 
 	/* draw background */
 	ui_draw_tooltip_background(UI_GetStyle(), NULL, &bbox);
@@ -412,8 +417,10 @@
 		GPU_STRING_MARKER("tooltip text end");
 	}
 
+#if defined(WITH_GL_PROFILE_COMPAT) || defined(WITH_GL_PROFILE_CORE)
 	if (multisample_enabled)
 		glEnable(GL_MULTISAMPLE);
+#endif
 }
 
 static void ui_tooltip_region_free_cb(ARegion *ar)

Modified: branches/soc-2013-viewport_fx/source/blender/editors/screen/glutil.c
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/editors/screen/glutil.c	2013-07-23 07:40:07 UTC (rev 58532)
+++ branches/soc-2013-viewport_fx/source/blender/editors/screen/glutil.c	2013-07-23 07:54:05 UTC (rev 58533)
@@ -353,36 +353,39 @@
 	return v;
 }
 
+// XXX jwilkins: it seems like this probably doesn't work like it is supposed to
+
 static int get_cached_work_texture(int *w_r, int *h_r)
 {
 	static GLint texid = -1;
-	static int tex_w = 256;
-	static int tex_h = 256;
+	int tex_w = 1024;//GPU_max_texture_size();//256;
+	int tex_h = 1024;//tex_w;//256;
 
 	if (texid == -1) {
-		GLint ltexid = gpuGetTextureBinding2D();
-		unsigned char *tbuf;
+		//GLint ltexid = gpuGetTextureBinding2D();
+		//unsigned char *tbuf;
 
 		glGenTextures(1, (GLuint *)&texid);
 
-		gpuBindTexture(GL_TEXTURE_2D, texid);
+		//gpuBindTexture(GL_TEXTURE_2D, texid);
 
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+		//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+		//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 
-		tbuf = MEM_callocN(tex_w * tex_h * 4, "tbuf");
-		glTexImage2D(GL_TEXTURE_2D, 0, (GLEW_VERSION_1_1 || GLEW_OES_required_internalformat) ? GL_RGBA8 : GL_RGBA, tex_w, tex_h, 0, GL_RGBA, GL_UNSIGNED_BYTE, tbuf);
-		MEM_freeN(tbuf);
+		//tbuf = MEM_callocN(tex_w * tex_h * 4, "tbuf");
+		//glTexImage2D(GL_TEXTURE_2D, 0, (GLEW_VERSION_1_1 || GLEW_OES_required_internalformat) ? GL_RGBA8 : GL_RGBA, tex_w, tex_h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);//tbuf);
+		//MEM_freeN(tbuf);
 
-		gpuBindTexture(GL_TEXTURE_2D, ltexid); /* restore previous value */
+		//gpuBindTexture(GL_TEXTURE_2D, ltexid); /* restore previous value */
 	}
 
 	*w_r = tex_w;
 	*h_r = tex_h;
+
 	return texid;
 }
 
-void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect, float scaleX, float scaleY)
+void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, const void *rect, float scaleX, float scaleY)
 {
 	float xzoom, yzoom;
 	int ltexid = gpuGetTextureBinding2D();
@@ -410,6 +413,7 @@
 	/* don't want nasty border artifacts */
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, zoomfilter);
 
 	/* setup seamless 2=on, 0=off */
@@ -534,12 +538,19 @@
 	gpuImmediateUnformat();
 
 	gpuBindTexture(GL_TEXTURE_2D, ltexid);
+
+#if defined(WITH_GL_PROFILE_COMPAT)
 	glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); /* restore default value */
+#else
+	// XXX jwilkins: ES doesn't have GL_UNPACK_ROW_LENGTH, so sub images will have to be created on the CPU
+#endif
 }
 
 void glaDrawPixelsTex(float x, float y, int img_w, int img_h, int format, int type, int zoomfilter, void *rect)
 {
+	gpuAspectBegin(GPU_ASPECT_TEXTURE, NULL);
 	glaDrawPixelsTexScaled(x, y, img_w, img_h, format, type, zoomfilter, rect, 1.0f, 1.0f);
+	gpuAspectEnd(GPU_ASPECT_TEXTURE, NULL);
 }
 
 void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int format, int type, void *rect)

Modified: branches/soc-2013-viewport_fx/source/blender/editors/sculpt_paint/paint_cursor.c
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/editors/sculpt_paint/paint_cursor.c	2013-07-23 07:40:07 UTC (rev 58532)
+++ branches/soc-2013-viewport_fx/source/blender/editors/sculpt_paint/paint_cursor.c	2013-07-23 07:54:05 UTC (rev 58533)
@@ -717,6 +717,8 @@
 		        U.sculpt_paint_overlay_col[2],
 		        brush->cursor_overlay_alpha / 100.0f);
 
+		gpuAspectBegin(GPU_ASPECT_TEXTURE, NULL);
+
 		/* draw textured quad */
 		gpuImmediateFormat_T2_V2();
 		gpuBegin(GL_QUADS);
@@ -730,6 +732,8 @@
 		gpuVertex2f(quad.xmin, quad.ymax);
 		gpuEnd();
 		gpuImmediateUnformat();
+
+		gpuAspectEnd(GPU_ASPECT_TEXTURE, NULL);
 	}
 }
 

Modified: branches/soc-2013-viewport_fx/source/blender/editors/space_file/file_draw.c
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/editors/space_file/file_draw.c	2013-07-23 07:40:07 UTC (rev 58532)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list