show title splash while the game is loading

This commit is contained in:
georgemoralis
2024-05-16 16:58:14 +03:00
parent 55855b4195
commit c9b5b5e963
14 changed files with 8147 additions and 12 deletions

View File

@@ -2,6 +2,9 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/config.h"
#include "common/singleton.h"
#include "core/file_format/splash.h"
#include "core/libraries/system/systemservice.h"
#include "sdl_window.h"
#include "video_core/renderer_vulkan/renderer_vulkan.h"
@@ -157,10 +160,38 @@ void RendererVulkan::RecreateFrame(Frame* frame, u32 width, u32 height) {
frame->height = height;
}
bool RendererVulkan::ShowSplash(Frame* frame /*= nullptr*/) {
if (!Libraries::SystemService::IsSplashVisible()) {
return false;
}
if (!frame) {
const auto* splash = Common::Singleton<Splash>::Instance();
VideoCore::ImageInfo info{};
info.pixel_format = vk::Format::eR8G8B8A8Srgb;
info.type = vk::ImageType::e2D;
info.size =
VideoCore::Extent3D{splash->GetImageInfo().width, splash->GetImageInfo().height, 1};
info.pitch = splash->GetImageInfo().width * 4;
info.guest_size_bytes = splash->GetImageData().size();
auto& image = texture_cache.FindImage(info, VAddr(splash->GetImageData().data()));
frame = PrepareFrameInternal(image);
}
Present(frame);
return true;
}
Frame* RendererVulkan::PrepareFrame(const Libraries::VideoOut::BufferAttributeGroup& attribute,
VAddr cpu_address) {
// Request presentation image from the texture cache.
auto& image = texture_cache.FindDisplayBuffer(attribute, cpu_address);
const auto info = VideoCore::ImageInfo{attribute};
auto& image = texture_cache.FindImage(info, cpu_address);
return PrepareFrameInternal(image);
}
Frame* RendererVulkan::PrepareFrameInternal(VideoCore::Image& image) {
// Request a free presentation frame.
Frame* frame = GetRenderFrame();

View File

@@ -34,10 +34,12 @@ public:
Frame* PrepareFrame(const Libraries::VideoOut::BufferAttributeGroup& attribute,
VAddr cpu_address);
bool ShowSplash(Frame* frame = nullptr);
void Present(Frame* frame);
void RecreateFrame(Frame* frame, u32 width, u32 height);
private:
Frame* PrepareFrameInternal(VideoCore::Image& image);
Frame* GetRenderFrame();
private:

View File

@@ -101,20 +101,19 @@ void TextureCache::OnCpuWrite(VAddr address) {
});
}
Image& TextureCache::FindDisplayBuffer(const Libraries::VideoOut::BufferAttributeGroup& group,
VAddr cpu_address) {
Image& TextureCache::FindImage(const ImageInfo& info, VAddr cpu_address) {
boost::container::small_vector<ImageId, 2> image_ids;
ForEachImageInRegion(cpu_address, group.size_in_bytes, [&](ImageId image_id, Image& image) {
ForEachImageInRegion(cpu_address, info.guest_size_bytes, [&](ImageId image_id, Image& image) {
if (image.cpu_addr == cpu_address) {
image_ids.push_back(image_id);
}
});
ASSERT_MSG(image_ids.size() <= 1, "Overlapping framebuffers not allowed!");
ASSERT_MSG(image_ids.size() <= 1, "Overlapping images not allowed!");
ImageId image_id{};
if (image_ids.empty()) {
image_id = slot_images.insert(instance, scheduler, ImageInfo{group}, cpu_address);
image_id = slot_images.insert(instance, scheduler, info, cpu_address);
RegisterImage(image_id);
} else {
image_id = image_ids[0];

View File

@@ -33,8 +33,7 @@ public:
void OnCpuWrite(VAddr address);
/// Retrieves the image handle of the image with the provided attributes and address.
Image& FindDisplayBuffer(const Libraries::VideoOut::BufferAttributeGroup& attribute,
VAddr cpu_address);
Image& FindImage(const ImageInfo& info, VAddr cpu_address);
private:
/// Iterate over all page indices in a range