From 774506fc59bad5c93d450cdf6c21861cd70d34d2 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sat, 24 Nov 2018 21:07:34 -0800 Subject: Moved ITextureView::GenerateMips() to IDeviceContext::GenerateMips() --- Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h | 4 ++++ Graphics/GraphicsEngineOpenGL/include/TextureViewGLImpl.h | 2 -- Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp | 11 +++++++++++ Graphics/GraphicsEngineOpenGL/src/TextureViewGLImpl.cpp | 11 ----------- 4 files changed, 15 insertions(+), 13 deletions(-) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h index 8741bf47..788327d6 100644 --- a/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h +++ b/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h @@ -106,6 +106,10 @@ public: virtual void UnmapTextureSubresource(ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice)override final; + + virtual void GenerateMips( ITextureView *pTexView )override; + + virtual void FinishFrame()override final; virtual void TransitionResourceStates(Uint32 BarrierCount, StateTransitionDesc* pResourceBarriers)override final; diff --git a/Graphics/GraphicsEngineOpenGL/include/TextureViewGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/TextureViewGLImpl.h index 7f9a16c6..1b54400b 100644 --- a/Graphics/GraphicsEngineOpenGL/include/TextureViewGLImpl.h +++ b/Graphics/GraphicsEngineOpenGL/include/TextureViewGLImpl.h @@ -54,8 +54,6 @@ public: GLenum GetBindTarget(); void SetBindTarget(GLenum ViewTexBindTarget) { m_ViewTexBindTarget = ViewTexBindTarget; } - void GenerateMips( IDeviceContext *pContext )override; - protected: GLObjectWrappers::GLTextureObj m_ViewTexGLHandle; GLenum m_ViewTexBindTarget; diff --git a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp index fee3867c..8da30532 100644 --- a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp @@ -1073,6 +1073,17 @@ namespace Diligent LOG_ERROR_MESSAGE("Texture mapping is not supported in OpenGL"); } + void DeviceContextGLImpl::GenerateMips( ITextureView *pTexView ) + { + TDeviceContextBase::GenerateMips(pTexView); + auto* pTexViewGL = ValidatedCast(pTexView); + auto BindTarget = pTexViewGL->GetBindTarget(); + m_ContextState.BindTexture( -1, BindTarget, pTexViewGL->GetHandle() ); + glGenerateMipmap( BindTarget ); + CHECK_GL_ERROR( "Failed to generate mip maps" ); + m_ContextState.BindTexture( -1, BindTarget, GLObjectWrappers::GLTextureObj(false) ); + } + void DeviceContextGLImpl::TransitionResourceStates(Uint32 BarrierCount, StateTransitionDesc* pResourceBarriers) { diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureViewGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureViewGLImpl.cpp index 60b94439..f71b0c0f 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureViewGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureViewGLImpl.cpp @@ -71,15 +71,4 @@ namespace Diligent return static_cast(pTexture)->GetBindTarget(); } } - - void TextureViewGLImpl::GenerateMips( IDeviceContext *pContext ) - { - auto pCtxGL = ValidatedCast( pContext ); - auto &GLState = pCtxGL->GetContextState(); - auto BindTarget = GetBindTarget(); - GLState.BindTexture( -1, BindTarget, GetHandle() ); - glGenerateMipmap( BindTarget ); - CHECK_GL_ERROR( "Failed to generate mip maps" ); - GLState.BindTexture( -1, BindTarget, GLObjectWrappers::GLTextureObj(false) ); - } } -- cgit v1.2.3