Jump to content

  • Log In with Google      Sign In   
  • Create Account

Problem with mapping a constant buffer resource


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 steven166   Members   -  Reputation: 237

Like
0Likes
Like

Posted 16 March 2014 - 09:12 PM

I am implementing for my paper. However, there is a vague problem which I do not know exact reason. As debugging, the windows is frozen for a while, then goes black and it stops at code which mapping a constant buffer. The constant buffer is not null, but it is data is null after mapping.

        D3D11_MAPPED_SUBRESOURCE MappedResource3;  
	HR( gpImmediateContext->Map( mCBPS_ID, 0, D3D11_MAP_WRITE_DISCARD, 0, &MappedResource3 ) );
	PS_CB_ID* pPSID = ( PS_CB_ID* )MappedResource3.pData;

	char DebugString[100];
	sprintf_s(DebugString,"ID_constant buffer is: %p\n", mCBPS_ID);
	OutputDebugString(DebugString);
	pPSID->g_iID = 0; // pPSID is null

	gpImmediateContext->Unmap( mCBPS_ID, 0 );	    
	gpImmediateContext->PSSetConstantBuffers( 3, 1, &mCBPS_ID );

Have anybody experienced this problem before? Please, help me. Thanks in advanced



Sponsor:

#2 Samith   Members   -  Reputation: 2327

Like
0Likes
Like

Posted 16 March 2014 - 09:30 PM

There are a couple of reasons this could happen. Are you running with the DirectX debug layer enabled? If so, you'll get some stuff in your debug output log that will probably tell you why the buffer can't be mapped. This link has more info on enabling the debug layer: http://msdn.microsoft.com/en-us/library/windows/desktop/jj200584(v=vs.85).aspx

 

If you already have the debug layer enabled and it's not telling you anything helpful, then I guess it would be helpful for us to see how you create the constant buffer that you're trying to map.



#3 steven166   Members   -  Reputation: 237

Like
0Likes
Like

Posted 16 March 2014 - 09:39 PM

Samith, thank for the reply. The error message which I get as my program is stopped is "D3D11: Removing Device.

D3D11 ERROR: ID3D11Device::RemoveDevice: Device removal has been triggered for the following reason (DXGI_ERROR_DEVICE_HUNG: The Device took an unreasonable amount of time to execute its commands, or the hardware crashed/hung. As a result, the TDR (Timeout Detection and Recovery) mechanism has been triggered. The current Device Context was executing commands when the hang occurred. The application may want to respawn and fallback to less aggressive use of the display hardware). [ EXECUTION ERROR #378: DEVICE_REMOVAL_PROCESS_AT_FAULT]"

 

Do you know the exact reason?



#4 BarrySkellern   Members   -  Reputation: 754

Like
0Likes
Like

Posted 17 March 2014 - 01:19 AM

What CPU access flags and usage do you specify when you create the buffer? It's possible the map is failing because you've told DirectX not to allow you to access the buffer data after creation. Are you using CPU_ACCESS_WRITE and USAGE_DYNAMIC?

Edited by BarrySkellern, 17 March 2014 - 01:22 AM.

Visit http://www.mugsgames.com - Just released: Stroids, a retro style mini-game for Windows PC.

Mugs Games on Twitter: @MugsGames and Facebook: www.facebook.com/mugsgames

Me on Twitter @BarrySkellern

 


#5 steven166   Members   -  Reputation: 237

Like
0Likes
Like

Posted 18 March 2014 - 05:33 AM

Yes, I am using D3D11_CPU_ACCESS_WRITE for CPUAccessFlags and D3D11_USAGE_DYNAMIC for Usage.






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