flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Linux > Fastest and very "assembly" way to draw in Linux.

Author
Thread Post new topic Reply to topic
JohnFound



Joined: 16 Jun 2003
Posts: 3434
Location: Bulgaria
Fastest and very "assembly" way to draw in Linux.
Shame on me, I found this method only recently, but was surprised how fast it is and how comfortable is to use it in Linux.

It is MIT-SHM extension of X server.

The idea is to create XImage with memory shared with the X server. This way, there is no need to transfer all the image data to the server and drawing the images to the screen is very fast.

On my slow netbook the drawing speed raises at least twice to 200fps.

You can read more about this API here:

http://www.x.org/releases/current/doc/xextproto/shm.html

Here is some example code:

http://www.mesa3d.org/brianp/xshm.c

and in Linux simply use: "man xshm" for quick reference.

Anyway, I made some simple example that uses this method in FreshLib test programs (branch FreshLibGUI): /freshlib/test_code0/TestPNG.asm (it is actually test of the PNG library, but I added some animation code in order to test the framerate...)

Anyway, if you don't want to download the source and compile, I will attach the precompiled binary for Linux.

If you have some problems with the program, please report it. Also you can report the frame rate you got on your machine.


Description: MIT-SHM extension test.
Download
Filename: TestPNG.tar.gz
Filesize: 124.75 KB
Downloaded: 68 Time(s)


_________________
Tox ID: A48DEF727DF44C3B5C2E576B65021F1A45D8FA52E2F8E257F1CAE148BBADB162FDF7820BD1F9


Last edited by JohnFound on 08 Feb 2015, 07:57; edited 1 time in total
Post 07 Feb 2015, 20:46
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1173
Location: Unknown
Stupid post removed.


Last edited by HaHaAnonymous on 28 Feb 2015, 17:58; edited 1 time in total
Post 07 Feb 2015, 22:57
View user's profile Send private message Reply with quote
sleepsleep



Joined: 05 Oct 2006
Posts: 6519
Location: ˛                              ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣ Posts: 6699
1300+ FPS, running on CPU0: Intel(R) Core(TM) i5-3337U CPU @ 1.80GHz

and the application exit after a while, is that by designed? or conflict and exit?

i am thinking about writing a program that utilize xserver, perhaps i could borrow and learn from your code, johnfound, thanks!
Post 08 Feb 2015, 05:30
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3434
Location: Bulgaria

sleepsleep wrote:
1300+ FPS, running on CPU0: Intel(R) Core(TM) i5-3337U CPU @ 1.80GHz

and the application exit after a while, is that by designed? or conflict and exit?

i am thinking about writing a program that utilize xserver, perhaps i could borrow and learn from your code, johnfound, thanks!



It is known bug that the test application crashes on the end of the animation, i.e. after 100000 frames. On 1300+ fps, it should happen after 56 seconds or little bit less.

If it happens earlier, it is another unknown bug that need to be researched. Wink

_________________
Tox ID: A48DEF727DF44C3B5C2E576B65021F1A45D8FA52E2F8E257F1CAE148BBADB162FDF7820BD1F9
Post 08 Feb 2015, 07:22
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3434
Location: Bulgaria
BTW, mentioned bug is fixed and I updated the attachment.
Post 08 Feb 2015, 07:58
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1173
Location: Unknown
Stupid post removed.


Last edited by HaHaAnonymous on 28 Feb 2015, 17:57; edited 1 time in total
Post 15 Feb 2015, 01:19
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3434
Location: Bulgaria

HaHaAnonymous wrote:
I got rid of my Intel IGP and I am now getting 900+ FPS.



How slow is my pure little netbook! Crying or Very sad Laughing


HaHaAnonymous wrote:
CPU usage: MAX!
GPU usage: 50-55%



CPU can be 100% loaded only if it has two or less cores - one for the test program and one for the X server.

_________________
Tox ID: A48DEF727DF44C3B5C2E576B65021F1A45D8FA52E2F8E257F1CAE148BBADB162FDF7820BD1F9
Post 15 Feb 2015, 07:26
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1173
Location: Unknown
Stupid post removed.


Last edited by HaHaAnonymous on 28 Feb 2015, 17:56; edited 1 time in total
Post 15 Feb 2015, 12:08
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3434
Location: Bulgaria
I think we are talking about the same. The demo program above has one thread and is intentionally designed to run at maximal possible CPU use in order to test the maximal framerate. (which is 50% on CPU with two cores). But, there is some synchronization code that can lower the main thread CPU utilization.

This is because after drawing the flame and calling XShmImageDraw, the main thread must wait for the X server to complete the drawing process, before drawing the next frame.

On my 2 core AMD CPU, the program itself loads the CPU by 26% (which means that it waits approximately the half of the time) and the X server process loads the CPU by 48%.

And one interesting observation: The Windows version of the same program, when run in WINE has similar flamerate, but loads the CPU differently: The main thread has 50% CPU and the X server only 26..27%;
Post 15 Feb 2015, 13:29
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
gens



Joined: 18 Feb 2013
Posts: 159
under a compositing window manager and plenty of cores, i get

X ~64%
program ~36%
kwin (window manager) ~6%

it says it's over 1100 fps


il try it under a non-compositing wm later

also
cool stuff, thx

here's another low level graphics things i found
http://betteros.org/tut/graphics1.php
Post 15 Feb 2015, 19:15
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3434
Location: Bulgaria
@gens, thanks for the link. It is interesting reading.
Post 16 Feb 2015, 06:24
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
keantoken



Joined: 19 Mar 2008
Posts: 58
I got 850-1100FPS, generally around 1000FPS on an AMD FX8320 (4GHz 8 core). This program apparently tests single-thread performance.

Button 1 only works the first time I start the program. If I press button 1 after button 2 has been running, sections of the animation don't get drawn or are flashing.

Maybe if this method doesn't require esoteric secret knowledge I will be able to use it.
Post 31 Dec 2015, 19:15
View user's profile Send private message Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1171
Location: Overflow
Linux High Performance Framebuffer drawing
Hi John!

This is something similar to the already existing DirectFB and Linux Framebuffer
https://en.wikipedia.org/wiki/DirectFB
https://en.wikipedia.org/wiki/Linux_framebuffer

(I am working on XCB right now. but only because it is more readily available)

btw found a little something for you Smile

framebuffer square test on linux:
http://www.cubieforums.com/index.php?topic=33.0
https://gist.github.com/FredEckert/3425429
Low Level Graphics on Linux
http://betteros.org/tut/graphics1.php

just open a console that has fbdev and magic Wink
Post 28 Jan 2016, 19:33
View user's profile Send private message Visit poster's website Reply with quote
kerr



Joined: 24 Feb 2016
Posts: 118
Oh yeah! Thank you for you methond!
Post 25 Feb 2016, 06:14
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.