Common Point Rotation / Dot Cube (PB2DLL Example)

Started by kevin, April 11, 2014, 12:08:04 PM

Previous topic - Next topic

kevin

  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)

kevin

#1
 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)

ATLUS


kevin

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

ATLUS


stevmjon

i ran the tweaked version in PB1.64P4, and i see a cube in test#1, but the other tests (pressing spacebar) only show part of a cube, and runs slower...

do i need PB1.64P to PB1.64P3 only in order to run this correctly?
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

kevin


  all binaries are version specific, as the exported DLL contains hooks back into PB.     It's the same as trying to use say PB1.20 compiler say with the PB1.64 runtimes.. 
 
  PlayBASIC to DLL BLOG