Implement Mipmapped Texture Support

Support for mipmapped textures was not implemented which is fairly crucial to proper rendering of games as the only level that would load is the first level (highest resolution), that might result in a lot more memory bandwidth being utilized. Mipmapping also has associated benefits regarding aliasing as it has a minor anti-aliasing effect on distant textures. 

This commit entirely implements mipmapping support but it does not extend to full support for views into specific mipmap levels due to the texture manager implemention being incomplete.
This commit is contained in:
PixelyIon
2022-05-28 20:27:17 +05:30
parent da7e6a7df7
commit 7d4e0a7844
7 changed files with 253 additions and 68 deletions

View File

@ -45,11 +45,12 @@ namespace skyline::gpu {
if (firstHostMapping == hostMappings.begin() && firstHostMapping->begin() == guestMapping.begin() && mappingMatch && lastHostMapping == hostMappings.end() && lastGuestMapping.end() == std::prev(lastHostMapping)->end()) {
// We've gotten a perfect 1:1 match for *all* mappings from the start to end, we just need to check for compatibility aside from this
auto &matchGuestTexture{*hostMapping->texture->guest};
if (matchGuestTexture.format->IsCompatible(*guestTexture.format) && matchGuestTexture.dimensions == guestTexture.dimensions && matchGuestTexture.tileConfig == guestTexture.tileConfig) {
if (matchGuestTexture.format->IsCompatible(*guestTexture.format) && (matchGuestTexture.dimensions == guestTexture.dimensions || matchGuestTexture.viewMipBase > 0) && matchGuestTexture.tileConfig == guestTexture.tileConfig) {
auto &texture{hostMapping->texture};
return texture->GetView(static_cast<vk::ImageViewType>(guestTexture.type), vk::ImageSubresourceRange{
.aspectMask = guestTexture.aspect,
.levelCount = texture->mipLevels,
.baseMipLevel = guestTexture.viewMipBase,
.levelCount = guestTexture.viewMipCount,
.layerCount = texture->layerCount,
}, guestTexture.format, guestTexture.swizzle);
}
@ -81,7 +82,8 @@ namespace skyline::gpu {
return texture->GetView(static_cast<vk::ImageViewType>(guestTexture.type), vk::ImageSubresourceRange{
.aspectMask = guestTexture.aspect,
.levelCount = texture->mipLevels,
.baseMipLevel = guestTexture.viewMipBase,
.levelCount = guestTexture.viewMipCount,
.layerCount = texture->layerCount,
}, guestTexture.format, guestTexture.swizzle);
}