ES 3: Use sized internal formats for half float textures (#1015)

Co-authored-by: Alex Cristici <alex.cristici@gmail.com>
Co-authored-by: Bart Louwers <bart@emeel.net>
This commit is contained in:
mwilsnd
2023-04-15 06:14:42 -05:00
committed by GitHub
parent 12fcba89bf
commit 2e4e963d89
3 changed files with 24 additions and 1 deletions

View File

@@ -218,7 +218,7 @@ std::unique_ptr<gfx::TextureResource> Context::createTextureResource(
texture[0] = static_cast<gl::TextureResource&>(*resource).texture;
// Creates an empty texture with the specified size and format.
MBGL_CHECK_ERROR(glTexImage2D(GL_TEXTURE_2D, 0, Enum<gfx::TexturePixelType>::to(format),
MBGL_CHECK_ERROR(glTexImage2D(GL_TEXTURE_2D, 0, Enum<gfx::TexturePixelType>::sizedFor(format, type),
size.width, size.height, 0,
Enum<gfx::TexturePixelType>::to(format),
Enum<gfx::TextureChannelDataType>::to(type), nullptr));

View File

@@ -265,6 +265,26 @@ platform::GLenum Enum<gfx::TexturePixelType>::to(const gfx::TexturePixelType val
return GL_INVALID_ENUM;
}
template <> template<>
platform::GLenum Enum<gfx::TexturePixelType>::sizedFor<>(const gfx::TexturePixelType value,
gfx::TextureChannelDataType type)
{
switch (type) {
case gfx::TextureChannelDataType::UnsignedByte: {
return Enum<gfx::TexturePixelType>::to(value);
}
case gfx::TextureChannelDataType::HalfFloat: {
switch (value) {
case gfx::TexturePixelType::RGBA:
return GL_RGBA16F;
default: break;
}
}
}
return GL_INVALID_ENUM;
}
template <>
gfx::TextureChannelDataType Enum<gfx::TextureChannelDataType>::from(const platform::GLint value) {
switch (value) {

View File

@@ -15,6 +15,9 @@ public:
static T from(InType);
static OutType to(T);
template<typename U>
static OutType sizedFor(T, U type);
};
} // namespace gl