Skip to main content
gamedev.net
🔒 Locked

Transformation optimization

Started by peter86 3 replies 200+ views
Original Post
peter86
peter86
I''m trying to concatenate the world and view matrix and pass that concatenated matrix as a world matrix and pass an identity matrix for the view matrix, but it crashes on the first line in this code: g_pd3dDevice->SetTransform( D3DTS_WORLD, D3DXMatrixMultiply( NULL, &matWorld, &matView ) ); g_pd3dDevice->SetTransform( D3DTS_VIEW, D3DXMatrixIdentity( NULL ) ); It works if I pass each matrix where it should be passed, so why dosen''t it work this way?
juhaszt
juhaszt
NULL as parameter seems here really wrong...
programmer
Pipo DeClown
Pipo DeClown
not at all. the function also returns the 1st parameter, which means you can use the function AS A PARAMETER. so the NULL is quite right.
juhaszt
juhaszt
anyway, optimizations like that will save for you about 1 nanosecond
programmer
Lightrocker
Lightrocker
You can use D3DXMatrixMultiply() and D3DXMatrixIdentity() as parameters, but you should not use NULL as parameter for these two functions, because those functions do not create a temporary object of D3DXMATRIX for the return value.
I do not think, that this is an optimization, because Direct3D will use the view matrix to transform the vertex, also if it is an identity one.
But in vertex shader you are able to optimize it by using pre-multiplied matrices. And this will save a lot more than one nanosecond. I have tested it. Depending on the size of the vertex shader, you can get up to 200% speed performance.

[edited by - Lightrocker on January 26, 2003 3:08:51 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.