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