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