Move image type logic to GuestTexture, allowing 2D array views for 3D RTs

We can't render to a 3D texture through a 3D view, we instead have to create a 2D array view into it and render to that. The texture manager previously didn't support having a different view type/layer count between a guest texture view and the underlying storage texture that is required to support this so that was also implemented by reading the view layer count from the dimensions depth instead if the underlying texture is 3D (and the view type is 2D array). Additionally move away from our own view type enum to Vulkan, inline with other guest texture member types.
This commit is contained in:
Billy Laws
2022-05-31 22:09:53 +01:00
parent 22695c4feb
commit c745e0e02b
6 changed files with 77 additions and 61 deletions

View File

@ -45,13 +45,18 @@ 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.viewMipBase > 0) && matchGuestTexture.tileConfig == guestTexture.tileConfig) {
if (matchGuestTexture.format->IsCompatible(*guestTexture.format) &&
((matchGuestTexture.dimensions.width == guestTexture.dimensions.width &&
matchGuestTexture.dimensions.height == guestTexture.dimensions.height &&
matchGuestTexture.dimensions.depth == guestTexture.GetViewDepth())
|| matchGuestTexture.viewMipBase > 0)
&& matchGuestTexture.tileConfig == guestTexture.tileConfig) {
auto &texture{hostMapping->texture};
return texture->GetView(static_cast<vk::ImageViewType>(guestTexture.type), vk::ImageSubresourceRange{
return texture->GetView(guestTexture.viewType, vk::ImageSubresourceRange{
.aspectMask = guestTexture.aspect,
.baseMipLevel = guestTexture.viewMipBase,
.levelCount = guestTexture.viewMipCount,
.layerCount = texture->layerCount,
.layerCount = guestTexture.GetViewLayerCount(),
}, guestTexture.format, guestTexture.swizzle);
}
} /* else if (mappingMatch) {
@ -80,11 +85,11 @@ namespace skyline::gpu {
textures.emplace(mapping, TextureMapping{texture, it, guestMapping});
}
return texture->GetView(static_cast<vk::ImageViewType>(guestTexture.type), vk::ImageSubresourceRange{
return texture->GetView(guestTexture.viewType, vk::ImageSubresourceRange{
.aspectMask = guestTexture.aspect,
.baseMipLevel = guestTexture.viewMipBase,
.levelCount = guestTexture.viewMipCount,
.layerCount = texture->layerCount,
.layerCount = guestTexture.GetViewLayerCount(),
}, guestTexture.format, guestTexture.swizzle);
}
}