From 80026db2b32d6d0eea9233c9f129d8c400f1de2e Mon Sep 17 00:00:00 2001 From: Payam Date: Mon, 7 Feb 2022 12:51:01 -0500 Subject: [PATCH] SWDEV-321160 - Checking if GL-Context is initialized Change-Id: I5482fa33bcf9a1587ee68ed37f2058b7ed7e706a [ROCm/clr commit: f501317b5b33f7f0a43a8b14a9366c72010f9000] --- projects/clr/hipamd/src/hip_gl.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) 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());