1cdc920a0Smrg/************************************************************************** 2cdc920a0Smrg * 3cdc920a0Smrg * Copyright 2009 VMware, Inc. 4cdc920a0Smrg * All Rights Reserved. 5cdc920a0Smrg * 6cdc920a0Smrg * Permission is hereby granted, free of charge, to any person obtaining a 7cdc920a0Smrg * copy of this software and associated documentation files (the 8cdc920a0Smrg * "Software"), to deal in the Software without restriction, including 9cdc920a0Smrg * without limitation the rights to use, copy, modify, merge, publish, 10cdc920a0Smrg * distribute, sub license, and/or sell copies of the Software, and to 11cdc920a0Smrg * permit persons to whom the Software is furnished to do so, subject to 12cdc920a0Smrg * the following conditions: 13cdc920a0Smrg * 14cdc920a0Smrg * The above copyright notice and this permission notice (including the 15cdc920a0Smrg * next paragraph) shall be included in all copies or substantial portions 16cdc920a0Smrg * of the Software. 17cdc920a0Smrg * 18cdc920a0Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19cdc920a0Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20cdc920a0Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21cdc920a0Smrg * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 22cdc920a0Smrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23cdc920a0Smrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24cdc920a0Smrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25cdc920a0Smrg * 26cdc920a0Smrg **************************************************************************/ 27cdc920a0Smrg 28cdc920a0Smrg 29cdc920a0Smrg#ifndef LP_FENCE_H 30cdc920a0Smrg#define LP_FENCE_H 31cdc920a0Smrg 32cdc920a0Smrg 33cdc920a0Smrg#include "os/os_thread.h" 34cdc920a0Smrg#include "pipe/p_state.h" 353464ebd5Sriastradh#include "util/u_inlines.h" 36cdc920a0Smrg 37cdc920a0Smrg 38cdc920a0Smrgstruct pipe_screen; 39cdc920a0Smrg 40cdc920a0Smrg 41cdc920a0Smrgstruct lp_fence 42cdc920a0Smrg{ 43cdc920a0Smrg struct pipe_reference reference; 443464ebd5Sriastradh unsigned id; 45cdc920a0Smrg 4601e04c3fSmrg mtx_t mutex; 4701e04c3fSmrg cnd_t signalled; 48cdc920a0Smrg 493464ebd5Sriastradh boolean issued; 50cdc920a0Smrg unsigned rank; 51cdc920a0Smrg unsigned count; 52cdc920a0Smrg}; 53cdc920a0Smrg 54cdc920a0Smrg 55cdc920a0Smrgstruct lp_fence * 56cdc920a0Smrglp_fence_create(unsigned rank); 57cdc920a0Smrg 58cdc920a0Smrg 593464ebd5Sriastradhvoid 603464ebd5Sriastradhlp_fence_signal(struct lp_fence *fence); 613464ebd5Sriastradh 623464ebd5Sriastradhboolean 633464ebd5Sriastradhlp_fence_signalled(struct lp_fence *fence); 643464ebd5Sriastradh 653464ebd5Sriastradhvoid 663464ebd5Sriastradhlp_fence_wait(struct lp_fence *fence); 673464ebd5Sriastradh 689f464c52Smayaboolean 699f464c52Smayalp_fence_timedwait(struct lp_fence *fence, uint64_t timeout); 709f464c52Smaya 71cdc920a0Smrgvoid 72cdc920a0Smrgllvmpipe_init_screen_fence_funcs(struct pipe_screen *screen); 73cdc920a0Smrg 74cdc920a0Smrg 753464ebd5Sriastradhvoid 763464ebd5Sriastradhlp_fence_destroy(struct lp_fence *fence); 773464ebd5Sriastradh 7801e04c3fSmrgstatic inline void 793464ebd5Sriastradhlp_fence_reference(struct lp_fence **ptr, 803464ebd5Sriastradh struct lp_fence *f) 813464ebd5Sriastradh{ 823464ebd5Sriastradh struct lp_fence *old = *ptr; 833464ebd5Sriastradh 843464ebd5Sriastradh if (pipe_reference(&old->reference, &f->reference)) { 853464ebd5Sriastradh lp_fence_destroy(old); 863464ebd5Sriastradh } 873464ebd5Sriastradh 883464ebd5Sriastradh *ptr = f; 893464ebd5Sriastradh} 903464ebd5Sriastradh 9101e04c3fSmrgstatic inline boolean 923464ebd5Sriastradhlp_fence_issued(const struct lp_fence *fence) 933464ebd5Sriastradh{ 943464ebd5Sriastradh return fence->issued; 953464ebd5Sriastradh} 963464ebd5Sriastradh 973464ebd5Sriastradh 98cdc920a0Smrg#endif /* LP_FENCE_H */ 99