From f9768816515e3c385c3b9812a3f6f64384f9dfa9 Mon Sep 17 00:00:00 2001 From: David Gow Date: Sat, 24 Feb 2024 22:06:38 +0800 Subject: [PATCH] Vulkan: Don't invalidate internal state in InvalidateCachedState The VULKAN_InvalidateCachedState() function seems to be meant to invalidate any _cached_ state, i.e. global state of the API which may have been modified outside the renderer. However, at the moment, the Vulkan renderer also resets a number of internal variables which track buffers, offsets, etc, in use. As a result, the renderer can get into an inconsistant state and/or lose data. For example, if VULKAN_InvalidateCachedState() is called in between two calls to VULKAN_UpdateVertexBuffer(), the data from the first call will be overwritten by that from the second, as the number of the next vertex buffer to use will be reset to 0. This can result in rendering errors, as the same vertex data is used incorrectly for several calls. By no longer resetting this 'internal' state here, those glitches disappear. However, I haven't tested this with any applications which mix the Vulkan renderer with their own Vulkan code (do any such applications exist?), so this may be insufficient in case a full flush of the renderer state -- and possibly a wait on the appropriate fence -- could be required. Signed-off-by: David Gow --- src/render/vulkan/SDL_render_vulkan.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/render/vulkan/SDL_render_vulkan.c b/src/render/vulkan/SDL_render_vulkan.c index d374f4fb23..698e249bba 100644 --- a/src/render/vulkan/SDL_render_vulkan.c +++ b/src/render/vulkan/SDL_render_vulkan.c @@ -3372,11 +3372,7 @@ static void VULKAN_InvalidateCachedState(SDL_Renderer *renderer) { VULKAN_RenderData *rendererData = (VULKAN_RenderData *)renderer->driverdata; rendererData->currentPipelineState = NULL; - rendererData->currentVertexBuffer = 0; - rendererData->issueBatch = SDL_FALSE; rendererData->cliprectDirty = SDL_TRUE; - rendererData->currentDescriptorSetIndex = 0; - rendererData->currentConstantBufferOffset = 0; } static int VULKAN_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)