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
|
How to add a new post-processing filter
=======================================
The Gallium post-processing queue works by passing the current screen to a fragment shader.
These shaders may be written in any supported language, but are added here in TGSI text
assembly.
You can translate GLSL/ARB fairly easily via llvmpipe (LP_DEBUG=tgsi). I don't know the
status of the D3D gallium frontend, but if/when that works, I'd assume HLSL would be possible
too.
Steps
=====
1. Add it to PP
2. Make it known to PP
3. Make it known to driconf
4. ????
5. Profit
1. Add it to PP
---------------
Once you have the shader(s) in TGSI asm, put them to static const char arrays in a header
file (see pp_colors.h).
Add the filter's prototypes (main and init functions) to postprocess.h. This is mostly a
copy-paste job with only changing the name.
Then create a file containing empty main and init functions, named as you specified above.
See pp_colors.c for an example.
2. Make it known to PP
----------------------
Add your filter to filters.h, in a correct place. Placement is important, AA should usually
be the last effect in the queue for example.
Name is the config option your filter will be enabled by, both in driconf and as an env var.
Inner temp means an intermediate framebuffer you may use in your filter to store
results between passes. If you have a single-pass filter, request 0 of those.
Shaders is the number of shaders your filter needs. The minimum is 2.
You could also write the init and main functions now. If your filter is single-pass without
a vertex shader and any other input than the main screen, you can use pp_nocolor as your
main function as is.
3. Make it known to driconf
---------------------------
First time outside of auxiliary/postprocess. First, add a suitable description to
src/util/driconf.h.
Use the name you put into filters.h as the config option name.
With driconf aware of the option, make Gallium aware of it too. Add it to
frontends/dri/common/dri_screen.c in a proper section, specifying its default value and
the accepted range (if applicable).
Do check that __driNConfigOptions is still correct after the addition.
4. ????
-------
Testing, praying, hookers, blow, sacrificial lambs...
5. Profit
---------
Assuming you got here, sharing is caring. Send your filter to mesa-dev.
|