Path: blob/21.2-virgl/src/gallium/drivers/freedreno/a6xx/fd6_blend.h
4574 views
/*1* Copyright (C) 2016 Rob Clark <[email protected]>2* Copyright © 2018 Google, Inc.3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the "Software"),6* to deal in the Software without restriction, including without limitation7* the rights to use, copy, modify, merge, publish, distribute, sublicense,8* and/or sell copies of the Software, and to permit persons to whom the9* Software is furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice (including the next12* paragraph) shall be included in all copies or substantial portions of the13* Software.14*15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL18* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER19* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,20* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE21* SOFTWARE.22*23* Authors:24* Rob Clark <[email protected]>25*/2627#ifndef FD6_BLEND_H_28#define FD6_BLEND_H_2930#include "pipe/p_context.h"31#include "pipe/p_state.h"3233#include "freedreno_context.h"34#include "freedreno_util.h"3536/**37* Since the sample-mask is part of the hw blend state, we need to have state38* variants per sample-mask value. But we don't expect the sample-mask state39* to change frequently.40*/41struct fd6_blend_variant {42unsigned sample_mask;43struct fd_ringbuffer *stateobj;44};4546struct fd6_blend_stateobj {47struct pipe_blend_state base;4849bool use_dual_src_blend;5051struct fd_context *ctx;52bool reads_dest;53struct util_dynarray variants;54};5556static inline struct fd6_blend_stateobj *57fd6_blend_stateobj(struct pipe_blend_state *blend)58{59return (struct fd6_blend_stateobj *)blend;60}6162struct fd6_blend_variant *63__fd6_setup_blend_variant(struct fd6_blend_stateobj *blend,64unsigned sample_mask);6566static inline struct fd6_blend_variant *67fd6_blend_variant(struct pipe_blend_state *cso, unsigned nr_samples,68unsigned sample_mask)69{70struct fd6_blend_stateobj *blend = fd6_blend_stateobj(cso);71unsigned mask = BITFIELD_MASK(nr_samples);7273util_dynarray_foreach (&blend->variants, struct fd6_blend_variant *, vp) {74struct fd6_blend_variant *v = *vp;7576/* mask out sample-mask bits that we don't care about to avoid77* creating unnecessary variants78*/79if ((mask & v->sample_mask) == (mask & sample_mask)) {80return v;81}82}8384return __fd6_setup_blend_variant(blend, sample_mask);85}8687void *fd6_blend_state_create(struct pipe_context *pctx,88const struct pipe_blend_state *cso);89void fd6_blend_state_delete(struct pipe_context *, void *hwcso);9091#endif /* FD6_BLEND_H_ */929394