DX10 / C++ Sample Code Crashes On Execution

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

35 Replies - 4114 Views - Last Post: 23 April 2012 - 02:55 PM Rate Topic: -----

#31 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 931
  • View blog
  • Posts: 4,012
  • Joined: 14-February 08

Re: DX10 / C++ Sample Code Crashes On Execution

Posted 03 February 2012 - 09:59 AM

If this warning is really bugging you then you could attempt a pragma directive to stop it

#pragma warning( disable :  )



Dunno what the warning number might be, I don't know if it is #55 like the warning says. Of course don't get into the habit of doing this but if the warning is not coming from your code then go for it :)
Was This Post Helpful? 1
  • +
  • -

#32 ButchDean  Icon User is offline

  • Ex-Pro Games Programmer
  • member icon

Reputation: 895
  • View blog
  • Posts: 3,385
  • Joined: 26-November 10

Re: DX10 / C++ Sample Code Crashes On Execution

Posted 03 February 2012 - 10:07 AM

It's a DX10 SDK issue. They probably chose to remove the feature in DX11 because it was a pain to solve. It happens.
Was This Post Helpful? 1
  • +
  • -

#33 gaddam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 20-February 11

Re: DX10 / C++ Sample Code Crashes On Execution

Posted 03 February 2012 - 10:32 AM

Thank you both for the clarification, and stayscrisp for that nifty feature!
Was This Post Helpful? 0
  • +
  • -

#34 ButchDean  Icon User is offline

  • Ex-Pro Games Programmer
  • member icon

Reputation: 895
  • View blog
  • Posts: 3,385
  • Joined: 26-November 10

Re: DX10 / C++ Sample Code Crashes On Execution

Posted 03 February 2012 - 10:35 AM

No problem. I admire your perseverance, so big Kudos on that score! :)
Was This Post Helpful? 0
  • +
  • -

#35 maninvan  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 2
  • Joined: 23-April 12

Re: DX10 / C++ Sample Code Crashes On Execution

Posted 23 April 2012 - 02:30 PM

The problem is that DumpMessages is coded incorrectly. The author of the example fixes this in a newer version of the example GameLib, also incorrectly, by setting a count limit of 10 for the while loop.

The correct solution is below is where you request the waiting number of messages on the queue and then iterate over them and print them out. Finally removing the read messages from the list. see below

void cGraphicsLayer::DumpMessages()
{
	assert(m_pMessageQueue);

	HRESULT r = 0;

	UINT64 numMessages = m_pMessageQueue->GetNumStoredMessages();
	UINT64 count = 0;

	while( count < numMessages )
	{
		// Get the size of the message
		SIZE_T messageLength = 0;
		r = m_pMessageQueue->GetMessage(count, NULL, &messageLength);
		if(messageLength == 0)
			break;

		// Allocate space and get the message
		D3D10_MESSAGE * pMessage = (D3D10_MESSAGE*)malloc(messageLength);
		r = m_pMessageQueue->GetMessage(count, pMessage, &messageLength);
		if(FAILED(r))
		{
			OutputDebugString(L"Failed to get Direct3D Message");
			break;
		}
	
		TCHAR strOutput[MAX_PATH];
		swprintf_s(strOutput, MAX_PATH, L"D3DDMSG [Cat[%i] Sev[%i] ID[%i]: %s\n",
			pMessage->Category, pMessage->Severity, pMessage->ID, pMessage->pDescription);
		OutputDebugString(strOutput);
	
		count++;
	}

	// Clear Messages from the D3D message queue
	m_pMessageQueue->ClearStoredMessages();
}


Was This Post Helpful? 1
  • +
  • -

#36 maninvan  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 2
  • Joined: 23-April 12

Re: DX10 / C++ Sample Code Crashes On Execution

Posted 23 April 2012 - 02:55 PM

PS: Also if the swprintf_s is set to a captial %S the unicode string will display in a readable format in the debug output window

void cGraphicsLayer::DumpMessages()
{
	assert(m_pMessageQueue);

	HRESULT r = 0;

	UINT64 numMessages = m_pMessageQueue->GetNumStoredMessages();
	UINT64 count = 0;

	while( count < numMessages )
	{
		// Get the size of the message
		SIZE_T messageLength = 0;
		r = m_pMessageQueue->GetMessage(count, NULL, &messageLength);
		if(messageLength == 0)
			break;

		// Allocate space and get the message
		D3D10_MESSAGE * pMessage = (D3D10_MESSAGE*)malloc(messageLength);
		r = m_pMessageQueue->GetMessage(count, pMessage, &messageLength);
		if(FAILED(r))
		{
			OutputDebugString(L"Failed to get Direct3D Message");
			break;
		}
	
		TCHAR strOutput[MAX_PATH];
		swprintf_s(strOutput, MAX_PATH, L"D3DDMSG [Cat[%i] Sev[%i] ID[%i]: %S\n",
			pMessage->Category, pMessage->Severity, pMessage->ID, pMessage->pDescription);
		OutputDebugString(strOutput);
	
		count++;
	}

	// Clear Messages from the D3D message queue
	m_pMessageQueue->ClearStoredMessages();
}


[/quote]
Was This Post Helpful? 1
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3