Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTomoaki Kawada <i@yvt.jp>2019-06-01 18:54:07 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-06-02 13:50:50 +0300
commit62fe7e9a9d0e211bc2ad4cdfedb2489c5f899133 (patch)
treecaa21887fa80485937012a17edcea8126ae7482e /source
parent2a5dc454f63a4c3442d0ff0715cbd3d135bb5ca7 (diff)
GPU: support default framebuffer with ID not equal to 0
Diffstat (limited to 'source')
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightcache.c2
-rw-r--r--source/blender/draw/intern/draw_manager.c2
-rw-r--r--source/blender/gpu/GPU_context.h2
-rw-r--r--source/blender/gpu/intern/gpu_context.cpp12
-rw-r--r--source/blender/gpu/intern/gpu_context_private.h1
-rw-r--r--source/blender/gpu/intern/gpu_extensions.c9
-rw-r--r--source/blender/gpu/intern/gpu_framebuffer.c6
-rw-r--r--source/blender/render/intern/source/pipeline.c2
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c3
-rw-r--r--source/blender/windowmanager/intern/wm_window.c3
10 files changed, 23 insertions, 19 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c
index 149ebae1137..ebdc7813335 100644
--- a/source/blender/draw/engines/eevee/eevee_lightcache.c
+++ b/source/blender/draw/engines/eevee/eevee_lightcache.c
@@ -409,7 +409,7 @@ static void eevee_lightbake_context_enable(EEVEE_LightBake *lbake)
if (lbake->gl_context) {
DRW_opengl_render_context_enable(lbake->gl_context);
if (lbake->gpu_context == NULL) {
- lbake->gpu_context = GPU_context_create();
+ lbake->gpu_context = GPU_context_create(0);
}
DRW_gawain_render_context_enable(lbake->gpu_context);
}
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 9e69cfa7ea4..08e8a8c001e 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -3158,7 +3158,7 @@ void DRW_opengl_context_create(void)
DST.gl_context = WM_opengl_context_create();
WM_opengl_context_activate(DST.gl_context);
/* Be sure to create gawain.context too. */
- DST.gpu_context = GPU_context_create();
+ DST.gpu_context = GPU_context_create(0);
if (!G.background) {
immActivate();
}
diff --git a/source/blender/gpu/GPU_context.h b/source/blender/gpu/GPU_context.h
index 1f812129e29..ebeb104b7e8 100644
--- a/source/blender/gpu/GPU_context.h
+++ b/source/blender/gpu/GPU_context.h
@@ -36,7 +36,7 @@ extern "C" {
typedef struct GPUContext GPUContext;
-GPUContext *GPU_context_create(void);
+GPUContext *GPU_context_create(GLuint default_framebuffer);
void GPU_context_discard(GPUContext *);
void GPU_context_active_set(GPUContext *);
diff --git a/source/blender/gpu/intern/gpu_context.cpp b/source/blender/gpu/intern/gpu_context.cpp
index 4bfc44327c2..a0e03e61d5d 100644
--- a/source/blender/gpu/intern/gpu_context.cpp
+++ b/source/blender/gpu/intern/gpu_context.cpp
@@ -64,6 +64,7 @@ static std::mutex orphans_mutex;
struct GPUContext {
GLuint default_vao;
+ GLuint default_framebuffer;
GPUFrameBuffer *current_fbo;
std::unordered_set<GPUBatch *> batches; /* Batches that have VAOs from this context */
#ifdef DEBUG
@@ -137,11 +138,12 @@ static void orphans_clear(GPUContext *ctx)
orphans_mutex.unlock();
}
-GPUContext *GPU_context_create(void)
+GPUContext *GPU_context_create(GLuint default_framebuffer)
{
/* BLI_assert(thread_is_main()); */
GPUContext *ctx = new GPUContext;
glGenVertexArrays(1, &ctx->default_vao);
+ ctx->default_framebuffer = default_framebuffer;
GPU_context_active_set(ctx);
return ctx;
}
@@ -201,6 +203,14 @@ GLuint GPU_vao_default(void)
return active_ctx->default_vao;
}
+GLuint GPU_framebuffer_default(void)
+{
+ BLI_assert(active_ctx); /* need at least an active context */
+ BLI_assert(pthread_equal(
+ pthread_self(), active_ctx->thread)); /* context has been activated by another thread! */
+ return active_ctx->default_framebuffer;
+}
+
GLuint GPU_vao_alloc(void)
{
GLuint new_vao_id = 0;
diff --git a/source/blender/gpu/intern/gpu_context_private.h b/source/blender/gpu/intern/gpu_context_private.h
index 9c4cb30e40f..6825b67d2c8 100644
--- a/source/blender/gpu/intern/gpu_context_private.h
+++ b/source/blender/gpu/intern/gpu_context_private.h
@@ -35,6 +35,7 @@ extern "C" {
struct GPUFrameBuffer;
GLuint GPU_vao_default(void);
+GLuint GPU_framebuffer_default(void);
/* These require a gl ctx bound. */
GLuint GPU_buf_alloc(void);
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c
index 57734686b23..8cd554cc9d5 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -244,15 +244,6 @@ void gpu_extensions_init(void)
glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, GG.line_width_range);
-#ifndef NDEBUG
- GLint ret;
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
- glGetFramebufferAttachmentParameteriv(
- GL_FRAMEBUFFER, GL_FRONT_LEFT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &ret);
- /* We expect FRONT_LEFT to be the default buffer. */
- BLI_assert(ret == GL_FRAMEBUFFER_DEFAULT);
-#endif
-
glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &GG.samples_color_texture_max);
const char *vendor = (const char *)glGetString(GL_VENDOR);
diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c
index 62fb02931ab..98ab6d96c0a 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.c
+++ b/source/blender/gpu/intern/gpu_framebuffer.c
@@ -539,7 +539,7 @@ void GPU_framebuffer_bind(GPUFrameBuffer *fb)
void GPU_framebuffer_restore(void)
{
if (GPU_framebuffer_active_get() != NULL) {
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ glBindFramebuffer(GL_FRAMEBUFFER, GPU_framebuffer_default());
gpu_framebuffer_current_set(NULL);
}
}
@@ -718,7 +718,7 @@ void GPU_framebuffer_blit(GPUFrameBuffer *fb_read,
gpu_framebuffer_current_set(prev_fb);
}
else {
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ glBindFramebuffer(GL_FRAMEBUFFER, GPU_framebuffer_default());
gpu_framebuffer_current_set(NULL);
}
}
@@ -909,7 +909,7 @@ void GPU_offscreen_draw_to_screen(GPUOffScreen *ofs, int x, int y)
gpu_print_framebuffer_error(status, NULL);
}
- glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, GPU_framebuffer_default());
}
void GPU_offscreen_read_pixels(GPUOffScreen *ofs, int type, void *pixels)
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index 76767d0d1d8..6bde162f507 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -1116,7 +1116,7 @@ void *RE_gl_context_get(Render *re)
void *RE_gpu_context_get(Render *re)
{
if (re->gpu_context == NULL) {
- re->gpu_context = GPU_context_create();
+ re->gpu_context = GPU_context_create(0);
}
return re->gpu_context;
}
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index 7cc44bcad99..51dccf5bb8b 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -1287,7 +1287,8 @@ static char *wm_main_playanim_intern(int argc, const char **argv)
// GHOST_ActivateWindowDrawingContext(g_WS.ghost_window);
/* initialize OpenGL immediate mode */
- g_WS.gpu_context = GPU_context_create();
+ GLuint default_fb = GHOST_GetDefaultOpenGLFramebuffer(g_WS.ghost_window);
+ g_WS.gpu_context = GPU_context_create(default_fb);
GPU_init();
immActivate();
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 7ae572e5685..e9cf1cc5469 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -581,7 +581,8 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm
if (ghostwin) {
GHOST_RectangleHandle bounds;
- win->gpuctx = GPU_context_create();
+ GLuint default_fb = GHOST_GetDefaultOpenGLFramebuffer(ghostwin);
+ win->gpuctx = GPU_context_create(default_fb);
/* needed so we can detect the graphics card below */
GPU_init();