Path: blob/21.2-virgl/src/gallium/drivers/swr/swr_fence.h
4570 views
/****************************************************************************1* Copyright (C) 2015 Intel Corporation. All Rights Reserved.2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice shall be included11* in all copies or substantial portions of the Software.12*13* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS14* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL16* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN17* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN18* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.19***************************************************************************/2021#ifndef SWR_FENCE_H22#define SWR_FENCE_H2324#include "pipe/p_state.h"25#include "util/u_inlines.h"2627#include "swr_fence_work.h"2829struct pipe_screen;3031struct swr_fence {32struct pipe_reference reference;3334uint64_t read;35uint64_t write;3637unsigned pending;3839unsigned id; /* Just for reference */4041struct {42uint32_t count;43struct swr_fence_work head;44struct swr_fence_work *tail;45} work;46};474849static inline struct swr_fence *50swr_fence(struct pipe_fence_handle *fence)51{52return (struct swr_fence *)fence;53}545556static INLINE bool57swr_is_fence_done(struct pipe_fence_handle *fence_handle)58{59struct swr_fence *fence = swr_fence(fence_handle);60return (fence->read == fence->write);61}6263static INLINE bool64swr_is_fence_pending(struct pipe_fence_handle *fence_handle)65{66return swr_fence(fence_handle)->pending;67}686970void swr_fence_init(struct pipe_screen *screen);7172struct pipe_fence_handle *swr_fence_create();7374void swr_fence_reference(struct pipe_screen *screen,75struct pipe_fence_handle **ptr,76struct pipe_fence_handle *f);7778bool swr_fence_finish(struct pipe_screen *screen,79struct pipe_context *ctx,80struct pipe_fence_handle *fence_handle,81uint64_t timeout);8283void84swr_fence_submit(struct swr_context *ctx, struct pipe_fence_handle *fence);8586uint64_t swr_get_timestamp(struct pipe_screen *screen);8788#endif899091