Jump to content

  • Log In with Google      Sign In   
  • Create Account


XMMatrixTranspose Crashes


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
4 replies to this topic

#1 Brianmj   Members   -  Reputation: 111

Like
0Likes
Like

Posted 26 June 2012 - 06:52 PM

Hello, I'm trying to render a .obj exported from blender. In my code I transpose the world, view and projection matrices, but as soon as I try to transpose the world matrix, I get a "Unhandled exception at 0x003EDF63 in Obj Renderer.exe: 0xC0000005: Access violation reading location 0xFFFFFFFF." This is odd cause the code is pretty much the same as in other projects which work.

[source lang="cpp"]deviceContext->ClearDepthStencilView(depthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0); deviceContext->ClearRenderTargetView(renderTargetView, &clearColor.x); ConstantBuffer cb; cb.world = DirectX::XMMatrixTranspose(world); cb.view = DirectX::XMMatrixTranspose(view); cb.proj = DirectX::XMMatrixTranspose(proj); deviceContext->UpdateSubresource(cBuf, 0, nullptr, &cb, 0, 0); deviceContext->VSSetConstantBuffers(0, 1, &cBuf); UINT vertexCount = cylinder->meshes.front().vn.size(); deviceContext->Draw(vertexCount, 0); swapChain->Present(0, 0)[/source]
The problem is that sometimes this will compile and execute, but nothing will render, and sometimes it'll throw an exception. I have the matrices set up as
[source lang="cpp"]void Model::build_matrices(){ auto e = XMVectorSet(0.0f, 0.0f, -3.0f, 1.0f); auto u = XMVectorSet(0.0f, 1.0f, 0.0f, 1.0f); auto t = XMVectorSet(0.0f, 0.0f, 0.0f, 1.0f); view = DirectX::XMMatrixLookAtLH(e, t, u); world = DirectX::XMMatrixTranslation(0.0f, 0.0f, 2.0f); proj = DirectX::XMMatrixPerspectiveFovLH(XM_PIDIV2, aspect_ratio(), 0.1f, 1000.0f);}[/source]
with view, world, proj declared as DirectX::XMMATRIX. Can someone please help - this is baffling

Sponsor:

#2 Necrolis   Members   -  Reputation: 1276

Like
0Likes
Like

Posted 27 June 2012 - 01:10 AM

the destination of XMMatrix* ops needs to be 16-byte aligned when compiled with SSE(2) enabled, else you are gonna go to crash heaven (or worse, crash your GFX driver....)
Try making a temporary stack allocated XMMMatrix and then memcpy from that into your view/world/proj

#3 kubera   Members   -  Reputation: 887

Like
1Likes
Like

Posted 27 June 2012 - 06:10 AM

Please consider reading this thread in Microsoft's forum:
http://forums.create...ms/t/84299.aspx

#4 Brianmj   Members   -  Reputation: 111

Like
0Likes
Like

Posted 28 June 2012 - 09:25 AM

Thank you very much. I couldn't figure out whythiswas happening. What an odd rule

#5 molehill mountaineer   Members   -  Reputation: 595

Like
0Likes
Like

Posted 28 June 2012 - 11:26 AM

In case you need it, here's how you convert between XMMATRIX and XMFLOAT4X4 (so that you can use the XNA functions)

XMLoadFloat4x4()
//transpose to feed to shader
    shaderData cbd;
    cbd.world = XMMatrixTranspose(XMLoadFloat4x4(&m_world));
    cbd.view =XMMatrixTranspose(XMLoadFloat4x4(&p_camera.getView()));
    cbd.projection =XMMatrixTranspose(XMLoadFloat4x4(&p_camera.getProjection()));

XMStoreFloat4x4
    XMMATRIX world = XMMatrixRotationY(p_deltaTime);
    XMStoreFloat4x4(&m_world, world);





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