Path: blob/21.2-virgl/src/gallium/frontends/clover/api/interop.cpp
4572 views
//1// Copyright 2015 Advanced Micro Devices, Inc.2// All Rights Reserved.3//4// Permission is hereby granted, free of charge, to any person obtaining a5// copy of this software and associated documentation files (the "Software"),6// to deal in the Software without restriction, including without limitation7// the rights to use, copy, modify, merge, publish, distribute, sublicense,8// and/or sell copies of the Software, and to permit persons to whom the9// Software is furnished to do so, subject to the following conditions:10//11// The above copyright notice and this permission notice shall be included in12// all copies or substantial portions of the Software.13//14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR18// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,19// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR20// OTHER DEALINGS IN THE SOFTWARE.21//2223#include "core/event.hpp"24#include "api/util.hpp"2526using namespace clover;2728extern "C" {2930PUBLIC bool31opencl_dri_event_add_ref(cl_event event)32{33/* This should fail if the event hasn't been created by34* clEnqueueReleaseGLObjects or clEnqueueReleaseEGLObjects.35*36* TODO: implement the CL functions37*/38return false; /*return clRetainEvent(event) == CL_SUCCESS;*/39}4041PUBLIC bool42opencl_dri_event_release(cl_event event)43{44return clReleaseEvent(event) == CL_SUCCESS;45}4647PUBLIC bool48opencl_dri_event_wait(cl_event event, uint64_t timeout) try {49if (!timeout) {50return obj(event).status() == CL_COMPLETE;51}5253obj(event).wait();54return true;5556} catch (error &) {57return false;58}5960PUBLIC struct pipe_fence_handle *61opencl_dri_event_get_fence(cl_event event) try {62return obj(event).fence();6364} catch (error &) {65return NULL;66}6768}697071