[Bf-blender-cvs] [ca550d20738] greasepencil-object: Create multisample buffer for render
Antonio Vazquez
noreply at git.blender.org
Sat Feb 10 17:58:39 CET 2018
Commit: ca550d207383cd6c540892eb01e63af214cd4f1a
Author: Antonio Vazquez
Date: Sat Feb 10 17:58:25 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rBca550d207383cd6c540892eb01e63af214cd4f1a
Create multisample buffer for render
As render does not create default buffers by default, the render needs to create multisample default buffer in order to use antialiasing.
===================================================================
M source/blender/draw/engines/gpencil/gpencil_engine.c
M source/blender/draw/intern/DRW_render.h
M source/blender/draw/intern/draw_manager.c
===================================================================
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 2e84547b2fd..e0754aea5be 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -896,6 +896,13 @@ void GPENCIL_render_init(GPENCIL_Data *ved, RenderEngine *engine, struct Depsgra
* because there is no viewport. So we need to manually create one
* NOTE : use 32 bit format for precision in render mode.
*/
+ DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
+ DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
+
+ int rect_w = (int)viewport_size[0];
+ int rect_h = (int)viewport_size[1];
+ DRW_framebuffer_create_multisample(dfbl, dtxl, rect_w, rect_h);
+
DRWFboTexture tex_color[2] = {
{ &e_data.render_depth_tx, DRW_TEX_DEPTH_24_STENCIL_8, DRW_TEX_TEMP },
{ &e_data.render_color_tx, DRW_TEX_RGBA_32, DRW_TEX_TEMP }
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index 8eb10ed5a14..ac05754ca2e 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -235,6 +235,8 @@ struct GPUFrameBuffer *DRW_framebuffer_create(void);
void DRW_framebuffer_init(
struct GPUFrameBuffer **fb, void *engine_type, int width, int height,
DRWFboTexture textures[MAX_FBO_TEX], int textures_len);
+void DRW_framebuffer_create_multisample(struct DefaultFramebufferList *dfbl,
+ struct DefaultTextureList *dtx, int rect_w, int rect_h);
void DRW_framebuffer_bind(struct GPUFrameBuffer *fb);
void DRW_framebuffer_clear(bool color, bool depth, bool stencil, float clear_col[4], float clear_depth);
void DRW_framebuffer_read_data(int x, int y, int w, int h, int channels, int slot, float *data);
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 3f57709810e..b00243bd6f4 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -2382,6 +2382,29 @@ void DRW_framebuffer_init(
}
}
+/* create multisample framebuffer */
+void DRW_framebuffer_create_multisample(DefaultFramebufferList *dfbl, DefaultTextureList *dtxl, int rect_w, int rect_h)
+{
+ if (U.ogl_multisamples > 0) {
+ if (!dfbl->default_fb) {
+ dfbl->multisample_fb = GPU_framebuffer_create();
+ if (dfbl->multisample_fb) {
+ /* Color */
+ dtxl->multisample_color = GPU_texture_create_2D_multisample(rect_w, rect_h, NULL, U.ogl_multisamples, NULL);
+ GPU_framebuffer_texture_attach(dfbl->multisample_fb, dtxl->multisample_color, 0, 0);
+ /* Depth */
+ dtxl->multisample_depth = GPU_texture_create_depth_with_stencil_multisample(rect_w, rect_h,
+ U.ogl_multisamples, NULL);
+ GPU_framebuffer_texture_attach(dfbl->multisample_fb, dtxl->multisample_depth, 0, 0);
+
+ if (!GPU_framebuffer_check_valid(dfbl->multisample_fb, NULL)) {
+ GPU_framebuffer_free(dfbl->multisample_fb);
+ }
+ }
+ }
+ }
+}
+
void DRW_framebuffer_free(struct GPUFrameBuffer *fb)
{
GPU_framebuffer_free(fb);
More information about the Bf-blender-cvs
mailing list