2022-01-18 22:47:50 +01:00
|
|
|
#include "memory.h"
|
2020-12-24 11:49:08 +01:00
|
|
|
#include "sampler.h"
|
|
|
|
|
#include "../../rsx_utils.h"
|
|
|
|
|
|
|
|
|
|
namespace vk
|
|
|
|
|
{
|
2021-05-29 13:54:11 +02:00
|
|
|
sampler::sampler(const vk::render_device& dev, VkSamplerAddressMode clamp_u, VkSamplerAddressMode clamp_v, VkSamplerAddressMode clamp_w,
|
2020-12-24 11:49:08 +01:00
|
|
|
VkBool32 unnormalized_coordinates, float mipLodBias, float max_anisotropy, float min_lod, float max_lod,
|
|
|
|
|
VkFilter min_filter, VkFilter mag_filter, VkSamplerMipmapMode mipmap_mode, VkBorderColor border_color,
|
|
|
|
|
VkBool32 depth_compare, VkCompareOp depth_compare_mode)
|
|
|
|
|
: m_device(dev)
|
|
|
|
|
{
|
|
|
|
|
info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
|
|
|
|
info.addressModeU = clamp_u;
|
|
|
|
|
info.addressModeV = clamp_v;
|
|
|
|
|
info.addressModeW = clamp_w;
|
2021-05-29 13:54:11 +02:00
|
|
|
info.anisotropyEnable = dev.get_anisotropic_filtering_support();
|
2020-12-24 11:49:08 +01:00
|
|
|
info.compareEnable = depth_compare;
|
|
|
|
|
info.unnormalizedCoordinates = unnormalized_coordinates;
|
|
|
|
|
info.mipLodBias = mipLodBias;
|
|
|
|
|
info.maxAnisotropy = max_anisotropy;
|
|
|
|
|
info.maxLod = max_lod;
|
|
|
|
|
info.minLod = min_lod;
|
|
|
|
|
info.magFilter = mag_filter;
|
|
|
|
|
info.minFilter = min_filter;
|
|
|
|
|
info.mipmapMode = mipmap_mode;
|
|
|
|
|
info.compareOp = depth_compare_mode;
|
|
|
|
|
info.borderColor = border_color;
|
|
|
|
|
|
|
|
|
|
CHECK_RESULT(vkCreateSampler(m_device, &info, nullptr, &value));
|
2022-01-18 22:47:50 +01:00
|
|
|
vmm_notify_object_allocated(VMM_ALLOCATION_POOL_SAMPLER);
|
2020-12-24 11:49:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sampler::~sampler()
|
|
|
|
|
{
|
|
|
|
|
vkDestroySampler(m_device, value, nullptr);
|
2022-01-18 22:47:50 +01:00
|
|
|
vmm_notify_object_freed(VMM_ALLOCATION_POOL_SAMPLER);
|
2020-12-24 11:49:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool sampler::matches(VkSamplerAddressMode clamp_u, VkSamplerAddressMode clamp_v, VkSamplerAddressMode clamp_w,
|
|
|
|
|
VkBool32 unnormalized_coordinates, float mipLodBias, float max_anisotropy, float min_lod, float max_lod,
|
|
|
|
|
VkFilter min_filter, VkFilter mag_filter, VkSamplerMipmapMode mipmap_mode, VkBorderColor border_color,
|
|
|
|
|
VkBool32 depth_compare, VkCompareOp depth_compare_mode)
|
|
|
|
|
{
|
|
|
|
|
if (info.magFilter != mag_filter || info.minFilter != min_filter || info.mipmapMode != mipmap_mode ||
|
|
|
|
|
info.addressModeU != clamp_u || info.addressModeV != clamp_v || info.addressModeW != clamp_w ||
|
|
|
|
|
info.compareEnable != depth_compare || info.unnormalizedCoordinates != unnormalized_coordinates ||
|
|
|
|
|
!rsx::fcmp(info.maxLod, max_lod) || !rsx::fcmp(info.mipLodBias, mipLodBias) || !rsx::fcmp(info.minLod, min_lod) ||
|
|
|
|
|
!rsx::fcmp(info.maxAnisotropy, max_anisotropy) ||
|
|
|
|
|
info.compareOp != depth_compare_mode || info.borderColor != border_color)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|