Path: blob/21.2-virgl/src/freedreno/drm/freedreno_ringbuffer.c
4564 views
/*1* Copyright (C) 2012-2018 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#include <assert.h>2728#include "freedreno_drmif.h"29#include "freedreno_priv.h"30#include "freedreno_ringbuffer.h"3132struct fd_submit *33fd_submit_new(struct fd_pipe *pipe)34{35struct fd_submit *submit = pipe->funcs->submit_new(pipe);36submit->refcnt = 1;37submit->pipe = fd_pipe_ref(pipe);38return submit;39}4041void42fd_submit_del(struct fd_submit *submit)43{44if (!p_atomic_dec_zero(&submit->refcnt))45return;4647if (submit->primary)48fd_ringbuffer_del(submit->primary);4950fd_pipe_del(submit->pipe);5152submit->funcs->destroy(submit);53}5455struct fd_submit *56fd_submit_ref(struct fd_submit *submit)57{58p_atomic_inc(&submit->refcnt);59return submit;60}6162int63fd_submit_flush(struct fd_submit *submit, int in_fence_fd,64struct fd_submit_fence *out_fence)65{66submit->fence = fd_pipe_emit_fence(submit->pipe, submit->primary);67return submit->funcs->flush(submit, in_fence_fd, out_fence);68}6970struct fd_ringbuffer *71fd_submit_new_ringbuffer(struct fd_submit *submit, uint32_t size,72enum fd_ringbuffer_flags flags)73{74debug_assert(!(flags & _FD_RINGBUFFER_OBJECT));75if (flags & FD_RINGBUFFER_STREAMING) {76debug_assert(!(flags & FD_RINGBUFFER_GROWABLE));77debug_assert(!(flags & FD_RINGBUFFER_PRIMARY));78}79struct fd_ringbuffer *ring =80submit->funcs->new_ringbuffer(submit, size, flags);8182if (flags & FD_RINGBUFFER_PRIMARY) {83debug_assert(!submit->primary);84submit->primary = fd_ringbuffer_ref(ring);85}8687return ring;88}8990struct fd_ringbuffer *91fd_ringbuffer_new_object(struct fd_pipe *pipe, uint32_t size)92{93return pipe->funcs->ringbuffer_new_object(pipe, size);94}959697