renderer: add translate_format function for SceGxmTextureFormat and update texture configuration

This commit is contained in:
Francisco José García García
2026-04-22 08:22:53 +02:00
parent 5b42300a15
commit 7606ed4e85
3 changed files with 19 additions and 1 deletions
@@ -45,6 +45,7 @@ vk::ComponentMapping translate_swizzle(SceGxmColorFormat format);
} // namespace color
namespace texture {
vk::Format translate_format(SceGxmTextureFormat format);
vk::Format translate_format(SceGxmTextureBaseFormat base_format);
vk::ComponentMapping translate_swizzle(SceGxmTextureFormat format);
vk::SamplerAddressMode translate_address_mode(SceGxmTextureAddrMode src);
@@ -717,6 +717,23 @@ vk::ComponentMapping translate_swizzle(SceGxmTextureFormat format) {
}
}
vk::Format translate_format(SceGxmTextureFormat format) {
const SceGxmTextureBaseFormat base_format = gxm::get_base_format(format);
if (base_format == SCE_GXM_TEXTURE_BASE_FORMAT_U1U5U5U5) {
switch (format & SCE_GXM_TEXTURE_SWIZZLE_MASK) {
case SCE_GXM_TEXTURE_SWIZZLE4_RGBA:
case SCE_GXM_TEXTURE_SWIZZLE4_BGRA:
case SCE_GXM_TEXTURE_SWIZZLE4_RGB1:
case SCE_GXM_TEXTURE_SWIZZLE4_BGR1:
return vk::Format::eR5G5B5A1UnormPack16;
default:
return vk::Format::eA1R5G5B5UnormPack16;
}
}
return translate_format(base_format);
}
vk::Format translate_format(SceGxmTextureBaseFormat base_format) {
switch (base_format) {
case SCE_GXM_TEXTURE_BASE_FORMAT_U8:
+1 -1
View File
@@ -361,7 +361,7 @@ void VKTextureCache::configure_texture(const SceGxmTexture &gxm_texture) {
const uint16_t mip_count = renderer::texture::get_upload_mip(gxm_texture.true_mip_count(), width, height);
vk::Format vk_format = texture::translate_format(base_format);
vk::Format vk_format = texture::translate_format(format);
if (gxm::is_bcn_format(base_format) && !support_dxt)
// texture will be decompressed
vk_format = bcn_to_rgba8(vk_format);