From bee567b21589b63aaf60d69e693b1dd5018abb06 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 6 Aug 2019 23:13:11 -0700 Subject: OpenGL backend: creating a dummy fragment shader when none is present in the PSO to fix issues in some GL implementations --- Graphics/GraphicsEngineOpenGL/src/PipelineStateGLImpl.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/src/PipelineStateGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/PipelineStateGLImpl.cpp index ea853b4b..d00d0162 100644 --- a/Graphics/GraphicsEngineOpenGL/src/PipelineStateGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/PipelineStateGLImpl.cpp @@ -38,6 +38,19 @@ PipelineStateGLImpl::PipelineStateGLImpl(IReferenceCounters* pRefCounters, TPipelineStateBase(pRefCounters, pDeviceGL, PipelineDesc, bIsDeviceInternal), m_GLProgram(false) { + if (!m_Desc.IsComputePipeline && m_pPS == nullptr) + { + // Some OpenGL implementations fail if fragment shader is not present, so + // create a dummy one. + ShaderCreateInfo ShaderCI; + ShaderCI.SourceLanguage = SHADER_SOURCE_LANGUAGE_GLSL; + ShaderCI.Source = "void main(){}"; + ShaderCI.Desc.ShaderType = SHADER_TYPE_PIXEL; + ShaderCI.Desc.Name = "Dummy fragment shader"; + pDeviceGL->CreateShader(ShaderCI, &m_pPS); + m_Desc.GraphicsPipeline.pPS = m_pPS; + m_ppShaders[m_NumShaders++] = m_pPS; + } auto &DeviceCaps = pDeviceGL->GetDeviceCaps(); VERIFY( DeviceCaps.DevType != DeviceType::Undefined, "Device caps are not initialized" ); -- cgit v1.2.3