Advertisement

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

Started by July 12, 2019 10:10 AM
5 comments, last by 0xnullptr 5 years, 6 months ago

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?

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.

Advertisement

I think the first way should be OK, although it's a been a long while since I had to wrangle D3D directly... What are your map flags? 

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.

Sounds like a driver issue to me. Have you tried on multiple drivers? Maybe try WARP and see if that works correctly?

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.

This topic is closed to new replies.

Advertisement