Path: blob/21.2-virgl/src/gallium/drivers/softpipe/sp_state_blend.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 "util/u_math.h"31#include "util/u_memory.h"32#include "draw/draw_context.h"33#include "sp_context.h"34#include "sp_state.h"353637static void *38softpipe_create_blend_state(struct pipe_context *pipe,39const struct pipe_blend_state *blend)40{41return mem_dup(blend, sizeof(*blend));42}434445static void46softpipe_bind_blend_state(struct pipe_context *pipe,47void *blend)48{49struct softpipe_context *softpipe = softpipe_context(pipe);5051draw_flush(softpipe->draw);5253softpipe->blend = (struct pipe_blend_state *)blend;5455softpipe->dirty |= SP_NEW_BLEND;56}575859static void60softpipe_delete_blend_state(struct pipe_context *pipe,61void *blend)62{63FREE( blend );64}656667static void68softpipe_set_blend_color(struct pipe_context *pipe,69const struct pipe_blend_color *blend_color)70{71struct softpipe_context *softpipe = softpipe_context(pipe);72unsigned i;7374draw_flush(softpipe->draw);7576softpipe->blend_color = *blend_color;7778/* save clamped color too */79for (i = 0; i < 4; i++)80softpipe->blend_color_clamped.color[i] =81SATURATE(blend_color->color[i]);8283softpipe->dirty |= SP_NEW_BLEND;84}858687static void *88softpipe_create_depth_stencil_state(struct pipe_context *pipe,89const struct pipe_depth_stencil_alpha_state *depth_stencil)90{91return mem_dup(depth_stencil, sizeof(*depth_stencil));92}939495static void96softpipe_bind_depth_stencil_state(struct pipe_context *pipe,97void *depth_stencil)98{99struct softpipe_context *softpipe = softpipe_context(pipe);100101softpipe->depth_stencil = (struct pipe_depth_stencil_alpha_state *)depth_stencil;102103softpipe->dirty |= SP_NEW_DEPTH_STENCIL_ALPHA;104}105106107static void108softpipe_delete_depth_stencil_state(struct pipe_context *pipe, void *depth)109{110FREE( depth );111}112113114static void115softpipe_set_stencil_ref(struct pipe_context *pipe,116const struct pipe_stencil_ref stencil_ref)117{118struct softpipe_context *softpipe = softpipe_context(pipe);119120softpipe->stencil_ref = stencil_ref;121122softpipe->dirty |= SP_NEW_DEPTH_STENCIL_ALPHA;123}124125126static void127softpipe_set_sample_mask(struct pipe_context *pipe,128unsigned sample_mask)129{130}131132133void134softpipe_init_blend_funcs(struct pipe_context *pipe)135{136pipe->create_blend_state = softpipe_create_blend_state;137pipe->bind_blend_state = softpipe_bind_blend_state;138pipe->delete_blend_state = softpipe_delete_blend_state;139140pipe->set_blend_color = softpipe_set_blend_color;141142pipe->create_depth_stencil_alpha_state = softpipe_create_depth_stencil_state;143pipe->bind_depth_stencil_alpha_state = softpipe_bind_depth_stencil_state;144pipe->delete_depth_stencil_alpha_state = softpipe_delete_depth_stencil_state;145146pipe->set_stencil_ref = softpipe_set_stencil_ref;147148pipe->set_sample_mask = softpipe_set_sample_mask;149}150151152