summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineOpenGL
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-04-01 21:29:40 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-04-01 21:29:40 +0000
commit6438621293a4dc5b12def1954375aa41e661bba4 (patch)
tree39660542c2d1d63fb1d2db26cb911f88b759b2fc /Graphics/GraphicsEngineOpenGL
parentImplementing texture views in Vulkan (diff)
parentAdded comment (diff)
downloadDiligentCore-6438621293a4dc5b12def1954375aa41e661bba4.tar.gz
DiligentCore-6438621293a4dc5b12def1954375aa41e661bba4.zip
Merge branch 'master'
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/SwapChainGLIOS.h6
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/SwapChainGLImpl.h6
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp7
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp7
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/RenderDeviceFactoryOpenGL.cpp6
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp47
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/SwapChainGLIOS.mm14
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp12
8 files changed, 83 insertions, 22 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/include/SwapChainGLIOS.h b/Graphics/GraphicsEngineOpenGL/include/SwapChainGLIOS.h
index f41b5d52..141d7c4f 100644
--- a/Graphics/GraphicsEngineOpenGL/include/SwapChainGLIOS.h
+++ b/Graphics/GraphicsEngineOpenGL/include/SwapChainGLIOS.h
@@ -47,10 +47,14 @@ 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;
+ 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/include/SwapChainGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/SwapChainGLImpl.h
index 01630707..85137adc 100644
--- a/Graphics/GraphicsEngineOpenGL/include/SwapChainGLImpl.h
+++ b/Graphics/GraphicsEngineOpenGL/include/SwapChainGLImpl.h
@@ -47,10 +47,14 @@ 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;
+ 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/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<DeviceContextGLImpl>(pContext);
auto &ContextState = pContextGL->GetContextState();
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;
diff --git a/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/ShaderGLImpl.cpp
index 58106b5e..7b9d93ac 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<GLint>( 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<IDataBlob> pFileData(MakeNewRCObj<DataBlobImpl>()(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<IFileStream> 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.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);
+ std::vector<GLchar> infoLog(infoLogLen);
if (infoLogLen > 0)
{
- std::vector<GLchar> 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<DataBlobImpl>()(infoLogLen + FullSource.length() + 1);
+ char* DataPtr = reinterpret_cast<char*>(pOutputDataBlob->GetDataPtr());
+ memcpy(DataPtr, !infoLog.empty() ? infoLog.data() : nullptr, infoLogLen);
+ memcpy(DataPtr + infoLogLen, FullSource.data(), FullSource.length() + 1);
+ pOutputDataBlob->QueryInterface(IID_DataBlob, reinterpret_cast<IObject**>(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());
}
diff --git a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLIOS.mm b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLIOS.mm
index 3da0a75b..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);
@@ -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");
+}
+
}
diff --git a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp
index 4939716d..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<RenderDeviceGLImpl>(m_pRenderDevice.RawPtr());
@@ -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");
+}
+
}