From 3aaa8e2dcb73ca91a488f21250aceb0267fb15d6 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Mon, 26 Mar 2018 23:20:54 -0700 Subject: Reworked debug message handling to allow user-specified callbacks --- Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp | 7 +++++++ Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp | 7 +++++++ 2 files changed, 14 insertions(+) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp index 390b99cd..ff2d46de 100644 --- a/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp @@ -52,7 +52,14 @@ static GLenum GetBufferBindTarget(const BufferDesc& Desc) Target = GL_UNIFORM_BUFFER; else if(Desc.BindFlags & BIND_INDIRECT_DRAW_ARGS) { +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable : 4127) // conditional expression is constant +#endif VERIFY(GL_DRAW_INDIRECT_BUFFER != 0, "Inidrect draw is not supported"); +#ifdef _MSC_VER +# pragma warning(pop) +#endif Target = GL_DRAW_INDIRECT_BUFFER; } else if (Desc.Usage == USAGE_CPU_ACCESSIBLE && Desc.CPUAccessFlags == CPU_ACCESS_WRITE) diff --git a/Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp index 46653e2a..46ee6ca2 100644 --- a/Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp @@ -42,7 +42,14 @@ namespace Diligent { if( ViewDesc.ViewType == BUFFER_VIEW_SHADER_RESOURCE && pBuffer->GetDesc().Mode == BUFFER_MODE_FORMATTED ) { +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable : 4127) // conditional expression is constant +#endif VERIFY( GL_TEXTURE_BUFFER != 0, "GL texture buffers are not supported"); +#ifdef _MSC_VER +# pragma warning(pop) +#endif auto *pContextGL = ValidatedCast(pContext); auto &ContextState = pContextGL->GetContextState(); -- cgit v1.2.3 From 87382bcca0ea984274477af3af1ff8d8c9495ced Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 27 Mar 2018 08:58:06 -0700 Subject: Added DebugMessageCallback to EngineCreation attribs --- Graphics/GraphicsEngineOpenGL/src/RenderDeviceFactoryOpenGL.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceFactoryOpenGL.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceFactoryOpenGL.cpp index bb455da1..a3e4d276 100644 --- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceFactoryOpenGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceFactoryOpenGL.cpp @@ -98,6 +98,9 @@ void EngineFactoryOpenGLImpl::CreateDeviceAndSwapChainGL(const EngineGLAttribs& const SwapChainDesc& SCDesc, ISwapChain **ppSwapChain ) { + if (CreationAttribs.DebugMessageCallback != nullptr) + SetDebugMessageCallback(CreationAttribs.DebugMessageCallback); + VERIFY( ppDevice && ppImmediateContext && ppSwapChain, "Null pointer provided" ); if( !ppDevice || !ppImmediateContext || !ppSwapChain ) return; @@ -164,6 +167,9 @@ void EngineFactoryOpenGLImpl::AttachToActiveGLContext( const EngineGLAttribs& Cr IRenderDevice **ppDevice, IDeviceContext **ppImmediateContext ) { + if (CreationAttribs.DebugMessageCallback != nullptr) + SetDebugMessageCallback(CreationAttribs.DebugMessageCallback); + VERIFY( ppDevice && ppImmediateContext, "Null pointer provided" ); if( !ppDevice || !ppImmediateContext ) return; -- cgit v1.2.3 From cf7ef96b20bf3f91a9ee623f94800d617bc6ff3c Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 27 Mar 2018 18:46:47 -0700 Subject: Added shader compiler log output --- Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp | 47 ++++++++++++++-------- 1 file changed, 30 insertions(+), 17 deletions(-) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp index 58106b5e..dad50a0c 100644 --- a/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp @@ -33,8 +33,8 @@ using namespace Diligent; namespace Diligent { -ShaderGLImpl::ShaderGLImpl(IReferenceCounters *pRefCounters, RenderDeviceGLImpl *pDeviceGL, const ShaderCreationAttribs &ShaderCreationAttribs, bool bIsDeviceInternal) : - TShaderBase( pRefCounters, pDeviceGL, ShaderCreationAttribs.Desc, bIsDeviceInternal ), +ShaderGLImpl::ShaderGLImpl(IReferenceCounters *pRefCounters, RenderDeviceGLImpl *pDeviceGL, const ShaderCreationAttribs &CreationAttribs, bool bIsDeviceInternal) : + TShaderBase( pRefCounters, pDeviceGL, CreationAttribs.Desc, bIsDeviceInternal ), m_GlProgObj(false), m_GLShaderObj( false, GLObjectWrappers::GLShaderObjCreateReleaseHelper( GetGLShaderType( m_Desc.ShaderType ) ) ) { @@ -196,9 +196,9 @@ ShaderGLImpl::ShaderGLImpl(IReferenceCounters *pRefCounters, RenderDeviceGLImpl Lenghts.push_back( static_cast( strlen(ShaderTypeDefine) ) ); String UserDefines; - if( ShaderCreationAttribs.Macros != nullptr) + if( CreationAttribs.Macros != nullptr) { - auto *pMacro = ShaderCreationAttribs.Macros; + auto *pMacro = CreationAttribs.Macros; while( pMacro->Name != nullptr && pMacro->Definition != nullptr ) { UserDefines += "#define "; @@ -213,7 +213,7 @@ ShaderGLImpl::ShaderGLImpl(IReferenceCounters *pRefCounters, RenderDeviceGLImpl } RefCntAutoPtr pFileData(MakeNewRCObj()(0)); - auto ShaderSource = ShaderCreationAttribs.Source; + auto ShaderSource = CreationAttribs.Source; GLuint SourceLen = 0; if( ShaderSource ) { @@ -221,9 +221,9 @@ ShaderGLImpl::ShaderGLImpl(IReferenceCounters *pRefCounters, RenderDeviceGLImpl } else { - VERIFY(ShaderCreationAttribs.pShaderSourceStreamFactory, "Input stream factory is null"); + VERIFY(CreationAttribs.pShaderSourceStreamFactory, "Input stream factory is null"); RefCntAutoPtr pSourceStream; - ShaderCreationAttribs.pShaderSourceStreamFactory->CreateInputStream( ShaderCreationAttribs.FilePath, &pSourceStream ); + CreationAttribs.pShaderSourceStreamFactory->CreateInputStream( CreationAttribs.FilePath, &pSourceStream ); if (pSourceStream == nullptr) LOG_ERROR_AND_THROW("Failed to open shader source file"); @@ -233,19 +233,19 @@ ShaderGLImpl::ShaderGLImpl(IReferenceCounters *pRefCounters, RenderDeviceGLImpl } String ConvertedSource; - if( ShaderCreationAttribs.SourceLanguage == SHADER_SOURCE_LANGUAGE_HLSL ) + if( CreationAttribs.SourceLanguage == SHADER_SOURCE_LANGUAGE_HLSL ) { // Convert HLSL to GLSL const auto &Converter = HLSL2GLSLConverterImpl::GetInstance(); HLSL2GLSLConverterImpl::ConversionAttribs Attribs; - Attribs.pSourceStreamFactory = ShaderCreationAttribs.pShaderSourceStreamFactory; - Attribs.ppConversionStream = ShaderCreationAttribs.ppConversionStream; + Attribs.pSourceStreamFactory = CreationAttribs.pShaderSourceStreamFactory; + Attribs.ppConversionStream = CreationAttribs.ppConversionStream; Attribs.HLSLSource = ShaderSource; Attribs.NumSymbols = SourceLen; - Attribs.EntryPoint = ShaderCreationAttribs.EntryPoint; - Attribs.ShaderType = ShaderCreationAttribs.Desc.ShaderType; + Attribs.EntryPoint = CreationAttribs.EntryPoint; + Attribs.ShaderType = CreationAttribs.Desc.ShaderType; Attribs.IncludeDefinitions = true; - Attribs.InputFileName = ShaderCreationAttribs.FilePath; + Attribs.InputFileName = CreationAttribs.FilePath; ConvertedSource = Converter.Convert(Attribs); ShaderSource = ConvertedSource.c_str(); @@ -284,17 +284,15 @@ ShaderGLImpl::ShaderGLImpl(IReferenceCounters *pRefCounters, RenderDeviceGLImpl for(const auto *str : ShaderStrings) FullSource.append(str); - LOG_INFO_MESSAGE("Failed shader full source: \n\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n", FullSource, "\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n"); - std::stringstream ErrorMsgSS; - ErrorMsgSS << "Failed to compile shader file \""<< (ShaderCreationAttribs.FilePath != nullptr ? ShaderCreationAttribs.FilePath : "") << '\"' << std::endl; + ErrorMsgSS << "Failed to compile shader file \""<< (CreationAttribs.FilePath != nullptr ? CreationAttribs.FilePath : "") << '\"' << std::endl; int infoLogLen = 0; // The function glGetShaderiv() tells how many bytes to allocate; the length includes the NULL terminator. glGetShaderiv(ShaderObj, GL_INFO_LOG_LENGTH, &infoLogLen); + std::vector infoLog(infoLogLen); if (infoLogLen > 0) { - std::vector infoLog(infoLogLen); int charsWritten = 0; // Get the log. infoLogLen is the size of infoLog. This tells OpenGL how many bytes at maximum it will write // charsWritten is a return value, specifying how many bytes it actually wrote. One may pass NULL if he @@ -303,6 +301,21 @@ ShaderGLImpl::ShaderGLImpl(IReferenceCounters *pRefCounters, RenderDeviceGLImpl VERIFY(charsWritten == infoLogLen-1, "Unexpected info log length"); ErrorMsgSS << "InfoLog:" << std::endl << infoLog.data() << std::endl; } + + if (CreationAttribs.ppCompilerOutput != nullptr) + { + auto *pOutputDataBlob = MakeNewRCObj()(infoLogLen + FullSource.length() + 1); + char* DataPtr = reinterpret_cast(pOutputDataBlob->GetDataPtr()); + memcpy(DataPtr, !infoLog.empty() ? infoLog.data() : nullptr, infoLogLen); + memcpy(DataPtr + infoLogLen, FullSource.data(), FullSource.length() + 1); + pOutputDataBlob->QueryInterface(IID_DataBlob, reinterpret_cast(CreationAttribs.ppCompilerOutput)); + } + else + { + // Dump full source code to debug output + LOG_INFO_MESSAGE("Failed shader full source: \n\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n", FullSource, "\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n"); + } + LOG_ERROR_AND_THROW(ErrorMsgSS.str().c_str()); } -- cgit v1.2.3 From 0a63fc06246a3868e11741cd3682accc069ba868 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 27 Mar 2018 19:39:35 -0700 Subject: Added shader name output when shader compilation fails --- Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp index dad50a0c..7b9d93ac 100644 --- a/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp @@ -285,7 +285,7 @@ ShaderGLImpl::ShaderGLImpl(IReferenceCounters *pRefCounters, RenderDeviceGLImpl FullSource.append(str); std::stringstream ErrorMsgSS; - ErrorMsgSS << "Failed to compile shader file \""<< (CreationAttribs.FilePath != nullptr ? CreationAttribs.FilePath : "") << '\"' << std::endl; + ErrorMsgSS << "Failed to compile shader file \""<< (CreationAttribs.Desc.Name != nullptr ? CreationAttribs.Desc.Name : "") << '\"' << std::endl; int infoLogLen = 0; // The function glGetShaderiv() tells how many bytes to allocate; the length includes the NULL terminator. glGetShaderiv(ShaderObj, GL_INFO_LOG_LENGTH, &infoLogLen); -- cgit v1.2.3 From f88358621a3a2ffa1a9b7a87baa84695075337bd Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sat, 31 Mar 2018 11:55:55 -0700 Subject: Implemented switching to a fullscreen mode in d3d on Win32 --- Graphics/GraphicsEngineOpenGL/include/SwapChainGLImpl.h | 4 ++++ Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp | 10 ++++++++++ 2 files changed, 14 insertions(+) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/include/SwapChainGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/SwapChainGLImpl.h index 01630707..7cfca2da 100644 --- a/Graphics/GraphicsEngineOpenGL/include/SwapChainGLImpl.h +++ b/Graphics/GraphicsEngineOpenGL/include/SwapChainGLImpl.h @@ -51,6 +51,10 @@ public: virtual void Resize( Uint32 NewWidth, Uint32 NewHeight )override final; + virtual void SetFullscreenMode(const DisplayModeAttribs &DisplayMode)override final; + + virtual void SetWindowedMode()override final; + virtual GLuint GetDefaultFBO()const override final{ return 0; } }; diff --git a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp index 4939716d..e9349f7b 100644 --- a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp @@ -111,4 +111,14 @@ void SwapChainGLImpl::Resize( Uint32 NewWidth, Uint32 NewHeight ) } } +void SwapChainGLImpl::SetFullscreenMode(const DisplayModeAttribs &DisplayMode) +{ + UNSUPPORTED("OpenGL does not support switching to the fullscreen mode"); +} + +void SwapChainGLImpl::SetWindowedMode() +{ + UNSUPPORTED("OpenGL does not support switching to the windowed mode"); +} + } -- cgit v1.2.3 From b731e5ae479f53adb2be57fdcef1a253c9edbf40 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sat, 31 Mar 2018 12:31:42 -0700 Subject: Fixed build error on iOS --- Graphics/GraphicsEngineOpenGL/include/SwapChainGLIOS.h | 4 ++++ Graphics/GraphicsEngineOpenGL/src/SwapChainGLIOS.mm | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/include/SwapChainGLIOS.h b/Graphics/GraphicsEngineOpenGL/include/SwapChainGLIOS.h index f41b5d52..4f91e2f8 100644 --- a/Graphics/GraphicsEngineOpenGL/include/SwapChainGLIOS.h +++ b/Graphics/GraphicsEngineOpenGL/include/SwapChainGLIOS.h @@ -51,6 +51,10 @@ public: virtual void Resize( Uint32 NewWidth, Uint32 NewHeight )override final; + virtual void SetFullscreenMode(const DisplayModeAttribs &DisplayMode)override final; + + virtual void SetWindowedMode()override final; + virtual GLuint GetDefaultFBO()const override final; private: diff --git a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLIOS.mm b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLIOS.mm index 3da0a75b..b56ed277 100644 --- a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLIOS.mm +++ b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLIOS.mm @@ -136,5 +136,15 @@ GLuint SwapChainGLIOS::GetDefaultFBO()const { return m_DefaultFBO; } - + +void SwapChainGLIOS::SetFullscreenMode(const DisplayModeAttribs &DisplayMode) +{ + UNSUPPORTED("Switching to fullscreen mode is not available on iOS"); +} + +void SwapChainGLIOS::SetWindowedMode() +{ + UNSUPPORTED("Switching to windowed mode is not available on iOS"); +} + } -- cgit v1.2.3 From a8a3940fa4491963048ade02dcb035eaca4b6eb5 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sat, 31 Mar 2018 16:43:02 -0700 Subject: Added sync interval parameter to ISwapChain::Present() --- Graphics/GraphicsEngineOpenGL/include/SwapChainGLIOS.h | 2 +- Graphics/GraphicsEngineOpenGL/include/SwapChainGLImpl.h | 2 +- Graphics/GraphicsEngineOpenGL/src/SwapChainGLIOS.mm | 2 +- Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/include/SwapChainGLIOS.h b/Graphics/GraphicsEngineOpenGL/include/SwapChainGLIOS.h index 4f91e2f8..141d7c4f 100644 --- a/Graphics/GraphicsEngineOpenGL/include/SwapChainGLIOS.h +++ b/Graphics/GraphicsEngineOpenGL/include/SwapChainGLIOS.h @@ -47,7 +47,7 @@ public: virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override final; - virtual void Present()override final; + virtual void Present(Uint32 SyncInterval)override final; virtual void Resize( Uint32 NewWidth, Uint32 NewHeight )override final; diff --git a/Graphics/GraphicsEngineOpenGL/include/SwapChainGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/SwapChainGLImpl.h index 7cfca2da..85137adc 100644 --- a/Graphics/GraphicsEngineOpenGL/include/SwapChainGLImpl.h +++ b/Graphics/GraphicsEngineOpenGL/include/SwapChainGLImpl.h @@ -47,7 +47,7 @@ public: virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override final; - virtual void Present()override final; + virtual void Present(Uint32 SyncInterval)override final; virtual void Resize( Uint32 NewWidth, Uint32 NewHeight )override final; diff --git a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLIOS.mm b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLIOS.mm index b56ed277..679ea021 100644 --- a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLIOS.mm +++ b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLIOS.mm @@ -50,7 +50,7 @@ SwapChainGLIOS::SwapChainGLIOS(IReferenceCounters *pRefCounters, IMPLEMENT_QUERY_INTERFACE( SwapChainGLIOS, IID_SwapChainGL, TSwapChainBase ) -void SwapChainGLIOS::Present() +void SwapChainGLIOS::Present(Uint32 SyncInterval) { EAGLContext* context = [EAGLContext currentContext]; glBindRenderbuffer(GL_RENDERBUFFER, m_ColorRenderBuffer); diff --git a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp index e9349f7b..bebaacb3 100644 --- a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp @@ -69,7 +69,7 @@ SwapChainGLImpl::~SwapChainGLImpl() IMPLEMENT_QUERY_INTERFACE( SwapChainGLImpl, IID_SwapChainGL, TSwapChainBase ) -void SwapChainGLImpl::Present() +void SwapChainGLImpl::Present(Uint32 SyncInterval) { #if PLATFORM_WIN32 || PLATFORM_LINUX || PLATFORM_ANDROID auto *pDeviceGL = ValidatedCast(m_pRenderDevice.RawPtr()); -- cgit v1.2.3