|
DirectX VRAM-VRAM accelerated stretch blit |
A J
Member #3,025
December 2002
|
The most useful feature i want from Allegro is VRAM to VRAM accelerated stretch blit. I dont think the current DirectX driver has this feature as its using dx3. What versions of DirectX contain this feature ? if this is not likely to occur any time soon, does anyone know of other allegro-like libs that can do it ? ___________________________ |
HoHo
Member #4,534
April 2004
|
Quote: When would allegro get this DirectX version ? when someone implements it. I personally think there is little point in improving current drivers. The main energy should go into developing a decent OpenGL driver. With that it would be possible to accelerate almost anything and it would be portable. __________ |
Evert
Member #794
November 2000
|
As HoHo said, it'll be there when someone writes the code. I'm sure you're aware of the number of active Windows developers we have right now, so if you care to implement it that would be welcome. Regarding OpenGL to do this, it's possible that AllegroGL already implements this functionality. I don't know for sure that it does, but it would be possible for it to support it. If it doesn't, I'm sure some help there is also appreciated. |
Richard Phipps
Member #1,632
November 2001
|
AJ: If you use OpenLayer you can effectively do this already (and with blending, roatation, etc..) |
Elias
Member #358
May 2000
|
Quote: What versions of DirectX contain this feature ? No DirectDraw version has this, so upgrading Allegro's code to DirectDraw 7 would have no effect. The only way would be to replace the "DirectDraw" interface based driver by a "Direct3D" interface based one, which is the equivalent of OpenGL. Probably it would make most sense to use DX9. But it means, a complete driver rewrite is necessary. (Someone started such a driver once I think.. not sure what happened to it.) -- |
Dennis
Member #1,090
July 2003
|
The problem with DX9 is, we would lose "ddraw.h", because the last directX version supporting standard 2D interfaces is DirectX8. DX9 is 3D interfaces only and that would require to emulate 2D through 3D interfaces. Another point for not using DX9 would be that there are a lot of video cards out there, who simply can not run DX9 games in hardware, so there would be a need for fallback drivers to DX8 and DX7 to support the most common video cards in use. (Otherwise those unsupported cards would use DX9 software interfaces, which would slow everything down and not utilize the acceleration potential of those cards.) Sounds all nice and easy in theory. In practice that means a huge workload and i don't know if that's worth the trouble in the current Allegro version(which sources are horrible). Goes without saying that, if i knew HOW to do all of the above, i would long have started to implement it, but since i don't know anything about Direct3D and don't have the time to learn it, i have not.;D --- 0xDB | @dennisbusch_de --- |
HoHo
Member #4,534
April 2004
|
Quote: The problem with DX9 is, ... Or in other words, doing the same with OpenGL would be much simplier and would work cross-platform everywhere __________ |
Thomas Harte
Member #33
April 2000
|
Quote: No DirectDraw version has this With all due respect, every version of DirectDraw has this. It's the reason IDirectDrawSurface::Blt has a source RECT and a dest RECT. Microsoft aren't in the habit of keeping around old documentation, but I can still find IDirectDrawSurface5::Blt in MSDN and note particularly from the comments (emphasis added): MSDN said: This method is capable of synchronous or asynchronous blits (the default behavior), either display memory to display memory, display memory to system memory, system memory to display memory, or system memory to system memory. The blits can be performed by using source color keys, and destination color keys. Arbitrary stretching or shrinking will be performed if the source and destination rectangles are not the same size. I can't find an MSDN source for it, but I can assert that this method was not changed as DirectDraw advanced. The ability to scale is what differentiates Blt from BltFast. Of course DirectDraw is able to use either of its blit functions for the equivalent of Allegro _blit and _sprite functionality. To implement an accelerated stretch on Windows should be as simple as duplicating the hardware non-scaled blitter, changing the (hopefully) BltFast to a Blt and independently building a destination rectangle. It should be a quick enough modification. Although I don't have a suitable build chain, I'll go glance at the source. EDIT: Having found the non-accelerated version (src/win/wddaccel.c, line 88 onwards), what is the purpose of this clause at line 139: else { /* have to use the original software version */ _orig_masked_blit(source, dest, source_x, source_y, dest_x, dest_y, width, height); } } I cannot imagine that the Allegro developers think they have implemented a faster software blit than that provided by DirectDraw? Perhaps it is to mask Allegro's continuing deficiencies with locking and unlocking? EDIT2:
Plus something analogous to ddraw_draw_sprite to map from stretch_sprite to masked_stretch_blit, and the flagging of this as an available accelerated routine at wherever that should be done (which I haven't quite found yet...) EDIT3:
[My site] [Tetrominoes] |
Elias
Member #358
May 2000
|
Quote: To implement an accelerated stretch on Windows should be as simple as duplicating the hardware non-scaled blitter, changing the (hopefully) BltFast to a Blt and independently building a destination rectangle. It should be a quick enough modification. Although I don't have a suitable build chain, I'll go glance at the source. Oh, very nice, I didn't know that. Quote: I cannot imagine that the Allegro developers think they have implemented a faster software blit than that provided by DirectDraw? That's simply the case for memory bitmaps.. there is no DX function (well, again, to my knowledge) to blit a memory rectangle to a DX surface. -- |
Thomas Harte
Member #33
April 2000
|
Quote: That's simply the case for memory bitmaps.. Oh, Allegro is maintaining it's own internal format for memory bitmaps? I'm curious - why would does it not just use DirectDraw memory surfaces? [My site] [Tetrominoes] |
GullRaDriel
Member #3,861
September 2003
|
Quote: Oh, Allegro is maintaining it's own internal format for memory bitmaps? I'm curious - why would does it not just use DirectDraw memory surfaces? CrossPlatform Issues ? "Code is like shit - it only smells if it is not yours" |
Thomas Harte
Member #33
April 2000
|
Quote: CrossPlatform Issues ? I can't see how, if Allegro is flexible enough to be able to handle DirectDraw surfaces as BITMAPS where they are system/video resident, it could not handle DirectDraw surfaces as memory BITMAPS. EDIT: if ((ddcaps.dwCaps & DDCAPS_COLORKEY) && (ddcaps.dwCKeyCaps & DDCKEYCAPS_SRCBLT)) { _screen_vtable.masked_blit = ddraw_masked_blit; _screen_vtable.draw_sprite = ddraw_draw_sprite; if (_screen_vtable.color_depth == 8) _screen_vtable.draw_256_sprite = ddraw_draw_sprite; gfx_capabilities |= (GFX_HW_VRAM_BLIT_MASKED | GFX_HW_SYS_TO_VRAM_BLIT_MASKED); } To: if ((ddcaps.dwCaps & DDCAPS_COLORKEY) && (ddcaps.dwCKeyCaps & DDCKEYCAPS_SRCBLT)) { _screen_vtable.masked_blit = ddraw_masked_blit; _screen_vtable.draw_sprite = ddraw_draw_sprite; /* new entry */ _screen_vtable.masked_stretch_blit = ddraw_masked_stretch_blit if (_screen_vtable.color_depth == 8) _screen_vtable.draw_256_sprite = ddraw_draw_sprite; gfx_capabilities |= (GFX_HW_VRAM_BLIT_MASKED | GFX_HW_SYS_TO_VRAM_BLIT_MASKED); } Does anybody have a Windows/GCC toolchain to try some of this stuff out? [My site] [Tetrominoes] |
Elias
Member #358
May 2000
|
Probably the original idea was to avoid overhead in the case where you do lots of direct manipulations on the memory bitmap. I think in the new API, we won't have the separation into "memory", "system" and "video" bitmaps.. it will all be managed internally. Probably with the possibility to set some extra flag if you want to override the default behavior. [Edit:] And in my understanding, you get DX memory bitmaps as "system" bitmaps currently. -- |
GullRaDriel
Member #3,861
September 2003
|
i'm trying it ... "Code is like shit - it only smells if it is not yours" |
A J
Member #3,025
December 2002
|
GullRaDriel, have any luck ? ___________________________ |
GullRaDriel
Member #3,861
September 2003
|
ddraw_masked_stretch_blit isn't declared. Quote:
C:\PROG\LIBRARY_IDE\Allegro\Copy of allegro>make src/win/wddaccel.c:470: error: for each function it appears in.)
i'm trying to use the Thomas's ddraw_masked_strech_blit. EDIT: currently compiling... with no warning or error, i follow the AL_FUNC(...) and other allegro's specific way of implementing. "Code is like shit - it only smells if it is not yours" |
Evert
Member #794
November 2000
|
Quote: I haven't found the definition of _screen_vtable yet
It's just a global variable of type GFX_VTABLE. The element you'll want to change is |
GullRaDriel
Member #3,861
September 2003
|
I'm leaving work but will try to to this when at home. "Code is like shit - it only smells if it is not yours" |
Thomas Harte
Member #33
April 2000
|
Quote: ... masked is a flag (true or false) that determines wether or not to do a masked blit or a normal blit. Well in that case the code above won't work properly, but it should be easy to make something that does. This Sunday I'll try and get a working Windows/GCC install so that I can look into that + the clipping topics Neil Walker raised in the other thread. It seems that time I spent learning Windows/DirectDraw will not have been wasted. [My site] [Tetrominoes] |
GullRaDriel
Member #3,861
September 2003
|
i'm back "Code is like shit - it only smells if it is not yours" |
Richard Phipps
Member #1,632
November 2001
|
GullRaDriel
Member #3,861
September 2003
|
i'm currently here: Quote:
C:\PROG\LIBRARY_IDE\Allegro\Copy of allegro>make any idea? PS: if a someone is good at allegro-updating, i can provide a 'fast' vnc connection for him. Also a ftp. PM me ! "Code is like shit - it only smells if it is not yours" |
Evert
Member #794
November 2000
|
Quote: any idea? See my above post. |
Thomas Harte
Member #33
April 2000
|
Dump ddraw_masked_stretch_blit as suggested above and try the following:
And then bin: [My site] [Tetrominoes] |
Evert
Member #794
November 2000
|
Quote: Note that this should only accelerate stretch_blit and masked_stretch_blit (or wherever masked is added to make that an Allegro function) - if it works then a simple thing to convert accelerated stretch_sprites to stretch_blits can be added.
Actually, stretch_blit, masked_stretch_blit and stretch_sprite all call the same do_stretch_blit(), which is actually called that in the asm version of the code; it's the infamous self-modifying code in Allegro; it's called _al_stretch_blit in the C version of the code. Neither function is exposed through the API and they're static to their respective sourcefiles (allegro/src/i386/istretch.c and allegro/src/c/cstretch.c). Pretty confusing, isn't it? /* vtable hook */ if (source->vtable->do_stretch_blit) { source->vtable->do_stretch_blit(source, dest, source_x, source_y, source_width, source_height, dest_x, dest_y, dest_width, dest_height, masked); return; } So bottom line: they should all work. EDIT: do we need a GFX_HW_STRETCH_BLIT flag for gfx_capabilities now? |
|
|