mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-09-13 15:04:29 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 11639bbb64 | |||
| 5e425e4e9e |
@@ -22,6 +22,7 @@
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
#include "common/scope_exit.h"
|
||||
#include "common/literals.h"
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <sys/random.h>
|
||||
@@ -526,7 +527,28 @@ public:
|
||||
#elif defined(__OpenBSD__)
|
||||
fd = shm_open_anon(O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW, 0600);
|
||||
#elif defined(__FreeBSD__)
|
||||
fd = shm_open(SHM_ANON, O_RDWR, 0600);
|
||||
int n_page_sizes = getpagesizes(nullptr, 0);
|
||||
if (n_page_sizes > 0) {
|
||||
std::vector<size_t> page_sizes(n_page_sizes);
|
||||
if (getpagesizes(page_sizes.data(), n_page_sizes) > 0) {
|
||||
size_t max_size = page_sizes[0];
|
||||
size_t max_index = 0;
|
||||
for (size_t i = 0; i < page_sizes.size(); ++i) {
|
||||
using namespace Common::Literals;
|
||||
if (page_sizes[i] <= 4_GiB) {
|
||||
max_size = (std::max)(max_size, page_sizes[i]);
|
||||
max_index = i;
|
||||
}
|
||||
}
|
||||
LOG_WARNING(Common_Memory, "using largepage of size {} #{}", max_size, max_index);
|
||||
// Do not use SHM_LARGEPAGE_ALLOC_HARD, will infinitely hang on vm_reclaim on most systems
|
||||
fd = shm_create_largepage(SHM_ANON, O_RDWR, max_index, SHM_LARGEPAGE_ALLOC_DEFAULT, 0600);
|
||||
}
|
||||
}
|
||||
if (fd < 0) {
|
||||
LOG_WARNING(Common_Memory, "unable to force largepage: {}", strerror(errno));
|
||||
fd = shm_open(SHM_ANON, O_RDWR, 0600);
|
||||
}
|
||||
#elif defined(__APPLE__) || defined(__managarm__)
|
||||
// macOS doesn't have memfd_create, use anonymous temporary file
|
||||
char template_path[] = "/tmp/eden_mem_XXXXXX";
|
||||
@@ -558,7 +580,12 @@ public:
|
||||
close(fd);
|
||||
}
|
||||
} else {
|
||||
backing_base = static_cast<u8*>(mmap(nullptr, backing_size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_NOCORE, fd, 0));
|
||||
int map_flags =MAP_SHARED | MAP_NOCORE;
|
||||
#ifdef __FreeBSD__
|
||||
// Prevent dirty tracking of memfd
|
||||
map_flags |= MAP_NOSYNC;
|
||||
#endif
|
||||
backing_base = static_cast<u8*>(mmap(nullptr, backing_size, PROT_READ | PROT_WRITE, map_flags, fd, 0));
|
||||
}
|
||||
if (backing_base == MAP_FAILED) {
|
||||
LOG_CRITICAL(HW_Memory, "mmap failed: {}", strerror(errno));
|
||||
|
||||
@@ -2850,6 +2850,8 @@ Sampler::VariantKey Sampler::MakeKey(const ImageView& image_view, bool is_depth)
|
||||
VariantKey key{};
|
||||
key.reduce_anisotropy = has_added_anisotropy && !image_view.SupportsAnisotropy();
|
||||
key.force_nearest = has_linear_filtering && IsPixelFormatInteger(image_view.format);
|
||||
key.drop_depth_comparison =
|
||||
is_depth && has_depth_comparison && !image_view.SupportsDepthComparison();
|
||||
key.drop_reduction = has_minmax_reduction && !image_view.SupportsMinmaxFilter();
|
||||
key.drop_custom_border = has_custom_border_colors && image_view.RequiresBorderColorFormat();
|
||||
key.srgb_border = has_srgb_border_color && IsPixelFormatSRGB(image_view.format);
|
||||
@@ -2927,6 +2929,9 @@ VkSampler Sampler::Emplace(VariantKey key) {
|
||||
create_info.anisotropyEnable = static_cast<VkBool32>(default_anisotropy > 1.0f);
|
||||
create_info.maxAnisotropy = default_anisotropy;
|
||||
}
|
||||
if (key.drop_depth_comparison) {
|
||||
create_info.compareEnable = VK_FALSE;
|
||||
}
|
||||
if (!custom_border) {
|
||||
create_info.borderColor = ConvertBorderColor(color);
|
||||
}
|
||||
|
||||
@@ -536,6 +536,7 @@ private:
|
||||
struct VariantKey {
|
||||
bool reduce_anisotropy;
|
||||
bool force_nearest;
|
||||
bool drop_depth_comparison;
|
||||
bool drop_reduction;
|
||||
bool drop_custom_border;
|
||||
bool srgb_border;
|
||||
|
||||
Reference in New Issue
Block a user