locked
directx11 : starter kit sample : Exception on startup

    Question

  • Hi,

    Following exception message is found on application's startup,

    Exception Message: Unhandled exception at 0x00B67B13 in StarterKit.exe: 0xC0000005: Access violation reading location 0xFFFFFFFF.

    Following is the StackTrace:
    > StarterKit.exe!DirectX::XMMatrixTranspose(const DirectX::XMMATRIX & M) Line 615
    C++
    StarterKit.exe!VSD3DStarter::Mesh::Render(const VSD3DStarter::Graphics & graphics, const DirectX::XMMATRIX & world) Line 1447
    C++
    StarterKit.exe!Game::[Direct3DBase]::Render() Line 434
    C++
    StarterKit.exe!StarterKit::DirectXPage::OnRendering(Platform::Object ^ sender, Platform::Object ^ args) Line 88
    C++
    [External Code]

    [Frames below may be incorrect and/or missing, no symbols loaded for Windows.UI.Xaml.dll]


    This error occurs on starting up the application.
    Often times this error doesn't occur on startup and application works fine.

    It seems that VSD3DStarter::Mesh::Render() routine finds this problem either due code issue or any pending initialization of starter kit library.

    Following the the code related to mesh rendering:

    Game::Game()
    {

    }

    Game::~Game()
    {
        for (Mesh* m : m_meshModels

    )
        {
            delete m;
        }
        m_meshModels.clear();

    m_meshModelWorldMatrix.clear();

    }

    void Game::CreateWindowSizeDependentResources()
    {
        GameBase::CreateWindowSizeDependentResources();

        float aspectRatio = m_windowBounds.Width / m_windowBounds.Height;

        //
        // setup camera for our scene
        //
        m_graphics.GetCamera().SetViewport((UINT)m_windowBounds.Width, (UINT)m_windowBounds.Height);
    //m_graphics.GetCamera().SetPosition(XMFLOAT3(0.0f, 6.0f, -18.0f));
        m_graphics.GetCamera().SetPosition(XMFLOAT3(0.0f, 200.0f, -508.0f));
        m_graphics.GetCamera().SetLookAt(XMFLOAT3(0.0f, 200.0f, 0.0f));

        float fovAngleY = 70.0f * XM_PI / 180.0f;

        if (aspectRatio < 1.0f)
        {
            ///
            /// portrait or snap view
            ///
            m_graphics.GetCamera().SetUpVector(XMFLOAT3(1.0f, 0.0f, 0.0f));
            fovAngleY = 120.0f * XM_PI / 180.0f;

        }
        else
        {
            ///
            /// landscape view
            ///
            m_graphics.GetCamera().SetUpVector(XMFLOAT3(0.0f, 1.0f, 0.0f));
        }

        m_graphics.GetCamera().SetProjection(fovAngleY, aspectRatio, 1.0f, 1000.0f);

        //
        // setup lighting for our scene
        //
        XMFLOAT3 pos = XMFLOAT3(5.0f, 5.0f, -2.5f);
        XMVECTOR vPos = XMLoadFloat3(&pos);

        XMFLOAT3 dir;
        XMStoreFloat3(&dir, XMVector3Normalize(vPos));

        m_lightConstants.ActiveLights = 1;
        m_lightConstants.Ambient =  XMFLOAT4(0.3f, 0.3f, 0.3f, 1.0f);
        m_lightConstants.IsPointLight[0] = false;
        m_lightConstants.LightColor[0] = XMFLOAT4(0.8f, 0.8f, 0.8f, 1.0f); 
        m_lightConstants.LightDirection[0].x = dir.x;
        m_lightConstants.LightDirection[0].y = dir.y;
        m_lightConstants.LightDirection[0].z = dir.z;
        m_lightConstants.LightDirection[0].w = 0;
        m_lightConstants.LightSpecularIntensity[0].x = 2;

        m_graphics.UpdateLightConstants(m_lightConstants);
    }

    void Game::Initialize()
    {
    /*Mesh::LoadFromFile(m_graphics, L"die.cmo", L"", L"", m_meshModels);
    Mesh::LoadFromFile(m_graphics, L"Baby.cmo", L"", L"", m_meshModels);
    Mesh::LoadFromFile(m_graphics, L"USAcessLift.cmo", L"", L"", m_meshModels);*/

    Mesh::LoadFromFile(m_graphics, L"Container.cmo", L"", L"", m_meshModels);

    //const uint16 meshCount = m_meshModels.size();
    //m_meshModelWorldMatrix = std::unique_ptr<DirectX::XMMATRIX[meshCount]>();

    m_meshModelWorldMatrix = std::vector<XMMATRIX>(m_meshModels.size());
    //m_meshModelWorldMatrix = (XMMATRIX *)_aligned_malloc(m_meshModels.size() * sizeof(XMMATRIX), 16);

    Reset();


    for (UINT i = 0; i < m_meshModels.size(); i++)
    {
    auto meshName = ref new String(m_meshModels[i]->Name());
    if (meshName == ONEINCH_CUBE_OBJECTNAME)
    {
    OneInchGameUnit = m_meshModels[i]->Extents().MaxX - m_meshModels[i]->Extents().MinY;
    }
    }

    // opt in to recieve touch/mouse events
    m_window->PointerPressed +=
    ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &Game::OnPointerPressed);

    m_window->PointerMoved +=
    ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &Game::OnPointerMoved);

    m_window->PointerReleased +=
    ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &Game::OnPointerReleased);

    // for mouse-only use
    // register handler for relative mouse movement events
    Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved +=
    ref new TypedEventHandler<MouseDevice^, MouseEventArgs^>(this, &Game::OnMouseMoved);

    DegreeOfAngle = 0;

    }

    void Game::Update(float timeTotal, float timeDelta)
    {
    for (UINT i = 0; i < m_meshModels.size(); i++)
    {
    auto meshName = ref new String(m_meshModels[i]->Name());
    if (meshName == MOVABLE_OBJECTNAME)
    {
    XMMATRIX translationMat = XMMatrixTranslation(m_MousePointerDeltaX, m_MousePointerDeltaY, 0.0f);
    XMMATRIX rotateTransform = XMMatrixRotationRollPitchYaw(0, 0, XMConvertToRadians(DegreeOfAngle));

    m_meshModelWorldMatrix[i] = XMMatrixMultiply(m_meshModelWorldMatrix[i], rotateTransform);

    m_meshModelWorldMatrix[i] = XMMatrixMultiply(m_meshModelWorldMatrix[i], translationMat);

    m_MousePointerDeltaX = 0;
    m_MousePointerDeltaY = 0;
    DegreeOfAngle = 0;

    if (meshName == MOVABLE_OBJECTNAME){
    PickPoint1.y =  (-m_meshModelWorldMatrix[i].r[3].m128_f32[1]) / OneInchGameUnit;
    PickPoint2.y = (-m_meshModelWorldMatrix[i].r[3].m128_f32[1]) / OneInchGameUnit;
    PickPoint3.y = (-m_meshModelWorldMatrix[i].r[3].m128_f32[1]) / OneInchGameUnit;
    PickPoint4.y = (-m_meshModelWorldMatrix[i].r[3].m128_f32[1]) / OneInchGameUnit;
    }
    }

    }
    }

    void Game::Render()
    {
        GameBase::Render();

        // clear
        m_d3dContext->OMSetRenderTargets(
            1,
            m_d3dRenderTargetView.GetAddressOf(),
            m_d3dDepthStencilView.Get()
            );

        m_d3dContext->ClearRenderTargetView(
            m_d3dRenderTargetView.Get(),
            DirectX::Colors::DarkSlateGray
            );

        m_d3dContext->ClearDepthStencilView(
            m_d3dDepthStencilView.Get(),
            D3D11_CLEAR_DEPTH,
            1.0f,
            0
            );


    for (UINT i = 0; i < m_meshModels.size(); i++)
    {
    m_meshModels[i]->Render(m_graphics, m_meshModelWorldMatrix[i]);
    }

        //
        // only enable MSAA if the device has enough power
        //
        if (m_d3dFeatureLevel >= D3D_FEATURE_LEVEL_10_0)
        {
            //
            // resolve multi-sample textures into single-sample textures
            //
            UINT resourceIndex = D3D11CalcSubresource(0, 0, 1);
            m_d3dContext->ResolveSubresource(m_backBuffer.Get(), resourceIndex, m_backBufferMsaa.Get(), resourceIndex, DXGI_FORMAT_B8G8R8A8_UNORM);
        }
    }

    }

    Please inform possible reason or solution to this problem.  

    Thanks.


    Monday, April 14, 2014 4:00 PM

All replies

  • Which VS Starter Kit did you download? Which compiler/OS are you using? Which arch did you compile for? (x86/x64/ARM)
    Monday, April 14, 2014 6:24 PM
  • Hi Chuck,

    I'm using "diceroller3d-e75ccd62e002" version of Starter kit from 

    http://diceroller3d.codeplex.com/SourceControl/changeset/e75ccd62e002

    This error is found in "Mesh::Render" only on second time deploying app, first time it works fine.

    So it seems related to buffer not getting cleared but i'm not sure how to clear graphics memory using 3D Starter kit.

    Monday, April 14, 2014 6:43 PM
  • The 3d starter kit has a lot of bugs in it. It was lagging in Visual Studio and popped up a warning on my desktop saying to report the problem if this continues. I am using the 2013 version. Yikes..

    Also, the program was running as a service or win32 process and did not close with the Shift + F5 stop debugging command. I closed the program with task manager. Yikes..

    Calvin

    • Edited by IQ100 Thursday, May 15, 2014 3:29 AM
    Thursday, May 15, 2014 3:27 AM