From: David Steele Date: Thu, 10 Jun 2021 17:15:09 +0000 (+0100) Subject: Fixed depth/stencil renderbuffer attachments X-Git-Tag: dali_2.0.31~3^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9b34236ce8f58e401920bfe8c4629ee22f6b4c9c;p=platform%2Fcore%2Fuifw%2Fdali-core.git Fixed depth/stencil renderbuffer attachments If no depth or depth/stencil texture was attached, but depth/stencil attachment was requested on initialization, then the renderbuffer attachments weren't being created. Added usage flags to the Graphics::DepthStencilAttachment to indicate when RenderBuffers are required. Also, the load/clear ops were set incorrectly for depth/stencil, so each renderpass wasn't working as intended. Change-Id: I6a77bf67628a7225007ab40bef31ffa271023f1f Signed-off-by: David Steele --- diff --git a/dali/graphics-api/graphics-types.h b/dali/graphics-api/graphics-types.h index d6b2072..99984bb 100644 --- a/dali/graphics-api/graphics-types.h +++ b/dali/graphics-api/graphics-types.h @@ -1003,11 +1003,17 @@ struct ColorAttachment */ struct DepthStencilAttachment { - // TODO: - Texture* depthTexture; - Texture* stencilTexture; - uint32_t depthLevel; - uint32_t stencilLevel; + enum class Usage + { + WRITE, // If no texture, will create a RenderBuffer instead + NONE // If no attachment/RenderBuffer required + }; + Texture* depthTexture{nullptr}; + Texture* stencilTexture{nullptr}; + uint32_t depthLevel{0}; + uint32_t stencilLevel{0}; + Usage depthUsage{Usage::NONE}; + Usage stencilUsage{Usage::NONE}; }; /** diff --git a/dali/internal/render/renderers/render-frame-buffer.cpp b/dali/internal/render/renderers/render-frame-buffer.cpp index f668a1c..73101e1 100644 --- a/dali/internal/render/renderers/render-frame-buffer.cpp +++ b/dali/internal/render/renderers/render-frame-buffer.cpp @@ -33,6 +33,16 @@ FrameBuffer::FrameBuffer(uint32_t width, uint32_t height, Mask attachments) mDepthBuffer(attachments & Dali::FrameBuffer::Attachment::DEPTH), mStencilBuffer(attachments & Dali::FrameBuffer::Attachment::STENCIL) { + mCreateInfo.size.width = width; + mCreateInfo.size.height = height; + if(mDepthBuffer) + { + mCreateInfo.depthStencilAttachment.depthUsage = Graphics::DepthStencilAttachment::Usage::WRITE; + } + if(mStencilBuffer) + { + mCreateInfo.depthStencilAttachment.stencilUsage = Graphics::DepthStencilAttachment::Usage::WRITE; + } } FrameBuffer::~FrameBuffer() = default; @@ -64,7 +74,7 @@ void FrameBuffer::AttachColorTexture(Render::Texture* texture, uint32_t mipmapLe void FrameBuffer::AttachDepthTexture(Render::Texture* texture, uint32_t mipmapLevel) { - if(texture && mDepthBuffer) + if(texture) { if(!texture->GetGraphicsObject()) { @@ -72,19 +82,21 @@ void FrameBuffer::AttachDepthTexture(Render::Texture* texture, uint32_t mipmapLe } mCreateInfo.depthStencilAttachment.depthTexture = texture->GetGraphicsObject(); + mCreateInfo.depthStencilAttachment.depthUsage = Graphics::DepthStencilAttachment::Usage::WRITE; mCreateInfo.depthStencilAttachment.depthLevel = mipmapLevel; } } void FrameBuffer::AttachDepthStencilTexture(Render::Texture* texture, uint32_t mipmapLevel) { - if(texture && mStencilBuffer) + if(texture) { if(!texture->GetGraphicsObject()) { texture->Create(0 | Graphics::TextureUsageFlagBits::DEPTH_STENCIL_ATTACHMENT | Graphics::TextureUsageFlagBits::SAMPLE); } mCreateInfo.depthStencilAttachment.stencilTexture = texture->GetGraphicsObject(); + mCreateInfo.depthStencilAttachment.stencilUsage = Graphics::DepthStencilAttachment::Usage::WRITE; mCreateInfo.depthStencilAttachment.stencilLevel = mipmapLevel; } } @@ -98,7 +110,8 @@ bool FrameBuffer::CreateGraphicsObjects() // Only create a graphics object if there are attachments for it to render into if(mCreateInfo.colorAttachments.empty() && mCreateInfo.depthStencilAttachment.depthTexture == nullptr && - mCreateInfo.depthStencilAttachment.stencilTexture == nullptr) + mCreateInfo.depthStencilAttachment.stencilTexture == nullptr && + !mDepthBuffer && !mStencilBuffer) { DALI_LOG_ERROR("Attempting to bind a framebuffer with no attachments\n"); } @@ -130,16 +143,17 @@ bool FrameBuffer::CreateGraphicsObjects() } } - if(mCreateInfo.depthStencilAttachment.depthTexture || mCreateInfo.depthStencilAttachment.stencilTexture) + if(mCreateInfo.depthStencilAttachment.depthTexture || mCreateInfo.depthStencilAttachment.stencilTexture || + mDepthBuffer || mStencilBuffer) { Graphics::AttachmentDescription depthStencilDesc{}; - depthStencilDesc.SetStencilLoadOp(Graphics::AttachmentLoadOp::CLEAR) + depthStencilDesc.SetLoadOp(Graphics::AttachmentLoadOp::CLEAR) .SetStoreOp(Graphics::AttachmentStoreOp::DONT_CARE); - if(mCreateInfo.depthStencilAttachment.stencilTexture) + if(mCreateInfo.depthStencilAttachment.stencilTexture || mStencilBuffer) { depthStencilDesc.SetStencilLoadOp(Graphics::AttachmentLoadOp::CLEAR) - .SetStoreOp(Graphics::AttachmentStoreOp::DONT_CARE); + .SetStencilStoreOp(Graphics::AttachmentStoreOp::DONT_CARE); } mClearValues.emplace_back(); attachmentDescriptions.push_back(depthStencilDesc);