Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / dbDot() dog slow ?

Author
Message
kamelito
19
Years of Service
User Offline
Joined: 25th Dec 2004
Location: France
Posted: 22nd Oct 2005 00:12
Hi, I try to port a raster program from purebasic, and the raster drawing routine using the purebasic command plot is instantaneously done while the same using dbDot() is dog slow (10 to 15s).
Even in release mode and with speed optimization on.

What wrong ? is this function that bad ?
Code below.
/kml

int width = 640, height = 480 , depth = 32; // screen resolution and depth

long couleur[] = {
0x13, 0x30, 0x50, 0x70, 0x8E, 0xAE, 0xCF, 0xEC,
0xFF, 0xEB, 0xCF, 0xAF, 0x8E, 0x71, 0x50, 0x30,
0x0, 0x30914, 0x61632, 0x92454, 0xD3373, 0x104193, 0x144FB5, 0x185CD2,
0x1A65E7, 0x185CD2, 0x144FB4, 0x114193, 0xD3373, 0xA2554, 0x51632, 0x30A15,
0x1D2D, 0x314B, 0x4569, 0x5785, 0x6BA3, 0x7EC1, 0x90DC, 0x9CEE,
0x90DB, 0x7FC2, 0x6BA3, 0x5785, 0x4569, 0x314B, 0x1D2C, 0xD12,
0x62518, 0xB3E27, 0xF5837, 0x136F46, 0x178755, 0x1CA165, 0x1FB673, 0x22C67D,
0x20B773, 0x1CA166, 0x178755, 0x136F46, 0xF5837, 0xB3F28, 0x62518, 0x30F0A,
0x152516, 0x233E25, 0x315735, 0x3F6D43, 0x4D8652, 0x5B9F62, 0x67B56F, 0x70C478,
0x67B56E, 0x5BA062, 0x4D8752, 0x3E6D43, 0x325635, 0x243E26, 0x152417, 0x80F0A,
0x152209, 0x24390F, 0x324F15, 0x3F651A, 0x4E7C20, 0x5C9226, 0x69A62C, 0x72B42F,
0x69A62C, 0x5C9226, 0x4E7C20, 0x40641A, 0x324F15, 0x24390E, 0x152209, 0x90E04,
0x22230B, 0x393A13, 0x50511A, 0x666621, 0x7C7E29, 0x939631, 0xA7AA38, 0xB5B83C,
0xA7AA37, 0x939631, 0x7C7E2A, 0x656621, 0x50521B, 0x393A13, 0x22230B, 0xE0E05,
0x423411, 0x5E4919, 0x785D1F, 0x927226, 0xAD872D, 0xC89C34, 0xDFAE3B, 0xEFBB3F,
0xDEAE3B, 0xC79C34, 0xAD872D, 0x927227, 0x785D1F, 0x5D4A18, 0x423412, 0x271E0A,
0x251A12, 0x3E2C1E, 0x573C2A, 0x6E4D35, 0x875F41, 0xA0704D, 0xB68058, 0xC58A5F,
0xB58057, 0xA0704D, 0x875F41, 0x6E4D35, 0x573D29, 0x3E2B1E, 0x251A12, 0xF0A07,
0x211513, 0x372321, 0x4E302D, 0x633D39, 0x784C46, 0x8F5953, 0xA3665F, 0xB06E66,
0xA3655E, 0x8F5A53, 0x794B46, 0x623D39, 0x4E312D, 0x372220, 0x211514, 0xD0808,
0xC0609, 0x1D0F14, 0x311921, 0x44232F, 0x562C3B, 0x693649, 0x7D4056, 0x8E4961,
0x9A4F6A, 0x8E4962, 0x7D4056, 0x693648, 0x562C3B, 0x44232F, 0x311921, 0x1D0F14,
0x1D101B, 0x311B2D, 0x44263F, 0x573050, 0x6B3B62, 0x7E4673, 0x8F4F83, 0x9B568E,
0x8F5083, 0x7E4673, 0x6A3B61, 0x573050, 0x45263E, 0x301B2D, 0x1D101A, 0xC070B,
0xC0912, 0x1E142C, 0x31214A, 0x452F69, 0x583C84, 0x6D49A3, 0x8157C0, 0x9262DA,
0x9E6BED, 0x9262DB, 0x8157C0, 0x6D4AA2, 0x583C85, 0x462F69, 0x32224B, 0x1E152C,
0x211D42, 0x2E2A5D, 0x3B3676, 0x484190, 0x564EAB, 0x635AC5, 0x6E63DC, 0x766BEC,
0x6E64DC, 0x6259C6, 0x554EAB, 0x48418F, 0x3B3676, 0x2F2A5C, 0x211D41, 0x141227,
0x18003F, 0x220058, 0x2C0070, 0x350089, 0x3F00A3, 0x4900BD, 0x5100D2, 0x5700E1,
0x5100D1, 0x4800BC, 0x3F00A3, 0x350089, 0x2C0070, 0x220059, 0x18003E, 0xE0025,
0x23003E, 0x320059, 0x3F0071, 0x4D008A, 0x5C00A3, 0x6A00BD, 0x7600D3, 0x7F00E2,
0x7700D2, 0x6A00BD, 0x5C00A4, 0x4D0089, 0x400071, 0x320058, 0x23003F, 0x150025,
0x220029, 0x310039, 0x3E0049, 0x4B0059, 0x59006A, 0x66007A, 0x720088, 0x7B0092,
0x730088, 0x67007A, 0x59006A, 0x4A0059, 0x3E0049, 0x300039, 0x220028, 0x140018,
0x22031C, 0x310328, 0x3D0433, 0x4B053E, 0x59064A, 0x670755, 0x73085F, 0x7B0966,
0x73085F, 0x670855, 0x590649, 0x4A053E, 0x3D0433, 0x300428, 0x22021C, 0x140111,
0x220511, 0x300718, 0x3E081E, 0x4A0B25, 0x590D2C, 0x670E33, 0x721038, 0x7B113D,
0x721039, 0x670E33, 0x590C2C, 0x4A0A25, 0x3E091F, 0x300718, 0x220510, 0x14030A,
0x29130E, 0x3A1B13, 0x4B2219, 0x5A291F, 0x6C3125, 0x7C382A, 0x8B3E2F, 0x954332,
0x8B3F2F, 0x7C382A, 0x6C3025, 0x5A291E, 0x4A2219, 0x3B1A14, 0x2A130E, 0x190B08,
0xE0800, 0x221400, 0x382100, 0x4F2F00, 0x643B00, 0x7A4800, 0x915500, 0xA56100,
0xB36900, 0xA56000, 0x925600, 0x7B4800, 0x643B00, 0x4F2F00, 0x382100, 0x221300,
0x120D00, 0x2C2100, 0x4A3800, 0x684E00, 0x836300, 0xA17A00, 0xBF9000, 0xD9A400,
0xEBB200, 0xD9A400, 0xBF9100, 0xA17A00, 0x836400, 0x684E00, 0x4A3900, 0x2C2200,
0xD0D00, 0x1D1F00, 0x323400, 0x464900, 0x595C00, 0x6C7100, 0x808500, 0x929700,
0x9EA400, 0x919700, 0x808600, 0x6C7100, 0x585B00, 0x464800, 0x323300, 0x1E1F00,
0x1B2C00, 0x273E00, 0x314F00, 0x3B6000, 0x477300, 0x528500, 0x5C9400, 0x629F00,
0x5B9400, 0x518500, 0x477300, 0x3C6100, 0x315000, 0x263E00, 0x1B2C00, 0x101A00,
0x50E00, 0xB2100, 0x133700, 0x1A4D00, 0x216200, 0x287800, 0x308F00, 0x36A200,
0x3BB000, 0x37A200, 0x308E00, 0x297900, 0x216200, 0x1A4E00, 0x133800, 0xB2100,
0x93722, 0xD4D31, 0x11633F, 0x15794C, 0x198F5A, 0x1DA669, 0x20B975, 0x22C67D,
0x20B975, 0x1CA568, 0x18905B, 0x15784C, 0x11633E, 0xD4E30, 0x93723, 0x62114,
0x4344, 0x5F62, 0x7A7D, 0x9497, 0xB0B4, 0xCCD0, 0xE3E8, 0xF4F9,
0xE3E8, 0xCCD0, 0xB1B5, 0x9597, 0x7A7D, 0x6062, 0x4344, 0x2829,
0x2B42, 0x3E5E, 0x4E77, 0x5F90, 0x71AC, 0x82C7, 0x91DD, 0x9CEE,
0x92DE, 0x83C7, 0x71AD, 0x5F91, 0x4E77, 0x3D5D, 0x2B41, 0x1A27,
0x20812, 0x4132C, 0x81F48, 0xB2C66, 0xF3881, 0x12469E, 0x1552BC, 0x185DD5,
0x1A65E7, 0x185DD5, 0x1552BB, 0x12459F, 0xF3881, 0xB2D66, 0x82049, 0x5132C,
0x40011, 0x8002A, 0xD0046, 0x120063, 0x17007C, 0x1C0099, 0x2200B5, 0x2600CE,
0x2900DF, 0x2500CE, 0x2100B5, 0x1C0099, 0x17007C, 0x120063, 0xD0046, 0x80029
};

void DarkSDK ( void )
{

dbSyncOn ( );
dbSyncRate (0);

/*
;-------------------------------------------------
; screen inits and prog
;-------------------------------------------------
*/

dbSetDisplayMode ( width, height, depth );
//dbSetWindowOff(); /* set windows fullscreen. */


for (int l = 0; l <= 479; l++) {
for (int i = 0 ; i <= 479; i++) {
int coul = couleur[i];
dbDot(l, i, coul);
}
}


while ( LoopSDK ( ) )
{
if ( dbEscapeKey ( ) )
return;
dbSync ( );
}
}

/kml
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 22nd Oct 2005 00:23
The code is invalid, by the way.

It takes a couple of seconds for everything to be displayed though, but then it does have a lot of work to do. Dot is a trifle slow.

Come to the third DarkBasic Pro Sci Fi Con - Be there and be square
Blog:http://spaces.msn.com/members/BouncyBrick/
Web Site:http://www.nicholaskingsley.co.uk
kamelito
19
Years of Service
User Offline
Joined: 25th Dec 2004
Location: France
Posted: 22nd Oct 2005 00:42
the code is not incorrect execpt the line int coul = couleur[i];
error while copy paste. In fact I just post part of the code where the pb is.
Well its slow in DarkSDK, very fast in purebasic using the same machine. (I only have a 1 ghz Athlon).
Is there's a substitute of dbDot which is faster ? (I tried dbLine() which seems to be a little faster.

Any idea on how to optimize the code?

/kml
kamelito
19
Years of Service
User Offline
Joined: 25th Dec 2004
Location: France
Posted: 22nd Oct 2005 01:02
Maybe I just can poke the rgb value directly into the screen buffer, might be faster...
Any idea as to how get the screen buffer address?

Thanks
/kml

/kml
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 22nd Oct 2005 01:33
Each time you call Dot/Point etc without previously locking the surface, the function will lock/render/ then unlock the surface for you. So you should manually lock the surface before the render loop and unlock it again where the loop is complete.

I don't have the SDK, but those functions are bound to be something like

dbLockbuffer()
dbUnLockbuffer()

But a quicker way, would be to grab the BackBuffer pointer and just write directly to the buffer. But this also means handling the buffer format manually

Kevin Picone
[url]www.underwaredesign.com[/url]
Play Nice!Play Basic (Release V1.088 Out Now)- Play Extreme with Play Basic FX {TBA}
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 22nd Oct 2005 01:54
Quote: "the code is not incorrect execpt the line int coul = couleur;"

Precisely - what is the line supposed to be ?

Come to the third DarkBasic Pro Sci Fi Con - Be there and be square
Blog:http://spaces.msn.com/members/BouncyBrick/
Web Site:http://www.nicholaskingsley.co.uk
kamelito
19
Years of Service
User Offline
Joined: 25th Dec 2004
Location: France
Posted: 22nd Oct 2005 02:02
"int coul = couleur[i];" (it seems that the square brackets are eaten by the forum)

I tried dbLockbuffer/dbUnlockbuffer (even with a B at Buffer) but its I got a warning "undeclared identifier". I can't find those functions in the Dark SDK help file.

/kml
kamelito
19
Years of Service
User Offline
Joined: 25th Dec 2004
Location: France
Posted: 22nd Oct 2005 02:03
tried that way

/kml
kamelito
19
Years of Service
User Offline
Joined: 25th Dec 2004
Location: France
Posted: 22nd Oct 2005 02:05
you should read "int coul = couleur square bracket open value i square bracket closed semi colon, pfew

/kml
kamelito
19
Years of Service
User Offline
Joined: 25th Dec 2004
Location: France
Posted: 22nd Oct 2005 02:24
I put :
dbLocBackkbuffer()
dbUnLockBackbuffer() rem I would have put a B in buffer.

Lock before the loop, unlock after and it crash the application.

/kml
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 22nd Oct 2005 12:04
Yes, thats what happened to me.

Come to the third DarkBasic Pro Sci Fi Con - Be there and be square
Blog:http://spaces.msn.com/members/BouncyBrick/
Web Site:http://www.nicholaskingsley.co.uk
kamelito
19
Years of Service
User Offline
Joined: 25th Dec 2004
Location: France
Posted: 24th Oct 2005 01:20
Hi,

Here's my plot routine which work for the job I've to do.
Its much faster than using dbDot() in my pc.

dbLockPixels();
// get pointers
unsigned long ppp = dbGetPixelsPointer();
unsigned long *pp = (unsigned long *) ppp;
int pitch = dbGetPixelsPitch(); // the pitch is the value you have to add to pp to go to the next line.
int screendepth = dbScreenDepth()/8;
unsigned long *coul = couleur;
for (int l = 0; l <= 479 ; l++) {

for (int i = 0 ; i <= 479; i++) {
*pp++ = *coul;
}
unsigned long *pp = (unsigned long *) ppp + ((pitch - 480) * (l+1));
coul++;
}
dbUnlockPixels();

/kml
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 27th Oct 2005 17:31
Very nice, I was trying to convert that from DBPro, I use it with a DWORD pointer.
Also it could be useful to translate cloggy's .dll with 'dot' and 'dot3d', and test performance (could it be faster?), maybe Sephnroth can help us with that.
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 28th Oct 2005 20:12
This is what I've done so far:



But I only get blank white sprites when I call the function, instead of dots , maybe I don't know very well what I'm doing, uh.

I think it would be very interesting to have Cloggy's dot & dot3d translated into DBSDK, but I don't have any more time right now...
Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 30th Oct 2005 20:06
Hello, point me at the source to the original dll and i will take a peek at it when i have a spare moment

Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 31st Oct 2005 10:51
That would be great, this is the link to the latest source that Cloggy posted:

http://forum.thegamecreators.com/xt/xt_apollo_download.php?i=651984

(From the thread: Forum / Program Announcements / D3DFunc V1.0)
Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 2nd Nov 2005 19:26
whoops, forgot about this! Sorry xD I've glanced at the code and it shouldnt be too much trouble. I will try and port the bits you want as soon as i have a spare moment, i'm laid down with alot of stuff atm so i cant promise anything but hopfully tomorrow or the day after

Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 2nd Nov 2005 19:35
lol , excellent news. Take your time, of course.
I don't know if I can be of any help, but here I am
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 11th Nov 2005 10:46
If you are too busy, maybe you can point me where or what I could be missing, so I can stop wandering when I try to make it work...
Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 11th Nov 2005 22:15
I am so SORRY! I honestly completly forgot :/ Well as my current routine (that vertex shadowing thing) has run into a brick wall until I get some input, i'll take an hour out now to look at the code and try and port it for you.

Sorry for taking so long, i'll go see what I can do.

Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 11th Nov 2005 22:40
okay, well dot was VERY easy to port and took a few minutes.

d3dfunc.cpp:



d3dfunc.h:



simple usage example:



and because I simply couldnt resist, heres a blast from the past if anyone remembers it. BBC micro mag, teach yourself programming, clever and pretty effects. I present the persian program ported to darksdk:



I always loved that one. Sorry I made the reply take longer by taking time to write it, but i couldnt resist xD Very fast too..

Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 12th Nov 2005 13:12
Great contribution Sephnroth!

With that little help, I converted easily, and succesfully :

- d3d_line (it's faster!, try your BBC example below )
- d3d_box
- d3d_boxAlpha
- d3d_line3D

Now, I still need help with:

- d3d_dot3D : it compiles, but I can see nothing when running.
- d3d_text3D : does not compile
- d3d_MakePyramid : does not compile

I think that we should try to convert them, at least dot3d and text3d, and post the whole thing into your "Text extension, Image extension, Primitives Extension" thread.

d3dfunc.cpp:


d3dfunc.h:


simple usage example (your BBC program, delete the remarks to try each function):



Tell me what you think. Thanks for your help!
Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 12th Nov 2005 18:35
good grief, thats some serious speed - nice job

I will take a look at the other functions later today or tomorrow (*beats it into himself* must not forget!) but right this moment im off out to watch a movie - but again good work with porting the other functions

Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 14th Nov 2005 23:11
Just a friendly note to say I havnt had a chance to look at the code yet because i've fallen ill :/ Spending most of my time wrapped up in duvets and in bed feeling sorry for myself, I did sleep from 10am to 7:30pm today too x_X Crazy.

Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 15th Nov 2005 10:27
Don't worry and get healthy.
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 15th Nov 2005 14:04 Edited at: 18th Nov 2005 22:43
Now, I found one problem with d3d_line3d:
Since it uses ambient light to "colour" the 3d lines, it leaves ambient light set to 0. The last function line says:



And that affects other objects in scene

I don't know how to solve it, but in the mean time I'll post it at the DBPro forum, to see if Cloggy is around...

(Sorry if this thread is expanding out of initial subject.)

[Edit]
Also, I cannot get zwrite to work (to get the 3d line ocluded by other objects )

[Edit2]
Developing continues here, dot3d and line3d seem to work:

http://forum.thegamecreators.com/?m=forum_view&t=65202&b=22

Login to post a reply

Server time is: 2024-04-18 05:37:52
Your offset time is: 2024-04-18 05:37:52