How much of Unity's UI run on a shader/GPU?

I bumped into a page on using a shader to display a tilemap, and I have already seen examples of “word processors” running in shadertoy.

So it got me thinking how much of the UI could we move onto the GPU as shaders?

Asked the question on the Graphics forum, but got tumbleweeds, so thought I would ask on general to get people’s opinions or see if anyone else has seen examples of UI’s running in shaders or on GPU’s?

You could probably move the whole thing on to a shader but the performance increase would be super negligible. Like… there’d really be no point.

Its already rendered by the GPU isn’t it? Like, it’s just a big opengl/directx window? And all the buttons and stuff are all rendered with shaders, right?

1 Like

It would more than likely be a performance loss. The tilemap on gpu is very limiting, and can’t possibly expand to be part of a comprehensive UI system.

A complex UI running entirely gpu side would require compute shaders or in essence be a kind of skinned mesh. There’s no benefit to custom shader just to render an entire UI. It’s much slower and very limiting.

The word processor shadertoy isn’t the most performant way to render text either.

3 Likes

But should all of it run on the CPU?

Is there a sweet spot where work appropriate for a GPU (lots of small simpler jobs) is moved onto the GPU and the more complex jobs done on the CPU.

If you think about a UI…

  • You have lots of components and characters, which sounds like a good fit for GPU.
  • As well as layout and processing logic, which sounds like a good fit for the CPU.

So could Unity improve the UI by moving some of the work onto the GPU?

The GPU operates by doing the same task millions of times. “Do this to every vertex”, “Do that to every pixel” and so on.

The UI rendering is already handled by the GPU. I’m not sure moving the ton of custom stuff you do to generate the UI to the GPU would help at all. Especially if your game is already GPU bound.

3 Likes

Didn’t OS X and Windows both switch to a compositing back-end that runs on top of the graphics card API’s (DX/GL)? Like, Quartz, and Aero, or whatever, like in Windows Vista or something? So everything graphical is already hardware accelerated?

Yes, and for that matter Linux has it too.

https://en.wikipedia.org/wiki/Compiz

Or the GUI Acceleration applied to Windows 8 → https://blogs.msdn.microsoft.com/b8/2012/07/23/hardware-accelerating-everything-windows-8-graphics/