Add GuestTexture::GetSize helper function

This code was getting duplicated a bit so commonise into a helper function.
This commit is contained in:
Billy Laws 2022-06-03 19:30:54 +01:00
parent 31d418ad54
commit 581a016991
4 changed files with 8 additions and 3 deletions

View File

@ -103,8 +103,7 @@ namespace skyline::gpu::interconnect {
} }
IOVA iova{surface.address}; IOVA iova{surface.address};
size_t size{texture.GetLayerStride() * (texture.layerCount - texture.baseArrayLayer)}; auto mappings{channelCtx.asCtx->gmmu.TranslateRange(iova, texture.GetSize())};
auto mappings{channelCtx.asCtx->gmmu.TranslateRange(iova, size)};
texture.mappings.assign(mappings.begin(), mappings.end()); texture.mappings.assign(mappings.begin(), mappings.end());
return texture; return texture;

View File

@ -2335,7 +2335,7 @@ namespace skyline::gpu::interconnect {
throw exception("Unsupported TIC Header Type: {}", static_cast<u32>(textureControl.headerType)); throw exception("Unsupported TIC Header Type: {}", static_cast<u32>(textureControl.headerType));
} }
auto mappings{channelCtx.asCtx->gmmu.TranslateRange(textureControl.Iova(), guest.GetLayerStride() * (guest.layerCount - guest.baseArrayLayer))}; auto mappings{channelCtx.asCtx->gmmu.TranslateRange(textureControl.Iova(), guest.GetSize())};
guest.mappings.assign(mappings.begin(), mappings.end()); guest.mappings.assign(mappings.begin(), mappings.end());
} else if (auto textureView{poolTexture.view.lock()}; textureView != nullptr) { } else if (auto textureView{poolTexture.view.lock()}; textureView != nullptr) {
// If the entry already exists and the view is still valid then we return it directly // If the entry already exists and the view is still valid then we return it directly

View File

@ -62,6 +62,10 @@ namespace skyline::gpu {
return dimensions.depth; return dimensions.depth;
} }
size_t GuestTexture::GetSize() {
return GetLayerStride() * (layerCount - baseArrayLayer);
}
TextureView::TextureView(std::shared_ptr<Texture> texture, vk::ImageViewType type, vk::ImageSubresourceRange range, texture::Format format, vk::ComponentMapping mapping) : texture(std::move(texture)), type(type), format(format), mapping(mapping), range(range) {} TextureView::TextureView(std::shared_ptr<Texture> texture, vk::ImageViewType type, vk::ImageSubresourceRange range, texture::Format format, vk::ComponentMapping mapping) : texture(std::move(texture)), type(type), format(format), mapping(mapping), range(range) {}
Texture::TextureViewStorage::TextureViewStorage(vk::ImageViewType type, texture::Format format, vk::ComponentMapping mapping, vk::ImageSubresourceRange range, vk::raii::ImageView &&vkView) : type(type), format(format), mapping(mapping), range(range), vkView(std::move(vkView)) {} Texture::TextureViewStorage::TextureViewStorage(vk::ImageViewType type, texture::Format format, vk::ComponentMapping mapping, vk::ImageSubresourceRange range, vk::raii::ImageView &&vkView) : type(type), format(format), mapping(mapping), range(range), vkView(std::move(vkView)) {}

View File

@ -281,6 +281,8 @@ namespace skyline::gpu {
u32 GetViewLayerCount() const; u32 GetViewLayerCount() const;
u32 GetViewDepth() const; u32 GetViewDepth() const;
size_t GetSize();
}; };
class TextureManager; class TextureManager;