From 58c801be58ebd6c571cee14c24e3bcbe88344342 Mon Sep 17 00:00:00 2001 From: niki Date: Mon, 19 Sep 2022 19:51:48 +0200 Subject: [PATCH] vulkan: fix incorrect samplers --- src/modules/graphics/vulkan/Graphics.cpp | 10 +++++----- src/modules/graphics/vulkan/Graphics.h | 4 ++-- src/modules/graphics/vulkan/Texture.cpp | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/modules/graphics/vulkan/Graphics.cpp b/src/modules/graphics/vulkan/Graphics.cpp index 968baf009..7050edc93 100644 --- a/src/modules/graphics/vulkan/Graphics.cpp +++ b/src/modules/graphics/vulkan/Graphics.cpp @@ -2495,10 +2495,8 @@ void Graphics::endRenderPass() Vulkan::cmdTransitionImageLayout(commandBuffers.at(currentFrame), image, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); } -VkSampler Graphics::createSampler(uint64 samplerKey) +VkSampler Graphics::createSampler(const SamplerState &samplerState) { - auto samplerState = SamplerState::fromKey(samplerKey); - VkSamplerCreateInfo samplerInfo{}; samplerInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; samplerInfo.magFilter = Vulkan::getFilter(samplerState.magFilter); @@ -2520,6 +2518,7 @@ VkSampler Graphics::createSampler(uint64 samplerKey) samplerInfo.compareEnable = VK_FALSE; samplerInfo.compareOp = VK_COMPARE_OP_ALWAYS; } + samplerInfo.compareEnable = VK_FALSE; samplerInfo.mipmapMode = Vulkan::getMipMapMode(samplerState.mipmapFilter); samplerInfo.mipLodBias = samplerState.lodBias; samplerInfo.minLod = static_cast(samplerState.minLod); @@ -2574,14 +2573,15 @@ std::set &Graphics::getUsedShadersInFrame() return usedShadersInFrame; } -VkSampler Graphics::getCachedSampler(uint64 samplerkey) +VkSampler Graphics::getCachedSampler(const SamplerState &samplerState) { + auto samplerkey = samplerState.toKey(); auto it = samplers.find(samplerkey); if (it != samplers.end()) return it->second; else { - VkSampler sampler = createSampler(samplerkey); + VkSampler sampler = createSampler(samplerState); samplers.insert({ samplerkey, sampler }); return sampler; } diff --git a/src/modules/graphics/vulkan/Graphics.h b/src/modules/graphics/vulkan/Graphics.h index e49f44d41..e9fc5c492 100644 --- a/src/modules/graphics/vulkan/Graphics.h +++ b/src/modules/graphics/vulkan/Graphics.h @@ -308,7 +308,7 @@ public: uint32_t getFrameIndex() const; const VkDeviceSize getMinUniformBufferOffsetAlignment() const; graphics::Texture *getDefaultTexture() const; - VkSampler getCachedSampler(uint64); + VkSampler getCachedSampler(const SamplerState &sampler); void setComputeShader(Shader *computeShader); std::set &getUsedShadersInFrame(); graphics::Shader::BuiltinUniformData getCurrentBuiltinUniformData(); @@ -379,7 +379,7 @@ private: void setDefaultRenderPass(); void startRenderPass(); void endRenderPass(); - VkSampler createSampler(uint64 samplerKey); + VkSampler createSampler(const SamplerState &sampler); void cleanupUnusedObjects(); uint32_t vulkanApiVersion = VK_VERSION_1_0; diff --git a/src/modules/graphics/vulkan/Texture.cpp b/src/modules/graphics/vulkan/Texture.cpp index 0178cf183..1d28b62a0 100644 --- a/src/modules/graphics/vulkan/Texture.cpp +++ b/src/modules/graphics/vulkan/Texture.cpp @@ -152,7 +152,7 @@ bool Texture::loadVolatile() clear(); createTextureImageView(); - textureSampler = vgfx->getCachedSampler(samplerState.toKey()); + textureSampler = vgfx->getCachedSampler(samplerState); if (!isPixelFormatDepthStencil(format) && mipmapCount > 1 && getMipmapsMode() != MIPMAPS_NONE) generateMipmaps(); @@ -251,7 +251,7 @@ void Texture::setSamplerState(const SamplerState &s) { love::graphics::Texture::setSamplerState(s); - textureSampler = vgfx->getCachedSampler(s.toKey()); + textureSampler = vgfx->getCachedSampler(s); } VkImageLayout Texture::getImageLayout() const