We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4913

Summary: Direct3D11 D3D11_UpdateVertexBuffer does not bind VBO when an already created VBO is used
Product: SDL Reporter: Konrad <iryont>
Component: renderAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: blocker    
Priority: P2 Keywords: target-2.0.12
Version: HG 2.1   
Hardware: x86_64   
OS: Windows 10   
Attachments: Patch

Description Konrad 2019-12-22 16:27:37 UTC
After this patch:

https://hg.libsdl.org/SDL/rev/44b0a095f4b7

I did notice "flickering" of my game with Direct3D 11 renderer and looks like this:

https://hg.libsdl.org/SDL/rev/44b0a095f4b7

It was not the case when the VB was recreated each time it was being updated (prior to fix in 2.0.11).

I believe this bug happens because the vertex buffer is bigger than the data (dataSizeInBytes) we are currently drawing, thus some random stuff is popping up here and there because the whole buffer is drawn.

I will check whether I can find an easy fix for this though.
Comment 1 Konrad 2019-12-22 16:35:13 UTC
My bad, here is the video:

https://www.youtube.com/watch?v=hIu01zdC8hc
Comment 2 Konrad 2019-12-22 18:42:52 UTC
Geez, I'm seriously blind. The vertex buffer isn't bound with ID3D11DeviceContext_IASetVertexBuffers.

https://docs.microsoft.com/en-us/windows/win32/api/d3d11/nf-d3d11-id3d11devicecontext-iasetvertexbuffers

It is only done when vertex buffer is created and that is why it worked before, but it should always be bound after being updated.
Comment 3 Konrad 2019-12-22 20:02:35 UTC
Created attachment 4135 [details]
Patch

Here is the patch for fixing this issue. Vertex buffer is now always bind when used.
Comment 4 Ryan C. Gordon 2019-12-23 01:49:33 UTC
Good catch, this patch is now https://hg.libsdl.org/SDL/rev/d5b022b3511c, thanks!

--ryan.