Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Help with modifying Rastertek tutorials


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 striker87   Members   -  Reputation: 118

Like
0Likes
Like

Posted 15 January 2012 - 11:51 PM

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.

Attached Files



Sponsor:

#2 Jason Z   Crossbones+   -  Reputation: 5782

Like
0Likes
Like

Posted 16 January 2012 - 03:16 PM

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.

#3 striker87   Members   -  Reputation: 118

Like
0Likes
Like

Posted 16 January 2012 - 07:43 PM

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:


bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*);

#4 Jason Z   Crossbones+   -  Reputation: 5782

Like
0Likes
Like

Posted 17 January 2012 - 12:55 AM

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.

#5 Corvwyn   Members   -  Reputation: 331

Like
0Likes
Like

Posted 17 January 2012 - 06:58 AM

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.

#6 Jason Z   Crossbones+   -  Reputation: 5782

Like
0Likes
Like

Posted 17 January 2012 - 02:03 PM

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


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.

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).

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.

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?

#7 striker87   Members   -  Reputation: 118

Like
0Likes
Like

Posted 17 January 2012 - 05:39 PM

My operating system is x64. So I should use XMFLOAT4X4 instead of XMMATRIX?




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS