Files
compute-runtime/runtime/sharings/gl/gl_sync_event.cpp
Artur Harasimiuk de2d5d7532 move CL-GL Sharing header to different folder
- rename file
- move to folder public

Change-Id: Ie3c14c5a2be0aec5809b322b9a0e2cebe0e3fc22
Signed-off-by: Artur Harasimiuk <artur.harasimiuk@intel.com>
2018-09-20 10:42:41 +02:00

59 lines
1.9 KiB
C++

/*
* Copyright (C) 2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/sharings/gl/gl_sync_event.h"
#include "runtime/sharings/gl/gl_sharing.h"
#include "runtime/command_stream/command_stream_receiver.h"
#include "runtime/context/context.h"
#include "runtime/device/device.h"
#include "runtime/event/async_events_handler.h"
#include "runtime/event/event_builder.h"
#include "runtime/gmm_helper/gmm_helper.h"
#include "runtime/helpers/get_info.h"
#include "runtime/platform/platform.h"
#include "public/cl_gl_private_intel.h"
namespace OCLRT {
GlSyncEvent::GlSyncEvent(Context &context, const GL_CL_SYNC_INFO &sync)
: Event(&context, nullptr, CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR, eventNotReady, eventNotReady), glSync(new GL_CL_SYNC_INFO(sync)) {
transitionExecutionStatus(CL_SUBMITTED);
}
GlSyncEvent::~GlSyncEvent() { ctx->getSharing<GLSharingFunctions>()->releaseSync(glSync->pSync); }
GlSyncEvent *GlSyncEvent::create(Context &context, cl_GLsync sync, cl_int *errCode) {
GLContextGuard guard(*context.getSharing<GLSharingFunctions>());
ErrorCodeHelper err(errCode, CL_SUCCESS);
GL_CL_SYNC_INFO syncInfo = {sync, nullptr};
context.getSharing<GLSharingFunctions>()->retainSync(&syncInfo);
DEBUG_BREAK_IF(!syncInfo.pSync);
EventBuilder eventBuilder;
eventBuilder.create<GlSyncEvent>(context, syncInfo);
return static_cast<GlSyncEvent *>(eventBuilder.finalizeAndRelease());
}
void GlSyncEvent::updateExecutionStatus() {
GLContextGuard guard(*ctx->getSharing<GLSharingFunctions>());
int retVal = 0;
ctx->getSharing<GLSharingFunctions>()->getSynciv(glSync->pSync, GL_SYNC_STATUS, &retVal);
if (retVal == GL_SIGNALED) {
setStatus(CL_COMPLETE);
}
}
uint32_t GlSyncEvent::getTaskLevel() {
auto &csr = ctx->getDevice(0)->getCommandStreamReceiver();
return csr.peekTaskLevel();
}
} // namespace OCLRT