iris: Make an iris_genx_protos.h header for prototypes.
[mesa.git] / src / gallium / drivers / panfrost / pan_blend.h
1 /*
2 * Copyright (C) 2019 Collabora, Ltd.
3 *
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:
10 *
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
13 * Software.
14 *
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
21 * SOFTWARE.
22 *
23 * Authors (Collabora):
24 * Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
25 *
26 */
27
28 #ifndef __PAN_BLEND_H
29 #define __PAN_BLEND_H
30
31 #include "util/hash_table.h"
32
33 /* An internal blend shader descriptor, from the compiler */
34
35 struct panfrost_blend_shader {
36 /* The compiled shader in GPU memory */
37 struct panfrost_transfer shader;
38
39 /* Byte count of the shader */
40 unsigned size;
41
42 /* Number of 128-bit work registers required by the shader */
43 unsigned work_count;
44
45 /* Offset into the shader to patch constants. Zero to disable patching
46 * (it is illogical to have constants at offset 0). */
47 unsigned patch_index;
48
49 /* First instruction tag (for tagging the pointer) */
50 unsigned first_tag;
51 };
52
53 /* A blend shader descriptor ready for actual use */
54
55 struct panfrost_blend_shader_final {
56 /* The upload, possibly to transient memory */
57 mali_ptr gpu;
58
59 /* Same meaning as panfrost_blend_shader */
60 unsigned work_count;
61 };
62
63 struct panfrost_blend_equation_final {
64 struct mali_blend_equation *equation;
65 float constant;
66 };
67
68 struct panfrost_blend_rt {
69 /* If has_fixed_function is set, equation is the
70 * fixed-function configuration for this blend state */
71
72 bool has_fixed_function;
73 struct mali_blend_equation equation;
74
75 /* Mask of blend color components read */
76 unsigned constant_mask;
77
78 /* Regardless of fixed-function blending, this is a map of pipe_format
79 * to panfrost_blend_shader */
80
81 struct hash_table_u64 *shaders;
82 };
83
84 struct panfrost_blend_state {
85 struct pipe_blend_state base;
86
87 struct panfrost_blend_rt rt[PIPE_MAX_COLOR_BUFS];
88 };
89
90 /* Container for a final blend state, specialized to constants and a
91 * framebuffer formats. */
92
93 struct panfrost_blend_final {
94 /* Set for a shader, clear for an equation */
95 bool is_shader;
96
97 union {
98 struct panfrost_blend_shader_final shader;
99 struct panfrost_blend_equation_final equation;
100 };
101 };
102
103 void
104 panfrost_blend_context_init(struct pipe_context *pipe);
105
106 struct panfrost_blend_final
107 panfrost_get_blend_for_context(struct panfrost_context *ctx, unsigned rt);
108
109 #endif