Recent

Author Topic: Port "voxel" DOS demo to Lazarus  (Read 10629 times)

BeanzMaster

  • Sr. Member
  • ****
  • Posts: 268
Re: Port "voxel" DOS demo to Lazarus
« Reply #45 on: August 12, 2020, 01:57:46 pm »
We can 'isolate' the slowdown on some demo? I didn't read code detailed.

I don't think it's seems to be internal to the widget and on how canvas is refreshed. or it's simply specific to windows but i don't think because CODE3 is very fast  %)
The problem seems come from "control.canvas.pixel[x,y]" access,  is not locked like with CODE1 and the bitmap BeginUpdate/EndUpdate.
We can also see the display is not "v"-sync. because we draw directly on the canvas, we don't have a buffer like CODE1
If we compare benchmark CODE1.  Windows is around 4/5x slower than Linux.

I compiled in win32 the result is the same

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 844
Re: Port "voxel" DOS demo to Lazarus
« Reply #46 on: August 12, 2020, 03:27:55 pm »
Looks like there is some difference between calling UpdateImage inside and outside of OnPaint. Outside is 4x slower for me. It can be fixed via adding "and not(defined(CODE2))" to OnTimer event.
Is it healthy for project not to have regular stable releases?
Just for fun: Code::Blocks, GCC 13 and DOS - is it possible?

BeanzMaster

  • Sr. Member
  • ****
  • Posts: 268
Re: Port "voxel" DOS demo to Lazarus
« Reply #47 on: August 12, 2020, 04:19:56 pm »
Looks like there is some difference between calling UpdateImage inside and outside of OnPaint. Outside is 4x slower for me. It can be fixed via adding "and not(defined(CODE2))" to OnTimer event.

Hi, You're right {$IFDEF} can be remove in the onTimer event  :-[

without CODE2 run around 187 ms/frame  :)

BeanzMaster

  • Sr. Member
  • ****
  • Posts: 268
Re: Port "voxel" DOS demo to Lazarus
« Reply #48 on: August 12, 2020, 05:15:44 pm »
Update ready

New benchmark

Now under windows
 - CODE2 is 4x time faster
 - BGRABitmap CODE4 in release mode is under 1 ms

Globally performances are little bit better

Note by lauching application outside IDE, performances are little bit better  :D

Code: Pascal  [Select][+][-]
  1.                            (Run inside IDE)
  2.  ______________________________________________________________________________
  3.  |  CPU     : AMD A10-7870K Radeon R7, 12 Compute Cores 4C+8G                 |
  4.  |  OS      : Windows 10 64bit                                                |
  5.  |  FPC     : 3.2.0                                                           |
  6.  |  LAZARUS : 2.0.10                                                          |
  7.  |____________________________________________________________________________|
  8.  |  METHOD |  CODE 1  |  CODE 2  |  CODE 3  |  CODE 4  |  CODE 5  |  CODE 6   |
  9.  |=========|==========|==========|==========|==========|==========|===========|
  10.  |  Debug  | 32,9288  | 179,0486 |  0,3927  |  1,1459  |  1,6595  |  0,7231   |
  11.  |---------|----------|----------|----------|----------|----------|-----------|
  12.  | Release | 33,7899  | 175,9073 |  0,3314  |  0,9093  |  1,3172  |  0,6364   |
  13.  |----------------------------------------------------------------------------|
  14.  
  15.  ______________________________________________________________________________
  16.  |  CPU     : AMD A10-7870K Radeon R7, 12 Compute Cores 4C+8G                 |
  17.  |  OS      : Linux Manjaro 64bit                                             |
  18.  |  FPC     : 3.2.0                                                           |
  19.  |  LAZARUS : 2.0.10                                                          |
  20.  |____________________________________________________________________________|
  21.  |  METHOD |  CODE 1  |  CODE 2  |  CODE 3  |  CODE 4  |  CODE 5  |  CODE 6   |
  22.  |=========|==========|==========|==========|==========|==========|===========|
  23.  |  Debug  |  9,6536  |  28,8853 |   N/A    |  2,5927  |  3,5188  |  2,2695   |
  24.  |---------|----------|----------|----------|----------|----------|-----------|
  25.  | Release | 10,0101  |  29,9593 |   N/A    |  2,2685  |  3,0899  |  2,0943   |
  26.  |----------------------------------------------------------------------------|
  27.  
 
« Last Edit: August 12, 2020, 05:18:01 pm by BeanzMaster »

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: Port "voxel" DOS demo to Lazarus
« Reply #49 on: August 12, 2020, 07:05:09 pm »
Note that drawing outside of OnPaint event is not possible on MacOS.

EDIT: I tried running BZScene on MacOS but it doesn't compile. The unit BZSystem uses linux and users units but they are not found.
« Last Edit: August 12, 2020, 07:33:52 pm by circular »
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: Port "voxel" DOS demo to Lazarus
« Reply #50 on: August 12, 2020, 08:09:58 pm »
I've added support for Retina display. I have the following times:
Code: [Select]
                                   circular
                               (Run inside IDE)
 ______________________________________________________________________________
 |  CPU     : 3 GHz Intel Core i5 6 cores                                     |
 |  OS      : MacOS Catalina (64bit)                                          |
 |  FPC     : 3.2.0                                                           |
 |  LAZARUS : 2.0.10                                                          |
 |____________________________________________________________________________|
 |  METHOD |  CODE 1  |  CODE 2  |  CODE 3  |  CODE 4  |  CODE 5  |  CODE 6   |
 |=========|==========|==========|==========|==========|==========|===========|
 |  Debug  | 63 - 112 | 140 - 143|   N/A    |  1 - 2   |   2 - 3  |     ?     |
 |---------|----------|----------|----------|----------|----------|-----------|
 | Release | 21 - 75  | 79 - 81  |   N/A    |  1 - 2   |   1 - 2  |     ?     |
 |----------------------------------------------------------------------------|
Conscience is the debugger of the mind

BeanzMaster

  • Sr. Member
  • ****
  • Posts: 268
Re: Port "voxel" DOS demo to Lazarus
« Reply #51 on: August 12, 2020, 09:10:56 pm »
Note that drawing outside of OnPaint event is not possible on MacOS.

EDIT: I tried running BZScene on MacOS but it doesn't compile. The unit BZSystem uses linux and users units but they are not found.

Hi I'll add support for MacOs  when i'll have more time. I'm sure it will be not hard. Surely need to add some $IFDEF

Thanks for report  8)

BeanzMaster

  • Sr. Member
  • ****
  • Posts: 268
Re: Port "voxel" DOS demo to Lazarus
« Reply #52 on: August 13, 2020, 03:52:48 pm »
Hi to all today i've updated my mac and install the latest Lazarus.
I've worked on BZScene to get compatible with MacOS.

This is the benchmark i did on my iMac

 
Code: Pascal  [Select][+][-]
  1. ______________________________________________________________________________
  2.  |  CPU     : Intel(R) Core(TM) i5 CPU 750 2.67Ghz                            |
  3.  |  OS      : iMac - MacOS High Sierra 64 bits - Widget set : COCOA           |
  4.  |  FPC     : 3.2.0                                                           |
  5.  |  LAZARUS : 2.0.10                                                          |
  6.  |____________________________________________________________________________|
  7.  |  METHOD |  CODE 1  |  CODE 2  |  CODE 3  |  CODE 4  |  CODE 5  |  CODE 6   |
  8.  |=========|==========|==========|==========|==========|==========|===========|
  9.  |  Debug  | 139,8880 | 984,8184 |   N/A    | 2,5060   |  3,1831  |  2,7487   |
  10.  |---------|----------|----------|----------|----------|----------|-----------|
  11.  | Release |  84,1881 | 833,1344 |   N/A    | 2.1283   |  2,7723  |  2,5091   |
  12.  |----------------------------------------------------------------------------|


Like we see on my machine BGRABitmap is the best, closely follow by BZScene and by CODE5 in release and debug mode.
Unfortunally on my Mac CODE2 is a very big pit of doom  :o and CODE1 is cleary less performant rather than Windows and Linux
 
I'll update BZScene repo soon as possible

Cheers
« Last Edit: August 13, 2020, 03:57:08 pm by BeanzMaster »

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 844
Re: Port "voxel" DOS demo to Lazarus
« Reply #53 on: August 13, 2020, 06:59:36 pm »
Seems like CODE7 is even faster than CODE3, because it doesn't have any bitmap copy operations at all. But in case of Panel1.Canvas there shoudn't be difference, because it requires one bitmap copy anyway.
« Last Edit: August 13, 2020, 07:22:25 pm by Mr.Madguy »
Is it healthy for project not to have regular stable releases?
Just for fun: Code::Blocks, GCC 13 and DOS - is it possible?

AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
Re: Port "voxel" DOS demo to Lazarus
« Reply #54 on: August 13, 2020, 08:12:46 pm »
Maybe someone will make pull-req for CODE7?

BeanzMaster

  • Sr. Member
  • ****
  • Posts: 268
Re: Port "voxel" DOS demo to Lazarus
« Reply #55 on: August 13, 2020, 08:54:35 pm »
Maybe someone will make pull-req for CODE7?

Hi
I'll can tomorrow  :D

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 844
Re: Port "voxel" DOS demo to Lazarus
« Reply #56 on: August 14, 2020, 10:37:13 am »
I would add initial DOS support to this project including actual ModeX (actually ModeY, as we want 320x200), if somebody would explain, how to compile it on DOS. I tried to do it, installed DOS cross compile package, put got "can't execute ppc8086" error and direct execution of ppcross8086 was giving me "Can't find system unit for your platform" or something like that.
Is it healthy for project not to have regular stable releases?
Just for fun: Code::Blocks, GCC 13 and DOS - is it possible?

BeanzMaster

  • Sr. Member
  • ****
  • Posts: 268
Re: Port "voxel" DOS demo to Lazarus
« Reply #57 on: August 14, 2020, 01:11:13 pm »
Seems like CODE7 is even faster than CODE3, because it doesn't have any bitmap copy operations at all. But in case of Panel1.Canvas there shoudn't be difference, because it requires one bitmap copy anyway.

Hi

I take a look to your code

CODE7 is a little bit less efficient rather than CODE3
In CODE3 the "Bitmap" is direclty displayed on Canvas and is more efficient than CODE7.
In CODE7 you don't see the "copy" because the display is managing internally by the TImage

Your CODE6 is bugged, the landscape is in a red shade

Note in the code from repo we have deleted the TImage Bitmap is directly displayed on Panel.Canvas


Mr.Madguy

  • Hero Member
  • *****
  • Posts: 844
Re: Port "voxel" DOS demo to Lazarus
« Reply #58 on: August 14, 2020, 05:48:37 pm »
Hi

I take a look to your code

CODE7 is a little bit less efficient rather than CODE3
In CODE3 the "Bitmap" is direclty displayed on Canvas and is more efficient than CODE7.
In CODE7 you don't see the "copy" because the display is managing internally by the TImage

Your CODE6 is bugged, the landscape is in a red shade

Note in the code from repo we have deleted the TImage Bitmap is directly displayed on Panel.Canvas
I've said about both cases. Yeah, CODE7 isn't better in case of TPanel, but it is in case of TImage. And CODE6 doesn't work properly, because if I enable palette, screen just goes blank. Palette is disabled and without it red color is used.

About DOS example. I've managed to compile it and implement ModeY (see CODE2). It's true "hardware" implementation - not lazy "software" one. That's why it's so complicated. Not sure, if it's faster or not. Couldn't combine it with first project, because go32v2 cross compiler requires packages to be deleted, but throws internal error anyway. I guess, that's because it requires program to be simple pas file - not project.
Is it healthy for project not to have regular stable releases?
Just for fun: Code::Blocks, GCC 13 and DOS - is it possible?

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: Port "voxel" DOS demo to Lazarus
« Reply #59 on: August 14, 2020, 06:10:38 pm »
Yeah, CODE7 isn't better in case of TPanel, but it is in case of TImage.
I guess you're not getting it. TImage rendering is drawn in another event, so the actual drawing on the screen in not taken into account. Hence you get a lower time, but it does not count everything.
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018