From 750af88ed9a9bfbd64ebd0c551a57e007382b69d Mon Sep 17 00:00:00 2001 From: Zephyron Date: Mon, 8 Dec 2025 19:39:23 +1000 Subject: [PATCH] fix(video): handle invalid texture format in format lookup table Return default pixel format for uninitialized texture descriptors (format=0, components=0) instead of asserting. Prevents crashes when texture cache encounters uninitialized texture data. Fixes assertion failures in format_lookup_table.cpp:250. Signed-off-by: Zephyron --- src/video_core/texture_cache/format_lookup_table.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/video_core/texture_cache/format_lookup_table.cpp b/src/video_core/texture_cache/format_lookup_table.cpp index 8c774f512..0fde8361f 100644 --- a/src/video_core/texture_cache/format_lookup_table.cpp +++ b/src/video_core/texture_cache/format_lookup_table.cpp @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project +// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include "common/common_types.h" @@ -41,6 +42,14 @@ constexpr u32 Hash(TextureFormat format, ComponentType component, bool is_srgb = PixelFormat PixelFormatFromTextureInfo(TextureFormat format, ComponentType red, ComponentType green, ComponentType blue, ComponentType alpha, bool is_srgb) noexcept { + // Handle invalid/uninitialized texture format (0) with zero components + // This can occur when texture descriptors are not yet initialized + if (static_cast(format) == 0 && static_cast(red) == 0 && + static_cast(green) == 0 && static_cast(blue) == 0 && + static_cast(alpha) == 0) { + return PixelFormat::A8B8G8R8_UNORM; + } + switch (Hash(format, red, green, blue, alpha, is_srgb)) { case Hash(TextureFormat::A8B8G8R8, UNORM): return PixelFormat::A8B8G8R8_UNORM;