17ec681f3Smrg//
27ec681f3Smrg// Copyright 2015 Advanced Micro Devices, Inc.
37ec681f3Smrg// All Rights Reserved.
47ec681f3Smrg//
57ec681f3Smrg// Permission is hereby granted, free of charge, to any person obtaining a
67ec681f3Smrg// copy of this software and associated documentation files (the "Software"),
77ec681f3Smrg// to deal in the Software without restriction, including without limitation
87ec681f3Smrg// the rights to use, copy, modify, merge, publish, distribute, sublicense,
97ec681f3Smrg// and/or sell copies of the Software, and to permit persons to whom the
107ec681f3Smrg// Software is furnished to do so, subject to the following conditions:
117ec681f3Smrg//
127ec681f3Smrg// The above copyright notice and this permission notice shall be included in
137ec681f3Smrg// all copies or substantial portions of the Software.
147ec681f3Smrg//
157ec681f3Smrg// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
167ec681f3Smrg// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
177ec681f3Smrg// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
187ec681f3Smrg// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
197ec681f3Smrg// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
207ec681f3Smrg// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
217ec681f3Smrg// OTHER DEALINGS IN THE SOFTWARE.
227ec681f3Smrg//
237ec681f3Smrg
247ec681f3Smrg#include "core/event.hpp"
257ec681f3Smrg#include "api/util.hpp"
267ec681f3Smrg
277ec681f3Smrgusing namespace clover;
287ec681f3Smrg
297ec681f3Smrgextern "C" {
307ec681f3Smrg
317ec681f3SmrgPUBLIC bool
327ec681f3Smrgopencl_dri_event_add_ref(cl_event event)
337ec681f3Smrg{
347ec681f3Smrg   /* This should fail if the event hasn't been created by
357ec681f3Smrg    * clEnqueueReleaseGLObjects or clEnqueueReleaseEGLObjects.
367ec681f3Smrg    *
377ec681f3Smrg    * TODO: implement the CL functions
387ec681f3Smrg    */
397ec681f3Smrg   return false; /*return clRetainEvent(event) == CL_SUCCESS;*/
407ec681f3Smrg}
417ec681f3Smrg
427ec681f3SmrgPUBLIC bool
437ec681f3Smrgopencl_dri_event_release(cl_event event)
447ec681f3Smrg{
457ec681f3Smrg   return clReleaseEvent(event) == CL_SUCCESS;
467ec681f3Smrg}
477ec681f3Smrg
487ec681f3SmrgPUBLIC bool
497ec681f3Smrgopencl_dri_event_wait(cl_event event, uint64_t timeout) try {
507ec681f3Smrg   if (!timeout) {
517ec681f3Smrg      return obj(event).status() == CL_COMPLETE;
527ec681f3Smrg   }
537ec681f3Smrg
547ec681f3Smrg   obj(event).wait();
557ec681f3Smrg   return true;
567ec681f3Smrg
577ec681f3Smrg} catch (error &) {
587ec681f3Smrg   return false;
597ec681f3Smrg}
607ec681f3Smrg
617ec681f3SmrgPUBLIC struct pipe_fence_handle *
627ec681f3Smrgopencl_dri_event_get_fence(cl_event event) try {
637ec681f3Smrg   return obj(event).fence();
647ec681f3Smrg
657ec681f3Smrg} catch (error &) {
667ec681f3Smrg   return NULL;
677ec681f3Smrg}
687ec681f3Smrg
697ec681f3Smrg}
70