From 2585e4f6e34878c2ce111752699d9f618082ef6f Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Mon, 21 Feb 2022 23:51:05 +0100 Subject: [PATCH] early-access version 2501 --- README.md | 2 +- src/common/page_table.cpp | 28 +++++++++---------- src/common/page_table.h | 4 +-- src/core/hle/kernel/k_page_table.cpp | 24 ++-------------- .../renderer_vulkan/vk_texture_cache.cpp | 6 ++-- .../vulkan_common/vulkan_device.cpp | 8 ++++-- src/video_core/vulkan_common/vulkan_device.h | 5 ++++ 7 files changed, 33 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index f5cb082f4..25b87cd0f 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 2499. +This is the source code for early-access 2501. ## Legal Notice diff --git a/src/common/page_table.cpp b/src/common/page_table.cpp index 75897eeae..4817b09f9 100755 --- a/src/common/page_table.cpp +++ b/src/common/page_table.cpp @@ -10,12 +10,12 @@ PageTable::PageTable() = default; PageTable::~PageTable() noexcept = default; -bool PageTable::BeginTraversal(TraversalEntry* out_entry, TraversalContext* out_context, +bool PageTable::BeginTraversal(TraversalEntry& out_entry, TraversalContext& out_context, u64 address) const { // Setup invalid defaults. - out_entry->phys_addr = 0; - out_entry->block_size = page_size; - out_context->next_page = 0; + out_entry.phys_addr = 0; + out_entry.block_size = page_size; + out_context.next_page = 0; // Validate that we can read the actual entry. const auto page = address / page_size; @@ -30,20 +30,20 @@ bool PageTable::BeginTraversal(TraversalEntry* out_entry, TraversalContext* out_ } // Populate the results. - out_entry->phys_addr = phys_addr + address; - out_context->next_page = page + 1; - out_context->next_offset = address + page_size; + out_entry.phys_addr = phys_addr + address; + out_context.next_page = page + 1; + out_context.next_offset = address + page_size; return true; } -bool PageTable::ContinueTraversal(TraversalEntry* out_entry, TraversalContext* context) const { +bool PageTable::ContinueTraversal(TraversalEntry& out_entry, TraversalContext& context) const { // Setup invalid defaults. - out_entry->phys_addr = 0; - out_entry->block_size = page_size; + out_entry.phys_addr = 0; + out_entry.block_size = page_size; // Validate that we can read the actual entry. - const auto page = context->next_page; + const auto page = context.next_page; if (page >= backing_addr.size()) { return false; } @@ -55,9 +55,9 @@ bool PageTable::ContinueTraversal(TraversalEntry* out_entry, TraversalContext* c } // Populate the results. - out_entry->phys_addr = phys_addr + context->next_offset; - context->next_page = page + 1; - context->next_offset += page_size; + out_entry.phys_addr = phys_addr + context.next_offset; + context.next_page = page + 1; + context.next_offset += page_size; return true; } diff --git a/src/common/page_table.h b/src/common/page_table.h index fe254d7ae..82d91e9f3 100755 --- a/src/common/page_table.h +++ b/src/common/page_table.h @@ -99,9 +99,9 @@ struct PageTable { PageTable(PageTable&&) noexcept = default; PageTable& operator=(PageTable&&) noexcept = default; - bool BeginTraversal(TraversalEntry* out_entry, TraversalContext* out_context, + bool BeginTraversal(TraversalEntry& out_entry, TraversalContext& out_context, u64 address) const; - bool ContinueTraversal(TraversalEntry* out_entry, TraversalContext* context) const; + bool ContinueTraversal(TraversalEntry& out_entry, TraversalContext& context) const; /** * Resizes the page table to be able to accommodate enough pages within diff --git a/src/core/hle/kernel/k_page_table.cpp b/src/core/hle/kernel/k_page_table.cpp index 8aca5d377..88aa2a152 100755 --- a/src/core/hle/kernel/k_page_table.cpp +++ b/src/core/hle/kernel/k_page_table.cpp @@ -41,24 +41,6 @@ constexpr std::size_t GetAddressSpaceWidthFromType(FileSys::ProgramAddressSpaceT } } -constexpr u64 GetAddressInRange(const KMemoryInfo& info, VAddr addr) { - if (info.GetAddress() < addr) { - return addr; - } - return info.GetAddress(); -} - -constexpr std::size_t GetSizeInRange(const KMemoryInfo& info, VAddr start, VAddr end) { - std::size_t size{info.GetSize()}; - if (info.GetAddress() < start) { - size -= start - info.GetAddress(); - } - if (info.GetEndAddress() > end) { - size -= info.GetEndAddress() - end; - } - return size; -} - } // namespace KPageTable::KPageTable(Core::System& system_) @@ -724,8 +706,7 @@ ResultCode KPageTable::UnmapPhysicalMemory(VAddr address, std::size_t size) { size_t tot_size = 0; cur_address = address; - next_valid = - impl.BeginTraversal(std::addressof(next_entry), std::addressof(context), cur_address); + next_valid = impl.BeginTraversal(next_entry, context, cur_address); next_entry.block_size = (next_entry.block_size - (next_entry.phys_addr & (next_entry.block_size - 1))); @@ -751,8 +732,7 @@ ResultCode KPageTable::UnmapPhysicalMemory(VAddr address, std::size_t size) { break; } - next_valid = - impl.ContinueTraversal(std::addressof(next_entry), std::addressof(context)); + next_valid = impl.ContinueTraversal(next_entry, context); } // Add the last block. diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 1ad38df72..8be7e162e 100755 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -554,10 +554,12 @@ void CopyBufferToImage(vk::CommandBuffer cmdbuf, VkBuffer src_buffer, VkImage im }; } -[[nodiscard]] bool IsFormatFlipped(PixelFormat format) { +[[nodiscard]] bool IsFormatFlipped(PixelFormat format, bool emulate_bgr565) { switch (format) { case PixelFormat::A1B5G5R5_UNORM: return true; + case PixelFormat::B5G6R5_UNORM: + return emulate_bgr565; default: return false; } @@ -1497,7 +1499,7 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI }; if (!info.IsRenderTarget()) { swizzle = info.Swizzle(); - if (IsFormatFlipped(format)) { + if (IsFormatFlipped(format, device->MustEmulateBGR565())) { std::ranges::transform(swizzle, swizzle.begin(), SwapBlueRed); } if ((aspect_mask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) != 0) { diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index 0c8516b33..f9e837554 100755 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp @@ -44,9 +44,6 @@ constexpr std::array DEPTH16_UNORM_STENCIL8_UINT{ constexpr std::array B5G6R5_UNORM_PACK16{ VK_FORMAT_R5G6B5_UNORM_PACK16, - VK_FORMAT_R5G5B5A1_UNORM_PACK16, - VK_FORMAT_A1R5G5B5_UNORM_PACK16, - VK_FORMAT_R4G4B4A4_UNORM_PACK16, VK_FORMAT_UNDEFINED, }; } // namespace Alternatives @@ -656,6 +653,7 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR } const bool is_intel_windows = driver_id == VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS; + const bool is_intel_anv = driver_id == VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA; if (ext_vertex_input_dynamic_state && is_intel_windows) { LOG_WARNING(Render_Vulkan, "Blacklisting Intel for VK_EXT_vertex_input_dynamic_state"); ext_vertex_input_dynamic_state = false; @@ -669,6 +667,10 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR LOG_WARNING(Render_Vulkan, "Intel proprietary drivers do not support MSAA image blits"); cant_blit_msaa = true; } + if (is_intel_anv) { + LOG_WARNING(Render_Vulkan, "ANV driver does not support native BGR format"); + must_emulate_bgr565 = true; + } supports_d24_depth = IsFormatSupported(VK_FORMAT_D24_UNORM_S8_UINT, diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h index 5c3cd5e7e..a6dba0eac 100755 --- a/src/video_core/vulkan_common/vulkan_device.h +++ b/src/video_core/vulkan_common/vulkan_device.h @@ -360,6 +360,10 @@ public: return cant_blit_msaa; } + bool MustEmulateBGR565() const { + return must_emulate_bgr565; + } + private: /// Checks if the physical device is suitable. void CheckSuitability(bool requires_swapchain) const; @@ -458,6 +462,7 @@ private: bool has_nsight_graphics{}; ///< Has Nsight Graphics attached bool supports_d24_depth{}; ///< Supports D24 depth buffers. bool cant_blit_msaa{}; ///< Does not support MSAA<->MSAA blitting. + bool must_emulate_bgr565{}; ///< Emulates BGR565 by swizzling RGB565 format. // Telemetry parameters std::string vendor_name; ///< Device's driver name.