Compare commits

...

5 commits

Author SHA1 Message Date
f35018782d [Vk] Improve Stencil Handling and Fix Read-After-Write Hazard
1. Improves stencil handling:
   - Adds surface type detection to distinguish between color, depth, stencil, and depth-stencil formats
   - Only enables stencil load/store operations for surfaces that actually contain stencil data
   - Avoids unnecessary stencil operations for non-stencil formats (DONT_CARE)

2. Fixes read-after-write (RAW) synchronization hazards:
   - Adds a subpass self-dependency (subpass 0 → subpass 0)
   - Synchronizes color/depth writes with subsequent shader reads
   - Uses VK_DEPENDENCY_BY_REGION_BIT for efficient synchronization
   - Covers all relevant stages:
     • src: Color output + Early/Late fragment tests
     • dst: Fragment shader
     • Access: Write → Read transitions
here is what hazard looks like [1147.550616] Render.Vulkan <Critical> video_core/vulkan_common/vulkan_debug_callback.cpp:DebugUtilCallback:55: Validation Error: [ SYNC-HAZARD-READ-AFTER-WRITE ] Object 0: handle = 0x7409630000000192, type = VK_OBJECT_TYPE_IMAGE_VIEW; | MessageID = 0xe4d96472 | vkCmdDrawIndexed: Hazard READ_AFTER_WRITE for VkImageView 0x7409630000000192[], in VkCommandBuffer 0xb400007cb003ea70[], and VkPipeline 0x44d3470000000213[], VkDescriptorSet 0x0[], type: VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, imageLayout: VK_IMAGE_LAYOUT_GENERAL, binding #2, index 0. Access info (usage: SYNC_FRAGMENT_SHADER_SHADER_SAMPLED_READ, prior_usage: SYNC_IMAGE_LAYOUT_TRANSITION, write_barriers: SYNC_FRAGMENT_SHADER_COLOR_ATTACHMENT_READ|SYNC_FRAGMENT_SHADER_DEPTH_STENCIL_ATTACHMENT_READ|SYNC_FRAGMENT_SHADER_INPUT_ATTACHMENT_READ|SYNC_EARLY_FRAGMENT_TESTS_DEPTH_STENCIL_ATTACHMENT_READ|SYNC_EARLY_FRAGMENT_TESTS_DEPTH_STENCIL_ATTACHMENT_WRITE|SYNC_LATE_FRAGMENT_TESTS_DEPTH_STENCIL_ATTACHMENT_READ|SYNC_LATE_FRAGMENT_TESTS_DEPTH_STENCIL_ATTACHMENT_WRITE|SYNC_COLOR_ATTACHMENT_OUTPUT_COLOR_ATTACHMENT_READ|SYNC_COLOR_ATTACHMENT_OUTPUT_COLOR_ATTACHMENT_WRITE|SYNC_SUBPASS_SHADER_HUAWEI_INPUT_ATTACHMENT_READ, command: vkCmdPipelineBarrier, seq_no: 45, reset_no: 129).

Signed-off-by: crueter <crueter@eden-emu.dev>
2025-08-15 20:17:18 +02:00
72fb15cacc
[shader_recompiler] ISBERD minor cleanups (#211)
Clean up some ISBERD related implementations.

Reviewed-on: eden-emu/eden#211
Reviewed-by: Shinmegumi <shinmegumi@eden-emu.dev>
Co-authored-by: SDK Chan <sdkchan@eden-emu.dev>
Co-committed-by: SDK Chan <sdkchan@eden-emu.dev>
2025-08-15 20:11:08 +02:00
b906abf9fc
[kernel] Ensure all kernel objects exist before destroying them and avoid infinite loop between Open() and Close() functions (#261)
This ensures that all kernel objects exist before destroying them and prevents an infinite loop between the Open() and Close() functions.

Reviewed-on: eden-emu/eden#261
Reviewed-by: Shinmegumi <shinmegumi@eden-emu.dev>
Co-authored-by: MaranBr <maranbr@outlook.com>
Co-committed-by: MaranBr <maranbr@outlook.com>
2025-08-15 14:01:11 +02:00
e807e32b1a
[compat] fix solaris Qt build (#194)
Co-authored-by: crueter <crueter@eden-emu.dev>
Reviewed-on: eden-emu/eden#194
Reviewed-by: crueter <crueter@eden-emu.dev>
Co-authored-by: lizzie <lizzie@eden-emu.dev>
Co-committed-by: lizzie <lizzie@eden-emu.dev>
2025-08-15 04:12:45 +02:00
c39e3bece6
[cmake] do not allow system xbyak
Signed-off-by: crueter <crueter@eden-emu.dev>
2025-08-14 22:02:59 -04:00
29 changed files with 294 additions and 168 deletions

View file

@ -7,6 +7,11 @@ project(yuzu)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules")
if (${CMAKE_SYSTEM_NAME} STREQUAL "SunOS")
# Terrific Solaris pkg shenanigans
list(APPEND CMAKE_PREFIX_PATH "/usr/lib/qt/6.6/lib/amd64/cmake")
list(APPEND CMAKE_MODULE_PATH "/usr/lib/qt/6.6/lib/amd64/cmake")
endif()
set(CPM_SOURCE_CACHE ${CMAKE_SOURCE_DIR}/.cache/cpm)
@ -649,8 +654,10 @@ if (ENABLE_QT)
find_package(Qt6 REQUIRED COMPONENTS Multimedia)
endif()
if (UNIX AND NOT APPLE)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_package(Qt6 REQUIRED COMPONENTS DBus GuiPrivate)
elseif (UNIX AND NOT APPLE)
find_package(Qt6 REQUIRED COMPONENTS DBus Gui)
endif()
if (ENABLE_QT_TRANSLATION)

View file

@ -104,6 +104,7 @@ Then type `target remote localhost:1234` and type `c` (for continue) - and then
- `br <expr>`: Set breakpoint at `<expr>`.
- `delete`: Deletes all breakpoints.
- `catch throw`: Breakpoint at throw. Can also use `br __cxa_throw`
- `br _mesa_error`: Break on mesa errors (set environment variable `MESA_DEBUG=1` beforehand), see [MESA_DEBUG](https://mesa-docs.readthedocs.io/en/latest/debugging.html).
Expressions can be `variable_names` or `1234` (numbers) or `*var` (dereference of a pointer) or `*(1 + var)` (computed expression).

13
docs/build/Solaris.md vendored
View file

@ -87,6 +87,19 @@ export PATH="$PATH:$PWD"
- **Build**: `cmake --build build`.
- **Installing**: `sudo cmake --install build`.
### Running
Default Mesa is a bit outdated, the following environment variables should be set for a smoother experience:
```sh
export MESA_GL_VERSION_OVERRIDE=4.6
export MESA_GLSL_VERSION_OVERRIDE=460
export MESA_EXTENSION_MAX_YEAR=2025
export MESA_DEBUG=1
export MESA_VK_VERSION_OVERRIDE=1.3
# Only if nvidia/intel drm drivers cause crashes, will severely hinder performance
export LIBGL_ALWAYS_SOFTWARE=1
```
### Notes
- Modify the generated ffmpeg.make (in build dir) if using multiple threads (base system `make` doesn't use `-j4`, so change for `gmake`).

View file

@ -46,6 +46,7 @@ if (ARCHITECTURE_x86 OR ARCHITECTURE_x86_64)
REPO "Lizzie841/xbyak"
SHA ${XBYAK_HASH}
HASH ${XBYAK_SHA512SUM}
BUNDLED_PACKAGE ON
)
endif()

View file

@ -205,8 +205,8 @@ NetPlayStatus AndroidMultiplayer::NetPlayCreateRoom(const std::string &ipaddress
std::string token;
// TODO(alekpop): properly handle the compile definition, it's not working right
//#ifdef ENABLE_WEB_SERVICE
// LOG_INFO(WebService, "Web Service enabled");
#ifdef ENABLE_WEB_SERVICE
LOG_INFO(WebService, "Web Service enabled");
if (isPublic) {
WebService::Client client(Settings::values.web_api_url.GetValue(),
Settings::values.eden_username.GetValue(),
@ -220,9 +220,9 @@ NetPlayStatus AndroidMultiplayer::NetPlayCreateRoom(const std::string &ipaddress
LOG_INFO(WebService, "Successfully requested external JWT: size={}", token.size());
}
}
//#else
// LOG_INFO(WebService, "Web Service disabled");
//#endif
#else
LOG_ERROR(WebService, "Web Service disabled");
#endif
member->Join(username, ipaddress.c_str(), static_cast<u16>(port), 0, Network::NoPreferredIP,
password, token);
@ -432,12 +432,12 @@ std::vector<std::string> AndroidMultiplayer::NetPlayGetBanList() {
std::unique_ptr<Network::VerifyUser::Backend> AndroidMultiplayer::CreateVerifyBackend(bool use_validation) {
std::unique_ptr<Network::VerifyUser::Backend> verify_backend;
if (use_validation) {
//#ifdef ENABLE_WEB_SERVICE
#ifdef ENABLE_WEB_SERVICE
verify_backend =
std::make_unique<WebService::VerifyUserJWT>(Settings::values.web_api_url.GetValue());
//#else
// verify_backend = std::make_unique<Network::VerifyUser::NullBackend>();
//#endif
#else
verify_backend = std::make_unique<Network::VerifyUser::NullBackend>();
#endif
} else {
verify_backend = std::make_unique<Network::VerifyUser::NullBackend>();
}

View file

@ -442,16 +442,15 @@ static int shm_open_anon(int flags, mode_t mode) {
for (char *fill = start; fill < limit; r /= 8)
*fill++ = '0' + (r % 8);
int fd = shm_open(name, flags, mode);
if (fd != -1)
return ([](const char *name, int fd) {
if (shm_unlink(name) == -1) {
int tmp = errno;
close(fd);
errno = tmp;
return -1;
}
return fd;
})(name, fd);
if (fd != -1) {
if (shm_unlink(name) == -1) {
int tmp = errno;
close(fd);
errno = tmp;
return -1;
}
return fd;
}
if (errno != EEXIST)
break;
}
@ -464,15 +463,13 @@ static int shm_open_anon(int flags, mode_t mode) {
int fd;
if ((fd = shm_mkstemp(name)) == -1)
return -1;
return ([](const char *name, int fd) {
if (shm_unlink(name) == -1) {
int tmp = errno;
close(fd);
errno = tmp;
return -1;
}
return fd;
})(name, fd);
if (shm_unlink(name) == -1) {
int tmp = errno;
close(fd);
errno = tmp;
return -1;
}
return fd;
}
#endif

View file

@ -1199,8 +1199,8 @@ if (MINGW)
endif()
if (ENABLE_WEB_SERVICE)
target_compile_definitions(core PRIVATE -DENABLE_WEB_SERVICE)
target_link_libraries(core PRIVATE web_service)
target_compile_definitions(core PUBLIC -DENABLE_WEB_SERVICE)
target_link_libraries(core PUBLIC web_service)
endif()
if (HAS_NCE)

View file

@ -1,5 +1,8 @@
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
@ -153,12 +156,15 @@ public:
// Atomically decrement the reference count, not allowing it to become negative.
u32 cur_ref_count = m_ref_count.load(std::memory_order_acquire);
do {
if (cur_ref_count == 0) {
return;
}
ASSERT(cur_ref_count > 0);
} while (!m_ref_count.compare_exchange_weak(cur_ref_count, cur_ref_count - 1,
std::memory_order_acq_rel));
// If ref count hits zero, destroy the object.
if (cur_ref_count - 1 == 0) {
// If ref count hits 1, destroy the object.
if (cur_ref_count == 1) {
KernelCore& kernel = m_kernel;
this->Destroy();
KAutoObject::UnregisterWithKernel(kernel, this);

View file

@ -12,7 +12,7 @@
#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#elif YUZU_UNIX
#elif defined(__unix__)
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
@ -77,7 +77,7 @@ SOCKET GetInterruptSocket() {
sockaddr TranslateFromSockAddrIn(SockAddrIn input) {
sockaddr_in result;
#if YUZU_UNIX
#ifdef __unix__
result.sin_len = sizeof(result);
#endif
@ -162,7 +162,7 @@ Errno TranslateNativeError(int e, CallType call_type = CallType::Other) {
}
}
#elif YUZU_UNIX // ^ _WIN32 v YUZU_UNIX
#elif defined(__unix__) // ^ _WIN32 v __unix__
using SOCKET = int;
using WSAPOLLFD = pollfd;
@ -835,7 +835,7 @@ std::pair<s32, Errno> Socket::Send(std::span<const u8> message, int flags) {
ASSERT(flags == 0);
int native_flags = 0;
#if YUZU_UNIX
#ifdef __unix__
native_flags |= MSG_NOSIGNAL; // do not send us SIGPIPE
#endif
const auto result = send(fd, reinterpret_cast<const char*>(message.data()),

View file

@ -13,7 +13,7 @@
#ifdef _WIN32
#include <winsock2.h>
#elif YUZU_UNIX
#else
#include <netinet/in.h>
#endif
@ -104,7 +104,7 @@ constexpr IPv4Address TranslateIPv4(in_addr addr) {
auto& bytes = addr.S_un.S_un_b;
return IPv4Address{bytes.s_b1, bytes.s_b2, bytes.s_b3, bytes.s_b4};
}
#elif YUZU_UNIX
#elif defined(__unix__)
constexpr IPv4Address TranslateIPv4(in_addr addr) {
const u32 bytes = addr.s_addr;
return IPv4Address{static_cast<u8>(bytes), static_cast<u8>(bytes >> 8),

View file

@ -15,7 +15,7 @@
#include "core/internal_network/socket_proxy.h"
#include "network/network.h"
#if YUZU_UNIX
#ifdef __unix__
#include <sys/socket.h>
#endif

View file

@ -9,7 +9,11 @@
#include <utility>
#if defined(_WIN32)
#elif !YUZU_UNIX
// windows
#elif defined(__unix__)
// unix
#else
// haiku
#error "Platform not implemented"
#endif
@ -24,7 +28,7 @@ struct ProxyPacket;
class SocketBase {
public:
#ifdef YUZU_UNIX
#ifdef __unix__
using SOCKET = int;
static constexpr SOCKET INVALID_SOCKET = -1;
static constexpr SOCKET SOCKET_ERROR = -1;

View file

@ -13,9 +13,9 @@
#include "common/settings.h"
#include "network/network.h"
//#ifdef ENABLE_WEB_SERVICE
#ifdef ENABLE_WEB_SERVICE
#include "web_service/announce_room_json.h"
//#endif
#endif
namespace Core {
@ -28,7 +28,7 @@ AnnounceMultiplayerSession::AnnounceMultiplayerSession() {
Settings::values.eden_username.GetValue(),
Settings::values.eden_token.GetValue());
#else
backend = std::make_unique<AnnounceMultiplayerRoom::NullBackend>();
backend = std::make_unique<AnnounceMultiplayerRoom::NullBackend>();
#endif
}
@ -155,11 +155,12 @@ bool AnnounceMultiplayerSession::IsRunning() const {
void AnnounceMultiplayerSession::UpdateCredentials() {
ASSERT_MSG(!IsRunning(), "Credentials can only be updated when session is not running");
#ifdef ENABLE_WEB_SERVICE
backend = std::make_unique<WebService::RoomJson>(Settings::values.web_api_url.GetValue(),
Settings::values.eden_username.GetValue(),
Settings::values.eden_token.GetValue());
#else
backend = std::make_unique<AnnounceMultiplayerRoom::NullBackend>();
#endif
}

View file

@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2018 yuzu Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later
@ -240,6 +243,7 @@ add_library(shader_recompiler STATIC
runtime_info.h
shader_info.h
varying_state.h
)
target_link_libraries(shader_recompiler PUBLIC common fmt::fmt sirit SPIRV-Tools-opt SPIRV-Tools SPIRV-Tools-link)

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@ -268,4 +271,40 @@ void TranslatorVisitor::ResetOFlag() {
SetOFlag(ir.Imm1(false));
}
IR::U32 TranslatorVisitor::apply_ISBERD_shift(IR::U32 result, Isberd::Shift shift_value) {
if (shift_value != Isberd::Shift::Default) {
return ir.ShiftLeftLogical(result, ir.Imm32(1));
}
return result;
}
IR::U32 TranslatorVisitor::apply_ISBERD_size_read(IR::U32 address, Isberd::SZ sz) {
switch (sz) {
case Isberd::SZ::U8:
return ir.LoadGlobalU8(ir.UConvert(64, address));
case Isberd::SZ::U16:
return ir.LoadGlobalU16(ir.UConvert(64, address));
case Isberd::SZ::U32:
case Isberd::SZ::F32:
return ir.LoadGlobal32(ir.UConvert(64, address));
default:
UNREACHABLE();
}
}
IR::U32 TranslatorVisitor::compute_ISBERD_address(IR::Reg src_reg, u32 src_reg_num, u32 imm, u64 skew_value) {
IR::U32 address{};
if (src_reg_num == 0xFF) {
address = ir.Imm32(imm);
} else {
auto offset = ir.Imm32(imm);
address = ir.IAdd(X(src_reg), offset);
if (skew_value != 0) {
address = ir.IAdd(address, ir.LaneId());
}
}
return address;
};
} // namespace Shader::Maxwell

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@ -53,6 +56,30 @@ enum class FPCompareOp : u64 {
T,
};
namespace Isberd {
enum class Mode : u64 {
Default,
Patch,
Prim,
Attr,
};
enum class Shift : u64 {
Default,
U16,
B32,
};
enum class SZ : u64 {
U8,
U16,
U32,
F32,
};
} // namespace Isberd
class TranslatorVisitor {
public:
explicit TranslatorVisitor(Environment& env_, IR::Block& block) : env{env_}, ir(block) {}
@ -381,6 +408,12 @@ public:
void ResetSFlag();
void ResetCFlag();
void ResetOFlag();
private:
// Helper functions for various translator visitors
IR::U32 apply_ISBERD_shift(IR::U32 result, Isberd::Shift shift_value);
IR::U32 apply_ISBERD_size_read(IR::U32 address, Isberd::SZ sz_value);
IR::U32 compute_ISBERD_address(IR::Reg src_reg, u32 src_reg_num, u32 imm, u64 skew_value);
};
} // namespace Shader::Maxwell

View file

@ -9,21 +9,6 @@
#include "shader_recompiler/frontend/maxwell/translate/impl/impl.h"
namespace Shader::Maxwell {
namespace {
enum class Mode : u64 {
Default,
Patch,
Prim,
Attr,
};
enum class Shift : u64 {
Default,
U16,
B32,
};
} // Anonymous namespace
// Valid only for GS, TI, VS and trap
void TranslatorVisitor::ISBERD(u64 insn) {
@ -35,70 +20,49 @@ void TranslatorVisitor::ISBERD(u64 insn) {
BitField<24, 8, u32> imm;
BitField<31, 1, u64> skew;
BitField<32, 1, u64> o;
BitField<33, 2, Mode> mode;
BitField<47, 2, Shift> shift;
BitField<33, 2, Isberd::Mode> mode;
BitField<36, 4, Isberd::SZ> sz;
BitField<47, 2, Isberd::Shift> shift;
} const isberd{insn};
if (isberd.skew != 0) {
IR::U32 current_lane_id{ir.LaneId()};
IR::U32 result{ir.IAdd(X(isberd.src_reg), current_lane_id)};
X(isberd.dest_reg, result);
}
auto address = compute_ISBERD_address(isberd.src_reg, isberd.src_reg_num, isberd.imm, isberd.skew);
if (isberd.o != 0) {
IR::U32 address{};
IR::F32 result{};
if (isberd.src_reg_num == 0xFF) {
address = ir.Imm32(isberd.imm);
result = ir.GetAttributeIndexed(address);
} else {
IR::U32 offset = ir.Imm32(isberd.imm);
address = ir.IAdd(X(isberd.src_reg), offset);
result = ir.GetAttributeIndexed(address);
}
X(isberd.dest_reg, ir.BitCast<IR::U32>(result));
auto result = apply_ISBERD_size_read(address, isberd.sz.Value());
X(isberd.dest_reg, apply_ISBERD_shift(result, isberd.shift.Value()));
return;
}
if (isberd.mode != Mode::Default) {
IR::F32 result{};
IR::U32 index{};
if (isberd.src_reg_num == 0xFF) {
index = ir.Imm32(isberd.imm);
} else {
index = ir.IAdd(X(isberd.src_reg), ir.Imm32(isberd.imm));
if (isberd.mode != Isberd::Mode::Default) {
IR::F32 result_f32{};
switch (isberd.mode.Value()) {
case Isberd::Mode::Patch:
result_f32 = ir.GetPatch(address.Patch());
break;
case Isberd::Mode::Prim:
result_f32 = ir.GetAttribute(address.Attribute());
break;
case Isberd::Mode::Attr:
result_f32 = ir.GetAttributeIndexed(address);
break;
default:
UNREACHABLE();
}
switch (static_cast<u64>(isberd.mode.Value())) {
case static_cast<u64>(Mode::Patch):
result = ir.GetPatch(index.Patch());
break;
case static_cast<u64>(Mode::Prim):
result = ir.GetAttribute(index.Attribute());
break;
case static_cast<u64>(Mode::Attr):
result = ir.GetAttributeIndexed(index);
break;
}
X(isberd.dest_reg, ir.BitCast<IR::U32>(result));
auto result_u32 = ir.BitCast<IR::U32>(result_f32);
X(isberd.dest_reg, apply_ISBERD_shift(result_u32, isberd.shift.Value()));
return;
}
if (isberd.shift != Shift::Default) {
IR::U32 result{};
switch (static_cast<u64>(isberd.shift.Value())) {
case static_cast<u64>(Shift::U16):
result = ir.ShiftLeftLogical(result, static_cast<IR::U32>(ir.Imm16(1)));
break;
case static_cast<u64>(Shift::B32):
result = ir.ShiftLeftLogical(result, ir.Imm32(1));
break;
}
if (isberd.skew != 0) {
auto result = ir.IAdd(X(isberd.src_reg), ir.LaneId());
X(isberd.dest_reg, result);
return;
}
//LOG_DEBUG(Shader, "(STUBBED) called {}", insn);
if (isberd.src_reg_num == 0xFF) {
IR::U32 src_imm{ir.Imm32(static_cast<u32>(isberd.imm))};
IR::U32 result{ir.IAdd(X(isberd.src_reg), src_imm)};
X(isberd.dest_reg, result);
} else {
X(isberd.dest_reg, X(isberd.src_reg));
}
// Fallback if nothing else applies
X(isberd.dest_reg, X(isberd.src_reg));
}
} // namespace Shader::Maxwell

View file

@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2018 yuzu Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later

View file

@ -24,6 +24,8 @@ using namespace Common::Literals;
namespace OpenGL {
namespace {
// TODO: Needs to explicitly enable ARB_TESSELLATION_SHADER for GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS
constexpr std::array LIMIT_UBOS = {
GL_MAX_VERTEX_UNIFORM_BLOCKS, GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS,
GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS, GL_MAX_GEOMETRY_UNIFORM_BLOCKS,
@ -62,7 +64,7 @@ bool HasExtension(std::span<const std::string_view> extensions, std::string_view
}
std::array<u32, Shader::MaxStageTypes> BuildMaxUniformBuffers() noexcept {
std::array<u32, Shader::MaxStageTypes> max;
std::array<u32, Shader::MaxStageTypes> max{};
std::ranges::transform(LIMIT_UBOS, max.begin(), &GetInteger<u32>);
return max;
}
@ -108,7 +110,7 @@ bool IsASTCSupported() {
static bool HasSlowSoftwareAstc(std::string_view vendor_name, std::string_view renderer) {
// ifdef for Unix reduces string comparisons for non-Windows drivers, and Intel
#ifdef YUZU_UNIX
#ifdef __unix__
// Sorted vaguely by how likely a vendor is to appear
if (vendor_name == "AMD") {
// RadeonSI

View file

@ -60,6 +60,7 @@ size_t StagingBuffers::RequestBuffer(size_t requested_size) {
storage_flags | GL_MAP_PERSISTENT_BIT);
alloc.map = static_cast<u8*>(glMapNamedBufferRange(alloc.buffer.handle, 0, next_pow2_size,
map_flags | GL_MAP_PERSISTENT_BIT));
DEBUG_ASSERT(alloc.map != nullptr);
alloc.size = next_pow2_size;
allocs.emplace_back(std::move(alloc));
return allocs.size() - 1;

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@ -14,23 +17,55 @@
namespace Vulkan {
namespace {
using VideoCore::Surface::PixelFormat;
using VideoCore::Surface::SurfaceType;
VkAttachmentDescription AttachmentDescription(const Device& device, PixelFormat format,
VkSampleCountFlagBits samples) {
using MaxwellToVK::SurfaceFormat;
return {
.flags = {},
.format = SurfaceFormat(device, FormatType::Optimal, true, format).format,
.samples = samples,
.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
.stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE,
.initialLayout = VK_IMAGE_LAYOUT_GENERAL,
.finalLayout = VK_IMAGE_LAYOUT_GENERAL,
};
}
} // Anonymous namespace
constexpr SurfaceType GetSurfaceType(PixelFormat format) {
switch (format) {
// Depth formats
case PixelFormat::D16_UNORM:
case PixelFormat::D32_FLOAT:
case PixelFormat::X8_D24_UNORM:
return SurfaceType::Depth;
// Stencil formats
case PixelFormat::S8_UINT:
return SurfaceType::Stencil;
// Depth+Stencil formats
case PixelFormat::D24_UNORM_S8_UINT:
case PixelFormat::S8_UINT_D24_UNORM:
case PixelFormat::D32_FLOAT_S8_UINT:
return SurfaceType::DepthStencil;
// Everything else is a color texture
default:
return SurfaceType::ColorTexture;
}
}
VkAttachmentDescription AttachmentDescription(const Device& device, PixelFormat format,
VkSampleCountFlagBits samples) {
using MaxwellToVK::SurfaceFormat;
const SurfaceType surface_type = GetSurfaceType(format);
const bool has_stencil = surface_type == SurfaceType::DepthStencil ||
surface_type == SurfaceType::Stencil;
return {
.flags = {},
.format = SurfaceFormat(device, FormatType::Optimal, true, format).format,
.samples = samples,
.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
.stencilLoadOp = has_stencil ? VK_ATTACHMENT_LOAD_OP_LOAD
: VK_ATTACHMENT_LOAD_OP_DONT_CARE,
.stencilStoreOp = has_stencil ? VK_ATTACHMENT_STORE_OP_STORE
: VK_ATTACHMENT_STORE_OP_DONT_CARE,
.initialLayout = VK_IMAGE_LAYOUT_GENERAL,
.finalLayout = VK_IMAGE_LAYOUT_GENERAL,
};
}
} // Anonymous namespace
RenderPassCache::RenderPassCache(const Device& device_) : device{&device_} {}
@ -78,6 +113,18 @@ VkRenderPass RenderPassCache::Get(const RenderPassKey& key) {
.preserveAttachmentCount = 0,
.pPreserveAttachments = nullptr,
};
const VkSubpassDependency dependency{
.srcSubpass = 0, // Current subpass
.dstSubpass = 0, // Same subpass (self-dependency)
.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT |
VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT |
VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
.dstStageMask = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT |
VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
.dstAccessMask = VK_ACCESS_SHADER_READ_BIT,
.dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT
};
pair->second = device->GetLogical().CreateRenderPass({
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
.pNext = nullptr,
@ -86,8 +133,8 @@ VkRenderPass RenderPassCache::Get(const RenderPassKey& key) {
.pAttachments = descriptions.empty() ? nullptr : descriptions.data(),
.subpassCount = 1,
.pSubpasses = &subpass,
.dependencyCount = 0,
.pDependencies = nullptr,
.dependencyCount = 1,
.pDependencies = &dependency,
});
return *pair->second;
}

View file

@ -497,6 +497,11 @@ if (YUZU_ROOM)
target_link_libraries(yuzu PRIVATE yuzu-room)
endif()
# Explicit linking required
if (${CMAKE_SYSTEM_NAME} STREQUAL "SunOS")
target_link_libraries(yuzu PRIVATE X11)
endif()
# Extra deps
add_subdirectory(externals)
target_link_libraries(yuzu PRIVATE QuaZip::QuaZip)

View file

@ -295,7 +295,7 @@ void ConfigureGraphics::Setup(const ConfigurationShared::Builder& builder) {
api_restore_global_button = widget->restore_button;
if (!Settings::IsConfiguringGlobal()) {
QObject::connect(api_restore_global_button, &QAbstractButton::clicked,
api_restore_global_button->connect(api_restore_global_button, &QAbstractButton::clicked,
[this](bool) { UpdateAPILayout(); });
// Detach API's restore button and place it where we want
@ -327,7 +327,7 @@ void ConfigureGraphics::Setup(const ConfigurationShared::Builder& builder) {
restore_button->setEnabled(true);
widget->layout()->addWidget(restore_button);
QObject::connect(restore_button, &QAbstractButton::clicked,
restore_button->connect(restore_button, &QAbstractButton::clicked,
[restore_button, this](bool) {
Settings::values.vsync_mode.SetGlobal(true);
PopulateVSyncModeSelection(true);
@ -340,7 +340,7 @@ void ConfigureGraphics::Setup(const ConfigurationShared::Builder& builder) {
UpdateVsyncSetting();
restore_button->setVisible(true);
};
QObject::connect(widget->combobox, QOverload<int>::of(&QComboBox::activated),
widget->combobox->connect(widget->combobox, QOverload<int>::of(&QComboBox::activated),
[set_non_global]() { set_non_global(); });
vsync_restore_global_button = restore_button;
}
@ -379,7 +379,7 @@ void ConfigureGraphics::Setup(const ConfigurationShared::Builder& builder) {
Settings::values.bg_red.UsingGlobal(), ui->bg_widget);
ui->bg_widget->layout()->addWidget(bg_restore_button);
QObject::connect(bg_restore_button, &QAbstractButton::clicked,
bg_restore_button->connect(bg_restore_button, &QAbstractButton::clicked,
[bg_restore_button, this](bool) {
const int r = Settings::values.bg_red.GetValue(true);
const int g = Settings::values.bg_green.GetValue(true);
@ -390,7 +390,7 @@ void ConfigureGraphics::Setup(const ConfigurationShared::Builder& builder) {
bg_restore_button->setEnabled(false);
});
QObject::connect(ui->bg_button, &QAbstractButton::clicked, [bg_restore_button](bool) {
ui->bg_button->connect(ui->bg_button, &QAbstractButton::clicked, [bg_restore_button](bool) {
bg_restore_button->setVisible(true);
bg_restore_button->setEnabled(true);
});

View file

@ -2429,7 +2429,7 @@ void PlayerControlPreview::DrawProJoystick(QPainter& p, const QPointF center, co
1.0 - std::sqrt((offset.x() * offset.x()) + (offset.y() * offset.y())) * 0.1f);
const float rotation =
((offset.x() == 0) ? atan(1) * 2 : atan(offset.y() / offset.x())) * (180 / (atan(1) * 4));
((offset.x() == 0.f) ? std::atan(1.f) * 2.f : std::atan(offset.y() / offset.x())) * (180.f / (std::atan(1.f) * 4.f));
p.save();
p.translate(offset_center);

View file

@ -118,7 +118,7 @@ QWidget* Widget::CreateCheckBox(Settings::BasicSetting* bool_setting, const QStr
};
if (!Settings::IsConfiguringGlobal()) {
QObject::connect(checkbox, &QCheckBox::clicked, [touch]() { touch(); });
checkbox->connect(checkbox, &QCheckBox::clicked, [touch]() { touch(); });
}
return checkbox;
@ -165,7 +165,7 @@ QWidget* Widget::CreateCombobox(std::function<std::string()>& serializer,
};
if (!Settings::IsConfiguringGlobal()) {
QObject::connect(combobox, QOverload<int>::of(&QComboBox::activated),
combobox->connect(combobox, QOverload<int>::of(&QComboBox::activated),
[touch]() { touch(); });
}
@ -223,9 +223,8 @@ QWidget* Widget::CreateRadioGroup(std::function<std::string()>& serializer,
};
if (!Settings::IsConfiguringGlobal()) {
for (const auto& [id, button] : radio_buttons) {
QObject::connect(button, &QAbstractButton::clicked, [touch]() { touch(); });
}
for (const auto& [id, button] : radio_buttons)
button->connect(button, &QAbstractButton::clicked, [touch]() { touch(); });
}
return group;
@ -249,7 +248,7 @@ QWidget* Widget::CreateLineEdit(std::function<std::string()>& serializer,
};
if (!Settings::IsConfiguringGlobal()) {
QObject::connect(line_edit, &QLineEdit::textChanged, [touch]() { touch(); });
line_edit->connect(line_edit, &QLineEdit::textChanged, [touch]() { touch(); });
}
return line_edit;
@ -266,7 +265,7 @@ static void CreateIntSlider(Settings::BasicSetting& setting, bool reversed, floa
feedback->setText(use_format.arg(QVariant::fromValue(present).value<QString>()));
};
QObject::connect(slider, &QAbstractSlider::valueChanged, update_feedback);
slider->connect(slider, &QAbstractSlider::valueChanged, update_feedback);
update_feedback(std::strtol(setting.ToString().c_str(), nullptr, 0));
slider->setMinimum(std::strtol(setting.MinVal().c_str(), nullptr, 0));
@ -293,7 +292,7 @@ static void CreateFloatSlider(Settings::BasicSetting& setting, bool reversed, fl
feedback->setText(use_format.arg(QVariant::fromValue(present).value<QString>()));
};
QObject::connect(slider, &QAbstractSlider::valueChanged, update_feedback);
slider->connect(slider, &QAbstractSlider::valueChanged, update_feedback);
update_feedback(std::strtof(setting.ToString().c_str(), nullptr));
slider->setMinimum(min_val * use_multiplier);
@ -346,7 +345,7 @@ QWidget* Widget::CreateSlider(bool reversed, float multiplier, const QString& gi
slider->setInvertedAppearance(reversed);
if (!Settings::IsConfiguringGlobal()) {
QObject::connect(slider, &QAbstractSlider::actionTriggered, [touch]() { touch(); });
slider->connect(slider, &QAbstractSlider::actionTriggered, [touch]() { touch(); });
}
return container;
@ -376,7 +375,7 @@ QWidget* Widget::CreateSpinBox(const QString& given_suffix,
};
if (!Settings::IsConfiguringGlobal()) {
QObject::connect(spinbox, QOverload<int>::of(&QSpinBox::valueChanged), [this, touch]() {
spinbox->connect(spinbox, QOverload<int>::of(&QSpinBox::valueChanged), [this, touch]() {
if (spinbox->value() != std::strtol(setting.ToStringGlobal().c_str(), nullptr, 0)) {
touch();
}
@ -410,7 +409,7 @@ QWidget* Widget::CreateDoubleSpinBox(const QString& given_suffix,
};
if (!Settings::IsConfiguringGlobal()) {
QObject::connect(double_spinbox, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
double_spinbox->connect(double_spinbox, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
[this, touch]() {
if (double_spinbox->value() !=
std::strtod(setting.ToStringGlobal().c_str(), nullptr)) {
@ -453,8 +452,7 @@ QWidget* Widget::CreateHexEdit(std::function<std::string()>& serializer,
restore_func = [this, to_hex]() { line_edit->setText(to_hex(RelevantDefault(setting))); };
if (!Settings::IsConfiguringGlobal()) {
QObject::connect(line_edit, &QLineEdit::textChanged, [touch]() { touch(); });
line_edit->connect(line_edit, &QLineEdit::textChanged, [touch]() { touch(); });
}
return line_edit;
@ -488,7 +486,7 @@ QWidget* Widget::CreateDateTimeEdit(bool disabled, bool restrict,
restore_func = [this, get_clear_val]() { date_time_edit->setDateTime(get_clear_val()); };
if (!Settings::IsConfiguringGlobal()) {
QObject::connect(date_time_edit, &QDateTimeEdit::editingFinished,
date_time_edit->connect(date_time_edit, &QDateTimeEdit::editingFinished,
[this, get_clear_val, touch]() {
if (date_time_edit->dateTime() != get_clear_val()) {
touch();
@ -665,7 +663,7 @@ void Widget::SetupComponent(const QString& label, std::function<void()>& load_fu
} else {
layout->addWidget(restore_button);
QObject::connect(restore_button, &QAbstractButton::clicked,
restore_button->connect(restore_button, &QAbstractButton::clicked,
[this, restore_func, checkbox_restore_func](bool) {
LOG_DEBUG(Frontend, "Restore global state for \"{}\"",
setting.GetLabel());

View file

@ -100,7 +100,7 @@ void DiscordImpl::Update() {
request.setTransferTimeout(3000);
QNetworkReply* reply = manager.head(request);
QEventLoop request_event_loop;
QObject::connect(reply, &QNetworkReply::finished, &request_event_loop, &QEventLoop::quit);
reply->connect(reply, &QNetworkReply::finished, &request_event_loop, &QEventLoop::quit);
request_event_loop.exec();
UpdateGameStatus(reply->error());

View file

@ -536,7 +536,7 @@ GMainWindow::GMainWindow(bool has_broken_vulkan)
}
return QString{};
});
QObject::connect(&update_watcher, &QFutureWatcher<QString>::finished, this,
update_watcher.connect(&update_watcher, &QFutureWatcher<QString>::finished, this,
&GMainWindow::OnEmulatorUpdateAvailable);
update_watcher.setFuture(update_future);
}
@ -5786,7 +5786,7 @@ int main(int argc, char* argv[]) {
// After settings have been loaded by GMainWindow, apply the filter
main_window.show();
QObject::connect(&app, &QGuiApplication::applicationStateChanged, &main_window,
app.connect(&app, &QGuiApplication::applicationStateChanged, &main_window,
&GMainWindow::OnAppFocusStateChanged);
int result = app.exec();

View file

@ -7,7 +7,7 @@
#include <cstring>
#include <processthreadsapi.h>
#include <windows.h>
#elif defined(YUZU_UNIX)
#else
#include <cstring>
#include <errno.h>
#include <spawn.h>
@ -56,7 +56,7 @@ bool CheckEnvVars(bool* is_child) {
IS_CHILD_ENV_VAR, GetLastError());
return true;
}
#elif defined(YUZU_UNIX)
#else
const char* startup_check_var = getenv(STARTUP_CHECK_ENV_VAR);
if (startup_check_var != nullptr &&
std::strncmp(startup_check_var, ENV_VAR_ENABLED_TEXT, 8) == 0) {
@ -110,7 +110,7 @@ bool StartupChecks(const char* arg0, bool* has_broken_vulkan, bool perform_vulka
STARTUP_CHECK_ENV_VAR, GetLastError());
}
#elif defined(YUZU_UNIX)
#else
const int env_var_set = setenv(STARTUP_CHECK_ENV_VAR, ENV_VAR_ENABLED_TEXT, 1);
if (env_var_set == -1) {
const int err = errno;
@ -175,7 +175,7 @@ bool SpawnChild(const char* arg0, PROCESS_INFORMATION* pi, int flags) {
return true;
}
#elif defined(YUZU_UNIX)
#else
pid_t SpawnChild(const char* arg0) {
const pid_t pid = fork();

View file

@ -5,7 +5,7 @@
#ifdef _WIN32
#include <windows.h>
#elif defined(YUZU_UNIX)
#else
#include <sys/types.h>
#endif
@ -19,6 +19,6 @@ bool StartupChecks(const char* arg0, bool* has_broken_vulkan, bool perform_vulka
#ifdef _WIN32
bool SpawnChild(const char* arg0, PROCESS_INFORMATION* pi, int flags);
#elif defined(YUZU_UNIX)
#else
pid_t SpawnChild(const char* arg0);
#endif