1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/********************************************************** 2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright 2008-2009 VMware, Inc. All rights reserved. 3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Permission is hereby granted, free of charge, to any person 5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * obtaining a copy of this software and associated documentation 6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * files (the "Software"), to deal in the Software without 7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * restriction, including without limitation the rights to use, copy, 8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * modify, merge, publish, distribute, sublicense, and/or sell copies 9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * of the Software, and to permit persons to whom the Software is 10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * furnished to do so, subject to the following conditions: 11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The above copyright notice and this permission notice shall be 13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * included in all copies or substantial portions of the Software. 14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * SOFTWARE. 23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org **********************************************************/ 25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "pipe/p_defines.h" 27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "util/u_string.h" 28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "svga_screen.h" 29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "svga_surface.h" 30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "svga_context.h" 31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "svga_debug.h" 32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void svga_flush( struct pipe_context *pipe, 35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct pipe_fence_handle **fence ) 36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct svga_context *svga = svga_context(pipe); 38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Emit buffered drawing commands, and any back copies. 40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org svga_surfaces_flush( svga ); 42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Flush command queue. 44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org svga_context_flush(svga, fence); 46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org SVGA_DBG(DEBUG_DMA|DEBUG_PERF, "%s fence_ptr %p\n", 48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org __FUNCTION__, fence ? *fence : 0x0); 49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Enable to dump BMPs of the color/depth buffers each frame */ 51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (0) { 52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct pipe_framebuffer_state *fb = &svga->curr.framebuffer; 53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org static unsigned frame_no = 1; 54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org char filename[256]; 55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned i; 56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org for (i = 0; i < fb->nr_cbufs; i++) { 58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org util_snprintf(filename, sizeof(filename), "cbuf%u_%04u", i, frame_no); 59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org debug_dump_surface_bmp(&svga->pipe, filename, fb->cbufs[i]); 60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (0 && fb->zsbuf) { 63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org util_snprintf(filename, sizeof(filename), "zsbuf_%04u", frame_no); 64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org debug_dump_surface_bmp(&svga->pipe, filename, fb->zsbuf); 65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ++frame_no; 68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid svga_init_flush_functions( struct svga_context *svga ) 73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org svga->pipe.flush = svga_flush; 75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 76