Toshiba e740 GAPI blit
I'm sure everyone has heard of the performance issues when accessing the display buffer of the Toshiba e740. If anyone has a blit routine specifically optimized for the e740 that they would like to share, then I would certainly appreciate it (as would many other developers I'm sure). The only blit optimized specifically for the e740 that I'm aware of is found in the Pocket DivX sources.
BTW, I'm referring to a straight RGB 565 to RGB 565 blit. Examples using the ATI hardware acceleration (specifically the hardware YUV to RGB conversion) are not required (or preferred).
Finally, I’ve complained about this before, but this is really Toshiba’s problem / fault. It would benefit them greatly to determine the optimum method of blitting and provide that source to developers. They chose the pipeline to the display hardware, so they should have some specific method of accessing it in mind.
Thanks!
Dan East
[ignorance]
Aren't a large part of the PocketDivX speedups caused by the e740's ability to decode MPEG4 if I recall correctly, right on the Imageon?
[/ignorance]
To my knowledge both PocketTV and PocketDivX can allow the ATI hardware to convert pixels from YUV to RGB. It doesn't do anything nearly as drastic as actual decoding via hardware.
Dan East
Odd.. isn't it the Imageon 100? I'm looking at the data sheet for the 100, and it says MPEG4/JPEG decoding on the chip itself. I'm aware of the YUV to RGB conversions, but I've always been under the impression that there was more.
As they've kept the specs and API well hidden from any developers other than those who sign NDAs / pay lots of money, ATI are digging their own hole. Sure, the chip might have a nice specification, but if the coders can't use it or aren't given information, then it's pointless and if support for the chip is crappy, it's their fault.
I wouln't be surprised if the ATI chipset wasn't doing much (or did it poorly). ATI would obviously not want everyone to know about it. They'd rather keep people in the dark, letting them believe that the chipset is giving them something.
Has someone verified if the bus to the display memory is 16 or 32 bits? My guess is that without DMA transfers (or pseudo-DMA like the J720), we will never have good performances on this ATI chipset.
I've heard from several sources (that have spoken with ATI) that the bus is only 16 bit.
Dan East
There's no magic bullet here. The ATI chip in question has a 16 bit path to its on-chip video memory. Using memcpy, it takes ~13ms to perform the full-screen back buffer to front buffer copy on an e740, compared to ~5ms for all of the other SA/XScale devices.
You might investigate a dirty rect blitter that would only need to copy the subrect of the back buffer that changed from the previous frame. That gets tricky to do for 3D apps that typically wipe the back buffer and redraw everything per frame though.
I suppose the question you have to ask yourself is how much extra effort do you want to expend in order to support this one device? Heh, you could be the guy who draws a line in the sand by intentionally not supporting the e740. Perhaps then Toshiba/ATI and hopefully other OEMs would get it through their thick heads that a lot of people would like to use their Pocket PCs for playing games and they should consider this as they design their future devices.
Digby wrote:
You might investigate a dirty rect blitter that would only need to copy the subrect of the back buffer that changed from the previous frame. That gets tricky to do for 3D apps that typically wipe the back buffer and redraw everything per frame though.
That's pretty much out of the question for Varium. Just a simple rotation of the player results in the isocam moving a great deal. Basically the only time I could get by with just blitting dirty rects is when the FPS would matter the least (ie the player is not moving or even rotating).
Digby wrote:
I suppose the question you have to ask yourself is how much extra effort do you want to expend in order to support this one device? Heh, you could be the guy who draws a line in the sand by intentionally not supporting the e740. Perhaps then Toshiba/ATI and hopefully other OEMs would get it through their thick heads that a lot of people would like to use their Pocket PCs for playing games and they should consider this as they design their future devices.
That's an interesting concept. First off, one would have to actually block the exe from running on the e740. Otherwise you'd get people constantly trying / buying and complaining about the poor performance. If the app doesn't run in the first place, and the user is advised of why it does not run, then people might actually place pressure on Toshiba. (IE, provide an explanation and the phone number to Toshiba Support when the app closes down).
The second issue is that Randall's e740 has travelled over 2,000 miles to arrive here at my desk, so I hate to think the voyage was in vain.
I guess my primary concern is that my current blit is at least in the ballpark of what is expected on the e740. I'll have to do some benchmarks and compare my blit time to the memcpy time you reported. I certainly don't want to waste time trying to optimize something that can't be optimized. The Pocket DivX and PocketTV performance muddies the water somewhat, because they seem to perform very well on the device. But, they are probably the only two apps that can actually make any use of the hardware acceleration. So unfortunately they provide defense to Toshiba to some small degree, and can cause uninformed consumers to wonder why the Pocket DivX and PocketTV coders are good while the rest of us suck (no offense guys).
Dan East
Regardless of the outcome, my device wouldn't have travelled coast-to-coast in vain. We needed real answers, and its almost impossible to figure this stuff out without a device (maybe THAT concept can get through the OEMs thick heads too).
I am with Digby, that we may have to drop e740 support altogether. Its a gutsy move, but this is actually hindering our progress. We can't spend weeks debugging this stuff without a glimmer of hope, and so far there is none.
Toshiba/ATI are very little help. Possibly they KNOW they screwed up, so they just keep their mouth shut and just hope it will all go away.
I thought about this a bit and I think if it were me, I'd go ahead and support the e740 even though it will probably have a reduced frame rate compared to other devices. I'd release a demo version of the game so that people who have e740s would know prior to spending their money whether or not the frame rate would be acceptable or not. Heck, some folks might still enjoy my game running at 15 fps instead of 25 fps and I wouldn't want to deny them the opportunity (or me, the additional revenue). For the other e740 owners who are unhappy about the performance, let's all hope their whining is loud enough to be heard by the OEMs. Look at the bright side, at least it's only one device that has this problem.
Regarding the PocketTV guys, I'm pretty sure the ATI chip in the e740 can do MPEG decoding. If that's the case then they would be writing far less data to video memory than a typical game does updating from a 240x320 back buffer each frame. Even if it didn't do this and they decompressed the video to a system memory back buffer, they would only need to update the macro blocks on the screen that changed each frame.
Has anyone tried to use GDI blits with the e740? I guess Dan already did and I am really curious about the performances. If updating the entire screen with a GDI blit is faster then 13 ms, then is means there is some kind of hardware blitting available.
The Jornada 720 has a pseudo-DMA transfer to blit from system to video memory. I wouln't be surprised if such a thing was available on the ATI chipset. Basically, what I call a pseudo-DMA is a small FIFO queue that the host CPU writes to while the video chip reads from the other side. Such transfers are usually faster then directly accessing the video memory. The fact that the chip can convert YUV data to RGB strongly suggest that there is such a FIFO. Whether we can send RGB data to it or not is another thing. Hell, we could even try to send YUV data to the display if that can make your game faster.
I understand that the PPC platform is not aimed at gamers. As such, design decisions are not bad on gaming needs. On the other hand, I can't believe there is no kind of blit acceleration whatsoever going on in the display driver.
It seems the problem here is the lack information, thanks to ATI.
Looking here:
http://www.ati.com/technology/hardware/ ... tures.html
It is obvious we need more infos.
Regarding GDI BitBlt performance on the e740, the only bitmaps accelerated by the ATI W100 (or any other low-power graphics chip) are device-dependent-bitmaps (DDBs). These reside in video memory and are created via CreateCompatibleBitmap. The important thing to note is that there is no way that an application can touch the bits of a DDB once it's been created. This prevents the use of these bitmaps for most games that draw to a back buffer in system memory and then copy the contents to video memory each frame.
I've got benchmarks of the various type of BitBlt/FillRect GDI operations and GAPI memcpy/memsets for a number of devices. I'm currently out of town and don't have access to the results but I can post them next week if anyone is interested.
So you've researched this? What is the difference between PocketQuake's blit routine? Except I don't see why simply blitting the information to the screen is what is massively slowing down Varium. It would have to be something else, wouldn't it? And you've benchmarked PQ and Varium both on the same e740 so it couldn't just be a malfunctioning test device, right?
This certainly is a mystery.
The reason PQ gets a decent FPS in portrait is extremely simple. My GAPI blit routine only has to blit half of the whole display in portrait. The onscreen controls and taskbar are not drawn every frame. You should see a huge disproportionate drop in FPS in full screen mode compared to other Pocket PCs, because the slow display access penalty will be doubled.
I just got 7.8 FPS portrait on Randall's e740 with the ROM upgrade, so I'll benchmark landscape now.
Dan East
Okay, I just did these benchmarks, and used the exact same everything for both (used the same CF card with all data files and exe for both devices).
iPaq 3630:
Portrait: 9.0 FPS
Portrait no GAPI blit: 9.5 FPS
Landscape: 6.8 FPS
Toshiba e740:
Portrait: 7.8 FPS
Portrait no GAPI blit: 9.4 FPS
Landscape: 5.2 FPS
So you can see that with the GAPI blit, the e740 gets almost the exact same performance as an iPaq 3630. Add in the GAPI blit and it takes quite a hit.
Hmm, I just realised something else. My GAPI blit on the iPaq is probably not as fast as it could be. I get the same 9.5 FPS for both portrait and landscape without the GAPI blit. So the only thing making landscape mode slower is blitting the extra pixels to the display hardware. Also, I step through the display buffer in a different direction in landscape compared to portrait, so there may be cache issues as well for the iPaq. So the disparity between landscape and portrait GAPI blit performance for the iPaq is much larger than it should be as well, probably due to cache issues.
On the e740, the time required to load the uncompressed data files from the CF card is at least 3 times longer than on my iPaq. It takes around 3 seconds to load on my iPaq, and over 10 seconds on the e740.
Dan East
Dan East wrote:
Hmm, I just realised something else. My GAPI blit on the iPaq is probably not as fast as it could be. I get the same 9.5 FPS for both portrait and landscape without the GAPI blit. So the only thing making landscape mode slower is blitting the extra pixels to the display hardware. Also, I step through the display buffer in a different direction in landscape compared to portrait, so there may be cache issues as well for the iPaq. So the disparity between landscape and portrait GAPI blit performance for the iPaq is much larger than it should be as well, probably due to cache issues.
Yes, the slowdown will be a caching problem, but on an IPAQ you should be able to do a memcpy from the backbuffer to the screen on an IPAQ which should mean landscape blitting is faster than portrait... In fact it should half the speed to around 4-5ms
Ya, since the screen is natively landscape wouldn't it be faster to blit in landscape mode. I'm not saying that the FPS in LS would be faster than in portrait, since it still is the full screen compared to half, but portrait on an iPaq 36xx would require rotation, landscape would not require that extra operation.
Hello,
Here is some benchmarking code for the e740:
http://mono.eurosoft.od.ua/wince/files/blitmark.zip
It supports both GDI blits & memcpy in GAPI mode.
I attempted to optimize memcpy a bit, based on some assumptions about framebuffer location/alignment on the e740.
These two routines are in src/asm/blit.asm. You'll need ARM assembler from the eVC++ 4.0 in order to compile this code:
I.e. copy armasm.exe into eVT3.0 directoty:
From: "%ProgramFiles%\Microsoft eMbedded C++ 4.0\EVC\WCE400\BIN\armasm.exe"
To: "%ProgramFiles%\Microsoft eMbedded Tools\EVC\WCE300\BIN\armasm.exe"
then just compile as usual in eVT IDE.
(Side note: there is a serious bug in this new assembler, it encodes STRD instr as LDRD).
These two routines (xs_blit_full & xs_blit_full_ldrd) only marginally faster than std. memcpy, i.e. they usually provide some speed-ups within 1 FPS.
Benchmark results in brief: GDI blits on e740 are slow compared to direct vmem access, and accessing vmem is significantly slower than mem.
There are also definitions and run-time linking code for (a portion of) the ATI API. It's in the imageon.c/h.
I haven't figured yet how to use this API (well, apart from calling ProcessAttach/Detach

)
HTH,
SC
Ok, so I figured out enough of the ATI API to implement RGB blits.
I updated blitmark.zip to use ATI routines (see URL in the previous post). Surprisingly, it seems that accessing vmem of the offscreen surface is slightly faster than accessing frontbuffer's memory, so I always get better results when ATI blit is used.
I included two precompiled binaries in the archive:
BlitMark-e740-GAPI.exe (GAPI + memcpy)
BlitMark-e740-ATI.exe (ATI overlay + xs_blit_full_ldrd)
The latter is always slightly faster on my e740.
SC
I don't quite understand, is this useful for real programs and games, or still just video? And what kind of speedup are we seeing here?
This is an attempt to optimize direct RGB blits from in-memory buffer to video mem, i.e. more or less how it's implemented in games. So it's not about video but more about games.
Speed-up is quite small, around 2 FPS for this benchmark, but it's still something IMO.
As for whether ATI API is useful for games/programs in general, than probably yes, but this would require special coding in most cases. Blit implementation could be just used in place of GAPI (i.e. BeginDraw/EndDraw) with little changes in the existing code.
Besides it looks like API supports rotations for blits, so this could be used to speed-up landscape mode on Toshiba.
In general, API consists of more than 80 functions, I only figured a half-dozen for now, we'll see what else is in there
SC
so is the performance difference on the e740 mainly in the blitting stage?
Would that explain why its pocketQuake score is decent (low FPS)? The higher the FPS, the more significant the time wasted in the blitting stage becomes.
Thanks!
More like, the more of the screen that needs to be blitted each frame the slower it is. The e740 is inordinately slower in landscape PocketQuake than other PocketPCs, whereas it's slightly faster (after the ROM update) than other PocketPCs in portrait because only half of the screen is being blitted each frame in portrait.
I remember having this discussion with the Pocket TV guy.
When the e740 came out, PTV performance in landscape was 50% slower than in portrait (if not even worse). I speculated that the extra pixels in landscape could not have caused that much of a slowdown for the following simple reason:
If blitting constitutes 20% of the CPU time, than a 50% increase in pixels would only increase the blitting CPU time to say 30%. But that would only translate to a small decrease (10%) in total performance.
Shortly after a new version of PTV was released WITHOUT any ATI specific API calls in which Landscape performance was 10-20% slower than portrait (as opposed to 50% earlier). From what I remember he mentionned something along the lines of "the e740 video buffer needs to be filled in a certain way to prevent a huge performance drop".
I'm paraphrasing, but I thought I'd throw it out there anyway in case it might help a developper. I think this might also explain why some games seem to run fine on the e740 and some are MUCH slower (depending on how they fill the video buffer).
here is a quote I digged up from Tristan on Brighthand:
The performance issues of graphic-intensive or video applications that use GAPI can only be "fixed" by the developers of those applications.
Getting correct performances on the e740 may require changing the way the application writes video data into the display frame buffer, and this is due to the very particular hardware design of the e740.
Rather cryptic, he had been more specific at some points. This was before the pdivx people had found the correct way to fix landscape performance, so he didn't want to just blurt it out IIRC.
I'll try and find more if the developers in this thread think it's a worthwhile lead.
You mention blitting taking up a percentage of the CPU clock. The Toshiba e740 uses that ATI Imageon to blit, so all blitting is off-processor.
The reason that blitting more pixels at a time is slow is probably a combination of the 16 bit wide bus of the ATI chip and the relatively small frame buffer built into the ATI chip. It's 384K, if I'm not mistaken, and that is not enough memory to backbuffer, so with continual blitting, such as in a full screen action game like Varium the frames end transfering to the screen slower than they need to be blitted because of the bus width. With more frame buffer memory then it would be less of a problem because one could transfer two or even three frames to the frame buffer before they're needed and blit them in time. But because the buffer is small then one cannot perform this back buffering function. Quite the combination of poor quality component did ATI use!
Moose, we're talking about blitting without using the ATI. Just writing the pixels to the video buffer like all GAPI games do (and how PTV did before ATI optimizations). Read my little analysis again if you wish.
Now! I'm getting some more quotes, this time from Marc of PDivx off the projectmayo board to give some more light to some of the devs who might be reading.
...probably related to the poor video display performance on the e740 and the fact that the order of access for the frame buffer changes if you rotate. Most device do not see any performance hit due to this, however it appears yours does.
No that WAS a bug fix this is some very strange behavoir in the display buffer of the e740. The bug is theirs not ours. The problem with releasing this now is that as it stands it adds large penalty for all other devices. I need to figure a way to toggle this in the code appropriately.
Again, not very helpful, but seems to indicate something about accessing/filling the video buffer in a 'special' way for the e740.
The Toshiba e740 uses that ATI Imageon to blit, so all blitting is off-processor.
No, Imageon has no support for mem->vmem transfers so workload is still on the processor.
Imageon can perform vmem->vmem blits and it's very fast at it.
Actually there is enough room for two buffers plus some more.
Writting to offscreen buffer than blitting from there appears to be slightly faster than writting to front-buffer memory (see my posts eralier in the thread).
SC
Moose, we're talking about blitting without using the ATI.
BTW, is there any specific reason to avoid ATI APIs?
It seems pretty straightforward to support it in a program that already supports GAPI.
SC
I would say if you have the time and testing resources to write ATI-specific code in order to support this one device AND you can get the proper SDK and support from ATI to do this, then it might be worth your while.
If ATI or Toshiba doesn't feel it's worthwhile to document and support their GPU, then why should I?
Sergey Chaban wrote:
BTW, is there any specific reason to avoid ATI APIs?
It seems pretty straightforward to support it in a program that already supports GAPI.
We really don't need e740 specific builds now. Combining the builds just results in larger filesize.
I don't hate the e740. I actually have one sitting here on my desk. Except for the slow writes to video memory, it's no worse than any of the other XScale-based devices.
I can't speak for Dan or Randall, but if I were designing a cutting edge game that was going to take all of the CPU horsepower available to get my content on the screen at an acceptable frame rate, I've got the following choices to get that game on an e740:
1) Spend time authoring less detailed content (low poly count models, fewer textures, maybe lower quality audio, etc.) in order to save CPU cycles that could be then used on the slower writes to display memory.
2) Decrease the screen size so that the back buffer to front buffer copy operation is moving fewer pixels each frame.
3) Get some info from either Toshiba or ATI on how best to use their hardware. Maybe there is some trick in accessing the video memory on the ATI chip that might help. Who knows? No offense aimed at other people in this forum, but I'm not going to risk releasing a commercial game based on what someone has managed to figure out of the functions in the ATI Imageon DLL. That is just begging for a support nightmare.
4) The final option is do nothing special for this one device and just let the app run slower on the e740. I'd make a demo available of the game so that people would know what they are getting themselves into before they bought it. Maybe 8 FPS is playable for some people with e740s? Who knows? At least I have the chance at making *some* revenue from e740 owners. I'd probably add some sort of Options dialog that would turn off certain features in order to update the frame rate a bit, but that's it. I'm not going to ask my art staff to re-author dumbed down content.
Anyway, that's my take on it. Like I said, it's not a horrible device on the whole, just the video memory bandwidth is subpar.
One thing people fail to realize is that OEMs like Toshiba use graphics chips like the Imageon not for their performance, but rather for their ability to decrease the number of cycles used by the CPU and thereby reduce power consumption.
No offense aimed at other people in this forum, but I'm not going to risk releasing a commercial game based on what someone has managed to figure out of the functions in the ATI Imageon DLL.
In fact I'm fully agree with you on that. That was just for evaluation to see whether it's possible at all to speed up the thing a bit. It seems that ATI is quite unhelpful, at least in our case. It will take forever to get some info from them.
My original question was more along the lines: IF ATI releases Imageon SDK is there are any reasons to avoid using this API alongside with GAPI.
SC
Let me clarify some points. While it's true that ATI chip supports video acceleration, even video app would suffer from the same issue - access to video memory is very slow. Imageon supports one h/w overlay with different color modes, PocketMVP uses YUV420 color mode, actual yuv data is written into offscreen surface, then BitBlt function performs colorspace conversion. That last conversion stage this is what is accelerated by the chip. While this helps with video decoding a bit, it seems that actual speedup is not that great as it could be - writes to vmem are still slow and you have to get yuv data to vmem somehow.
Exactly the same sequence works for RGB data, only overlay color type will be different. That is, if chip has support for 8-bit paletted RGB data, then speedup would be the same as for YUV420.
In either case - blits are fast while vmem writes are slow, so while speedup from using ATI API exists it's pretty small.
Another way to speedup vmem writes is to use some specific write order, which is faster due to chip specific write-coalescing or caching or whatever it is. Again speedup is small.
Another situation where ATI API may help is non-fullscreen blits, since it's possible to use straight memcpy to the surface rather than copying buffer line-by-line.
The biggest problem is that accessing active screen buffer (as returned by GAPI) is even slower than accessing an off-screen surface. BTW offscreen memory is available thru the GAPI pointer but only for reading (and it's also useless without ATI API).
Well, I think I'm repeating myself, but that's just to summarize so don't flame me for that
For what I'm doing it's relatively painless to add ATI support (it's about 50 LOC anyway), we don't use GAPI directly and we already have support for several h/w interfaces. For others that may be too much of a hassle. BTW, we already contacted ATI in order to obtain official SDK, but I honestly don't understand their reasons to hide the specs/SDK. I think e740 is not going to be the last and only device with ATI chip, so it may be worthwhile to support it. Anyhow, it's of course everyone's own bussiness whether to support something or not.
SC
With all this feedback about e740´s video performance for games I don´t think this video chip is going to do well, at least not for now.. maybe with more info available, but for now, If I was you, I would simply place some degrade-video options for the e740 owners to tweak and get a more acceptable performance.. but all this trouble with SDK´s? I don´t think this device deserves it.
but this is just my opinion, I don´t like issues like this one from e740.. they screwed the video and they keep avoiding to help developers!
Maybe a more calm person can have a sane thought about this and work hard about how to implement a fast blit on this device, i´m not like that.
There are a lot of things in the registry that have to do with the ATI chip. Granted, they might not do anything except make you do a hard reset, but I think there are probably a couple of tricks that can be done there... I should find out.
yeah. try:
[HKEY_LOCAL_MACHINE\HARDWARE\ATI\SECRET_SDK_STUFF]
REMOVE_BOTTLENECK=1
RUN_FULLSPEED=1
oh look! A constructive and encouraging post by randall...
Unforchantly most registry keys that "fix" MS issues etc dont exist to start with, so you a, have to know what the key should be called, b, where it goes, and c, it's value. I'd assume ATI is no diff...
-B
Most settings to do with the ATI chip are in the \Windows\atihwtbl.txt file, not in the registry.
SC
haha, atihwtbl? ATI Hardware Tranform and Busted Lighting?
What about using a pseudo- KTX buffer region to update only sections of the screen that change rapidly. Or add a scanline option. People like scanlines, they think it makes it cool or something.
MooseMaster wrote:
haha, atihwtbl? ATI Hardware Tranform and Busted Lighting?
What about using a pseudo- KTX buffer region to update only sections of the screen that change rapidly. Or add a scanline option. People like scanlines, they think it makes it cool or something.
comedic genius!
randall wrote:
yeah. try:
[HKEY_LOCAL_MACHINE\HARDWARE\ATI\SECRET_SDK_STUFF]
REMOVE_BOTTLENECK=1
RUN_FULLSPEED=1
LOL
Yeah, though. Um. Yeah. Most of the settings that you can probably do anything with from what I've seen so far are for the VGA-output with the e740 expansion pack, which I hope to get soon. When I get around to it.
Isn't the VGA out pack just a small adapter?
Moose: That method would work, until you need to scroll the background. Something about that sounds like it's not going to work.
Yeah, it is, sponge. It also has a USB-host adapter on it. But what good is changing the VGA-out settings if I don't even have the adapter?