Convert Atlas texture to be Float16 from Float32 (#11637) ce781fdcc0 * Convert to Float16 * Clang * Update render_context_vulkan_impl.cpp * Updated GMS * Update render_context_gl_impl.cpp * gms * Josh's comments * GMS * Update GMS * Rebase GMS * GMS * GMS Co-authored-by: John White <aliasbinman@gmail.com>
diff --git a/.rive_head b/.rive_head index 06926e6..b39f688 100644 --- a/.rive_head +++ b/.rive_head
@@ -1 +1 @@ -37764336dbdb4b78d2be6842cd9cf34dacf996f1 +ce781fdcc017db12a3f4509b017a5b652d702ac3
diff --git a/renderer/include/rive/renderer/gl/render_context_gl_impl.hpp b/renderer/include/rive/renderer/gl/render_context_gl_impl.hpp index 20e3e6d..b1fd92f 100644 --- a/renderer/include/rive/renderer/gl/render_context_gl_impl.hpp +++ b/renderer/include/rive/renderer/gl/render_context_gl_impl.hpp
@@ -81,8 +81,8 @@ // These are sorted with the most preferred types higher up in the list. enum class AtlasType { - r32f, // Most preferred. Uses HW blending to count coverage. - r16f, // Uses HW blending but loses precision on complex feathers. + r16f, // Most preferred. Balances performances with precision. + r32f, // Uses HW blending to count coverage. r32uiFramebufferFetch, // Stores coverage as fp32 bits in a uint. r32uiPixelLocalStorage,
diff --git a/renderer/src/d3d11/render_context_d3d_impl.cpp b/renderer/src/d3d11/render_context_d3d_impl.cpp index 455ad56..b32baba 100644 --- a/renderer/src/d3d11/render_context_d3d_impl.cpp +++ b/renderer/src/d3d11/render_context_d3d_impl.cpp
@@ -1354,7 +1354,7 @@ } else { - m_atlasTexture = makeSimple2DTexture(DXGI_FORMAT_R32_FLOAT, + m_atlasTexture = makeSimple2DTexture(DXGI_FORMAT_R16_FLOAT, width, height, 1,
diff --git a/renderer/src/d3d12/render_context_d3d12_impl.cpp b/renderer/src/d3d12/render_context_d3d12_impl.cpp index eaf5104..c5cc1b6 100644 --- a/renderer/src/d3d12/render_context_d3d12_impl.cpp +++ b/renderer/src/d3d12/render_context_d3d12_impl.cpp
@@ -751,13 +751,13 @@ else { - D3D12_CLEAR_VALUE clear{DXGI_FORMAT_R32_FLOAT, {}}; + D3D12_CLEAR_VALUE clear{DXGI_FORMAT_R16_FLOAT, {}}; m_atlasTexture = m_resourceManager->make2DTexture( width, height, 1, - DXGI_FORMAT_R32_FLOAT, + DXGI_FORMAT_R16_FLOAT, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET, D3D12_RESOURCE_STATE_COMMON, D3D12_HEAP_FLAG_NONE,
diff --git a/renderer/src/gl/render_context_gl_impl.cpp b/renderer/src/gl/render_context_gl_impl.cpp index e3b0dea..464a4bb 100644 --- a/renderer/src/gl/render_context_gl_impl.cpp +++ b/renderer/src/gl/render_context_gl_impl.cpp
@@ -83,11 +83,17 @@ static RenderContextGLImpl::AtlasType select_atlas_type( const GLCapabilities& capabilities, RenderContextGLImpl::AtlasType atlasDesiredType = - RenderContextGLImpl::AtlasType::r32f) + RenderContextGLImpl::AtlasType::r16f) { switch (atlasDesiredType) { using AtlasType = RenderContextGLImpl::AtlasType; + case AtlasType::r16f: + if (capabilities.EXT_color_buffer_half_float) + { + return AtlasType::r16f; + } + [[fallthrough]]; case AtlasType::r32f: if (capabilities.EXT_color_buffer_float && capabilities.EXT_float_blend) @@ -97,12 +103,6 @@ return AtlasType::r32f; } [[fallthrough]]; - case AtlasType::r16f: - if (capabilities.EXT_color_buffer_half_float) - { - return AtlasType::r16f; - } - [[fallthrough]]; case AtlasType::r32uiFramebufferFetch: if (capabilities.EXT_shader_framebuffer_fetch) {
diff --git a/renderer/src/metal/render_context_metal_impl.mm b/renderer/src/metal/render_context_metal_impl.mm index 2e01674..61fb292 100644 --- a/renderer/src/metal/render_context_metal_impl.mm +++ b/renderer/src/metal/render_context_metal_impl.mm
@@ -149,7 +149,7 @@ desc.vertexFunction = [plsLibrary newFunctionWithName:@GLSL_atlasVertexMain]; desc.fragmentFunction = [plsLibrary newFunctionWithName:fragmentMain]; - desc.colorAttachments[0].pixelFormat = MTLPixelFormatR32Float; + desc.colorAttachments[0].pixelFormat = MTLPixelFormatR16Float; desc.colorAttachments[0].blendingEnabled = TRUE; desc.colorAttachments[0].sourceRGBBlendFactor = MTLBlendFactorOne; desc.colorAttachments[0].destinationRGBBlendFactor = MTLBlendFactorOne; @@ -924,7 +924,7 @@ } MTLTextureDescriptor* desc = [[MTLTextureDescriptor alloc] init]; - desc.pixelFormat = MTLPixelFormatR32Float; + desc.pixelFormat = MTLPixelFormatR16Float; desc.width = width; desc.height = height; desc.usage = MTLTextureUsageRenderTarget | MTLTextureUsageShaderRead;
diff --git a/renderer/src/vulkan/pipeline_manager_vulkan.cpp b/renderer/src/vulkan/pipeline_manager_vulkan.cpp index ce958fa..dcdcce2 100644 --- a/renderer/src/vulkan/pipeline_manager_vulkan.cpp +++ b/renderer/src/vulkan/pipeline_manager_vulkan.cpp
@@ -52,13 +52,7 @@ PipelineManagerVulkan::PipelineManagerVulkan(rcp<VulkanContext> vk, ShaderCompilationMode mode, VkImageView nullTextureView) : - Super(mode), - m_vk(std::move(vk)), - m_atlasFormat(m_vk->isFormatSupportedWithFeatureFlags( - VK_FORMAT_R32_SFLOAT, - VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT) - ? VK_FORMAT_R32_SFLOAT - : VK_FORMAT_R16_SFLOAT) + Super(mode), m_vk(std::move(vk)), m_atlasFormat(VK_FORMAT_R16_SFLOAT) { // Create the immutable samplers. VkSamplerCreateInfo linearSamplerCreateInfo = {