mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-12-02 04:40:35 +01:00
[TEST] Removal of IsSafeDownload death path
This commit is contained in:
parent
2e52ca5753
commit
2f83399798
7 changed files with 43 additions and 20 deletions
|
|
@ -370,6 +370,7 @@ struct TextureCacheParams {
|
||||||
static constexpr bool HAS_EMULATED_COPIES = true;
|
static constexpr bool HAS_EMULATED_COPIES = true;
|
||||||
static constexpr bool HAS_DEVICE_MEMORY_INFO = true;
|
static constexpr bool HAS_DEVICE_MEMORY_INFO = true;
|
||||||
static constexpr bool IMPLEMENTS_ASYNC_DOWNLOADS = true;
|
static constexpr bool IMPLEMENTS_ASYNC_DOWNLOADS = true;
|
||||||
|
static constexpr bool HAS_MSAA_DOWNLOADS = false;
|
||||||
|
|
||||||
using Runtime = OpenGL::TextureCacheRuntime;
|
using Runtime = OpenGL::TextureCacheRuntime;
|
||||||
using Image = OpenGL::Image;
|
using Image = OpenGL::Image;
|
||||||
|
|
|
||||||
|
|
@ -1765,6 +1765,16 @@ u64 TextureCacheRuntime::GetDeviceMemoryUsage() const {
|
||||||
return device.GetDeviceMemoryUsage();
|
return device.GetDeviceMemoryUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TextureCacheRuntime::CanDownloadMsaa(const VideoCommon::ImageInfo& info) const {
|
||||||
|
if (ImageAspectMask(info.format) != VK_IMAGE_ASPECT_COLOR_BIT) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (VideoCore::Surface::IsPixelFormatInteger(info.format)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return info.resources.layers == 1;
|
||||||
|
}
|
||||||
|
|
||||||
bool TextureCacheRuntime::CanReportMemoryUsage() const {
|
bool TextureCacheRuntime::CanReportMemoryUsage() const {
|
||||||
return device.CanReportMemoryUsage();
|
return device.CanReportMemoryUsage();
|
||||||
}
|
}
|
||||||
|
|
@ -2012,8 +2022,7 @@ void Image::DownloadMemory(std::span<VkBuffer> buffers_span, std::span<size_t> o
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.num_samples > 1) {
|
if (info.num_samples > 1) {
|
||||||
if (aspect_mask == VK_IMAGE_ASPECT_COLOR_BIT &&
|
if (runtime->CanDownloadMsaa(info)) {
|
||||||
!VideoCore::Surface::IsPixelFormatInteger(info.format)) {
|
|
||||||
ImageInfo temp_info = info;
|
ImageInfo temp_info = info;
|
||||||
temp_info.num_samples = 1;
|
temp_info.num_samples = 1;
|
||||||
|
|
||||||
|
|
@ -2133,8 +2142,11 @@ void Image::DownloadMemory(std::span<VkBuffer> buffers_span, std::span<size_t> o
|
||||||
});
|
});
|
||||||
runtime->pending_msaa_images.emplace_back(scheduler->CurrentTick(),
|
runtime->pending_msaa_images.emplace_back(scheduler->CurrentTick(),
|
||||||
std::move(temp_image));
|
std::move(temp_image));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
if (is_rescaled) {
|
||||||
|
ScaleUp(true);
|
||||||
|
}
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
boost::container::small_vector<VkBuffer, 8> buffers_vector{};
|
boost::container::small_vector<VkBuffer, 8> buffers_vector{};
|
||||||
boost::container::small_vector<boost::container::small_vector<VkBufferImageCopy, 16>, 8>
|
boost::container::small_vector<boost::container::small_vector<VkBufferImageCopy, 16>, 8>
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,8 @@ public:
|
||||||
|
|
||||||
bool CanReportMemoryUsage() const;
|
bool CanReportMemoryUsage() const;
|
||||||
|
|
||||||
|
bool CanDownloadMsaa(const VideoCommon::ImageInfo& info) const;
|
||||||
|
|
||||||
void BlitImage(Framebuffer* dst_framebuffer, ImageView& dst, ImageView& src,
|
void BlitImage(Framebuffer* dst_framebuffer, ImageView& dst, ImageView& src,
|
||||||
const Region2D& dst_region, const Region2D& src_region,
|
const Region2D& dst_region, const Region2D& src_region,
|
||||||
Tegra::Engines::Fermi2D::Filter filter,
|
Tegra::Engines::Fermi2D::Filter filter,
|
||||||
|
|
@ -585,6 +587,7 @@ struct TextureCacheParams {
|
||||||
static constexpr bool HAS_EMULATED_COPIES = false;
|
static constexpr bool HAS_EMULATED_COPIES = false;
|
||||||
static constexpr bool HAS_DEVICE_MEMORY_INFO = true;
|
static constexpr bool HAS_DEVICE_MEMORY_INFO = true;
|
||||||
static constexpr bool IMPLEMENTS_ASYNC_DOWNLOADS = true;
|
static constexpr bool IMPLEMENTS_ASYNC_DOWNLOADS = true;
|
||||||
|
static constexpr bool HAS_MSAA_DOWNLOADS = true;
|
||||||
|
|
||||||
using Runtime = Vulkan::TextureCacheRuntime;
|
using Runtime = Vulkan::TextureCacheRuntime;
|
||||||
using Image = Vulkan::Image;
|
using Image = Vulkan::Image;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||||
|
|
@ -134,17 +134,6 @@ bool ImageBase::IsSafeGpuCopy() const noexcept {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImageBase::IsSafeDownload() const noexcept {
|
|
||||||
if (!IsSafeGpuCopy()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (info.num_samples > 1) {
|
|
||||||
LOG_WARNING(HW_GPU, "MSAA image downloads are not implemented");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImageBase::CheckBadOverlapState() {
|
void ImageBase::CheckBadOverlapState() {
|
||||||
if (False(flags & ImageFlagBits::BadOverlap)) {
|
if (False(flags & ImageFlagBits::BadOverlap)) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
|
@ -66,8 +69,6 @@ struct ImageBase {
|
||||||
|
|
||||||
[[nodiscard]] bool IsSafeGpuCopy() const noexcept;
|
[[nodiscard]] bool IsSafeGpuCopy() const noexcept;
|
||||||
|
|
||||||
[[nodiscard]] bool IsSafeDownload() const noexcept;
|
|
||||||
|
|
||||||
[[nodiscard]] bool Overlaps(VAddr overlap_cpu_addr, size_t overlap_size) const noexcept {
|
[[nodiscard]] bool Overlaps(VAddr overlap_cpu_addr, size_t overlap_size) const noexcept {
|
||||||
const VAddr overlap_end = overlap_cpu_addr + overlap_size;
|
const VAddr overlap_end = overlap_cpu_addr + overlap_size;
|
||||||
return cpu_addr < overlap_end && overlap_cpu_addr < cpu_addr_end;
|
return cpu_addr < overlap_end && overlap_cpu_addr < cpu_addr_end;
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ void TextureCache<P>::RunGarbageCollector() {
|
||||||
if (True(image.flags & ImageFlagBits::IsDecoding)) {
|
if (True(image.flags & ImageFlagBits::IsDecoding)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const bool must_download = image.IsSafeDownload() && False(image.flags & ImageFlagBits::BadOverlap);
|
const bool must_download = IsDownloadable(image) && False(image.flags & ImageFlagBits::BadOverlap);
|
||||||
if ((!aggressive_mode && True(image.flags & ImageFlagBits::CostlyLoad)) || (!high_priority_mode && must_download)) {
|
if ((!aggressive_mode && True(image.flags & ImageFlagBits::CostlyLoad)) || (!high_priority_mode && must_download)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -594,11 +594,26 @@ void TextureCache<P>::WriteMemory(DAddr cpu_addr, size_t size) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class P>
|
||||||
|
bool TextureCache<P>::IsDownloadable(const ImageBase& image) const noexcept {
|
||||||
|
if (!image.IsSafeGpuCopy()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (image.info.num_samples == 1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if constexpr (P::HAS_MSAA_DOWNLOADS) {
|
||||||
|
return runtime.CanDownloadMsaa(image.info);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
void TextureCache<P>::DownloadMemory(DAddr cpu_addr, size_t size) {
|
void TextureCache<P>::DownloadMemory(DAddr cpu_addr, size_t size) {
|
||||||
boost::container::small_vector<ImageId, 16> images;
|
boost::container::small_vector<ImageId, 16> images;
|
||||||
ForEachImageInRegion(cpu_addr, size, [&images](ImageId image_id, ImageBase& image) {
|
ForEachImageInRegion(cpu_addr, size, [this, &images](ImageId image_id, ImageBase& image) {
|
||||||
if (!image.IsSafeDownload()) {
|
if (!IsDownloadable(image)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
image.flags &= ~ImageFlagBits::GpuModified;
|
image.flags &= ~ImageFlagBits::GpuModified;
|
||||||
|
|
|
||||||
|
|
@ -303,6 +303,8 @@ private:
|
||||||
FramebufferId GetFramebufferId(const RenderTargets& key);
|
FramebufferId GetFramebufferId(const RenderTargets& key);
|
||||||
|
|
||||||
/// Refresh the contents (pixel data) of an image
|
/// Refresh the contents (pixel data) of an image
|
||||||
|
[[nodiscard]] bool IsDownloadable(const ImageBase& image) const noexcept;
|
||||||
|
|
||||||
void RefreshContents(Image& image, ImageId image_id);
|
void RefreshContents(Image& image, ImageId image_id);
|
||||||
|
|
||||||
/// Upload data from guest to an image
|
/// Upload data from guest to an image
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue