142542f5fSchristos/* 242542f5fSchristos * Copyright © 2011-2013 Intel Corporation 342542f5fSchristos * 442542f5fSchristos * Permission is hereby granted, free of charge, to any person obtaining a 542542f5fSchristos * copy of this software and associated documentation files (the "Software"), 642542f5fSchristos * to deal in the Software without restriction, including without limitation 742542f5fSchristos * the rights to use, copy, modify, merge, publish, distribute, sublicense, 842542f5fSchristos * and/or sell copies of the Software, and to permit persons to whom the 942542f5fSchristos * Software is furnished to do so, subject to the following conditions: 1042542f5fSchristos * 1142542f5fSchristos * The above copyright notice and this permission notice (including the next 1242542f5fSchristos * paragraph) shall be included in all copies or substantial portions of the 1342542f5fSchristos * Software. 1442542f5fSchristos * 1542542f5fSchristos * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1642542f5fSchristos * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1742542f5fSchristos * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1842542f5fSchristos * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1942542f5fSchristos * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 2042542f5fSchristos * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 2142542f5fSchristos * SOFTWARE. 2242542f5fSchristos * 2342542f5fSchristos * Authors: 2442542f5fSchristos * Chris Wilson <chris@chris-wilson.co.uk> 2542542f5fSchristos * 2642542f5fSchristos */ 2742542f5fSchristos 2842542f5fSchristos#ifdef HAVE_CONFIG_H 2942542f5fSchristos#include "config.h" 3042542f5fSchristos#endif 3142542f5fSchristos 3242542f5fSchristos#include "gen6_common.h" 3342542f5fSchristos#include "gen4_vertex.h" 3442542f5fSchristos 3542542f5fSchristosvoid 3642542f5fSchristosgen6_render_context_switch(struct kgem *kgem, 3742542f5fSchristos int new_mode) 3842542f5fSchristos{ 3942542f5fSchristos if (kgem->nbatch) { 4042542f5fSchristos DBG(("%s: from %d to %d, submit batch\n", __FUNCTION__, kgem->mode, new_mode)); 4142542f5fSchristos _kgem_submit(kgem); 4242542f5fSchristos } 4342542f5fSchristos 4442542f5fSchristos if (kgem->nexec) { 4542542f5fSchristos DBG(("%s: from %d to %d, reset incomplete batch\n", __FUNCTION__, kgem->mode, new_mode)); 4642542f5fSchristos kgem_reset(kgem); 4742542f5fSchristos } 4842542f5fSchristos 4942542f5fSchristos assert(kgem->nbatch == 0); 5042542f5fSchristos assert(kgem->nreloc == 0); 5142542f5fSchristos assert(kgem->nexec == 0); 5242542f5fSchristos 5342542f5fSchristos kgem->ring = new_mode; 5442542f5fSchristos} 5542542f5fSchristos 5642542f5fSchristosvoid gen6_render_retire(struct kgem *kgem) 5742542f5fSchristos{ 5842542f5fSchristos struct sna *sna; 5942542f5fSchristos 6042542f5fSchristos if (kgem->ring && (kgem->has_semaphores || !kgem->need_retire)) 6142542f5fSchristos kgem->ring = kgem->mode; 6242542f5fSchristos 6342542f5fSchristos sna = container_of(kgem, struct sna, kgem); 6442542f5fSchristos if (sna->render.nvertex_reloc == 0 && 6542542f5fSchristos sna->render.vbo && 6642542f5fSchristos !kgem_bo_is_busy(sna->render.vbo)) { 6742542f5fSchristos DBG(("%s: resetting idle vbo\n", __FUNCTION__)); 6842542f5fSchristos sna->render.vertex_used = 0; 6942542f5fSchristos sna->render.vertex_index = 0; 7042542f5fSchristos } 7142542f5fSchristos} 72