direct3d11: Always set vertex buffers when updating them (thanks, Konrad!). Fixes Bugzilla #4913.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c
index 7ae0d02..bcd7b86 100644
--- a/src/render/direct3d11/SDL_render_d3d11.c
+++ b/src/render/direct3d11/SDL_render_d3d11.c
@@ -1835,6 +1835,8 @@ D3D11_UpdateVertexBuffer(SDL_Renderer *renderer,
D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
HRESULT result = S_OK;
const int vbidx = rendererData->currentVertexBuffer;
+ const UINT stride = sizeof(VertexPositionColor);
+ const UINT offset = 0;
if (dataSizeInBytes == 0) {
return 0; /* nothing to do. */
@@ -1858,8 +1860,6 @@ D3D11_UpdateVertexBuffer(SDL_Renderer *renderer,
} else {
D3D11_BUFFER_DESC vertexBufferDesc;
D3D11_SUBRESOURCE_DATA vertexBufferData;
- const UINT stride = sizeof(VertexPositionColor);
- const UINT offset = 0;
SAFE_RELEASE(rendererData->vertexBuffers[vbidx]);
@@ -1885,16 +1885,16 @@ D3D11_UpdateVertexBuffer(SDL_Renderer *renderer,
}
rendererData->vertexBufferSizes[vbidx] = dataSizeInBytes;
-
- ID3D11DeviceContext_IASetVertexBuffers(rendererData->d3dContext,
- 0,
- 1,
- &rendererData->vertexBuffers[vbidx],
- &stride,
- &offset
- );
}
+ ID3D11DeviceContext_IASetVertexBuffers(rendererData->d3dContext,
+ 0,
+ 1,
+ &rendererData->vertexBuffers[vbidx],
+ &stride,
+ &offset
+ );
+
rendererData->currentVertexBuffer++;
if (rendererData->currentVertexBuffer >= SDL_arraysize(rendererData->vertexBuffers)) {
rendererData->currentVertexBuffer = 0;