From e6f773f9504e947a2b86177b26488151b0f4bad6 Mon Sep 17 00:00:00 2001 From: psucien Date: Sat, 15 Jun 2024 21:18:48 +0200 Subject: [PATCH] videoout: register buffers in texture cache at VO creation time --- src/core/libraries/videoout/driver.cpp | 1 + .../renderer_vulkan/renderer_vulkan.cpp | 13 ------------- .../renderer_vulkan/renderer_vulkan.h | 17 +++++++++++++++-- src/video_core/texture_cache/image.cpp | 5 ++--- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/core/libraries/videoout/driver.cpp b/src/core/libraries/videoout/driver.cpp index e86fb1ed..c7677252 100644 --- a/src/core/libraries/videoout/driver.cpp +++ b/src/core/libraries/videoout/driver.cpp @@ -134,6 +134,7 @@ int VideoOutDriver::RegisterBuffers(VideoOutPort* port, s32 startIndex, void* co .address_right = 0, }; + renderer->RegisterVideoOutSurface(group, address); LOG_INFO(Lib_VideoOut, "buffers[{}] = {:#x}", i + startIndex, address); } diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.cpp b/src/video_core/renderer_vulkan/renderer_vulkan.cpp index dc986249..fb6bc248 100644 --- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp +++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp @@ -192,19 +192,6 @@ bool RendererVulkan::ShowSplash(Frame* frame /*= nullptr*/) { return true; } -Frame* RendererVulkan::PrepareFrame(const Libraries::VideoOut::BufferAttributeGroup& attribute, - VAddr cpu_address) { - // Request presentation image from the texture cache. - const auto info = VideoCore::ImageInfo{attribute}; - auto& image = texture_cache.FindImage(info, cpu_address); - return PrepareFrameInternal(image); -} - -Frame* RendererVulkan::PrepareBlankFrame() { - auto& image = texture_cache.GetImage(VideoCore::NULL_IMAGE_ID); - return PrepareFrameInternal(image); -} - Frame* RendererVulkan::PrepareFrameInternal(VideoCore::Image& image) { // Request a free presentation frame. Frame* frame = GetRenderFrame(); diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.h b/src/video_core/renderer_vulkan/renderer_vulkan.h index f4b1a608..3c1d5f50 100644 --- a/src/video_core/renderer_vulkan/renderer_vulkan.h +++ b/src/video_core/renderer_vulkan/renderer_vulkan.h @@ -38,8 +38,21 @@ public: ~RendererVulkan(); Frame* PrepareFrame(const Libraries::VideoOut::BufferAttributeGroup& attribute, - VAddr cpu_address); - Frame* PrepareBlankFrame(); + VAddr cpu_address) { + auto& image = RegisterVideoOutSurface(attribute, cpu_address); + return PrepareFrameInternal(image); + } + + Frame* PrepareBlankFrame() { + auto& image = texture_cache.GetImage(VideoCore::NULL_IMAGE_ID); + return PrepareFrameInternal(image); + } + + VideoCore::Image& RegisterVideoOutSurface( + const Libraries::VideoOut::BufferAttributeGroup& attribute, VAddr cpu_address) { + const auto info = VideoCore::ImageInfo{attribute}; + return texture_cache.FindImage(info, cpu_address); + } bool ShowSplash(Frame* frame = nullptr); void Present(Frame* frame); diff --git a/src/video_core/texture_cache/image.cpp b/src/video_core/texture_cache/image.cpp index 727e89e4..308eceec 100644 --- a/src/video_core/texture_cache/image.cpp +++ b/src/video_core/texture_cache/image.cpp @@ -22,7 +22,7 @@ static vk::Format ConvertPixelFormat(const VideoOutFormat format) { case VideoOutFormat::A8R8G8B8Srgb: return vk::Format::eB8G8R8A8Srgb; case VideoOutFormat::A8B8G8R8Srgb: - return vk::Format::eA8B8G8R8SrgbPack32; + return vk::Format::eR8G8B8A8Srgb; case VideoOutFormat::A2R10G10B10: case VideoOutFormat::A2R10G10B10Srgb: return vk::Format::eA2R10G10B10UnormPack32; @@ -121,8 +121,7 @@ ImageInfo::ImageInfo(const Libraries::VideoOut::BufferAttributeGroup& group) noe size.width = attrib.width; size.height = attrib.height; pitch = attrib.tiling_mode == TilingMode::Linear ? size.width : (size.width + 127) >> 7; - const bool is_32bpp = pixel_format == vk::Format::eB8G8R8A8Srgb || - pixel_format == vk::Format::eA8B8G8R8SrgbPack32; + const bool is_32bpp = attrib.pixel_format != VideoOutFormat::A16R16G16B16Float; ASSERT(is_32bpp); if (!is_tiled) { guest_size_bytes = pitch * size.height * 4;