![]() |
Forum Index : Microcontroller and PC projects : Page Copying Speed
Author | Message | ||||
vegipete![]() Guru ![]() Joined: 29/01/2013 Location: CanadaPosts: 1132 |
So how fast are the various commands that alter the entire screen? Well, instead of having it served to me on a platter, I timed it myself: 1000 iterations of each, using MODE 1,8: 1) CLS 545.393 milliseconds 2) CLS RGB(MAGENTA) 550.737 3) PAGE COPY 1,2 7199.96 4) PAGE COPY 1,2,B 16576.317 5) PAGE COPY 1,2,D 12703.316 6) BLIT 0,0,0,0,MM.HRES,MM.VRES,1 7348.923 7) BLIT 0,0,0,0,MM.HRES,MM.VRES,1,4 16173.745 8) PAGE OR_PIXELS 1,2,3 12079.231 9) PAGE OR_PIXELS 1,2,2 11791.483 A) PAGE OR_PIXELS 1,1,1 7220.06 As expected, PAGE AND_PIXELS and PAGE XOR_PIXELS are the same speed as PAGE OR_PIXELS. Number A serves no purpose other than timing. It is curiously fast though. Number 3 is ever so slightly faster than 6 although they do the same thing. Numbers 4 & 5 may be somewhat meaningless because they are timed to the vertical blanking and may be tripping over themselves. Number 7, BLIT with transparency, is the most costly. This makes sense because a comparison is required for each pixel and DMA can't be used. Do we learn anything from this? Ideally, we should build our image on a page other than page 0, then use a vertical blanking based PAGE COPY command to cleanly (ie: without tearing) move the image to page 0 for display. PAGE COPY n,0,D is preferred if and only if our program will not change anything on PAGE n before the copy is finished. Otherwise, PAGE COPY ,0,B will pause our program until the copy is done. I am not aware of a simple means by which a program can determine when PAGE COPY n,0,D is finished. Interrupts associated with the MODE command might help. ========================================== Would the optional WHEN parameter (I, B or D) of the PAGE COPY command be a useful addition to the PAGE OR/AND/XOR_PIXEL commands? t = timer for i = 1 to 1000 cls next i tc = timer - t t = timer for i = 1 to 1000 cls RGB(MAGENTA) next i tm = timer - t cls ? "cls ", tc ? "cls RGB(MAGENTA) ", tm t = timer for i = 1 to 1000 page copy 1,2 next i ? "page copy 1,2 ", timer - t t = timer for i = 1 to 1000 page copy 1,2,B next i ? "page copy 1,2,B ", timer - t t = timer for i = 1 to 1000 page copy 1,2,D next i ? "page copy 1,2,D ", timer - t page write 2 t = timer for i = 1 to 1000 blit 0,0,0,0,MM.HRES,MM.VRES,1 next i page write 0 ? "blit 0,0,0,0,MM.HRES,MM.VRES,1 ", timer - t page write 2 t = timer for i = 1 to 1000 blit 0,0,0,0,MM.HRES,MM.VRES,1,4 next i page write 0 ? "blit 0,0,0,0,MM.HRES,MM.VRES,1,4", timer - t t = timer for i = 1 to 1000 page or_pixels 1,2,3 next i ? "page or_pixels 1,2,3 ", timer - t t = timer for i = 1 to 1000 page or_pixels 1,2,2 next i ? "page or_pixels 1,2,2 ", timer - t t = timer for i = 1 to 1000 page or_pixels 1,1,1 next i ? "page or_pixels 1,1,1 ", timer - t end Visit Vegipete's *Mite Library for cool programs. |
||||
berighteous Senior Member ![]() Joined: 18/07/2020 Location: United StatesPosts: 110 |
neat. how fast is your CMM2? Mine's 400mhz Edited 2020-08-10 09:27 by berighteous |
||||
vegipete![]() Guru ![]() Joined: 29/01/2013 Location: CanadaPosts: 1132 |
It's a 'V' chip which I think is the 480Mhz one. Is it running that fast? Beats me. Visit Vegipete's *Mite Library for cool programs. |
||||
KeepIS![]() Guru ![]() Joined: 13/10/2014 Location: AustraliaPosts: 1882 |
Manual page 46. MM.INFO$(CPUSPEED) Returns the CPU speed as a string. This will be 400000000 for the Y version of the STM32H743II or 480000000 for the V version. NANO Inverter: Full download - Only Hex Ver 8.1Ks |
||||
vegipete![]() Guru ![]() Joined: 29/01/2013 Location: CanadaPosts: 1132 |
My mistake. The times listed above are with my 400MHz Waveshare board (rev Y). My 480MHz Waveshare (rev V) times are slightly different/improved. Here they are combined: 480MHz 400MHz 1) CLS 452.832 545.393 milliseconds 2) CLS RGB(MAGENTA) 457.936 550.737 3) PAGE COPY 1,2 7154.907 7199.96 4) PAGE COPY 1,2,B 16579.436 16576.317 5) PAGE COPY 1,2,D 12558.197 12703.316 6) BLIT 0,0,0,0,MM.HRES,MM.VRES,1 7339.73 7348.923 7) BLIT 0,0,0,0,MM.HRES,MM.VRES,1,4 15291.557 16173.745 8) PAGE OR_PIXELS 1,2,3 12072.615 12079.231 9) PAGE OR_PIXELS 1,2,2 11645.814 11791.483 A) PAGE OR_PIXELS 1,1,1 7215.809 7220.06 Both boards are running firmware version 5.05.05b5 Only CLS and BLIT with transparency benefit from the extra 80MHz. (I don't generally use the rev V board because it would benefit from the oscillator mod.) Thanks KeepIS. There is so much in the manual to learn... It's all too hard. Visit Vegipete's *Mite Library for cool programs. |
||||
KeepIS![]() Guru ![]() Joined: 13/10/2014 Location: AustraliaPosts: 1882 |
BTW you might want to time the difference between CLS and the BOX command. Last time I did a check on that the BOX CMD was around 50% faster at clearing the screen, however that was quite a few builds ago, I haven't installed the latest build yet. NANO Inverter: Full download - Only Hex Ver 8.1Ks |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10310 |
To get maximum performance it is important to understand the architecture. There is 3.5MB of memory allocated to video. The first 512Kb is in the processor and the 3Mb in the SDRAM. The processor memory is much faster than the SDRAM. Mode 1,8 uses all of the 512KB for page 0 (800x600=480,000) so all copies are comparatively slow Mode 2,8 has two pages in the 512KB (640x400=256,000) so copies from page 1 to page 0 and visa versa will be faster than all others. Mode 3,8 has 4 pages in the 512Kb (320x400=128,000 - lines are duplicated) You can play with the tests above to see the impact of different pages with different modes. Of course the tests with B and D are sort of meaningless as the time will be completely dependent on the timing of the start of the test compared to the next frame blanking. For the avoidance of doubt BOX and CLS use the same code You can use MM.INFO(PAGE ADDRESS pageno) to see where any given page resides. SDRAM starts at &HD0000000 Edited 2020-08-10 17:18 by matherp |
||||
MachineEmpath Newbie ![]() Joined: 25/10/2020 Location: United StatesPosts: 12 |
I've been running into page copy timing limits and have been thinking about it a bit. In particular, I'm using mode 9,16 to do some IFS fractal rendering on page 1 and copying the result to page 0, allowing me to animate the fractal smoothly. Unfortunately, the page copy takes more than 50ms, even when the fractal render only takes 15ms using a CSUB. I would LOVE to have a "page read n" command (or equivalent) that would set the page that was scanned out to the VGA connector. Since even page 0 can't fit in the internal SRAM for more 9,16, it seems like changing the scan out address to a different page should be possible. I'm guessing it might be a bit harder when the first page is in internal SRAM and later pages are in the external SDRAM? It would also be great to have an MM.INFO(read page) variable so you could see if the page flip had happened. Anton |
||||
johnd Newbie ![]() Joined: 22/10/2020 Location: United StatesPosts: 30 |
I like the idea of being able to just change the video page pointer instead of having to copy/blit memory to the current video page. If you are trying for 60fps (~16ms per page) and half of that time (~8ms) is for the page copy, that only leave 8ms to draw the page. If you could just switch the video output to the new page, instead of having to copy it, you could skip the page copy and get a full 16ms to draw the page before flipping. But, I don't really know if this is possible under this architecture. Note: are the units in first post microseconds or milliseconds? EDIT: ah, for 1000 iterations. My bad. Edited 2020-10-31 18:25 by johnd |
||||
vegipete![]() Guru ![]() Joined: 29/01/2013 Location: CanadaPosts: 1132 |
True page flipping would be nice, maybe Peter will amaze us yet again. What does work instead is to 'page flip' while drawing. (Except this won't work for mode 9,16 because there are only 2 pages total.) ' Pseudo code for illustration only. There is only one ' draw routine, PAGE WRITE toggles active drawing page. DO draw on page A pause until frame time expired PAGE COPY A, 0, D draw on page B pause until frame time expired PAGE COPY B, 0, D LOOP I used this technique in Rocks in Space to good effect. It removed the page copy time, giving me the full frame rate time to do the drawing. Visit Vegipete's *Mite Library for cool programs. |
||||
johnd Newbie ![]() Joined: 22/10/2020 Location: United StatesPosts: 30 |
@vegipete: excellent trick. thx |
||||
MachineEmpath Newbie ![]() Joined: 25/10/2020 Location: United StatesPosts: 12 |
Vegipete, I like that trick. Unfortunately, even if there was enough RAM allocated to video pages it wouldn't help much in my case because it takes a full 50ms to do a single page copy in more 9,16. Matherp, I'm noticing something else interesting. The mode 9,16 page copy seems to be messing with the USB keyboard handling code. It is very unresponsive, with keys taking a lot of presses to register and then getting stuck down. At first I thought it might have been the fact that I set the repeat delay to 250,25 to make editing easier, but changing that back to the default didn't fix it. Taking the page copy out of the render loop fixes the keyboard responsiveness. I also tried disabling my CSUB (which only runs for a few hundred microseconds at a time) and that didn't have any effect. This is with firmware 5.05.06RC10 on a 400MHz board. Thanks! |
||||
NPHighview![]() Senior Member ![]() Joined: 02/09/2020 Location: United StatesPosts: 203 |
Peter, MachineEmpath - I've noticed the keyboard issue as well. I'm using mode 9 for the Game of Life implementation I'm working on (512x256 cells), and do screen copies after every generation (~14 sxeconds per). The key loss / key repeat is particularly noticable after running simulations for a few hours, then going into the editor to make alterations to the code. The rapid key repeat is particularly problematic when I hit [Esc] to leave markup mode; the [Esc] repeats cause me to lose all my edits. I'm not using CSUBs. I've updated to RC12. My Maximite is running at 480MHz. I'll see if I can come up with a minimal code demonstration; my Game of Life program is far too complex to unequivocally demonstrat the issue. In the interim, I'll try using BLITs to copy the playing field from the update page to the visible page. Wonderful stuff! Thank you. - Steve "NPHighview" Johnson Edited 2020-11-02 14:43 by NPHighview Live in the Future. It's Just Starting Now! |
||||
MachineEmpath Newbie ![]() Joined: 25/10/2020 Location: United StatesPosts: 12 |
Here is a pretty simple test case that exhibits the problems mentioned. cls mode 9,16 page write 1 dim integer i, a = 0 do a = a << 1 for i = 1 to keydown(0) select case keydown(i) case 149 : a = a OR 1 end select next text 0, 0, BIN$(a, 64) page copy 1 to 0 pause 100 loop You should see a string of 64 zero's at the top of the screen and when you hit F5 ones should start shifting left until you release F5. If you change the "pause 100" to "pause 1" it starts to be flaky. And if you remove the pause altogether then I've only been able to break out by hitting the reset button (Ctrl-C doesn't function), and I never see any ones show up. |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10310 |
Thanks for the simple example - found and fixed - will post new version later today |
||||
NPHighview![]() Senior Member ![]() Joined: 02/09/2020 Location: United StatesPosts: 203 |
Hi, Peter - it looks like RC12 is still the most current one at geoffg.net/Downloads/Maximite/CMM2_Beta.zip Did you get around to posting the newer one from yesterday? Thank you! - Steve "NPHighview" Johnson Live in the Future. It's Just Starting Now! |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |