diff --git a/projects/clr/hipamd/src/hip_gl.cpp b/projects/clr/hipamd/src/hip_gl.cpp index 16938a22d7..7282e51636 100644 --- a/projects/clr/hipamd/src/hip_gl.cpp +++ b/projects/clr/hipamd/src/hip_gl.cpp @@ -235,6 +235,11 @@ hipError_t hipGraphicsGLRegisterImage(hipGraphicsResource** resource, GLuint ima GLint miplevel = 0; amd::Context& amdContext = *(hip::getCurrentDevice()->asContext()); + if (amdContext.glenv() == nullptr) { + LogError("invalid context, gl interop not initialized"); + HIP_RETURN(hipErrorInvalidValue); + } + amd::GLFunctions::SetIntEnv ie(amdContext.glenv()); if (!ie.isValid()) { LogWarning("\"amdContext\" is not created from GL context or share list \n"); @@ -544,6 +549,11 @@ hipError_t hipGraphicsGLRegisterBuffer(hipGraphicsResource** resource, GLuint bu amd::Context& amdContext = *(hip::getCurrentDevice()->asContext()); + if (amdContext.glenv() == nullptr) { + LogError("invalid context, gl interop not initialized"); + HIP_RETURN(hipErrorInvalidValue); + } + // Add this scope to bound the scoped lock { amd::GLFunctions::SetIntEnv ie(amdContext.glenv());