From a8e28405f9bd56924b494012166212189c8948aa Mon Sep 17 00:00:00 2001 From: mchughalex <25671999+mchughalex@users.noreply.github.com> Date: Fri, 17 Jul 2026 12:06:47 +0100 Subject: [PATCH] render: float color formats in nrhi (RGBA16F + R11G11B10F) --- include/rex/graphics/native_rhi.h | 6 ++++++ src/graphics/d3d12/native_rhi_d3d12.cpp | 4 ++++ src/graphics/vulkan/native_rhi_vulkan.cpp | 9 +++++++++ 3 files changed, 19 insertions(+) diff --git a/include/rex/graphics/native_rhi.h b/include/rex/graphics/native_rhi.h index ef04b42..aa51542 100644 --- a/include/rex/graphics/native_rhi.h +++ b/include/rex/graphics/native_rhi.h @@ -59,6 +59,12 @@ enum class Format : uint32_t { kBC3_UNORM, kBC4_UNORM, kBC5_UNORM, + // Float color formats (HDR render targets), appended so existing values + // stay stable across exe/dll pairs. Both are color-renderable and + // blendable on every target backend (D3D12 FL11+, Vulkan core, MoltenVK); + // kR11G11B10_FLOAT has no alpha channel and stores no sign bits. + kR16G16B16A16_FLOAT, + kR11G11B10_FLOAT, }; // Block dimensions/bytes for the copy math (1x1 for uncompressed). diff --git a/src/graphics/d3d12/native_rhi_d3d12.cpp b/src/graphics/d3d12/native_rhi_d3d12.cpp index 673ebc1..7a6e327 100644 --- a/src/graphics/d3d12/native_rhi_d3d12.cpp +++ b/src/graphics/d3d12/native_rhi_d3d12.cpp @@ -45,6 +45,10 @@ DXGI_FORMAT ToDxgi(Format format) { return DXGI_FORMAT_R16G16_UNORM; case Format::kR10G10B10A2_UNORM: return DXGI_FORMAT_R10G10B10A2_UNORM; + case Format::kR16G16B16A16_FLOAT: + return DXGI_FORMAT_R16G16B16A16_FLOAT; + case Format::kR11G11B10_FLOAT: + return DXGI_FORMAT_R11G11B10_FLOAT; case Format::kR32_FLOAT: return DXGI_FORMAT_R32_FLOAT; case Format::kR32G32_FLOAT: diff --git a/src/graphics/vulkan/native_rhi_vulkan.cpp b/src/graphics/vulkan/native_rhi_vulkan.cpp index 8d92d27..105bc06 100644 --- a/src/graphics/vulkan/native_rhi_vulkan.cpp +++ b/src/graphics/vulkan/native_rhi_vulkan.cpp @@ -76,6 +76,12 @@ VkFormat ToVkFormat(Format format) { case Format::kR10G10B10A2_UNORM: // Identical bit layout to DXGI_FORMAT_R10G10B10A2_UNORM. return VK_FORMAT_A2B10G10R10_UNORM_PACK32; + case Format::kR16G16B16A16_FLOAT: + return VK_FORMAT_R16G16B16A16_SFLOAT; + case Format::kR11G11B10_FLOAT: + // Identical bit layout to DXGI_FORMAT_R11G11B10_FLOAT (R in the low + // bits of the packed 32). + return VK_FORMAT_B10G11R11_UFLOAT_PACK32; case Format::kR32_FLOAT: return VK_FORMAT_R32_SFLOAT; case Format::kR32G32_FLOAT: @@ -123,6 +129,9 @@ uint32_t FormatBytesPerBlock(Format format) { case Format::kR32_FLOAT: case Format::kD32_FLOAT: return 4; + case Format::kR11G11B10_FLOAT: + return 4; + case Format::kR16G16B16A16_FLOAT: case Format::kR32G32_FLOAT: return 8; case Format::kR32G32B32_FLOAT: