mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-31 14:52:11 +01:00
[dxvk] Properly encode KHR_maintenance5 formats
This commit is contained in:
parent
4dd0afe121
commit
32399461da
@ -534,13 +534,15 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t encodeColorFormat(VkFormat format, uint32_t index) {
|
static uint64_t encodeColorFormat(VkFormat format, uint32_t index) {
|
||||||
uint64_t value = uint64_t(format);
|
uint64_t value = 0u;
|
||||||
|
|
||||||
if (value >= uint64_t(VK_FORMAT_A4R4G4B4_UNORM_PACK16)) {
|
for (const auto& p : s_colorFormatRanges) {
|
||||||
value -= uint64_t(VK_FORMAT_A4R4G4B4_UNORM_PACK16);
|
if (format >= p.first && format <= p.second) {
|
||||||
value += uint64_t(VK_FORMAT_E5B9G9R9_UFLOAT_PACK32) + 1;
|
value += uint32_t(format) - uint32_t(p.first);
|
||||||
} else if (value > uint64_t(VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
|
break;
|
||||||
value = 0;
|
}
|
||||||
|
|
||||||
|
value += uint32_t(p.second) - uint32_t(p.first) + 1u;
|
||||||
}
|
}
|
||||||
|
|
||||||
return value << (7 * index);
|
return value << (7 * index);
|
||||||
@ -561,14 +563,24 @@ namespace dxvk {
|
|||||||
static VkFormat decodeColorFormat(uint64_t value, uint32_t index) {
|
static VkFormat decodeColorFormat(uint64_t value, uint32_t index) {
|
||||||
value = (value >> (7 * index)) & 0x7F;
|
value = (value >> (7 * index)) & 0x7F;
|
||||||
|
|
||||||
if (value > uint64_t(VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
|
for (const auto& p : s_colorFormatRanges) {
|
||||||
value -= uint64_t(VK_FORMAT_E5B9G9R9_UFLOAT_PACK32) + 1ull;
|
uint32_t rangeSize = uint32_t(p.second) - uint32_t(p.first) + 1u;
|
||||||
value += uint64_t(VK_FORMAT_A4R4G4B4_UNORM_PACK16);
|
|
||||||
|
if (value < rangeSize)
|
||||||
|
return VkFormat(uint32_t(p.first) + uint32_t(value));
|
||||||
|
|
||||||
|
value -= rangeSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
return VkFormat(value);
|
return VK_FORMAT_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static constexpr std::array<std::pair<VkFormat, VkFormat>, 3> s_colorFormatRanges = {{
|
||||||
|
{ VK_FORMAT_UNDEFINED, VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 }, /* 0 - 123 */
|
||||||
|
{ VK_FORMAT_A4R4G4B4_UNORM_PACK16, VK_FORMAT_A4B4G4R4_UNORM_PACK16 }, /* 124 - 125 */
|
||||||
|
{ VK_FORMAT_A1B5G5R5_UNORM_PACK16_KHR, VK_FORMAT_A8_UNORM_KHR }, /* 126 - 127 */
|
||||||
|
}};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user