early-access version 3630
This commit is contained in:
parent
5d6ba5745f
commit
b66267d52f
@ -1,7 +1,7 @@
|
||||
yuzu emulator early access
|
||||
=============
|
||||
|
||||
This is the source code for early-access 3629.
|
||||
This is the source code for early-access 3630.
|
||||
|
||||
## Legal Notice
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#include <boost/icl/interval_set.hpp>
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
@ -423,6 +424,7 @@ public:
|
||||
madvise(virtual_base, virtual_size, MADV_HUGEPAGE);
|
||||
#endif
|
||||
|
||||
placeholders.add({0, virtual_size});
|
||||
good = true;
|
||||
}
|
||||
|
||||
@ -431,6 +433,10 @@ public:
|
||||
}
|
||||
|
||||
void Map(size_t virtual_offset, size_t host_offset, size_t length) {
|
||||
{
|
||||
std::scoped_lock lock{placeholder_mutex};
|
||||
placeholders.subtract({virtual_offset, virtual_offset + length});
|
||||
}
|
||||
|
||||
void* ret = mmap(virtual_base + virtual_offset, length, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED | MAP_FIXED, fd, host_offset);
|
||||
@ -441,6 +447,19 @@ public:
|
||||
// The method name is wrong. We're still talking about the virtual range.
|
||||
// We don't want to unmap, we want to reserve this memory.
|
||||
|
||||
{
|
||||
std::scoped_lock lock{placeholder_mutex};
|
||||
auto it = placeholders.find({virtual_offset - 1, virtual_offset + length + 1});
|
||||
|
||||
if (it != placeholders.end()) {
|
||||
size_t prev_upper = virtual_offset + length;
|
||||
virtual_offset = std::min(virtual_offset, it->lower());
|
||||
length = std::max(it->upper(), prev_upper) - virtual_offset;
|
||||
}
|
||||
|
||||
placeholders.add({virtual_offset, virtual_offset + length});
|
||||
}
|
||||
|
||||
void* ret = mmap(virtual_base + virtual_offset, length, PROT_NONE,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
|
||||
ASSERT_MSG(ret != MAP_FAILED, "mmap failed: {}", strerror(errno));
|
||||
@ -484,6 +503,9 @@ private:
|
||||
}
|
||||
|
||||
int fd{-1}; // memfd file descriptor, -1 is the error value of memfd_create
|
||||
|
||||
boost::icl::interval_set<size_t> placeholders; ///< Mapped placeholders
|
||||
std::mutex placeholder_mutex; ///< Mutex for placeholders
|
||||
};
|
||||
|
||||
#else // ^^^ Linux ^^^ vvv Generic vvv
|
||||
|
@ -34,7 +34,7 @@ BufferCache<P>::BufferCache(VideoCore::RasterizerInterface& rasterizer_,
|
||||
const s64 min_spacing_critical = device_memory - 512_MiB;
|
||||
const s64 mem_threshold = std::min(device_memory, TARGET_THRESHOLD);
|
||||
const s64 min_vacancy_expected = (6 * mem_threshold) / 10;
|
||||
const s64 min_vacancy_critical = (3 * mem_threshold) / 10;
|
||||
const s64 min_vacancy_critical = (2 * mem_threshold) / 10;
|
||||
minimum_memory = static_cast<u64>(
|
||||
std::max(std::min(device_memory - min_vacancy_expected, min_spacing_expected),
|
||||
DEFAULT_EXPECTED_MEMORY));
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "common/math_util.h"
|
||||
#include "common/settings.h"
|
||||
#include "video_core/surface.h"
|
||||
|
||||
namespace VideoCore::Surface {
|
||||
@ -375,11 +376,20 @@ std::pair<u32, u32> GetASTCBlockSize(PixelFormat format) {
|
||||
return {DefaultBlockWidth(format), DefaultBlockHeight(format)};
|
||||
}
|
||||
|
||||
u64 EstimatedDecompressedSize(u64 base_size, PixelFormat format) {
|
||||
u64 TranscodedAstcSize(u64 base_size, PixelFormat format) {
|
||||
constexpr u64 RGBA8_PIXEL_SIZE = 4;
|
||||
const u64 base_block_size = static_cast<u64>(DefaultBlockWidth(format)) *
|
||||
static_cast<u64>(DefaultBlockHeight(format)) * RGBA8_PIXEL_SIZE;
|
||||
return (base_size * base_block_size) / BytesPerBlock(format);
|
||||
const u64 uncompressed_size = (base_size * base_block_size) / BytesPerBlock(format);
|
||||
|
||||
switch (Settings::values.astc_recompression.GetValue()) {
|
||||
case Settings::AstcRecompression::Bc1:
|
||||
return uncompressed_size / 8;
|
||||
case Settings::AstcRecompression::Bc3:
|
||||
return uncompressed_size / 4;
|
||||
default:
|
||||
return uncompressed_size;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace VideoCore::Surface
|
||||
|
@ -511,6 +511,6 @@ size_t PixelComponentSizeBitsInteger(PixelFormat format);
|
||||
|
||||
std::pair<u32, u32> GetASTCBlockSize(PixelFormat format);
|
||||
|
||||
u64 EstimatedDecompressedSize(u64 base_size, PixelFormat format);
|
||||
u64 TranscodedAstcSize(u64 base_size, PixelFormat format);
|
||||
|
||||
} // namespace VideoCore::Surface
|
||||
|
@ -53,7 +53,7 @@ TextureCache<P>::TextureCache(Runtime& runtime_, VideoCore::RasterizerInterface&
|
||||
const s64 min_spacing_critical = device_memory - 512_MiB;
|
||||
const s64 mem_threshold = std::min(device_memory, TARGET_THRESHOLD);
|
||||
const s64 min_vacancy_expected = (6 * mem_threshold) / 10;
|
||||
const s64 min_vacancy_critical = (3 * mem_threshold) / 10;
|
||||
const s64 min_vacancy_critical = (2 * mem_threshold) / 10;
|
||||
expected_memory = static_cast<u64>(
|
||||
std::max(std::min(device_memory - min_vacancy_expected, min_spacing_expected),
|
||||
DEFAULT_EXPECTED_MEMORY));
|
||||
@ -79,7 +79,6 @@ void TextureCache<P>::RunGarbageCollector() {
|
||||
if (num_iterations == 0) {
|
||||
return true;
|
||||
}
|
||||
--num_iterations;
|
||||
auto& image = slot_images[image_id];
|
||||
if (True(image.flags & ImageFlagBits::IsDecoding)) {
|
||||
// This image is still being decoded, deleting it will invalidate the slot
|
||||
@ -94,6 +93,7 @@ void TextureCache<P>::RunGarbageCollector() {
|
||||
if (!high_priority_mode && must_download) {
|
||||
return false;
|
||||
}
|
||||
--num_iterations;
|
||||
if (must_download) {
|
||||
auto map = runtime.DownloadStagingBuffer(image.unswizzled_size_bytes);
|
||||
const auto copies = FullDownloadCopies(image.info);
|
||||
@ -1908,7 +1908,7 @@ void TextureCache<P>::RegisterImage(ImageId image_id) {
|
||||
if ((IsPixelFormatASTC(image.info.format) &&
|
||||
True(image.flags & ImageFlagBits::AcceleratedUpload)) ||
|
||||
True(image.flags & ImageFlagBits::Converted)) {
|
||||
tentative_size = EstimatedDecompressedSize(tentative_size, image.info.format);
|
||||
tentative_size = TranscodedAstcSize(tentative_size, image.info.format);
|
||||
}
|
||||
total_used_memory += Common::AlignUp(tentative_size, 1024);
|
||||
image.lru_index = lru_cache.Insert(image_id, frame_tick);
|
||||
@ -2077,7 +2077,7 @@ void TextureCache<P>::DeleteImage(ImageId image_id, bool immediate_delete) {
|
||||
if ((IsPixelFormatASTC(image.info.format) &&
|
||||
True(image.flags & ImageFlagBits::AcceleratedUpload)) ||
|
||||
True(image.flags & ImageFlagBits::Converted)) {
|
||||
tentative_size = EstimatedDecompressedSize(tentative_size, image.info.format);
|
||||
tentative_size = TranscodedAstcSize(tentative_size, image.info.format);
|
||||
}
|
||||
total_used_memory -= Common::AlignUp(tentative_size, 1024);
|
||||
const GPUVAddr gpu_addr = image.gpu_addr;
|
||||
|
Loading…
Reference in New Issue
Block a user