Path: blob/21.2-virgl/src/gallium/drivers/softpipe/sp_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#include "util/format/u_format.h"28#include "util/u_surface.h"29#include "sp_context.h"30#include "sp_surface.h"31#include "sp_query.h"3233static void sp_blit(struct pipe_context *pipe,34const struct pipe_blit_info *info)35{36struct softpipe_context *sp = softpipe_context(pipe);3738if (info->render_condition_enable && !softpipe_check_render_cond(sp))39return;4041if (info->src.resource->nr_samples > 1 &&42info->dst.resource->nr_samples <= 1 &&43!util_format_is_depth_or_stencil(info->src.resource->format) &&44!util_format_is_pure_integer(info->src.resource->format)) {45debug_printf("softpipe: color resolve unimplemented\n");46return;47}4849if (util_try_blit_via_copy_region(pipe, info)) {50return; /* done */51}5253if (!util_blitter_is_blit_supported(sp->blitter, info)) {54debug_printf("softpipe: blit unsupported %s -> %s\n",55util_format_short_name(info->src.resource->format),56util_format_short_name(info->dst.resource->format));57return;58}5960/* XXX turn off occlusion and streamout queries */6162util_blitter_save_vertex_buffer_slot(sp->blitter, sp->vertex_buffer);63util_blitter_save_vertex_elements(sp->blitter, sp->velems);64util_blitter_save_vertex_shader(sp->blitter, sp->vs);65util_blitter_save_geometry_shader(sp->blitter, sp->gs);66util_blitter_save_so_targets(sp->blitter, sp->num_so_targets,67(struct pipe_stream_output_target**)sp->so_targets);68util_blitter_save_rasterizer(sp->blitter, sp->rasterizer);69util_blitter_save_viewport(sp->blitter, &sp->viewports[0]);70util_blitter_save_scissor(sp->blitter, &sp->scissors[0]);71util_blitter_save_fragment_shader(sp->blitter, sp->fs);72util_blitter_save_blend(sp->blitter, sp->blend);73util_blitter_save_depth_stencil_alpha(sp->blitter, sp->depth_stencil);74util_blitter_save_stencil_ref(sp->blitter, &sp->stencil_ref);75/*util_blitter_save_sample_mask(sp->blitter, sp->sample_mask);*/76util_blitter_save_framebuffer(sp->blitter, &sp->framebuffer);77util_blitter_save_fragment_sampler_states(sp->blitter,78sp->num_samplers[PIPE_SHADER_FRAGMENT],79(void**)sp->samplers[PIPE_SHADER_FRAGMENT]);80util_blitter_save_fragment_sampler_views(sp->blitter,81sp->num_sampler_views[PIPE_SHADER_FRAGMENT],82sp->sampler_views[PIPE_SHADER_FRAGMENT]);83util_blitter_save_render_condition(sp->blitter, sp->render_cond_query,84sp->render_cond_cond, sp->render_cond_mode);85util_blitter_blit(sp->blitter, info);86}8788static void89sp_flush_resource(struct pipe_context *pipe,90struct pipe_resource *resource)91{92}9394static void95softpipe_clear_render_target(struct pipe_context *pipe,96struct pipe_surface *dst,97const union pipe_color_union *color,98unsigned dstx, unsigned dsty,99unsigned width, unsigned height,100bool render_condition_enabled)101{102struct softpipe_context *softpipe = softpipe_context(pipe);103104if (render_condition_enabled && !softpipe_check_render_cond(softpipe))105return;106107util_clear_render_target(pipe, dst, color,108dstx, dsty, width, height);109}110111112static void113softpipe_clear_depth_stencil(struct pipe_context *pipe,114struct pipe_surface *dst,115unsigned clear_flags,116double depth,117unsigned stencil,118unsigned dstx, unsigned dsty,119unsigned width, unsigned height,120bool render_condition_enabled)121{122struct softpipe_context *softpipe = softpipe_context(pipe);123124if (render_condition_enabled && !softpipe_check_render_cond(softpipe))125return;126127util_clear_depth_stencil(pipe, dst, clear_flags,128depth, stencil,129dstx, dsty, width, height);130}131132133void134sp_init_surface_functions(struct softpipe_context *sp)135{136sp->pipe.resource_copy_region = util_resource_copy_region;137sp->pipe.clear_render_target = softpipe_clear_render_target;138sp->pipe.clear_depth_stencil = softpipe_clear_depth_stencil;139sp->pipe.blit = sp_blit;140sp->pipe.flush_resource = sp_flush_resource;141}142143144