3 ms·
> Pixel fill is expensive. And how. People don't realize that even with modern graphics card bandwidths, windows that are a good fraction of a 4K monitor take
by bsder 3y ago
> Pixel fill is expensive.
And how. People don't realize that even with modern graphics card bandwidths, windows that are a good fraction of a 4K monitor take a remarkable amount of bandwidth to clear and fill.
- andrewmcwatters 3y agoThank you! Man, if you could get people who work on UIs to write a shader once in their software career and tell them, hey how do you get a nice Gaussian blur to draw fast on a 4/5/8k monitor, they'll quickly realize you need to do as little drawing as possible.
- rerdavies 3y agoThey'd probably answer: you need to be using 2D FFT convolution. ;-P
- rikroots 3y agoWhen I was searching for a very fast Gaussian blur algorithm to implement into my 2d canvas library, I stumbled across some code[1] which does a magnificent job by using something called an Infinite Impulse Response[2] filter - something that comes from the world of audio, I believe? The best bit from my POV is that the work is all done on the CPU with no need to care about webGL/shaders/etc. [1] - https://github.com/nodeca/glur/blob/master/index.js https://github.com/nodeca/glur/blob/master/index.js [2] - https://en.wikipedia.org/wiki/Infinite_impulse_response https://en.wikipedia.org/wiki/Infinite_impulse_response
- kuschku 3y agoGaussian blur is "easy", you can decompose it into a vertical and horizontal component and parallelize and vectorize most of the task. But that's a special case. If you have to actually fill the buffer the traditional way, it takes an eternity. Which is why I'm so disappointed by Gtk's decision to say "just draw at 6K at 2x if you want 4K at 1.5x, scaling is cheap". Because it's definitely not.
- Blackthorn 3y agoIs there somewhere that has a good guide to understanding why this is the case? I'd love to learn more about it. I imagine there's a lot more to it than a gpu's pixel fill rate, which from the marketing should be sufficient but obviously from this discussion is not.
- andrewmcwatters 3y agoYou really don't feel this unless you do graphics programming and then it hits you like a ton of bricks. If you want a beginner's introduction to pixel fill impact, and say, you're a web developer, try picking up a friendly graphics framework like Phaser, LÖVE, or something comparable and writing a shader that's applied to a fullscreen framebuffer, and measure the frametime that it takes to simply draw that as compared to a texture without a "default" fragment shader.
- Blackthorn 3y agoThat really doesn't explain the why though. Why is pixel fill so slow? You'd expect the opposite given the numbers on graphics cards. What's the disconnect here?
- bsder 3y agoHonestly, it's not "slow", it's just there are a LOT of pixels. Number of pixels goes up roughly as the square of resolution. A 4K monitor is 4x the pixels of a 1080p monitor. 8K is 16x the pixels of a 1080p monitor. My current browser window is probably more pixels than 2 1080p monitors. Doing the math: 1920x1080x2x4bytes(RGBA) = roughly 16 megabytes On a 3070 (a quite solid graphics card) you get roughly 450GB/s of memory bandwidth. That's if everything is up, running, powered, and in order. You wind up with 16MB/450000MB/s = 35uS for a simple window clear. Nothing clever just a pure write clear. That's 3+ orders of magnitude off from CPU operations. If you have to do a blend op, you have 3x--read byte, operate on byte with other data and write back. You've just crossed 100uS for the simplest blend--if you get all the memory interleaved correctly AND nothing has to leave the graphics card (if you have to transfer between the card and CPU you can kiss your time budget goodbye). It's one of the reasons why "compositing" is such a PITA. And, to be honest, I suspect compositing window managers are a dead end. Do we really need animated window opening and closing effects? Do windows really need to be transparent so you can see something behind? Do we really need greyscale, blended drop shadows on the edges? Do we really need to render the contents of the window while resizing it? The mobile space answers "Oh, hell, no." The tiling window manager users also concur. 8K is just going to make this kind of stuff disastrously obvious.