Path: blob/21.2-virgl/src/gallium/drivers/freedreno/freedreno_fence.h
4570 views
/*1* Copyright (C) 2012 Rob Clark <[email protected]>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 (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,19* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE20* SOFTWARE.21*22* Authors:23* Rob Clark <[email protected]>24*/2526#ifndef FREEDRENO_FENCE_H_27#define FREEDRENO_FENCE_H_2829#include "pipe/p_context.h"30#include "util/u_queue.h"3132#include "drm/freedreno_ringbuffer.h"3334struct pipe_fence_handle {35struct pipe_reference reference;3637/* When a pre-created unflushed fence has no actual rendering to flush, and38* the last_fence optimization is used, this will be a reference to the39* *actualy* fence which needs to be flushed before waiting.40*/41struct pipe_fence_handle *last_fence;4243/* fence holds a weak reference to the batch until the batch is flushed, to44* accommodate PIPE_FLUSH_DEFERRED. When the batch is actually flushed, it45* is cleared (before the batch reference is dropped). If we need to wait46* on a fence, and the batch is not NULL, we need to flush it.47*48* Note that with u_threaded_context async flushes, if a fence is requested49* by the frontend, the fence is initially created without a weak reference50* to the batch, which is filled in later when fd_context_flush() is called51* from the driver thread. In this case tc_token will be non-null, in52* which case threaded_context_flush() should be called in fd_fence_finish()53*/54struct fd_batch *batch;5556struct tc_unflushed_batch_token *tc_token;57bool needs_signal;5859/* For threaded_context async flushes, we must wait on the fence, signaled60* when fence->batch is cleared, to know that the rendering has been actually61* flushed from the driver thread.62*63* The ready fence is created signaled for non-async-flush fences, and only64* transitions once from unsignalled->signalled for async-flush fences65*/66struct util_queue_fence ready;6768/* Note that a fence can outlive the ctx, so we can only assume this is a69* valid ptr for unflushed fences. However we hold a reference to the70* fence->pipe so that is safe to use after flushing.71*/72struct fd_context *ctx;73struct fd_pipe *pipe;74struct fd_screen *screen;75struct fd_submit_fence submit_fence;76uint32_t syncobj;77};7879void fd_fence_repopulate(struct pipe_fence_handle *fence,80struct pipe_fence_handle *last_fence);81void fd_fence_ref(struct pipe_fence_handle **ptr,82struct pipe_fence_handle *pfence);83bool fd_fence_finish(struct pipe_screen *pscreen, struct pipe_context *ctx,84struct pipe_fence_handle *pfence, uint64_t timeout);85void fd_create_fence_fd(struct pipe_context *pctx,86struct pipe_fence_handle **pfence, int fd,87enum pipe_fd_type type);88void fd_fence_server_sync(struct pipe_context *pctx,89struct pipe_fence_handle *fence);90void fd_fence_server_signal(struct pipe_context *ctx,91struct pipe_fence_handle *fence);92int fd_fence_get_fd(struct pipe_screen *pscreen,93struct pipe_fence_handle *pfence);94bool fd_fence_is_fd(struct pipe_fence_handle *fence);9596struct fd_batch;97struct pipe_fence_handle *fd_fence_create(struct fd_batch *batch);9899void fd_fence_set_batch(struct pipe_fence_handle *fence,100struct fd_batch *batch);101102struct tc_unflushed_batch_token;103struct pipe_fence_handle *104fd_fence_create_unflushed(struct pipe_context *pctx,105struct tc_unflushed_batch_token *tc_token);106107#endif /* FREEDRENO_FENCE_H_ */108109110