[Scummvm-devel] Bitdepth/pixel format API concerns

Rafał Rzepecki divided.mind at gmail.com
Sat Jun 13 19:44:54 CEST 2009


On Sat, Jun 13, 2009 at 5:33 PM, Johannes Schickel<lordhoto at gmail.com> wrote:
> Eugene Sandulenko wrote:
>> On Sat, 13 Jun 2009 12:15:22 +0000 (GMT)
>> Bertrand Augereau <bertrand_augereau at yahoo.fr> wrote:
>>
>>
>>> Different GPUs have different framebuffers format, and moreover
>>> graphic hardware endianness is not always the CPU endianness (ie
>>> XBox360 vs PS3).
>>>
>> But should engines bother about that?
>>
> I guess only in the case these platforms would have too limited
> performace otherwise. So if the engine is able to convert all data on
> the first load to the native format, it would be better than doing a
> conversion every copyRectToScreen call. Of course if the backend is able
> to do that conversion without any real performance loss it should be by
> the backend.
>
> That's anway why I agree that the backend should take cover of any
> format the engine requests in the first place.
>
> Thus I agree with Max' proposal:
>
> 1) Let the backend worry about conversion.
> 2) If an engine expires too much performance loss on an specific
> backend, try to optimize the engine with format conversion on load if
> possible.

I can't help but feel this whole discussion is an acute case of
premature optimalization. How expensive is colorspace conversion
anyway? My guess is, not very much. Most (all?) backends do full
screen conversions anyway, since the hardware is usually truecolor.
How much more expensive could full screen pixel swizzling be compared
to palette lookup?

My vote is (although I'm not sure if I have any right to vote, so
let's make it "my voice") to KISS it. Let the engine request however
exotic colorspace it wants (as long as it's supported by our
conversion routines, ie. the PixelFormat struct) and let the backend
worry about how to draw it. Unless the engine just wants whatever
high/truecolor mode (as when doing conversion anyway), then let it ask
for any mode and let it find out what mode it was provided.

All this talk is probably more text already than all the code would
have been, while it isn't clear (at least to me) than any such clever
optimizations (at risk of leaking abstraction, no less), which would
certainly need such discussions, are at all neccessary.
-- 
- Rafał Rzepecki




More information about the Scummvm-devel mailing list