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:
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2024 Wildfire Games.
|
/* Copyright (C) 2026 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@@ -56,6 +56,8 @@ enum class Format
|
|||||||
R32G32B32_SFLOAT,
|
R32G32B32_SFLOAT,
|
||||||
R32G32B32A32_SFLOAT,
|
R32G32B32A32_SFLOAT,
|
||||||
|
|
||||||
|
B10G11R11_UFLOAT,
|
||||||
|
|
||||||
D16_UNORM,
|
D16_UNORM,
|
||||||
D24_UNORM,
|
D24_UNORM,
|
||||||
D24_UNORM_S8_UINT,
|
D24_UNORM_S8_UINT,
|
||||||
|
|||||||
@@ -943,7 +943,6 @@ bool CDevice::IsTextureFormatSupported(const Format format) const
|
|||||||
case Format::R32_SFLOAT:
|
case Format::R32_SFLOAT:
|
||||||
case Format::R32G32_SFLOAT:
|
case Format::R32G32_SFLOAT:
|
||||||
case Format::R32G32B32_SFLOAT:
|
case Format::R32G32B32_SFLOAT:
|
||||||
case Format::R32G32B32A32_SFLOAT:
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Format::D16_UNORM:
|
case Format::D16_UNORM:
|
||||||
@@ -967,6 +966,11 @@ bool CDevice::IsTextureFormatSupported(const Format format) const
|
|||||||
supported = m_Capabilities.S3TC;
|
supported = m_Capabilities.S3TC;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Format::R16G16B16A16_SFLOAT:
|
||||||
|
case Format::R32G32B32A32_SFLOAT:
|
||||||
|
supported = m_Capabilities.computeShaders && m_Capabilities.storage && ogl_HaveExtension("GL_ARB_texture_float");
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -984,6 +988,10 @@ bool CDevice::IsFramebufferFormatSupported(const Format format) const
|
|||||||
case Format::R8_UNORM:
|
case Format::R8_UNORM:
|
||||||
supported = ogl_HaveVersion(3, 0);
|
supported = ogl_HaveVersion(3, 0);
|
||||||
break;
|
break;
|
||||||
|
case Format::R16G16B16A16_SFLOAT:
|
||||||
|
case Format::R32G32B32A32_SFLOAT:
|
||||||
|
supported = m_Capabilities.computeShaders && m_Capabilities.storage && GLAD_GL_ARB_texture_float;
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
case Format::R8G8B8A8_UNORM:
|
case Format::R8G8B8A8_UNORM:
|
||||||
supported = true;
|
supported = true;
|
||||||
|
|||||||
@@ -244,6 +244,16 @@ std::unique_ptr<CTexture> CTexture::Create(
|
|||||||
pixelFormat = GL_DEPTH_STENCIL_EXT;
|
pixelFormat = GL_DEPTH_STENCIL_EXT;
|
||||||
pixelType = GL_UNSIGNED_INT_24_8_EXT;
|
pixelType = GL_UNSIGNED_INT_24_8_EXT;
|
||||||
break;
|
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
|
#endif
|
||||||
case Format::BC1_RGB_UNORM:
|
case Format::BC1_RGB_UNORM:
|
||||||
case Format::BC1_RGBA_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);
|
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)
|
else if (format == Format::D24_UNORM_S8_UINT)
|
||||||
{
|
{
|
||||||
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, sampleCount, GL_DEPTH24_STENCIL8_EXT, width, height, GL_TRUE);
|
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, sampleCount, GL_DEPTH24_STENCIL8_EXT, width, height, GL_TRUE);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2025 Wildfire Games.
|
/* Copyright (C) 2026 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 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(R32G32B32_SFLOAT)
|
||||||
CASE(R32G32B32A32_SFLOAT)
|
CASE(R32G32B32A32_SFLOAT)
|
||||||
|
|
||||||
|
CASE2(B10G11R11_UFLOAT, B10G11R11_UFLOAT_PACK32)
|
||||||
|
|
||||||
CASE(D16_UNORM)
|
CASE(D16_UNORM)
|
||||||
CASE2(D24_UNORM, X8_D24_UNORM_PACK32)
|
CASE2(D24_UNORM, X8_D24_UNORM_PACK32)
|
||||||
CASE(D24_UNORM_S8_UINT)
|
CASE(D24_UNORM_S8_UINT)
|
||||||
|
|||||||
Reference in New Issue
Block a user