1How to add a new post-processing filter
2=======================================
3
4The Gallium post-processing queue works by passing the current screen to a fragment shader.
5These shaders may be written in any supported language, but are added here in TGSI text
6assembly.
7
8You can translate GLSL/ARB fairly easily via llvmpipe (LP_DEBUG=tgsi). I don't know the
9status of the D3D state tracker, but if/when that works, I'd assume HLSL would be possible
10too.
11
12
13
14Steps
15=====
16
171. Add it to PP
182. Make it known to PP
193. Make it known to driconf
204. ????
215. Profit
22
23
24
25
261. Add it to PP
27---------------
28
29Once you have the shader(s) in TGSI asm, put them to static const char arrays in a header
30file (see pp_colors.h).
31
32Add the filter's prototypes (main and init functions) to postprocess.h. This is mostly a
33copy-paste job with only changing the name.
34
35Then create a file containing empty main and init functions, named as you specified above.
36See pp_colors.c for an example.
37
38
39
402. Make it known to PP
41----------------------
42
43Add your filter to filters.h, in a correct place. Placement is important, AA should usually
44be the last effect in the queue for example.
45
46Name is the config option your filter will be enabled by, both in driconf and as an env var.
47
48Inner temp means an intermediate framebuffer you may use in your filter to store
49results between passes. If you have a single-pass filter, request 0 of those.
50
51Shaders is the number of shaders your filter needs. The minimum is 2.
52
53
54You could also write the init and main functions now. If your filter is single-pass without
55a vertex shader and any other input than the main screen, you can use pp_nocolor as your
56main function as is.
57
58
59
603. Make it known to driconf
61---------------------------
62
63First time outside of auxiliary/postprocess. First, add a suitable description to
64drivers/dri/common/xmlpool/t_options.h, and regenerate options.h by running make in that
65directory. Use the name you put into filters.h as the config option name.
66
67With driconf aware of the option, make Gallium aware of it too. Add it to
68state_trackers/dri/common/dri_screen.c in a proper section, specifying its default value and
69the accepted range (if applicable).
70
71Do check that __driNConfigOptions is still correct after the addition.
72
73
74
754. ????
76-------
77
78Testing, praying, hookers, blow, sacrificial lambs...
79
80
81
825. Profit
83---------
84
85Assuming you got here, sharing is caring. Send your filter to mesa-dev.
86
87
88