UnderwareDesign
June 28, 2017, 12:18:17 PM *
News: PlayBASIC V1.64P4 (Revision 4) Released  (24th,Mar,2016)
   Home    
Pages: [1]
 
Author Topic: Common Point Rotation / Dot Cube (PB2DLL Example)  (Read 3417 times)
Member
Development Team


WWW
« on: April 11, 2014, 12:08:04 PM »


  Common Point Rotation / Dot Cube (PB2DLL Example)

   This demo shows a cube of uniformly spaced vertex rotating in front  of a viewer.  The demo use common point rotations to trim around 6 mults  from each rotated point.   The demo includes two versions of the rendering function, one which is included in the project as normal and compiled to byte code and the other version has been converted to machine code using PlayBASIC2DLL.

   It's important to understand that the machine code version is 'as is' the code wasn't tweaked to give better performance from the DLL, I say this as you probably could improve performance by writing your own dot function, and getting rid of the array accesses,  but that's another story.

   The goal of this little is to show one possible structure when creating  games & apps with machine code accelerated parts in them.

  
  Note: The demo has no z clipping, so if you move the cube or bump the vertex counts and a point falls on 'zero', it'll crash from a divide by zero.  Tweak the spacing /sections variables accordingly.  


   Attached: Built and Running in PlayBASIC V1.64P (pictured demo running on 2005 vintage Althon FX64 computer)

Dot-Code-Example-2014-04-12.zip (10.23 KB - downloaded 11 times.)

PB2DLL-Common-Point-Rotation-Dot-Cube-Example.png (76.34 KB, 808x634 - viewed 223 times.)
Logged

Member
Development Team


WWW
« Reply #1 on: April 12, 2014, 01:34:14 AM »

 1000000 (Common) Point Rotation / Dot Cube (PB2DLL Example)

    This is tweaked version of the project above, this version includes three versions of the draw cube functions, there's the 'standard' and two optimized for DLL versions.  The demo lets you cycle through all them (SPACE BAR) starting with the slowed DLL version (The as is) through to the two optimized versions.

    To optimizations the routine, I've done three things.  

     1) Replaced array accesses in the inner loops with direct memory access.  
  
     2) Replaced bound clipping with RANGE()  - Eg this  is  Range(A,0,EndValue)  is currently quicker than ,(A>=0  and A<EndValue)  

     3) Replaced the FastDOT pixel drawing calls by manually drawing a dot to the target frame buffer.  

   These three things, bring the most optimized machine code version to somewhere around the 3->4 times faster the 'as is' translation.

    So it's well worth wrapping your heads around!

   Attached: Built and Running in PlayBASIC V1.64P (pictured demo running on 2005 vintage Althon FX64 computer)

1000000-Point-Dot-Code-Example.zip (14.55 KB - downloaded 7 times.)

PB2DLL-100000-Point-Rotation-Dot-Cube-Example2.png (76.44 KB, 808x634 - viewed 213 times.)
Logged

Member

WWW
« Reply #2 on: April 12, 2014, 01:37:00 PM »

Good job!
6 fps in my machine!
Logged
Member
Development Team


WWW
« Reply #3 on: April 13, 2014, 02:55:26 AM »

 what mode is that ?  - Runs in 11 fps in mode #2 here
Logged

Member

WWW
« Reply #4 on: April 14, 2014, 02:54:06 AM »

#1 mode, #2 mode 11 fps.
Logged
Pages: [1]
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2009, Simple Machines LLC | Privacy Policy Valid XHTML 1.0! Valid CSS!