Fallback Vulkan R6G5B5 textures to RGBA8 SNORM

This commit is contained in:
izzy2lost
2026-04-08 02:34:52 -04:00
parent 862b4bd58d
commit e9a6201d5b
3 changed files with 5 additions and 3 deletions
+3 -2
View File
@@ -384,12 +384,12 @@ uint8_t *pgraph_convert_texture_data(const TextureShape s, const uint8_t *data,
}
} else if (s.color_format == NV097_SET_TEXTURE_FORMAT_COLOR_SZ_R6G5B5) {
assert(depth == 1); /* FIXME */
size = width * height * 3;
size = width * height * 4;
converted_data = g_malloc(size);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
uint16_t rgb655 = *(uint16_t *)(data + y * row_pitch + x * 2);
int8_t *pixel = (int8_t *)&converted_data[(y * width + x) * 3];
int8_t *pixel = (int8_t *)&converted_data[(y * width + x) * 4];
/* Maps 5 bit G and B signed value range to 8 bit
* signed values. R is probably unsigned.
*/
@@ -397,6 +397,7 @@ uint8_t *pgraph_convert_texture_data(const TextureShape s, const uint8_t *data,
pixel[0] = ((rgb655 & 0xFC00) >> 10) * 0x7F / 0x3F;
pixel[1] = ((rgb655 & 0x03E0) >> 5) * 0xFF / 0x1F - 0x80;
pixel[2] = (rgb655 & 0x001F) * 0xFF / 0x1F - 0x80;
pixel[3] = 0x7F;
}
}
} else if (s.color_format == NV097_SET_TEXTURE_FORMAT_COLOR_SZ_A4R4G4B4 ||
+1 -1
View File
@@ -244,7 +244,7 @@ static const VkColorFormatInfo kelvin_color_format_vk_map[66] = {
{ VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G }
},
[NV097_SET_TEXTURE_FORMAT_COLOR_SZ_R6G5B5] = {
VK_FORMAT_R8G8B8_SNORM, // Converted
VK_FORMAT_R8G8B8A8_SNORM, // Converted
},
[NV097_SET_TEXTURE_FORMAT_COLOR_SZ_G8B8] = {
VK_FORMAT_R8G8_UNORM,
+1
View File
@@ -879,6 +879,7 @@ static unsigned int vk_format_texel_size(VkFormat format)
case VK_FORMAT_A4R4G4B4_UNORM_PACK16: return 2;
case VK_FORMAT_R16_UNORM: return 2;
case VK_FORMAT_R8G8B8_SNORM: return 3;
case VK_FORMAT_R8G8B8A8_SNORM: return 4;
case VK_FORMAT_B8G8R8A8_UNORM: return 4;
case VK_FORMAT_R8G8B8A8_UNORM: return 4;
case VK_FORMAT_R32_UINT: return 4;