Jump to content
  • Advertisement
Sign in to follow this  
striker87

Help with modifying Rastertek tutorials

This topic is 2525 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

I have been looking at the Rastertek DirectX 11 tutorials which have been helpful but noticed they use D3DX10Math instead of XNAMath. So have been trying to modify it to use XNAMath but having no luck so far. Has anyone tried changing the tutorials to use XNAMath before? Also is it beneficial for me to use XNAMath instead of D3DX10Math or does it really not matter as to which one is used. I also attached a zip file containing the tutorial I have been trying to change to use XNAMath incase anyone would like to take a look and see what I'm missing to get it to work correctly.

Share this post


Link to post
Share on other sites
Advertisement
I haven't used these tutorials before, but can you describe what isn't working for you? Are you getting compile time errors, incorrect results, or runtime issues? Please try to be as specific as possible and I am sure we will be able to point out what the issue is.

Share this post


Link to post
Share on other sites
Sorry about that. Here is the error I get when compiling:

Error 1 error C2719: 'unnamed-parameter': formal parameter with __declspec(align('16')) won't be aligned c:\users\dwc2987@msn.com\documents\visual studio 2010\projects\2d engine\2d engine\textureshaderclass.h 29 1 2D Engine

which is pointing to this line of code:


[color=blue]bool[size=2] Render(ID3D11DeviceContext*, [color=blue]int[size=2], XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*);

Share this post


Link to post
Share on other sites
I haven't dealt with XNAMath just yet, but it looks like there is a calling convention issue. It is saying that the alignment of 16 bytes isn't going to be adhered to in one of your parameters. My guess would be that the XMMATRIX types are using a special calling convention to take advantage of the some SIMD instructions, but that is a total guess. Try finding out if there are certain requirements for using XNAMath regarding the calling convention and byte alignment.

Share this post


Link to post
Share on other sites
I'm also using the Rastertek tutorials to learn DirectX 11.

I converted most of the final terrain tutorial to XNAMath some months ago, but hit a snag somewhere. I can't remember where. I gave up and removed it. I'd be interested in whether there's a good reason to convert it to XNAMath as well.

Share this post


Link to post
Share on other sites
I just took a look in the documentation for XNAMath, and found the following statement on the calling conventions in the getting started page:

Type Usage Guidelines


[indent=1]The XMVECTOR and XMMATRIX types are the work horses for the XNA Math library. Every operation consumes or produces data of these types. Working with them is key to using the library. However, since XNA Math makes use of the SIMD instruction sets, these data types are subject to a number of restrictions. It is critical that you understand these restrictions if you want to make good use of the XNA Math functions.

[indent=1]You should think of XMVECTOR as a proxy for a SIMD hardware register, and XMMATRIX as a proxy for a logical grouping of four SIMD hardware registers. These types are annotated to indicate they require 16-byte alignment to work correctly. The compiler will automatically place them correctly on the stack when they are used as a local variable, or place them in the data segment when they are used as a global variable. With proper conventions, they can also be passed safely as parameters to a function (see Calling Conventions for details).

[indent=1]Allocations from the heap, however, are more complicated. As such, you need to be careful whenever you use either XMVECTOR or XMMATRIX as a member of a class or structure to be allocated from the heap. On Xbox 360 and Windows x64, all heap allocations are 16-byte aligned, but for Windows x86, they are only 8-byte aligned. There are options for allocating structures from the heap with 16-byte alignment (see Properly Align Allocations). Also, for C++, you can make use of operator new/delete overloads, if you want.

[indent=1]However, often it is easier and more compact to avoid using XMVECTOR or XMMATRIX directly in a class or structure. Instead, make use of the XMFLOAT3, XMFLOAT4, XMFLOAT4X3, XMFLOAT4X4, and so on, as members of your structure. Further, you can use the Vector Loading and Vector Storage functions to move the data efficiently into XMVECTOR or XMMATRIX local variables, perform computations, and store the results. There are also streaming functions (XMVector3TransformStream, XMVector4TransformStream, and so on) that efficiently operate directly on arrays of these data types.


I am fairly certain that the information in here is going to have the answer for your issue... Are you using Windows x86 or x64?

Share this post


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

×

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!