Jump to content
  • Advertisement

DX11 Strange setbuffer->map->unmap->draw issue

Recommended Posts

Hi all.

I came across an issue today with the D3D11DeviceContext->Draw method. In a nutshell, after hours of pulling out what little hair I have left...  I was able to find out the that if I did the following:

  1. set the vertex buffer
  2. map the vertex buffer
  3. update the vertex buffer contents
  4. unmap the vertex buffer
  5. use the context->Draw method to draw some lines
  6. repeat 2 to 5 multiple times

then the gpu didn't actually calculate the output vertices correctly. In RenderDoc I can see that the map update did succeed as the vertex buffer contents are changing, however the output vertex positions would all be the same values as if the gpu was only using just the first piece of mapped data. Rather strange for a state machine. So I tried this order:

  1. map the vertex buffer
  2. update the vertex buffer
  3. unmap the vertex buffer
  4. set the vertex buffer
  5. context->Draw
  6. repeat 1 to 5 multiple times

and everything is drawing as expected.
Is this normal/expected or could this some kind of bug?

Share this post

Link to post
Share on other sites

I'm not sure if it's a "bug" or not, however I would never think of doing it the first way. I mean IASetVertexBuffers and IASetIndexBuffer are part of the draw sequence and I would assume you have to complete building your buffers before calling those. I'm far from an expert on DX11 however so maybe someone else can give you better information.

Share this post

Link to post
Share on other sites

Im using DISCARD in the map flags. The funny thing is that RenderDoc show the map updates are successful. RenderDoc shows the output of the vertex shader as incorrect... which is kind of correct because the output is indeed incorrect.

Share this post

Link to post
Share on other sites

Hmm, using WARP all I get is a white screen.

I've just updated the driver to the latest NVidia one and the issue is exactly the same. The GPU is an NVidia 750Ti. I'm also using Win10.

OMG Sorry everyone, it's amazing what some sleep does for the mind. I had the buffer set up incorrectly. I thought I had the debug layer on but it turns out that I didn't. I corrected the buffer set up and everything is working fine even using WARP.

Edited by 0xnullptr

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!