Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hardware Acceleration and Uses
#5
Even using the one that you say jumps your CPU usage up to 50%, I'm just not seeing it.  I follow the link, copy the code, run it...

And use 2 -3% CPU at max.



If I had to guess at the issue you're having, however, I'd say it's the way you're doing things.

Take a look at this code snippet: 
Code: (Select All)
For k = i2 To i3
            j = Len(button$(k)): a$ = " " + button$(k) + " "
            HTMLBStatic = fb_gfx_hyb_hw(j * 8, 2 * 16, 170, 170, 170, -9, -9, -1, Mid$(a$, 1, j))
            HTMLBHover = fb_gfx_hyb_hw(j * 8, 2 * 16, 200, 200, 200, -8, -7, -1, Mid$(a$, 1, j))
            HTMLBPress = fb_gfx_hyb_hw(j * 8, 2 * 16, 200, 200, 200, -1, -1, -1, Mid$(a$, 1, j))
            Overlay_Hardware = _CopyImage(overlay, 33)
            _PutImage (0, 0), Overlay_Hardware
            If HtmlBtn = k And lb = 0 Then
                _PutImage ((x(k) - 1) * 8, (y(k) - 1) * 16 + 8), HTMLBHover
            Else
                If lb = 0 And b_hover = k Then
                    _PutImage ((x(k) - 1) * 8, (y(k) - 1) * 16 + 8), HTMLBHover
                ElseIf Abs(lb) = 1 And b_hover = k Then
                    _PutImage ((x(k) - 1) * 8, (y(k) - 1) * 16 + 8), HTMLBPress
                Else
                    _PutImage ((x(k) - 1) * 8, (y(k) - 1) * 16 + 8), HTMLBStatic
                End If
            End If
            _FreeImage HTMLBHover
            _FreeImage HTMLBPress
            _FreeImage HTMLBStatic
            _FreeImage Overlay_Hardware
        Next

You make 4 software images. You then convert those to 4 hardware images. You free the software image. You put the hardware to the screen. You free the hardware image.

And you do this inside a FOR loop inside your DO loop... and... OMG!! How many times is that memory being allocated and freed repeated in this process???

I think what you need to do here is:

1) Step back and rebuild so that the screen only updates when needed.

DO
updateScreen = _FALSE
k = _KEYHIT
IF k THEN updateScreen = _TRUE 'a key was hit, let's set the flag to update the screen!

'more junk

IF updateScreen THEN
'do the draw routines
_DISPLAY
END IF
LOOP

If the screen isn't changed, you don't need to redraw it over and over; just leave it as it was until the user interacts with it somehow.

^This change would make a HUGE difference in things.

2) Make the conversion over from software to hardware ONCE, and be done with it, if you possibly can. Create those buttons in advance, don't bother to _FREEIMAGE them. Free the software versions, but save the hardware versions for use elsewhere in the program as needed. Don't create and free them on the fly like that repeatedly. Make 'em, save 'em, use 'em. Only when you're certain you're done with them, THEN free them.

The issue isn't so much the hardware image itself; it's "the creation of the software image, the copy to the hardware, the freeing of the software, the display of the hardware, the freeing of the hardware"....

If you can change it to just "display of the hardware", can't you see how much more efficient that would end up being? << And then make it so it only does that when the screen itself HAS to be updated??



This is a case where the problem isn't in the commands. It's in how you're implementing and trying to use those commands. Wink
Reply


Messages In This Thread
Hardware Acceleration and Uses - by Pete - 02-18-2025, 04:57 PM
RE: Hardware Acceleration and Uses - by SMcNeill - 02-18-2025, 05:42 PM
RE: Hardware Acceleration and Uses - by a740g - 02-18-2025, 05:47 PM
RE: Hardware Acceleration and Uses - by Pete - 02-18-2025, 10:35 PM
RE: Hardware Acceleration and Uses - by SMcNeill - 02-18-2025, 11:23 PM
RE: Hardware Acceleration and Uses - by SMcNeill - 02-18-2025, 11:36 PM
RE: Hardware Acceleration and Uses - by Pete - 02-18-2025, 11:45 PM
RE: Hardware Acceleration and Uses - by SMcNeill - 02-19-2025, 06:06 AM
RE: Hardware Acceleration and Uses - by SMcNeill - 02-19-2025, 06:42 AM
RE: Hardware Acceleration and Uses - by SMcNeill - 02-19-2025, 06:58 AM
RE: Hardware Acceleration and Uses - by SMcNeill - 02-19-2025, 07:06 AM
RE: Hardware Acceleration and Uses - by Pete - 02-19-2025, 12:05 PM
RE: Hardware Acceleration and Uses - by SMcNeill - 02-19-2025, 02:28 PM
RE: Hardware Acceleration and Uses - by SMcNeill - 02-19-2025, 02:16 PM
RE: Hardware Acceleration and Uses - by Pete - 02-19-2025, 06:00 PM
RE: Hardware Acceleration and Uses - by SMcNeill - 02-19-2025, 07:54 PM
RE: Hardware Acceleration and Uses - by Pete - 02-19-2025, 08:52 PM
RE: Hardware Acceleration and Uses - by SMcNeill - 02-20-2025, 04:23 PM
RE: Hardware Acceleration and Uses - by Pete - Yesterday, 02:28 AM
RE: Hardware Acceleration and Uses - by SMcNeill - Yesterday, 03:13 AM



Users browsing this thread: 15 Guest(s)