iris: Initial commit of a new 'iris' driver for Intel Gen8+ GPUs.
[mesa.git] / src / gallium / drivers / iris / iris_draw.c
1 /*
2 * Copyright © 2017 Intel Corporation
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 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the 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 NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23 #include <stdio.h>
24 #include <errno.h>
25 #include "pipe/p_defines.h"
26 #include "pipe/p_state.h"
27 #include "pipe/p_context.h"
28 #include "pipe/p_screen.h"
29 #include "util/u_inlines.h"
30 #include "util/u_transfer.h"
31 #include "intel/compiler/brw_compiler.h"
32 #include "iris_context.h"
33
34 #define __gen_address_type unsigned
35 #define __gen_user_data void
36
37 static uint64_t
38 __gen_combine_address(void *user_data, void *location,
39 unsigned address, uint32_t delta)
40 {
41 return delta;
42 }
43
44 #define __genxml_cmd_length(cmd) cmd ## _length
45 #define __genxml_cmd_length_bias(cmd) cmd ## _length_bias
46 #define __genxml_cmd_header(cmd) cmd ## _header
47 #define __genxml_cmd_pack(cmd) cmd ## _pack
48
49 #define iris_pack_command(cmd, dst, name) \
50 for (struct cmd name = { __genxml_cmd_header(cmd) }, \
51 *_dst = (void *)(dst); __builtin_expect(_dst != NULL, 1); \
52 __genxml_cmd_pack(cmd)(NULL, (void *)dst, &name), \
53 _dst = NULL)
54
55 #define iris_pack_state(cmd, dst, name) \
56 for (struct cmd name = {}, \
57 *_dst = (void *)(dst); __builtin_expect(_dst != NULL, 1); \
58 __genxml_cmd_pack(cmd)(NULL, (void *)_dst, &name), \
59 _dst = NULL)
60
61 #include "genxml/genX_pack.h"
62 #include "genxml/gen_macros.h"
63
64 static void
65 iris_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
66 {
67 #if 0
68 l3 configuration
69
70 3DSTATE_VIEWPORT_STATE_POINTERS_CC - CC_VIEWPORT
71 -> from iris_depth_stencil_alpha_state
72
73 3DSTATE_VIEWPORT_STATE_POINTERS_SF_CL - SF_CLIP_VIEWPORT
74 -> pipe_viewport_state for matrix elements, guardband is calculated
75 from those. can calculate screen space from matrix apparently...
76
77 3DSTATE_SCISSOR_STATE_POINTERS - SCISSOR_RECT
78 -> from ice->state.scissors
79
80 3DSTATE_PUSH_CONSTANT_ALLOC_*
81 3DSTATE_URB_*
82 -> TODO
83
84 3DSTATE_PS_BLEND
85 3DSTATE_BLEND_STATE_POINTERS - BLEND_STATE
86 -> from iris_blend_state (most) + iris_depth_stencil_alpha_state
87 (alpha test function/enable) + has writeable RT from ???????
88
89 3DSTATE_CC_STATE_POINTERS - COLOR_CALC_STATE
90 -> from ice->state.blend_color + iris_depth_stencil_alpha_state
91 (ref_value)
92
93 3DSTATE_CONSTANT_* - push constants
94 -> TODO
95
96 Surfaces:
97 - pull constants
98 - ubos/ssbos/abos
99 - images
100 - textures
101 - render targets - write and read
102 3DSTATE_BINDING_TABLE_POINTERS_*
103 -> TODO
104
105 3DSTATE_SAMPLER_STATE_POINTERS_*
106 -> TODO
107
108 3DSTATE_MULTISAMPLE
109 3DSTATE_SAMPLE_MASK
110
111 3DSTATE_VS
112 3DSTATE_HS
113 3DSTATE_TE
114 3DSTATE_DS
115 3DSTATE_GS
116 3DSTATE_PS_EXTRA
117 3DSTATE_PS
118 3DSTATE_STREAMOUT
119 3DSTATE_SO_BUFFER
120 3DSTATE_SO_DECL_LIST
121
122 3DSTATE_CLIP
123 -> iris_raster_state + ??? (Non-perspective Bary, ForceZeroRTAIndex)
124
125 3DSTATE_RASTER
126 3DSTATE_SF
127 -> iris_raster_state
128
129 3DSTATE_WM
130 -> iris_raster_state + FS state (barycentric, EDSC)
131 3DSTATE_SBE
132 -> iris_raster_state (point sprite texture coordinate origin)
133 -> bunch of shader state...
134 3DSTATE_SBE_SWIZ
135 -> FS state
136
137 3DSTATE_DEPTH_BUFFER
138 3DSTATE_HIER_DEPTH_BUFFER
139 3DSTATE_STENCIL_BUFFER
140 3DSTATE_CLEAR_PARAMS
141 -> iris_framebuffer_state?
142
143 3DSTATE_VF_TOPOLOGY
144 -> pipe_draw_info (prim_mode)
145 3DSTATE_VF
146 -> pipe_draw_info (restart_index, primitive_restart)
147
148 3DSTATE_INDEX_BUFFER
149 -> pipe_draw_info (index)
150 3DSTATE_VERTEX_BUFFERS
151 -> pipe_vertex_buffer (set_vertex_buffer hook)
152 3DSTATE_VERTEX_ELEMENTS
153 -> iris_vertex_element
154 3DSTATE_VF_INSTANCING
155 -> iris_vertex_element
156 3DSTATE_VF_SGVS
157 -> TODO ???
158 3DSTATE_VF_COMPONENT_PACKING
159 -> TODO ???
160
161 3DPRIMITIVE
162 -> pipe_draw_info
163
164 rare:
165 3DSTATE_POLY_STIPPLE_OFFSET
166 3DSTATE_POLY_STIPPLE_PATTERN
167 -> ice->state.poly_stipple
168 3DSTATE_LINE_STIPPLE
169 -> iris_raster_state
170
171 once:
172 3DSTATE_AA_LINE_PARAMETERS
173 3DSTATE_WM_CHROMAKEY
174 3DSTATE_SAMPLE_PATTERN
175 3DSTATE_DRAWING_RECTANGLE
176 3DSTATE_WM_HZ_OP
177 #endif
178 }