diff --git a/src/common/rendering/vulkan/textures/vk_samplers.cpp b/src/common/rendering/vulkan/textures/vk_samplers.cpp index a7b94326a7..2a616e2931 100644 --- a/src/common/rendering/vulkan/textures/vk_samplers.cpp +++ b/src/common/rendering/vulkan/textures/vk_samplers.cpp @@ -60,9 +60,6 @@ VkTexClamp TexClamp[] ={ { VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, VK_SAMPLER_ADDRESS_MODE_REPEAT }, { VK_SAMPLER_ADDRESS_MODE_REPEAT, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE }, { VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE }, - { VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE }, - { VK_SAMPLER_ADDRESS_MODE_REPEAT, VK_SAMPLER_ADDRESS_MODE_REPEAT }, - { VK_SAMPLER_ADDRESS_MODE_REPEAT, VK_SAMPLER_ADDRESS_MODE_REPEAT } }; VkSamplerManager::VkSamplerManager(VulkanDevice *dev) @@ -86,14 +83,14 @@ void VkSamplerManager::Create() { int filter = sysCallbacks && sysCallbacks->DisableTextureFilter && sysCallbacks->DisableTextureFilter()? 0 : gl_texture_filter; - for(int i = 0; i < 7; i++) + for (int i = CLAMP_NONE; i <= CLAMP_XY; i++) { SamplerBuilder builder; builder.setMagFilter(TexFilter[filter].magFilter); builder.setMinFilter(TexFilter[filter].minFilter); builder.setAddressMode(TexClamp[i].clamp_u, TexClamp[i].clamp_v, VK_SAMPLER_ADDRESS_MODE_REPEAT); builder.setMipmapMode(TexFilter[filter].mipfilter); - if (i <= CLAMP_XY && TexFilter[filter].mipmapping) + if (TexFilter[filter].mipmapping) { builder.setAnisotropy(gl_texture_filter_anisotropic); builder.setMaxLod(100.0f); // According to the spec this value is clamped so something high makes it usable for all textures. @@ -104,11 +101,43 @@ void VkSamplerManager::Create() } mSamplers[i] = builder.create(vDevice); mSamplers[i]->SetDebugName("VkSamplerManager.mSamplers"); - } + } + { + SamplerBuilder builder; + builder.setMagFilter(TexFilter[filter].magFilter); + builder.setMinFilter(TexFilter[filter].magFilter); + builder.setAddressMode(VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, VK_SAMPLER_ADDRESS_MODE_REPEAT); + builder.setMipmapMode(VK_SAMPLER_MIPMAP_MODE_NEAREST); + builder.setMaxLod(0.25f); + mSamplers[CLAMP_XY_NOMIP] = builder.create(vDevice); + mSamplers[CLAMP_XY_NOMIP]->SetDebugName("VkSamplerManager.mSamplers"); + } + for (int i = CLAMP_NOFILTER; i <= CLAMP_NOFILTER_XY; i++) + { + SamplerBuilder builder; + builder.setMagFilter(VK_FILTER_NEAREST); + builder.setMinFilter(VK_FILTER_NEAREST); + builder.setAddressMode(TexClamp[i - CLAMP_NOFILTER].clamp_u, TexClamp[i - CLAMP_NOFILTER].clamp_v, VK_SAMPLER_ADDRESS_MODE_REPEAT); + builder.setMipmapMode(VK_SAMPLER_MIPMAP_MODE_NEAREST); + builder.setMaxLod(0.25f); + mSamplers[i] = builder.create(vDevice); + mSamplers[i]->SetDebugName("VkSamplerManager.mSamplers"); + } + // CAMTEX is repeating with texture filter and no mipmap + { + SamplerBuilder builder; + builder.setMagFilter(TexFilter[filter].magFilter); + builder.setMinFilter(TexFilter[filter].magFilter); + builder.setAddressMode(VK_SAMPLER_ADDRESS_MODE_REPEAT, VK_SAMPLER_ADDRESS_MODE_REPEAT, VK_SAMPLER_ADDRESS_MODE_REPEAT); + builder.setMipmapMode(VK_SAMPLER_MIPMAP_MODE_NEAREST); + builder.setMaxLod(0.25f); + mSamplers[CLAMP_CAMTEX] = builder.create(vDevice); + mSamplers[CLAMP_CAMTEX]->SetDebugName("VkSamplerManager.mSamplers"); + } } void VkSamplerManager::Destroy() { - for (int i = 0; i < 7; i++) + for (int i = 0; i < NUMSAMPLERS; i++) mSamplers[i].reset(); } diff --git a/src/common/rendering/vulkan/textures/vk_samplers.h b/src/common/rendering/vulkan/textures/vk_samplers.h index cd1b8462fa..59c49fbf4f 100644 --- a/src/common/rendering/vulkan/textures/vk_samplers.h +++ b/src/common/rendering/vulkan/textures/vk_samplers.h @@ -8,7 +8,7 @@ class VulkanDevice; class VkSamplerManager { VulkanDevice *vDevice; - std::unique_ptr mSamplers[7]; + std::unique_ptr mSamplers[NUMSAMPLERS]; //void UnbindAll();