[C++, DX11] System crash with Frame Counter

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

Ripiz
Just popping in
Just popping in
Posts: 17
Joined: Sat Oct 01, 2011 16:53

[C++, DX11] System crash with Frame Counter

Postby Ripiz » Sat Oct 01, 2011 17:02

Hello,

I'm trying to implement CEGUI into my engine and having some troubles. I've managed to get DirectX 11 renderer working and rendered simple Hello World window. Next thing I tried to do was FPS counter (the part I added is between Start and End comments in Frame Render), which causes my system to crash.

CEGUI initialization:

Code: Select all

   CEGUI::Direct3D11Renderer *renderer = &CEGUI::Direct3D11Renderer::bootstrapSystem(pDevice, pDeviceContext);

   CEGUI::DefaultResourceProvider* rp = (CEGUI::DefaultResourceProvider*)(CEGUI::System::getSingleton().getResourceProvider());
   rp->setResourceGroupDirectory("schemes", "datafiles/schemes/");
   rp->setResourceGroupDirectory("imagesets", "datafiles/imagesets/");
   rp->setResourceGroupDirectory("fonts", "datafiles/fonts/");
   rp->setResourceGroupDirectory("looknfeels", "datafiles/looknfeel/");
   rp->setResourceGroupDirectory("layouts", "datafiles/layouts/");
   
   CEGUI::Scheme::setDefaultResourceGroup("schemes");
   CEGUI::Imageset::setDefaultResourceGroup("imagesets");
   CEGUI::Font::setDefaultResourceGroup("fonts");
   CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels");
   CEGUI::WindowManager::setDefaultResourceGroup("layouts");

   CEGUI::XMLParser* parser = CEGUI::System::getSingleton().getXMLParser();
   if(parser->isPropertyPresent("SchemaDefaultResourceGroup"))
      parser->setProperty("SchemaDefaultResourceGroup", "schemas");   
   
   CEGUI::SchemeManager::getSingleton().create(CEGUI::String("TaharezLook.scheme"));
   CEGUI::System::getSingleton().setDefaultFont("DejaVuSans-10");
   CEGUI::System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow");
   CEGUI::Window *myRoot = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "_MasterRoot");
   CEGUI::System::getSingleton().setGUISheet(myRoot);

   CEGUI::Window *wnd = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/FrameWindow", "Demo Window");
   myRoot->addChildWindow(wnd);
   wnd->setPosition(CEGUI::UVector2(cegui_reldim(0.25f), cegui_reldim( 0.25f)));
   wnd->setSize(CEGUI::UVector2(cegui_reldim(0.5f), cegui_reldim( 0.5f)));
   wnd->setMaxSize(CEGUI::UVector2(cegui_reldim(1.0f), cegui_reldim( 1.0f)));
   wnd->setMinSize(CEGUI::UVector2(cegui_reldim(0.1f), cegui_reldim( 0.1f)));
   wnd->setText("Hello world!");


Frame Move:

Code: Select all

   CEGUI::System::getSingleton().injectTimePulse(fElapsedTime);


Frame Render:

Code: Select all

void CALLBACK OnFrameRender(ID3D11Device *pd3dDevice, ID3D11DeviceContext *pd3dImmediateContext, double fTime, float fElapsedTime, void *pUserContext) {
   float ClearColor[4] = {0.2, 0.2, 0.7, 0};
   ID3D11RenderTargetView *pRTV = DXUTGetD3D11RenderTargetView();
   pDeviceContext->ClearRenderTargetView(pRTV, ClearColor);

   // Clear the depth stencil
   ID3D11DepthStencilView *pDSV = DXUTGetD3D11DepthStencilView();
   pDeviceContext->ClearDepthStencilView(pDSV, D3D11_CLEAR_DEPTH, 1, 0);

   pDeviceContext->OMSetRenderTargets(1, &pRTV, pDSV);

   // ==== Start ====
   CEGUI::Direct3D11GeometryBuffer *buffer = (CEGUI::Direct3D11GeometryBuffer*)&CEGUI::System::getSingleton().getRenderer()->createGeometryBuffer();
   buffer->reset();
   CEGUI::System::getSingleton().getDefaultFont()->drawText(*buffer, CEGUI::String((char*)DXUTGetFrameStats(DXUTIsVsyncEnabled())), CEGUI::Vector2(0, 0), 0, CEGUI::colour(0xFFFFFFFF));
   CEGUI::System::getSingleton().getDefaultFont()->drawText(*buffer, CEGUI::String((char*)DXUTGetDeviceStats()), CEGUI::Vector2(0, 20), 0, CEGUI::colour(0xFFFFFFFF));
   buffer->draw();
   CEGUI::System::getSingleton().getRenderer()->destroyGeometryBuffer(*buffer);
   // ==== End ====
   CEGUI::System::getSingleton().renderGUI();
}


To be exact, system crashes when DXUT calls SwapChain->Present();.

CEGUI log: http://dl.dropbox.com/u/2637453/CEGUI/C ... 0-2011.log

If I forgot to provide any information let me know.

Thank you.


Edit:
New Frame Render code:

Code: Select all

void CALLBACK OnFrameRender(ID3D11Device *pd3dDevice, ID3D11DeviceContext *pd3dImmediateContext, double fTime, float fElapsedTime, void *pUserContext) {
   float ClearColor[4] = {0.2, 0.2, 0.7, 0};
   ID3D11RenderTargetView *pRTV = DXUTGetD3D11RenderTargetView();
   pDeviceContext->ClearRenderTargetView(pRTV, ClearColor);

   // Clear the depth stencil
   ID3D11DepthStencilView *pDSV = DXUTGetD3D11DepthStencilView();
   pDeviceContext->ClearDepthStencilView(pDSV, D3D11_CLEAR_DEPTH, 1, 0);

   pDeviceContext->OMSetRenderTargets(1, &pRTV, pDSV);

   static CEGUI::Direct3D11GeometryBuffer *buffer = 0;
   if(!buffer)
      buffer = (CEGUI::Direct3D11GeometryBuffer*)&CEGUI::System::getSingleton().getRenderer()->createGeometryBuffer();

   const CEGUI::Rect scrn(CEGUI::Vector2(0, 0), CEGUI::System::getSingleton().getRenderer()->getDisplaySize());
   buffer->setClippingRegion(scrn);

   buffer->reset();
   wstring wstr = wstring(DXUTGetFrameStats(DXUTIsVsyncEnabled())) + wstring(L"\n") + wstring(DXUTGetDeviceStats());
   size_t length = wstr.length() + 1;
   char *string = new char[length];
   wcstombs(string, wstr.c_str(), length);
   CEGUI::System::getSingleton().getDefaultFont()->drawText(*buffer, CEGUI::String(string), CEGUI::Vector2(0, 0), 0, CEGUI::colour(0xFFFFFFFF));
   delete[] string;
   buffer->draw();

   CEGUI::System::getSingleton().renderGUI();
}


I used WARP device and code works fine: it renders string perfectly and doesn't spew any errors. However if I use HARDWARE device it still crashes on same line.

New CEGUI log: http://dl.dropbox.com/u/2637453/CEGUI/C ... 0-2011.log

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: [C++, DX11] System crash with Frame Counter

Postby CrazyEddie » Mon Oct 03, 2011 07:37

I can't tell you what's wrong here, because I'm not sure. Normally you would not call draw on the GeometryBuffer directly, but add the GeometryBuffer to some rendering queue on some render target, this said, I don't think it would cause crashes later (though you should be aware that none of the render states that might normally be set will be set by that call alone).

Can you confirm which compiler you're using. The log contains the "Great Scott!" version, which means something newer than version 10, I'm not sure if that 'ultimate' version of VS 2010 comes out as that, or if you're using the 2011 version - if you are you might want to switch to using a compiler that's actually released, since we will not support pre-release compilers (because they cause strange, unexplainable issues - not saying that's what's happening here, but only by using a known 'good' compiler can you say for sure).

Could you also post a callstack with debug symbols. I'm not convinced it will help, but it's something else to look at :D

I should probably add that in general I do not use Windows, and even then, I do not have D3D11 level hardware to test with, so your hope for help here lies in the hands of the larger community.

CE.

Ripiz
Just popping in
Just popping in
Posts: 17
Joined: Sat Oct 01, 2011 16:53

Re: [C++, DX11] System crash with Frame Counter

Postby Ripiz » Mon Oct 03, 2011 14:10

That is strange. If I create WARP device states seem to be correct (which is CPU renderer if I understand correctly http://msdn.microsoft.com/en-us/library/gg615082.aspx), as text is rendered correctly. I will try to add Buffer to render target.

I am using Visual Studio 2011. All my projects work correctly as long as I don't try to use Windows 8 features, therefore I doubt it's a problem. Sadly I do not have Visual Studio 2010 installed anymore, if that appears the problem I will have to wait till it's fixed :(

Which callstack would you like? I'm sorry if I wasn't completely clear about the problem, but I had in mind my whole computer crashes, mouse freezes, keyboard doesn't respond etc, I just have to press 'Reset'.

I don't have D3D11 hardware either. I am using D3D11 layer with D3D9 features, which means Windows Vista/7/8 is all you need to run it.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: [C++, DX11] System crash with Frame Counter

Postby Kulik » Mon Oct 03, 2011 14:41

We can't support an unreleased compiler so you are pretty much on your own.

However I think the compiler itself is unlikely the issue. What dependency pack are you using? MSVC 2010 deps won't work (or might not work to be precise) with MSVC 2011. The runtimes definitely have to match, the compiler versions should match as well.

PS: Unless you have really solid reasons to use Windows 8 and MSVC 2011 for development I wouldn't go there.

Ripiz
Just popping in
Just popping in
Posts: 17
Joined: Sat Oct 01, 2011 16:53

Re: [C++, DX11] System crash with Frame Counter

Postby Ripiz » Tue Oct 04, 2011 06:02

It seems if I render GUI before rendering FPS it's all fine 0.o Thanks for the help.

I built all dependencies myself using VS11, they weren't working with VS11. However I had A LOT of troubles (and I still have them).

You don't need to have Windows 8 to use VS11. I use VS11 because it has some very nice features.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 1 guest