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.

Dark GDK / MultiThreading - Exception

Author
Message
Red Eye
16
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 1st Aug 2011 13:28
Hello,

I have been working on getting multithreading to work.

I have a function which does NOT contain DARKGDK related functions.
It compiles, and runs for a couple of seconds (around 5 secs) than gives me an exception:



...and then points to something totally irrelevant in the code, but in the Call Stack tab he shows something (interesting?):



This is the code to create thread:


This is the code to close Thread:


This is the function name:



This is the function code:


Note: Nothing related to that code is using DARKGDK commands.

If you need any more code, I would be happy to email it to you.

Can it be it is out of Memory?

Cheers,

Leo

Red Eye
16
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 1st Aug 2011 14:52 Edited at: 1st Aug 2011 14:55
My mistake, I use dbGetViewMatrix and dbGetProjectionMatrix to convert worldspace to viewspace (3d coordinate to 2d coordinate).



EDIT: I am on a laptop, and it aint very strong, so maybe it is out of memory. Is that even possible for such a thing?

Another EDIT: I will start cutting down my code to see where to problem lies hidden.

Red Eye
16
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 1st Aug 2011 14:59 Edited at: 1st Aug 2011 15:00
Yup i found my problem, It was the D3DXVECTOR2 ConvertWorldSpaceToViewSpace(int Camera,float x,float y,float z) function.

I will try to store the projection matrix and view matrix somewhere else outside the thread, and get it when needed. Will post my progress on getting this to work.

Red Eye
16
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 1st Aug 2011 15:07
It now works but gives me exception when closing thread or at end of the program. Here is a screenshot:



But as this may be just a stupid thing of me, i will try and hunt it down. And after that clean up my code because it is messy i know.

Cheers,

Leo

Mistrel
Retired Moderator
19
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 1st Aug 2011 18:32 Edited at: 1st Aug 2011 18:48
I'm assuming you already know this but DarkGDK is not thread safe.

You can still use threads, but you'll have to use synchronization if you don't want to crash.

http://msdn.microsoft.com/en-us/library/ms686360(v=vs.85).aspx

If it's crashing at the end of the program then your stack is getting corrupt somewhere. This will be extremely difficult to track down later on so make absolutely sure you fix this!

If you do a add an additional "bool update" parameter, you can add synchronization but store the matrix data statically until update is called. Then you wouldn't have any additional overhead for subsequent calls.

Red Eye
16
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 1st Aug 2011 19:11
I got the crash at the end solved, the handle of the thread wasnt closed after the program itself was cleaned, so it was grabbing in the dark, which caused memory access violation. - Fixed

I am now working on getting the thread to do its job when the main thread says it may so. - Refers to your "bool update".

Also I needed the projection matrix and view matrix in other part of my engine, so in my EnginCore Class-Update Function i store them to use them further on in my engine.

Login to post a reply

Server time is: 2024-11-19 08:24:27
Your offset time is: 2024-11-19 08:24:27