Jump to content
  • Advertisement
Sign in to follow this  
dawoodr

Need some help, can't figure out what's wrong

This topic is 1510 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello!

 

Well I am stuck, I don¨t know why the following problem occurs. My program totally crashes once it is up, it says .... has stopped working. If I run the debug mode I get this message "Unhandled exception at 0x0088378B in D3.exe: 0xC0000005: Access violation reading location 0xFFFFFFFF." and then I have to press break.

 

 

Now all this happens in the following code.

worldViewProj = worldMatrix * viewMatrix * projMatrix;
cbPerObj.WVP = DirectX::XMMatrixTranspose(worldViewProj);

Something is wrong with theese two or one of theese two particular lines, I can't figure out what it is. But it is here that the program breaks.

I didn¨t want to patste the whole code here but only to clarify where the problem occurs, below is a link to the whole project which you probably gonna have to look at but now you atleast know where the problem occurs

 

http://pastebin.com/jk4RwukS

 

Regards!

Share this post


Link to post
Share on other sites
Advertisement

It likely has something to do with memory alignment, which is a common issue when working with DirectXMath objects and functions.  Can you describe the types of the objects you are using, and if you followed the declaration procedures listed here?

Share this post


Link to post
Share on other sites

Yes you are right here is the error I forgot to post,

1>c:\users\dawood\documents\visual studio 2013\projects\d3\d3\main.cpp(5): warning C4316: 'Ggraphics' : object allocated on the heap may not be aligned 16

I am a complete beginner sort of and don¨t know very much, I am following this tutorial. http://www.braynzarsoft.net/index.php?p=D3D11WVP

 

Also everything I have written in my entire project is in the link I posted to pastebin if you scroll up.

Edited by dawoodr

Share this post


Link to post
Share on other sites

Can anybody help me out? What should I change and how should I write it, please show it to me because I don't get it.

 

Regards!

Share this post


Link to post
Share on other sites

The XMMATRIX and XMVECTOR structures must be on 16 byte aligned boundaries. In the tutorial, all the XMMATRIX and XMVECTOR variables are in global scope. As a result, they would be aligned correctly.

 

You've declared your XMMATRIX and XMVECTOR variables as local (not global, as in the tutorial) in a class. When the class is created, as the warning indicates, there's no guarantee those structure will be aligned correctly (and they apparently are not!)

 

You can either declare them as global (i.e., not as class members), or use XMFLOAT4X4 and XMFLOAT3 (or XMFLOAT4) for needed matrices and vectors respectively.

 

For functions which require XMMATRIX and XMVECTOR parameters, use XMLoadFloat4x4 and XMLoadFloat3/4 to set the arguments, and XMStoreFloatxxx to store the results back in your variables.

Edited by Buckeye

Share this post


Link to post
Share on other sites

Ok I am trying to fix it but what does this mean "16 byte aligned boundaries" I don't even know what that is. And why do they have to be 16 byte aligned?

 

Also, would I have to have XMVECTOR and XMMATRIX aswell as XMFLOAT4 and XMFLOAT4X4 and then keep converting between them? Because I read that you should only do operations on XMVECTOR and XMMATRIX and for storing the variables or whatever you should use XMFLOATS, am I correct on this or wrong? Also if it is not too much to ask, could you take the code that I posted on pastebin and then take a row or two and remake them to show me? Meaning chaning a row or two where I am using the XMMATRIX and XMVECTOR and write them the correct what so the program works.

 

Regards!

Edited by dawoodr

Share this post


Link to post
Share on other sites

__declspec(align(16)) XMMATRIX World; ?

or
XMMATRIX 
__declspec(align(16)) World; ?


If the problem occurs again I will definitely try this but I don't know WTF is wrong, the program just started working and all I did was rewrite the lines according to the tutorial I was following.

Share this post


Link to post
Share on other sites

Guys I really appreciate your help but since I am a newbie I really would appreciate some examples, meaning that you show me how to do it, it is very hard for me to understand otherwise. Please take your time to show me if you are able because the problem started occuring again sad.png

 

An example would be; If I want to allocate memory for my XMMATRIX WVP; how do I do it?

 

Regards!

Edited by dawoodr

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!