Path: blob/21.2-virgl/src/gallium/drivers/softpipe/sp_state_surface.c
4570 views
/**************************************************************************1*2* Copyright 2007 VMware, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627/* Authors: Keith Whitwell <[email protected]>28*/2930#include "sp_context.h"31#include "sp_state.h"32#include "sp_tile_cache.h"3334#include "draw/draw_context.h"3536#include "util/format/u_format.h"37#include "util/u_inlines.h"383940/**41* XXX this might get moved someday42* Set the framebuffer surface info: color buffers, zbuffer, stencil buffer.43* Here, we flush the old surfaces and update the tile cache to point to the new44* surfaces.45*/46void47softpipe_set_framebuffer_state(struct pipe_context *pipe,48const struct pipe_framebuffer_state *fb)49{50struct softpipe_context *sp = softpipe_context(pipe);51uint i;5253draw_flush(sp->draw);5455for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {56struct pipe_surface *cb = i < fb->nr_cbufs ? fb->cbufs[i] : NULL;5758/* check if changing cbuf */59if (sp->framebuffer.cbufs[i] != cb) {60/* flush old */61sp_flush_tile_cache(sp->cbuf_cache[i]);6263/* assign new */64pipe_surface_reference(&sp->framebuffer.cbufs[i], cb);6566/* update cache */67sp_tile_cache_set_surface(sp->cbuf_cache[i], cb);68}69}7071sp->framebuffer.nr_cbufs = fb->nr_cbufs;7273/* zbuf changing? */74if (sp->framebuffer.zsbuf != fb->zsbuf) {75/* flush old */76sp_flush_tile_cache(sp->zsbuf_cache);7778/* assign new */79pipe_surface_reference(&sp->framebuffer.zsbuf, fb->zsbuf);8081/* update cache */82sp_tile_cache_set_surface(sp->zsbuf_cache, fb->zsbuf);8384/* Tell draw module how deep the Z/depth buffer is85*86* If no depth buffer is bound, send the utility function the87* format for no bound depth (PIPE_FORMAT_NONE).88*/89draw_set_zs_format(sp->draw,90(sp->framebuffer.zsbuf) ?91sp->framebuffer.zsbuf->format : PIPE_FORMAT_NONE);92}9394sp->framebuffer.width = fb->width;95sp->framebuffer.height = fb->height;96sp->framebuffer.samples = fb->samples;97sp->framebuffer.layers = fb->layers;9899sp->dirty |= SP_NEW_FRAMEBUFFER | SP_NEW_TEXTURE;100}101102103