diff --git a/src/video_core/amdgpu/pixel_format.cpp b/src/video_core/amdgpu/pixel_format.cpp index 676d452b8..b13fc2d11 100644 --- a/src/video_core/amdgpu/pixel_format.cpp +++ b/src/video_core/amdgpu/pixel_format.cpp @@ -213,7 +213,7 @@ static constexpr std::array component_offset = { std::array{0, 4, 8, 12}, // 19 Format4_4_4_4 std::array{0, 24, -1, -1}, // 20 Format8_24 std::array{0, 8, -1, -1}, // 21 Format24_8 - std::array{0, 8, -1, -1}, // 22 FormatX24_8_32 + std::array{0, 8, -1, -1}, // 22 FormatX24_8_32 std::array{-1, -1, -1, -1}, // 23 std::array{-1, -1, -1, -1}, // 24 std::array{-1, -1, -1, -1}, // 25 diff --git a/src/video_core/renderer_vulkan/liverpool_to_vk.cpp b/src/video_core/renderer_vulkan/liverpool_to_vk.cpp index a4cdd35e2..73c23dfd9 100644 --- a/src/video_core/renderer_vulkan/liverpool_to_vk.cpp +++ b/src/video_core/renderer_vulkan/liverpool_to_vk.cpp @@ -8,7 +8,8 @@ #include -#define INVALID_NUMBER_FORMAT_COMBO LOG_ERROR(Render_Vulkan, "Unsupported number type {} for format {}", number_type, format); +#define INVALID_NUMBER_FORMAT_COMBO \ + LOG_ERROR(Render_Vulkan, "Unsupported number type {} for format {}", number_type, format); namespace Vulkan::LiverpoolToVK { @@ -738,10 +739,12 @@ vk::ClearValue ColorBufferClearValue(const AmdGpu::Liverpool::ColorBuffer& color const auto num_bits = AmdGpu::NumBits(color_buffer.info.format); auto num_components = AmdGpu::NumComponents(format); - const bool comp_swap_alt = comp_swap == AmdGpu::Liverpool::ColorBuffer::SwapMode::Alternate || - comp_swap == AmdGpu::Liverpool::ColorBuffer::SwapMode::AlternateReverse; - const bool comp_swap_reverse = comp_swap == AmdGpu::Liverpool::ColorBuffer::SwapMode::StandardReverse || - comp_swap == AmdGpu::Liverpool::ColorBuffer::SwapMode::AlternateReverse; + const bool comp_swap_alt = + comp_swap == AmdGpu::Liverpool::ColorBuffer::SwapMode::Alternate || + comp_swap == AmdGpu::Liverpool::ColorBuffer::SwapMode::AlternateReverse; + const bool comp_swap_reverse = + comp_swap == AmdGpu::Liverpool::ColorBuffer::SwapMode::StandardReverse || + comp_swap == AmdGpu::Liverpool::ColorBuffer::SwapMode::AlternateReverse; vk::ClearColorValue color{}; @@ -752,7 +755,7 @@ vk::ClearValue ColorBufferClearValue(const AmdGpu::Liverpool::ColorBuffer& color case AmdGpu::NumberFormat::Srgb: // Should we handle gamma correction here? color.float32[0] = NumberUtils::U8ToUnorm(c0 & 0xff); break; - break; + break; case AmdGpu::NumberFormat::Snorm: color.float32[0] = NumberUtils::S8ToSnorm(c0 & 0xff); break; @@ -789,16 +792,16 @@ vk::ClearValue ColorBufferClearValue(const AmdGpu::Liverpool::ColorBuffer& color switch (number_type) { case AmdGpu::NumberFormat::Unorm: case AmdGpu::NumberFormat::Srgb: // Should we handle gamma correction here? - color.float32[0] = NumberUtils::U8ToUnorm( c0 & 0xff); + color.float32[0] = NumberUtils::U8ToUnorm(c0 & 0xff); color.float32[1] = NumberUtils::U8ToUnorm((c0 >> 8) & 0xff); break; case AmdGpu::NumberFormat::Snorm: - color.float32[0] = NumberUtils::S8ToSnorm( c0 & 0xff); + color.float32[0] = NumberUtils::S8ToSnorm(c0 & 0xff); color.float32[1] = NumberUtils::S8ToSnorm((c0 >> 8) & 0xff); break; case AmdGpu::NumberFormat::Uint: case AmdGpu::NumberFormat::Sint: - color.uint32[0] = c0 & 0xff; + color.uint32[0] = c0 & 0xff; color.uint32[1] = (c0 >> 8) & 0xff; break; default: @@ -823,20 +826,20 @@ vk::ClearValue ColorBufferClearValue(const AmdGpu::Liverpool::ColorBuffer& color case AmdGpu::DataFormat::Format16_16: switch (number_type) { case AmdGpu::NumberFormat::Unorm: - color.float32[0] = NumberUtils::U16ToUnorm( c0 & 0xffff); + color.float32[0] = NumberUtils::U16ToUnorm(c0 & 0xffff); color.float32[1] = NumberUtils::U16ToUnorm((c0 >> 16) & 0xffff); break; case AmdGpu::NumberFormat::Snorm: - color.float32[0] = NumberUtils::S16ToSnorm( c0 & 0xffff); + color.float32[0] = NumberUtils::S16ToSnorm(c0 & 0xffff); color.float32[1] = NumberUtils::S16ToSnorm((c0 >> 16) & 0xffff); break; case AmdGpu::NumberFormat::Uint: case AmdGpu::NumberFormat::Sint: - color.uint32[0] = c0 & 0xffff; + color.uint32[0] = c0 & 0xffff; color.uint32[1] = (c0 >> 16) & 0xffff; break; case AmdGpu::NumberFormat::Float: - color.float32[0] = NumberUtils::Uf16ToF32( c0 & 0xffff); + color.float32[0] = NumberUtils::Uf16ToF32(c0 & 0xffff); color.float32[1] = NumberUtils::Uf16ToF32((c0 >> 16) & 0xffff); break; default: @@ -845,47 +848,50 @@ vk::ClearValue ColorBufferClearValue(const AmdGpu::Liverpool::ColorBuffer& color } break; case AmdGpu::DataFormat::Format10_11_11: - color.float32[0] = NumberUtils::Uf11ToF32( c0 & 0x7ff); + color.float32[0] = NumberUtils::Uf11ToF32(c0 & 0x7ff); color.float32[1] = NumberUtils::Uf11ToF32((c0 >> 11) & 0x7ff); color.float32[2] = NumberUtils::Uf10ToF32((c0 >> 22) & 0x3ff); break; case AmdGpu::DataFormat::Format11_11_10: - color.float32[0] = NumberUtils::Uf10ToF32( c0 & 0x3ff); + color.float32[0] = NumberUtils::Uf10ToF32(c0 & 0x3ff); color.float32[1] = NumberUtils::Uf11ToF32((c0 >> 10) & 0x7ff); color.float32[2] = NumberUtils::Uf11ToF32((c0 >> 21) & 0x7ff); break; case AmdGpu::DataFormat::Format5_9_9_9: { int exponent; - union { float f; u32 u; } scale; + union { + float f; + u32 u; + } scale; exponent = (c0 >> 27) - 10; scale.u = (exponent + 127) << 23; - color.float32[0] = ( c0 & 0x1ff) * scale.f; - color.float32[1] = ((c0 >> 9) & 0x1ff) * scale.f; + color.float32[0] = (c0 & 0x1ff) * scale.f; + color.float32[1] = ((c0 >> 9) & 0x1ff) * scale.f; color.float32[2] = ((c0 >> 18) & 0x1ff) * scale.f; break; } case AmdGpu::DataFormat::Format10_10_10_2: switch (number_type) { case AmdGpu::NumberFormat::Unorm: - color.float32[0] = NumberUtils::U2ToUnorm( c0 & 0x3); - color.float32[1] = NumberUtils::U10ToUnorm((c0 >> 2) & 0x3ff); + color.float32[0] = NumberUtils::U2ToUnorm(c0 & 0x3); + color.float32[1] = NumberUtils::U10ToUnorm((c0 >> 2) & 0x3ff); color.float32[2] = NumberUtils::U10ToUnorm((c0 >> 12) & 0x3ff); - color.float32[3] = NumberUtils::U10ToUnorm( c0 >> 22); + color.float32[3] = NumberUtils::U10ToUnorm(c0 >> 22); break; case AmdGpu::NumberFormat::Snorm: - color.float32[0] = NumberUtils::S2ToSnorm( c0 & 0x3); - color.float32[1] = NumberUtils::S10ToSnorm((c0 >> 2) & 0x3ff); + color.float32[0] = NumberUtils::S2ToSnorm(c0 & 0x3); + color.float32[1] = NumberUtils::S10ToSnorm((c0 >> 2) & 0x3ff); color.float32[2] = NumberUtils::S10ToSnorm((c0 >> 12) & 0x3ff); - color.float32[3] = NumberUtils::S2ToSnorm( c0 >> 22); + color.float32[3] = NumberUtils::S2ToSnorm(c0 >> 22); break; case AmdGpu::NumberFormat::Uint: case AmdGpu::NumberFormat::Sint: - color.uint32[0] = c0 & 0x3; - color.uint32[1] = (c0 >> 2) & 0x3ff; + color.uint32[0] = c0 & 0x3; + color.uint32[1] = (c0 >> 2) & 0x3ff; color.uint32[2] = (c0 >> 12) & 0x3ff; - color.uint32[3] = c0 >> 22; + color.uint32[3] = c0 >> 22; break; default: INVALID_NUMBER_FORMAT_COMBO; @@ -895,23 +901,23 @@ vk::ClearValue ColorBufferClearValue(const AmdGpu::Liverpool::ColorBuffer& color case AmdGpu::DataFormat::Format2_10_10_10: switch (number_type) { case AmdGpu::NumberFormat::Unorm: - color.float32[0] = NumberUtils::U10ToUnorm( c0 & 0x3ff); + color.float32[0] = NumberUtils::U10ToUnorm(c0 & 0x3ff); color.float32[1] = NumberUtils::U10ToUnorm((c0 >> 10) & 0x3ff); color.float32[2] = NumberUtils::U10ToUnorm((c0 >> 20) & 0x3ff); - color.float32[3] = NumberUtils::U2ToUnorm( c0 >> 30); + color.float32[3] = NumberUtils::U2ToUnorm(c0 >> 30); break; case AmdGpu::NumberFormat::Snorm: - color.float32[0] = NumberUtils::S10ToSnorm( c0 & 0x3ff); + color.float32[0] = NumberUtils::S10ToSnorm(c0 & 0x3ff); color.float32[1] = NumberUtils::S10ToSnorm((c0 >> 10) & 0x3ff); color.float32[2] = NumberUtils::S10ToSnorm((c0 >> 20) & 0x3ff); - color.float32[3] = NumberUtils::S2ToSnorm( c0 >> 30); + color.float32[3] = NumberUtils::S2ToSnorm(c0 >> 30); break; case AmdGpu::NumberFormat::Uint: case AmdGpu::NumberFormat::Sint: - color.uint32[0] = c0 & 0x3ff; + color.uint32[0] = c0 & 0x3ff; color.uint32[1] = (c0 >> 10) & 0x3ff; color.uint32[2] = (c0 >> 20) & 0x3ff; - color.uint32[3] = c0 >> 30; + color.uint32[3] = c0 >> 30; break; default: INVALID_NUMBER_FORMAT_COMBO; @@ -922,23 +928,23 @@ vk::ClearValue ColorBufferClearValue(const AmdGpu::Liverpool::ColorBuffer& color switch (number_type) { case AmdGpu::NumberFormat::Unorm: case AmdGpu::NumberFormat::Srgb: // Should we handle gamma correction here? - color.float32[0] = NumberUtils::U8ToUnorm( c0 & 0xff); - color.float32[1] = NumberUtils::U8ToUnorm((c0 >> 8) & 0xff); + color.float32[0] = NumberUtils::U8ToUnorm(c0 & 0xff); + color.float32[1] = NumberUtils::U8ToUnorm((c0 >> 8) & 0xff); color.float32[2] = NumberUtils::U8ToUnorm((c0 >> 16) & 0xff); - color.float32[3] = NumberUtils::U8ToUnorm( c0 >> 24); + color.float32[3] = NumberUtils::U8ToUnorm(c0 >> 24); break; case AmdGpu::NumberFormat::Snorm: - color.float32[0] = NumberUtils::S8ToSnorm( c0 & 0xff); - color.float32[1] = NumberUtils::S8ToSnorm((c0 >> 8) & 0xff); + color.float32[0] = NumberUtils::S8ToSnorm(c0 & 0xff); + color.float32[1] = NumberUtils::S8ToSnorm((c0 >> 8) & 0xff); color.float32[2] = NumberUtils::S8ToSnorm((c0 >> 16) & 0xff); - color.float32[3] = NumberUtils::S8ToSnorm( c0 >> 24); + color.float32[3] = NumberUtils::S8ToSnorm(c0 >> 24); break; case AmdGpu::NumberFormat::Uint: case AmdGpu::NumberFormat::Sint: - color.uint32[0] = c0 & 0xff; - color.uint32[1] = (c0 >> 8) & 0xff; + color.uint32[0] = c0 & 0xff; + color.uint32[1] = (c0 >> 8) & 0xff; color.uint32[2] = (c0 >> 16) & 0xff; - color.uint32[3] = c0 >> 24; + color.uint32[3] = c0 >> 24; break; default: INVALID_NUMBER_FORMAT_COMBO; @@ -964,28 +970,28 @@ vk::ClearValue ColorBufferClearValue(const AmdGpu::Liverpool::ColorBuffer& color case AmdGpu::DataFormat::Format16_16_16_16: switch (number_type) { case AmdGpu::NumberFormat::Unorm: - color.float32[0] = NumberUtils::U16ToUnorm( c0 & 0xffff); + color.float32[0] = NumberUtils::U16ToUnorm(c0 & 0xffff); color.float32[1] = NumberUtils::U16ToUnorm((c0 >> 16) & 0xffff); - color.float32[2] = NumberUtils::U16ToUnorm( c1 & 0xffff); + color.float32[2] = NumberUtils::U16ToUnorm(c1 & 0xffff); color.float32[3] = NumberUtils::U16ToUnorm((c1 >> 16) & 0xffff); break; case AmdGpu::NumberFormat::Snorm: - color.float32[0] = NumberUtils::S16ToSnorm( c0 & 0xffff); + color.float32[0] = NumberUtils::S16ToSnorm(c0 & 0xffff); color.float32[1] = NumberUtils::S16ToSnorm((c0 >> 16) & 0xffff); - color.float32[2] = NumberUtils::S16ToSnorm( c1 & 0xffff); + color.float32[2] = NumberUtils::S16ToSnorm(c1 & 0xffff); color.float32[3] = NumberUtils::S16ToSnorm((c1 >> 16) & 0xffff); break; case AmdGpu::NumberFormat::Uint: case AmdGpu::NumberFormat::Sint: - color.uint32[0] = c0 & 0xffff; + color.uint32[0] = c0 & 0xffff; color.uint32[1] = (c0 >> 16) & 0xffff; - color.uint32[2] = c1 & 0xffff; + color.uint32[2] = c1 & 0xffff; color.uint32[3] = (c1 >> 16) & 0xffff; break; case AmdGpu::NumberFormat::Float: - color.float32[0] = NumberUtils::Uf16ToF32( c0 & 0xffff); + color.float32[0] = NumberUtils::Uf16ToF32(c0 & 0xffff); color.float32[1] = NumberUtils::Uf16ToF32((c0 >> 16) & 0xffff); - color.float32[2] = NumberUtils::Uf16ToF32( c1 & 0xffff); + color.float32[2] = NumberUtils::Uf16ToF32(c1 & 0xffff); color.float32[3] = NumberUtils::Uf16ToF32((c1 >> 16) & 0xffff); break; default: @@ -1014,27 +1020,27 @@ vk::ClearValue ColorBufferClearValue(const AmdGpu::Liverpool::ColorBuffer& color } break; case AmdGpu::DataFormat::Format5_6_5: - color.float32[0] = NumberUtils::U5ToUnorm( c0 & 0x1f); - color.float32[1] = NumberUtils::U6ToUnorm((c0 >> 5) & 0x3f); - color.float32[2] = NumberUtils::U5ToUnorm( c0 >> 11); + color.float32[0] = NumberUtils::U5ToUnorm(c0 & 0x1f); + color.float32[1] = NumberUtils::U6ToUnorm((c0 >> 5) & 0x3f); + color.float32[2] = NumberUtils::U5ToUnorm(c0 >> 11); break; case AmdGpu::DataFormat::Format1_5_5_5: - color.float32[0] = NumberUtils::U5ToUnorm( c0 & 0x1f); - color.float32[1] = NumberUtils::U5ToUnorm((c0 >> 5) & 0x1f); + color.float32[0] = NumberUtils::U5ToUnorm(c0 & 0x1f); + color.float32[1] = NumberUtils::U5ToUnorm((c0 >> 5) & 0x1f); color.float32[2] = NumberUtils::U5ToUnorm((c0 >> 10) & 0x1f); color.float32[3] = (c0 >> 15) ? 1.0f : 0.0f; break; case AmdGpu::DataFormat::Format5_5_5_1: color.float32[0] = (c0 & 0x1) ? 1.0f : 0.0f; - color.float32[1] = NumberUtils::U5ToUnorm((c0 >> 1) & 0x1f); - color.float32[2] = NumberUtils::U5ToUnorm((c0 >> 6) & 0x1f); + color.float32[1] = NumberUtils::U5ToUnorm((c0 >> 1) & 0x1f); + color.float32[2] = NumberUtils::U5ToUnorm((c0 >> 6) & 0x1f); color.float32[3] = NumberUtils::U5ToUnorm((c0 >> 11) & 0x1f); break; case AmdGpu::DataFormat::Format4_4_4_4: - color.float32[0] = NumberUtils::U4ToUnorm( c0 & 0xf); - color.float32[1] = NumberUtils::U4ToUnorm((c0 >> 4) & 0xf); - color.float32[2] = NumberUtils::U4ToUnorm((c0 >> 8) & 0xf); - color.float32[3] = NumberUtils::U4ToUnorm( c0 >> 12); + color.float32[0] = NumberUtils::U4ToUnorm(c0 & 0xf); + color.float32[1] = NumberUtils::U4ToUnorm((c0 >> 4) & 0xf); + color.float32[2] = NumberUtils::U4ToUnorm((c0 >> 8) & 0xf); + color.float32[3] = NumberUtils::U4ToUnorm(c0 >> 12); break; default: LOG_ERROR(Render_Vulkan, "Unsupported color buffer format: {}", format); diff --git a/src/video_core/renderer_vulkan/number_utils.cpp b/src/video_core/renderer_vulkan/number_utils.cpp index b2361be41..18b595331 100644 --- a/src/video_core/renderer_vulkan/number_utils.cpp +++ b/src/video_core/renderer_vulkan/number_utils.cpp @@ -8,155 +8,154 @@ #include "video_core/amdgpu/types.h" #include "video_core/renderer_vulkan/number_utils.h" -#define UF11_EXPONENT_SHIFT 6 -#define UF10_EXPONENT_SHIFT 5 +#define UF11_EXPONENT_SHIFT 6 +#define UF10_EXPONENT_SHIFT 5 #define RGB9E5_MANTISSA_BITS 9 -#define RGB9E5_EXP_BIAS 1 +#define RGB9E5_EXP_BIAS 1 -#define F32_INFINITY 0x7f800000 +#define F32_INFINITY 0x7f800000 namespace Vulkan::NumberUtils { float Uf11ToF32(u16 val) { - union { - float f; - u32 ui; - } f32; + union { + float f; + u32 ui; + } f32; - int exponent = (val & 0x07c0) >> UF11_EXPONENT_SHIFT; - int mantissa = (val & 0x003f); + int exponent = (val & 0x07c0) >> UF11_EXPONENT_SHIFT; + int mantissa = (val & 0x003f); - f32.f = 0.0; + f32.f = 0.0; - if (exponent == 0) { - if (mantissa != 0) { - const float scale = 1.0 / (1 << 20); - f32.f = scale * mantissa; - } - } else if (exponent == 31) { - f32.ui = F32_INFINITY | mantissa; - } else { - float scale, decimal; - exponent -= 15; - if (exponent < 0) { - scale = 1.0f / (1 << -exponent); - } else { - scale = (float) (1 << exponent); - } - decimal = 1.0f + (float) mantissa / 64; - f32.f = scale * decimal; - } + if (exponent == 0) { + if (mantissa != 0) { + const float scale = 1.0 / (1 << 20); + f32.f = scale * mantissa; + } + } else if (exponent == 31) { + f32.ui = F32_INFINITY | mantissa; + } else { + float scale, decimal; + exponent -= 15; + if (exponent < 0) { + scale = 1.0f / (1 << -exponent); + } else { + scale = (float)(1 << exponent); + } + decimal = 1.0f + (float)mantissa / 64; + f32.f = scale * decimal; + } - return f32.f; + return f32.f; } float Uf10ToF32(u16 val) { - union { - float f; - u32 ui; - } f32; + union { + float f; + u32 ui; + } f32; - int exponent = (val & 0x03e0) >> UF10_EXPONENT_SHIFT; - int mantissa = (val & 0x001f); + int exponent = (val & 0x03e0) >> UF10_EXPONENT_SHIFT; + int mantissa = (val & 0x001f); - f32.f = 0.0; + f32.f = 0.0; - if (exponent == 0) { - if (mantissa != 0) { - const float scale = 1.0 / (1 << 19); - f32.f = scale * mantissa; - } - } else if (exponent == 31) { - f32.ui = F32_INFINITY | mantissa; - } else { - float scale, decimal; - exponent -= 15; - if (exponent < 0) { - scale = 1.0f / (1 << -exponent); - } - else { - scale = (float) (1 << exponent); - } - decimal = 1.0f + (float) mantissa / 32; - f32.f = scale * decimal; - } + if (exponent == 0) { + if (mantissa != 0) { + const float scale = 1.0 / (1 << 19); + f32.f = scale * mantissa; + } + } else if (exponent == 31) { + f32.ui = F32_INFINITY | mantissa; + } else { + float scale, decimal; + exponent -= 15; + if (exponent < 0) { + scale = 1.0f / (1 << -exponent); + } else { + scale = (float)(1 << exponent); + } + decimal = 1.0f + (float)mantissa / 32; + f32.f = scale * decimal; + } - return f32.f; + return f32.f; } float Uf16ToF32(u16 val) { - return half_float::half_cast(reinterpret_cast(val)); + return half_float::half_cast(reinterpret_cast(val)); } float U2ToUnorm(u8 val) { - static constexpr auto c = 1.0f / 3.0f; - return float(val * c); + static constexpr auto c = 1.0f / 3.0f; + return float(val * c); } float S2ToSnorm(s8 val) { - static constexpr auto c = 1.0f / 1.0f; - return float(val * c); + static constexpr auto c = 1.0f / 1.0f; + return float(val * c); } float U4ToUnorm(u8 val) { - static constexpr auto c = 1.0f / 15.0f; - return float(val * c); + static constexpr auto c = 1.0f / 15.0f; + return float(val * c); } float S4ToSnorm(s8 val) { - static constexpr auto c = 1.0f / 7.0f; - return float(val * c); + static constexpr auto c = 1.0f / 7.0f; + return float(val * c); } float U5ToUnorm(u8 val) { - static constexpr auto c = 1.0f / 31.0f; - return float(val * c); + static constexpr auto c = 1.0f / 31.0f; + return float(val * c); } float S5ToSnorm(s8 val) { - static constexpr auto c = 1.0f / 15.0f; - return float(val * c); + static constexpr auto c = 1.0f / 15.0f; + return float(val * c); } float U6ToUnorm(u8 val) { - static constexpr auto c = 1.0f / 63.0f; - return float(val * c); + static constexpr auto c = 1.0f / 63.0f; + return float(val * c); } float S6ToSnorm(s8 val) { - static constexpr auto c = 1.0f / 31.0f; - return float(val * c); + static constexpr auto c = 1.0f / 31.0f; + return float(val * c); } float U8ToUnorm(u8 val) { - static constexpr auto c = 1.0f / 255.0f; - return float(val * c); + static constexpr auto c = 1.0f / 255.0f; + return float(val * c); } float S8ToSnorm(s8 val) { - static constexpr auto c = 1.0f / 127.0f; - return float(val * c); + static constexpr auto c = 1.0f / 127.0f; + return float(val * c); } float U10ToUnorm(u16 val) { - static constexpr auto c = 1.0f / 1023.0f; - return float(val * c); + static constexpr auto c = 1.0f / 1023.0f; + return float(val * c); } float S10ToSnorm(s16 val) { - static constexpr auto c = 1.0f / 511.0f; - return float(val * c); + static constexpr auto c = 1.0f / 511.0f; + return float(val * c); } float U16ToUnorm(u16 val) { - static constexpr auto c = 1.0f / 65535.0f; - return float(val * c); + static constexpr auto c = 1.0f / 65535.0f; + return float(val * c); } float S16ToSnorm(s16 val) { - static constexpr auto c = 1.0f / 32767.0f; - return float(val * c); + static constexpr auto c = 1.0f / 32767.0f; + return float(val * c); } } // namespace Vulkan::NumberUtils \ No newline at end of file