[Bf-blender-cvs] [b3a11b65842] viewport-compositor: Merge branch 'eevee-rewrite' into viewport-compositor
Omar Emara
noreply at git.blender.org
Fri Feb 18 08:38:30 CET 2022
Commit: b3a11b658429f0e07c474ea980eecbbe06a2f73d
Author: Omar Emara
Date: Fri Feb 18 09:37:49 2022 +0200
Branches: viewport-compositor
https://developer.blender.org/rBb3a11b658429f0e07c474ea980eecbbe06a2f73d
Merge branch 'eevee-rewrite' into viewport-compositor
===================================================================
===================================================================
diff --cc source/blender/draw/CMakeLists.txt
index 3374181bc16,4cba8e5320c..15c16ae457e
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@@ -135,8 -136,6 +136,7 @@@ set(SR
intern/smaa_textures.c
engines/basic/basic_engine.c
engines/basic/basic_shader.c
+ engines/compositor/compositor_engine.cc
- engines/compositor/compositor_shader.cc
engines/image/image_engine.cc
engines/image/image_shader.cc
engines/eevee/eevee_camera.cc
@@@ -243,8 -241,6 +242,7 @@@
intern/smaa_textures.h
engines/basic/basic_engine.h
engines/basic/basic_private.h
+ engines/compositor/compositor_engine.h
- engines/compositor/compositor_shader.hh
engines/eevee/eevee_engine.h
engines/eevee/eevee_lightcache.h
engines/eevee/eevee_camera.hh
diff --cc source/blender/draw/engines/compositor/compositor_engine.cc
index bca0fc98a25,00000000000..33f5ff42041
mode 100644,000000..100644
--- a/source/blender/draw/engines/compositor/compositor_engine.cc
+++ b/source/blender/draw/engines/compositor/compositor_engine.cc
@@@ -1,238 -1,0 +1,44 @@@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright 2021, Blender Foundation.
+ */
+
- /** \file
- * \ingroup draw_engine
- *
- * Engine processing the render buffer using GLSL to apply the scene compositing node tree.
- */
++#include "BLT_translation.h"
+
+#include "DRW_render.h"
+
- #include "BLI_assert.h"
-
- #include "IMB_colormanagement.h"
-
- #include "compositor_shader.hh"
-
- namespace blender::compositor {
-
- /* Keep in sync with CompositorData in compositor_lib.glsl. */
- typedef struct CompositorData {
- float luminance_coefficients[3];
- float frame_number;
- } CompositorData;
-
- BLI_STATIC_ASSERT_ALIGN(CompositorData, 16)
-
- static ShaderModule *g_shader_module = nullptr;
-
- class Instance {
- public:
- ShaderModule &shaders;
-
- private:
- /** TODO(fclem) multipass. */
- DRWPass *pass_;
- /** A UBO storing CompositorData. */
- GPUUniformBuf *ubo_;
- GPUMaterial *gpumat_;
- /** Temp buffers to hold intermediate results or the input color. */
- GPUTexture *tmp_buffer_ = nullptr;
- GPUFrameBuffer *tmp_fb_ = nullptr;
-
- bool enabled_;
-
- public:
- Instance(ShaderModule &shader_module) : shaders(shader_module)
- {
- ubo_ = GPU_uniformbuf_create_ex(sizeof(CompositorData), &ubo_, "CompositorData");
- };
-
- ~Instance()
- {
- GPU_uniformbuf_free(ubo_);
- GPU_FRAMEBUFFER_FREE_SAFE(tmp_fb_);
- }
-
- void init()
- {
- const DRWContextState *ctx_state = DRW_context_state_get();
- Scene *scene = ctx_state->scene;
- enabled_ = scene->use_nodes && scene->nodetree;
-
- if (!enabled_) {
- return;
- }
-
- gpumat_ = shaders.material_get(scene);
- enabled_ = GPU_material_status(gpumat_) == GPU_MAT_SUCCESS;
-
- if (!enabled_) {
- return;
- }
-
- /* Create temp double buffer to render to or copy source to. */
- /* TODO(fclem) with multipass compositing we might need more than one temp buffer. */
- DrawEngineType *owner = (DrawEngineType *)g_shader_module;
- eGPUTextureFormat format = GPU_texture_format(DRW_viewport_texture_list_get()->color);
- tmp_buffer_ = DRW_texture_pool_query_fullscreen(format, owner);
-
- GPU_framebuffer_ensure_config(&tmp_fb_,
- {
- GPU_ATTACHMENT_NONE,
- GPU_ATTACHMENT_TEXTURE(tmp_buffer_),
- });
- }
-
- void sync()
- {
- if (!enabled_) {
- return;
- }
-
- pass_ = DRW_pass_create("Compositing", DRW_STATE_WRITE_COLOR);
- DRWShadingGroup *grp = DRW_shgroup_material_create(gpumat_, pass_);
-
- sync_compositor_ubo(grp);
-
- ListBase rpasses = GPU_material_render_passes(gpumat_);
- LISTBASE_FOREACH (GPUMaterialRenderPass *, gpu_rp, &rpasses) {
- DRWRenderPass *drw_rp = DRW_render_pass_find(
- gpu_rp->scene, gpu_rp->viewlayer, gpu_rp->pass_type);
- if (drw_rp) {
- DRW_shgroup_uniform_texture_ex(
- grp, gpu_rp->sampler_name, drw_rp->pass_tx, gpu_rp->sampler_state);
- }
- }
-
- DRW_shgroup_call_procedural_triangles(grp, nullptr, 1);
- }
-
- void draw()
- {
- if (!enabled_) {
- return;
- }
-
- DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
-
- /* Reset default view. */
- DRW_view_set_active(nullptr);
-
- GPU_framebuffer_bind(tmp_fb_);
- DRW_draw_pass(pass_);
-
- /* TODO(fclem) only copy if we need to. Only possible in multipass.
- * This is because dtxl->color can also be an input to the compositor. */
- GPU_texture_copy(dtxl->color, tmp_buffer_);
- }
-
- private:
- void sync_compositor_ubo(DRWShadingGroup *shading_group)
- {
- CompositorData compositor_data;
- IMB_colormanagement_get_luminance_coefficients(compositor_data.luminance_coefficients);
- compositor_data.frame_number = (float)DRW_context_state_get()->scene->r.cfra;
-
- GPU_uniformbuf_update(ubo_, &compositor_data);
- DRW_shgroup_uniform_block(shading_group, "compositor_block", ubo_);
- }
- };
-
- } // namespace blender::compositor
-
- /* -------------------------------------------------------------------- */
- /** \name C interface
- * \{ */
-
- using namespace blender::compositor;
-
- typedef struct COMPOSITOR_Data {
- DrawEngineType *engine_type;
- DRWViewportEmptyList *fbl;
- DRWViewportEmptyList *txl;
- DRWViewportEmptyList *psl;
- DRWViewportEmptyList *stl;
- Instance *instance_data;
- } COMPOSITOR_Data;
-
- static void compositor_engine_init(void *vedata)
- {
- COMPOSITOR_Data *ved = (COMPOSITOR_Data *)vedata;
-
- if (g_shader_module == nullptr) {
- /* TODO(fclem) threadsafety. */
- g_shader_module = new ShaderModule();
- }
-
- if (ved->instance_data == nullptr) {
- ved->instance_data = new Instance(*g_shader_module);
- }
-
- ved->instance_data->init();
- }
-
- static void compositor_engine_free(void)
- {
- delete g_shader_module;
- g_shader_module = nullptr;
- }
-
- static void compositor_instance_free(void *instance_data_)
- {
- Instance *instance_data = reinterpret_cast<Instance *>(instance_data_);
- delete instance_data;
- }
-
- static void compositor_cache_init(void *vedata)
- {
- COMPOSITOR_Data *ved = (COMPOSITOR_Data *)vedata;
- ved->instance_data->sync();
- }
-
- static void compositor_draw(void *vedata)
- {
- COMPOSITOR_Data *ved = (COMPOSITOR_Data *)vedata;
- ved->instance_data->draw();
- }
-
- /** \} */
-
+extern "C" {
+
- static const DrawEngineDataSize compositor_data_size = DRW_VIEWPORT_DATA_SIZE(COMPOSITOR_Data);
++static const DrawEngineDataSize compositor_data_size = {};
+
+DrawEngineType draw_engine_compositor_type = {
+ nullptr,
+ nullptr,
+ N_("Compositor"),
+ &compositor_data_size,
- &compositor_engine_init,
- &compositor_engine_free,
- &compositor_instance_free,
- &compositor_cache_init,
+ nullptr,
+ nullptr,
- &compositor_draw,
++ nullptr,
++ nullptr,
++ nullptr,
++ nullptr,
++ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+};
+}
diff --cc source/blender/draw/intern/draw_view_data.h
index a4cbd3715ec,98ada5a59cb..29bbe409dea
--- a/source/blender/draw/intern/draw_view_data.h
+++ b/source/blender/draw/intern/draw_view_data.h
@@@ -33,10 -33,9 +33,10 @@@ extern "C"
struct DRWRegisteredDrawEngine;
struct DrawEngineType;
+struct DRWRenderScene;
struct GPUViewport;
- /* NOTE these structs are only here for reading the actual lists from the engine.
+ /* NOTE: these structs are only here for reading the actual lists from the engine.
* The actual length of them is stored in a ViewportEngineData_Info.
* The length of 1 is just here to avoid compiler warning. */
typedef struct FramebufferList {
diff --cc source/blender/editors/space_view3d/view3d_navigate_smoothview.c
index 00000000000,aeffb520b0a..a75fc9ed939
mode 000000,100644..100644
--- a/source/blender/editors/space_view3d/view3d_navigate_smoothview.c
+++ b/source/blender/editors/space_view3d/view3d_navigate_smoothview.c
@@@ -1,0 -1,406 +1,410 @@@
+ /*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+ /** \file
+ * \ingroup spview3d
+ */
+
+ #include "DNA_camera_types.h"
+
+ #include "MEM_guardedalloc.h"
+
+ #include "BLI_math.h"
+
+ #include "BKE_context.h"
+
+ #include "DEG_depsgraph_query.h"
+
+ #include "WM_api.h"
+
+ #include "ED_screen.h"
+
++#include "DRW_engine.h"
++
+ #include "view3d_intern.h"
+ #include "view3d_navigate.h" /* own include */
+
+ /* -------------------------------------------------------------------- */
+ /** \name Smooth
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list