maxwell_to_vk: Approach GL_CLAMP closer to the GL spec
The OpenGL spec defines GL_CLAMP's formula similarly to CLAMP_TO_EDGE and CLAMP_TO_BORDER depending on the filter mode used. It doesn't exactly behave like this, but it's the closest we can get with what Vulkan offers without emulating it by injecting shader code.
This commit is contained in:
parent
f845df8651
commit
15513f0801
@ -44,7 +44,8 @@ vk::SamplerMipmapMode MipmapMode(Tegra::Texture::TextureMipmapFilter mipmap_filt
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
vk::SamplerAddressMode WrapMode(Tegra::Texture::WrapMode wrap_mode) {
|
vk::SamplerAddressMode WrapMode(Tegra::Texture::WrapMode wrap_mode,
|
||||||
|
Tegra::Texture::TextureFilter filter) {
|
||||||
switch (wrap_mode) {
|
switch (wrap_mode) {
|
||||||
case Tegra::Texture::WrapMode::Wrap:
|
case Tegra::Texture::WrapMode::Wrap:
|
||||||
return vk::SamplerAddressMode::eRepeat;
|
return vk::SamplerAddressMode::eRepeat;
|
||||||
@ -55,10 +56,15 @@ vk::SamplerAddressMode WrapMode(Tegra::Texture::WrapMode wrap_mode) {
|
|||||||
case Tegra::Texture::WrapMode::Border:
|
case Tegra::Texture::WrapMode::Border:
|
||||||
return vk::SamplerAddressMode::eClampToBorder;
|
return vk::SamplerAddressMode::eClampToBorder;
|
||||||
case Tegra::Texture::WrapMode::Clamp:
|
case Tegra::Texture::WrapMode::Clamp:
|
||||||
// TODO(Rodrigo): GL_CLAMP was removed as of OpenGL 3.1, to implement GL_CLAMP, we can use
|
// TODO(Rodrigo): Emulate GL_CLAMP properly
|
||||||
// eClampToBorder to get the border color of the texture, and then sample the edge to
|
switch (filter) {
|
||||||
// manually mix them. However the shader part of this is not yet implemented.
|
case Tegra::Texture::TextureFilter::Nearest:
|
||||||
|
return vk::SamplerAddressMode::eClampToEdge;
|
||||||
|
case Tegra::Texture::TextureFilter::Linear:
|
||||||
return vk::SamplerAddressMode::eClampToBorder;
|
return vk::SamplerAddressMode::eClampToBorder;
|
||||||
|
}
|
||||||
|
UNREACHABLE();
|
||||||
|
return vk::SamplerAddressMode::eClampToEdge;
|
||||||
case Tegra::Texture::WrapMode::MirrorOnceClampToEdge:
|
case Tegra::Texture::WrapMode::MirrorOnceClampToEdge:
|
||||||
return vk::SamplerAddressMode::eMirrorClampToEdge;
|
return vk::SamplerAddressMode::eMirrorClampToEdge;
|
||||||
case Tegra::Texture::WrapMode::MirrorOnceBorder:
|
case Tegra::Texture::WrapMode::MirrorOnceBorder:
|
||||||
|
@ -23,7 +23,8 @@ vk::Filter Filter(Tegra::Texture::TextureFilter filter);
|
|||||||
|
|
||||||
vk::SamplerMipmapMode MipmapMode(Tegra::Texture::TextureMipmapFilter mipmap_filter);
|
vk::SamplerMipmapMode MipmapMode(Tegra::Texture::TextureMipmapFilter mipmap_filter);
|
||||||
|
|
||||||
vk::SamplerAddressMode WrapMode(Tegra::Texture::WrapMode wrap_mode);
|
vk::SamplerAddressMode WrapMode(Tegra::Texture::WrapMode wrap_mode,
|
||||||
|
Tegra::Texture::TextureFilter filter);
|
||||||
|
|
||||||
vk::CompareOp DepthCompareFunction(Tegra::Texture::DepthCompareFunc depth_compare_func);
|
vk::CompareOp DepthCompareFunction(Tegra::Texture::DepthCompareFunc depth_compare_func);
|
||||||
|
|
||||||
|
@ -46,9 +46,10 @@ UniqueSampler VKSamplerCache::CreateSampler(const Tegra::Texture::TSCEntry& tsc)
|
|||||||
{}, MaxwellToVK::Sampler::Filter(tsc.mag_filter),
|
{}, MaxwellToVK::Sampler::Filter(tsc.mag_filter),
|
||||||
MaxwellToVK::Sampler::Filter(tsc.min_filter),
|
MaxwellToVK::Sampler::Filter(tsc.min_filter),
|
||||||
MaxwellToVK::Sampler::MipmapMode(tsc.mipmap_filter),
|
MaxwellToVK::Sampler::MipmapMode(tsc.mipmap_filter),
|
||||||
MaxwellToVK::Sampler::WrapMode(tsc.wrap_u), MaxwellToVK::Sampler::WrapMode(tsc.wrap_v),
|
MaxwellToVK::Sampler::WrapMode(tsc.wrap_u, tsc.mag_filter),
|
||||||
MaxwellToVK::Sampler::WrapMode(tsc.wrap_p), tsc.GetLodBias(), has_anisotropy,
|
MaxwellToVK::Sampler::WrapMode(tsc.wrap_v, tsc.mag_filter),
|
||||||
max_anisotropy, tsc.depth_compare_enabled,
|
MaxwellToVK::Sampler::WrapMode(tsc.wrap_p, tsc.mag_filter), tsc.GetLodBias(),
|
||||||
|
has_anisotropy, max_anisotropy, tsc.depth_compare_enabled,
|
||||||
MaxwellToVK::Sampler::DepthCompareFunction(tsc.depth_compare_func), tsc.GetMinLod(),
|
MaxwellToVK::Sampler::DepthCompareFunction(tsc.depth_compare_func), tsc.GetMinLod(),
|
||||||
tsc.GetMaxLod(), vk_border_color.value_or(vk::BorderColor::eFloatTransparentBlack),
|
tsc.GetMaxLod(), vk_border_color.value_or(vk::BorderColor::eFloatTransparentBlack),
|
||||||
unnormalized_coords);
|
unnormalized_coords);
|
||||||
|
Loading…
Reference in New Issue
Block a user