Skip to content

Commit

Permalink
OpenGL backend: updated AttachToFramebuffer method to control which f…
Browse files Browse the repository at this point in the history
…ramebuffer targets the texture is attached to
  • Loading branch information
TheMostDiligent committed Nov 5, 2023
1 parent f9ea53a commit 95aa211
Show file tree
Hide file tree
Showing 16 changed files with 122 additions and 54 deletions.
3 changes: 2 additions & 1 deletion Graphics/GraphicsEngineOpenGL/include/Texture1DArray_GL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class Texture1DArray_GL final : public TextureBaseGL

/// Implementation of TextureBaseGL::AttachToFramebuffer() for 1D texture array.
virtual void AttachToFramebuffer(const struct TextureViewDesc& ViewDesc,
GLenum AttachmentPoint) override final;
GLenum AttachmentPoint,
FRAMEBUFFER_TARGET_FLAGS Targets) override final;

/// Implementation of TextureBaseGL::CopyTexSubimage() for 1D texture array.
virtual void CopyTexSubimage(GLContextState& GLState, const CopyTexSubimageAttribs& Attribs) override final;
Expand Down
3 changes: 2 additions & 1 deletion Graphics/GraphicsEngineOpenGL/include/Texture1D_GL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class Texture1D_GL final : public TextureBaseGL

/// Implementation of TextureBaseGL::AttachToFramebuffer() for 1D texture.
virtual void AttachToFramebuffer(const struct TextureViewDesc& ViewDesc,
GLenum AttachmentPoint) override final;
GLenum AttachmentPoint,
FRAMEBUFFER_TARGET_FLAGS Targets) override final;

/// Implementation of TextureBaseGL::CopyTexSubimage() for 1D texture.
virtual void CopyTexSubimage(GLContextState& GLState, const CopyTexSubimageAttribs& Attribs) override final;
Expand Down
3 changes: 2 additions & 1 deletion Graphics/GraphicsEngineOpenGL/include/Texture2DArray_GL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class Texture2DArray_GL final : public TextureBaseGL

/// Implementation of TextureBaseGL::AttachToFramebuffer() for 2D texture array.
virtual void AttachToFramebuffer(const struct TextureViewDesc& ViewDesc,
GLenum AttachmentPoint) override final;
GLenum AttachmentPoint,
FRAMEBUFFER_TARGET_FLAGS Targets) override final;

/// Implementation of TextureBaseGL::CopyTexSubimage() for 2D texture array.
virtual void CopyTexSubimage(GLContextState& GLState, const CopyTexSubimageAttribs& Attribs) override final;
Expand Down
3 changes: 2 additions & 1 deletion Graphics/GraphicsEngineOpenGL/include/Texture2D_GL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ class Texture2D_GL final : public TextureBaseGL

/// Implementation of TextureBaseGL::AttachToFramebuffer() for 2D texture.
virtual void AttachToFramebuffer(const struct TextureViewDesc& ViewDesc,
GLenum AttachmentPoint) override final;
GLenum AttachmentPoint,
FRAMEBUFFER_TARGET_FLAGS Targets) override final;

/// Implementation of TextureBaseGL::CopyTexSubimage() for 2D texture.
virtual void CopyTexSubimage(GLContextState& GLState, const CopyTexSubimageAttribs& Attribs) override final;
Expand Down
3 changes: 2 additions & 1 deletion Graphics/GraphicsEngineOpenGL/include/Texture3D_GL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class Texture3D_GL final : public TextureBaseGL

/// Implementation of TextureBaseGL::AttachToFramebuffer() for 3D texture.
virtual void AttachToFramebuffer(const struct TextureViewDesc& ViewDesc,
GLenum AttachmentPoint) override final;
GLenum AttachmentPoint,
FRAMEBUFFER_TARGET_FLAGS Targets) override final;

/// Implementation of TextureBaseGL::CopyTexSubimage() for 3D texture.
virtual void CopyTexSubimage(GLContextState& GLState, const CopyTexSubimageAttribs& Attribs) override final;
Expand Down
11 changes: 10 additions & 1 deletion Graphics/GraphicsEngineOpenGL/include/TextureBaseGL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,14 @@ class TextureBaseGL : public TextureBase<EngineGLImplTraits>, public AsyncWritab

__forceinline void TextureMemoryBarrier(MEMORY_BARRIER RequiredBarriers, class GLContextState& GLContextState);

virtual void AttachToFramebuffer(const struct TextureViewDesc& ViewDesc, GLenum AttachmentPoint) = 0;
enum FRAMEBUFFER_TARGET_FLAGS : Uint32
{
FRAMEBUFFER_TARGET_FLAG_NONE = 0u,
FRAMEBUFFER_TARGET_FLAG_READ = 1u << 0u,
FRAMEBUFFER_TARGET_FLAG_DRAW = 1u << 1u,
FRAMEBUFFER_TARGET_FLAG_READ_DRAW = FRAMEBUFFER_TARGET_FLAG_READ | FRAMEBUFFER_TARGET_FLAG_DRAW
};
virtual void AttachToFramebuffer(const struct TextureViewDesc& ViewDesc, GLenum AttachmentPoint, FRAMEBUFFER_TARGET_FLAGS Targets) = 0;

void CopyData(DeviceContextGLImpl* pDeviceCtxGL,
TextureBaseGL* pSrcTextureGL,
Expand Down Expand Up @@ -141,6 +148,8 @@ class TextureBaseGL : public TextureBase<EngineGLImplTraits>, public AsyncWritab
//Uint32 m_uiMapTarget;
};

DEFINE_FLAG_ENUM_OPERATORS(TextureBaseGL::FRAMEBUFFER_TARGET_FLAGS);

void TextureBaseGL::TextureMemoryBarrier(MEMORY_BARRIER RequiredBarriers, GLContextState& GLContextState)
{
#if GL_ARB_shader_image_load_store
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class TextureCubeArray_GL final : public TextureBaseGL

/// Implementation of TextureBaseGL::AttachToFramebuffer() for cube texture array.
virtual void AttachToFramebuffer(const struct TextureViewDesc& ViewDesc,
GLenum AttachmentPoint) override final;
GLenum AttachmentPoint,
FRAMEBUFFER_TARGET_FLAGS Targets) override final;

/// Implementation of TextureBaseGL::CopyTexSubimage() for cube texture array.
virtual void CopyTexSubimage(GLContextState& GLState, const CopyTexSubimageAttribs& Attribs) override final;
Expand Down
3 changes: 2 additions & 1 deletion Graphics/GraphicsEngineOpenGL/include/TextureCube_GL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class TextureCube_GL final : public TextureBaseGL

/// Implementation of TextureBaseGL::AttachToFramebuffer() for cube texture.
virtual void AttachToFramebuffer(const struct TextureViewDesc& ViewDesc,
GLenum AttachmentPoint) override final;
GLenum AttachmentPoint,
FRAMEBUFFER_TARGET_FLAGS Targets) override final;

/// Implementation of TextureBaseGL::CopyTexSubimage() for cube texture.
virtual void CopyTexSubimage(GLContextState& GLState, const CopyTexSubimageAttribs& Attribs) override final;
Expand Down
10 changes: 7 additions & 3 deletions Graphics/GraphicsEngineOpenGL/src/FBOCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ GLObjectWrappers::GLFrameBufferObj FBOCache::CreateFBO(GLContextState& Contex
{
const auto& RTVDesc = pRTView->GetDesc();
auto* pColorTexGL = pRTView->GetTexture<TextureBaseGL>();
pColorTexGL->AttachToFramebuffer(RTVDesc, GL_COLOR_ATTACHMENT0 + rt);
pColorTexGL->AttachToFramebuffer(RTVDesc, GL_COLOR_ATTACHMENT0 + rt, TextureBaseGL::FRAMEBUFFER_TARGET_FLAG_READ_DRAW);
}
}

Expand Down Expand Up @@ -172,7 +172,11 @@ GLObjectWrappers::GLFrameBufferObj FBOCache::CreateFBO(GLContextState& Contex
{
UNEXPECTED(GetTextureFormatAttribs(DSVDesc.Format).Name, " is not valid depth-stencil view format");
}
pDepthTexGL->AttachToFramebuffer(DSVDesc, AttachmentPoint);
VERIFY_EXPR(DSVDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL || DSVDesc.ViewType == TEXTURE_VIEW_READ_ONLY_DEPTH_STENCIL);
pDepthTexGL->AttachToFramebuffer(DSVDesc, AttachmentPoint,
DSVDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL ?
TextureBaseGL::FRAMEBUFFER_TARGET_FLAG_READ_DRAW :
TextureBaseGL::FRAMEBUFFER_TARGET_FLAG_READ);
}

if (NumRenderTargets > 0)
Expand Down Expand Up @@ -372,7 +376,7 @@ const GLObjectWrappers::GLFrameBufferObj& FBOCache::GetReadFBO(TextureBaseGL* pT
glBindFramebuffer(GL_READ_FRAMEBUFFER, NewFBO);
DEV_CHECK_GL_ERROR("Failed to bind new FBO as read framebuffer");

pTex->AttachToFramebuffer(RTV0, GetFramebufferAttachmentPoint(TexDesc.Format));
pTex->AttachToFramebuffer(RTV0, GetFramebufferAttachmentPoint(TexDesc.Format), TextureBaseGL::FRAMEBUFFER_TARGET_FLAG_READ);

GLenum Status = glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
if (Status != GL_FRAMEBUFFER_COMPLETE)
Expand Down
22 changes: 15 additions & 7 deletions Graphics/GraphicsEngineOpenGL/src/Texture1DArray_GL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,29 +182,37 @@ void Texture1DArray_GL::UpdateData(GLContextState& ContextState,
ContextState.BindTexture(-1, m_BindTarget, GLObjectWrappers::GLTextureObj::Null());
}

void Texture1DArray_GL::AttachToFramebuffer(const TextureViewDesc& ViewDesc, GLenum AttachmentPoint)
void Texture1DArray_GL::AttachToFramebuffer(const TextureViewDesc& ViewDesc, GLenum AttachmentPoint, FRAMEBUFFER_TARGET_FLAGS Targets)
{
if (ViewDesc.NumArraySlices == m_Desc.ArraySize)
{
if (ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET || ViewDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL)
if (Targets & FRAMEBUFFER_TARGET_FLAG_DRAW)
{
VERIFY_EXPR(ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET || ViewDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL);
glFramebufferTexture(GL_DRAW_FRAMEBUFFER, AttachmentPoint, m_GlTexture, ViewDesc.MostDetailedMip);
CHECK_GL_ERROR("Failed to attach texture 1D array to draw framebuffer");
}
glFramebufferTexture(GL_READ_FRAMEBUFFER, AttachmentPoint, m_GlTexture, ViewDesc.MostDetailedMip);
CHECK_GL_ERROR("Failed to attach texture 1D array to read framebuffer");
if (Targets & FRAMEBUFFER_TARGET_FLAG_READ)
{
glFramebufferTexture(GL_READ_FRAMEBUFFER, AttachmentPoint, m_GlTexture, ViewDesc.MostDetailedMip);
CHECK_GL_ERROR("Failed to attach texture 1D array to read framebuffer");
}
}
else if (ViewDesc.NumArraySlices == 1)
{
// Texture name must either be zero or the name of an existing 3D texture, 1D or 2D array texture,
// cube map array texture, or multisample array texture.
if (ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET || ViewDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL)
if (Targets & FRAMEBUFFER_TARGET_FLAG_DRAW)
{
VERIFY_EXPR(ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET || ViewDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL);
glFramebufferTextureLayer(GL_DRAW_FRAMEBUFFER, AttachmentPoint, m_GlTexture, ViewDesc.MostDetailedMip, ViewDesc.FirstArraySlice);
CHECK_GL_ERROR("Failed to attach texture 1D array to draw framebuffer");
}
glFramebufferTextureLayer(GL_READ_FRAMEBUFFER, AttachmentPoint, m_GlTexture, ViewDesc.MostDetailedMip, ViewDesc.FirstArraySlice);
CHECK_GL_ERROR("Failed to attach texture 1D array to read framebuffer");
if (Targets & FRAMEBUFFER_TARGET_FLAG_READ)
{
glFramebufferTextureLayer(GL_READ_FRAMEBUFFER, AttachmentPoint, m_GlTexture, ViewDesc.MostDetailedMip, ViewDesc.FirstArraySlice);
CHECK_GL_ERROR("Failed to attach texture 1D array to read framebuffer");
}
}
else
{
Expand Down
12 changes: 8 additions & 4 deletions Graphics/GraphicsEngineOpenGL/src/Texture1D_GL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,20 @@ void Texture1D_GL::UpdateData(GLContextState& ContextState,
ContextState.BindTexture(-1, m_BindTarget, GLObjectWrappers::GLTextureObj::Null());
}

void Texture1D_GL::AttachToFramebuffer(const TextureViewDesc& ViewDesc, GLenum AttachmentPoint)
void Texture1D_GL::AttachToFramebuffer(const TextureViewDesc& ViewDesc, GLenum AttachmentPoint, FRAMEBUFFER_TARGET_FLAGS Targets)
{
// For glFramebufferTexture1D(), if texture name is not zero, then texture target must be GL_TEXTURE_1D
if (ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET || ViewDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL)
if (Targets & FRAMEBUFFER_TARGET_FLAG_DRAW)
{
VERIFY_EXPR(ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET || ViewDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL);
glFramebufferTexture1D(GL_DRAW_FRAMEBUFFER, AttachmentPoint, m_BindTarget, m_GlTexture, ViewDesc.MostDetailedMip);
CHECK_GL_ERROR("Failed to attach texture 1D to draw framebuffer");
}
glFramebufferTexture1D(GL_READ_FRAMEBUFFER, AttachmentPoint, m_BindTarget, m_GlTexture, ViewDesc.MostDetailedMip);
CHECK_GL_ERROR("Failed to attach texture 1D to read framebuffer");
if (Targets & FRAMEBUFFER_TARGET_FLAG_READ)
{
glFramebufferTexture1D(GL_READ_FRAMEBUFFER, AttachmentPoint, m_BindTarget, m_GlTexture, ViewDesc.MostDetailedMip);
CHECK_GL_ERROR("Failed to attach texture 1D to read framebuffer");
}
}

void Texture1D_GL::CopyTexSubimage(GLContextState& GLState, const CopyTexSubimageAttribs& Attribs)
Expand Down
22 changes: 15 additions & 7 deletions Graphics/GraphicsEngineOpenGL/src/Texture2DArray_GL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,30 +256,38 @@ void Texture2DArray_GL::UpdateData(GLContextState& ContextState,
ContextState.BindTexture(-1, m_BindTarget, GLObjectWrappers::GLTextureObj::Null());
}

void Texture2DArray_GL::AttachToFramebuffer(const TextureViewDesc& ViewDesc, GLenum AttachmentPoint)
void Texture2DArray_GL::AttachToFramebuffer(const TextureViewDesc& ViewDesc, GLenum AttachmentPoint, FRAMEBUFFER_TARGET_FLAGS Targets)
{

if (ViewDesc.NumArraySlices == m_Desc.ArraySize)
{
if (ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET || ViewDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL)
if (Targets & FRAMEBUFFER_TARGET_FLAG_DRAW)
{
VERIFY_EXPR(ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET || ViewDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL);
glFramebufferTexture(GL_DRAW_FRAMEBUFFER, AttachmentPoint, m_GlTexture, ViewDesc.MostDetailedMip);
CHECK_GL_ERROR("Failed to attach texture 2D array to draw framebuffer");
}
glFramebufferTexture(GL_READ_FRAMEBUFFER, AttachmentPoint, m_GlTexture, ViewDesc.MostDetailedMip);
CHECK_GL_ERROR("Failed to attach texture 2D array to read framebuffer");
if (Targets & FRAMEBUFFER_TARGET_FLAG_READ)
{
glFramebufferTexture(GL_READ_FRAMEBUFFER, AttachmentPoint, m_GlTexture, ViewDesc.MostDetailedMip);
CHECK_GL_ERROR("Failed to attach texture 2D array to read framebuffer");
}
}
else if (ViewDesc.NumArraySlices == 1)
{
// Texture name must either be zero or the name of an existing 3D texture, 1D or 2D array texture,
// cube map array texture, or multisample array texture.
if (ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET || ViewDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL)
if (Targets & FRAMEBUFFER_TARGET_FLAG_DRAW)
{
VERIFY_EXPR(ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET || ViewDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL);
glFramebufferTextureLayer(GL_DRAW_FRAMEBUFFER, AttachmentPoint, m_GlTexture, ViewDesc.MostDetailedMip, ViewDesc.FirstArraySlice);
CHECK_GL_ERROR("Failed to attach texture 2D array to draw framebuffer");
}
glFramebufferTextureLayer(GL_READ_FRAMEBUFFER, AttachmentPoint, m_GlTexture, ViewDesc.MostDetailedMip, ViewDesc.FirstArraySlice);
CHECK_GL_ERROR("Failed to attach texture 2D array to read framebuffer");
if (Targets & FRAMEBUFFER_TARGET_FLAG_READ)
{
glFramebufferTextureLayer(GL_READ_FRAMEBUFFER, AttachmentPoint, m_GlTexture, ViewDesc.MostDetailedMip, ViewDesc.FirstArraySlice);
CHECK_GL_ERROR("Failed to attach texture 2D array to read framebuffer");
}
}
else
{
Expand Down
12 changes: 8 additions & 4 deletions Graphics/GraphicsEngineOpenGL/src/Texture2D_GL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,17 +275,21 @@ void Texture2D_GL::UpdateData(GLContextState& ContextState,
ContextState.BindTexture(-1, m_BindTarget, GLObjectWrappers::GLTextureObj::Null());
}

void Texture2D_GL::AttachToFramebuffer(const TextureViewDesc& ViewDesc, GLenum AttachmentPoint)
void Texture2D_GL::AttachToFramebuffer(const TextureViewDesc& ViewDesc, GLenum AttachmentPoint, FRAMEBUFFER_TARGET_FLAGS Targets)
{
// For glFramebufferTexture2D(), if texture name is not zero, then texture target must be GL_TEXTURE_2D,
// GL_TEXTURE_RECTANGLE or one of the 6 cubemap face targets GL_TEXTURE_CUBE_MAP_POSITIVE_X, ...
if (ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET || ViewDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL)
if (Targets & FRAMEBUFFER_TARGET_FLAG_DRAW)
{
VERIFY_EXPR(ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET || ViewDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL);
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, AttachmentPoint, m_BindTarget, m_GlTexture, ViewDesc.MostDetailedMip);
CHECK_GL_ERROR("Failed to attach texture 2D to draw framebuffer");
}
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, AttachmentPoint, m_BindTarget, m_GlTexture, ViewDesc.MostDetailedMip);
CHECK_GL_ERROR("Failed to attach texture 2D to read framebuffer");
if (Targets & FRAMEBUFFER_TARGET_FLAG_READ)
{
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, AttachmentPoint, m_BindTarget, m_GlTexture, ViewDesc.MostDetailedMip);
CHECK_GL_ERROR("Failed to attach texture 2D to read framebuffer");
}
}

void Texture2D_GL::CopyTexSubimage(GLContextState& GLState, const CopyTexSubimageAttribs& Attribs)
Expand Down
22 changes: 15 additions & 7 deletions Graphics/GraphicsEngineOpenGL/src/Texture3D_GL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,18 +194,22 @@ void Texture3D_GL::UpdateData(GLContextState& ContextState,
ContextState.BindTexture(-1, m_BindTarget, GLObjectWrappers::GLTextureObj::Null());
}

void Texture3D_GL::AttachToFramebuffer(const TextureViewDesc& ViewDesc, GLenum AttachmentPoint)
void Texture3D_GL::AttachToFramebuffer(const TextureViewDesc& ViewDesc, GLenum AttachmentPoint, FRAMEBUFFER_TARGET_FLAGS Targets)
{
auto NumDepthSlicesInMip = m_Desc.Depth >> ViewDesc.MostDetailedMip;
if (ViewDesc.NumDepthSlices == NumDepthSlicesInMip)
{
if (ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET || ViewDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL)
if (Targets & FRAMEBUFFER_TARGET_FLAG_DRAW)
{
VERIFY_EXPR(ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET || ViewDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL);
glFramebufferTexture(GL_DRAW_FRAMEBUFFER, AttachmentPoint, m_GlTexture, ViewDesc.MostDetailedMip);
CHECK_GL_ERROR("Failed to attach texture 3D to draw framebuffer");
}
glFramebufferTexture(GL_READ_FRAMEBUFFER, AttachmentPoint, m_GlTexture, ViewDesc.MostDetailedMip);
CHECK_GL_ERROR("Failed to attach texture 3D to read framebuffer");
if (Targets & FRAMEBUFFER_TARGET_FLAG_READ)
{
glFramebufferTexture(GL_READ_FRAMEBUFFER, AttachmentPoint, m_GlTexture, ViewDesc.MostDetailedMip);
CHECK_GL_ERROR("Failed to attach texture 3D to read framebuffer");
}
}
else if (ViewDesc.NumDepthSlices == 1)
{
Expand All @@ -215,13 +219,17 @@ void Texture3D_GL::AttachToFramebuffer(const TextureViewDesc& ViewDesc, GLenum A

// On Android (at least on Intel HW), glFramebufferTexture3D() runs without errors, but the
// FBO turns out to be incomplete. glFramebufferTextureLayer() seems to work fine.
if (ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET || ViewDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL)
if (Targets & FRAMEBUFFER_TARGET_FLAG_DRAW)
{
VERIFY_EXPR(ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET || ViewDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL);
glFramebufferTextureLayer(GL_DRAW_FRAMEBUFFER, AttachmentPoint, m_GlTexture, ViewDesc.MostDetailedMip, ViewDesc.FirstDepthSlice);
CHECK_GL_ERROR("Failed to attach texture 3D to draw framebuffer");
}
glFramebufferTextureLayer(GL_READ_FRAMEBUFFER, AttachmentPoint, m_GlTexture, ViewDesc.MostDetailedMip, ViewDesc.FirstDepthSlice);
CHECK_GL_ERROR("Failed to attach texture 3D to read framebuffer");
if (Targets & FRAMEBUFFER_TARGET_FLAG_READ)
{
glFramebufferTextureLayer(GL_READ_FRAMEBUFFER, AttachmentPoint, m_GlTexture, ViewDesc.MostDetailedMip, ViewDesc.FirstDepthSlice);
CHECK_GL_ERROR("Failed to attach texture 3D to read framebuffer");
}
}
else
{
Expand Down
Loading

0 comments on commit 95aa211

Please sign in to comment.