Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Paste sprite slowing game down

Author
Message
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 20th Nov 2011 01:11
Hi all,

I use PASTE SPRITE quite a bit during my housekeeping routine to keep the UI of my 3D game in place, but every so often, certain sprites (particularly transparent ones) make the game lag MASSIVELY when I try to paste them. I'm not entirely certain but I think it's only when using PNGs. Anyone else run into this?

Malevolence: The Sword of Ahkranox
www.msoa-game.com
www.facebook.com/malevolencegame
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 20th Nov 2011 01:54
You might try Sven B's Image Kit. It'll allow you to paste directly to one image so you only have to use a single native Darkbasic PASTE IMAGE command to update your UI.

http://forum.thegamecreators.com/?m=forum_view&t=176270&b=8&p=0#m2100619

CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 20th Nov 2011 01:59
Oooooooh, that sounds cool. Would require a bit of a re-write but that's awesome! Thank you!

Malevolence: The Sword of Ahkranox
www.msoa-game.com
www.facebook.com/malevolencegame
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 20th Nov 2011 13:01
Textures are usually the most memory-hungry part of your game - it could simply be that you've run low on graphics memory and that the textures are being transferred to and from main memory.

If you are in that situation, then making one big image to solve the problem may actually make it worse.

Also, once a texture is loaded, there is no 'PNG' format in memory. In fact there is no difference between the loaded textures at all.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 20th Nov 2011 13:23
Quote: "In fact there is no difference between the loaded textures at all."


Is that true? I thought DirectX was able to store image data in a variety of formats and it seems possible to me that DBPro might not load all images into the same internal format. For example, aren't DDS images loaded directly into the corresponding DirectX surface format?

For example, from the DX9 SDK docs:

Quote: "D3DFORMAT
Defines the various types of surface formats.

Syntax
typedef enum _D3DFORMAT {
... (values)
} D3DFORMAT;

There are several types of formats:

BackBuffer or Display Formats
Buffer Formats
DXTn Compressed Texture Formats
Floating-Point Formats
FOURCC Formats
IEEE Formats
Mixed Formats
Signed Formats
Unsigned Formats
Other
Constant Information
All formats are listed from left to right, most-significant bit to least-significant bit. For example, D3DFORMAT_ARGB is ordered from the most-significant bit channel A (alpha), to the least-significant bit channel B (blue). When traversing surface data, the data is stored in memory from least-significant bit to most-significant bit, which means that the channel order in memory is from least-significant bit (blue) to most-significant bit (alpha).

The default value for formats that contain undefined channels (G16R16, A8, and so on) is 1. The only exception is the A8 format, which is initialized to 000 for the three color channels.

The order of the bits is from the most significant byte first, so D3DFMT_A8L8 indicates that the high byte of this 2-byte format is alpha. D3DFMT_D16 indicates a 16-bit integer value and an application-lockable surface.

Pixel formats have been chosen to enable the expression of hardware-vendor-defined extension formats, as well as to include the well-established FOURCC method. The set of formats understood by the Direct3D runtime is defined by D3DFORMAT.

Note that formats are supplied by independent hardware vendors (IHVs) and many FOURCC codes are not listed. The formats in this enumeration are unique in that they are sanctioned by the runtime, meaning that the reference rasterizer will operate on all these types. IHV-supplied formats will be supported by the individual IHVs on a card-by-card basis.
"


Or have I misunderstood something?
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 20th Nov 2011 13:54 Edited at: 20th Nov 2011 13:55
I was being simplistic to avoid confusion ... whoops.

Except for the underlying source image quality, if you load a 24 bit PNG or a 24 bit BMP or a 24 bit JPEG then there is no difference in memory usage.

Actually, that has raised a point - compressed textures. Are they decompressed immediately, or are they decompressed on demand? If they are decompressed on demand then this may fix the out-of-memory condition of graphics memory temporarily (if it is indeed the cause of the problem).

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 20th Nov 2011 14:16
Since the DDS formats are native DX formats perhaps they do not need to be decompressed at all? Your question probably relates to PNG, JPG and other compressed non-native DX formats though.

I would expect DBPro to convert everything except DDS files to a native format when images are loaded with something like A8R8G8B8 or X8R8G8B8 being the default. I guess the only way to find out is to inspect the DBPro source itself and see which DX functions/arguments are used. Where can I find the source by the way? I keep forgetting.
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 20th Nov 2011 15:10
When you say Textures, do you mean the textures of the sprites? Or is it a misunderstanding of my orginal question? My textures are working fine. It's just sprites with transparency that cause the issue...

Malevolence: The Sword of Ahkranox
www.msoa-game.com
www.facebook.com/malevolencegame
Jambo B
16
Years of Service
User Offline
Joined: 17th Sep 2009
Location: The Pit
Posted: 20th Nov 2011 15:45
Would loading without mipmaps slow the game down?
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 20th Nov 2011 19:25
Quote: "When you say Textures, do you mean the textures of the sprites?"


I guess so since that's what we're discussing.

Quote: "My textures are working fine. It's just sprites with transparency that cause the issue..."


But they need textures for that, surely? What happens if you use a DDS version of the PNG images? I use DDS files when I need transparency since they are easy to create and haven't noticed any problems. But then I haven't used them in large projects.
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 21st Nov 2011 05:59
I might end up giving that a try. I didn't know that DDS files could be used for sprites.

Sorry for the confusion. I'm not used to referencing sprite images as textures. You can have a model without an image, but you can't have a sprite without an image, so I just refer to them as Sprites ;-P

But I'll definitely give the DDS files a shot and see if that makes a difference. Thanks for the tip!

Malevolence: The Sword of Ahkranox
www.msoa-game.com
www.facebook.com/malevolencegame

Login to post a reply

Server time is: 2026-07-11 06:13:50
Your offset time is: 2026-07-11 06:13:50