case Graphics::Format::R64G64B64A64_SINT:
case Graphics::Format::R64G64B64A64_SFLOAT:
case Graphics::Format::B10G11R11_UFLOAT_PACK32:
+ case Graphics::Format::R11G11B10_UFLOAT_PACK32:
case Graphics::Format::E5B9G9R9_UFLOAT_PACK32:
case Graphics::Format::D16_UNORM:
case Graphics::Format::X8_D24_UNORM_PACK32:
glFormat = 0;
break;
}
+ case Graphics::Format::R11G11B10_UFLOAT_PACK32:
+ {
+ glFormat = GL_RGB;
+ pixelDataType = GL_FLOAT;
+ break;
+ }
case Graphics::Format::R4G4_UNORM_PACK8:
case Graphics::Format::A1R5G5B5_UNORM_PACK16:
{
case Graphics::Format::R16G16B16A16_SFLOAT:
case Graphics::Format::R32G32B32A32_SFLOAT:
+ case Graphics::Format::R11G11B10_UFLOAT_PACK32:
{
glInternalFormat = GL_R11F_G11F_B10F;
break;
// GPU memory must be already allocated.
// Check if it needs conversion
- auto* texture = static_cast<GLES::Texture*>(info.dstTexture);
- const auto& createInfo = texture->GetCreateInfo();
- auto srcFormat = GLES::GLTextureFormatType(info.srcFormat).format;
- auto destFormat = GLES::GLTextureFormatType(createInfo.format).format;
- auto destType = GLES::GLTextureFormatType(createInfo.format).type;
+ auto* texture = static_cast<GLES::Texture*>(info.dstTexture);
+ const auto& createInfo = texture->GetCreateInfo();
+ auto srcFormat = GLES::GLTextureFormatType(info.srcFormat).format;
+ auto srcType = GLES::GLTextureFormatType(info.srcFormat).type;
+ auto destInternalFormat = GLES::GLTextureFormatType(createInfo.format).internalFormat;
+ auto destFormat = GLES::GLTextureFormatType(createInfo.format).format;
// From render-texture.cpp
const bool isSubImage(info.dstOffset2D.x != 0 || info.dstOffset2D.y != 0 ||
// Convert RGB to RGBA if necessary.
texture->TryConvertPixelData(source.memorySource.memory, info.srcFormat, createInfo.format, info.srcSize, info.srcExtent2D.width, info.srcExtent2D.height, tempBuffer);
sourceBuffer = &tempBuffer[0];
+ srcFormat = destFormat;
+ srcType = GLES::GLTextureFormatType(createInfo.format).type;
}
// Calculate the maximum mipmap level for the texture
texture->SetMaxMipMapLevel(std::max(texture->GetMaxMipMapLevel(), info.level));
- switch(createInfo.textureType)
- {
- // Texture 2D
- case Graphics::TextureType::TEXTURE_2D:
- {
- mGlAbstraction->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
-
- mGlAbstraction->BindTexture(GL_TEXTURE_2D, texture->GetGLTexture());
-
- mGlAbstraction->TexSubImage2D(GL_TEXTURE_2D,
- info.level,
- info.dstOffset2D.x,
- info.dstOffset2D.y,
- info.srcExtent2D.width,
- info.srcExtent2D.height,
- destFormat,
- destType,
- sourceBuffer);
- break;
- }
- // Texture Cubemap
- case Graphics::TextureType::TEXTURE_CUBEMAP:
- {
- mGlAbstraction->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ GLenum bindTarget{GL_TEXTURE_2D};
+ GLenum target{GL_TEXTURE_2D};
- mGlAbstraction->BindTexture(GL_TEXTURE_CUBE_MAP, texture->GetGLTexture());
+ if(createInfo.textureType == Graphics::TextureType::TEXTURE_CUBEMAP)
+ {
+ bindTarget = GL_TEXTURE_CUBE_MAP;
+ target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + info.layer;
+ }
- mGlAbstraction->TexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + info.layer,
- info.level,
- info.dstOffset2D.x,
- info.dstOffset2D.y,
- info.srcExtent2D.width,
- info.srcExtent2D.height,
- destFormat,
- destType,
- sourceBuffer);
+ mGlAbstraction->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ mGlAbstraction->BindTexture(bindTarget, texture->GetGLTexture());
- break;
- }
- default:
- {
- // nothing?
- }
+ if(!isSubImage)
+ {
+ mGlAbstraction->TexImage2D(target,
+ info.level,
+ destInternalFormat,
+ info.srcExtent2D.width,
+ info.srcExtent2D.height,
+ 0,
+ srcFormat,
+ srcType,
+ sourceBuffer);
+ }
+ else
+ {
+ mGlAbstraction->TexSubImage2D(target,
+ info.level,
+ info.dstOffset2D.x,
+ info.dstOffset2D.y,
+ info.srcExtent2D.width,
+ info.srcExtent2D.height,
+ srcFormat,
+ srcType,
+ sourceBuffer);
}
-
// free staging memory
free(source.memorySource.memory);
}
case Graphics::Format::R16G16B16_SFLOAT:
{
// GLES 3.0 floating point formats.
- Assign(GL_RGB, GL_HALF_FLOAT);
+ AssignInternal(GL_RGB, GL_R11F_G11F_B10F, GL_HALF_FLOAT); // DALi uses compact internal format
break;
}
case Graphics::Format::R16G16B16A16_UNORM:
}
case Graphics::Format::R32G32B32_SFLOAT:
{
- // GLES 3.0 floating point formats.
- Assign(GL_RGB, GL_FLOAT);
+ AssignInternal(GL_RGB, GL_R11F_G11F_B10F, GL_FLOAT); // DALi uses compact internal format
break;
}
case Graphics::Format::R32G32B32A32_UINT:
Assign(0, 0);
break;
}
+ case Graphics::Format::R11G11B10_UFLOAT_PACK32:
+ {
+ AssignInternal(GL_RGB, GL_R11F_G11F_B10F, GL_FLOAT);
+ break;
+ }
case Graphics::Format::B10G11R11_UFLOAT_PACK32:
{
Assign(0, 0);
case Graphics::Format::D32_SFLOAT:
{
// GLES 3.0 depth and stencil formats
- Assign(GL_DEPTH_COMPONENT, GL_FLOAT);
+ AssignInternal(GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT32F, GL_FLOAT);
break;
}
case Graphics::Format::S8_UINT:
case Graphics::Format::D24_UNORM_S8_UINT:
{
// GLES 3.0 depth and stencil formats
- Assign(GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
+ AssignInternal(GL_DEPTH_STENCIL, GL_DEPTH24_STENCIL8, GL_UNSIGNED_INT_24_8);
break;
}
case Graphics::Format::D32_SFLOAT_S8_UINT:
constexpr inline void Assign(uint32_t f, uint32_t t)
{
- format = f;
- type = t;
+ format = f;
+ internalFormat = f;
+ type = t;
+ }
+ constexpr inline void AssignInternal(uint32_t f, uint32_t i, uint32_t t)
+ {
+ format = f;
+ internalFormat = i;
+ type = t;
}
uint32_t format{0};
+ uint32_t internalFormat{0};
uint32_t type{0};
};