101e04c3fSmrg/**************************************************************************** 201e04c3fSmrg * Copyright (C) 2015 Intel Corporation. All Rights Reserved. 301e04c3fSmrg * 401e04c3fSmrg * Permission is hereby granted, free of charge, to any person obtaining a 501e04c3fSmrg * copy of this software and associated documentation files (the "Software"), 601e04c3fSmrg * to deal in the Software without restriction, including without limitation 701e04c3fSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 801e04c3fSmrg * and/or sell copies of the Software, and to permit persons to whom the 901e04c3fSmrg * Software is furnished to do so, subject to the following conditions: 1001e04c3fSmrg * 1101e04c3fSmrg * The above copyright notice and this permission notice shall be included 1201e04c3fSmrg * in all copies or substantial portions of the Software. 1301e04c3fSmrg * 1401e04c3fSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 1501e04c3fSmrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1601e04c3fSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1701e04c3fSmrg * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 1801e04c3fSmrg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 1901e04c3fSmrg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2001e04c3fSmrg ***************************************************************************/ 2101e04c3fSmrg 2201e04c3fSmrg#ifndef SWR_FENCE_H 2301e04c3fSmrg#define SWR_FENCE_H 2401e04c3fSmrg 2501e04c3fSmrg#include "pipe/p_state.h" 2601e04c3fSmrg#include "util/u_inlines.h" 2701e04c3fSmrg 2801e04c3fSmrg#include "swr_fence_work.h" 2901e04c3fSmrg 3001e04c3fSmrgstruct pipe_screen; 3101e04c3fSmrg 3201e04c3fSmrgstruct swr_fence { 3301e04c3fSmrg struct pipe_reference reference; 3401e04c3fSmrg 3501e04c3fSmrg uint64_t read; 3601e04c3fSmrg uint64_t write; 3701e04c3fSmrg 3801e04c3fSmrg unsigned pending; 3901e04c3fSmrg 4001e04c3fSmrg unsigned id; /* Just for reference */ 4101e04c3fSmrg 4201e04c3fSmrg struct { 4301e04c3fSmrg uint32_t count; 4401e04c3fSmrg struct swr_fence_work head; 4501e04c3fSmrg struct swr_fence_work *tail; 4601e04c3fSmrg } work; 4701e04c3fSmrg}; 4801e04c3fSmrg 4901e04c3fSmrg 5001e04c3fSmrgstatic inline struct swr_fence * 5101e04c3fSmrgswr_fence(struct pipe_fence_handle *fence) 5201e04c3fSmrg{ 5301e04c3fSmrg return (struct swr_fence *)fence; 5401e04c3fSmrg} 5501e04c3fSmrg 5601e04c3fSmrg 577ec681f3Smrgstatic INLINE bool 5801e04c3fSmrgswr_is_fence_done(struct pipe_fence_handle *fence_handle) 5901e04c3fSmrg{ 6001e04c3fSmrg struct swr_fence *fence = swr_fence(fence_handle); 6101e04c3fSmrg return (fence->read == fence->write); 6201e04c3fSmrg} 6301e04c3fSmrg 647ec681f3Smrgstatic INLINE bool 6501e04c3fSmrgswr_is_fence_pending(struct pipe_fence_handle *fence_handle) 6601e04c3fSmrg{ 6701e04c3fSmrg return swr_fence(fence_handle)->pending; 6801e04c3fSmrg} 6901e04c3fSmrg 7001e04c3fSmrg 7101e04c3fSmrgvoid swr_fence_init(struct pipe_screen *screen); 7201e04c3fSmrg 7301e04c3fSmrgstruct pipe_fence_handle *swr_fence_create(); 7401e04c3fSmrg 7501e04c3fSmrgvoid swr_fence_reference(struct pipe_screen *screen, 7601e04c3fSmrg struct pipe_fence_handle **ptr, 7701e04c3fSmrg struct pipe_fence_handle *f); 7801e04c3fSmrg 797ec681f3Smrgbool swr_fence_finish(struct pipe_screen *screen, 807ec681f3Smrg struct pipe_context *ctx, 817ec681f3Smrg struct pipe_fence_handle *fence_handle, 827ec681f3Smrg uint64_t timeout); 8301e04c3fSmrg 8401e04c3fSmrgvoid 8501e04c3fSmrgswr_fence_submit(struct swr_context *ctx, struct pipe_fence_handle *fence); 8601e04c3fSmrg 8701e04c3fSmrguint64_t swr_get_timestamp(struct pipe_screen *screen); 8801e04c3fSmrg 8901e04c3fSmrg#endif 90