i915_flush.c revision 93d5cfd8b7c641c5656aed38ad2f9559e09502f0
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" 3493d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell#include "i915_context.h" 3593d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell#include "i915_reg.h" 3693d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell#include "i915_batch.h" 3793d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell 3893d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell/* There will be actual work to do here. In future we may want a 3993d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * fence-like interface instead of finish, and perhaps flush will take 4093d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * flags to indicate what type of flush is required. 4193d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell */ 4293d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwellstatic void i915_flush( struct pipe_context *pipe, 4393d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell unsigned flags ) 4493d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell{ 4593d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell struct i915_context *i915 = i915_context(pipe); 4693d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell 4793d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell /* Do we need to emit an MI_FLUSH command to flush the hardware 4893d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell * caches? 4993d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell */ 5093d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell if (flags) { 5193d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell unsigned flush = MI_FLUSH; 5293d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell 5393d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell if (!(flags & PIPE_FLUSH_RENDER_CACHE)) 5493d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell flush |= INHIBIT_FLUSH_RENDER_CACHE; 5593d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell 5693d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell if (flags & PIPE_FLUSH_TEXTURE_CACHE) 5793d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell flush |= FLUSH_MAP_CACHE; 5893d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell 5993d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell BEGIN_BATCH( 1, 0 ); 6093d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell OUT_BATCH( flush ); 6193d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell ADVANCE_BATCH(); 6293d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell } 6393d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell 6493d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell /* If there are no flags, just flush pending commands to hardware: 6593d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell */ 6693d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell FLUSH_BATCH(); 6793d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell} 6893d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell 6993d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwellstatic void i915_finish(struct pipe_context *pipe) 7093d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell{ 7193d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell struct i915_context *i915 = i915_context(pipe); 7293d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell 7393d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell i915_flush( pipe, 0 ); 7493d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell i915->winsys->batch_wait_idle( i915->winsys ); 7593d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell} 7693d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell 7793d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell 7893d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwellvoid i915_init_flush_functions( struct i915_context *i915 ) 7993d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell{ 8093d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell i915->pipe.flush = i915_flush; 8193d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell i915->pipe.finish = i915_finish; 8293d5cfd8b7c641c5656aed38ad2f9559e09502f0Keith Whitwell} 83