Author Topic: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library  (Read 140615 times)

0 Members and 3 Guests are viewing this topic.

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
Re: nSDL (0.1.1 beta)
« Reply #105 on: March 16, 2012, 02:05:12 pm »
Great job! I'll have to learn how to use SDL :)

Offline hoffa

  • Project Author
  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 322
  • Rating: +131/-13
    • View Profile
Re: nSDL (0.1.1 beta)
« Reply #106 on: March 17, 2012, 03:58:28 pm »
I did some benchmarking, and the performance seems rather good.

Blitting 1000 times a 100x100 BMP image takes about 2.6 seconds. See for yourself:

« Last Edit: March 20, 2012, 03:34:54 pm by hoffa »

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: nSDL (0.1.1 beta)
« Reply #107 on: March 17, 2012, 04:06:30 pm »
That's ~400 100x100 BMP images per second.
What are the figures for 32x32 and 16x16 bitmaps (if possible, drawn with various modes: replace, masked, transparent), i.e. game sprites ? :)
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline hoffa

  • Project Author
  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 322
  • Rating: +131/-13
    • View Profile
Re: nSDL (0.1.1 beta)
« Reply #108 on: March 17, 2012, 04:25:01 pm »
Image: (16x16)
1000 blits in 114 ms: 8772 blits/second

Image: (32x32)
1000 blits in 334 ms: 2994 blits/second

EDIT:

Trying out alpha, just posting this here as it gives a nice-looking CRT effect (well, more or less): (don't mind the results, it's on an emulator)

Alpha doesn't work on palettized surfaces though (i.e. Touchpad/Clickpad models), although I could hack it a bit and add support for them.

EDIT2:

Here's the code I used for the benchmark test: http://pastebin.com/vvdpJq57
« Last Edit: March 19, 2012, 03:17:44 pm by hoffa »

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: nSDL (0.1.1 beta)
« Reply #109 on: March 18, 2012, 07:59:00 am »
Thanks :)

So... as there are 20*15 16x16 sprites on the Nspire's 320x240 screen, 8-9K blits per second for 16x16 sprites translates to 26-30 FPS for redrawing the entire screen using only 16x16 clipped sprites. That's better than the performance achievable on TI-68k calcs (shown by e.g. ExtGraph demo12), which is good news, but it's still insufficient for completely getting rid of a tilemap engine for platform games. But unlike what we did on TI-68k calculators (reimplementing tilemap engines), we'll surely be able to take advantage of a number of existing tilemap engine implementations :)
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline hoffa

  • Project Author
  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 322
  • Rating: +131/-13
    • View Profile
Re: nSDL (0.1.1 beta)
« Reply #110 on: March 18, 2012, 09:20:00 am »
Seems pretty good for a start. Performance hasn't really been my main thing yet though, as I have been dealing with more important stuff. In later versions I'll optimize whatever possible to squeeze all the juice out of the TI-Nspire. (memcpy I'm looking at you)

On a side note, I'm working on getting SDL_image to run, i.e. support for a lot of different image formats.
« Last Edit: March 18, 2012, 03:38:10 pm by hoffa »

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: nSDL (0.1.1 beta)
« Reply #111 on: March 18, 2012, 09:32:45 am »
Quote
Seems pretty good for a start. Performance hasn't really been my main thing yet though, as I have been dealing with more important stuff. In later versions I'll optimize whatever possible to squeeze all the juice out of the TI-Nspire.
Sure :)

Quote
On a side note, I'm working on getting SDL_image to run, i.e. support for a lot of different image formats.
Nice :)

Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: nSDL (0.1.1 beta)
« Reply #112 on: March 18, 2012, 02:25:00 pm »
Darn that is awesome, you even got alpha transparency! Great job on this :)

Offline hoffa

  • Project Author
  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 322
  • Rating: +131/-13
    • View Profile
Re: nSDL (0.1.2 beta)
« Reply #113 on: March 20, 2012, 03:20:52 pm »
0.1.2's out, it contains mostly just minor changes. One useful addition though is printf-like formatting for SDL_nDrawString (along with NSP_COL and NSP_ROW to easily align text).
For example, to draw "Hello 0xFFFF, 42, world!" in row 1 (starts from 0) column 5, you could do something like (just replace the values by variables of course, otherwise it's useless):

SDL_nDrawString(screen, font, NSP_COL(5), NSP_ROW(1), "Hello 0x%X, %d, %s!", 65535, 42, "world");

It also supports tabs and newline characters, and text wrapping.

I've looked at the mouse stuff, and I might be able to implement that for the next release. I'll also write a full how-to guide to (I reckon it's not very homely when I just dump the headers and static libs in a zip file) and a few example codes in the thread soon.

EDIT:

Could somebody check how fast sprites are blitted on the CX? Download the zip and copy both TNS files to the Examples folder on your TI-Nspire, then run sdl_test.tns. I'm not sure how well memcpy is optimized, but with some magic it might (it's a vague guess though) be faster on the CX than on the non-CX. Thanks a lot.
« Last Edit: March 20, 2012, 05:34:03 pm by hoffa »

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: nSDL (0.1.2 beta)
« Reply #114 on: March 20, 2012, 04:26:15 pm »
it varies between about 112 and 116 ms per 1000 blits (i tried it about 10 times) with an average of 113.44

edit: it's a CX CAS btw
edit2: changed 100 to 1000 (typo)
« Last Edit: March 20, 2012, 04:33:32 pm by Nick »

Offline hoffa

  • Project Author
  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 322
  • Rating: +131/-13
    • View Profile
Re: nSDL (0.1.2 beta)
« Reply #115 on: March 20, 2012, 04:40:39 pm »
1000 blits in 113 ms means 8850 blits/s for a 32x32 BMP image, while on the non-CX it was 2994 blits/s. If your figures and my calculations are correct, that's nearly three times faster than on the non-CX. Damn. :o

Is that correct or am I just missing something and failing at basic math? (EDIT: indeed I messed up, it was 16x16 not 32x32)

EDIT:

Could you (or anyone else for that matter) replace the image.bmp.tns, by the one attached (it's the 16x16 one)? Thanks a lot, you're doing a great favor.
« Last Edit: March 21, 2012, 02:43:39 am by hoffa »

Offline atiatinini

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 19
  • Rating: +0/-0
    • View Profile
Re: nSDL (0.1.2 beta)
« Reply #116 on: March 20, 2012, 04:54:20 pm »
Both images are exactly the same (16x16).

EDIT: I've tried with another 32x32 image and it says '1000 blits in 282 ms'.
« Last Edit: March 20, 2012, 04:56:06 pm by atiatinini »

Offline hoffa

  • Project Author
  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 322
  • Rating: +131/-13
    • View Profile
Re: nSDL (0.1.2 beta)
« Reply #117 on: March 20, 2012, 05:11:49 pm »
Oh wow what a mistake, so it was the 16x16 after all. No wonder the results seemed too great to be true.

Well seems like there's not much difference with the 16x16 (although maybe 1000 blits is too little), but in a 1000-blit run it seems to be about 50 ms faster on the CX with the 32x32 image. Thanks for the information.

Once I get the more important stuff working (mouse for instance), I'll look into performance.

EDIT:

Good news. I hadn't compiled with any GCC optimization yet and had forgot about it. Now I compiled SDL with -O3 (i.e. highest optimization level), and the size went from 383K to 241K. But most importantly, with the exact same 32x32 image on a 1000-blit run, it took 325 ms without optimization, and 155 ms with optimization. That's over twice as fast. :)


I checked and rechecked, and it is indeed true. I tried with a 10000-blit run this time, one program compiled with no optimization and the other one with O3. Here are the results that fit the previous finding:

(10000-blit run, 32x32 BMP image)
Unoptimized: 3261 ms or 3067 blits/s (+0%)
O3 optimized: 1555 ms or 6431 blits/s (+110%)
« Last Edit: March 20, 2012, 06:53:32 pm by hoffa »

Offline atiatinini

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 19
  • Rating: +0/-0
    • View Profile
Re: nSDL (0.1.2 beta)
« Reply #118 on: March 20, 2012, 07:25:50 pm »
Great news, can't wait for that how-to! :D

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: nSDL (0.1.2 beta)
« Reply #119 on: March 20, 2012, 08:37:54 pm »
Really nice :o
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation