1bf215546Sopenharmony_ciHow to add a new post-processing filter
2bf215546Sopenharmony_ci=======================================
3bf215546Sopenharmony_ci
4bf215546Sopenharmony_ciThe Gallium post-processing queue works by passing the current screen to a fragment shader.
5bf215546Sopenharmony_ciThese shaders may be written in any supported language, but are added here in TGSI text
6bf215546Sopenharmony_ciassembly.
7bf215546Sopenharmony_ci
8bf215546Sopenharmony_ciYou can translate GLSL/ARB fairly easily via llvmpipe (LP_DEBUG=tgsi). I don't know the
9bf215546Sopenharmony_cistatus of the D3D gallium frontend, but if/when that works, I'd assume HLSL would be possible
10bf215546Sopenharmony_citoo.
11bf215546Sopenharmony_ci
12bf215546Sopenharmony_ci
13bf215546Sopenharmony_ci
14bf215546Sopenharmony_ciSteps
15bf215546Sopenharmony_ci=====
16bf215546Sopenharmony_ci
17bf215546Sopenharmony_ci1. Add it to PP
18bf215546Sopenharmony_ci2. Make it known to PP
19bf215546Sopenharmony_ci3. Make it known to driconf
20bf215546Sopenharmony_ci4. ????
21bf215546Sopenharmony_ci5. Profit
22bf215546Sopenharmony_ci
23bf215546Sopenharmony_ci
24bf215546Sopenharmony_ci
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_ci1. Add it to PP
27bf215546Sopenharmony_ci---------------
28bf215546Sopenharmony_ci
29bf215546Sopenharmony_ciOnce you have the shader(s) in TGSI asm, put them to static const char arrays in a header
30bf215546Sopenharmony_cifile (see pp_colors.h).
31bf215546Sopenharmony_ci
32bf215546Sopenharmony_ciAdd the filter's prototypes (main and init functions) to postprocess.h. This is mostly a
33bf215546Sopenharmony_cicopy-paste job with only changing the name.
34bf215546Sopenharmony_ci
35bf215546Sopenharmony_ciThen create a file containing empty main and init functions, named as you specified above.
36bf215546Sopenharmony_ciSee pp_colors.c for an example.
37bf215546Sopenharmony_ci
38bf215546Sopenharmony_ci
39bf215546Sopenharmony_ci
40bf215546Sopenharmony_ci2. Make it known to PP
41bf215546Sopenharmony_ci----------------------
42bf215546Sopenharmony_ci
43bf215546Sopenharmony_ciAdd your filter to filters.h, in a correct place. Placement is important, AA should usually
44bf215546Sopenharmony_cibe the last effect in the queue for example.
45bf215546Sopenharmony_ci
46bf215546Sopenharmony_ciName is the config option your filter will be enabled by, both in driconf and as an env var.
47bf215546Sopenharmony_ci
48bf215546Sopenharmony_ciInner temp means an intermediate framebuffer you may use in your filter to store
49bf215546Sopenharmony_ciresults between passes. If you have a single-pass filter, request 0 of those.
50bf215546Sopenharmony_ci
51bf215546Sopenharmony_ciShaders is the number of shaders your filter needs. The minimum is 2.
52bf215546Sopenharmony_ci
53bf215546Sopenharmony_ci
54bf215546Sopenharmony_ciYou could also write the init and main functions now. If your filter is single-pass without
55bf215546Sopenharmony_cia vertex shader and any other input than the main screen, you can use pp_nocolor as your
56bf215546Sopenharmony_cimain function as is.
57bf215546Sopenharmony_ci
58bf215546Sopenharmony_ci
59bf215546Sopenharmony_ci
60bf215546Sopenharmony_ci3. Make it known to driconf
61bf215546Sopenharmony_ci---------------------------
62bf215546Sopenharmony_ci
63bf215546Sopenharmony_ciFirst time outside of auxiliary/postprocess. First, add a suitable description to
64bf215546Sopenharmony_cisrc/util/driconf.h.
65bf215546Sopenharmony_ciUse the name you put into filters.h as the config option name.
66bf215546Sopenharmony_ci
67bf215546Sopenharmony_ciWith driconf aware of the option, make Gallium aware of it too. Add it to
68bf215546Sopenharmony_cifrontends/dri/common/dri_screen.c in a proper section, specifying its default value and
69bf215546Sopenharmony_cithe accepted range (if applicable).
70bf215546Sopenharmony_ci
71bf215546Sopenharmony_ciDo check that __driNConfigOptions is still correct after the addition.
72bf215546Sopenharmony_ci
73bf215546Sopenharmony_ci
74bf215546Sopenharmony_ci
75bf215546Sopenharmony_ci4. ????
76bf215546Sopenharmony_ci-------
77bf215546Sopenharmony_ci
78bf215546Sopenharmony_ciTesting, praying, hookers, blow, sacrificial lambs...
79bf215546Sopenharmony_ci
80bf215546Sopenharmony_ci
81bf215546Sopenharmony_ci
82bf215546Sopenharmony_ci5. Profit
83bf215546Sopenharmony_ci---------
84bf215546Sopenharmony_ci
85bf215546Sopenharmony_ciAssuming you got here, sharing is caring. Send your filter to mesa-dev.
86bf215546Sopenharmony_ci
87bf215546Sopenharmony_ci
88