2 * Copyright (C) 2016 Rob Clark <robclark@freedesktop.org>
3 * Copyright © 2018 Google, Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * Rob Clark <robclark@freedesktop.org>
31 #include "pipe/p_state.h"
32 #include "pipe/p_context.h"
34 #include "freedreno_context.h"
35 #include "freedreno_util.h"
38 * Since the sample-mask is part of the hw blend state, we need to have state
39 * variants per sample-mask value. But we don't expect the sample-mask state
40 * to change frequently.
42 struct fd6_blend_variant
{
44 struct fd_ringbuffer
*stateobj
;
47 struct fd6_blend_stateobj
{
48 struct pipe_blend_state base
;
50 struct fd_context
*ctx
;
52 struct util_dynarray variants
;
55 static inline struct fd6_blend_stateobj
*
56 fd6_blend_stateobj(struct pipe_blend_state
*blend
)
58 return (struct fd6_blend_stateobj
*)blend
;
61 struct fd6_blend_variant
* __fd6_setup_blend_variant(
62 struct fd6_blend_stateobj
*blend
, unsigned sample_mask
);
64 static inline struct fd6_blend_variant
*
65 fd6_blend_variant(struct pipe_blend_state
*cso
,
66 unsigned nr_samples
, unsigned sample_mask
)
68 struct fd6_blend_stateobj
*blend
= fd6_blend_stateobj(cso
);
69 unsigned mask
= BITFIELD_MASK(nr_samples
);
71 util_dynarray_foreach(&blend
->variants
, struct fd6_blend_variant
*, vp
) {
72 struct fd6_blend_variant
*v
= *vp
;
74 /* mask out sample-mask bits that we don't care about to avoid
75 * creating unnecessary variants
77 if ((mask
& v
->sample_mask
) == (mask
& sample_mask
)) {
82 return __fd6_setup_blend_variant(blend
, sample_mask
);
85 void * fd6_blend_state_create(struct pipe_context
*pctx
,
86 const struct pipe_blend_state
*cso
);
87 void fd6_blend_state_delete(struct pipe_context
*, void *hwcso
);
89 #endif /* FD6_BLEND_H_ */