Recent

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

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 844
Re: Port "voxel" DOS demo to Lazarus
« Reply #15 on: August 11, 2020, 09:18:37 am »
Couldn't implement it via TLazIntfImage, as it says, that it currently doesn't support palettes. I've implemented it via TBGRABitmap. See CODE4. Still 5 times slower than my code. Also I've cleaned up code and made it portable (I guess).
« Last Edit: August 11, 2020, 10:11:26 am 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?

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 844
Re: Port "voxel" DOS demo to Lazarus
« Reply #16 on: August 11, 2020, 10:07:02 am »
I've implemented TLazIntfImage code via ARGB data type the same way, TBGRABitmap code is implemented. Faster, but still 3 times slower, than raw SetDIBitsToDevice.
« Last Edit: August 11, 2020, 10:10:52 am 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?

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: Port "voxel" DOS demo to Lazarus
« Reply #17 on: August 11, 2020, 10:39:04 am »
Oh you're right, I thought that header was created each time.
Conscience is the debugger of the mind

AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
Re: Port "voxel" DOS demo to Lazarus
« Reply #18 on: August 11, 2020, 10:50:00 am »
Good. Posted your version to github!
(for next update, pls format the unit1.pas - indents should be 2 spaces, no tab's)

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: Port "voxel" DOS demo to Lazarus
« Reply #19 on: August 11, 2020, 12:09:58 pm »
I think that using TImage does not give accurate result. Indeed, when doing so, the screen update is postponed to the OnPaint event of TImage, thus not counted in the time.

I replaced Code2 by drawing pixels directly on the Panel.

There was a problem with the line order and byte order of the BGRABitmap (it can change depending on the platform). I've also used precomputed palettes to hopefully optimize.

I don't get any difference between TLazIntfImage and TBGRABitmap, I get 10 ms in both cases. Note that TLazIntfImage could be optimized by using a palette.

MacOS 64bits
---------------
Code1 (bmp pixels): 88ms
Code2 (panel pixels): 77.5ms
Code3 (DIB): N/A
Code4 (BGRA): 10.5ms
Code5 (Intf): 10ms

Can you give me your times with this version?
Conscience is the debugger of the mind

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 844
Re: Port "voxel" DOS demo to Lazarus
« Reply #20 on: August 11, 2020, 12:25:52 pm »
Note that TLazIntfImage could be optimized by using a palette.
How can I do it? TLazIntfImage doesn't provide direct access to palette and direct TRawImage usage doesn't work for me (see CODE6). Once I set RawImageDesc.PaletteColorCount = 256, screen just goes blank.

P.S. CODE5 is a little bit optimized. CODE6 is even faster, than SetDIBitsToDevice.

P.P.S. Ohhhh. And another one. I have Lazarus 1.8.2 and LoadFromRawImage has memory leak for ADataOwner = True, because it calls CreateData in GetRawImagePtr, but doesn't clean this old data up. I've fixed this bug on my local copy of Graphics.pas.
« Last Edit: August 11, 2020, 12:31:00 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 #21 on: August 11, 2020, 12:29:56 pm »
Good, @circular. Updated- https://github.com/Alexey-T/Voxel_demo_Lazarus
Mr.Madguy, I welcome update over github version.

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 844
Re: Port "voxel" DOS demo to Lazarus
« Reply #22 on: August 11, 2020, 12:39:13 pm »
Can you give me your times with this version?
CODE1: 32ms
CODE2: 56ms
CODE3: 0.33ms
CODE4: 0.46ms
CODE5: 0.70ms, but bugged - shows wrong picture and throws exception at termination
« Last Edit: August 11, 2020, 12:57:16 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?

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: Port "voxel" DOS demo to Lazarus
« Reply #23 on: August 11, 2020, 12:40:56 pm »
Mr.Madguy, as I mentioned before, the times you had do not include the actual drawing on the screen, because the TImage will update the screen after the UpdateImage procedure.

Are those new results with my version?
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: Port "voxel" DOS demo to Lazarus
« Reply #24 on: August 11, 2020, 12:48:40 pm »
Does not seem possible to me that BGRA would be so slow. And neither that accessing bitmap pixels would be so fast. For the DIB too, I find the timing very low.
Conscience is the debugger of the mind

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 844
Re: Port "voxel" DOS demo to Lazarus
« Reply #25 on: August 11, 2020, 12:57:40 pm »
Does not seem possible to me that BGRA would be so slow. And neither that accessing bitmap pixels would be so fast. For the DIB too, I find the timing very low.
Oh, of course 0.48ms
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 #26 on: August 11, 2020, 01:02:03 pm »
It makes sense to me that SetDIBitsToDevice would be the fastest on Windows, even though that's not portable.

Ok so BGRA is 42% slower than using DIB with palette. That makes sense, because it contains RGBA information for each pixel, that's 4 times more information to copy.
Conscience is the debugger of the mind

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 844
Re: Port "voxel" DOS demo to Lazarus
« Reply #27 on: August 11, 2020, 01:09:22 pm »
Ok, my final version with precomputed palettes implemented. I know, that TImage code isn't accurate, but I like it more. CODE6 doesn't fully work. I guess, because something about "hardware" palettes isn't fully implemented in FPC.
« Last Edit: August 11, 2020, 01:12:53 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?

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: Port "voxel" DOS demo to Lazarus
« Reply #28 on: August 11, 2020, 01:14:16 pm »
Where is this final version?

By the way, what was the display error with Code5 with my version on your computer? Can you provide a screenshot?

About TImage, that does not provide the actual drawing times, at least on MacOS and Linux.
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: Port "voxel" DOS demo to Lazarus
« Reply #29 on: August 11, 2020, 01:16:49 pm »
Good. Posted your version to github!
(for next update, pls format the unit1.pas - indents should be 2 spaces, no tab's)
Thanks. I will suggest a fork if I can make the TLazIntfImage with palette work.
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018