From 9aebe61637a61d147f663de2c47d857860767e16 Mon Sep 17 00:00:00 2001 From: German Andryeyev Date: Fri, 12 Mar 2021 14:34:59 -0500 Subject: [PATCH] SWDEV-276631 - return error codes for clCreateEventFromGLsyncKHR() Change-Id: I9b93f5bde157d0f746a9d662ef35fbbb20cce6e6 --- opencl/amdocl/cl_gl.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/opencl/amdocl/cl_gl.cpp b/opencl/amdocl/cl_gl.cpp index 7d87809fa0..320edee5e5 100644 --- a/opencl/amdocl/cl_gl.cpp +++ b/opencl/amdocl/cl_gl.cpp @@ -753,15 +753,26 @@ RUNTIME_EXIT RUNTIME_ENTRY_RET(cl_event, clCreateEventFromGLsyncKHR, (cl_context context, cl_GLsync clGLsync, cl_int* errcode_ret)) { + if (!is_valid(context)) { + *not_null(errcode_ret) = CL_INVALID_CONTEXT; + LogWarning("invalid parameter \"context\""); + return nullptr; + } // create event of fence sync type amd::ClGlEvent* clglEvent = new amd::ClGlEvent(*as_amd(context)); + if (clglEvent == nullptr) { + *not_null(errcode_ret) = CL_OUT_OF_HOST_MEMORY; + LogWarning("Memory allocation of clglEvent object failed"); + return nullptr; + } clglEvent->context().glenv()->glFlush_(); // initially set the status of fence as queued clglEvent->setStatus(CL_SUBMITTED); // store GLsync id of the fence in event in order to associate them together clglEvent->setData(clGLsync); - amd::Event* evt = dynamic_cast(clglEvent); + amd::Event* evt = clglEvent; evt->retain(); + *not_null(errcode_ret) = CL_SUCCESS; return as_cl(evt); } RUNTIME_EXIT