When an academic researcher decides to file for a patent, where does the budget to pay for the patent-related costs typically come from? From the academic researcher's budget? From the University's intellectual property/legal budget? From somewhere else?
In my experience, in the United States, patenting is typically provided as a service by the university, budgeted to its intellectual property office (or equivalent).
Since the university typically owns the rights to all work done by its employees, it is more or less compulsory for them to use its services if they wish to patent. Moreover, many of these organizations will actively solicit interactions with faculty and offer them assistance in patenting as otherwise many faculty will not bother to patent things the university might be interested in licensing.
For most universities, this office is probably able to effectively pay for itself via licensing fees, though there might be any number of complexities in how the actual accounting might be done.
Usually bigger universities with fundamental and applied research departments have distinct funds and departments dealing with patents, IP and advising, coordinating and realizing start-up business ideas and companies. This is more or less necessary, as often you have to hire patent-lawyers to set up the patent in a professional manner. In Germany such departments are even prescribed, to be allowed to submit proposals for distinct bigger funding programs by the local state or industry and private/industry foundations to fund start-up ideas and R&D projects to build prototypes for market entry.
Patent registration and fees for non-national areas like europe or worldwide are also quite expensive. With an academic salary, you would have to be very convinced by the patent/idea to spend the money and invest time to write the patent on your own. Even then, if you do necessary tasks like patent literature research on your own, you need a patent-lawyer advising you. And their services are not cheap at all in general.
There exist also funding options, specially to get money which can only be used for the registration and payment of fees for patents. The incentive for a researcher to register a patent can also be very different from university to university. At my university a researcher registering a patent (property of the university) with the help and money of the university will get 30% of income generated from selling the patent or licensing fees. To my knowledge this number at my university is relatively high, but reasonable, as universities not as rich as ivy league universities or located in start-up-areas like San Fransisco with risk-aware and -willing investors, mostly generate income from selling patents or licensíng fees. With success rates of start-up's below 10%, money for founding a company nearly always has to come from private investors or national funding programs. For public universities this business is to risky.
As the minstries of resarch and economy also have huge funding programs to support development of new technologies in collaborations/consortiums of public research institutes and private companies, especially through funding from the european union for small and medium enterprises (SME's), dealing with IP rights and possible patents and ownership in the consortium often has to be already outlined in funding proposals and contracts are negotiated before the projects starts and money is granted.
I have no clue what the situation is like in very innovative and start-up focused areas like the silicon valley, but the case of Germany will rather be the normal case due to limited budget and financial means most universities face. Though I would be very interested to hear what the situation for researchers at public institutions in the silicon valley is like.