vulkan: fix incorrect samplers

This commit is contained in:
niki
2022-09-19 19:51:48 +02:00
parent fe8cbfecbf
commit 58c801be58
3 changed files with 9 additions and 9 deletions
+5 -5
View File
@@ -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<float>(samplerState.minLod);
@@ -2574,14 +2573,15 @@ std::set<Shader*> &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;
}
+2 -2
View File
@@ -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<Shader*> &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;
+2 -2
View File
@@ -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