Welcome, Guest. Please login or register.

Author Topic: newb questions, hit the hardware or not?  (Read 33060 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline SamuraiCrow

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2280
  • Country: us
  • Gender: Male
    • Show only replies by SamuraiCrow
Re: newb questions, hit the hardware or not?
« Reply #14 on: July 14, 2014, 05:55:52 PM »
@Thomas Richter

I've researched the OS functions extensively in the interest of encapsulating the most efficient special effects of the Amiga chipsets in shared libraries.  This is not only to make things easier for newbies on the Amiga but also to be able to reroute some of them to emulations on graphics cards for better compatibility.

BltBitMap only works on the Blitter.  What about MrgCop, the rather incomplete interface to the Copper?  CINIT, CBUMP, CWAIT, and CMOVE are hardly enough macros to suffice!  The Copper is able to implement display-list like properties to queue the Blitter much more efficiently than QBlit can do using the CPU and an interrupt.  Also, I'd like to be able to merge partial Copper lists based on different starting raster positions so that multiple effects can be combined.  (Both usages need not be concurrent since waiting for the Blitter and raster positions in the same CWAIT tend to result in race conditions.)  Neither the CNEXTBUFFER macro nor its underlying subroutine to skip to another buffer of Copper instructions was ever implemented even though certain infrastructure was added to graphics/copper.h indicating its existence.
 

Offline Thorham

  • Hero Member
  • *****
  • Join Date: Oct 2009
  • Posts: 1149
    • Show only replies by Thorham
Re: newb questions, hit the hardware or not?
« Reply #15 on: July 14, 2014, 06:48:48 PM »
Quote from: Thomas Richter;768938
The core function (BltBitmap()) is pretty much low-level and bare to the metal. I wonder whether you can do any better yourself.
If this call uses the blitter, then you can do much better with a 25 mhz 68020/30, depending on what you want to do.

An example is a Fire Emblem/Advance Wars style game, where you have several layers of tiles (all of which can be animated) and sprites (all animated) that are aligned to 16 pixels on the x-axis. With the CPU you can do nice pipelined 32 bit blits that do two tile positions at the same time by reading data for both, and doing a single transpose on that data. Much faster than what the blitter can do.

Quote from: Thomas Richter;768938
The amount of additional checks needed for non-native hardware are a single pointer (in the bitmap). How much performance does that cost?
Nothing, because you simply do that once when the software starts. Not a problem.

Quote from: Thomas Richter;768938
Sorry, but that's a typical argument of the "cycle counter party": Just hack the hardware because we don't know any better and argue "it's for speed".
In the case of the blitter it's already known that it's slower than a 25 mhz 68020/30 with fastmem, especially for the simple blits I described above.

Quote from: Thomas Richter;768938
Rule number one for performance optimizations: Measure first. Then optimize.
Obviously :)
 

guest11527

  • Guest
Re: newb questions, hit the hardware or not?
« Reply #16 on: July 14, 2014, 10:03:32 PM »
Quote from: Thorham;768944
If this call uses the blitter, then you can do much better with a 25 mhz 68020/30, depending on what you want to do.
Whether it does or does not use the blitter is the matter of circumstances. But that's exactly the reason for *using* this function. If you hack the hardware yourself, you cannot take advantage of improvements or configurations which would otherwise help you to keep your program operating (say on the graphics card) or working fast (by taking advance of a replacement implementation).
 

Offline Thorham

  • Hero Member
  • *****
  • Join Date: Oct 2009
  • Posts: 1149
    • Show only replies by Thorham
Re: newb questions, hit the hardware or not?
« Reply #17 on: July 14, 2014, 10:36:34 PM »
Quote from: Thomas Richter;768958
Whether it does or does not use the blitter is the matter of circumstances. But that's exactly the reason for *using* this function. If you hack the hardware yourself, you cannot take advantage of improvements or configurations which would otherwise help you to keep your program operating (say on the graphics card) or working fast (by taking advance of a replacement implementation).
Took a look at BltBitmap() in the autodocs, and it looks like a generic blit routine. Definitely not going to be faster for the example I gave above than an optimized, specialized, pipelined 32 bit CPU blit routine. The example above is too specific to handle properly with a generic routine.
« Last Edit: July 14, 2014, 10:38:56 PM by Thorham »
 

guest11527

  • Guest
Re: newb questions, hit the hardware or not?
« Reply #18 on: July 15, 2014, 06:39:10 AM »
Quote from: Thorham;768959
Took a look at BltBitmap() in the autodocs, and it looks like a generic blit routine. Definitely not going to be faster for the example I gave above than an optimized, specialized, pipelined 32 bit CPU blit routine. The example above is too specific to handle properly with a generic routine.

You still do not get it. BltBitmap() may use the CPU, and may run into an optimized, specialized, pipelined 32 bit CPU blit routine. Actually, it most certainly does if P96 is installed.
 

Offline Thorham

  • Hero Member
  • *****
  • Join Date: Oct 2009
  • Posts: 1149
    • Show only replies by Thorham
Re: newb questions, hit the hardware or not?
« Reply #19 on: July 15, 2014, 08:09:28 AM »
Quote from: Thomas Richter;768970
You still do not get it. BltBitmap() may use the CPU, and may run into an optimized, specialized, pipelined 32 bit CPU blit routine. Actually, it most certainly does if P96 is installed.
I get it perfectly fine, but you don't seem to get the difference between generic, and non-generic blitting routines. BltBitmap() has a source bitmap, a mask and a destination bitmap. How is that going to be optimal when you have a background tile, sprite+mask, overlay+mask and on top of that some pixels from a sprite one tile below, because the sprites are 24 pixels high and another mask for that (tiles are 16x16, sprites are 24 pixels high)? With a specialized routine, you can read ALL of that data in one go, AND you can do it for two tile positions at the same time. With BltBitmap() you need multiple calls to do one tile position.

Basically you're trying to tell me that a generic, one size fits all routine is better than specialized code that has been written specifically for the job. It's just not true.
 

guest11527

  • Guest
Re: newb questions, hit the hardware or not?
« Reply #20 on: July 15, 2014, 11:19:23 AM »
Quote from: Thorham;768972
Basically you're trying to tell me that a generic, one size fits all routine is better than specialized code that has been written specifically for the job. It's just not true.

It is at least better than writing a software that does not work for some configurations. That is what the operating system is good for.
 

Offline SamuraiCrow

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2280
  • Country: us
  • Gender: Male
    • Show only replies by SamuraiCrow
Re: newb questions, hit the hardware or not?
« Reply #21 on: July 15, 2014, 11:26:39 AM »
The main advantage of using the OS functions for blitting is that it works asynchronously so that the CPU can multitask while the Blitter is still plotting graphics.

Thorham's approach is the old-fashioned way of using the CPU to copy pixels.  It works best when you have sufficient cache memory and CPU time to do it that way.

The Blitter is clocked slow (3.5 MHz) and doesn't cache the mask plane when blitting BOBs.  I'd call that a shortcoming of the Blitter more than a shortcoming of the OS routines though.

Once faster, FPGA-based chipsets come on the scene, other advantages for using OS functions appear:  Using native chunky modes instead of chunky to planar conversion will save a lot of CPU time, for example.  If you're banging the hardware, your program will be oblivious to this new chunky hardware.

Does that sum it up?
 

Offline SamuraiCrow

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2280
  • Country: us
  • Gender: Male
    • Show only replies by SamuraiCrow
Re: newb questions, hit the hardware or not?
« Reply #22 on: July 15, 2014, 11:36:30 AM »
Quote from: Thomas Richter;768982
It is at least better than writing a software that does not work for some configurations. That is what the operating system is good for.


Or would be good for if it adequately supported all features of the chipset...  Copper lists anyone?

My opinion is that until we run all of our software in a static-compiled VM or have some way of propagating macros at install time rather than compile/assemble time, the OS will have some compatibility advantage.  Once we reach that point, however, a lot of stuff will shift from runtime to the programming ABI as accessed by the API defined by the OS so that unnecessary runtime checks can be optimized away via constant propagation and dead-code elimination in an ahead-of-time compiler.  That's one thing (and maybe the only thing) that AmigaDE did right.
 

Offline Thorham

  • Hero Member
  • *****
  • Join Date: Oct 2009
  • Posts: 1149
    • Show only replies by Thorham
Re: newb questions, hit the hardware or not?
« Reply #23 on: July 15, 2014, 11:51:41 AM »
Quote from: Thomas Richter;768982
It is at least better than writing a software that does not work for some configurations. That is what the operating system is good for.
It's not when your target is AGA+68020/30 and possibly A1200+trapdoor fastmem. Why do we have to take higher end systems in account, and make sacrifices on the low end, while the software could work perfectly fine on low end?

This is Amiga we're talking about, not some high end computer where making use of the OS for everything might make sense. For low end (68020/30) using the OS is fine. Well behaved software is nice, after all, and killing the OS (except for WHDLoad and demos) isn't a good thing, same for not using the OS's screen open functions. But blitting has to be fast on low end machines, or the software is going to run like crap.

Why does everything have to be adapted for high end machines and custom expansion boards? Want to run Amiga software? Use an Amiga.

Quote from: SamuraiCrow;768983
The main advantage of using the OS functions for blitting is that it works asynchronously so that the CPU can multitask while the Blitter is still plotting graphics.
With the blitter, yes, but the blitter is too slow.

Quote from: SamuraiCrow;768983
Thorham's approach is the old-fashioned way of using the CPU to copy pixels.  It works best when you have sufficient cache memory and CPU time to do it that way.
It's also the only way to get good performance on low end machines. It's old fashioned because the hardware is old, and many Amiga users use this hardware.
 

Offline SamuraiCrow

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2280
  • Country: us
  • Gender: Male
    • Show only replies by SamuraiCrow
Re: newb questions, hit the hardware or not?
« Reply #24 on: July 15, 2014, 12:00:37 PM »
Quote from: Thorham;768987
It's also the only way to get good performance on low end machines. It's old fashioned because the hardware is old, and many Amiga users use this hardware.


Hand-optimizing is a pain but being able to reinstall and reoptimize software from some bytecode that is optimized and compiled at install time will get your cake and let you eat it too!  (At the cost of some install time.)
 

Offline nicholas

Re: newb questions, hit the hardware or not?
« Reply #25 on: July 15, 2014, 12:06:34 PM »
Quote from: Thorham;768987
It's not when your target is AGA+68020/30 and possibly A1200+trapdoor fastmem. Why do we have to take higher end systems in account, and make sacrifices on the low end, while the software could work perfectly fine on low end?

This is Amiga we're talking about, not some high end computer where making use of the OS for everything might make sense. For low end (68020/30) using the OS is fine. Well behaved software is nice, after all, and killing the OS (except for WHDLoad and demos) isn't a good thing, same for not using the OS's screen open functions. But blitting has to be fast on low end machines, or the software is going to run like crap.

Why does everything have to be adapted for high end machines and custom expansion boards? Want to run Amiga software? Use an Amiga.


With the blitter, yes, but the blitter is too slow.


It's also the only way to get good performance on low end machines. It's old fashioned because the hardware is old, and many Amiga users use this hardware.

It's not like we can't detect the machine we are running on and use a different codepath for each architecture. Best of both worlds. :)
“Een rezhim-i eshghalgar-i Quds bayad az sahneh-i ruzgar mahv shaved.” - Imam Ayatollah Sayyed  Ruhollah Khomeini
 

Offline Thorham

  • Hero Member
  • *****
  • Join Date: Oct 2009
  • Posts: 1149
    • Show only replies by Thorham
Re: newb questions, hit the hardware or not?
« Reply #26 on: July 15, 2014, 12:10:50 PM »
Quote from: SamuraiCrow;768989
Hand-optimizing is a pain
680x0 assembly language is one of my computer related hobbies, and optimizing is part of the fun :) Actually, it's probably my favorite part of 680x0 coding. It's also the reason I stick to my 50 mhz 68030: It's challenging and interesting to get certain things to be fast on such systems.

Quote from: SamuraiCrow;768989
but being able to reinstall and reoptimize software from some bytecode that is optimized and compiled at install time will get your cake and let you eat it too!  (At the cost of some install time.)
Do we currently have such tools? How fast would that be for 68020/30 compared to hand optimized code?

Quote from: nicholas;768991
It's not like we can't detect the machine we are  running on and use a different codepath for each architecture. Best of  both worlds. :)
Indeed.
« Last Edit: July 15, 2014, 12:13:47 PM by Thorham »
 

Offline OlafS3

Re: newb questions, hit the hardware or not?
« Reply #27 on: July 15, 2014, 12:14:18 PM »
would it not be better to have standard libraries for that with versions for the different target platforms? When I worked on building up Aros Vision I did a lot of search (in both web and aminet) and found a lot of libraries that are dedicated to offer fast graphics hiding what platform you use (partly supporting ECS,AGA and RTG). SamuraiCrow knows one of those (and the owner has permitted to make changes on it). If adapted it would make life a lot easier. The 68k codebase is huge and we should make use of it as far as possible. We should have a set of portable libraries covering all important areas like graphics, sound and so on so that developer do not have to care about implementations/optimizations for a certain core (and it would be possible to port it to AROS/MorphOS/AmigaOS too).
« Last Edit: July 15, 2014, 12:20:56 PM by OlafS3 »
 

Offline nicholas

Re: newb questions, hit the hardware or not?
« Reply #28 on: July 15, 2014, 12:22:15 PM »
Quote from: OlafS3;768994
would it not be better to have standard libraries for that with versions for the different target platforms? When I worked on building up Aros Vision I did a lot of search (in both web and aminet) and found a lot of libraries that are dedicated to offer fast graphics hiding what platform you use (partly supporting ECS,AGA and RTG). SamuraiCrow knows one of those (and the owner has permitted to make changes on it). If adapted it would make life a lot easier. The 68k codebase is huge and we should make use of it as far as possible. We should have a set of portable libraries covering all important areas like graphics, sound and so on so that developer do not have to care about implementations/optimizations for a certain core (and it would be possible to port it to AROS/MorphOS/AmigaOS too).

There are many. Not sure about publicly released ones but I know of several that are in various states of finish.
“Een rezhim-i eshghalgar-i Quds bayad az sahneh-i ruzgar mahv shaved.” - Imam Ayatollah Sayyed  Ruhollah Khomeini
 

Offline smerf

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 1666
    • Show only replies by smerf
Re: newb questions, hit the hardware or not?
« Reply #29 from previous page: July 15, 2014, 12:29:22 PM »
You can bang the hardware, but remember you may have to make several different versions depending which Amiga you want the program to run on.


smerf
I have no idea what your talking about, so here is a doggy with a small pancake on his head.

MorphOS is a MAC done a little better