Path: blob/21.2-virgl/src/gallium/drivers/softpipe/sp_clear.c
4570 views
/**************************************************************************1*2* Copyright 2007 VMware, Inc.3* All Rights Reserved.4* Copyright 2009 VMware, Inc. All Rights Reserved.5*6* Permission is hereby granted, free of charge, to any person obtaining a7* copy of this software and associated documentation files (the8* "Software"), to deal in the Software without restriction, including9* without limitation the rights to use, copy, modify, merge, publish,10* distribute, sub license, and/or sell copies of the Software, and to11* permit persons to whom the Software is furnished to do so, subject to12* the following conditions:13*14* The above copyright notice and this permission notice (including the15* next paragraph) shall be included in all copies or substantial portions16* of the Software.17*18* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS19* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF20* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.21* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR22* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,23* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE24* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.25*26**************************************************************************/2728/* Author:29* Brian Paul30* Michel Dänzer31*/323334#include "pipe/p_defines.h"35#include "util/u_pack_color.h"36#include "util/u_surface.h"37#include "sp_clear.h"38#include "sp_context.h"39#include "sp_screen.h"40#include "sp_query.h"41#include "sp_tile_cache.h"424344/**45* Clear the given buffers to the specified values.46* No masking, no scissor (clear entire buffer).47*/48void49softpipe_clear(struct pipe_context *pipe, unsigned buffers,50const struct pipe_scissor_state *scissor_state,51const union pipe_color_union *color,52double depth, unsigned stencil)53{54struct softpipe_context *softpipe = softpipe_context(pipe);55struct pipe_surface *zsbuf = softpipe->framebuffer.zsbuf;56unsigned zs_buffers = buffers & PIPE_CLEAR_DEPTHSTENCIL;57uint64_t cv;58uint i;5960if (unlikely(sp_debug & SP_DBG_NO_RAST))61return;6263if (!softpipe_check_render_cond(softpipe))64return;6566#if 067softpipe_update_derived(softpipe, PIPE_PRIM_TRIANGLES); /* not needed?? */68#endif6970if (buffers & PIPE_CLEAR_COLOR) {71for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++) {72if (buffers & (PIPE_CLEAR_COLOR0 << i))73sp_tile_cache_clear(softpipe->cbuf_cache[i], color, 0);74}75}7677if (zs_buffers &&78util_format_is_depth_and_stencil(zsbuf->texture->format) &&79zs_buffers != PIPE_CLEAR_DEPTHSTENCIL) {80/* Clearing only depth or stencil in a combined depth-stencil buffer. */81util_clear_depth_stencil(pipe, zsbuf, zs_buffers, depth, stencil,820, 0, zsbuf->width, zsbuf->height);83}84else if (zs_buffers) {85static const union pipe_color_union zero;8687cv = util_pack64_z_stencil(zsbuf->format, depth, stencil);88sp_tile_cache_clear(softpipe->zsbuf_cache, &zero, cv);89}9091softpipe->dirty_render_cache = TRUE;92}939495