Commit: 0305fc30b3ba6a1b24e2c9c182ae2e76d553f341
Author: Dalai Felinto
Date:   Fri Feb 23 13:26:28 2018 -0300
Branches: blender2.8
https://developer.blender.org/rB0305fc30b3ba6a1b24e2c9c182ae2e76d553f341

Fix border rendering for eevee + stop passing render result around

Technically the original issue is that xof/yof in render result is calculated
for drawing border render. So a simpler patch could be:

```
- rr->xof = re->disprect.xmin;
+ rr->xof = re->disprect.xmin + BLI_rcti_cent_x(&re->disprect) - (re->winx / 2);
```

However everywhere in the code we are getting border directly from re->disprect
which we may as well do here too.

Besides I'm taking this as a chance to get rid of RenderResult in the internal
loop of eevee, to help prepare the code to the upcoming rendering pipeline
changes.

===================================================================

M       source/blender/draw/engines/eevee/eevee_engine.c
M       source/blender/draw/engines/eevee/eevee_private.h
M       source/blender/draw/engines/eevee/eevee_render.c
M       source/blender/draw/intern/DRW_render.h
M       source/blender/draw/intern/draw_manager.c

===================================================================

diff --git a/source/blender/draw/engines/eevee/eevee_engine.c 
b/source/blender/draw/engines/eevee/eevee_engine.c
index 4a7258d6525..c1c298417e8 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -377,7 +377,7 @@ static void eevee_id_update(void *vedata, ID *id)
        }
 }
 
-static void eevee_render_to_image(void *vedata, RenderEngine *engine, struct 
RenderResult *render_result, struct RenderLayer *render_layer)
+static void eevee_render_to_image(void *vedata, RenderEngine *engine, struct 
RenderLayer *render_layer, const rcti *rect)
 {
        const DRWContextState *draw_ctx = DRW_context_state_get();
        EEVEE_render_init(vedata, engine, draw_ctx->depsgraph);
@@ -385,7 +385,7 @@ static void eevee_render_to_image(void *vedata, 
RenderEngine *engine, struct Ren
        DRW_render_object_iter(vedata, engine, draw_ctx->depsgraph, 
EEVEE_render_cache);
 
        /* Actually do the rendering. */
-       EEVEE_render_draw(vedata, engine, render_result, render_layer);
+       EEVEE_render_draw(vedata, engine, render_layer, rect);
 }
 
 static void eevee_engine_free(void)
diff --git a/source/blender/draw/engines/eevee/eevee_private.h 
b/source/blender/draw/engines/eevee/eevee_private.h
index 85d6dd8b448..8039fa6e946 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -888,7 +888,7 @@ void EEVEE_effects_free(void);
 /* eevee_render.c */
 void EEVEE_render_init(EEVEE_Data *vedata, struct RenderEngine *engine, struct 
Depsgraph *depsgraph);
 void EEVEE_render_cache(void *vedata, struct Object *ob, struct RenderEngine 
*engine, struct Depsgraph *depsgraph);
-void EEVEE_render_draw(EEVEE_Data *vedata, struct RenderEngine *engine, struct 
RenderResult *render_result, struct RenderLayer *render_layer);
+void EEVEE_render_draw(EEVEE_Data *vedata, struct RenderEngine *engine, struct 
RenderLayer *render_layer, const struct rcti *rect);
 void EEVEE_render_update_passes(struct RenderEngine *engine, struct Scene 
*scene, struct ViewLayer *view_layer);
 
 /* Shadow Matrix */
diff --git a/source/blender/draw/engines/eevee/eevee_render.c 
b/source/blender/draw/engines/eevee/eevee_render.c
index f2db27f812f..e5b32cf2baa 100644
--- a/source/blender/draw/engines/eevee/eevee_render.c
+++ b/source/blender/draw/engines/eevee/eevee_render.c
@@ -33,6 +33,7 @@
 #include "DNA_node_types.h"
 
 #include "BLI_rand.h"
+#include "BLI_rect.h"
 
 #include "DEG_depsgraph_query.h"
 
@@ -152,17 +153,17 @@ void EEVEE_render_cache(
 }
 
 static void eevee_render_result_combined(
-        RenderResult *rr, RenderLayer *rl, const char *viewname,
+        RenderLayer *rl, const char *viewname, const rcti *rect,
         EEVEE_Data *vedata, EEVEE_ViewLayerData *UNUSED(sldata))
 {
        RenderPass *rp = RE_pass_find_by_name(rl, RE_PASSNAME_COMBINED, 
viewname);
 
        DRW_framebuffer_bind(vedata->stl->effects->final_fb);
-       DRW_framebuffer_read_data(rr->xof, rr->yof, rr->rectx, rr->recty, 4, 0, 
rp->rect);
+       DRW_framebuffer_read_data(rect->xmin, rect->ymin, 
BLI_rcti_size_x(rect), BLI_rcti_size_y(rect), 4, 0, rp->rect);
 }
 
 static void eevee_render_result_subsurface(
-        RenderResult *rr, RenderLayer *rl, const char *viewname,
+        RenderLayer *rl, const char *viewname, const rcti *rect,
         EEVEE_Data *vedata, EEVEE_ViewLayerData *UNUSED(sldata))
 {
        const DRWContextState *draw_ctx = DRW_context_state_get();
@@ -180,10 +181,10 @@ static void eevee_render_result_subsurface(
                float render_samples = 
(float)BKE_collection_engine_property_value_get_int(props, 
"taa_render_samples");
 
                DRW_framebuffer_bind(vedata->fbl->sss_accum_fb);
-               DRW_framebuffer_read_data(rr->xof, rr->yof, rr->rectx, 
rr->recty, 3, 1, rp->rect);
+               DRW_framebuffer_read_data(rect->xmin, rect->ymin, 
BLI_rcti_size_x(rect), BLI_rcti_size_y(rect), 3, 1, rp->rect);
 
                /* This is the accumulated color. Divide by the number of 
samples. */
-               for (int i = 0; i < rr->rectx * rr->recty * 3; i++) {
+               for (int i = 0; i < rp->rectx * rp->recty * 3; i++) {
                        rp->rect[i] /= render_samples;
                }
        }
@@ -195,10 +196,10 @@ static void eevee_render_result_subsurface(
                float render_samples = 
(float)BKE_collection_engine_property_value_get_int(props, 
"taa_render_samples");
 
                DRW_framebuffer_bind(vedata->fbl->sss_accum_fb);
-               DRW_framebuffer_read_data(rr->xof, rr->yof, rr->rectx, 
rr->recty, 3, 0, rp->rect);
+               DRW_framebuffer_read_data(rect->xmin, rect->ymin, 
BLI_rcti_size_x(rect), BLI_rcti_size_y(rect), 3, 0, rp->rect);
 
                /* This is the accumulated color. Divide by the number of 
samples. */
-               for (int i = 0; i < rr->rectx * rr->recty * 3; i++) {
+               for (int i = 0; i < rp->rectx * rp->recty * 3; i++) {
                        rp->rect[i] /= render_samples;
                }
        }
@@ -210,7 +211,7 @@ static void eevee_render_result_subsurface(
 }
 
 static void eevee_render_result_normal(
-        RenderResult *rr, RenderLayer *rl, const char *viewname,
+        RenderLayer *rl, const char *viewname, const rcti *rect,
         EEVEE_Data *vedata, EEVEE_ViewLayerData *UNUSED(sldata))
 {
        const DRWContextState *draw_ctx = DRW_context_state_get();
@@ -225,10 +226,10 @@ static void eevee_render_result_normal(
        if ((view_layer->passflag & SCE_PASS_NORMAL) != 0) {
                RenderPass *rp = RE_pass_find_by_name(rl, RE_PASSNAME_NORMAL, 
viewname);
 
-               DRW_framebuffer_read_data(rr->xof, rr->yof, rr->rectx, 
rr->recty, 3, 1, rp->rect);
+               DRW_framebuffer_read_data(rect->xmin, rect->ymin, 
BLI_rcti_size_x(rect), BLI_rcti_size_y(rect), 3, 1, rp->rect);
 
                /* Convert Eevee encoded normals to Blender normals. */
-               for (int i = 0; i < rr->rectx * rr->recty * 3; i += 3) {
+               for (int i = 0; i < rp->rectx * rp->recty * 3; i += 3) {
                        if (rp->rect[i] == 0.0f && rp->rect[i + 1] == 0.0f) {
                                /* If normal is not correct then do not produce 
NANs.  */
                                continue;
@@ -251,7 +252,7 @@ static void eevee_render_result_normal(
 }
 
 static void eevee_render_result_z(
-        RenderResult *rr, RenderLayer *rl, const char *viewname,
+        RenderLayer *rl, const char *viewname, const rcti *rect,
         EEVEE_Data *vedata, EEVEE_ViewLayerData *sldata)
 {
        const DRWContextState *draw_ctx = DRW_context_state_get();
@@ -267,12 +268,12 @@ static void eevee_render_result_z(
        if ((view_layer->passflag & SCE_PASS_Z) != 0) {
                RenderPass *rp = RE_pass_find_by_name(rl, RE_PASSNAME_Z, 
viewname);
 
-               DRW_framebuffer_read_depth(rr->xof, rr->yof, rr->rectx, 
rr->recty, rp->rect);
+               DRW_framebuffer_read_depth(rect->xmin, rect->ymin, 
BLI_rcti_size_x(rect), BLI_rcti_size_y(rect), rp->rect);
 
                bool is_persp = DRW_viewport_is_persp_get();
 
                /* Convert ogl depth [0..1] to view Z [near..far] */
-               for (int i = 0; i < rr->rectx * rr->recty; ++i) {
+               for (int i = 0; i < rp->rectx * rp->recty; ++i) {
                        if (rp->rect[i] == 1.0f ) {
                                rp->rect[i] = 1e10f; /* Background */
                        }
@@ -290,7 +291,7 @@ static void eevee_render_result_z(
 }
 
 static void eevee_render_result_mist(
-        RenderResult *rr, RenderLayer *rl, const char *viewname,
+        RenderLayer *rl, const char *viewname, const rcti *rect,
         EEVEE_Data *vedata, EEVEE_ViewLayerData *UNUSED(sldata))
 {
        const DRWContextState *draw_ctx = DRW_context_state_get();
@@ -303,17 +304,17 @@ static void eevee_render_result_mist(
                float render_samples = 
(float)BKE_collection_engine_property_value_get_int(props, 
"taa_render_samples");
 
                DRW_framebuffer_bind(vedata->fbl->mist_accum_fb);
-               DRW_framebuffer_read_data(rr->xof, rr->yof, rr->rectx, 
rr->recty, 1, 0, rp->rect);
+               DRW_framebuffer_read_data(rect->xmin, rect->ymin, 
BLI_rcti_size_x(rect), BLI_rcti_size_y(rect), 1, 0, rp->rect);
 
                /* This is the accumulated color. Divide by the number of 
samples. */
-               for (int i = 0; i < rr->rectx * rr->recty; i++) {
+               for (int i = 0; i < rp->rectx * rp->recty; i++) {
                        rp->rect[i] /= render_samples;
                }
        }
 }
 
 static void eevee_render_result_occlusion(
-        RenderResult *rr, RenderLayer *rl, const char *viewname,
+        RenderLayer *rl, const char *viewname, const rcti *rect,
         EEVEE_Data *vedata, EEVEE_ViewLayerData *UNUSED(sldata))
 {
        const DRWContextState *draw_ctx = DRW_context_state_get();
@@ -331,10 +332,10 @@ static void eevee_render_result_occlusion(
                float render_samples = 
(float)BKE_collection_engine_property_value_get_int(props, 
"taa_render_samples");
 
                DRW_framebuffer_bind(vedata->fbl->ao_accum_fb);
-               DRW_framebuffer_read_data(rr->xof, rr->yof, rr->rectx, 
rr->recty, 3, 0, rp->rect);
+               DRW_framebuffer_read_data(rect->xmin, rect->ymin, 
BLI_rcti_size_x(rect), BLI_rcti_size_y(rect), 3, 0, rp->rect);
 
                /* This is the accumulated color. Divide by the number of 
samples. */
-               for (int i = 0; i < rr->rectx * rr->recty * 3; i += 3) {
+               for (int i = 0; i < rp->rectx * rp->recty * 3; i += 3) {
                        rp->rect[i] = rp->rect[i + 1] = rp->rect[i+2] = 
min_ff(1.0f, rp->rect[i] / render_samples);
                }
        }
@@ -368,7 +369,7 @@ static void eevee_render_draw_background(EEVEE_Data *vedata)
        DRW_framebuffer_bind(fbl->main);
 }
 
-void EEVEE_render_draw(EEVEE_Data *vedata, RenderEngine *engine, RenderResult 
*rr, RenderLayer *rl)
+void EEVEE_render_draw(EEVEE_Data *vedata, RenderEngine *engine, RenderLayer 
*rl, const rcti *rect)
 {
        const DRWContextState *draw_ctx = DRW_context_state_get();
        ViewLayer *view_layer = draw_ctx->view_layer;
@@ -470,7 +471,7 @@ void EEVEE_render_draw(EEVEE_Data *vedata, RenderEngine 
*engine, RenderResult *r
                /* Occlusion output */
                EEVEE_occlusion_output_accumulate(sldata, vedata);
                /* Result NORMAL */
-               eevee_render_result_normal(rr, rl, viewname, vedata, sldata);
+               eevee_render_result_normal(rl, viewname, rect, vedata, sldata);
                /* Volumetrics Resolve Opaque */
                EEVEE_volumes_resolve(sldata, vedata);
                /* Mist output */
@@ -478,15 +479,15 @@ void EEVEE_render_draw(EEVEE_Data *vedata, RenderEngine 
*engine, RenderResult *r
                /* Transparent */
                DRW_draw_pass(psl->transparent_pass);
                /* Result Z */
-               eevee_render_result_z(rr, rl, viewname, vedata, sldata);
+               eevee_render_result_z(rl, viewname, rect, vedata, sldata);
                /* Post Process */
                EEVEE_draw_effects(sldata, vedata);
        }
 
-       eevee_render_result_combined(rr, rl, viewname, vedata, sldata);
-       eevee_render_result_subsu

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to