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
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/blender/gpu/intern
parent2a5dc454f63a4c3442d0ff0715cbd3d135bb5ca7 (diff)
GPU: support default framebuffer with ID not equal to 0
Diffstat (limited to 'source/blender/gpu/intern')
-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
4 files changed, 15 insertions, 13 deletions
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)