English Amiga Board


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

 
 
Thread Tools
Old 18 March 2023, 12:17   #1
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,219
help optimizing my blits in my program

Something is seriously wrong with my Xevious project (https://github.com/jotd666/xevious)

With fast memory, code is running OK, but as soon as I'm using only chipmem + cycle exact the game crawls and flickers despite double buffering

I've watched DMA debugger in this video on Project X (guys who know what they're talking about!)

[ Show youtube player ]

and indeed there's a lot of green, indicating that a lot of blitting is taking place.

In my game, here's the result

Click image for larger version

Name:	040.png
Views:	107
Size:	20.9 KB
ID:	78354

I'm using the blitter to blit enemies, and that doesn't show on the debugger

using "v -4" with FMODE=0xF

bitplane fetch looks different, copper yellow occurrences are expected (there's dynamic color on the text bitplane), there's a sprite (the ship) which expains the pink, background tiles are copied using CPU (8x8...) but even when only BOBs are active the game crawls.

Compared with Banshee on same config, Banshee flies. What I'm doing wrong? (Banshee shows the same blue -bitplane- pattern because of fmode probably, but a lot of greenish colors, not a lot of brown like in my case)

On my previous arcade projects, I had very few blits. Maybe 1 or 2. Here, lots of 16x16 enemies, small shots... Using dual playfield so no background restore. Lots of CPU also wasted refreshing text, but even without it it crawls...

dma debugger looks like a wonderful tool but I'm not getting it...

Last edited by jotd; 18 March 2023 at 12:22.
jotd is offline  
Old 18 March 2023, 12:33   #2
roondar
Registered User
 
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,415
It doesn't appear from the screenshot you've shown that the Blitter use is the problem. Looking at the Visual DMA Debugger output you've shared, it's almost all CPU (the brownish colour you're referring to). The amount of Blitter time shown here doesn't seem to be much more than 10% or so of the total.

I'd check if there's something wrong with your main loop or if you accidentally do some stuff non-optimally with the CPU (or perhaps running some stuff too often?), because that's where your problem seems to be.
roondar is offline  
Old 18 March 2023, 13:09   #3
paraj
Registered User
 
paraj's Avatar
 
Join Date: Feb 2017
Location: Denmark
Posts: 1,113
Yes, most of that is CPU activity. Here's an updated legend for the DMA debugger (hopefully without mistakes):


EDIT: Looked at the test you posted from a week or so ago, and it seems like all branches are word-sized even if they could be short. Maybe you're missing some optimization flags when assembling (that won't fix everything, but it certainly won't hurt)?
Attached Thumbnails
Click image for larger version

Name:	dma_debug_legend.png
Views:	313
Size:	2.7 KB
ID:	78356  

Last edited by paraj; 18 March 2023 at 13:31.
paraj is offline  
Old 18 March 2023, 13:29   #4
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
Yup, blitter is somewhat active in the top ~10% and then a decent amount of the 2nd quarter. Not much of a problem.
Lots of cpu activity, I'd guess the instruction cache is not utilized sufficiently. Also lots of unused slots in the cpu heavy parts (dark dots between purple and brown).

@paraj: Yeah, colors look OK. Just did one for myself since I never know what is what ;p.
a/b is offline  
Old 18 March 2023, 22:53   #5
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,219
Quote:
Originally Posted by a/b View Post
Lots of cpu activity, I'd guess the instruction cache is not utilized sufficiently. Also lots of unused slots in the cpu heavy parts (dark dots between purple and brown).
thanks.

I don't get the "lots of unused slots" part.

The fact that the game is a transcode from Z80 is probably the issue. It was designed for the NeoGeo where 68000 runs at 12MHz probably without bus cycles stolen by the dma.

The good point is: I could apply several micro optimizations and find one bug where the blitter was used to erase where a hardware sprite was (lol). But now I'm running out of ideas. Maybe my game will required fastmem (which a lot of A1200 owners have)

Here's dma debug with fastmem, A1200 cycle exact A1200 approx speed. CPU instructions don't even appear. Only CPU data appears and there's plenty of time to do everything... sob... (also runs great on 68060 ... unless I'm running the game in chipmem)

Running with CACHE on real machine slightly improves speed & flickering. Hope is not lost yet

Click image for larger version

Name:	042.png
Views:	70
Size:	13.7 KB
ID:	78368

Last edited by jotd; 18 March 2023 at 23:13.
jotd is offline  
Old 18 March 2023, 23:18   #6
paraj
Registered User
 
paraj's Avatar
 
Join Date: Feb 2017
Location: Denmark
Posts: 1,113
This is clearly showing that you're limited by the CPU. If there's still graphical issues that aren't handled by double buffing you have to work on that. Are you only updating things in vblank interrupt or outside as well? Is that properly syned?
paraj is offline  
Old 18 March 2023, 23:47   #7
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
If would also check if it's possible to split larger routines so that they can fit into a 256b icache, or maybe do some reordering for better icache utilization. That's a huge factor if you only have chip memory, especially with so many slots taken up by cpu instruction fetch as seen on the first picture.
There is a section at ~20% with a lot of unused slots, are you doing muls/divs there or do you know what exactly is happening? Would it be possible to sync that with blitting so blitter can eat up those cycles?
a/b is offline  
Old 19 March 2023, 09:13   #8
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,219
There seemed to be a big issue on Mark's end. He did whatever magic he did, and the flickering is almost GONE now. dma debug is also different (I still have issues interpreting it but the bottom seems to indicate fewer cpu activity)

Click image for larger version

Name:	043.png
Views:	69
Size:	16.3 KB
ID:	78370

now time to optimize some heavy remaining parts.
jotd 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
Does assembler language optimizing 'compilers' exist? (Whole program optimizer) NorthWay Coders. General 13 18 March 2023 20:37
Speed difference blind blits vs restoring background? ImmortalA1000 Coders. General 4 19 August 2022 16:02
Printing Score with sprites (or blits) Havie Coders. Blitz Basic 18 31 July 2020 18:28
Hard Blits under intuition & Gif To "struct BitMap" converter krabob Coders. Asm / Hardware 2 15 September 2014 17:25
External windows program communicating with program running inside WinUAE xxxxx support.WinUAE 10 19 February 2013 09:27

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 17:13.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.13866 seconds with 14 queries