• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 462
  • Last Modified:

Directx Managed memory allocation problem.

Hi I'm trying to use Managed DirectX to display some CAD objects in a numerical simulation program written in C#.
The program requires the calculation of big sparse matrices that need a lot of memory.
The matrix solver is working fine and I could solve without problem the large linear system.
The problem comes when I've tried to add the classes for Directx display. The program doesn't crush nor throw a exception but the linear system gives totally different results.
I suppose that the Directx classes are messing with the memory i use for the matrix solver.
Does anyone know of memory allocation problems connected with the Managed Directx classes and are they any means to fix these problems?
I use the latest Directx SDK release.
0
bogdanfun
Asked:
bogdanfun
  • 2
  • 2
1 Solution
 
davebytesCommented:
I've used DX for a decade, can't offhand recall any sort of memory overwrite issues -- and any that existed were likely because I was passing in bad ptrs to DX to start with.

Have you tried switching your DXSDK into Debug mode?  That activates more things like parameter checking (and likely some memory verification).

I mean, anything is possible, I'd just be surprised...  Are you sure you don't have uninitialized variables yourself, and that when you instantiate DX those uninitialized values change (stuff at different offsets...)?  I've seen that problem before a LOT.

-d
0
 
bogdanfunAuthor Commented:
Hi Davebytes

I think I found the reason why I get different results.
When I allocate the DirectX classes all the mathematical operation are apparently done in float precision even for double data. That's seriously affects the linear system solver.
For now I don't know why is this happening.
0
 
bogdanfunAuthor Commented:
I've found the solution in a previous question

http://www.experts-exchange.com/Programming/Game_Development/3D_Programming/Q_20788209.html?query=directx+float+precision&clearTAFilter=true


Davebytes thanks for your try and I will award you the credits anyway.

0
 
davebytesCommented:
You know, it's been so long since I've had to touch that flag I forgot all about it!

Yes, the D3D runtime switches the FPU into single-precision mode for performance.  Additionally, the FPU mode will get re-set every time you call into D3D (supposedly) if you flag FpuPreserve.  I wouldn't be surprised if some 3D engines might have actually set and restore the FPU state, around say physics computations, to control/reduce the overhead of D3D doing it constantly... But I could be wrong.

Glad you got it working,

-d
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now