Path: blob/21.2-virgl/src/gallium/drivers/i915/i915_flush.c
4570 views
/**************************************************************************1*2* Copyright 2007 VMware, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627/* Author:28* Keith Whitwell <[email protected]>29*/3031#include "draw/draw_context.h"32#include "pipe/p_defines.h"33#include "i915_batch.h"34#include "i915_context.h"35#include "i915_debug.h"36#include "i915_reg.h"3738static void39i915_flush_pipe(struct pipe_context *pipe, struct pipe_fence_handle **fence,40unsigned flags)41{42struct i915_context *i915 = i915_context(pipe);43enum i915_winsys_flush_flags winsys_flags = I915_FLUSH_ASYNC;4445if (!i915->batch)46return;4748/* Only shortcut this if we have no fence, otherwise we must flush the49* empty batchbuffer to get our fence back.50*/51if (!fence && (i915->batch->map == i915->batch->ptr)) {52return;53}5455if (flags == PIPE_FLUSH_END_OF_FRAME)56winsys_flags = I915_FLUSH_END_OF_FRAME;5758FLUSH_BATCH(fence, winsys_flags);5960I915_DBG(DBG_FLUSH, "%s: #####\n", __FUNCTION__);61}6263void64i915_init_flush_functions(struct i915_context *i915)65{66i915->base.flush = i915_flush_pipe;67}6869/**70* Here we handle all the notifications that needs to go out on a flush.71* XXX might move above function to i915_pipe_flush.c and leave this here.72*/73void74i915_flush(struct i915_context *i915, struct pipe_fence_handle **fence,75unsigned flags)76{77struct i915_winsys_batchbuffer *batch = i915->batch;7879batch->iws->batchbuffer_flush(batch, fence, flags);80i915->vbo_flushed = 1;81i915->hardware_dirty = ~0;82i915->immediate_dirty = ~0;83i915->dynamic_dirty = ~0;84i915->static_dirty = ~0;85/* kernel emits flushes in between batchbuffers */86i915->flush_dirty = 0;87i915->fired_vertices += i915->queued_vertices;88i915->queued_vertices = 0;89}909192