X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Frender%2Frenderers%2Frender-texture-frame-buffer.cpp;h=3062c6dcde19529e1b4c3f95b2a4e730590671e9;hb=481e9d8aefa1276909f0598d18c8533b93a2e31c;hp=9e3120e34590642aa9ec82222acc8944d617ced6;hpb=403f5989d41f4e5c5a657e24020fe32c77fc1414;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/render/renderers/render-texture-frame-buffer.cpp b/dali/internal/render/renderers/render-texture-frame-buffer.cpp index 9e3120e..3062c6d 100644 --- a/dali/internal/render/renderers/render-texture-frame-buffer.cpp +++ b/dali/internal/render/renderers/render-texture-frame-buffer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,14 +26,30 @@ namespace Internal { namespace Render { +namespace +{ +const GLenum COLOR_ATTACHMENTS[] = +{ + GL_COLOR_ATTACHMENT0, + GL_COLOR_ATTACHMENT1, + GL_COLOR_ATTACHMENT2, + GL_COLOR_ATTACHMENT3, + GL_COLOR_ATTACHMENT4, + GL_COLOR_ATTACHMENT5, + GL_COLOR_ATTACHMENT6, + GL_COLOR_ATTACHMENT7, +}; +} TextureFrameBuffer::TextureFrameBuffer( uint32_t width, uint32_t height, Mask attachments ) : FrameBuffer(), mId( 0u ), + mTextureId{ 0u }, mDepthBuffer( attachments & Dali::FrameBuffer::Attachment::DEPTH ), mStencilBuffer( attachments & Dali::FrameBuffer::Attachment::STENCIL ), mWidth( width ), - mHeight( height ) + mHeight( height ), + mColorAttachmentCount( 0u ) { } @@ -83,22 +99,48 @@ void TextureFrameBuffer::AttachColorTexture( Context& context, Render::Texture* { context.BindFramebuffer( GL_FRAMEBUFFER, mId ); + const GLuint textureId = texture->GetId(); + mTextureId[mColorAttachmentCount] = textureId; + // Create a color attachment. + const GLenum iAttachment = COLOR_ATTACHMENTS[mColorAttachmentCount]; if( texture->GetType() == TextureType::TEXTURE_2D ) { - if( !texture->IsNativeImage() ) - { - context.FramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture->GetId(), mipmapLevel ); - } - else - { - // If it's a native image we need to use GL_TEXTURE_EXTERNAL_OES as the texture target parameter - context.FramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_EXTERNAL_OES, texture->GetId(), mipmapLevel ); - } + context.FramebufferTexture2D( GL_FRAMEBUFFER, iAttachment, texture->GetTarget(), textureId, mipmapLevel ); } else { - context.FramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer, texture->GetId(), mipmapLevel ); + context.FramebufferTexture2D( GL_FRAMEBUFFER, iAttachment, GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer, textureId, mipmapLevel ); + } + + ++mColorAttachmentCount; + context.DrawBuffers(mColorAttachmentCount, COLOR_ATTACHMENTS); + DALI_ASSERT_DEBUG(context.CheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE); + + context.BindFramebuffer( GL_FRAMEBUFFER, 0 ); +} + +void TextureFrameBuffer::AttachDepthTexture( Context& context, Render::Texture* texture, uint32_t mipmapLevel ) +{ + context.BindFramebuffer( GL_FRAMEBUFFER, mId ); + + // Create a depth attachment. + if( texture->GetType() == TextureType::TEXTURE_2D ) + { + context.FramebufferTexture2D( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, texture->GetId(), mipmapLevel ); + } + + context.BindFramebuffer( GL_FRAMEBUFFER, 0 ); +} + +void TextureFrameBuffer::AttachDepthStencilTexture( Context& context, Render::Texture* texture, uint32_t mipmapLevel ) +{ + context.BindFramebuffer( GL_FRAMEBUFFER, mId ); + + // Create a stencil attachment. + if( texture->GetType() == TextureType::TEXTURE_2D ) + { + context.FramebufferTexture2D( GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, texture->GetId(), mipmapLevel ); } context.BindFramebuffer( GL_FRAMEBUFFER, 0 );