diff --git a/thirdparty/rexglue-sdk/src/graphics/pipeline/texture/extent.cpp b/thirdparty/rexglue-sdk/src/graphics/pipeline/texture/extent.cpp index 09f5b407..f4c1fa42 100644 --- a/thirdparty/rexglue-sdk/src/graphics/pipeline/texture/extent.cpp +++ b/thirdparty/rexglue-sdk/src/graphics/pipeline/texture/extent.cpp @@ -13,6 +13,7 @@ #include #include +#include #include namespace rex::graphics { @@ -46,6 +47,13 @@ static TextureExtent CalculateExtent(const FormatInfo* format_info, uint32_t pit uint32_t byte_pitch = extent.block_pitch_h * bytes_per_block; if (!is_tiled) { + if (bytes_per_block == 0) { + REXGPU_ERROR( + "TextureExtent::Calculate received linear guest texture format {} with zero " + "bytes_per_block (pitch={}, height={}, depth={})", + format_info->name, pitch, height, depth); + return extent; + } // Each row must be a multiple of 256 bytes in linear textures. byte_pitch = rex::round_up(byte_pitch, 256); extent.block_pitch_h = byte_pitch / bytes_per_block; diff --git a/thirdparty/rexglue-sdk/src/graphics/pipeline/texture/info_formats.cpp b/thirdparty/rexglue-sdk/src/graphics/pipeline/texture/info_formats.cpp index c456e1ed..437bb807 100644 --- a/thirdparty/rexglue-sdk/src/graphics/pipeline/texture/info_formats.cpp +++ b/thirdparty/rexglue-sdk/src/graphics/pipeline/texture/info_formats.cpp @@ -12,6 +12,7 @@ // clang-format off #include +#include namespace rex::graphics { @@ -86,6 +87,13 @@ const FormatInfo* FormatInfo::Get(uint32_t gpu_format) { FORMAT_INFO(k_8_8_8_8_GAMMA_EDRAM , kUncompressed, 1, 1, 32), FORMAT_INFO(k_2_10_10_10_FLOAT_EDRAM , kUncompressed, 1, 1, 32), }; + static const FormatInfo invalid_format_info = { + xenos::TextureFormat::k_8_8_8_8, "k_invalid", FormatType::kUncompressed, 1, 1, 32}; + if (gpu_format >= (sizeof(format_infos) / sizeof(format_infos[0]))) { + REXGPU_ERROR("Texture format index {} is out of range; falling back to {}", gpu_format, + invalid_format_info.name); + return &invalid_format_info; + } return &format_infos[gpu_format]; } #undef FORMAT_INFO