Samapico Posted December 19, 2008 Report Posted December 19, 2008 Try out the test release I just put up in the Downloads section... Performance features:-24x less memory used by ASSS regions-Only one instance declared for each drawing layer, instead of declaring them in each map, which results in more or less 18MB memory used instead of 18MB memory used for EACH map. The result of this is NO MORE blank screen caused by regions-intensive maps. However, LVZ images still use quite a lot of video memory, so it's not impossible you get blank screens with several LVZs. Improvements:-There was a small bug with ASSS regions where the bottom row and right column of tiles didn't show the regions correctly; that is fixed-The selected region is now drawn ON TOP of all the other regions with its actual color, making it more visible There are still some glitches like if you try to hide a region, it also selects it and shows it back... By the way, I just took my 7300GT out of my computer to run on the sucky Intel chipset to test these issues better... And I did notice a huge difference. With 3.4.09:I could not even open a single map of hyperspace correctly, not all the regions were shown and as soon as something else had to be shown, everything went white.I also could only open about 5 or 6 EMPTY maps before it went blank. With 3.4.10:I could open 10 maps easily, including 3 hyperspace maps I did not test with lvz's yet, since I haven't improved those yet.
rootbear75 Posted December 19, 2008 Report Posted December 19, 2008 in order to use less memory, blank the windows of maps not actively being selected. or only have the last 2 selected being completely drawn.
Drake7707 Posted December 19, 2008 Report Posted December 19, 2008 That doesn't make much of a difference, the problem is the 'textures' for lvz or the temporary bitmaps for selection, regions etc that's causing the memory of the video card to overflow. The preview where you actually draw on doesn't take much memory at all. Reloading lvz's takes quite a lot of time, especially when there are a lot of them, because it has to reload everything from disk. And discarding unnecessary temporary bitmaps not needed at the time is already happening. One thing that can be done is like this (wonder why i think of it only now ): instead of caching it on the disk you could cache it in general memory by using GetDIBits to retrieve all the pixels from the hdc into an array (much like clsPic does). I think i'll write a resource manager for that ^^ brb Option Explicit Private Type resource id As Long path As String cached As Boolean pixelarr() As Byte hdc As Long End Type Dim resources() As resource Dim resourceCount As Integer 'current id count to make a unique id Dim curIdCount As Long 'video memory used for resources Dim memUsed As Long Const MAX_MEMORY = 134217728 '128mb Sub load(imgPath As String) If resourceCount >= UBound(resources) Then ReDim Preserve resources(resourceCount + 100) End If Dim r As resource r.id = makeUniqueID r.path = imgPath '// TODO ' calculate memory for resource Dim memForResource As Long If memUsed + memForResource > MAX_MEMORY Then 'loading this resource will cause the memory to overflow 'swap out a resource that's not used to standard memory freeMemory (memForResource) End If memUsed = memUsed + memForResource End Sub Private Function makeUniqueID() As Long 'make a unique id for each resource makeUniqueID = curIdCount curIdCount = curIdCount + 1 End Function Sub save(id As Integer, path As String) Dim hdc As Long hdc = getResource(id) '//TODO 'save resource to path End Sub Sub discard(id As Integer) Dim idx As Integer idx = getResourceById(id) If idx <> -1 Then 'discard resource '// TODO 'calculate memory for resource Dim memForResource As Long '// TODO 'destroy its hdc memUsed = memUsed - memForResource Dim i As Integer For i = idx + 1 To resourceCount - 1 resources(i - 1) = resources(i) Next resourceCount = resourceCount - 1 End If End Sub Function getResource(id As Integer) As Long 'returns the hdc where the image is ready Dim idx As Integer idx = getResourceById(id) If idx <> -1 Then If resources(idx).cached Then '// TODO 'we need to restore the array back to a hdc, but we need to make 'sure that we still have enough memory Else getResource = resources(idx).hdc End If End If End Function Private Sub freeMemory(mem As Long) 'ensure that we have enough memory to load mem into the video ram 'move resources from their hdc's to arrays here Do While memUsed + mem > MAX_MEMORY '// TODO 'Clear out resources here 'select resources by a certain criteria (oldest, least used ?) and cache them Dim resID As Integer cache (resID) Loop End Sub Sub cache(id As Integer) Dim idx As Integer idx = getResourceById(id) If idx <> -1 Then 'force cache of the resource 'dump them to an array If resources(idx).cached Then 'it's already cached Else '//TODO 'move the hdc to an array '// TODO ' calculate memory for resource Dim memForResource As Long memUsed = memUsed - memForResource End If End If End Sub 'returns index of resource by id Private Function getResourceById(id As Integer) As Integer Dim i As Integer For i = 0 To resourceCount - 1 If resources(i).id = id Then getResourceById = i Exit Function End If Next getResourceById = -1 End Function Private Sub Class_Initialize() ReDim resources(100) resourceCount = 0 memUsed = 0 End Sub Private Sub Class_Terminate() 'delete all remaining resources Dim i As Integer For i = 0 To resourceCount - 1 Call discard(resources(i).id) Next End Sub I know, still a lot of todo's: - hdc -> array dump - array -> hdc - memory calculation of a resource - selection process of which resource to cache when there's not enough memory anymore (least used could be done with a timestamp for each resource, oldest could be done with a stack that pushes all the resources in it and the oldest is element 0)
Dr Brain Posted December 20, 2008 Report Posted December 20, 2008 If it makes you feel better, ASSS takes around 20 seconds to load the Hyperspace maps into memory each time a new arena is created.
Samapico Posted December 20, 2008 Author Report Posted December 20, 2008 That's about what it took for DCME in previous versions too... Now it doesn't take more than 5 seconds
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now