Compare commits

...

2 Commits

Author SHA1 Message Date
Zephyron 3205c9b691 fix(vulkan): address compiler warnings for Linux
- Fix variable shadowing in ShaderManager constructor by renaming parameter
- Remove unused variables in vk_texture_manager.cpp to avoid warnings
- Fix int conversion warning in syscall return value

These changes fix build errors when using certain optimized compile flags for Linux.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-04-18 14:26:04 +10:00
Zephyron f1e169e060 fix: correct implementation of present interval 0 for unlocked FPS
Fixes issues in commit bbd3253169 that could cause
crashes and deadlocks. The feature now works as intended, allowing games using
present interval 0 to run with truly unlocked FPS.

This ensures proper functionality of dynamic framerate mods like UltraCam
by MaxLastBreath (https://www.nxoptimizer.com/) without stability problems.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-04-18 10:11:16 +10:00
4 changed files with 27 additions and 33 deletions

View File

@ -19,31 +19,24 @@ namespace {
s32 NormalizeSwapInterval(f32* out_speed_scale, s32 swap_interval) {
if (swap_interval <= 0) {
// If swap_interval is 0 and setting enabled, respect it as unlocked FPS
if (swap_interval == 0 && Settings::values.respect_present_interval_zero.GetValue()) {
if (out_speed_scale) {
*out_speed_scale = 1.0f;
}
return 0;
}
// As an extension, treat nonpositive swap interval as speed multiplier.
if (out_speed_scale) {
*out_speed_scale = 2.f * static_cast<f32>(1 - swap_interval);
}
swap_interval = 1;
// Only normalize swap_interval to 1 if we're not respecting present interval 0
if (swap_interval == 0 && Settings::values.respect_present_interval_zero.GetValue()) {
// Keep swap_interval as 0 to allow for unlocked FPS
} else {
swap_interval = 1;
}
}
if (swap_interval >= 5) {
// As an extension, treat high swap interval as precise speed control.
if (out_speed_scale) {
*out_speed_scale = static_cast<f32>(swap_interval) / 100.f;
}
swap_interval = 1;
}
return swap_interval;
}

View File

@ -242,7 +242,7 @@ void AsyncCompileShader(const Device& device, const std::string& shader_path,
}).detach();
}
ShaderManager::ShaderManager(const Device& device) : device(device) {
ShaderManager::ShaderManager(const Device& device_) : device(device_) {
// Initialize command queue system
InitializeCommandQueue();
}

View File

@ -116,26 +116,27 @@ vk::Image TextureManager::LoadTexture(const std::string& texture_path) {
vk::Image TextureManager::CreateDefaultTexture() {
// Create a small default texture (1x1 pixel) to use as a fallback
const VkExtent2D extent{1, 1};
// const VkExtent2D extent{1, 1};
// Create image
const VkImageCreateInfo image_ci{
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
.pNext = nullptr,
.flags = 0,
.imageType = VK_IMAGE_TYPE_2D,
.format = texture_format,
.extent = {extent.width, extent.height, 1},
.mipLevels = 1,
.arrayLayers = 1,
.samples = VK_SAMPLE_COUNT_1_BIT,
.tiling = VK_IMAGE_TILING_OPTIMAL,
.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
.queueFamilyIndexCount = 0,
.pQueueFamilyIndices = nullptr,
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
};
// Avoid unused variable warning by commenting out the unused struct
// VkImageCreateInfo image_ci{
// .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
// .pNext = nullptr,
// .flags = 0,
// .imageType = VK_IMAGE_TYPE_2D,
// .format = texture_format,
// .extent = {extent.width, extent.height, 1},
// .mipLevels = 1,
// .arrayLayers = 1,
// .samples = VK_SAMPLE_COUNT_1_BIT,
// .tiling = VK_IMAGE_TILING_OPTIMAL,
// .usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
// .sharingMode = VK_SHARING_MODE_EXCLUSIVE,
// .queueFamilyIndexCount = 0,
// .pQueueFamilyIndices = nullptr,
// .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
// };
// TODO: create an actual VkImage [ZEP]
LOG_INFO(Render_Vulkan, "Created default fallback texture");

View File

@ -205,7 +205,7 @@ void FaultManagedAllocator::ExceptionHandlerThread() {
void FaultManagedAllocator::Initialize(void* base, size_t size) {
#if defined(__linux__) || defined(__ANDROID__)
uffd = syscall(SYS_userfaultfd, O_CLOEXEC | O_NONBLOCK);
uffd = static_cast<int>(syscall(SYS_userfaultfd, O_CLOEXEC | O_NONBLOCK));
if (uffd < 0) {
LOG_ERROR(Render_Vulkan, "Failed to create userfaultfd, fault handling disabled");
return;