1952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák// 2952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák// Copyright 2015 Advanced Micro Devices, Inc. 3952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák// All Rights Reserved. 4952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák// 5952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák// Permission is hereby granted, free of charge, to any person obtaining a 6952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák// copy of this software and associated documentation files (the "Software"), 7952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák// to deal in the Software without restriction, including without limitation 8952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák// the rights to use, copy, modify, merge, publish, distribute, sublicense, 9952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák// and/or sell copies of the Software, and to permit persons to whom the 10952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák// Software is furnished to do so, subject to the following conditions: 11952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák// 12952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák// The above copyright notice and this permission notice shall be included in 13952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák// all copies or substantial portions of the Software. 14952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák// 15952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 19952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák// OTHER DEALINGS IN THE SOFTWARE. 22952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák// 23952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák 24952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák#include "core/event.hpp" 25952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák#include "api/util.hpp" 26952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák 27952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšákusing namespace clover; 28952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák 29952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšákextern "C" { 30952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák 31952b5e84db47be3adaf01f047efeedd26cf0d173Marek OlšákPUBLIC bool 32952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšákopencl_dri_event_add_ref(cl_event event) 33952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák{ 346acb61fc9c2c5f81569d17d90a480abc48ec6055Marek Olšák /* This should fail if the event hasn't been created by 356acb61fc9c2c5f81569d17d90a480abc48ec6055Marek Olšák * clEnqueueReleaseGLObjects or clEnqueueReleaseEGLObjects. 366acb61fc9c2c5f81569d17d90a480abc48ec6055Marek Olšák * 376acb61fc9c2c5f81569d17d90a480abc48ec6055Marek Olšák * TODO: implement the CL functions 386acb61fc9c2c5f81569d17d90a480abc48ec6055Marek Olšák */ 396acb61fc9c2c5f81569d17d90a480abc48ec6055Marek Olšák return false; /*return clRetainEvent(event) == CL_SUCCESS;*/ 40952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák} 41952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák 42952b5e84db47be3adaf01f047efeedd26cf0d173Marek OlšákPUBLIC bool 43952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšákopencl_dri_event_release(cl_event event) 44952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák{ 45952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák return clReleaseEvent(event) == CL_SUCCESS; 46952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák} 47952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák 48952b5e84db47be3adaf01f047efeedd26cf0d173Marek OlšákPUBLIC bool 49952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšákopencl_dri_event_wait(cl_event event, uint64_t timeout) try { 50952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák if (!timeout) { 51952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák return obj(event).status() == CL_COMPLETE; 52952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák } 53952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák 54952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák obj(event).wait(); 55952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák return true; 56952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák 57952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák} catch (error &) { 58952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák return false; 59952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák} 60952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák 61952b5e84db47be3adaf01f047efeedd26cf0d173Marek OlšákPUBLIC struct pipe_fence_handle * 62952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšákopencl_dri_event_get_fence(cl_event event) try { 63952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák return obj(event).fence(); 64952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák 65952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák} catch (error &) { 66952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák return NULL; 67952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák} 68952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák 69952b5e84db47be3adaf01f047efeedd26cf0d173Marek Olšák} 70