Four of the world's richest companies are pouring a collective $5 billion into housing on the West Coast, raising an expectation that companies will serve as part financier, part philanthropist as tech hubs try to add more supply to tight housing markets.

Driving the news: Apple this week pledged $2.5 billion to housing initiatives in Silicon Valley, where even high-paid tech workers — let alone teachers, nurses and police officers — are struggling to find houses they can afford.

The big picture: Other tech companies have announced efforts over the past year to alleviate the housing crisis around their headquarters.

Facebook committed $1 billion to help create mixed-income housing units, housing for homeless and housing for teachers and "essential workers."

committed $1 billion to help create mixed-income housing units, housing for homeless and housing for teachers and "essential workers." Google has also committed $1 billion, including repurposing $750 million of Google-owned land for housing, and a $250 million investment fund to incentivize developers to build at least 5,000 affordable housing units.

has also committed $1 billion, including repurposing $750 million of Google-owned land for housing, and a $250 million investment fund to incentivize developers to build at least 5,000 affordable housing units. Microsoft committed $500 million toward loans and grants to accelerate construction of affordable housing in the Seattle region, as well as grants to address homelessness.

Local leaders praised the investments, and housing experts say corporate investments and philanthropy will play a bigger role in addressing the housing crunch going forward.

Yes, but: Some of the biggest factors driving up housing costs are out of tech companies' control.

In California, single-family zoning and opposition to denser development have been huge drivers of skyrocketing prices. In Apple's hometown of Cupertino, a battle has raged for three years over plans to rezone a defunct mall property for housing.

In the short term, Apple's $1 billion for first-time homebuyers will increase demand but not supply, "probably actively making things worse for people who aren't first-time homebuyers," said Salim Furth, a senior research fellow at the Mercatus Center at George Mason University.

"Tech companies don't zone land or issue building permits," tweeted California state Sen. Scott Wiener, whose district includes San Francisco.

"There’s no question that our local communities need to do more, and particularly the small suburban towns that have been quite welcoming to multibillion-dollar tech campus but are willing to build walls when it comes to more housing development,” said San Jose Mayor Sam Liccardo, noting that Cupertino didn’t add any housing units while Apple’s $3.6 billion headquarters was being built.

The bottom line: "Local communities have to be much more positive about approving housing construction. The biggest problem over the past 30 years as been the shortage of housing, especially rental housing," said Ken Rosen, chairman of the Berkeley Fisher Center for Real Estate and Urban Economics.