Welcome to mirror list, hosted at ThFree Co, Russian Federation.

workbench_effect_aa.c « workbench « engines « draw « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 482cb81917f118e2983cf97c9d69af73345ba488 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
 * 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 2016, Blender Foundation.
 */

/** \file
 * \ingroup draw_engine
 */

#include "ED_screen.h"

#include "draw_color_management.h"

#include "workbench_private.h"

void workbench_aa_create_pass(WORKBENCH_Data *vedata, GPUTexture **tx)
{
  WORKBENCH_StorageList *stl = vedata->stl;
  WORKBENCH_PrivateData *wpd = stl->g_data;
  WORKBENCH_PassList *psl = vedata->psl;
  WORKBENCH_EffectInfo *effect_info = stl->effects;

  if (workbench_is_taa_enabled(wpd)) {
    psl->effect_aa_pass = workbench_taa_create_pass(vedata, tx);
  }
  else if (workbench_is_fxaa_enabled(wpd)) {
    psl->effect_aa_pass = workbench_fxaa_create_pass(tx);
    effect_info->jitter_index = 0;
  }
  else {
    psl->effect_aa_pass = NULL;
    effect_info->jitter_index = 0;
  }
}

static void workspace_aa_draw_transform(GPUTexture *tx, WORKBENCH_PrivateData *UNUSED(wpd))
{
  DRW_transform_none(tx);
}

void workbench_aa_draw_pass(WORKBENCH_Data *vedata, GPUTexture *tx)
{
  WORKBENCH_StorageList *stl = vedata->stl;
  WORKBENCH_PrivateData *wpd = stl->g_data;
  WORKBENCH_FramebufferList *fbl = vedata->fbl;
  WORKBENCH_PassList *psl = vedata->psl;
  WORKBENCH_EffectInfo *effect_info = stl->effects;

  DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
  if (workbench_is_fxaa_enabled(wpd)) {
    GPU_framebuffer_bind(fbl->effect_fb);
    workspace_aa_draw_transform(tx, wpd);
    GPU_framebuffer_bind(dfbl->color_only_fb);
    DRW_draw_pass(psl->effect_aa_pass);
  }
  else if (workbench_is_taa_enabled(wpd)) {
    /*
     * when drawing the first TAA frame, we transform directly to the
     * color_only_fb as the TAA shader is just performing a direct copy.
     * the workbench_taa_draw_screen_end will fill the history buffer
     * for the other iterations.
     */
    if (effect_info->jitter_index == 1) {
      GPU_framebuffer_bind(dfbl->color_only_fb);
      workspace_aa_draw_transform(tx, wpd);
    }
    else {
      GPU_framebuffer_bind(fbl->effect_fb);
      workspace_aa_draw_transform(tx, wpd);
      GPU_framebuffer_bind(dfbl->color_only_fb);
      DRW_draw_pass(psl->effect_aa_pass);
    }
    workbench_taa_draw_scene_end(vedata);
  }
  else {
    GPU_framebuffer_bind(dfbl->color_only_fb);
    workspace_aa_draw_transform(tx, wpd);
  }
}