[Bf-blender-cvs] [1463ec68962] blender2.8: DRW: Rename ogl_context to gl_context

Clément Foucault noreply at git.blender.org
Mon Jun 11 13:56:44 CEST 2018


Commit: 1463ec68962380b015d7cbf3f65eadbd06ff3c4a
Author: Clément Foucault
Date:   Mon Jun 11 11:38:26 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB1463ec68962380b015d7cbf3f65eadbd06ff3c4a

DRW: Rename ogl_context to gl_context

We might not use opengl forever :)

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

M	source/blender/draw/intern/draw_manager.c
M	source/blender/draw/intern/draw_manager.h
M	source/blender/draw/intern/draw_manager_shader.c

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

diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 75649f7eebb..65702a65541 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -100,7 +100,7 @@ extern struct GPUUniformBuffer *view_ubo; /* draw_manager_exec.c */
 
 static void drw_state_prepare_clean_for_draw(DRWManager *dst)
 {
-	memset(dst, 0x0, offsetof(DRWManager, ogl_context));
+	memset(dst, 0x0, offsetof(DRWManager, gl_context));
 }
 
 /* This function is used to reset draw manager to a state
@@ -110,7 +110,7 @@ static void drw_state_prepare_clean_for_draw(DRWManager *dst)
 #ifdef DEBUG
 static void drw_state_ensure_not_reused(DRWManager *dst)
 {
-	memset(dst, 0xff, offsetof(DRWManager, ogl_context));
+	memset(dst, 0xff, offsetof(DRWManager, gl_context));
 }
 #endif
 
@@ -1180,7 +1180,7 @@ void DRW_notify_view_update(const DRWUpdateContext *update_ctx)
 		/* XXX Really nasty locking. But else this could
 		 * be executed by the material previews thread
 		 * while rendering a viewport. */
-		BLI_mutex_lock(&DST.ogl_context_mutex);
+		BLI_mutex_lock(&DST.gl_context_mutex);
 
 		/* Reset before using it. */
 		drw_state_prepare_clean_for_draw(&DST);
@@ -1208,7 +1208,7 @@ void DRW_notify_view_update(const DRWUpdateContext *update_ctx)
 
 		drw_engines_disable();
 
-		BLI_mutex_unlock(&DST.ogl_context_mutex);
+		BLI_mutex_unlock(&DST.gl_context_mutex);
 	}
 }
 
@@ -1460,7 +1460,7 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph)
 	RenderData *r = &scene->r;
 	Render *render = engine->re;
 
-	if (G.background && DST.ogl_context == NULL) {
+	if (G.background && DST.gl_context == NULL) {
 		WM_init_opengl();
 	}
 
@@ -2152,14 +2152,14 @@ void DRW_engines_free(void)
 
 void DRW_opengl_context_create(void)
 {
-	BLI_assert(DST.ogl_context == NULL); /* Ensure it's called once */
+	BLI_assert(DST.gl_context == NULL); /* Ensure it's called once */
 
-	BLI_mutex_init(&DST.ogl_context_mutex);
+	BLI_mutex_init(&DST.gl_context_mutex);
 	if (!G.background) {
 		immDeactivate();
 	}
 	/* This changes the active context. */
-	DST.ogl_context = WM_opengl_context_create();
+	DST.gl_context = WM_opengl_context_create();
 	/* Be sure to create gawain.context too. */
 	DST.gwn_context = GWN_context_create();
 	if (!G.background) {
@@ -2174,28 +2174,28 @@ void DRW_opengl_context_create(void)
 void DRW_opengl_context_destroy(void)
 {
 	BLI_assert(BLI_thread_is_main());
-	if (DST.ogl_context != NULL) {
-		WM_opengl_context_activate(DST.ogl_context);
+	if (DST.gl_context != NULL) {
+		WM_opengl_context_activate(DST.gl_context);
 		GWN_context_active_set(DST.gwn_context);
 		GWN_context_discard(DST.gwn_context);
-		WM_opengl_context_dispose(DST.ogl_context);
-		BLI_mutex_end(&DST.ogl_context_mutex);
+		WM_opengl_context_dispose(DST.gl_context);
+		BLI_mutex_end(&DST.gl_context_mutex);
 	}
 }
 
 void DRW_opengl_context_enable(void)
 {
-	if (DST.ogl_context != NULL) {
+	if (DST.gl_context != NULL) {
 		/* IMPORTANT: We dont support immediate mode in render mode!
 		 * This shall remain in effect until immediate mode supports
 		 * multiple threads. */
-		BLI_mutex_lock(&DST.ogl_context_mutex);
+		BLI_mutex_lock(&DST.gl_context_mutex);
 		if (BLI_thread_is_main()) {
 			if (!G.background) {
 				immDeactivate();
 			}
 		}
-		WM_opengl_context_activate(DST.ogl_context);
+		WM_opengl_context_activate(DST.gl_context);
 		GWN_context_active_set(DST.gwn_context);
 		if (BLI_thread_is_main()) {
 			if (!G.background) {
@@ -2208,7 +2208,7 @@ void DRW_opengl_context_enable(void)
 
 void DRW_opengl_context_disable(void)
 {
-	if (DST.ogl_context != NULL) {
+	if (DST.gl_context != NULL) {
 #ifdef __APPLE__
 		/* Need to flush before disabling draw context, otherwise it does not
 		 * always finish drawing and viewport can be empty or partially drawn */
@@ -2219,11 +2219,11 @@ void DRW_opengl_context_disable(void)
 			wm_window_reset_drawable();
 		}
 		else {
-			WM_opengl_context_release(DST.ogl_context);
+			WM_opengl_context_release(DST.gl_context);
 			GWN_context_active_set(NULL);
 		}
 
-		BLI_mutex_unlock(&DST.ogl_context_mutex);
+		BLI_mutex_unlock(&DST.gl_context_mutex);
 	}
 }
 
diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h
index 7cb6aef818b..e811e9ea8a9 100644
--- a/source/blender/draw/intern/draw_manager.h
+++ b/source/blender/draw/intern/draw_manager.h
@@ -369,11 +369,11 @@ typedef struct DRWManager {
 
 	/* ---------- Nothing after this point is cleared after use ----------- */
 
-	/* ogl_context serves as the offset for clearing only
+	/* gl_context serves as the offset for clearing only
 	 * the top portion of the struct so DO NOT MOVE IT! */
-	void *ogl_context;                /* Unique ghost context used by the draw manager. */
+	void *gl_context;                /* Unique ghost context used by the draw manager. */
 	Gwn_Context *gwn_context;
-	ThreadMutex ogl_context_mutex;    /* Mutex to lock the drw manager and avoid concurent context usage. */
+	ThreadMutex gl_context_mutex;    /* Mutex to lock the drw manager and avoid concurent context usage. */
 
 	/** GPU Resource State: Memory storage between drawing. */
 	struct {
diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c
index 0b6974b7b36..edc65afd465 100644
--- a/source/blender/draw/intern/draw_manager_shader.c
+++ b/source/blender/draw/intern/draw_manager_shader.c
@@ -71,7 +71,7 @@ typedef struct DRWShaderCompiler {
 	DRWDeferredShader *mat_compiling;
 	ThreadMutex compilation_lock;
 
-	void *ogl_context;
+	void *gl_context;
 
 	int shaders_done; /* To compute progress. */
 } DRWShaderCompiler;
@@ -93,9 +93,9 @@ static void drw_deferred_shader_queue_free(ListBase *queue)
 static void drw_deferred_shader_compilation_exec(void *custom_data, short *stop, short *do_update, float *progress)
 {
 	DRWShaderCompiler *comp = (DRWShaderCompiler *)custom_data;
-	void *ogl_context = comp->ogl_context;
+	void *gl_context = comp->gl_context;
 
-	WM_opengl_context_activate(ogl_context);
+	WM_opengl_context_activate(gl_context);
 
 	while (true) {
 		BLI_spin_lock(&comp->list_lock);
@@ -134,7 +134,7 @@ static void drw_deferred_shader_compilation_exec(void *custom_data, short *stop,
 		drw_deferred_shader_free(comp->mat_compiling);
 	}
 
-	WM_opengl_context_release(ogl_context);
+	WM_opengl_context_release(gl_context);
 }
 
 static void drw_deferred_shader_compilation_free(void *custom_data)
@@ -146,9 +146,9 @@ static void drw_deferred_shader_compilation_free(void *custom_data)
 	BLI_spin_end(&comp->list_lock);
 	BLI_mutex_end(&comp->compilation_lock);
 
-	if (comp->ogl_context) {
+	if (comp->gl_context) {
 		/* Only destroy if the job owns the context. */
-		WM_opengl_context_dispose(comp->ogl_context);
+		WM_opengl_context_dispose(comp->gl_context);
 	}
 
 	MEM_freeN(comp);
@@ -189,16 +189,16 @@ static void drw_deferred_shader_add(GPUMaterial *mat)
 		BLI_movelisttolist(&comp->queue, &old_comp->queue);
 		BLI_spin_unlock(&old_comp->list_lock);
 		/* Do not recreate context, just pass ownership. */
-		comp->ogl_context = old_comp->ogl_context;
-		old_comp->ogl_context = NULL;
+		comp->gl_context = old_comp->gl_context;
+		old_comp->gl_context = NULL;
 	}
 
 	BLI_addtail(&comp->queue, dsh);
 
 	/* Create only one context. */
-	if (comp->ogl_context == NULL) {
-		comp->ogl_context = WM_opengl_context_create();
-		WM_opengl_context_activate(DST.ogl_context);
+	if (comp->gl_context == NULL) {
+		comp->gl_context = WM_opengl_context_create();
+		WM_opengl_context_activate(DST.gl_context);
 	}
 
 	WM_jobs_customdata_set(wm_job, comp, drw_deferred_shader_compilation_free);



More information about the Bf-blender-cvs mailing list