1/**************************************************************************
2 *
3 * Copyright 2011 Lauri Kasanen
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28#ifndef POSTPROCESS_H
29#define POSTPROCESS_H
30
31#include "postprocess/pp_program.h"
32
33#define PP_FILTERS 6            /* Increment this if you add filters */
34#define PP_MAX_PASSES 6
35
36struct pp_queue_t;              /* Forward definition */
37
38/* Less typing later on */
39typedef void (*pp_func) (struct pp_queue_t *, struct pipe_resource *,
40                         struct pipe_resource *, unsigned int);
41/**
42*	The main post-processing queue.
43*/
44struct pp_queue_t
45{
46   pp_func *pp_queue;           /* An array of pp_funcs */
47   unsigned int n_filters;      /* Number of enabled filters */
48
49   struct pipe_resource *tmp[2];        /* Two temp FBOs for the queue */
50   struct pipe_resource *inner_tmp[3];  /* Three for filter use */
51
52   unsigned int n_tmp, n_inner_tmp;
53
54   struct pipe_resource *depth; /* depth of original input */
55   struct pipe_resource *stencil;       /* stencil shared by inner_tmps */
56
57   struct pipe_surface *tmps[2], *inner_tmps[3], *stencils;
58
59   void ***shaders;             /* Shaders in TGSI form */
60   unsigned int *verts;
61   struct program *p;
62
63   bool fbos_init;
64};
65
66/* Main functions */
67
68struct pp_queue_t *pp_init(struct pipe_screen *, const unsigned int *);
69void pp_run(struct pp_queue_t *, struct pipe_resource *,
70            struct pipe_resource *, struct pipe_resource *);
71void pp_free(struct pp_queue_t *);
72void pp_free_fbos(struct pp_queue_t *);
73void pp_debug(const char *, ...);
74struct program *pp_init_prog(struct pp_queue_t *, struct pipe_screen *);
75void pp_init_fbos(struct pp_queue_t *, unsigned int, unsigned int);
76
77/* The filters */
78
79void pp_nocolor(struct pp_queue_t *, struct pipe_resource *,
80                struct pipe_resource *, unsigned int);
81
82void pp_jimenezmlaa(struct pp_queue_t *, struct pipe_resource *,
83                    struct pipe_resource *, unsigned int);
84void pp_jimenezmlaa_color(struct pp_queue_t *, struct pipe_resource *,
85                          struct pipe_resource *, unsigned int);
86
87/* The filter init functions */
88
89void pp_celshade_init(struct pp_queue_t *, unsigned int, unsigned int);
90
91void pp_nored_init(struct pp_queue_t *, unsigned int, unsigned int);
92void pp_nogreen_init(struct pp_queue_t *, unsigned int, unsigned int);
93void pp_noblue_init(struct pp_queue_t *, unsigned int, unsigned int);
94
95void pp_jimenezmlaa_init(struct pp_queue_t *, unsigned int, unsigned int);
96void pp_jimenezmlaa_init_color(struct pp_queue_t *, unsigned int,
97                               unsigned int);
98
99#endif
100