Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
140 user(s) are online (127 user(s) are browsing Forums)

Members: 0
Guests: 140

more...

Support us!

Headlines

 
  Register To Post  

(1) 2 3 4 »
Optimize SDL blitting routine
Quite a regular
Quite a regular


See User information
Hello,

doesn anyone know if there's a way to optimize the SDL 1.2 blittling routines?

Using 32 bit mode is slow even in 640x480 if there are a certain number of blitting operations.
Could be possible to substitute at least the blitting part using the compositing? This probably would imply the conversion of an SDL surface to an amiga surface. What do you think about?

Retired
Go to top
Re: Optimize SDL blitting routine
Quite a regular
Quite a regular


See User information
Without having any idea how SDL works, I'd say: Sure, that's possible!

Software developer for Amiga OS3 and OS4.
Develops for OnyxSoft and the Amiga using E and C and occasionally C++
Go to top
Re: Optimize SDL blitting routine
Quite a regular
Quite a regular


See User information
@Deniil

SDL uses his own surface:

https://wiki.libsdl.org/SDL_Surface

Having this info about the SDL surface, a very fast way to convert the SDL surface to an Amiga surface, then blit via compositing.




Retired
Go to top
Re: Optimize SDL blitting routine
Quite a regular
Quite a regular


See User information
@AmigaBlitter

Looks like normal bitmaps. Compositing should be able to handle most of these formats I presume. At this time there is probably some incompatibility between the surfaces most SDL programs use and Amiga, so a software conversion has to be run before the bitmap is blitted.

I don't know where this conversion happens. Maybe there is a manual copy/conversion from SDL to an Amiga bitmap somewhere that is actually unnecessary, but added for maximum platform independence. It would probably be possible to use a blitting function here for most cases, or maybe even skip this step completely, just put it on a composition bitmap and off it goes. Don't know the abstraction inside SDL, but it's probably quite high so lots of conversions and layers needed to go through.

Software developer for Amiga OS3 and OS4.
Develops for OnyxSoft and the Amiga using E and C and occasionally C++
Go to top
Re: Optimize SDL blitting routine
Quite a regular
Quite a regular


See User information
@Deniil

Hi,

in the SDL_os4Surface.c seems that almost the conversions are made:

int os4video_AllocHWSurface(_THISSDL_Surface *surface)
{
    
int result = -1;

    
dprintf("Allocating HW surface %p flags:%s\n"surfaceget_flags_str(surface->flags));

    
/* Create surface hardware record if not already present */
    
if (!surface->hwdata)
        
surface->hwdata SaveAllocPooled(_this->hiddensizeof(struct private_hwdata));

    if (
surface->hwdata) {
        
struct BitMap *friend_bitmap;

        
surface->hwdata->type hwdata_bitmap;
        
surface->hwdata->lock 0;

        
/* Determine friend bitmap */
        
if (_this->hidden->scr == NULL)
        {
            
/* Windowed mode - use the off-screen buffer's bitmap */
            
friend_bitmap _this->hidden->offScreenBuffer.bitmap;
        }
        else
        {
            
/* Full-screen mode. Use the display's bitmap */
            
friend_bitmap _this->hidden->win->RPort->BitMap;
        }

        
dprintf("Trying to create %dx%dx%d bitmap\n",
                
surface->wsurface->hsurface->format->BitsPerPixel);

        
surface->hwdata->bm SDL_IP96->p96AllocBitMap (surface->w,
                                                    
surface->h,
                                                    
surface->format->BitsPerPixel,
                                                    
BMF_MINPLANES BMF_DISPLAYABLE,
                                                    
friend_bitmap,
                                                    
0);

        if (
surface->hwdata->bm)
        {
            
/* Successfully created bitmap */
            
dprintf ("Created bitmap %p\n"surface->hwdata->bm);

            
surface->flags |= SDL_HWSURFACE SDL_PREALLOC;
            
result 0;
        }
        else
        {
            
/* Failed */
            
dprintf ("Failed to create bitmap\n");
            
SaveFreePooled(_this->hiddensurface->hwdatasizeof(struct private_hwdata));
            
surface->hwdata NULL;
        }
    }
    return 
result;
}


there are other routines too.

The sdl_os4blit contains assembly routine for copy from an 8-bit paletted surface to a 16/24/32 bit surface


Retired
Go to top
Re: Optimize SDL blitting routine
Just can't stay away
Just can't stay away


See User information
Please check how Alain Thellier managed to redirect rendering from SDL to compositing here : http://os4depot.net/index.php?functio ... action/abbayedesmorts.lha

Hopefully he sees this thread and comes to explain what he did

--
AmigaONE X1000 and Radeon RX 560
Go to top
Re: Optimize SDL blitting routine
Just popping in
Just popping in


See User information
@K-L

This one doesn´t use SDL at all... it´s more after "CompositePOC" (Aminet). The concept used there is not very SDL-ish, and I think that compositing could be used in SDL in very few points (blitting incl. alpha channel, for example. But not with RLE surfaces etc.)

Go to top
Re: Optimize SDL blitting routine
Home away from home
Home away from home


See User information
@whose

Quote:
This one doesn´t use SDL at all... it´s more after "CompositePOC" (Aminet). The concept used there is not very SDL-ish, and I think that compositing could be used in SDL in very few points (blitting incl. alpha channel, for example. But not with RLE surfaces etc.)

Even if it is only needed with alpha blitting (& maybe blitting with 2D transforms), implementing it could make a big difference. If a game uses alpha blitting to render almost everything, then accelerating that function becomes critical. From memory, lack of HW accelerated alpha blitting was a key performance killer for several SDL games.

As an aside, the Quake III engine renders pretty much everything using glDrawElementsTriangles() with arrays of triangles whose vertices are in tri-strip order (and uses compiled vertex arrays where possible). That makes this one particular draw function and mode performance critical for that engine. Indeed, I've read that ATI implemented driver optimizations specifically for Quake III based on the above.

Hans

Join Kea Campus' Amiga Corner and support Amiga content creation
https://keasigmadelta.com/ - see more of my work
Go to top
Re: Optimize SDL blitting routine
Just popping in
Just popping in


See User information
@Hans

I don´t know the implementation details of the SDL alpha blit function, but I would think that it blits rectangles.

AbbayeDesMortes uses the vertex mode of CompositeTags() (as I do in my several test programs *hint* ), that´s why I think that it isn´t very SDL-ish...

Go to top
Re: Optimize SDL blitting routine
Home away from home
Home away from home


See User information
@whose
Quote:
I don´t know the implementation details of the SDL alpha blit function, but I would think that it blits rectangles.

If SDL doesn't support 2D rotation & other transformations, then that should make implementing HW acceleration easier.

Quote:
AbbayeDesMortes uses the vertex mode of CompositeTags() (as I do in my several test programs *hint* ), that´s why I think that it isn´t very SDL-ish...

Not sure what you mean here. The one question that matters is if CompositeTags() can do what SDL's alpha blitting is supposed to do. So long as SDL doesn't use a premultiplied alpha, then I'd expect that the answer is: yes, it can.

Hans

Join Kea Campus' Amiga Corner and support Amiga content creation
https://keasigmadelta.com/ - see more of my work
Go to top
Re: Optimize SDL blitting routine
Not too shy to talk
Not too shy to talk


See User information
Hello

I agree "Abbaye des morts" currently dont use SDL at all
SDL calls in original sources have been replaced with AmigaOS equivalent for the Amiga port
So there is now a function for drawing rectangular "sprite" that works the same ways as SDL but use CompositeTags
>uses the vertex mode of CompositeTags()
Yes but that is not a problem as it used to draw a rectangular "sprite" but let you the freedom to rotate/resize it if needed (like CompositePoc)

Alain Thellier


Go to top
Re: Optimize SDL blitting routine
Quite a regular
Quite a regular


See User information
Here's a function where to look at, as well as the other functions present in the SDL_os4utils.c
/*
 * Find a suitable AmigaOS screenmode to use for an SDL
 * screen of the specified width, height, bits-per-pixel
 * and SDL flags.
 *
 * Actually we ignore the flags for now, but it may come
 * in handy later.
 */
uint32
os4video_FindMode
(uint32 widthuint32 heightuint32 bppuint32 flags)
{
    
/* Get a list of p96 formats for this bpp */
    
const RGBFTYPE *p96Format os4video_GetP96FormatsForBpp(bpp);

    
uint32 foundWidth 0;
    
uint32 foundHeight 0;
    
uint32 foundMode INVALID_ID;

    
/* Try each p96 format in the list */
    
while (*p96Format != RGBFB_NONE)
    {
        
/* And see if there is a mode of sufficient size for the p96 format */
        
foundMode findModeWithPixelFormat (widthheight, *p96Format, &foundWidth, &foundHeight);

        if (
foundMode != INVALID_ID)
        {
            
dprintf("Found mode %08lx with height:%d width:%d\n"foundModefoundWidthfoundHeight);

            return 
foundMode;
        }

        
/* Otherwise try the next format */
        
p96Format++;
    }

    return 
INVALID_ID;
}

Retired
Go to top
Re: Optimize SDL blitting routine
Just can't stay away
Just can't stay away


See User information
I am working with experimental SDL 1.2 library which uses compositing for alpha blits. It currently works in fullscreen only (with SDL_HWSURFACE). Colorkey emulation is planned via alpha channel.

Hans: SDL1 transparent blitting operations are per-pixel alpha, per-surface alpha and color key, and there is no scaling/rotation. SDL2 seems to be a different beast.

Go to top
Re: Optimize SDL blitting routine
Home away from home
Home away from home


See User information
@Hans

Quote:
If SDL doesn't support 2D rotation & other transformations, then that should make implementing HW acceleration easier.


I do not get the big deal, already support 2D rotation in my Allegro implementation, its pretty simple.

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: Optimize SDL blitting routine
Just can't stay away
Just can't stay away


See User information
@AmigaBlitter

One more thing: if both source surface and display surface are SDL_HWSURFACE (== BMF_DISPLAYABLE), SDL (opaque) blitting is HW accelerated. IIRC this is currently only possible in fullscreen.

Go to top
Re: Optimize SDL blitting routine
Quite a regular
Quite a regular


See User information
@Capehill

Thank you. Very interesting.

I was trying to do the same (not with the alpha part, btw).
Actually i was about to substitute all the old IP96 using the IGraphics part of the new SDK.

Btw, thank you.

Please tell me if i can help even with the tests



Retired
Go to top
Re: Optimize SDL blitting routine
Home away from home
Home away from home


See User information
@Capehill

I'm happy to read SDL is improving.

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: Optimize SDL blitting routine
Quite a regular
Quite a regular


See User information
@Capehill

Any news on your compositing implementation for SDL 1.2?

Thank you

Retired
Go to top
Re: Optimize SDL blitting routine
Just can't stay away
Just can't stay away


See User information
I have just moved house so unfortunately no progress during the last 2 weeks. Today I have unpacked my OS4 machines so experiment should continue.

Meanwhile, what kind of blitting project did you have? Alpha used? What are your source and destination surface specs?

Go to top
Re: Optimize SDL blitting routine
Quite a regular
Quite a regular


See User information
Hi,

sorry for the late reply.

It's a sort of of multiple sprite blitting and the usage of a particle system. Yes, alpha is used. Source and destination surfaces are SDL surface, 32 bit.

Retired
Go to top

  Register To Post
(1) 2 3 4 »

 




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




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project