Jump to content
  • Advertisement
Sign in to follow this  
Juliean

"Don't read from a subresource mapped for writing" ...

This topic is 536 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

At least thats what MSDN tells you for mapping DX11-resources (https://msdn.microsoft.com/en-us/library/windows/desktop/ff476457(v=vs.85).aspx).

 

Now, how hard can this really be? I mean, why would I read from a buffer that I only intend on writing to? Thats just ridiculous (discount the example about generated assembly).

 

Then theres this:

SpriteVertex* pBuffer = m_pMapped + m_nextFreeID;

pBuffer->leftPos = vPosition.x;
pBuffer->rightPos = pBuffer->leftPos + vSize.x;
pBuffer->topPos = -vPosition.y;
pBuffer->bottomPos = -pBuffer->rightPos - vSize.y;

You should probably be able to spot the problem right away, but I had this exact code for over 2(!) years, until my profiler recently showed a decent amount of time spent on those two lines. Quess DRY is not always your best bet. :/

 

Did you fall for something similar?

Share this post


Link to post
Share on other sites
Advertisement

Mines not a bug, but a massive performance hit.....

 

I had this set on a GPU only texture.

 

D3D11.CpuAccessFlags.Write 

 

Wondered why my frame rate dipped by 25%.....

Share this post


Link to post
Share on other sites

Thats just ridiculous (discount the example about generated assembly).

 

It gets worse:  https://fgiesen.wordpress.com/2013/01/29/write-combining-is-not-your-friend/

 

There's a couple of additional strong recommendations:  Always write sequentially, and don't leave any holes.  IIRC violating the latter rule can even result in a cacheline read by the CPU on at least one arch - although I can't find a proper source/docs for that.

 

My golden rule now is:  Always use memcpy.  Always.  For the entire buffer.  *Always*.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!