From: Richard Huang Date: Tue, 27 Apr 2021 16:07:34 +0000 (+0100) Subject: CubeMap support X-Git-Tag: dali_2.0.28~3^2~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F67%2F257567%2F3;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git CubeMap support Change-Id: Idbe013328b3acb5e72931f16def48df609dbdb6f --- diff --git a/dali/internal/graphics/gles-impl/egl-graphics-controller.cpp b/dali/internal/graphics/gles-impl/egl-graphics-controller.cpp index 5546800..2f3d5aa 100644 --- a/dali/internal/graphics/gles-impl/egl-graphics-controller.cpp +++ b/dali/internal/graphics/gles-impl/egl-graphics-controller.cpp @@ -583,19 +583,52 @@ void EglGraphicsController::ProcessTextureUpdateQueue() sourceBuffer = &tempBuffer[0]; } - 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); + 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); + + mGlAbstraction->BindTexture(GL_TEXTURE_CUBE_MAP, texture->GetGLTexture()); + + 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); + + + break; + } + default: + { + // nothing? + } + } // free staging memory free(source.memorySource.memory); diff --git a/dali/internal/graphics/gles-impl/gles-graphics-texture.cpp b/dali/internal/graphics/gles-impl/gles-graphics-texture.cpp index 7e84495..cb75d68 100644 --- a/dali/internal/graphics/gles-impl/gles-graphics-texture.cpp +++ b/dali/internal/graphics/gles-impl/gles-graphics-texture.cpp @@ -207,6 +207,46 @@ bool Texture::InitializeTexture() } break; } + // Texture Cubemap + case Graphics::TextureType::TEXTURE_CUBEMAP: + { + Graphics::GLES::GLTextureFormatType format(mCreateInfo.format); + + if(format.format && format.type) + { + // Bind texture + gl->GenTextures(1, &texture); + gl->BindTexture(GL_TEXTURE_CUBE_MAP, texture); + gl->PixelStorei(GL_UNPACK_ALIGNMENT, 1); // We always use tightly packed data + + gl->TexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, Graphics::GLES::GLSamplerFilterAndMipMapMode(Graphics::SamplerFilter::LINEAR, SamplerMipmapMode::NONE)); + gl->TexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, Graphics::GLES::GLSamplerFilterAndMipMapMode(Graphics::SamplerFilter::LINEAR, SamplerMipmapMode::NONE)); + gl->TexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_WRAP_DEFAULT); + gl->TexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_WRAP_DEFAULT); + + // Allocate memory for the texture + for(uint32_t i = 0; i < 6; ++i) + { + gl->TexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, + 0, + format.format, + mCreateInfo.size.width, + mCreateInfo.size.height, + 0, + format.format, + format.type, + (mCreateInfo.data ? mStagingBuffer.data() : nullptr)); + } + + // Clear staging buffer if there was any + mStagingBuffer.clear(); + + mTextureId = texture; + + gl->TexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_WRAP_DEFAULT); + } + break; + } default: { // nothing?