diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-03-25 05:34:36 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-03-25 21:06:12 +0300 |
commit | 619d977e1a5922fd3f11cf2867c9e9cc1aa54ad7 (patch) | |
tree | 52ef5a209bde6da136dd23b7fae5ab2fb00ba888 /source/blender/gpu/intern/gpu_framebuffer.c | |
parent | 4c660687905a9f03269a9baa21fe2591db168ca7 (diff) |
GPULamp: Move GPU_frambuffer_blur to GPU_lamp.c
This is a bit useless because gpu lamps are only used by the game engine
and it is planned to be "remove" in some way.
Doing this to clean gpu_framebuffer.c.
Diffstat (limited to 'source/blender/gpu/intern/gpu_framebuffer.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_framebuffer.c | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c index b68badc7a3b..a267d9cf1ee 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.c +++ b/source/blender/gpu/intern/gpu_framebuffer.c @@ -439,85 +439,6 @@ void GPU_framebuffer_restore(void) } } -void GPU_framebuffer_blur( - GPUFrameBuffer *fb, GPUTexture *tex, - GPUFrameBuffer *blurfb, GPUTexture *blurtex) -{ - const float fullscreencos[4][2] = {{-1.0f, -1.0f}, {1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}}; - const float fullscreenuvs[4][2] = {{0.0f, 0.0f}, {1.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 1.0f}}; - - static Gwn_VertFormat format = {0}; - static Gwn_VertBuf vbo = {{0}}; - static Gwn_Batch batch = {{0}}; - - const float scaleh[2] = {1.0f / GPU_texture_width(blurtex), 0.0f}; - const float scalev[2] = {0.0f, 1.0f / GPU_texture_height(tex)}; - - GPUShader *blur_shader = GPU_shader_get_builtin_shader(GPU_SHADER_SEP_GAUSSIAN_BLUR); - - if (!blur_shader) - return; - - /* Preparing to draw quad */ - if (format.attrib_ct == 0) { - unsigned int i = 0; - /* Vertex format */ - unsigned int pos = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - unsigned int uvs = GWN_vertformat_attr_add(&format, "uvs", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - - /* Vertices */ - GWN_vertbuf_init_with_format(&vbo, &format); - GWN_vertbuf_data_alloc(&vbo, 36); - - for (int j = 0; j < 3; ++j) { - GWN_vertbuf_attr_set(&vbo, uvs, i, fullscreenuvs[j]); - GWN_vertbuf_attr_set(&vbo, pos, i++, fullscreencos[j]); - } - for (int j = 1; j < 4; ++j) { - GWN_vertbuf_attr_set(&vbo, uvs, i, fullscreenuvs[j]); - GWN_vertbuf_attr_set(&vbo, pos, i++, fullscreencos[j]); - } - - GWN_batch_init(&batch, GL_TRIANGLES, &vbo, NULL); - } - - glDisable(GL_DEPTH_TEST); - - /* Blurring horizontally */ - /* We do the bind ourselves rather than using GPU_framebuffer_texture_bind() to avoid - * pushing unnecessary matrices onto the OpenGL stack. */ - glBindFramebuffer(GL_FRAMEBUFFER, blurfb->object); - glDrawBuffer(GL_COLOR_ATTACHMENT0); - - /* avoid warnings from texture binding */ - g_currentfb = blurfb->object; - - glViewport(0, 0, GPU_texture_width(blurtex), GPU_texture_height(blurtex)); - - GPU_texture_bind(tex, 0); - - GWN_batch_program_set_builtin(&batch, GPU_SHADER_SEP_GAUSSIAN_BLUR); - GWN_batch_uniform_2f(&batch, "ScaleU", scaleh[0], scaleh[1]); - GWN_batch_uniform_1i(&batch, "textureSource", GL_TEXTURE0); - GWN_batch_draw(&batch); - - /* Blurring vertically */ - glBindFramebuffer(GL_FRAMEBUFFER, fb->object); - glDrawBuffer(GL_COLOR_ATTACHMENT0); - - g_currentfb = fb->object; - - glViewport(0, 0, GPU_texture_width(tex), GPU_texture_height(tex)); - - GPU_texture_bind(blurtex, 0); - - /* Hack to make the following uniform stick */ - GWN_batch_program_set_builtin(&batch, GPU_SHADER_SEP_GAUSSIAN_BLUR); - GWN_batch_uniform_2f(&batch, "ScaleU", scalev[0], scalev[1]); - GWN_batch_uniform_1i(&batch, "textureSource", GL_TEXTURE0); - GWN_batch_draw(&batch); -} - void GPU_framebuffer_blit( GPUFrameBuffer *fb_read, int read_slot, GPUFrameBuffer *fb_write, int write_slot, bool use_depth, bool use_stencil) |