193d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell/************************************************************************** 293d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * 393d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. 493d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * All Rights Reserved. 593d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * 693d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * Permission is hereby granted, free of charge, to any person obtaining a 793d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * copy of this software and associated documentation files (the 893d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * "Software"), to deal in the Software without restriction, including 993d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * without limitation the rights to use, copy, modify, merge, publish, 1093d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * distribute, sub license, and/or sell copies of the Software, and to 1193d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * permit persons to whom the Software is furnished to do so, subject to 1293d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * the following conditions: 1393d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * 1493d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * The above copyright notice and this permission notice (including the 1593d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * next paragraph) shall be included in all copies or substantial portions 1693d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * of the Software. 1793d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * 1893d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 1993d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2093d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 2193d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 2293d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 2393d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 2493d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2593d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * 2693d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell **************************************************************************/ 2793d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell 2893d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell/* Author: 2993d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * Keith Whitwell <keith@tungstengraphics.com> 3093d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell */ 3193d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell 3293d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell 3393d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell#include "pipe/p_defines.h" 34b53110c78941e7fcaa41921cce07ca00ec117a97Brian#include "draw/draw_context.h" 3593d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell#include "i915_context.h" 3693d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell#include "i915_reg.h" 3793d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell#include "i915_batch.h" 38abbb1bde06990cb15c82ebcdb9ac07b00cb0ab4fJakob Bornecrantz#include "i915_debug.h" 3993d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell 4074df1f4adbbc4fe6027265625cd248c3add154f5Brian 4157fc2ad7a165bd969de5d1943e325db52f702eb8Jakob Bornecrantzstatic void i915_flush_pipe( struct pipe_context *pipe, 4257fc2ad7a165bd969de5d1943e325db52f702eb8Jakob Bornecrantz struct pipe_fence_handle **fence ) 4393d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell{ 4493d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell struct i915_context *i915 = i915_context(pipe); 4593d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell 4632b07bb1496f5772ca16e719bb87e1702ceff196Stéphane Marchesin /* Only shortcut this if we have no fence, otherwise we must flush the 4732b07bb1496f5772ca16e719bb87e1702ceff196Stéphane Marchesin * empty batchbuffer to get our fence back. 4832b07bb1496f5772ca16e719bb87e1702ceff196Stéphane Marchesin */ 4932b07bb1496f5772ca16e719bb87e1702ceff196Stéphane Marchesin if (!fence && i915->batch && (i915->batch->map == i915->batch->ptr)) { 5087a4fa56ae473946b84233fda59d40dd479a4d64Jakob Bornecrantz return; 5187a4fa56ae473946b84233fda59d40dd479a4d64Jakob Bornecrantz } 5293d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell 5393d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell /* If there are no flags, just flush pending commands to hardware: 5493d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell */ 554abe1eb980ed76d2b2d3383eaab520d0aa2ae6f4Michel Dänzer FLUSH_BATCH(fence); 5693d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell 57abbb1bde06990cb15c82ebcdb9ac07b00cb0ab4fJakob Bornecrantz I915_DBG(DBG_FLUSH, "%s: #####\n", __FUNCTION__); 58abbb1bde06990cb15c82ebcdb9ac07b00cb0ab4fJakob Bornecrantz} 5993d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell 6093d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwellvoid i915_init_flush_functions( struct i915_context *i915 ) 6193d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell{ 6257fc2ad7a165bd969de5d1943e325db52f702eb8Jakob Bornecrantz i915->base.flush = i915_flush_pipe; 6357fc2ad7a165bd969de5d1943e325db52f702eb8Jakob Bornecrantz} 6457fc2ad7a165bd969de5d1943e325db52f702eb8Jakob Bornecrantz 6557fc2ad7a165bd969de5d1943e325db52f702eb8Jakob Bornecrantz/** 6657fc2ad7a165bd969de5d1943e325db52f702eb8Jakob Bornecrantz * Here we handle all the notifications that needs to go out on a flush. 6757fc2ad7a165bd969de5d1943e325db52f702eb8Jakob Bornecrantz * XXX might move above function to i915_pipe_flush.c and leave this here. 6857fc2ad7a165bd969de5d1943e325db52f702eb8Jakob Bornecrantz */ 6957fc2ad7a165bd969de5d1943e325db52f702eb8Jakob Bornecrantzvoid i915_flush(struct i915_context *i915, struct pipe_fence_handle **fence) 7057fc2ad7a165bd969de5d1943e325db52f702eb8Jakob Bornecrantz{ 7157fc2ad7a165bd969de5d1943e325db52f702eb8Jakob Bornecrantz struct i915_winsys_batchbuffer *batch = i915->batch; 7257fc2ad7a165bd969de5d1943e325db52f702eb8Jakob Bornecrantz 7357fc2ad7a165bd969de5d1943e325db52f702eb8Jakob Bornecrantz batch->iws->batchbuffer_flush(batch, fence); 744407e5078f6083e4e56ba5970d0fa10d504ed45bJakob Bornecrantz i915->vbo_flushed = 1; 7557fc2ad7a165bd969de5d1943e325db52f702eb8Jakob Bornecrantz i915->hardware_dirty = ~0; 76b9baad2aff6ddc5145d91cbfb81d083a21990a80Jakob Bornecrantz i915->immediate_dirty = ~0; 778fb0ecd0cf4a4d672c0744abb4a9f030b3a17527Jakob Bornecrantz i915->dynamic_dirty = ~0; 78288504fac7b659da6bd45f22ccfb39d130250f9cDaniel Vetter i915->static_dirty = ~0; 79d42c9433b0a3d9b3a198261d8037ce0d4595452dDaniel Vetter /* kernel emits flushes in between batchbuffers */ 80d42c9433b0a3d9b3a198261d8037ce0d4595452dDaniel Vetter i915->flush_dirty = 0; 81b97889f543085f516fc1c821c621790399d57fa5Stéphane Marchesin i915->fired_vertices += i915->queued_vertices; 82b97889f543085f516fc1c821c621790399d57fa5Stéphane Marchesin i915->queued_vertices = 0; 8393d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell} 84