2 * Copyright (C) 2019 Collabora, Ltd.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * 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 THE
23 * Authors (Collabora):
24 * Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
31 #include "util/hash_table.h"
33 /* An internal blend shader descriptor, from the compiler */
35 struct panfrost_blend_shader
{
36 struct panfrost_context
*ctx
;
38 /* The compiled shader */
41 /* Byte count of the shader */
44 /* Number of 128-bit work registers required by the shader */
47 /* Offset into the shader to patch constants. Zero to disable patching
48 * (it is illogical to have constants at offset 0). */
51 /* First instruction tag (for tagging the pointer) */
55 /* A blend shader descriptor ready for actual use */
57 struct panfrost_blend_shader_final
{
58 /* GPU address where we're compiled to */
61 /* First instruction tag (for tagging the pointer) */
64 /* Same meaning as panfrost_blend_shader */
68 struct panfrost_blend_equation_final
{
69 struct mali_blend_equation
*equation
;
73 struct panfrost_blend_rt
{
74 /* If has_fixed_function is set, equation is the
75 * fixed-function configuration for this blend state */
77 bool has_fixed_function
;
78 struct mali_blend_equation equation
;
80 /* Mask of blend color components read */
81 unsigned constant_mask
;
83 /* Regardless of fixed-function blending, this is a map of pipe_format
84 * to panfrost_blend_shader */
86 struct hash_table_u64
*shaders
;
89 struct panfrost_blend_state
{
90 struct pipe_blend_state base
;
92 struct panfrost_blend_rt rt
[PIPE_MAX_COLOR_BUFS
];
95 /* Container for a final blend state, specialized to constants and a
96 * framebuffer formats. */
98 struct panfrost_blend_final
{
99 /* Set for a shader, clear for an equation */
102 /* Clear if the destination needs to be loaded from the tilebuffer */
105 /* Set if the colour mask is 0x0 (nothing is written) */
109 struct panfrost_blend_shader_final shader
;
110 struct panfrost_blend_equation_final equation
;
115 panfrost_blend_context_init(struct pipe_context
*pipe
);
117 struct panfrost_blend_final
118 panfrost_get_blend_for_context(struct panfrost_context
*ctx
, unsigned rt
, struct panfrost_bo
**bo
, unsigned *shader_offset
);
120 struct panfrost_blend_shader
*
121 panfrost_get_blend_shader(
122 struct panfrost_context
*ctx
,
123 struct panfrost_blend_state
*blend
,
124 enum pipe_format fmt
,