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