mirror of
https://git.citron-emu.org/citron/emulator
synced 2025-12-21 11:33:35 +00:00
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 <zephyron@citron-emu.org>
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "common/common_types.h"
|
#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,
|
PixelFormat PixelFormatFromTextureInfo(TextureFormat format, ComponentType red, ComponentType green,
|
||||||
ComponentType blue, ComponentType alpha,
|
ComponentType blue, ComponentType alpha,
|
||||||
bool is_srgb) noexcept {
|
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<u32>(format) == 0 && static_cast<u32>(red) == 0 &&
|
||||||
|
static_cast<u32>(green) == 0 && static_cast<u32>(blue) == 0 &&
|
||||||
|
static_cast<u32>(alpha) == 0) {
|
||||||
|
return PixelFormat::A8B8G8R8_UNORM;
|
||||||
|
}
|
||||||
|
|
||||||
switch (Hash(format, red, green, blue, alpha, is_srgb)) {
|
switch (Hash(format, red, green, blue, alpha, is_srgb)) {
|
||||||
case Hash(TextureFormat::A8B8G8R8, UNORM):
|
case Hash(TextureFormat::A8B8G8R8, UNORM):
|
||||||
return PixelFormat::A8B8G8R8_UNORM;
|
return PixelFormat::A8B8G8R8_UNORM;
|
||||||
|
|||||||
Reference in New Issue
Block a user