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 / Large game = occasional missing images

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

I've only ever experienced this problem when making a particularly large game, but I just wanted to know if anyone else has run into it (or, better still, fixed it)

When making a particularly large game with a large number of images involved, sometimes when you run the program, everything will run fine, and other times (usually fairly rarely) the game will crash saying that it can't load a particular image. No code changes or anything like that. I have a feeling it might be a memory issue or something like that, as it only happens on games that are fairly system intensive.

From what I can tell, it only seems to happen with PNG files, but I could be wrong...

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: 14th Nov 2011 03:12
I'm not sure about multiple images but I tried to load a rather large .png map and it blurred it even though I loaded it with a transparency flag of 1... the image was 14,592 x 11,264.

CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 14th Nov 2011 03:48
All of mine are quite small. The largest of them is 1024x768...

Malevolence: The Sword of Ahkranox
www.msoa-game.com
www.facebook.com/malevolencegame
scythe_reaver
FPSC Reloaded TGC Backer
14
Years of Service
User Offline
Joined: 14th Nov 2011
Location:
Posted: 17th Nov 2011 04:10
@Cumquat
I have ran into this issue a couple of times. What seems to work for
Me is saving, closing, and re-opening. If the problem persists I find swapping
out the load, I.e if you used load image, use load bit map, and vice versa.
I hope this was useful to you in anyway.

http://www.shrinkpictures.com/processed/phprZ6E7O_c2AM.jpg
"I AM YOUR GOD OF DEATH"
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 17th Nov 2011 04:35
I've been having a very similar problem with a game I'm working on in Dark GDK. I code something, compile and run it. Keep doing that a few times and after a while the images don't show up and my objects are all white. I'm assuming that something is not being freed from memory on exit (ie video memory). When that happens I just restart and carry on.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 17th Nov 2011 05:25
Not very professional if you plan to release the game though... No ideas for a fix?

Malevolence: The Sword of Ahkranox
www.msoa-game.com
www.facebook.com/malevolencegame
Mychal B
15
Years of Service
User Offline
Joined: 21st Jul 2010
Location: Coos bay, rainville
Posted: 17th Nov 2011 07:08
Make sure you run through your own deletion process before exiting the program. I like to start from 0 and select a number way higher than what im using. I do this for each type of media I use



for i = 0 to 1000
if image(i) exist = 1 then delete image i
next i

The fastfood zombie killer
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 17th Nov 2011 22:31
I'm only loading at the moment 11 images, 2 objects. My clean up code has been checked, fixed, over and over and I still after a few compiles get white objects. I've even checked for memory leaks, fixed those. Maybe there's something the engines garbage collector just isn't picking up.

Still at the moment a restart and another hour or two programming before it happens again.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
revenant chaos
DBPro Master
19
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 18th Nov 2011 00:05
I have herd people say that it appears to do nothing, but have you guys tried flush video memory?
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 18th Nov 2011 00:26
Wow... I've recommended that too in the past to others and I can't believe I actually forgot to implement it myself.

Well, I'm going to see how it fares up to the keyboard battering and I'll report back whether or not it continues to happen for me.

( I'm in Dark GDK and using dbFlushVideoMemory() )

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 18th Nov 2011 01:35
@Mychal B - That has nothing to do with my post. I am talking about at load-time.

@revenant chaos - Yeah, I use Flush Video Memory and while it helps, it doesn't fix it totally. I think it'd work well for smaller games, but when you're dealing with as much media as I am, I think it just isn't enough...

Malevolence: The Sword of Ahkranox
www.msoa-game.com
www.facebook.com/malevolencegame
Stab in the Dark software
Valued Member
23
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 18th Nov 2011 05:56
We checked the DBPro source code today.

In Dbpro version 7.7 RC7 source code “Flush Video Memory” is labeled OBSOLETE.

There is no code in the function. Not sure what version it was removed in.

[img][/img]


WindowsXP SP3,Vista,Windows 7 SP1, DBpro v7.7RC7
Stab In The Dark Editor
The coffee is lovely dark and deep,and I have code to write before I sleep.
Mychal B
15
Years of Service
User Offline
Joined: 21st Jul 2010
Location: Coos bay, rainville
Posted: 19th Nov 2011 07:56
My mistake. I seen the title saying that there was missing images. Before I deleted objects myself Sometimes when I did a quick iteration it would tell me that the image already existed

The fastfood zombie killer
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 19th Nov 2011 12:31
Well, in my project so far I've added the dbFlushVideoMemory() (Dark GDK) but I've also re-kajigged a few other things. Over the last couple of days it seems to have done the trick. Whether it still works in GDK and not DBPro I don't know.

I suppose it's now just finding out from the 'powers that be' whether the version in DBPro has been omitted or there is an alternative way of flushing the video memory out. It certainly has improved my project.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 19th Nov 2011 13:50
As you start your program, try switching into and back out of full-screen exclusive mode:


basjak
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 19th Nov 2011 15:51 Edited at: 4th Dec 2011 16:30
I think it's related to the computer memory size.

@IanM: does switching refresh the memory? I notice now this switching when playing big games.
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 20th Nov 2011 01:43
After doing a little research on the problem on google, instead of restarting I run DxDiag from the command line, quit and then carry on. That solves the need to restart all the time. The last two days I've been just running mine in windowed mode and it still does it but not as often with the flush in it. Everything goes white after a while. DxDiag fixes it, so I'm gonna google a little bit more to find out what it does to clear it out.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Stab in the Dark software
Valued Member
23
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 20th Nov 2011 03:16
WLGfx,
dbFlushVideoMemory() function calls the DBPro function “Flush Video Memory”

Whether you are using the GDK or DBPro the Flush Video Memory does absolutely nothing. IanM can confirm this he has worked in the DBPro source.

[img][/img]


WindowsXP SP3,Vista,Windows 7 SP1, DBpro v7.7RC7
Stab In The Dark Editor
The coffee is lovely dark and deep,and I have code to write before I sleep.
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 20th Nov 2011 07:28
Wouldn't switching in and out of window mode remove all of my loaded images?

I think people are either not reading or misinterpreting my original post. My game will run fine some times and come up as not being able to load an image other times using the LOAD IMAGE command.

In short, code like this:



Will work some times but not others, when no change has been made to the external file. It always works in a program this simple, of course, but I'm talking about in LARGE games where there are many images loaded at the same time. And it seems to be exclusively with PNGs.

Malevolence: The Sword of Ahkranox
www.msoa-game.com
www.facebook.com/malevolencegame
miso
16
Years of Service
User Offline
Joined: 16th Jun 2010
Location: Budapest, Hungary, 127.0.0.1
Posted: 20th Nov 2011 11:00
I dont know what causes this, but I have a related question. Do you load all the images with the load image command, or are there some that is auto loaded with object loading? ( I mean do you load pretextured models sometimes? )

No place like 127.0.0.1 .
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 11:59
It could be a simple coding error. If you change directories and/or calculate image IDs, etc, in different ways depending on what happens in your game then things might have got muddled up there. That won't apply if everything is hardcoded - except possibly the directory thing.
Morcilla
23
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 20th Nov 2011 12:01 Edited at: 20th Nov 2011 12:03
Quote: "...but I'm talking about in LARGE games where there are many images loaded at the same time."

Well, what size exactly are we talking about? In your second post you say:
Quote: "All of mine are quite small. The largest of them is 1024x768..."

So I don't understand. I load a bunch of 4096x4096 images in my project, and it is true that sometimes they do not load because of the size, depending on the hardware.

Although this doesn't happen to me during the initial loading, but afterwards, when the images have been loaded and unloaded several times, like if the video ram memory got fragmented, and the large texture didn't fit.

There are several workarounds to cover this:

- Load without mipmaps. This will greatly reduce the amount of memory being used, and textures will load faster. Just set to '1' the 'texture flag' of LOAD IMAGE:



- Ask for IMAGE EXIST after loading. If the image didn't fit into memory, IMAGE EXIST will return 0. Then you can take the appropiate actions so that your sprite/object doesn't appear white.

For example, you can try to load a lower resolution texture, if you have one prepared within your media.

But you can also use the third parameter of LOAD IMAGE, that is 'Divide Texture Size'. A value greater than zero will divide the size of the texture to reduce the memory required to hold the texture in memory.
This allows to reduce texture size at run time, so you can re-try to load the image until it fits into memory. This will load the largest texture allowed by the hardware.
Maybe not the best solution, but your software won't look that 'unprofessional'.

Quote: "And it seems to be exclusively with PNGs."

Do you use other formats that verify this info? I think it will happen regardless of the file format.

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 20th Nov 2011 13:16 Edited at: 20th Nov 2011 13:17
Quote: "Wouldn't switching in and out of window mode remove all of my loaded images?"

Yes, which is why I said 'As you start your program...'.

Quote: "does switching refresh the memory?"

Whenever DirectX suffers a switch of display mode (whether triggered by yourself or by the OS), all graphics memory is freed. It's then up to your program to reallocate this memory and repopulate the data - with DBPro this is quite difficult to do efficiently, but it can actually be done.

Deliberately doing this as your program starts will cause all other programs to free their memory, and all leaked memory to also be freed.

Code for FLUSH VIDEO MEMORY


Quote: "I think it will happen regardless of the file format."

Me too - there's no difference in memory between images loaded in PNG format or any other format.

CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 20th Nov 2011 15:08
@IanM - I gave that a try and it definitely makes the game run a bit smoother, but the alpha/brightness REALLY drops when compared to running the game without that code. Everything is super dark and can't be brightened to anywhere close to where it was. It also drops the quality of the screen to something quite bad. Image quality drops massively, even though the screen is set to run at 32bit.

@Morcilla - The game itself is large (about 28k lines of code) but the images are small.

@Green Gandalf - No directory switching happens in the program. It's all referenced in folders such as
but that was the first thing i checked! When the program hits an error saying it can't load an image, it's on a line that normally works but it's never the same line. It seems to hit randomly. And only with PNGs...

Malevolence: The Sword of Ahkranox
www.msoa-game.com
www.facebook.com/malevolencegame
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 20th Nov 2011 16:16 Edited at: 20th Nov 2011 16:27
@CumQuaT - I'm also still having the same problem although not as often. After a few runs, which run perfectly, my program will suddenly either not load the images or textures and the models just go white. I've also come across another which is although the LoopGDK() is active, the program appears to run but nothing is displayed on the screen. And still the only way around this instead of restarting is to run DxDiag and then exit it and then re-run my program.

All my media is in the correct locations, that's proven by the perfect runs before it goes dodgy. I've gone over and over each day for memory leaks and checking that all the images and objects are being free'd when necessary. I've had it tested in both full screen exclusive, full screen windowed and just windowed with the same results.

All my images are PNG's for transparency so I might just try another format and see what happens. My code at the moment just assumes the images load correctly without any checks which I will change later but when it happens, it happens to all the images. And I know at the moment I'm definitely not bloating out the video memory with textures and vertex buffers, etc.

When it happens to you what do you have to do to get back to normal?

I do this:

1. Go to the Command prompt and type dxdiag
2. Go to the Display tab and click the test direct3d.
3. Skip tests that do dx7 and dx8 but run dx9.
4. Quit and carry on

EDIT: There seems to be no usable alternative for PNG's with transparency and apart from using DxDiag at the moment I can't as yet find an alternative way of flushing the DX video memory.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 20th Nov 2011 18:14
Quote: "There seems to be no usable alternative for PNG's with transparency"

dds files are directx native file formats with transparency.

My signature is NOT a moderator plaything! Stop changing it!
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 20th Nov 2011 18:35
@Mobiius - Thankyou. I will definitely test that out and see how it goes. (I missed that bit)

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 20th Nov 2011 18:56
No worries.

My signature is NOT a moderator plaything! Stop changing it!
Hockeykid
DBPro Tool Maker
18
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 20th Nov 2011 19:05 Edited at: 20th Nov 2011 19:06
Maybe you're hitting the 2GB virtual memory cap for 32Bit programs. The function below will allow you to print out the amount of MB used:



CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 21st Nov 2011 05:58
I had thought of that, hockeykid, but I'm only ever capping out at around 640MB at the absolute worst.

Malevolence: The Sword of Ahkranox
www.msoa-game.com
www.facebook.com/malevolencegame
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 27th Nov 2011 03:15
Well, earlier today I converted all my media to .DDS files and so far I've had no problems with white textures (not being loaded or being dumped on me during runtime). No need to run DXDIAG to flush the video memory or a rare need to restart my laptop.

GDK and DBP might have an internal issue with PNG files from what I can tell from this. I've had my laptop on all day without any glitches.

From now on I'll try and avoid PNG files in GDK and use DDS instead. The only issue I have with DDS is they don't save out as compressed but I'm sure there's something out there that will do that.

I understand that it may even be a driver issue or something else, but still if it does on this (ATI Radeon Xpress 200M) then it will happen on other machines too. Better safe than sorry to fix the issue now. I don't want people in the future saying that's what is happening.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Morcilla
23
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 27th Nov 2011 12:12 Edited at: 27th Nov 2011 12:13
To those who have this kind of problems, I would like to ask:

- Operating system, Windows XP or 7?
- Video card manufacturer, Nvidia, Ati or Intel?
- Video card RAM amount (vram)?
- System memory amount (ram)?

With image sizes up to 4096x4096, here I have:

- Windows XP + Ati Radeon + 512Mb vram + 2Gb System Memory = Occasional missing images.
- Windows 7 + Intel HD + 1Gb shared vram + 8Gb System Memory = Frequent missing images.

With Windows XP there are occasional missing images, but the game keeps on running. With Windows 7, the programs crashes, and it happens more frequently.

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 27th Nov 2011 15:56
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 27th Nov 2011 16:17
HP-Pavilion Turion64, Windows XP SP3 (32-bit), ATI Radeon Xpress 200M (256Mb shared), 1Gb Memory. Max image size used is 1024 x 1024.

Nope, I'm still getting the white textures appearing. I can compile and run my program about 10 times now before it either starts to kick out textures or it runs without any textures at all. And that's with everything as DDS now.

One part of my program in particular which generates a texture should create a bitmap in the background and draw to that. When the glitch occurs, the bitmap isn't generated and it will draw to the main window instead.

I haven't added anything as of yet to test it with mip map generation and will try that out today to see if they are the issue. Something is filling up the video memory and not being cleared out and it now appears not to be PNG related only.

@Chris Tate - I remember seeing that sometime ago but forgot about it when I was manually converting my media. I've got it now. Thanks

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Morcilla
23
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 4th Dec 2011 11:07
Hmmm I have to do further testings as well.
I'd be glad if I could forecast this issue at the start of the program. That way I could reduce texture size for loading.
I bet maximum texture size is returning 8192x8192 everywhere, but large textures still crash on some systems
As you said, perhaps it is just 'too many textures', but still this depends on the hardware, so how to detect this situation?

Morcilla
23
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 5th Dec 2011 11:34
I keep on having blank images. I use the workaround described above, in my first post of this thread, but the fact here is that
IMAGE EXIST
sometimes returns '1' and the object is untextured, so maybe the image exist, but it had a bad loading.

Although it is hard to prove, I'm going to report this to the bug section for DGDK.
If you add IMAGE EXIST after loading textures for your DBPro project, and you see white objects, then I would open the bug report for DBPro as well.

Please test IMAGE EXIST and let us know how it goes.
Or has this been already reported?

Morcilla
23
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 11th Dec 2011 10:56
I thought you'd like to know that I workarounded 'image exist' using 'make memblock from image'.
Although 'image exist' can return '1', if the image doesn't really exist, 'make memblock from image' will not succeed.
This way I can check if an image exist after loading and if it doesn't, then try to load a lower resolution sample.

CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 11th Dec 2011 11:01
Good to know!

Malevolence: The Sword of Ahkranox
www.msoa-game.com
www.facebook.com/malevolencegame
Jimpo
21
Years of Service
User Offline
Joined: 9th Apr 2005
Location:
Posted: 12th Dec 2011 16:41
I want to add that I've never encountered this problem, and one of my recent games had over a thousand png images. But most images were loaded and deleted as needed, so all of them weren't loaded into memory at once. So you might be hitting some sort of memory limit, or maybe there is just a strange bug somewhere in your code.

Randomness 128
19
Years of Service
User Offline
Joined: 13th Feb 2007
Location:
Posted: 12th Dec 2011 18:50
If you use compression with DDS files, the texture will remain compressed in video memory. They'll only use 25% (with alpha channels) or 16.7% (without alpha channels) of the memory an uncompressed texture will.
Morcilla
23
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 17th Dec 2011 17:29
Interesting, I din't know that. The problem about that is that .DDS files are very big in file size, right?
And it would make the final download size just too huge in some cases (already 335Mb here), but I'll think about it in the future.

Randomness 128
19
Years of Service
User Offline
Joined: 13th Feb 2007
Location:
Posted: 17th Dec 2011 18:51
Uncompressed DDS files certainly are large, but using compression has the same benefit for the file size. I'd suggest saving some of your images as compressed DDS files and see what happens. There's a good chance they'll be smaller that way.
Morcilla
23
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 18th Dec 2011 10:48
Yes, thanks for the additional tip.
Although compressed, .DDS are still much larger than a .jpg without compression, because they are storing the mipmap levels, and the .jpg isn't.
At least last time I tried.
However I'll keep what you say in mind, maybe it is the key to store huge textures in video ram.

WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 18th Dec 2011 23:31
Yeah, I've started using compressed .dds images too (without mipmaps, mostly not necessary) if I'm not manipulating them manually.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 19th Dec 2011 00:46
Handy to know...

Malevolence: The Sword of Ahkranox
www.msoa-game.com
www.facebook.com/malevolencegame
Dar13
18
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 19th Dec 2011 02:18
Quote: "Although compressed, .DDS are still much larger than a .jpg without compression, because they are storing the mipmap levels, and the .jpg isn't.
At least last time I tried."

Most DDS exporters, like GIMP's and Photoshop's, give the option to store the mipmaps. For DBPro, they're really not needed to be pregenerated, as DBPro will create mipmaps when the DDS files are loaded.

Using the Photoshop DDS exporter, I was able to get the DDS of a 1024x768 JPG to be within 150 KB of the JPG (385 KB vs. 265 KB).
I used the DXT1 compression setting(no alpha saved), so if you want alpha you'll have to deal with higher file sizes.

Agent
21
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 22nd Dec 2011 14:20
I have nothing to add to the solution of the original problem beyond what others have contributed, but I can report my own circumstances in case it assists with tracking.

Solodor loads almost nine thousand images (some PNGs, some JPGs, but mostly BMPs). They are all loaded at boot, with no load-on-demand functionality as yet. I've never had any problems with images failing to exist that weren't my own fault due to an error in code.

The only downside I have to such a high number of assets loaded is a noticable slowdown in DBPro's IMAGE EXIST() function. The more assets that have been loaded into memory, the longer IMAGE EXIST() takes to return a result.

Other than that, I've not experienced the problem described in the original post. Not sure if this is helpful information, but at least it tells you that it's probably not a direct issue with the *number* of assets loaded. It could still be related to memory (my images are very small, <300MB in total for all nine thousand of them) and it could be something external to your program, like video card or DirectX corruption. Try your program on another machine with a different video card, or try reinstalling DirectX9.0c and your video drivers, just to be thorough in eliminating those possibilities.

Other than this, I can only suggest that there's a logic error in your code, trying to reference objects that don't exist. I recommend that you set up a file-logging system: Every time you reference an object, check that it exists first. If it doesn't, dump a line of output to a log file. The only thing you need to output to this file is the image number that you expected to exist, but didn't. If there's ever anything in this file, you can cross-check your image numbers to make sure that you're not *accidentally* referencing image numbers that don't exist. The contents of your arrays that refer to image numbers may be at fault, causing incorrect references to invalid images. If you see strange numbers in your log file like negative numbers or anything over 65000 you can blame your variable contents. You can check that every image number that does appear in your log file has actually been loaded by your asset-load functions.

Logfiles are awesome bugtracking tools. Just create a function that looks like this (I'm writing this code on the fly, but you'll get the idea):

FUNCTION PasteImage(ImageNum, X, Y, T)
IF IMAGE EXIST(ImageNum)
PASTE IMAGE ImageNum, X, Y, T
ELSE
WriteLogFile("Illegal reference to Image Number " + str$(ImageNum) + "!")
ENDIF
ENDFUNCTION

You'll have to code your own WriteLogFile() function, but I'm assuming you know how to do that.

I think this will be an effective tool to aid your debugging of issues like this.

Agent
21
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 22nd Dec 2011 14:28 Edited at: 22nd Dec 2011 14:32
Another thought: I created a function for use in Solodor when dealing with a logic error in my code that started referencing images that don't exist. I used the logfile method I talked about in my last post, together with the following function:



This function gives me a list of all image numbers that are currently loaded and ready to be deployed by image manipulation commands like PASTE IMAGE or SPRITE.

Add a console command or keystroke trigger to your mainloop or input polling function that will execute this code. Trigger it during your game when all of your assets are loaded so that you get a complete dump of all images that are loaded, so you can be 100% sure that they are accessible.

One way to use this output file would be to check that any image numbers that appear in your logfile also appear in your image number dump file. If there's a discrepancy, you know you haven't loaded the asset in question.

Another way to use this image number dump file would be to generate one, close and reopen your game, and dump another one. You could do this ten times and see if the all the dump files match. If there's any discrepancy, that would be a useful bugtracking discovery.

Finally, you'll want to check that every image you're loading in your asset-load function has a corresponding entry in the dump file. If any LOAD IMAGE commands in your code don't have a matching entry in the dump file, you'll know that the load is failing somehow, or the asset is being cleared after it's been loaded for some reason.

If you have a very high number of images like I do, write a new project specifically to run through both the logfile and dumpfile and output a third and final report of any discrepancies, handing you a To-Do list on a silver platter.

I discovered a couple of logic errors in my code using these methods. Perhaps you can come up with something this way.

Morcilla
23
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 22nd Jan 2012 18:21
Ok, problems are solved. DDS image format is the key.
No more blank images, no more crashes so far in any operating system or hardware combination.

I changed most of the largest images from .jpg with loseless compression to .dds in DXT1 format.
It seems that the memory now is able to reallocate the images with much more stability.
DXT1 has more or less the same size of a .jpg, depending on the image. However it looks a little bit worst.
I haven't been able to use DXT1 for normal maps, as the result is ruined.
Also, DXT1 images look remarkably 'greenish' if compared to the original, probably because if the compression algorithm.
So, they have a price, but on the other side now the loading is faster, and the execution is more stable. It also performs a slightly faster than before.

Probably I'll end with a mix of DXT1 and .jpg images. I still find .dds uncompressed files too large in disk (they could be more than 1Gb here).

Nevertheless, stable execution was the goal. Done
Thanks for the tips!

Login to post a reply

Server time is: 2026-07-10 10:21:00
Your offset time is: 2026-07-10 10:21:00