|
|
|
@ -2314,6 +2314,7 @@ vk::ImageView ImageView::MakeView(VkFormat vk_format, VkImageAspectFlags aspect_ |
|
|
|
|
|
|
|
Sampler::Sampler(TextureCacheRuntime& runtime, const Tegra::Texture::TSCEntry& tsc) { |
|
|
|
const auto& device = runtime.device; |
|
|
|
has_depth_compare = tsc.depth_compare_enabled != 0; |
|
|
|
// Check if custom border colors are supported
|
|
|
|
const bool has_custom_border_colors = runtime.device.IsCustomBorderColorsSupported(); |
|
|
|
const bool has_format_undefined = runtime.device.IsCustomBorderColorWithoutFormatSupported(); |
|
|
|
@ -2354,7 +2355,7 @@ Sampler::Sampler(TextureCacheRuntime& runtime, const Tegra::Texture::TSCEntry& t |
|
|
|
// Some games have samplers with garbage. Sanitize them here.
|
|
|
|
const f32 max_anisotropy = std::clamp(tsc.MaxAnisotropy(), 1.0f, 16.0f); |
|
|
|
|
|
|
|
const auto create_sampler = [&](const f32 anisotropy) { |
|
|
|
const auto create_sampler = [&](const f32 anisotropy, bool enable_depth_compare) { |
|
|
|
return device.GetLogical().CreateSampler(VkSamplerCreateInfo{ |
|
|
|
.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, |
|
|
|
.pNext = pnext, |
|
|
|
@ -2368,7 +2369,7 @@ Sampler::Sampler(TextureCacheRuntime& runtime, const Tegra::Texture::TSCEntry& t |
|
|
|
.mipLodBias = tsc.LodBias(), |
|
|
|
.anisotropyEnable = static_cast<VkBool32>(anisotropy > 1.0f ? VK_TRUE : VK_FALSE), |
|
|
|
.maxAnisotropy = anisotropy, |
|
|
|
.compareEnable = tsc.depth_compare_enabled, |
|
|
|
.compareEnable = enable_depth_compare, |
|
|
|
.compareOp = MaxwellToVK::Sampler::DepthCompareFunction(tsc.depth_compare_func), |
|
|
|
.minLod = tsc.mipmap_filter == TextureMipmapFilter::None ? 0.0f : tsc.MinLod(), |
|
|
|
.maxLod = tsc.mipmap_filter == TextureMipmapFilter::None ? 0.25f : tsc.MaxLod(), |
|
|
|
@ -2378,11 +2379,18 @@ Sampler::Sampler(TextureCacheRuntime& runtime, const Tegra::Texture::TSCEntry& t |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
sampler = create_sampler(max_anisotropy); |
|
|
|
sampler = create_sampler(max_anisotropy, has_depth_compare); |
|
|
|
if (has_depth_compare) { |
|
|
|
sampler_no_compare = create_sampler(max_anisotropy, false); |
|
|
|
} |
|
|
|
|
|
|
|
const f32 max_anisotropy_default = static_cast<f32>(1U << tsc.max_anisotropy); |
|
|
|
if (max_anisotropy > max_anisotropy_default) { |
|
|
|
sampler_default_anisotropy = create_sampler(max_anisotropy_default); |
|
|
|
sampler_default_anisotropy = create_sampler(max_anisotropy_default, has_depth_compare); |
|
|
|
if (has_depth_compare) { |
|
|
|
sampler_default_anisotropy_no_compare = |
|
|
|
create_sampler(max_anisotropy_default, false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|