On May 25, 2010, at 3:58 AM, Kornel Lesinski wrote:

> On 24 May 2010, at 22:09, David Levin wrote:
> 
>>> that even if it was implemented everywhere, this solution involves readback
>>> from the GPU which, as Chris mentioned, is generally evil and should be
>>> avoided at all costs.
>> 
>> This I'm not qualified to comment on, though.  To the best of my
>> knowledge, GPUs are magical boxes that make things go faster via pixie
>> dust.  ;)
>> 
>> Thanks for your opinion. :)
>> 
>> Chris is qualified so are other people whom I've spoken to who have said the 
>> same thing, so using the gpu is not pixie dust in this particular scenario 
>> even though folks would like to be believe it so.
> 
> I think GPU readback is a red herring. It's an operation that takes 
> milliseconds. It's "slow" for realtime graphics, but it's not something that 
> user is going to notice when uploading images — users are not uploading 
> hundreds of images per second.

It's not a red herring. Readback performance has nothing to do with how fast 
pixels can be read from the GPU. As it turns out reading from a GPU is somewhat 
slower than writing but you're right that it's only a few ms. The problem is 
that GPU's are heavily pipelined. You can add lots of commands to the input 
queue and have them executed much later, without you waiting around. As soon as 
a readback comes in, all those pipelined commands have to executed and during 
this time no other commands can be accepted. All users of the GPU (and there 
are many users other than you) sit and wait, including you. When all the 
commands are flushed, your readback is done, then all those waiting get their 
commands submitted and eventually executed. If you're doing this for several 
images, it's even worse. Your readbacks will get interleaved with all the other 
command submissions, so you'll be stalling the pipe several times (as opposed 
to doing all your readbacks together). The flushes make readback slower than 
just copying the pixels and it makes every operation slower for every GPU user.

There are times when you have no choice but to do readback. But the API should 
be designed so that it can be avoided whenever possible.

It's simply evil :-)

-----
~Chris
[email protected]




Reply via email to