[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47570] branches/soc-2012-swiss_cheese/ source/blender: more strict checking and logging WITH_GPU_SAFETY + window manager ported to use gpu compatibility layer + fixes to blenfont to work with stricter gpu safety

Jason Wilkins Jason.A.Wilkins at gmail.com
Thu Jun 7 15:18:34 CEST 2012


Revision: 47570
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47570
Author:   jwilkins
Date:     2012-06-07 13:18:22 +0000 (Thu, 07 Jun 2012)
Log Message:
-----------
more strict checking and logging WITH_GPU_SAFETY + window manager ported to use gpu compatibility layer + fixes to blenfont to work with stricter gpu safety

Modified Paths:
--------------
    branches/soc-2012-swiss_cheese/source/blender/blenfont/intern/blf.c
    branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate.c
    branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate.h
    branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate_internal.h
    branches/soc-2012-swiss_cheese/source/blender/windowmanager/intern/wm_dragdrop.c
    branches/soc-2012-swiss_cheese/source/blender/windowmanager/intern/wm_draw.c
    branches/soc-2012-swiss_cheese/source/blender/windowmanager/intern/wm_gesture.c
    branches/soc-2012-swiss_cheese/source/blender/windowmanager/intern/wm_init_exit.c
    branches/soc-2012-swiss_cheese/source/blender/windowmanager/intern/wm_operators.c
    branches/soc-2012-swiss_cheese/source/blender/windowmanager/intern/wm_subwindow.c

Modified: branches/soc-2012-swiss_cheese/source/blender/blenfont/intern/blf.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/blenfont/intern/blf.c	2012-06-07 10:55:53 UTC (rev 47569)
+++ branches/soc-2012-swiss_cheese/source/blender/blenfont/intern/blf.c	2012-06-07 13:18:22 UTC (rev 47570)
@@ -452,7 +452,6 @@
 void BLF_draw_default_lock(void)
 {
 	if (get_default()) {
-		BLF_size(global_font_default, global_font_points, global_font_dpi);
 		BLF_draw_lock(global_font_default);
 	}
 }
@@ -467,10 +466,9 @@
 void BLF_draw_default(float x, float y, float z, const char *str, size_t len)
 {
 	if (str && get_default()) {
-		BLF_draw_default_lock();
+		BLF_size(global_font_default, global_font_points, global_font_dpi);
 		BLF_position(global_font_default, x, y, z);
 		BLF_draw(global_font_default, str, len);
-		BLF_draw_default_unlock();
 	}
 }
 
@@ -478,10 +476,8 @@
 void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len)
 {
 	if (str && get_default()) {
-		BLF_draw_default_lock();
 		BLF_position(global_font_default, x, y, z);
 		BLF_draw(global_font_default, str, len);  /* XXX, use real length */
-		BLF_draw_default_unlock();
 	}
 }
 
@@ -500,16 +496,17 @@
 	if (gpuImmediateLockCount() == 0) {
 		glEnable(GL_TEXTURE_2D);
 
-		glEnable(GL_BLEND);
-		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+		if (font->shadow || font->blur) {
+			gpuImmediateFormat_T2_C4_V2(); // DOODLE: blurred and/or shadowed text
+		}
+		else {
+			gpuImmediateFormat_T2_V2(); // DOODLE: normal text
+		}
 	}
 
-	if (font->shadow || font->blur) {
-		gpuImmediateFormat_T2_C4_V2(); // DOODLE: blurred and/or shadowed text
-	}
-	else {
-		gpuImmediateFormat_T2_V2(); // DOODLE: normal text
-	}
+	glEnable(GL_BLEND);
+	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
 }
 
 void BLF_draw_lock(int fontid)
@@ -523,11 +520,11 @@
 
 void BLF_draw_unlock(void)
 {
-	gpuImmediateUnformat();
+	glDisable(GL_BLEND);
+	glDisable(GL_TEXTURE_2D);
 
-	if (gpuImmediateLockCount() == 0) {
-		glDisable(GL_BLEND);
-		glDisable(GL_TEXTURE_2D);
+	if (gpuImmediateLockCount() == 1) {
+		gpuImmediateUnformat();
 	}
 }
 

Modified: branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate.c	2012-06-07 10:55:53 UTC (rev 47569)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate.c	2012-06-07 13:18:22 UTC (rev 47570)
@@ -211,7 +211,7 @@
 
 
 
-void gpuDeleteImmediate(GPUimmediate *restrict immediate)
+void gpuImmediateDelete(GPUimmediate *restrict immediate)
 {
 	if (!immediate) {
 		return;
@@ -503,8 +503,16 @@
 
 /* vertex formats */
 
+#if GPU_SAFETY
+void gpu_ImmediateFormat_V2(const char* file, int line)
+#else
 void gpuImmediateFormat_V2(void)
+#endif
 {
+#if GPU_SAFETY
+	printf("%s(%d): gpuImmediateFormat_V2\n", file, line);
+#endif
+
 	if (gpuImmediateLockCount() == 0) {
 		gpuImmediateElementSizes(2, 0, 0);
 	}
@@ -512,8 +520,16 @@
 	gpuImmediateLock();
 }
 
+#if GPU_SAFETY
+void gpu_ImmediateFormat_C4_V2(const char* file, int line)
+#else
 void gpuImmediateFormat_C4_V2(void)
+#endif
 {
+#if GPU_SAFETY
+	printf("%s(%d): gpuImmediateFormat_C4_V2\n", file, line);
+#endif
+
 	if (gpuImmediateLockCount() == 0) {
 		gpuImmediateElementSizes(2, 0, 4);
 	}
@@ -521,8 +537,16 @@
 	gpuImmediateLock();
 }
 
+#if GPU_SAFETY
+void gpu_ImmediateFormat_T2_V2(const char* file, int line)
+#else
 void gpuImmediateFormat_T2_V2(void)
+#endif
 {
+#if GPU_SAFETY
+	printf("%s(%d): gpuImmediateFormat_T2_V2\n", file, line);
+#endif
+
 	if (gpuImmediateLockCount() == 0) {
 		GLint texCoordSizes[1] = { 2 };
 		GLenum texUnitMap[1]    = { GL_TEXTURE0 };
@@ -537,8 +561,16 @@
 	gpuImmediateLock();
 }
 
+#if GPU_SAFETY
+void gpu_ImmediateFormat_T2_C4_V2(const char* file, int line)
+#else
 void gpuImmediateFormat_T2_C4_V2(void)
+#endif
 {
+#if GPU_SAFETY
+	printf("%s(%d): gpuImmediateFormat_T2_C4_V2\n", file, line);
+#endif
+
 	if (gpuImmediateLockCount() == 0) {
 		GLint texCoordSizes[1] = { 2 };
 		GLenum texUnitMap[1]    = { GL_TEXTURE0 };
@@ -553,8 +585,16 @@
 	gpuImmediateLock();
 }
 
+#if GPU_SAFETY
+void gpu_ImmediateFormat_V3(const char* file, int line)
+#else
 void gpuImmediateFormat_V3(void)
+#endif
 {
+#if GPU_SAFETY
+	printf("%s(%d): gpuImmediateFormat_V3\n", file, line);
+#endif
+
 	if (gpuImmediateLockCount() == 0) {
 		gpuImmediateElementSizes(3, 0, 0);
 	}
@@ -562,8 +602,16 @@
 	gpuImmediateLock();
 }
 
+#if GPU_SAFETY
+void gpu_ImmediateFormat_N3_V3(const char* file, int line)
+#else
 void gpuImmediateFormat_N3_V3(void)
+#endif
 {
+#if GPU_SAFETY
+	printf("%s(%d): gpuImmediateFormat_N3_V3\n", file, line);
+#endif
+
 	if (gpuImmediateLockCount() == 0) {
 		gpuImmediateElementSizes(3, 3, 0);
 	}
@@ -571,8 +619,16 @@
 	gpuImmediateLock();
 }
 
+#if GPU_SAFETY
+void gpu_ImmediateFormat_C4_V3(const char* file, int line)
+#else
 void gpuImmediateFormat_C4_V3(void)
+#endif
 {
+#if GPU_SAFETY
+	printf("%s(%d): gpuImmediateFormat_C4_V3\n", file, line);
+#endif
+
 	if (gpuImmediateLockCount() == 0) {
 		gpuImmediateElementSizes(3, 0, 4); //-V112
 	}
@@ -580,8 +636,16 @@
 	gpuImmediateLock();
 }
 
+#if GPU_SAFETY
+void gpu_ImmediateFormat_C4_N3_V3(const char* file, int line)
+#else
 void gpuImmediateFormat_C4_N3_V3(void)
+#endif
 {
+#if GPU_SAFETY
+	printf("%s(%d): gpuImmediateFormat_C4_N3_V3\n", file, line);
+#endif
+
 	if (gpuImmediateLockCount() == 0) {
 		gpuImmediateElementSizes(3, 3, 4); //-V112
 	}
@@ -589,8 +653,16 @@
 	gpuImmediateLock();
 }
 
+#if GPU_SAFETY
+void gpu_ImmediateFormat_T2_C4_N3_V3(const char* file, int line)
+#else
 void gpuImmediateFormat_T2_C4_N3_V3(void)
+#endif
 {
+#if GPU_SAFETY
+	printf("%s(%d): gpuImmediateFormat_T2_C4_N3_V3\n", file, line);
+#endif
+
 	if (gpuImmediateLockCount() == 0) {
 
 		GLint texCoordSizes[1] = { 2 };
@@ -605,8 +677,16 @@
 	gpuImmediateLock();
 }
 
+#if GPU_SAFETY
+void gpu_ImmediateFormat_T3_C4_V3(const char* file, int line)
+#else
 void gpuImmediateFormat_T3_C4_V3(void)
+#endif
 {
+#if GPU_SAFETY
+	printf("%s(%d): gpuImmediateFormat_T3_C4_V3\n", file, line);
+#endif
+
 	if (gpuImmediateLockCount() == 0) {
 
 		GLint texCoordSizes[1] = { 3 };
@@ -621,8 +701,16 @@
 	gpuImmediateLock();
 }
 
+#if GPU_SAFETY
+void gpu_ImmediateUnformat(const char* file, int line)
+#else
 void gpuImmediateUnformat(void)
+#endif
 {
+#if GPU_SAFETY
+	printf("%s(%d): gpuImmediateUnformat\n", file, line);
+#endif
+
 	gpuImmediateUnlock();
 }
 

Modified: branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate.h
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate.h	2012-06-07 10:55:53 UTC (rev 47569)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate.h	2012-06-07 13:18:22 UTC (rev 47570)
@@ -241,7 +241,7 @@
 
 GPUimmediate* gpuNewImmediate(void);
 void gpuImmediateMakeCurrent(GPUimmediate *restrict  immediate);
-void gpuDeleteImmediate(GPUimmediate *restrict  immediate);
+void gpuImmediateDelete(GPUimmediate *restrict  immediate);
 
 
 
@@ -269,6 +269,8 @@
 
 
 /* utility functions to setup vertex format and lock */
+#if !GPU_SAFETY
+
 void gpuImmediateFormat_V2(void);
 void gpuImmediateFormat_C4_V2(void);
 void gpuImmediateFormat_T2_V2(void);
@@ -281,8 +283,36 @@
 void gpuImmediateFormat_T3_C4_V3(void);
 void gpuImmediateUnformat(void);
 
+#else
 
+void gpu_ImmediateFormat_V2(const char* file, int line);
+void gpu_ImmediateFormat_C4_V2(const char* file, int line);
+void gpu_ImmediateFormat_T2_V2(const char* file, int line);
+void gpu_ImmediateFormat_T2_C4_V2(const char* file, int line);
+void gpu_ImmediateFormat_V3(const char* file, int line);
+void gpu_ImmediateFormat_N3_V3(const char* file, int line);
+void gpu_ImmediateFormat_C4_V3(const char* file, int line);
+void gpu_ImmediateFormat_C4_N3_V3(const char* file, int line);
+void gpu_ImmediateFormat_T2_C4_N3_V3(const char* file, int line);
+void gpu_ImmediateFormat_T3_C4_V3(const char* file, int line);
+void gpu_ImmediateUnformat(const char* file, int line);
 
+#define gpuImmediateFormat_V2() gpu_ImmediateFormat_V2(__FILE__, __LINE__)
+#define gpuImmediateFormat_C4_V2() gpu_ImmediateFormat_C4_V2(__FILE__, __LINE__)
+#define gpuImmediateFormat_T2_V2() gpu_ImmediateFormat_T2_V2(__FILE__, __LINE__)
+#define gpuImmediateFormat_T2_C4_V2() gpu_ImmediateFormat_T2_C4_V2(__FILE__, __LINE__)
+#define gpuImmediateFormat_V3() gpu_ImmediateFormat_V3(__FILE__, __LINE__)
+#define gpuImmediateFormat_N3_V3() gpu_ImmediateFormat_N3_V3(__FILE__, __LINE__)
+#define gpuImmediateFormat_C4_V3() gpu_ImmediateFormat_C4_V3(__FILE__, __LINE__)
+#define gpuImmediateFormat_C4_N3_V3() gpu_ImmediateFormat_C4_N3_V3(__FILE__, __LINE__)
+#define gpuImmediateFormat_T2_C4_N3_V3() gpu_ImmediateFormat_T2_C4_N3_V3(__FILE__, __LINE__)
+#define gpuImmediateFormat_T3_C4_V3() gpu_ImmediateFormat_T3_C4_V3(__FILE__, __LINE__)
+#define gpuImmediateUnformat() gpu_ImmediateUnformat(__FILE__, __LINE__)
+
+#endif
+
+
+
 #ifdef __cplusplus
 }
 #endif

Modified: branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate_internal.h
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate_internal.h	2012-06-07 10:55:53 UTC (rev 47569)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_immediate_internal.h	2012-06-07 13:18:22 UTC (rev 47570)
@@ -78,12 +78,14 @@
     GPU_SAFE_RETURN(GPU_IMMEDIATE->lockCount == 0, noBeginOK, NULL); \
     }
 
-#define GPU_CHECK_CAN_LOCK()      \
-    {                             \
-    GLboolean immediateOK;        \
-    GLboolean noBeginOK;          \
-    GPU_CHECK_BASE(immediateOK);  \
-    GPU_CHECK_NO_BEGIN(noBeginOK) \
+#define GPU_CHECK_CAN_LOCK()       \
+    {                              \
+    GLboolean immediateOK;         \
+    GLboolean noBeginOK;           \
+    GLboolean noLockOK;            \
+    GPU_CHECK_BASE(immediateOK);   \
+    GPU_CHECK_NO_BEGIN(noBeginOK); \
+    GPU_CHECK_NO_LOCK(noLockOK);   \
     }
 
 #define GPU_CHECK_CAN_UNLOCK()      \
@@ -96,7 +98,13 @@
     GPU_CHECK_NO_BEGIN(noBeginOK)   \
     }
 
-#define GPU_CHECK_CAN_CURRENT() GPU_CHECK_CAN_LOCK()
+#define GPU_CHECK_CAN_CURRENT()    \
+    {                              \
+    GLboolean immediateOK;         \
+    GLboolean noBeginOK;           \
+    GPU_CHECK_BASE(immediateOK);   \
+    GPU_CHECK_NO_BEGIN(noBeginOK); \

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list