English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 20 September 2018, 13:09   #21
deimos
Registered User

 
Join Date: Jul 2018
Location: Londonish / UK
Posts: 111
I'll be happy to share my CPU based code once I believe I can't make it faster, but until people better than me have verified that it is as fast as it can be, it's not the basis for comparison with anything.

As for blitter based code? That's a job for someone else.

Quote:
Originally Posted by sandruzzo View Post
Since @deimos have all code done we can ask him to implement this way: blitter line filling + cpu
deimos is online now  
Old 20 September 2018, 16:18   #22
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 1,255
@deimos

Thanks for your reply. you've been doing a hell of job!


I could try to put on some simple test to see which is faster. Some sort of best case scenario with well aligned quand, and fill it with blitter and cpu
sandruzzo is offline  
Old 21 September 2018, 16:34   #23
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 1,255
I did a simple test and blitter, on A500 seems to be more than 2 time faster

https://ibb.co/eeCN4z


sandruzzo is offline  
Old 21 September 2018, 16:50   #24
deimos
Registered User

 
Join Date: Jul 2018
Location: Londonish / UK
Posts: 111
I think your test needs to be a bit more representative of what a real application or game would draw.

Quote:
Originally Posted by sandruzzo View Post
I did a simple test and blitter, on A500 seems to be more than 2 time faster

https://ibb.co/eeCN4z


deimos is online now  
Old 21 September 2018, 17:00   #25
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 1,255
Quote:
Originally Posted by deimos View Post
I think your test needs to be a bit more representative of what a real application or game would draw.

I'll do in the future, now I wanted to test blitter line filling with simple d=a. Since you don't need to setup a lot of register, i could help a lot the cpu.
sandruzzo is offline  
Old 22 September 2018, 12:50   #26
DanScott
Lemon. / Core Design

DanScott's Avatar
 
Join Date: Mar 2016
Location: Belgrade, Serbia
Posts: 319
Does you blitter test iinvolve the following steps:

clearing the blitter buffer?
drawing the lines?
filling the buffer?
copying the buffer to all the bitplanes (either "or'ing" or "not anding")?

To be honest, your test is not representitive of anything if it is not doing all these things....
DanScott is offline  
Old 22 September 2018, 16:15   #27
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 1,255
Quote:
Originally Posted by DanScott View Post
Does you blitter test iinvolve the following steps:

clearing the blitter buffer?
drawing the lines?
filling the buffer?
copying the buffer to all the bitplanes (either "or'ing" or "not anding")?

To be honest, your test is not representitive of anything if it is not doing all these things....
I just wanted to see if line filling with blitter is fast. Now I have to do better test, just need time. Like I said, I'm interested on line filling
sandruzzo is offline  
Old 23 September 2018, 12:23   #28
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 1,255
About filling, I've an idea. Instead of fill a triangle, we can use a mask that cut unwanted pixels outside triangle edges(some sort of inverted mask)on a prefilled bitmap, and then, with blitter, copy this triangle chunck, into screen, piece by pieces, meanwhile cpu is preparing the next triangles' chunck. Every chunck is maximum 16 px in height
sandruzzo is offline  
Old 23 September 2018, 16:56   #29
Kalms
Registered User
 
Join Date: Nov 2006
Location: Stockholm, Sweden
Posts: 198
Quote:
Originally Posted by sandruzzo View Post
About filling, I've an idea. Instead of fill a triangle, we can use a mask that cut unwanted pixels outside triangle edges(some sort of inverted mask)on a prefilled bitmap, and then, with blitter, copy this triangle chunck, into screen, piece by pieces, meanwhile cpu is preparing the next triangles' chunck. Every chunck is maximum 16 px in height
Out of curiosity, what performance would you estimate that this gives you?
Kalms is offline  
Old 23 September 2018, 17:52   #30
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 1,255
Quote:
Originally Posted by Kalms View Post
Out of curiosity, what performance would you estimate that this gives you?
I have no figures. Like I said, was just an idea that'll try
sandruzzo is offline  
Old 23 September 2018, 18:07   #31
Kalms
Registered User
 
Join Date: Nov 2006
Location: Stockholm, Sweden
Posts: 198
Quote:
Originally Posted by sandruzzo View Post
I have no figures. Like I said, was just an idea that'll try
Okay. When the CPU "prepares" a chunk, do you intend that the CPU draws the mask pattern into a buffer? Effectively drawing the left- and right- edges of a 16-pixels-high segment of a triangle into a 1-bitplane image? If not, how do you intend this to work?
Kalms is offline  
Old 23 September 2018, 18:09   #32
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 1,255
Quote:
Originally Posted by Kalms View Post
Okay. When the CPU "prepares" a chunk, do you intend that the CPU draws the mask pattern into a buffer? Effectively drawing the left- and right- edges of a 16-pixels-high segment of a triangle into a 1-bitplane image? If not, how do you intend this to work?
You'we got it, cpu draws that mask patter, and then with blitter we can draw this chunk into buffer. This way should free cpu do fill the whole triangle since it's prefilled
sandruzzo is offline  
Old 23 September 2018, 18:18   #33
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 1,255
I think that with a bunch of precomputated masks(16*16 pixel), and knowing lines' slope, we can build that edge mask very fast.
sandruzzo is offline  
Old 23 September 2018, 18:35   #34
Kalms
Registered User
 
Join Date: Nov 2006
Location: Stockholm, Sweden
Posts: 198
Quote:
Originally Posted by sandruzzo View Post
I think that with a bunch of precomputated masks(16*16 pixel), and knowing lines' slope, we can build that edge mask very fast.
Alright, that makes your idea a lot more concrete, thanks.

Here are some more things for you to consider when you refine this:

- How many mask patterns do you need? Is there a trade off between precision and memory usage here? Can the mask patterns reasonably fit into memory?
- How do you handle edges that slope more horizontally than vertically? (This is a more general version of 'how do you handle edges which cross a horizontal 16-pixel boundary halfway through a 16-line-block?')
- what the CPU does is similar to drawing the edge of a triangle. Would it make more sense for the CPU to work directly against the screen?
- How do you effectively handle the 'interior' portions of large triangles - those areas where there are entirely filled 16x16-pixel-blocks?


If you can sort out these algorithmic problems then you are closer to a point where this can be compared to other approaches.

Last edited by Kalms; 23 September 2018 at 18:56.
Kalms is offline  
Old 23 September 2018, 20:11   #35
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 1,255
Quote:
Originally Posted by Kalms View Post
Alright, that makes your idea a lot more concrete, thanks.

Here are some more things for you to consider when you refine this:

- How many mask patterns do you need? Is there a trade off between precision and memory usage here? Can the mask patterns reasonably fit into memory?
- How do you handle edges that slope more horizontally than vertically? (This is a more general version of 'how do you handle edges which cross a horizontal 16-pixel boundary halfway through a 16-line-block?')
- what the CPU does is similar to drawing the edge of a triangle. Would it make more sense for the CPU to work directly against the screen?
- How do you effectively handle the 'interior' portions of large triangles - those areas where there are entirely filled 16x16-pixel-blocks?

If you can sort out these algorithmic problems then you are closer to a point where this can be compared to other approaches.
Thanks for your Questions, I'll think on them.
Quote:
- what the CPU does is similar to drawing the edge of a triangle. Would it make more sense for the CPU to work directly against the screen?
Yes, is better to write directly on screen if you don't have so much colors on screen, but if you have to handle multiply bit-plane, or tringles that require to be filled with many move or movem, that could slow down

Quote:
- How do you effectively handle the 'interior' portions of large triangles - those areas where there are entirely filled 16x16-pixel-blocks?
There is no need to handle them, since we have only to cut triangles' edge on a prefilled are....
sandruzzo is offline  
Old 23 September 2018, 20:51   #36
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 1,255
I think I wasn't able to explain this way well. Think about a piece of paper which is our prefilled area. Now, think about having scissor to cut our triangle and put it into screen.

I hope this example would be fine. Some sort of Stencil buffer
sandruzzo is offline  
Old 24 September 2018, 09:09   #37
Kalms
Registered User
 
Join Date: Nov 2006
Location: Stockholm, Sweden
Posts: 198
I'm not going to spend more time on this myself, but from what I can see so far the two main challenges will probably be 1. memory consumption for the precomputed masks (with too few masks, the triangle edges will look ugly when they cross between 16-pixel blocks) and 2. CPU overhead per individual block.
Kalms is offline  
Old 26 September 2018, 15:30   #38
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 1,255
Another possible way to optimize this kind of rendering is to define traingles' or quads' bounding box, and fill the outside portions' of these polygons and then doing a cookie cut operation with blitter
sandruzzo is offline  
Old 27 September 2018, 00:30   #39
DanScott
Lemon. / Core Design

DanScott's Avatar
 
Join Date: Mar 2016
Location: Belgrade, Serbia
Posts: 319
Just code it up and come back with some results. Will be interesting to see what you come up with
DanScott is offline  
Old 27 September 2018, 06:41   #40
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 1,255
Quote:
Originally Posted by DanScott View Post
Just code it up and come back with some results. Will be interesting to see what you come up with
I'm doing it, just a code a tri/quad filler to test some rendering tecniques
sandruzzo is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using blitter for filling 3D polygons kovacm Amiga scene 34 25 January 2018 16:30
Blitter filling speed, how much? sandruzzo Coders. Asm / Hardware 7 03 July 2015 15:38
CPU Filling vs. Blitter Filling Routine victim Coders. General 18 26 January 2014 03:15
Blitter filling routine used in games Codetapper Coders. General 2 26 January 2012 11:20
Filling with the blitter... Lonewolf10 Coders. Tutorials 7 13 September 2011 15:30

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 23:07.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.
Page generated in 0.09179 seconds with 15 queries