From 93eda1da4a8a35c8f4558b48815a08603cb9c99e Mon Sep 17 00:00:00 2001 From: assiduous Date: Thu, 20 Aug 2020 15:52:28 -0700 Subject: GL backend: committing GL program or pipeline in SetPipelineState function --- Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp index cf655a01..4155f51e 100644 --- a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp @@ -144,6 +144,11 @@ void DeviceContextGLImpl::SetPipelineState(IPipelineState* pPipelineState) } m_ContextState.InvalidateVAO(); } + + // Note that the program may change if a shader is created after the call + // (GLProgramResources needs to bind a program to load uniforms), but before + // the draw command. + m_pPipelineState->CommitProgram(m_ContextState); } void DeviceContextGLImpl::TransitionShaderResources(IPipelineState* pPipelineState, IShaderResourceBinding* pShaderResourceBinding) @@ -881,6 +886,8 @@ void DeviceContextGLImpl::PrepareForDraw(DRAW_FLAGS Flags, bool IsIndexed, GLenu DvpVerifyRenderTargets(); #endif + // The program might have changed since the last SetPipelineState call if a shader was + // created after the call (GLProgramResources needs to bind a program to load uniforms). m_pPipelineState->CommitProgram(m_ContextState); auto CurrNativeGLContext = m_pDevice->m_GLContext.GetCurrentNativeGLContext(); @@ -1101,6 +1108,8 @@ void DeviceContextGLImpl::DispatchCompute(const DispatchComputeAttribs& Attribs) return; #if GL_ARB_compute_shader + // The program might have changed since the last SetPipelineState call if a shader was + // created after the call (GLProgramResources needs to bind a program to load uniforms). m_pPipelineState->CommitProgram(m_ContextState); glDispatchCompute(Attribs.ThreadGroupCountX, Attribs.ThreadGroupCountY, Attribs.ThreadGroupCountZ); DEV_CHECK_GL_ERROR("glDispatchCompute() failed"); @@ -1117,6 +1126,8 @@ void DeviceContextGLImpl::DispatchComputeIndirect(const DispatchComputeIndirectA return; #if GL_ARB_compute_shader + // The program might have changed since the last SetPipelineState call if a shader was + // created after the call (GLProgramResources needs to bind a program to load uniforms). m_pPipelineState->CommitProgram(m_ContextState); auto* pBufferGL = ValidatedCast(pAttribsBuffer); -- cgit v1.2.3