1
0
forked from mirrors/0ad

Adds floating point textures to backends

R8G8B8A8_UNORM isn't enough to store HDR data as the scene can brighter
than 1.0 especially when looking into sun speculars.
This commit is contained in:
Vladislav Belov
2026-04-29 19:25:11 +02:00
parent c4fb0eed3a
commit 1a277269d3
4 changed files with 33 additions and 3 deletions
+3 -1
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2024 Wildfire Games.
/* Copyright (C) 2026 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -56,6 +56,8 @@ enum class Format
R32G32B32_SFLOAT,
R32G32B32A32_SFLOAT,
B10G11R11_UFLOAT,
D16_UNORM,
D24_UNORM,
D24_UNORM_S8_UINT,
+9 -1
View File
@@ -943,7 +943,6 @@ bool CDevice::IsTextureFormatSupported(const Format format) const
case Format::R32_SFLOAT:
case Format::R32G32_SFLOAT:
case Format::R32G32B32_SFLOAT:
case Format::R32G32B32A32_SFLOAT:
break;
case Format::D16_UNORM:
@@ -967,6 +966,11 @@ bool CDevice::IsTextureFormatSupported(const Format format) const
supported = m_Capabilities.S3TC;
break;
case Format::R16G16B16A16_SFLOAT:
case Format::R32G32B32A32_SFLOAT:
supported = m_Capabilities.computeShaders && m_Capabilities.storage && ogl_HaveExtension("GL_ARB_texture_float");
break;
default:
break;
}
@@ -984,6 +988,10 @@ bool CDevice::IsFramebufferFormatSupported(const Format format) const
case Format::R8_UNORM:
supported = ogl_HaveVersion(3, 0);
break;
case Format::R16G16B16A16_SFLOAT:
case Format::R32G32B32A32_SFLOAT:
supported = m_Capabilities.computeShaders && m_Capabilities.storage && GLAD_GL_ARB_texture_float;
break;
#endif
case Format::R8G8B8A8_UNORM:
supported = true;
+18
View File
@@ -244,6 +244,16 @@ std::unique_ptr<CTexture> CTexture::Create(
pixelFormat = GL_DEPTH_STENCIL_EXT;
pixelType = GL_UNSIGNED_INT_24_8_EXT;
break;
case Format::R16G16B16A16_SFLOAT:
internalFormat = GL_RGBA16F_ARB;
pixelFormat = GL_RGBA;
pixelType = GL_HALF_FLOAT;
break;
case Format::R32G32B32A32_SFLOAT:
internalFormat = GL_RGBA32F_ARB;
pixelFormat = GL_RGBA;
pixelType = GL_FLOAT;
break;
#endif
case Format::BC1_RGB_UNORM:
case Format::BC1_RGBA_UNORM:
@@ -273,6 +283,14 @@ std::unique_ptr<CTexture> CTexture::Create(
{
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, sampleCount, GL_RGBA8, width, height, GL_TRUE);
}
else if (format == Format::R16G16B16A16_SFLOAT)
{
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, sampleCount, GL_RGBA16F_ARB, width, height, GL_TRUE);
}
else if (format == Format::R32G32B32A32_SFLOAT)
{
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, sampleCount, GL_RGBA32F_ARB, width, height, GL_TRUE);
}
else if (format == Format::D24_UNORM_S8_UINT)
{
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, sampleCount, GL_DEPTH24_STENCIL8_EXT, width, height, GL_TRUE);
+3 -1
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2025 Wildfire Games.
/* Copyright (C) 2026 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -195,6 +195,8 @@ VkFormat FromFormat(const Format format)
CASE(R32G32B32_SFLOAT)
CASE(R32G32B32A32_SFLOAT)
CASE2(B10G11R11_UFLOAT, B10G11R11_UFLOAT_PACK32)
CASE(D16_UNORM)
CASE2(D24_UNORM, X8_D24_UNORM_PACK32)
CASE(D24_UNORM_S8_UINT)