20 May 2010, 10:40 | #1 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
I need quick transparent blitting
Hi all coders !
As the title says, it's about gfx blitting. I have code to do this, but without transparency. Do someone here have fast and reusable code for that ? Goal is code that I can later use in games - whatever the game will be must be irrelevant for the blitting code (it's about reusability). It's not as obvious as "just use the blitter". First, I'm not sure that it's faster than 030+ (my target). Second, it must be able to blit to/from chipmem and fastmem. Most common case will be from fast to chip. Advantage of fastmem : you can go to town with a much bigger amount of graphics. And third, it must work under OS, so beware about too much hardware poking. Of course I could use OS itself for that, but what I fear is : S.L.O.W. What I have is an interleaved bitmap (all planes for first line, all planes for second line, and so on) - both source and destination will be like that, including screen (I'm not against more generic code, though ). Might be anything from 1 to 8 bits per pixel (usually from 4 to 8) - and code must cope with that, if possible without having one routine per case. The best thing for me is a routine which takes a bitmap and a region (x,y,w,h) as input, and blits that to another bitmap, at any place in it - using a transparency color and/or a mask plane. My bitmap structure can be rearranged to include whatever fields are needed. Most important thing : it must be reusable. So don't ask me what the main program is, as it could be anything requiring a blit. So what ? Where are the hardcore people ? |
20 May 2010, 21:19 | #2 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,762
|
|
24 May 2010, 09:51 | #3 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Completeness ?
Well, i don't really need this. But if you can blit from fastmem, then you can also blit from chipmem so don't care about that case. What i need is generic blitting with transparency to be included into my system frame, no more no less. |
24 May 2010, 11:02 | #4 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,515
|
Fast _and_ reusable/generic transparent blit does not exists in Amiga land
|
24 May 2010, 17:08 | #5 | |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Quote:
But if it's not possible, then i need a reusable/generic transparent blit and i will make it as fast as possible. Or i could take a non generic, but fast, blit, and try to make it more generic. Do you have examples ? |
|
24 May 2010, 20:28 | #6 |
Registered User
Join Date: Nov 2006
Location: Stockholm, Sweden
Posts: 237
|
For the sake of clarification -
for the transparency, how would you specify it? using an extra transparency plane? all bits 0 in all bitplanes? pixel value #N (where N is an input parameter to the blit call)? Are source and destination always of the same bitdepth? If source has less planes than destination, how should extraneous planes in destination be handled? don't modify those? Perform source->dest blit with the assumption that the missing source planes contain all zeroes? Last edited by Kalms; 24 May 2010 at 23:54. |
25 May 2010, 18:27 | #7 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,187
|
@meynaf
The only tricks to copying interleaved bitplanes with the CPU is that you only load the mask plane every N pixels in height where N is the number of bitplanes in the image and take 32 pixels at a time for width. The blitting routine can be reused for additional width by putting it inside a loop. |
27 May 2010, 09:13 | #8 | ||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Quote:
So you have start mask, inside mask (all 1's if you're just copying w/o trans), end mask. Btw a regular (i.e. without transparency) blitting already eats all available cpu registers. Quote:
But i have code to "hide" this by precomputing a transparency plane which is used like a cache. So choose the method that better suits performance Yes they are - at least for now. Different bit depths are for a distant future - if i ever need this, which i doubt. |
||
31 May 2010, 17:29 | #9 |
Registered User
Join Date: Nov 2006
Location: Stockholm, Sweden
Posts: 237
|
I've been doodling around a bit with this over the past few days. Haven't done any test runs on real hardware yet.
Here's a routine which accomplishes the following: * copies a rectangular region from source to destination * supports 1..8 bitplanes * bitplanes must be either interleaved or contiguous * only 32-bit large, 32-bit aligned memory reads/writes are used Stuff not yet done properly: * it will always read the entire destination buffer * no transparency support Is this in the right ballpark with regards to performance and functionality? Also, if you are having a lot of transparency in your 32pixel runs it might be advantageous for the sprite blitting to maintain a copy of the framebuffer in fastram as well (for the destination reads). Is that an option for you? It would then affect all rendering code, not just the code that needs bitmap blits. Routine link:http://unitedstatesofamiga.googlecod...-Kalms-0.5.zip |
03 June 2010, 02:17 | #10 |
Registered User
Join Date: Nov 2006
Location: Stockholm, Sweden
Posts: 237
|
I implemented a masked version tonight.
Available in this package:http://unitedstatesofamiga.googlecod...-Kalms-0.6.zip Due to how it's implemented (it's processing vertically) it is wasteful with memory bandwidth on any platform that reads and/or writes 16-byte segments against fast memory. I'm not very keen on doing a rewrite to reduce the memory bandwidth waste right now. It might turn out that you need one routine for 020/030 and one for 040/060. Profiling results on 68060@50: Copy fast->chip, with 8bpl output... Mask is all empty: processing 2.1MB/frame Mask contains mixed data: outputting 43kB/frame Mask is all set: outputting 64kB/frame Rewriting the routine would likely make it run at up to 60kB/frame for mixed data and 90kB/frame for an all-set mask. |
03 June 2010, 10:03 | #11 | |||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Quote:
Quote:
Quote:
But i've read you're processing data vertically. Might make things simpler, but i'm afraid there will be some kind of display tearing if blit isn't made fully line by line... |
|||
22 June 2010, 19:05 | #12 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
I now have the blitting code i wanted. Thx to anyone who helped.
If some of you wants to have a look at it, then you can either ask here or PM me. As the code is integrated into my asm framework, it's not easy to post (it's not a simple, separate routine). |
23 June 2010, 17:02 | #13 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,762
|
So you wrote it from scratch? Must've been a pain in the backside Why don't you attach your system frame here? That way people anyone can have a look at your code
|
24 June 2010, 13:16 | #14 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
No, i didn't write it from scratch.
As a basis i used my regular (non-transparent) blitting routine, in which Don Adan (thx to you !) has been able to free enough registers (or better use them) to support transparency. About posting my system frame, it's already more than 4000 lines of code, with (as usual ) french comments. Besides, i hesitate in spreading it too much. Of course it would be cool to see it widely used - and you can be sure it helps in making programs simpler. But if i did so, i'd be flooded with feature requests (probably) and i would no longer be able to alter things in an incompatible way (which i sometimes do ; only requires some searching on my HD). |
13 November 2020, 14:28 | #15 | |
Zone Friend
Join Date: May 2006
Location: France
Posts: 1,801
|
Quote:
I'd like to look at it |
|
13 November 2020, 16:08 | #16 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
After 10 years ? Ok then. Check your PM
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
What's wrong with my blitting code? | MagerValp | Coders. System | 6 | 22 April 2013 15:00 |
Blitting question | sandruzzo | Coders. General | 30 | 06 April 2011 11:29 |
Bitmaps in FASTRAM and blitting - C++ | NovaCoder | Coders. General | 22 | 01 December 2010 23:40 |
Blitting with size 1x255 | JackAsser | Coders. Tutorials | 10 | 16 February 2010 20:49 |
difference in blitting uae vs. hw | yoki | Coders. General | 5 | 15 July 2009 15:21 |
|
|