diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-07-20 05:41:05 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-07-20 05:41:05 +0000 |
| commit | 908672f5b447e1e96e0dcbb3ec1eaabbd1d503f4 (patch) | |
| tree | d0ae2d5956d803b7f4ce11195bebed8deecb124a /Graphics/GraphicsEngineOpenGL | |
| parent | Added comment about shader reflection data (diff) | |
| download | DiligentCore-908672f5b447e1e96e0dcbb3ec1eaabbd1d503f4.tar.gz DiligentCore-908672f5b447e1e96e0dcbb3ec1eaabbd1d503f4.zip | |
Added fence object stubs + code formatting
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
6 files changed, 216 insertions, 24 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/CMakeLists.txt b/Graphics/GraphicsEngineOpenGL/CMakeLists.txt index 6b7e2037..b78a7fb2 100644 --- a/Graphics/GraphicsEngineOpenGL/CMakeLists.txt +++ b/Graphics/GraphicsEngineOpenGL/CMakeLists.txt @@ -8,6 +8,7 @@ set(INCLUDE include/BufferViewGLImpl.h include/DeviceContextGLImpl.h include/FBOCache.h + include/FenceGLImpl.h include/GLContext.h include/GLContextState.h include/GLObjectWrapper.h @@ -39,6 +40,7 @@ set(INTERFACE interface/BufferViewGL.h interface/DeviceContextGL.h interface/EngineGLAttribs.h + interface/FenceGL.h interface/PipelineStateGL.h interface/RenderDeviceFactoryOpenGL.h interface/RenderDeviceGL.h @@ -55,6 +57,7 @@ set(SOURCE src/BufferViewGLImpl.cpp src/DeviceContextGLImpl.cpp src/FBOCache.cpp + src/FenceGLImpl.cpp src/GLContextState.cpp src/GLObjectWrapper.cpp src/GLProgram.cpp diff --git a/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.h new file mode 100644 index 00000000..6756c467 --- /dev/null +++ b/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.h @@ -0,0 +1,58 @@ +/* Copyright 2015-2018 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +/// \file +/// Declaration of Diligent::FenceGLImpl class + +#include "FenceGL.h" +#include "RenderDeviceGL.h" +#include "FenceBase.h" + +namespace Diligent +{ + +class FixedBlockMemoryAllocator; + +/// Implementation of the Diligent::IFenceGL interface +class FenceGLImpl : public FenceBase<IFenceGL> +{ +public: + using TFenceBase = FenceBase<IFenceGL>; + + FenceGLImpl(IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, + const FenceDesc& Desc); + ~FenceGLImpl(); + + virtual Uint64 GetCompletedValue()override final; + + /// Resets the fence to the specified value. + virtual void Reset(Uint64 Value)override final; + +private: + +}; + +} diff --git a/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h index 15663ce9..36d611cd 100644 --- a/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h +++ b/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.h @@ -73,6 +73,8 @@ public: void CreatePipelineState( const PipelineStateDesc &PipelineDesc, IPipelineState **ppPipelineState, bool bIsDeviceInternal); virtual void CreatePipelineState( const PipelineStateDesc &PipelineDesc, IPipelineState **ppPipelineState )override final; + virtual void CreateFence(const FenceDesc& Desc, IFence** ppFence)override final; + virtual void CreateTextureFromGLHandle(Uint32 GLHandle, const TextureDesc &TexDesc, ITexture **ppTexture)override final; virtual void CreateBufferFromGLHandle(Uint32 GLHandle, const BufferDesc &BuffDesc, IBuffer **ppBuffer)override final; diff --git a/Graphics/GraphicsEngineOpenGL/interface/FenceGL.h b/Graphics/GraphicsEngineOpenGL/interface/FenceGL.h new file mode 100644 index 00000000..c6f9eebc --- /dev/null +++ b/Graphics/GraphicsEngineOpenGL/interface/FenceGL.h @@ -0,0 +1,47 @@ +/* Copyright 2015-2018 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +/// \file +/// Definition of the Diligent::IFenceGL interface + +#include "../../GraphicsEngine/interface/Fence.h" + +namespace Diligent +{ + +// {8FEACBDA-89D6-4509-88E6-D55DD06220C5} +static constexpr INTERFACE_ID IID_FenceGL = +{ 0x8feacbda, 0x89d6, 0x4509, { 0x88, 0xe6, 0xd5, 0x5d, 0xd0, 0x62, 0x20, 0xc5 } }; + + +/// Interface to the fence object implemented in GL +class IFenceGL : public IFence +{ +public: + /// Returns OpenGL sync object + //virtual IGLFence* GetGLFence() = 0; +}; + +} diff --git a/Graphics/GraphicsEngineOpenGL/src/FenceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/FenceGLImpl.cpp new file mode 100644 index 00000000..99bbe484 --- /dev/null +++ b/Graphics/GraphicsEngineOpenGL/src/FenceGLImpl.cpp @@ -0,0 +1,55 @@ +/* Copyright 2015-2018 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "pch.h" +#include <atlbase.h> + +#include "FenceGLImpl.h" +#include "EngineMemory.h" + +namespace Diligent +{ + +FenceGLImpl :: FenceGLImpl(IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, + const FenceDesc& Desc) : + TFenceBase(pRefCounters, pDevice, Desc) +{ +} + +FenceGLImpl :: ~FenceGLImpl() +{ +} + +Uint64 FenceGLImpl :: GetCompletedValue() +{ + UNSUPPORTED("Not yet implemented"); + return 0; +} + +void FenceGLImpl :: Reset(Uint64 Value) +{ + UNSUPPORTED("Not yet implemented"); +} + +} diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp index b62c1288..9524554e 100644 --- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp @@ -40,20 +40,35 @@ #include "GLTypeConversions.h" #include "PipelineStateGLImpl.h" #include "ShaderResourceBindingGLImpl.h" +#include "FenceGLImpl.h" #include "EngineMemory.h" #include "StringTools.h" namespace Diligent { -RenderDeviceGLImpl :: RenderDeviceGLImpl(IReferenceCounters *pRefCounters, IMemoryAllocator &RawMemAllocator, const EngineGLAttribs &InitAttribs): - TRenderDeviceBase(pRefCounters, RawMemAllocator, 0, sizeof(TextureBaseGL), sizeof(TextureViewGLImpl), sizeof(BufferGLImpl), sizeof(BufferViewGLImpl), sizeof(ShaderGLImpl), sizeof(SamplerGLImpl), sizeof(PipelineStateGLImpl), sizeof(ShaderResourceBindingGLImpl)), +RenderDeviceGLImpl :: RenderDeviceGLImpl(IReferenceCounters *pRefCounters, IMemoryAllocator& RawMemAllocator, const EngineGLAttribs& InitAttribs): + TRenderDeviceBase + { + pRefCounters, + RawMemAllocator, + 0, + sizeof(TextureBaseGL), + sizeof(TextureViewGLImpl), + sizeof(BufferGLImpl), + sizeof(BufferViewGLImpl), + sizeof(ShaderGLImpl), + sizeof(SamplerGLImpl), + sizeof(PipelineStateGLImpl), + sizeof(ShaderResourceBindingGLImpl), + sizeof(FenceGLImpl) + }, // Device caps must be filled in before the constructor of Pipeline Cache is called! m_GLContext(InitAttribs, m_DeviceCaps), m_TexRegionRender(this) { GLint NumExtensions = 0; - glGetIntegerv( GL_NUM_EXTENSIONS, &NumExtensions ); + glGetIntegerv( GL_NUM_EXTENSIONS,& NumExtensions ); CHECK_GL_ERROR( "Failed to get the number of extensions" ); m_ExtensionStrings.reserve(NumExtensions); for( int Ext = 0; Ext < NumExtensions; ++Ext ) @@ -87,7 +102,7 @@ RenderDeviceGLImpl :: ~RenderDeviceGLImpl() IMPLEMENT_QUERY_INTERFACE( RenderDeviceGLImpl, IID_RenderDeviceGL, TRenderDeviceBase ) -void RenderDeviceGLImpl :: CreateBuffer(const BufferDesc& BuffDesc, const BufferData &BuffData, IBuffer **ppBuffer, bool bIsDeviceInternal) +void RenderDeviceGLImpl :: CreateBuffer(const BufferDesc& BuffDesc, const BufferData& BuffData, IBuffer **ppBuffer, bool bIsDeviceInternal) { CreateDeviceObject( "buffer", BuffDesc, ppBuffer, [&]() @@ -101,12 +116,12 @@ void RenderDeviceGLImpl :: CreateBuffer(const BufferDesc& BuffDesc, const Buffer ); } -void RenderDeviceGLImpl :: CreateBuffer(const BufferDesc& BuffDesc, const BufferData &BuffData, IBuffer **ppBuffer) +void RenderDeviceGLImpl :: CreateBuffer(const BufferDesc& BuffDesc, const BufferData& BuffData, IBuffer **ppBuffer) { CreateBuffer(BuffDesc, BuffData, ppBuffer, false); } -void RenderDeviceGLImpl :: CreateBufferFromGLHandle(Uint32 GLHandle, const BufferDesc &BuffDesc, IBuffer **ppBuffer) +void RenderDeviceGLImpl :: CreateBufferFromGLHandle(Uint32 GLHandle, const BufferDesc& BuffDesc, IBuffer **ppBuffer) { VERIFY(GLHandle, "GL buffer handle must not be null"); CreateDeviceObject( "buffer", BuffDesc, ppBuffer, @@ -121,7 +136,7 @@ void RenderDeviceGLImpl :: CreateBufferFromGLHandle(Uint32 GLHandle, const Buffe ); } -void RenderDeviceGLImpl :: CreateShader(const ShaderCreationAttribs &ShaderCreationAttribs, IShader **ppShader, bool bIsDeviceInternal) +void RenderDeviceGLImpl :: CreateShader(const ShaderCreationAttribs& ShaderCreationAttribs, IShader **ppShader, bool bIsDeviceInternal) { CreateDeviceObject( "shader", ShaderCreationAttribs.Desc, ppShader, [&]() @@ -135,12 +150,12 @@ void RenderDeviceGLImpl :: CreateShader(const ShaderCreationAttribs &ShaderCreat ); } -void RenderDeviceGLImpl :: CreateShader(const ShaderCreationAttribs &ShaderCreationAttribs, IShader **ppShader) +void RenderDeviceGLImpl :: CreateShader(const ShaderCreationAttribs& ShaderCreationAttribs, IShader **ppShader) { CreateShader(ShaderCreationAttribs, ppShader, false); } -void RenderDeviceGLImpl :: CreateTexture(const TextureDesc& TexDesc, const TextureData &Data, ITexture **ppTexture, bool bIsDeviceInternal) +void RenderDeviceGLImpl :: CreateTexture(const TextureDesc& TexDesc, const TextureData& Data, ITexture **ppTexture, bool bIsDeviceInternal) { CreateDeviceObject( "texture", TexDesc, ppTexture, [&]() @@ -148,7 +163,7 @@ void RenderDeviceGLImpl :: CreateTexture(const TextureDesc& TexDesc, const Textu auto spDeviceContext = GetImmediateContext(); VERIFY(spDeviceContext, "Immediate device context has been destroyed"); auto pDeviceContext = spDeviceContext.RawPtr<DeviceContextGLImpl>(); - const auto &FmtInfo = GetTextureFormatInfo( TexDesc.Format ); + const auto& FmtInfo = GetTextureFormatInfo( TexDesc.Format ); if( !FmtInfo.Supported ) { LOG_ERROR_AND_THROW( FmtInfo.Name, " is not supported texture format" ); @@ -202,12 +217,12 @@ void RenderDeviceGLImpl :: CreateTexture(const TextureDesc& TexDesc, const Textu ); } -void RenderDeviceGLImpl::CreateTexture(const TextureDesc& TexDesc, const TextureData &Data, ITexture **ppTexture) +void RenderDeviceGLImpl::CreateTexture(const TextureDesc& TexDesc, const TextureData& Data, ITexture **ppTexture) { CreateTexture(TexDesc, Data, ppTexture, false); } -void RenderDeviceGLImpl::CreateTextureFromGLHandle(Uint32 GLHandle, const TextureDesc &TexDesc, ITexture **ppTexture) +void RenderDeviceGLImpl::CreateTextureFromGLHandle(Uint32 GLHandle, const TextureDesc& TexDesc, ITexture **ppTexture) { VERIFY(GLHandle, "GL texture handle must not be null"); CreateDeviceObject( "texture", TexDesc, ppTexture, @@ -288,12 +303,12 @@ void RenderDeviceGLImpl::CreateSampler(const SamplerDesc& SamplerDesc, ISampler } -void RenderDeviceGLImpl::CreatePipelineState( const PipelineStateDesc &PipelineDesc, IPipelineState **ppPipelineState) +void RenderDeviceGLImpl::CreatePipelineState( const PipelineStateDesc& PipelineDesc, IPipelineState **ppPipelineState) { CreatePipelineState(PipelineDesc, ppPipelineState, false); } -void RenderDeviceGLImpl::CreatePipelineState(const PipelineStateDesc &PipelineDesc, IPipelineState **ppPipelineState, bool bIsDeviceInternal) +void RenderDeviceGLImpl::CreatePipelineState(const PipelineStateDesc& PipelineDesc, IPipelineState **ppPipelineState, bool bIsDeviceInternal) { CreateDeviceObject( "Pipeline state", PipelineDesc, ppPipelineState, [&]() @@ -306,6 +321,18 @@ void RenderDeviceGLImpl::CreatePipelineState(const PipelineStateDesc &PipelineDe ); } +void RenderDeviceGLImpl::CreateFence(const FenceDesc& Desc, IFence** ppFence) +{ + CreateDeviceObject( "Fence", Desc, ppFence, + [&]() + { + FenceGLImpl* pFenceOGL( NEW_RC_OBJ(m_FenceAllocator, "FenceGLImpl instance", FenceGLImpl) + (this, Desc) ); + pFenceOGL->QueryInterface( IID_Fence, reinterpret_cast<IObject**>(ppFence) ); + OnCreateDeviceObject( pFenceOGL ); + } + ); +} bool RenderDeviceGLImpl::CheckExtension( const Char *ExtensionString ) { @@ -314,9 +341,9 @@ bool RenderDeviceGLImpl::CheckExtension( const Char *ExtensionString ) void RenderDeviceGLImpl::FlagSupportedTexFormats() { - const auto &DeviceCaps = GetDeviceCaps(); - bool bGL33OrAbove = DeviceCaps.DevType == DeviceType::OpenGL && - (DeviceCaps.MajorVersion >= 4 || (DeviceCaps.MajorVersion == 3 && DeviceCaps.MinorVersion >= 3) ); + const auto& DeviceCaps = GetDeviceCaps(); + bool bGL33OrAbove = DeviceCaps.DevType == DeviceType::OpenGL&& + (DeviceCaps.MajorVersion >= 4 || (DeviceCaps.MajorVersion == 3&& DeviceCaps.MinorVersion >= 3) ); bool bRGTC = CheckExtension( "GL_ARB_texture_compression_rgtc" ); bool bBPTC = CheckExtension( "GL_ARB_texture_compression_bptc" ); @@ -434,7 +461,7 @@ void RenderDeviceGLImpl::FlagSupportedTexFormats() FLAG_FORMAT(TEX_FORMAT_BC7_UNORM_SRGB, bBPTC ); #ifdef _DEBUG - bool bGL43OrAbove = DeviceCaps.DevType == DeviceType::OpenGL && + bool bGL43OrAbove = DeviceCaps.DevType == DeviceType::OpenGL && (DeviceCaps.MajorVersion >= 5 || (DeviceCaps.MajorVersion == 4 && DeviceCaps.MinorVersion >= 3) ); const int TestTextureDim = 32; @@ -479,7 +506,7 @@ void RenderDeviceGLImpl::FlagSupportedTexFormats() // For some reason glTexStorage2D() may succeed, but upload operation // will later fail. So we need to additionally try to upload some // data to the texture - const auto &TransferAttribs = GetNativePixelTransferAttribs( FmtInfo->Format ); + const auto& TransferAttribs = GetNativePixelTransferAttribs( FmtInfo->Format ); if( FmtInfo->ComponentType != COMPONENT_TYPE_COMPRESSED ) { glTexSubImage2D( GL_TEXTURE_2D, 0, // mip level @@ -495,7 +522,7 @@ void RenderDeviceGLImpl::FlagSupportedTexFormats() } template<typename CreateFuncType> -bool CreateTestGLTexture(GLContextState &GlCtxState, GLenum BindTarget, const GLObjectWrappers::GLTextureObj &GLTexObj, CreateFuncType CreateFunc) +bool CreateTestGLTexture(GLContextState& GlCtxState, GLenum BindTarget, const GLObjectWrappers::GLTextureObj& GLTexObj, CreateFuncType CreateFunc) { GlCtxState.BindTexture(-1, BindTarget, GLTexObj); CreateFunc(); @@ -506,7 +533,7 @@ bool CreateTestGLTexture(GLContextState &GlCtxState, GLenum BindTarget, const GL void RenderDeviceGLImpl::TestTextureFormat( TEXTURE_FORMAT TexFormat ) { - auto &TexFormatInfo = m_TextureFormatsInfo[TexFormat]; + auto& TexFormatInfo = m_TextureFormatsInfo[TexFormat]; VERIFY( TexFormatInfo.Supported, "Texture format is not supported" ); auto GLFmt = TexFormatToGLInternalTexFormat(TexFormat); @@ -515,14 +542,14 @@ void RenderDeviceGLImpl::TestTextureFormat( TEXTURE_FORMAT TexFormat ) auto spDeviceContext = GetImmediateContext(); VERIFY(spDeviceContext, "Immediate device context has been destroyed"); auto *pContextGL = spDeviceContext.RawPtr<DeviceContextGLImpl>(); - auto &ContextState = pContextGL->GetContextState(); + auto& ContextState = pContextGL->GetContextState(); const int TestTextureDim = 32; const int TestTextureDepth = 8; // Create test texture 1D TexFormatInfo.Tex1DFmt = false; - if( m_DeviceCaps.TexCaps.bTexture1DSupported && + if( m_DeviceCaps.TexCaps.bTexture1DSupported && TexFormatInfo.ComponentType != COMPONENT_TYPE_COMPRESSED ) { GLObjectWrappers::GLTextureObj TestGLTex( true ); @@ -620,7 +647,7 @@ void RenderDeviceGLImpl::TestTextureFormat( TEXTURE_FORMAT TexFormat ) } TexFormatInfo.SupportsMS = false; - if( TexFormatInfo.ComponentType != COMPONENT_TYPE_COMPRESSED && + if( TexFormatInfo.ComponentType != COMPONENT_TYPE_COMPRESSED && m_DeviceCaps.TexCaps.bTexture2DMSSupported ) { #if GL_ARB_texture_storage_multisample |
