From ffef628667e656fd9d48fc6e8fb2e9a04cd3eb86 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 1 May 2016 16:25:09 -0700 Subject: [PATCH] Vulkan: Move ApplyTexture after vert decode. --- GPU/Vulkan/DrawEngineVulkan.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index e2e1f0911f..410861a168 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -602,19 +602,16 @@ void DrawEngineVulkan::DoFlush(VkCommandBuffer cmd) { FrameData *frame = &frame_[curFrame_ & 1]; + bool textureNeedsApply = false; if (gstate_c.textureChanged != TEXCHANGE_UNCHANGED && !gstate.isModeClear() && gstate.isTextureMapEnabled()) { textureCache_->SetTexture(frame->pushUBO); + textureNeedsApply = true; gstate_c.textureChanged = TEXCHANGE_UNCHANGED; if (gstate_c.needShaderTexClamp) { // We will rarely need to set this, so let's do it every time on use rather than in runloop. // Most of the time non-framebuffer textures will be used which can be clamped themselves. shaderManager_->DirtyUniform(DIRTY_TEXCLAMP); } - textureCache_->ApplyTexture(imageView, sampler); - if (imageView == VK_NULL_HANDLE) - imageView = nullTexture_->GetImageView(); - if (sampler == VK_NULL_HANDLE) - sampler = nullSampler_; } GEPrimitiveType prim = prevPrim_; @@ -651,6 +648,14 @@ void DrawEngineVulkan::DoFlush(VkCommandBuffer cmd) { gstate_c.vertexFullAlpha = gstate_c.vertexFullAlpha && ((hasColor && (gstate.materialupdate & 1)) || gstate.getMaterialAmbientA() == 255) && (!gstate.isLightingEnabled() || gstate.getAmbientA() == 255); } + if (textureNeedsApply) { + textureCache_->ApplyTexture(imageView, sampler); + if (imageView == VK_NULL_HANDLE) + imageView = nullTexture_->GetImageView(); + if (sampler == VK_NULL_HANDLE) + sampler = nullSampler_; + } + VulkanPipelineRasterStateKey pipelineKey; VulkanDynamicState dynState; ConvertStateToVulkanKey(*framebufferManager_, shaderManager_, prim, pipelineKey, dynState); @@ -743,6 +748,14 @@ void DrawEngineVulkan::DoFlush(VkCommandBuffer cmd) { // Only here, where we know whether to clear or to draw primitives, should we actually set the current framebuffer! Because that gives use the opportunity // to use a "pre-clear" render pass, for high efficiency on tilers. if (result.action == SW_DRAW_PRIMITIVES) { + if (textureNeedsApply) { + textureCache_->ApplyTexture(imageView, sampler); + if (imageView == VK_NULL_HANDLE) + imageView = nullTexture_->GetImageView(); + if (sampler == VK_NULL_HANDLE) + sampler = nullSampler_; + } + VulkanPipelineRasterStateKey pipelineKey; VulkanDynamicState dynState; ConvertStateToVulkanKey(*framebufferManager_, shaderManager_, prim, pipelineKey, dynState);