1b8e80941Smrg/**************************************************************************** 2b8e80941Smrg * Copyright (C) 2015 Intel Corporation. All Rights Reserved. 3b8e80941Smrg * 4b8e80941Smrg * Permission is hereby granted, free of charge, to any person obtaining a 5b8e80941Smrg * copy of this software and associated documentation files (the "Software"), 6b8e80941Smrg * to deal in the Software without restriction, including without limitation 7b8e80941Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8b8e80941Smrg * and/or sell copies of the Software, and to permit persons to whom the 9b8e80941Smrg * Software is furnished to do so, subject to the following conditions: 10b8e80941Smrg * 11b8e80941Smrg * The above copyright notice and this permission notice shall be included 12b8e80941Smrg * in all copies or substantial portions of the Software. 13b8e80941Smrg * 14b8e80941Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15b8e80941Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16b8e80941Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17b8e80941Smrg * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 18b8e80941Smrg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19b8e80941Smrg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20b8e80941Smrg ***************************************************************************/ 21b8e80941Smrg 22b8e80941Smrg#ifndef SWR_FENCE_H 23b8e80941Smrg#define SWR_FENCE_H 24b8e80941Smrg 25b8e80941Smrg#include "pipe/p_state.h" 26b8e80941Smrg#include "util/u_inlines.h" 27b8e80941Smrg 28b8e80941Smrg#include "swr_fence_work.h" 29b8e80941Smrg 30b8e80941Smrgstruct pipe_screen; 31b8e80941Smrg 32b8e80941Smrgstruct swr_fence { 33b8e80941Smrg struct pipe_reference reference; 34b8e80941Smrg 35b8e80941Smrg uint64_t read; 36b8e80941Smrg uint64_t write; 37b8e80941Smrg 38b8e80941Smrg unsigned pending; 39b8e80941Smrg 40b8e80941Smrg unsigned id; /* Just for reference */ 41b8e80941Smrg 42b8e80941Smrg struct { 43b8e80941Smrg uint32_t count; 44b8e80941Smrg struct swr_fence_work head; 45b8e80941Smrg struct swr_fence_work *tail; 46b8e80941Smrg } work; 47b8e80941Smrg}; 48b8e80941Smrg 49b8e80941Smrg 50b8e80941Smrgstatic inline struct swr_fence * 51b8e80941Smrgswr_fence(struct pipe_fence_handle *fence) 52b8e80941Smrg{ 53b8e80941Smrg return (struct swr_fence *)fence; 54b8e80941Smrg} 55b8e80941Smrg 56b8e80941Smrg 57b8e80941Smrgstatic INLINE boolean 58b8e80941Smrgswr_is_fence_done(struct pipe_fence_handle *fence_handle) 59b8e80941Smrg{ 60b8e80941Smrg struct swr_fence *fence = swr_fence(fence_handle); 61b8e80941Smrg return (fence->read == fence->write); 62b8e80941Smrg} 63b8e80941Smrg 64b8e80941Smrgstatic INLINE boolean 65b8e80941Smrgswr_is_fence_pending(struct pipe_fence_handle *fence_handle) 66b8e80941Smrg{ 67b8e80941Smrg return swr_fence(fence_handle)->pending; 68b8e80941Smrg} 69b8e80941Smrg 70b8e80941Smrg 71b8e80941Smrgvoid swr_fence_init(struct pipe_screen *screen); 72b8e80941Smrg 73b8e80941Smrgstruct pipe_fence_handle *swr_fence_create(); 74b8e80941Smrg 75b8e80941Smrgvoid swr_fence_reference(struct pipe_screen *screen, 76b8e80941Smrg struct pipe_fence_handle **ptr, 77b8e80941Smrg struct pipe_fence_handle *f); 78b8e80941Smrg 79b8e80941Smrgboolean swr_fence_finish(struct pipe_screen *screen, 80b8e80941Smrg struct pipe_context *ctx, 81b8e80941Smrg struct pipe_fence_handle *fence_handle, 82b8e80941Smrg uint64_t timeout); 83b8e80941Smrg 84b8e80941Smrgvoid 85b8e80941Smrgswr_fence_submit(struct swr_context *ctx, struct pipe_fence_handle *fence); 86b8e80941Smrg 87b8e80941Smrguint64_t swr_get_timestamp(struct pipe_screen *screen); 88b8e80941Smrg 89b8e80941Smrg#endif 90