Path: blob/21.2-virgl/src/gallium/drivers/softpipe/sp_state_clip.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*/29#include "sp_context.h"30#include "sp_state.h"31#include "draw/draw_context.h"323334static void35softpipe_set_clip_state(struct pipe_context *pipe,36const struct pipe_clip_state *clip)37{38struct softpipe_context *softpipe = softpipe_context(pipe);3940/* pass the clip state to the draw module */41draw_set_clip_state(softpipe->draw, clip);42}434445static void46softpipe_set_viewport_states(struct pipe_context *pipe,47unsigned start_slot,48unsigned num_viewports,49const struct pipe_viewport_state *viewports)50{51struct softpipe_context *softpipe = softpipe_context(pipe);5253/* pass the viewport info to the draw module */54draw_set_viewport_states(softpipe->draw, start_slot, num_viewports,55viewports);5657memcpy(softpipe->viewports + start_slot, viewports,58sizeof(struct pipe_viewport_state) * num_viewports);59softpipe->dirty |= SP_NEW_VIEWPORT;60}616263static void64softpipe_set_scissor_states(struct pipe_context *pipe,65unsigned start_slot,66unsigned num_scissors,67const struct pipe_scissor_state *scissors)68{69struct softpipe_context *softpipe = softpipe_context(pipe);7071draw_flush(softpipe->draw);7273debug_assert(start_slot < PIPE_MAX_VIEWPORTS);74debug_assert((start_slot + num_scissors) <= PIPE_MAX_VIEWPORTS);7576memcpy(softpipe->scissors + start_slot, scissors,77sizeof(struct pipe_scissor_state) * num_scissors);78softpipe->dirty |= SP_NEW_SCISSOR;79}808182static void83softpipe_set_polygon_stipple(struct pipe_context *pipe,84const struct pipe_poly_stipple *stipple)85{86struct softpipe_context *softpipe = softpipe_context(pipe);8788draw_flush(softpipe->draw);8990softpipe->poly_stipple = *stipple; /* struct copy */91softpipe->dirty |= SP_NEW_STIPPLE;92}939495void96softpipe_init_clip_funcs(struct pipe_context *pipe)97{98pipe->set_clip_state = softpipe_set_clip_state;99pipe->set_viewport_states = softpipe_set_viewport_states;100pipe->set_scissor_states = softpipe_set_scissor_states;101pipe->set_polygon_stipple = softpipe_set_polygon_stipple;102}103104105