converting some rastertek tutorials to directxmath: black screen in debug mode

Started by
2 comments, last by hupsilardee 10 years, 10 months ago

I'm learning the DX11 tutorial of rastertek (http://www.rastertek.com/tutdx11.html).

Since they use the deprecated D3DX APIs family I decided to convert the source code to use DirectXMath and DirectXTK.

When I compile the projects with Release configuration everything works fine, but when I switch to Debug configuration they display just a black screen, without any kind of compilation or runtime errors.

I'm just a beginner in this world, so I don't have any idea about what could cause this issue.

The code is quite the same of the original, with some exception like the maths structures and functions.

I attach here the tutorial 4 that I converted. (original source: http://www.rastertek.com/dx11tut04.html).

[attachment=15539:DirectX 11 Tutorials VS2012.zip]

"Recursion is the first step towards madness." - "Skegg?ld, Skálm?ld, Skildir ro Klofnir!"
Direct3D 12 quick reference: https://github.com/alessiot89/D3D12QuickRef/
Advertisement

When you have two programs that should be doing the same thing, but aren't the easiest option to debug them is usually to load up two copies of Visual Studio, and step through both programs in the debugger at the same time. At some point you'll find the place where the values in the variables stop being the same - that is where a bug is located.

As you know what's changed you won't need to step over all the code. I'd start by looking at the constants that are passed to the shaders, and how they are calculated.

After comparing the two different version on debug mode it appears that is a constructor-call problem: since some structures of DirectXMath need aligned allocation I used _aligned_malloc function to have 16-byte aligned data.

My bad, I forgot that _aligned_malloc (and all malloc/free etc C-derived memory (de)allocation function) don't call the constructor and the destructor like new and delete...

I will try to use the "placement new" syntax, it should solve my problem.

"Recursion is the first step towards madness." - "Skegg?ld, Skálm?ld, Skildir ro Klofnir!"
Direct3D 12 quick reference: https://github.com/alessiot89/D3D12QuickRef/

I suggest you use the SimpleMath library that's part of the DirectXTK. It's a wrapper above DirectXMath, that provides Matrix, Vector2, Vector3, Vector4, Quaternion etc types, that make it much easier to write expressions intuitively.

The downside is a slight performance hit due to the way some data has to be unloaded and reloaded more times than necessary into the CPU registers, but it's extremely fast nonetheless.

My bottleneck is and will always be the scripting engine rather than the CPU math anyway :)

This topic is closed to new replies.

Advertisement