blob: 310093d779fd1e86688249978038b38142ebc66b [file] [log] [blame]
Chia-I Wub2755562014-08-20 13:38:52 +08001/*
2 * XGL
3 *
4 * Copyright (C) 2014 LunarG, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
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
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
Chia-I Wu44e42362014-09-02 08:32:09 +080023 *
24 * Authors:
25 * Chia-I Wu <olv@lunarg.com>
26 * Courtney Goeltzenleuchter <courtney@lunarg.com>
Chia-I Wub2755562014-08-20 13:38:52 +080027 */
28
Chia-I Wua4d1b392014-10-10 13:57:29 +080029#include <stdio.h> /* for printf */
Chia-I Wu9f039862014-08-20 15:39:56 +080030#include "genhw/genhw.h"
Chia-I Wub2755562014-08-20 13:38:52 +080031#include "dset.h"
Chia-I Wu7fae4e32014-08-21 11:39:44 +080032#include "img.h"
Chia-I Wub2755562014-08-20 13:38:52 +080033#include "mem.h"
Chia-I Wu018a3962014-08-21 10:37:52 +080034#include "pipeline.h"
Chia-I Wufc05a2e2014-10-07 00:34:13 +080035#include "sampler.h"
Chia-I Wu1f2fd292014-08-29 15:07:09 +080036#include "shader.h"
Chia-I Wub2755562014-08-20 13:38:52 +080037#include "state.h"
38#include "view.h"
39#include "cmd_priv.h"
40
Chia-I Wu59c097e2014-08-21 10:51:07 +080041static void gen6_3DPRIMITIVE(struct intel_cmd *cmd,
Chia-I Wu254db422014-08-21 11:54:29 +080042 int prim_type, bool indexed,
Chia-I Wu59c097e2014-08-21 10:51:07 +080043 uint32_t vertex_count,
44 uint32_t vertex_start,
45 uint32_t instance_count,
46 uint32_t instance_start,
47 uint32_t vertex_base)
48{
49 const uint8_t cmd_len = 6;
Chia-I Wu72292b72014-09-09 10:48:33 +080050 uint32_t dw0, *dw;
Chia-I Wu59c097e2014-08-21 10:51:07 +080051
52 CMD_ASSERT(cmd, 6, 6);
53
Chia-I Wu426072d2014-08-26 14:31:55 +080054 dw0 = GEN6_RENDER_CMD(3D, 3DPRIMITIVE) |
Chia-I Wu254db422014-08-21 11:54:29 +080055 prim_type << GEN6_3DPRIM_DW0_TYPE__SHIFT |
Chia-I Wu59c097e2014-08-21 10:51:07 +080056 (cmd_len - 2);
57
58 if (indexed)
59 dw0 |= GEN6_3DPRIM_DW0_ACCESS_RANDOM;
60
Chia-I Wu72292b72014-09-09 10:48:33 +080061 cmd_batch_pointer(cmd, cmd_len, &dw);
62 dw[0] = dw0;
63 dw[1] = vertex_count;
64 dw[2] = vertex_start;
65 dw[3] = instance_count;
66 dw[4] = instance_start;
67 dw[5] = vertex_base;
Chia-I Wu59c097e2014-08-21 10:51:07 +080068}
69
70static void gen7_3DPRIMITIVE(struct intel_cmd *cmd,
Chia-I Wu254db422014-08-21 11:54:29 +080071 int prim_type, bool indexed,
Chia-I Wu59c097e2014-08-21 10:51:07 +080072 uint32_t vertex_count,
73 uint32_t vertex_start,
74 uint32_t instance_count,
75 uint32_t instance_start,
76 uint32_t vertex_base)
77{
78 const uint8_t cmd_len = 7;
Chia-I Wu72292b72014-09-09 10:48:33 +080079 uint32_t dw0, dw1, *dw;
Chia-I Wu59c097e2014-08-21 10:51:07 +080080
81 CMD_ASSERT(cmd, 7, 7.5);
82
Chia-I Wu426072d2014-08-26 14:31:55 +080083 dw0 = GEN6_RENDER_CMD(3D, 3DPRIMITIVE) | (cmd_len - 2);
Chia-I Wu254db422014-08-21 11:54:29 +080084 dw1 = prim_type << GEN7_3DPRIM_DW1_TYPE__SHIFT;
Chia-I Wu59c097e2014-08-21 10:51:07 +080085
86 if (indexed)
87 dw1 |= GEN7_3DPRIM_DW1_ACCESS_RANDOM;
88
Chia-I Wu72292b72014-09-09 10:48:33 +080089 cmd_batch_pointer(cmd, cmd_len, &dw);
90 dw[0] = dw0;
91 dw[1] = dw1;
92 dw[2] = vertex_count;
93 dw[3] = vertex_start;
94 dw[4] = instance_count;
95 dw[5] = instance_start;
96 dw[6] = vertex_base;
Chia-I Wu59c097e2014-08-21 10:51:07 +080097}
98
Chia-I Wu270b1e82014-08-25 15:53:39 +080099static void gen6_PIPE_CONTROL(struct intel_cmd *cmd, uint32_t dw1,
Chia-I Wud6d079d2014-08-31 13:14:21 +0800100 struct intel_bo *bo, uint32_t bo_offset,
101 uint64_t imm)
Chia-I Wu270b1e82014-08-25 15:53:39 +0800102{
103 const uint8_t cmd_len = 5;
Chia-I Wu426072d2014-08-26 14:31:55 +0800104 const uint32_t dw0 = GEN6_RENDER_CMD(3D, PIPE_CONTROL) |
Chia-I Wu270b1e82014-08-25 15:53:39 +0800105 (cmd_len - 2);
Chia-I Wu2caf7492014-08-31 12:28:38 +0800106 uint32_t reloc_flags = INTEL_RELOC_WRITE;
Chia-I Wu72292b72014-09-09 10:48:33 +0800107 uint32_t *dw;
108 XGL_UINT pos;
Chia-I Wu270b1e82014-08-25 15:53:39 +0800109
110 CMD_ASSERT(cmd, 6, 7.5);
111
112 assert(bo_offset % 8 == 0);
113
114 if (dw1 & GEN6_PIPE_CONTROL_CS_STALL) {
115 /*
116 * From the Sandy Bridge PRM, volume 2 part 1, page 73:
117 *
118 * "1 of the following must also be set (when CS stall is set):
119 *
120 * * Depth Cache Flush Enable ([0] of DW1)
121 * * Stall at Pixel Scoreboard ([1] of DW1)
122 * * Depth Stall ([13] of DW1)
123 * * Post-Sync Operation ([13] of DW1)
124 * * Render Target Cache Flush Enable ([12] of DW1)
125 * * Notify Enable ([8] of DW1)"
126 *
127 * From the Ivy Bridge PRM, volume 2 part 1, page 61:
128 *
129 * "One of the following must also be set (when CS stall is set):
130 *
131 * * Render Target Cache Flush Enable ([12] of DW1)
132 * * Depth Cache Flush Enable ([0] of DW1)
133 * * Stall at Pixel Scoreboard ([1] of DW1)
134 * * Depth Stall ([13] of DW1)
135 * * Post-Sync Operation ([13] of DW1)"
136 */
137 uint32_t bit_test = GEN6_PIPE_CONTROL_RENDER_CACHE_FLUSH |
138 GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH |
139 GEN6_PIPE_CONTROL_PIXEL_SCOREBOARD_STALL |
140 GEN6_PIPE_CONTROL_DEPTH_STALL;
141
142 /* post-sync op */
143 bit_test |= GEN6_PIPE_CONTROL_WRITE_IMM |
144 GEN6_PIPE_CONTROL_WRITE_PS_DEPTH_COUNT |
145 GEN6_PIPE_CONTROL_WRITE_TIMESTAMP;
146
147 if (cmd_gen(cmd) == INTEL_GEN(6))
148 bit_test |= GEN6_PIPE_CONTROL_NOTIFY_ENABLE;
149
150 assert(dw1 & bit_test);
151 }
152
153 if (dw1 & GEN6_PIPE_CONTROL_DEPTH_STALL) {
154 /*
155 * From the Sandy Bridge PRM, volume 2 part 1, page 73:
156 *
157 * "Following bits must be clear (when Depth Stall is set):
158 *
159 * * Render Target Cache Flush Enable ([12] of DW1)
160 * * Depth Cache Flush Enable ([0] of DW1)"
161 */
162 assert(!(dw1 & (GEN6_PIPE_CONTROL_RENDER_CACHE_FLUSH |
163 GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH)));
164 }
165
166 /*
167 * From the Sandy Bridge PRM, volume 1 part 3, page 19:
168 *
169 * "[DevSNB] PPGTT memory writes by MI_* (such as MI_STORE_DATA_IMM)
170 * and PIPE_CONTROL are not supported."
171 *
172 * The kernel will add the mapping automatically (when write domain is
173 * INTEL_DOMAIN_INSTRUCTION).
174 */
Chia-I Wu2caf7492014-08-31 12:28:38 +0800175 if (cmd_gen(cmd) == INTEL_GEN(6) && bo) {
Chia-I Wu270b1e82014-08-25 15:53:39 +0800176 bo_offset |= GEN6_PIPE_CONTROL_DW2_USE_GGTT;
Chia-I Wu2caf7492014-08-31 12:28:38 +0800177 reloc_flags |= INTEL_RELOC_GGTT;
178 }
Chia-I Wu270b1e82014-08-25 15:53:39 +0800179
Chia-I Wu72292b72014-09-09 10:48:33 +0800180 pos = cmd_batch_pointer(cmd, cmd_len, &dw);
181 dw[0] = dw0;
182 dw[1] = dw1;
183 dw[2] = 0;
184 dw[3] = (uint32_t) imm;
185 dw[4] = (uint32_t) (imm >> 32);
186
187 if (bo) {
188 cmd_reserve_reloc(cmd, 1);
189 cmd_batch_reloc(cmd, pos + 2, bo, bo_offset, reloc_flags);
190 }
Chia-I Wu270b1e82014-08-25 15:53:39 +0800191}
192
Chia-I Wu254db422014-08-21 11:54:29 +0800193static bool gen6_can_primitive_restart(const struct intel_cmd *cmd)
194{
195 const struct intel_pipeline *p = cmd->bind.pipeline.graphics;
196 bool supported;
197
198 CMD_ASSERT(cmd, 6, 7.5);
199
200 if (cmd_gen(cmd) >= INTEL_GEN(7.5))
201 return (p->prim_type != GEN6_3DPRIM_RECTLIST);
202
203 switch (p->prim_type) {
204 case GEN6_3DPRIM_POINTLIST:
205 case GEN6_3DPRIM_LINELIST:
206 case GEN6_3DPRIM_LINESTRIP:
207 case GEN6_3DPRIM_TRILIST:
208 case GEN6_3DPRIM_TRISTRIP:
209 supported = true;
210 break;
211 default:
212 supported = false;
213 break;
214 }
215
216 if (!supported)
217 return false;
218
219 switch (cmd->bind.index.type) {
220 case XGL_INDEX_8:
221 supported = (p->primitive_restart_index != 0xffu);
222 break;
223 case XGL_INDEX_16:
224 supported = (p->primitive_restart_index != 0xffffu);
225 break;
226 case XGL_INDEX_32:
227 supported = (p->primitive_restart_index != 0xffffffffu);
228 break;
229 default:
230 supported = false;
231 break;
232 }
233
234 return supported;
235}
236
Chia-I Wu59c097e2014-08-21 10:51:07 +0800237static void gen6_3DSTATE_INDEX_BUFFER(struct intel_cmd *cmd,
Chia-I Wu958d1b72014-08-21 11:28:11 +0800238 const struct intel_mem *mem,
Chia-I Wu59c097e2014-08-21 10:51:07 +0800239 XGL_GPU_SIZE offset,
240 XGL_INDEX_TYPE type,
241 bool enable_cut_index)
242{
243 const uint8_t cmd_len = 3;
Chia-I Wu72292b72014-09-09 10:48:33 +0800244 uint32_t dw0, end_offset, *dw;
Chia-I Wu59c097e2014-08-21 10:51:07 +0800245 unsigned offset_align;
Chia-I Wu72292b72014-09-09 10:48:33 +0800246 XGL_UINT pos;
Chia-I Wu59c097e2014-08-21 10:51:07 +0800247
248 CMD_ASSERT(cmd, 6, 7.5);
249
Chia-I Wu426072d2014-08-26 14:31:55 +0800250 dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_INDEX_BUFFER) | (cmd_len - 2);
Chia-I Wu59c097e2014-08-21 10:51:07 +0800251
252 /* the bit is moved to 3DSTATE_VF */
253 if (cmd_gen(cmd) >= INTEL_GEN(7.5))
254 assert(!enable_cut_index);
255 if (enable_cut_index)
256 dw0 |= GEN6_IB_DW0_CUT_INDEX_ENABLE;
257
258 switch (type) {
259 case XGL_INDEX_8:
260 dw0 |= GEN6_IB_DW0_FORMAT_BYTE;
261 offset_align = 1;
262 break;
263 case XGL_INDEX_16:
264 dw0 |= GEN6_IB_DW0_FORMAT_WORD;
265 offset_align = 2;
266 break;
267 case XGL_INDEX_32:
268 dw0 |= GEN6_IB_DW0_FORMAT_DWORD;
269 offset_align = 4;
270 break;
271 default:
272 cmd->result = XGL_ERROR_INVALID_VALUE;
273 return;
274 break;
275 }
276
277 if (offset % offset_align) {
278 cmd->result = XGL_ERROR_INVALID_VALUE;
279 return;
280 }
281
282 /* aligned and inclusive */
283 end_offset = mem->size - (mem->size % offset_align) - 1;
284
Chia-I Wu72292b72014-09-09 10:48:33 +0800285 pos = cmd_batch_pointer(cmd, cmd_len, &dw);
286 dw[0] = dw0;
287
288 cmd_reserve_reloc(cmd, 2);
289 cmd_batch_reloc(cmd, pos + 1, mem->bo, offset, 0);
290 cmd_batch_reloc(cmd, pos + 2, mem->bo, end_offset, 0);
Chia-I Wu59c097e2014-08-21 10:51:07 +0800291}
292
Chia-I Wu62a7f252014-08-29 11:31:16 +0800293static void gen75_3DSTATE_VF(struct intel_cmd *cmd,
294 bool enable_cut_index,
295 uint32_t cut_index)
Chia-I Wu254db422014-08-21 11:54:29 +0800296{
297 const uint8_t cmd_len = 2;
Chia-I Wu72292b72014-09-09 10:48:33 +0800298 uint32_t dw0, *dw;
Chia-I Wu254db422014-08-21 11:54:29 +0800299
300 CMD_ASSERT(cmd, 7.5, 7.5);
301
Chia-I Wu426072d2014-08-26 14:31:55 +0800302 dw0 = GEN75_RENDER_CMD(3D, 3DSTATE_VF) | (cmd_len - 2);
Chia-I Wu254db422014-08-21 11:54:29 +0800303 if (enable_cut_index)
304 dw0 |= GEN75_VF_DW0_CUT_INDEX_ENABLE;
305
Chia-I Wu72292b72014-09-09 10:48:33 +0800306 cmd_batch_pointer(cmd, cmd_len, &dw);
307 dw[0] = dw0;
308 dw[1] = cut_index;
Chia-I Wu254db422014-08-21 11:54:29 +0800309}
310
Courtney Goeltzenleuchter3d72e8c2014-08-29 16:27:47 -0600311
Chia-I Wud95aa2b2014-08-29 12:07:47 +0800312static void gen6_3DSTATE_GS(struct intel_cmd *cmd)
313{
314 const uint8_t cmd_len = 7;
315 const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_GS) | (cmd_len - 2);
Chia-I Wu72292b72014-09-09 10:48:33 +0800316 uint32_t *dw;
Chia-I Wud95aa2b2014-08-29 12:07:47 +0800317
318 CMD_ASSERT(cmd, 6, 6);
319
Chia-I Wu72292b72014-09-09 10:48:33 +0800320 cmd_batch_pointer(cmd, cmd_len, &dw);
321 dw[0] = dw0;
322 dw[1] = 0;
323 dw[2] = 0;
324 dw[3] = 0;
325 dw[4] = 1 << GEN6_GS_DW4_URB_READ_LEN__SHIFT;
326 dw[5] = GEN6_GS_DW5_STATISTICS;
327 dw[6] = 0;
Chia-I Wud95aa2b2014-08-29 12:07:47 +0800328}
329
Chia-I Wu62a7f252014-08-29 11:31:16 +0800330static void gen7_3DSTATE_GS(struct intel_cmd *cmd)
331{
332 const uint8_t cmd_len = 7;
333 const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_GS) | (cmd_len - 2);
Chia-I Wu72292b72014-09-09 10:48:33 +0800334 uint32_t *dw;
Chia-I Wu62a7f252014-08-29 11:31:16 +0800335
336 CMD_ASSERT(cmd, 7, 7.5);
337
Chia-I Wu72292b72014-09-09 10:48:33 +0800338 cmd_batch_pointer(cmd, cmd_len, &dw);
339 dw[0] = dw0;
340 dw[1] = 0;
341 dw[2] = 0;
342 dw[3] = 0;
343 dw[4] = 0;
344 dw[5] = GEN6_GS_DW5_STATISTICS;
345 dw[6] = 0;
Chia-I Wu62a7f252014-08-29 11:31:16 +0800346}
347
Chia-I Wud88e02d2014-08-25 10:56:13 +0800348static void gen6_3DSTATE_DRAWING_RECTANGLE(struct intel_cmd *cmd,
349 XGL_UINT width, XGL_UINT height)
350{
351 const uint8_t cmd_len = 4;
Chia-I Wu426072d2014-08-26 14:31:55 +0800352 const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_DRAWING_RECTANGLE) |
Chia-I Wud88e02d2014-08-25 10:56:13 +0800353 (cmd_len - 2);
Chia-I Wu72292b72014-09-09 10:48:33 +0800354 uint32_t *dw;
Chia-I Wud88e02d2014-08-25 10:56:13 +0800355
356 CMD_ASSERT(cmd, 6, 7.5);
357
Chia-I Wu72292b72014-09-09 10:48:33 +0800358 cmd_batch_pointer(cmd, cmd_len, &dw);
359 dw[0] = dw0;
360
Chia-I Wud88e02d2014-08-25 10:56:13 +0800361 if (width && height) {
Chia-I Wu72292b72014-09-09 10:48:33 +0800362 dw[1] = 0;
363 dw[2] = (height - 1) << 16 |
364 (width - 1);
Chia-I Wud88e02d2014-08-25 10:56:13 +0800365 } else {
Chia-I Wu72292b72014-09-09 10:48:33 +0800366 dw[1] = 1;
367 dw[2] = 0;
Chia-I Wud88e02d2014-08-25 10:56:13 +0800368 }
Chia-I Wu72292b72014-09-09 10:48:33 +0800369
370 dw[3] = 0;
Chia-I Wud88e02d2014-08-25 10:56:13 +0800371}
372
Chia-I Wu8016a172014-08-29 18:31:32 +0800373static void gen7_fill_3DSTATE_SF_body(const struct intel_cmd *cmd,
374 uint32_t body[6])
375{
376 const struct intel_pipeline *pipeline = cmd->bind.pipeline.graphics;
377 const struct intel_viewport_state *viewport = cmd->bind.state.viewport;
378 const struct intel_raster_state *raster = cmd->bind.state.raster;
379 const struct intel_msaa_state *msaa = cmd->bind.state.msaa;
380 uint32_t dw1, dw2, dw3;
381 int point_width;
382
383 CMD_ASSERT(cmd, 6, 7.5);
384
385 dw1 = GEN7_SF_DW1_STATISTICS |
386 GEN7_SF_DW1_DEPTH_OFFSET_SOLID |
387 GEN7_SF_DW1_DEPTH_OFFSET_WIREFRAME |
388 GEN7_SF_DW1_DEPTH_OFFSET_POINT |
389 GEN7_SF_DW1_VIEWPORT_ENABLE |
390 raster->cmd_sf_fill;
391
392 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
393 int format;
394
395 switch (pipeline->db_format.channelFormat) {
396 case XGL_CH_FMT_R16:
397 format = GEN6_ZFORMAT_D16_UNORM;
398 break;
399 case XGL_CH_FMT_R32:
400 case XGL_CH_FMT_R32G8:
401 format = GEN6_ZFORMAT_D32_FLOAT;
402 break;
403 default:
404 assert(!"unknown depth format");
405 format = 0;
406 break;
407 }
408
409 dw1 |= format << GEN7_SF_DW1_DEPTH_FORMAT__SHIFT;
410 }
411
412 dw2 = raster->cmd_sf_cull;
413
414 if (msaa->sample_count > 1) {
415 dw2 |= 128 << GEN7_SF_DW2_LINE_WIDTH__SHIFT |
416 GEN7_SF_DW2_MSRASTMODE_ON_PATTERN;
417 } else {
418 dw2 |= 0 << GEN7_SF_DW2_LINE_WIDTH__SHIFT |
419 GEN7_SF_DW2_MSRASTMODE_OFF_PIXEL;
420 }
421
422 if (viewport->scissor_enable)
423 dw2 |= GEN7_SF_DW2_SCISSOR_ENABLE;
424
425 /* in U8.3 */
426 point_width = (int) (pipeline->pointSize * 8.0f + 0.5f);
427 point_width = U_CLAMP(point_width, 1, 2047);
428
429 dw3 = pipeline->provoking_vertex_tri << GEN7_SF_DW3_TRI_PROVOKE__SHIFT |
430 pipeline->provoking_vertex_line << GEN7_SF_DW3_LINE_PROVOKE__SHIFT |
431 pipeline->provoking_vertex_trifan << GEN7_SF_DW3_TRIFAN_PROVOKE__SHIFT |
432 GEN7_SF_DW3_SUBPIXEL_8BITS |
433 GEN7_SF_DW3_USE_POINT_WIDTH |
434 point_width;
435
436 body[0] = dw1;
437 body[1] = dw2;
438 body[2] = dw3;
439 body[3] = raster->cmd_depth_offset_const;
440 body[4] = raster->cmd_depth_offset_scale;
441 body[5] = raster->cmd_depth_offset_clamp;
442}
443
444static void gen7_fill_3DSTATE_SBE_body(const struct intel_cmd *cmd,
445 uint32_t body[13])
446{
Chia-I Wuf2b6d722014-09-02 08:52:27 +0800447 const struct intel_pipeline_shader *vs = &cmd->bind.pipeline.graphics->vs;
448 const struct intel_pipeline_shader *fs = &cmd->bind.pipeline.graphics->fs;
Chia-I Wu8016a172014-08-29 18:31:32 +0800449 XGL_UINT attr_skip, attr_count;
450 XGL_UINT vue_offset, vue_len;
451 XGL_UINT i;
452 uint32_t dw1;
453
454 CMD_ASSERT(cmd, 6, 7.5);
455
456 /* VS outputs VUE header and position additionally */
GregFbcbe19a2014-11-07 11:01:01 -0700457 assert(vs->out_count >= fs->in_count + 2);
458 attr_skip = vs->out_count - fs->in_count;
Chia-I Wu8016a172014-08-29 18:31:32 +0800459 attr_count = vs->out_count - attr_skip;
Chia-I Wu8016a172014-08-29 18:31:32 +0800460 assert(fs->in_count <= 32);
461
GregFbcbe19a2014-11-07 11:01:01 -0700462 vue_offset = (attr_skip + 1) / 2;
Chia-I Wu8016a172014-08-29 18:31:32 +0800463 vue_len = (attr_count + 1) / 2;
464 if (!vue_len)
465 vue_len = 1;
466
467 dw1 = fs->in_count << GEN7_SBE_DW1_ATTR_COUNT__SHIFT |
468 vue_len << GEN7_SBE_DW1_URB_READ_LEN__SHIFT |
469 vue_offset << GEN7_SBE_DW1_URB_READ_OFFSET__SHIFT;
470
471 body[0] = dw1;
472
473 for (i = 0; i < 8; i++) {
474 uint16_t hi, lo;
475
476 /* no attr swizzles */
477 if (i * 2 + 1 < fs->in_count) {
478 hi = i * 2 + 1;
479 lo = i * 2;
480 } else if (i * 2 < fs->in_count) {
481 hi = 0;
482 lo = i * 2;
483 } else {
484 hi = 0;
485 lo = 0;
486 }
487
488 body[1 + i] = hi << GEN7_SBE_ATTR_HIGH__SHIFT | lo;
489 }
490
491 body[9] = 0; /* point sprite enables */
492 body[10] = 0; /* constant interpolation enables */
493 body[11] = 0; /* WrapShortest enables */
494 body[12] = 0;
495}
496
497static void gen6_3DSTATE_SF(struct intel_cmd *cmd)
498{
499 const uint8_t cmd_len = 20;
500 const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_SF) |
501 (cmd_len - 2);
502 uint32_t sf[6];
503 uint32_t sbe[13];
Chia-I Wu72292b72014-09-09 10:48:33 +0800504 uint32_t *dw;
Chia-I Wu8016a172014-08-29 18:31:32 +0800505
506 CMD_ASSERT(cmd, 6, 6);
507
508 gen7_fill_3DSTATE_SF_body(cmd, sf);
509 gen7_fill_3DSTATE_SBE_body(cmd, sbe);
510
Chia-I Wu72292b72014-09-09 10:48:33 +0800511 cmd_batch_pointer(cmd, cmd_len, &dw);
512 dw[0] = dw0;
513 dw[1] = sbe[0];
514 memcpy(&dw[2], sf, sizeof(sf));
515 memcpy(&dw[8], &sbe[1], sizeof(sbe) - sizeof(sbe[0]));
Chia-I Wu8016a172014-08-29 18:31:32 +0800516}
517
518static void gen7_3DSTATE_SF(struct intel_cmd *cmd)
519{
520 const uint8_t cmd_len = 7;
Chia-I Wu72292b72014-09-09 10:48:33 +0800521 uint32_t *dw;
Chia-I Wu8016a172014-08-29 18:31:32 +0800522
523 CMD_ASSERT(cmd, 7, 7.5);
524
Chia-I Wu72292b72014-09-09 10:48:33 +0800525 cmd_batch_pointer(cmd, cmd_len, &dw);
Chia-I Wu8016a172014-08-29 18:31:32 +0800526 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_SF) |
527 (cmd_len - 2);
528 gen7_fill_3DSTATE_SF_body(cmd, &dw[1]);
Chia-I Wu8016a172014-08-29 18:31:32 +0800529}
530
531static void gen7_3DSTATE_SBE(struct intel_cmd *cmd)
532{
533 const uint8_t cmd_len = 14;
Chia-I Wu72292b72014-09-09 10:48:33 +0800534 uint32_t *dw;
Chia-I Wu8016a172014-08-29 18:31:32 +0800535
536 CMD_ASSERT(cmd, 7, 7.5);
537
Chia-I Wu72292b72014-09-09 10:48:33 +0800538 cmd_batch_pointer(cmd, cmd_len, &dw);
Chia-I Wu8016a172014-08-29 18:31:32 +0800539 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_SBE) |
540 (cmd_len - 2);
541 gen7_fill_3DSTATE_SBE_body(cmd, &dw[1]);
Chia-I Wu8016a172014-08-29 18:31:32 +0800542}
543
Chia-I Wuc3f9c092014-08-30 14:29:29 +0800544static void gen6_3DSTATE_CLIP(struct intel_cmd *cmd)
545{
546 const uint8_t cmd_len = 4;
547 const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_CLIP) |
548 (cmd_len - 2);
549 const struct intel_pipeline *pipeline = cmd->bind.pipeline.graphics;
GregFfd4c1f92014-11-07 15:32:52 -0700550 const struct intel_pipeline_shader *vs = &pipeline->vs;
Chia-I Wuf2b6d722014-09-02 08:52:27 +0800551 const struct intel_pipeline_shader *fs = &pipeline->fs;
Chia-I Wuc3f9c092014-08-30 14:29:29 +0800552 const struct intel_viewport_state *viewport = cmd->bind.state.viewport;
553 const struct intel_raster_state *raster = cmd->bind.state.raster;
Chia-I Wu72292b72014-09-09 10:48:33 +0800554 uint32_t dw1, dw2, dw3, *dw;
Chia-I Wuc3f9c092014-08-30 14:29:29 +0800555
556 CMD_ASSERT(cmd, 6, 7.5);
557
558 dw1 = GEN6_CLIP_DW1_STATISTICS;
559 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
560 dw1 |= GEN7_CLIP_DW1_SUBPIXEL_8BITS |
561 GEN7_CLIP_DW1_EARLY_CULL_ENABLE |
562 raster->cmd_clip_cull;
563 }
564
565 dw2 = GEN6_CLIP_DW2_CLIP_ENABLE |
566 GEN6_CLIP_DW2_XY_TEST_ENABLE |
567 GEN6_CLIP_DW2_APIMODE_OGL |
GregFfd4c1f92014-11-07 15:32:52 -0700568 (vs->enable_user_clip ? 1 : 0) << GEN6_CLIP_DW2_UCP_CLIP_ENABLES__SHIFT |
Chia-I Wuc3f9c092014-08-30 14:29:29 +0800569 pipeline->provoking_vertex_tri << GEN6_CLIP_DW2_TRI_PROVOKE__SHIFT |
570 pipeline->provoking_vertex_line << GEN6_CLIP_DW2_LINE_PROVOKE__SHIFT |
571 pipeline->provoking_vertex_trifan << GEN6_CLIP_DW2_TRIFAN_PROVOKE__SHIFT;
572
573 if (pipeline->rasterizerDiscardEnable)
574 dw2 |= GEN6_CLIP_DW2_CLIPMODE_REJECT_ALL;
575 else
576 dw2 |= GEN6_CLIP_DW2_CLIPMODE_NORMAL;
577
578 if (pipeline->depthClipEnable)
579 dw2 |= GEN6_CLIP_DW2_Z_TEST_ENABLE;
580
581 if (fs->barycentric_interps & (GEN6_INTERP_NONPERSPECTIVE_PIXEL |
582 GEN6_INTERP_NONPERSPECTIVE_CENTROID |
583 GEN6_INTERP_NONPERSPECTIVE_SAMPLE))
584 dw2 |= GEN6_CLIP_DW2_NONPERSPECTIVE_BARYCENTRIC_ENABLE;
585
586 dw3 = 0x1 << GEN6_CLIP_DW3_MIN_POINT_WIDTH__SHIFT |
587 0x7ff << GEN6_CLIP_DW3_MAX_POINT_WIDTH__SHIFT |
588 (viewport->viewport_count - 1);
589
Chia-I Wu72292b72014-09-09 10:48:33 +0800590 cmd_batch_pointer(cmd, cmd_len, &dw);
591 dw[0] = dw0;
592 dw[1] = dw1;
593 dw[2] = dw2;
594 dw[3] = dw3;
Chia-I Wuc3f9c092014-08-30 14:29:29 +0800595}
596
Chia-I Wu1f2fd292014-08-29 15:07:09 +0800597static void gen6_3DSTATE_WM(struct intel_cmd *cmd)
598{
599 const int max_threads = (cmd->dev->gpu->gt == 2) ? 80 : 40;
600 const struct intel_pipeline *pipeline = cmd->bind.pipeline.graphics;
Chia-I Wuf2b6d722014-09-02 08:52:27 +0800601 const struct intel_pipeline_shader *fs = &pipeline->fs;
Chia-I Wu1f2fd292014-08-29 15:07:09 +0800602 const struct intel_msaa_state *msaa = cmd->bind.state.msaa;
603 const uint8_t cmd_len = 9;
Chia-I Wu72292b72014-09-09 10:48:33 +0800604 uint32_t dw0, dw2, dw4, dw5, dw6, *dw;
Chia-I Wu1f2fd292014-08-29 15:07:09 +0800605
606 CMD_ASSERT(cmd, 6, 6);
607
608 dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_WM) | (cmd_len - 2);
609
610 dw2 = (fs->sampler_count + 3) / 4 << GEN6_THREADDISP_SAMPLER_COUNT__SHIFT |
611 fs->surface_count << GEN6_THREADDISP_BINDING_TABLE_SIZE__SHIFT;
612
613 dw4 = GEN6_WM_DW4_STATISTICS |
614 fs->urb_grf_start << GEN6_WM_DW4_URB_GRF_START0__SHIFT |
615 0 << GEN6_WM_DW4_URB_GRF_START1__SHIFT |
616 0 << GEN6_WM_DW4_URB_GRF_START2__SHIFT;
617
618 dw5 = (max_threads - 1) << GEN6_WM_DW5_MAX_THREADS__SHIFT |
619 GEN6_WM_DW5_PS_ENABLE |
620 GEN6_WM_DW5_8_PIXEL_DISPATCH;
621
622 if (fs->uses & INTEL_SHADER_USE_KILL ||
623 pipeline->cb_state.alphaToCoverageEnable)
624 dw5 |= GEN6_WM_DW5_PS_KILL;
625
626 if (fs->uses & INTEL_SHADER_USE_COMPUTED_DEPTH)
627 dw5 |= GEN6_WM_DW5_PS_COMPUTE_DEPTH;
628 if (fs->uses & INTEL_SHADER_USE_DEPTH)
629 dw5 |= GEN6_WM_DW5_PS_USE_DEPTH;
630 if (fs->uses & INTEL_SHADER_USE_W)
631 dw5 |= GEN6_WM_DW5_PS_USE_W;
632
633 if (pipeline->cb_state.dualSourceBlendEnable)
634 dw5 |= GEN6_WM_DW5_DUAL_SOURCE_BLEND;
635
636 dw6 = fs->in_count << GEN6_WM_DW6_SF_ATTR_COUNT__SHIFT |
637 GEN6_WM_DW6_POSOFFSET_NONE |
638 GEN6_WM_DW6_ZW_INTERP_PIXEL |
639 fs->barycentric_interps << GEN6_WM_DW6_BARYCENTRIC_INTERP__SHIFT |
640 GEN6_WM_DW6_POINT_RASTRULE_UPPER_RIGHT;
641
642 if (msaa->sample_count > 1) {
643 dw6 |= GEN6_WM_DW6_MSRASTMODE_ON_PATTERN |
644 GEN6_WM_DW6_MSDISPMODE_PERPIXEL;
645 } else {
646 dw6 |= GEN6_WM_DW6_MSRASTMODE_OFF_PIXEL |
647 GEN6_WM_DW6_MSDISPMODE_PERSAMPLE;
648 }
649
Chia-I Wu72292b72014-09-09 10:48:33 +0800650 cmd_batch_pointer(cmd, cmd_len, &dw);
651 dw[0] = dw0;
Chia-I Wua57761b2014-10-14 14:27:44 +0800652 dw[1] = cmd->bind.pipeline.fs_offset;
Chia-I Wu72292b72014-09-09 10:48:33 +0800653 dw[2] = dw2;
654 dw[3] = 0; /* scratch */
655 dw[4] = dw4;
656 dw[5] = dw5;
657 dw[6] = dw6;
658 dw[7] = 0; /* kernel 1 */
659 dw[8] = 0; /* kernel 2 */
Chia-I Wu1f2fd292014-08-29 15:07:09 +0800660}
661
662static void gen7_3DSTATE_WM(struct intel_cmd *cmd)
663{
664 const struct intel_pipeline *pipeline = cmd->bind.pipeline.graphics;
Chia-I Wuf2b6d722014-09-02 08:52:27 +0800665 const struct intel_pipeline_shader *fs = &pipeline->fs;
Chia-I Wu1f2fd292014-08-29 15:07:09 +0800666 const struct intel_msaa_state *msaa = cmd->bind.state.msaa;
667 const uint8_t cmd_len = 3;
Chia-I Wu72292b72014-09-09 10:48:33 +0800668 uint32_t dw0, dw1, dw2, *dw;
Chia-I Wu1f2fd292014-08-29 15:07:09 +0800669
670 CMD_ASSERT(cmd, 7, 7.5);
671
672 dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_WM) | (cmd_len - 2);
673
674 dw1 = GEN7_WM_DW1_STATISTICS |
675 GEN7_WM_DW1_PS_ENABLE |
676 GEN7_WM_DW1_ZW_INTERP_PIXEL |
677 fs->barycentric_interps << GEN7_WM_DW1_BARYCENTRIC_INTERP__SHIFT |
678 GEN7_WM_DW1_POINT_RASTRULE_UPPER_RIGHT;
679
680 if (fs->uses & INTEL_SHADER_USE_KILL ||
681 pipeline->cb_state.alphaToCoverageEnable)
682 dw1 |= GEN7_WM_DW1_PS_KILL;
683
684 if (fs->uses & INTEL_SHADER_USE_COMPUTED_DEPTH)
685 dw1 |= GEN7_WM_DW1_PSCDEPTH_ON;
686 if (fs->uses & INTEL_SHADER_USE_DEPTH)
687 dw1 |= GEN7_WM_DW1_PS_USE_DEPTH;
688 if (fs->uses & INTEL_SHADER_USE_W)
689 dw1 |= GEN7_WM_DW1_PS_USE_W;
690
691 dw2 = 0;
692
693 if (msaa->sample_count > 1) {
694 dw1 |= GEN7_WM_DW1_MSRASTMODE_ON_PATTERN;
695 dw2 |= GEN7_WM_DW2_MSDISPMODE_PERPIXEL;
696 } else {
697 dw1 |= GEN7_WM_DW1_MSRASTMODE_OFF_PIXEL;
698 dw2 |= GEN7_WM_DW2_MSDISPMODE_PERSAMPLE;
699 }
700
Chia-I Wu72292b72014-09-09 10:48:33 +0800701 cmd_batch_pointer(cmd, cmd_len, &dw);
702 dw[0] = dw0;
703 dw[1] = dw1;
704 dw[2] = dw2;
Chia-I Wu1f2fd292014-08-29 15:07:09 +0800705}
706
707static void gen7_3DSTATE_PS(struct intel_cmd *cmd)
708{
709 const struct intel_pipeline *pipeline = cmd->bind.pipeline.graphics;
Chia-I Wuf2b6d722014-09-02 08:52:27 +0800710 const struct intel_pipeline_shader *fs = &pipeline->fs;
Chia-I Wu1f2fd292014-08-29 15:07:09 +0800711 const struct intel_msaa_state *msaa = cmd->bind.state.msaa;
712 const uint8_t cmd_len = 8;
Chia-I Wu72292b72014-09-09 10:48:33 +0800713 uint32_t dw0, dw2, dw4, dw5, *dw;
Chia-I Wu1f2fd292014-08-29 15:07:09 +0800714
715 CMD_ASSERT(cmd, 7, 7.5);
716
717 dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_PS) | (cmd_len - 2);
718
719 dw2 = (fs->sampler_count + 3) / 4 << GEN6_THREADDISP_SAMPLER_COUNT__SHIFT |
720 fs->surface_count << GEN6_THREADDISP_BINDING_TABLE_SIZE__SHIFT;
721
722 dw4 = GEN7_PS_DW4_POSOFFSET_NONE |
723 GEN7_PS_DW4_8_PIXEL_DISPATCH;
724
725 if (cmd_gen(cmd) >= INTEL_GEN(7.5)) {
726 const int max_threads =
727 (cmd->dev->gpu->gt == 3) ? 408 :
728 (cmd->dev->gpu->gt == 2) ? 204 : 102;
729 dw4 |= (max_threads - 1) << GEN75_PS_DW4_MAX_THREADS__SHIFT;
730 dw4 |= msaa->cmd[msaa->cmd_len - 1] << GEN75_PS_DW4_SAMPLE_MASK__SHIFT;
731 } else {
732 const int max_threads = (cmd->dev->gpu->gt == 2) ? 172 : 48;
733 dw4 |= (max_threads - 1) << GEN7_PS_DW4_MAX_THREADS__SHIFT;
734 }
735
Chia-I Wu1f2fd292014-08-29 15:07:09 +0800736 if (fs->in_count)
737 dw4 |= GEN7_PS_DW4_ATTR_ENABLE;
738
739 if (pipeline->cb_state.dualSourceBlendEnable)
740 dw4 |= GEN7_PS_DW4_DUAL_SOURCE_BLEND;
741
742 dw5 = fs->urb_grf_start << GEN7_PS_DW5_URB_GRF_START0__SHIFT |
743 0 << GEN7_PS_DW5_URB_GRF_START1__SHIFT |
744 0 << GEN7_PS_DW5_URB_GRF_START2__SHIFT;
745
Chia-I Wu72292b72014-09-09 10:48:33 +0800746 cmd_batch_pointer(cmd, cmd_len, &dw);
747 dw[0] = dw0;
Chia-I Wua57761b2014-10-14 14:27:44 +0800748 dw[1] = cmd->bind.pipeline.fs_offset;
Chia-I Wu72292b72014-09-09 10:48:33 +0800749 dw[2] = dw2;
750 dw[3] = 0; /* scratch */
751 dw[4] = dw4;
752 dw[5] = dw5;
753 dw[6] = 0; /* kernel 1 */
754 dw[7] = 0; /* kernel 2 */
Chia-I Wu1f2fd292014-08-29 15:07:09 +0800755}
756
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800757static void gen6_3DSTATE_DEPTH_BUFFER(struct intel_cmd *cmd,
758 const struct intel_ds_view *view)
759{
760 const uint8_t cmd_len = 7;
Chia-I Wu72292b72014-09-09 10:48:33 +0800761 uint32_t dw0, *dw;
762 XGL_UINT pos;
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800763
764 CMD_ASSERT(cmd, 6, 7.5);
765
766 dw0 = (cmd_gen(cmd) >= INTEL_GEN(7)) ?
Chia-I Wu426072d2014-08-26 14:31:55 +0800767 GEN7_RENDER_CMD(3D, 3DSTATE_DEPTH_BUFFER) :
768 GEN6_RENDER_CMD(3D, 3DSTATE_DEPTH_BUFFER);
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800769 dw0 |= (cmd_len - 2);
770
Chia-I Wu72292b72014-09-09 10:48:33 +0800771 pos = cmd_batch_pointer(cmd, cmd_len, &dw);
772 dw[0] = dw0;
773 dw[1] = view->cmd[0];
774 dw[2] = 0;
775 dw[3] = view->cmd[2];
776 dw[4] = view->cmd[3];
777 dw[5] = view->cmd[4];
778 dw[6] = view->cmd[5];
779
Courtney Goeltzenleuchtere316d972014-08-22 16:25:24 -0600780 if (view->img) {
Chia-I Wu72292b72014-09-09 10:48:33 +0800781 cmd_reserve_reloc(cmd, 1);
782 cmd_batch_reloc(cmd, pos + 2, view->img->obj.mem->bo,
783 view->cmd[1], INTEL_RELOC_WRITE);
Courtney Goeltzenleuchtere316d972014-08-22 16:25:24 -0600784 }
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800785}
786
787static void gen6_3DSTATE_STENCIL_BUFFER(struct intel_cmd *cmd,
788 const struct intel_ds_view *view)
789{
790 const uint8_t cmd_len = 3;
Chia-I Wu72292b72014-09-09 10:48:33 +0800791 uint32_t dw0, *dw;
792 XGL_UINT pos;
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800793
794 CMD_ASSERT(cmd, 6, 7.5);
795
796 dw0 = (cmd_gen(cmd) >= INTEL_GEN(7)) ?
Chia-I Wu426072d2014-08-26 14:31:55 +0800797 GEN7_RENDER_CMD(3D, 3DSTATE_STENCIL_BUFFER) :
798 GEN6_RENDER_CMD(3D, 3DSTATE_STENCIL_BUFFER);
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800799 dw0 |= (cmd_len - 2);
800
Chia-I Wu72292b72014-09-09 10:48:33 +0800801 pos = cmd_batch_pointer(cmd, cmd_len, &dw);
802 dw[0] = dw0;
803 dw[1] = view->cmd[6];
804 dw[2] = 0;
805
Courtney Goeltzenleuchtere316d972014-08-22 16:25:24 -0600806 if (view->img) {
Chia-I Wu72292b72014-09-09 10:48:33 +0800807 cmd_reserve_reloc(cmd, 1);
808 cmd_batch_reloc(cmd, pos + 2, view->img->obj.mem->bo,
809 view->cmd[7], INTEL_RELOC_WRITE);
Courtney Goeltzenleuchtere316d972014-08-22 16:25:24 -0600810 }
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800811}
812
813static void gen6_3DSTATE_HIER_DEPTH_BUFFER(struct intel_cmd *cmd,
814 const struct intel_ds_view *view)
815{
816 const uint8_t cmd_len = 3;
Chia-I Wu72292b72014-09-09 10:48:33 +0800817 uint32_t dw0, *dw;
818 XGL_UINT pos;
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800819
820 CMD_ASSERT(cmd, 6, 7.5);
821
822 dw0 = (cmd_gen(cmd) >= INTEL_GEN(7)) ?
Chia-I Wu426072d2014-08-26 14:31:55 +0800823 GEN7_RENDER_CMD(3D, 3DSTATE_HIER_DEPTH_BUFFER) :
824 GEN6_RENDER_CMD(3D, 3DSTATE_HIER_DEPTH_BUFFER);
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800825 dw0 |= (cmd_len - 2);
826
Chia-I Wu72292b72014-09-09 10:48:33 +0800827 pos = cmd_batch_pointer(cmd, cmd_len, &dw);
828 dw[0] = dw0;
829 dw[1] = view->cmd[8];
830 dw[2] = 0;
831
Courtney Goeltzenleuchtere316d972014-08-22 16:25:24 -0600832 if (view->img) {
Chia-I Wu72292b72014-09-09 10:48:33 +0800833 cmd_reserve_reloc(cmd, 1);
834 cmd_batch_reloc(cmd, pos + 2, view->img->obj.mem->bo,
835 view->cmd[9], INTEL_RELOC_WRITE);
Courtney Goeltzenleuchtere316d972014-08-22 16:25:24 -0600836 }
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800837}
838
Chia-I Wuf8231032014-08-25 10:44:45 +0800839static void gen6_3DSTATE_CLEAR_PARAMS(struct intel_cmd *cmd,
840 uint32_t clear_val)
841{
842 const uint8_t cmd_len = 2;
Chia-I Wu426072d2014-08-26 14:31:55 +0800843 const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_CLEAR_PARAMS) |
Chia-I Wuf8231032014-08-25 10:44:45 +0800844 GEN6_CLEAR_PARAMS_DW0_VALID |
845 (cmd_len - 2);
Chia-I Wu72292b72014-09-09 10:48:33 +0800846 uint32_t *dw;
Chia-I Wuf8231032014-08-25 10:44:45 +0800847
848 CMD_ASSERT(cmd, 6, 6);
849
Chia-I Wu72292b72014-09-09 10:48:33 +0800850 cmd_batch_pointer(cmd, cmd_len, &dw);
851 dw[0] = dw0;
852 dw[1] = clear_val;
Chia-I Wuf8231032014-08-25 10:44:45 +0800853}
854
855static void gen7_3DSTATE_CLEAR_PARAMS(struct intel_cmd *cmd,
856 uint32_t clear_val)
857{
858 const uint8_t cmd_len = 3;
Chia-I Wu426072d2014-08-26 14:31:55 +0800859 const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_CLEAR_PARAMS) |
Chia-I Wuf8231032014-08-25 10:44:45 +0800860 (cmd_len - 2);
Chia-I Wu72292b72014-09-09 10:48:33 +0800861 uint32_t *dw;
Chia-I Wuf8231032014-08-25 10:44:45 +0800862
863 CMD_ASSERT(cmd, 7, 7.5);
864
Chia-I Wu72292b72014-09-09 10:48:33 +0800865 cmd_batch_pointer(cmd, cmd_len, &dw);
866 dw[0] = dw0;
867 dw[1] = clear_val;
868 dw[2] = 1;
Chia-I Wuf8231032014-08-25 10:44:45 +0800869}
870
Chia-I Wu302742d2014-08-22 10:28:29 +0800871static void gen6_3DSTATE_CC_STATE_POINTERS(struct intel_cmd *cmd,
Chia-I Wu72292b72014-09-09 10:48:33 +0800872 uint32_t blend_offset,
873 uint32_t ds_offset,
874 uint32_t cc_offset)
Chia-I Wu302742d2014-08-22 10:28:29 +0800875{
876 const uint8_t cmd_len = 4;
Chia-I Wu72292b72014-09-09 10:48:33 +0800877 uint32_t dw0, *dw;
Chia-I Wu302742d2014-08-22 10:28:29 +0800878
879 CMD_ASSERT(cmd, 6, 6);
880
Chia-I Wu426072d2014-08-26 14:31:55 +0800881 dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_CC_STATE_POINTERS) |
Chia-I Wu302742d2014-08-22 10:28:29 +0800882 (cmd_len - 2);
883
Chia-I Wu72292b72014-09-09 10:48:33 +0800884 cmd_batch_pointer(cmd, cmd_len, &dw);
885 dw[0] = dw0;
886 dw[1] = blend_offset | 1;
887 dw[2] = ds_offset | 1;
888 dw[3] = cc_offset | 1;
Chia-I Wu302742d2014-08-22 10:28:29 +0800889}
890
Chia-I Wu1744cca2014-08-22 11:10:17 +0800891static void gen6_3DSTATE_VIEWPORT_STATE_POINTERS(struct intel_cmd *cmd,
Chia-I Wu72292b72014-09-09 10:48:33 +0800892 uint32_t clip_offset,
893 uint32_t sf_offset,
894 uint32_t cc_offset)
Chia-I Wu1744cca2014-08-22 11:10:17 +0800895{
896 const uint8_t cmd_len = 4;
Chia-I Wu72292b72014-09-09 10:48:33 +0800897 uint32_t dw0, *dw;
Chia-I Wu1744cca2014-08-22 11:10:17 +0800898
899 CMD_ASSERT(cmd, 6, 6);
900
Chia-I Wu426072d2014-08-26 14:31:55 +0800901 dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_VIEWPORT_STATE_POINTERS) |
Chia-I Wu1744cca2014-08-22 11:10:17 +0800902 GEN6_PTR_VP_DW0_CLIP_CHANGED |
903 GEN6_PTR_VP_DW0_SF_CHANGED |
904 GEN6_PTR_VP_DW0_CC_CHANGED |
905 (cmd_len - 2);
906
Chia-I Wu72292b72014-09-09 10:48:33 +0800907 cmd_batch_pointer(cmd, cmd_len, &dw);
908 dw[0] = dw0;
909 dw[1] = clip_offset;
910 dw[2] = sf_offset;
911 dw[3] = cc_offset;
Chia-I Wu1744cca2014-08-22 11:10:17 +0800912}
913
914static void gen6_3DSTATE_SCISSOR_STATE_POINTERS(struct intel_cmd *cmd,
Chia-I Wu72292b72014-09-09 10:48:33 +0800915 uint32_t scissor_offset)
Chia-I Wu1744cca2014-08-22 11:10:17 +0800916{
917 const uint8_t cmd_len = 2;
Chia-I Wu72292b72014-09-09 10:48:33 +0800918 uint32_t dw0, *dw;
Chia-I Wu1744cca2014-08-22 11:10:17 +0800919
920 CMD_ASSERT(cmd, 6, 6);
921
Chia-I Wu426072d2014-08-26 14:31:55 +0800922 dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_SCISSOR_STATE_POINTERS) |
Chia-I Wu1744cca2014-08-22 11:10:17 +0800923 (cmd_len - 2);
924
Chia-I Wu72292b72014-09-09 10:48:33 +0800925 cmd_batch_pointer(cmd, cmd_len, &dw);
926 dw[0] = dw0;
927 dw[1] = scissor_offset;
Chia-I Wu1744cca2014-08-22 11:10:17 +0800928}
929
Chia-I Wu42a56202014-08-23 16:47:48 +0800930static void gen6_3DSTATE_BINDING_TABLE_POINTERS(struct intel_cmd *cmd,
Chia-I Wu72292b72014-09-09 10:48:33 +0800931 uint32_t vs_offset,
932 uint32_t gs_offset,
933 uint32_t ps_offset)
Chia-I Wu42a56202014-08-23 16:47:48 +0800934{
935 const uint8_t cmd_len = 4;
Chia-I Wu72292b72014-09-09 10:48:33 +0800936 uint32_t dw0, *dw;
Chia-I Wu42a56202014-08-23 16:47:48 +0800937
938 CMD_ASSERT(cmd, 6, 6);
939
Chia-I Wu426072d2014-08-26 14:31:55 +0800940 dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_BINDING_TABLE_POINTERS) |
Chia-I Wu42a56202014-08-23 16:47:48 +0800941 GEN6_PTR_BINDING_TABLE_DW0_VS_CHANGED |
942 GEN6_PTR_BINDING_TABLE_DW0_GS_CHANGED |
943 GEN6_PTR_BINDING_TABLE_DW0_PS_CHANGED |
944 (cmd_len - 2);
945
Chia-I Wu72292b72014-09-09 10:48:33 +0800946 cmd_batch_pointer(cmd, cmd_len, &dw);
947 dw[0] = dw0;
948 dw[1] = vs_offset;
949 dw[2] = gs_offset;
950 dw[3] = ps_offset;
Chia-I Wu42a56202014-08-23 16:47:48 +0800951}
952
Chia-I Wu257e75e2014-08-29 14:06:35 +0800953static void gen6_3DSTATE_SAMPLER_STATE_POINTERS(struct intel_cmd *cmd,
Chia-I Wu72292b72014-09-09 10:48:33 +0800954 uint32_t vs_offset,
955 uint32_t gs_offset,
956 uint32_t ps_offset)
Chia-I Wu257e75e2014-08-29 14:06:35 +0800957{
958 const uint8_t cmd_len = 4;
Chia-I Wu72292b72014-09-09 10:48:33 +0800959 uint32_t dw0, *dw;
Chia-I Wu257e75e2014-08-29 14:06:35 +0800960
961 CMD_ASSERT(cmd, 6, 6);
962
963 dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_SAMPLER_STATE_POINTERS) |
964 GEN6_PTR_SAMPLER_DW0_VS_CHANGED |
965 GEN6_PTR_SAMPLER_DW0_GS_CHANGED |
966 GEN6_PTR_SAMPLER_DW0_PS_CHANGED |
967 (cmd_len - 2);
968
Chia-I Wu72292b72014-09-09 10:48:33 +0800969 cmd_batch_pointer(cmd, cmd_len, &dw);
970 dw[0] = dw0;
971 dw[1] = vs_offset;
972 dw[2] = gs_offset;
973 dw[3] = ps_offset;
Chia-I Wu257e75e2014-08-29 14:06:35 +0800974}
975
Chia-I Wu302742d2014-08-22 10:28:29 +0800976static void gen7_3dstate_pointer(struct intel_cmd *cmd,
Chia-I Wu72292b72014-09-09 10:48:33 +0800977 int subop, uint32_t offset)
Chia-I Wu302742d2014-08-22 10:28:29 +0800978{
979 const uint8_t cmd_len = 2;
980 const uint32_t dw0 = GEN6_RENDER_TYPE_RENDER |
981 GEN6_RENDER_SUBTYPE_3D |
982 subop | (cmd_len - 2);
Chia-I Wu72292b72014-09-09 10:48:33 +0800983 uint32_t *dw;
Chia-I Wu302742d2014-08-22 10:28:29 +0800984
Chia-I Wu72292b72014-09-09 10:48:33 +0800985 cmd_batch_pointer(cmd, cmd_len, &dw);
986 dw[0] = dw0;
987 dw[1] = offset;
Chia-I Wu302742d2014-08-22 10:28:29 +0800988}
989
Chia-I Wu72292b72014-09-09 10:48:33 +0800990static uint32_t gen6_BLEND_STATE(struct intel_cmd *cmd,
Chia-I Wu302742d2014-08-22 10:28:29 +0800991 const struct intel_blend_state *state)
992{
Chia-I Wu72292b72014-09-09 10:48:33 +0800993 const uint8_t cmd_align = GEN6_ALIGNMENT_BLEND_STATE * 4;
Chia-I Wu302742d2014-08-22 10:28:29 +0800994 const uint8_t cmd_len = XGL_MAX_COLOR_ATTACHMENTS * 2;
995
996 CMD_ASSERT(cmd, 6, 7.5);
997 STATIC_ASSERT(ARRAY_SIZE(state->cmd) >= cmd_len);
998
Chia-I Wu00b51a82014-09-09 12:07:37 +0800999 return cmd_state_write(cmd, INTEL_CMD_ITEM_BLEND,
1000 cmd_align, cmd_len, state->cmd);
Chia-I Wu302742d2014-08-22 10:28:29 +08001001}
1002
Chia-I Wu72292b72014-09-09 10:48:33 +08001003static uint32_t gen6_DEPTH_STENCIL_STATE(struct intel_cmd *cmd,
Chia-I Wu302742d2014-08-22 10:28:29 +08001004 const struct intel_ds_state *state)
1005{
Chia-I Wu72292b72014-09-09 10:48:33 +08001006 const uint8_t cmd_align = GEN6_ALIGNMENT_DEPTH_STENCIL_STATE * 4;
Chia-I Wu302742d2014-08-22 10:28:29 +08001007 const uint8_t cmd_len = 3;
1008
1009 CMD_ASSERT(cmd, 6, 7.5);
1010 STATIC_ASSERT(ARRAY_SIZE(state->cmd) >= cmd_len);
1011
Chia-I Wu00b51a82014-09-09 12:07:37 +08001012 return cmd_state_write(cmd, INTEL_CMD_ITEM_DEPTH_STENCIL,
1013 cmd_align, cmd_len, state->cmd);
Chia-I Wu302742d2014-08-22 10:28:29 +08001014}
1015
Chia-I Wu72292b72014-09-09 10:48:33 +08001016static uint32_t gen6_COLOR_CALC_STATE(struct intel_cmd *cmd,
Chia-I Wu302742d2014-08-22 10:28:29 +08001017 uint32_t stencil_ref,
1018 const uint32_t blend_color[4])
1019{
Chia-I Wu72292b72014-09-09 10:48:33 +08001020 const uint8_t cmd_align = GEN6_ALIGNMENT_COLOR_CALC_STATE * 4;
Chia-I Wu302742d2014-08-22 10:28:29 +08001021 const uint8_t cmd_len = 6;
Chia-I Wu72292b72014-09-09 10:48:33 +08001022 uint32_t offset, *dw;
Chia-I Wu302742d2014-08-22 10:28:29 +08001023
1024 CMD_ASSERT(cmd, 6, 7.5);
1025
Chia-I Wu00b51a82014-09-09 12:07:37 +08001026 offset = cmd_state_pointer(cmd, INTEL_CMD_ITEM_COLOR_CALC,
1027 cmd_align, cmd_len, &dw);
Chia-I Wu302742d2014-08-22 10:28:29 +08001028 dw[0] = stencil_ref;
1029 dw[1] = 0;
1030 dw[2] = blend_color[0];
1031 dw[3] = blend_color[1];
1032 dw[4] = blend_color[2];
1033 dw[5] = blend_color[3];
Chia-I Wu302742d2014-08-22 10:28:29 +08001034
Chia-I Wu72292b72014-09-09 10:48:33 +08001035 return offset;
Chia-I Wu302742d2014-08-22 10:28:29 +08001036}
1037
Chia-I Wu8370b402014-08-29 12:28:37 +08001038static void cmd_wa_gen6_pre_depth_stall_write(struct intel_cmd *cmd)
Chia-I Wu48c283d2014-08-25 23:13:46 +08001039{
Chia-I Wu8370b402014-08-29 12:28:37 +08001040 CMD_ASSERT(cmd, 6, 7.5);
1041
Chia-I Wu707a29e2014-08-27 12:51:47 +08001042 if (!cmd->bind.draw_count)
1043 return;
1044
Chia-I Wu8370b402014-08-29 12:28:37 +08001045 if (cmd->bind.wa_flags & INTEL_CMD_WA_GEN6_PRE_DEPTH_STALL_WRITE)
Chia-I Wu48c283d2014-08-25 23:13:46 +08001046 return;
1047
Chia-I Wu8370b402014-08-29 12:28:37 +08001048 cmd->bind.wa_flags |= INTEL_CMD_WA_GEN6_PRE_DEPTH_STALL_WRITE;
Chia-I Wu48c283d2014-08-25 23:13:46 +08001049
1050 /*
1051 * From the Sandy Bridge PRM, volume 2 part 1, page 60:
1052 *
1053 * "Pipe-control with CS-stall bit set must be sent BEFORE the
1054 * pipe-control with a post-sync op and no write-cache flushes."
1055 *
1056 * The workaround below necessitates this workaround.
1057 */
1058 gen6_PIPE_CONTROL(cmd,
1059 GEN6_PIPE_CONTROL_CS_STALL |
1060 GEN6_PIPE_CONTROL_PIXEL_SCOREBOARD_STALL,
Chia-I Wud6d079d2014-08-31 13:14:21 +08001061 NULL, 0, 0);
Chia-I Wu48c283d2014-08-25 23:13:46 +08001062
Chia-I Wud6d079d2014-08-31 13:14:21 +08001063 gen6_PIPE_CONTROL(cmd, GEN6_PIPE_CONTROL_WRITE_IMM,
1064 cmd->scratch_bo, 0, 0);
Chia-I Wu48c283d2014-08-25 23:13:46 +08001065}
1066
Chia-I Wu8370b402014-08-29 12:28:37 +08001067static void cmd_wa_gen6_pre_command_scoreboard_stall(struct intel_cmd *cmd)
Courtney Goeltzenleuchterf9e1a412014-08-27 13:59:36 -06001068{
Chia-I Wu48c283d2014-08-25 23:13:46 +08001069 CMD_ASSERT(cmd, 6, 7.5);
1070
Chia-I Wubb2d8ca2014-08-28 23:15:48 +08001071 if (!cmd->bind.draw_count)
1072 return;
1073
Chia-I Wud6d079d2014-08-31 13:14:21 +08001074 gen6_PIPE_CONTROL(cmd, GEN6_PIPE_CONTROL_PIXEL_SCOREBOARD_STALL,
1075 NULL, 0, 0);
Chia-I Wu8370b402014-08-29 12:28:37 +08001076}
Chia-I Wubb2d8ca2014-08-28 23:15:48 +08001077
Chia-I Wu8370b402014-08-29 12:28:37 +08001078static void cmd_wa_gen7_pre_vs_depth_stall_write(struct intel_cmd *cmd)
1079{
Chia-I Wubb2d8ca2014-08-28 23:15:48 +08001080 CMD_ASSERT(cmd, 7, 7.5);
1081
Chia-I Wu8370b402014-08-29 12:28:37 +08001082 if (!cmd->bind.draw_count)
1083 return;
1084
1085 cmd_wa_gen6_pre_depth_stall_write(cmd);
Chia-I Wubb2d8ca2014-08-28 23:15:48 +08001086
1087 gen6_PIPE_CONTROL(cmd,
1088 GEN6_PIPE_CONTROL_DEPTH_STALL | GEN6_PIPE_CONTROL_WRITE_IMM,
Chia-I Wud6d079d2014-08-31 13:14:21 +08001089 cmd->scratch_bo, 0, 0);
Chia-I Wubb2d8ca2014-08-28 23:15:48 +08001090}
1091
Chia-I Wu8370b402014-08-29 12:28:37 +08001092static void cmd_wa_gen7_post_command_cs_stall(struct intel_cmd *cmd)
1093{
1094 CMD_ASSERT(cmd, 7, 7.5);
1095
1096 if (!cmd->bind.draw_count)
1097 return;
1098
1099 /*
1100 * From the Ivy Bridge PRM, volume 2 part 1, page 61:
1101 *
1102 * "One of the following must also be set (when CS stall is set):
1103 *
1104 * * Render Target Cache Flush Enable ([12] of DW1)
1105 * * Depth Cache Flush Enable ([0] of DW1)
1106 * * Stall at Pixel Scoreboard ([1] of DW1)
1107 * * Depth Stall ([13] of DW1)
1108 * * Post-Sync Operation ([13] of DW1)"
1109 */
1110 gen6_PIPE_CONTROL(cmd,
1111 GEN6_PIPE_CONTROL_CS_STALL |
1112 GEN6_PIPE_CONTROL_PIXEL_SCOREBOARD_STALL,
Chia-I Wud6d079d2014-08-31 13:14:21 +08001113 NULL, 0, 0);
Chia-I Wu8370b402014-08-29 12:28:37 +08001114}
1115
1116static void cmd_wa_gen7_post_command_depth_stall(struct intel_cmd *cmd)
1117{
1118 CMD_ASSERT(cmd, 7, 7.5);
1119
1120 if (!cmd->bind.draw_count)
1121 return;
1122
1123 cmd_wa_gen6_pre_depth_stall_write(cmd);
1124
Chia-I Wud6d079d2014-08-31 13:14:21 +08001125 gen6_PIPE_CONTROL(cmd, GEN6_PIPE_CONTROL_DEPTH_STALL, NULL, 0, 0);
Chia-I Wu8370b402014-08-29 12:28:37 +08001126}
1127
1128static void cmd_wa_gen6_pre_multisample_depth_flush(struct intel_cmd *cmd)
1129{
1130 CMD_ASSERT(cmd, 6, 7.5);
1131
1132 if (!cmd->bind.draw_count)
1133 return;
1134
1135 /*
1136 * From the Sandy Bridge PRM, volume 2 part 1, page 305:
1137 *
1138 * "Driver must guarentee that all the caches in the depth pipe are
1139 * flushed before this command (3DSTATE_MULTISAMPLE) is parsed. This
1140 * requires driver to send a PIPE_CONTROL with a CS stall along with
1141 * a Depth Flush prior to this command."
1142 *
1143 * From the Ivy Bridge PRM, volume 2 part 1, page 304:
1144 *
1145 * "Driver must ierarchi that all the caches in the depth pipe are
1146 * flushed before this command (3DSTATE_MULTISAMPLE) is parsed. This
1147 * requires driver to send a PIPE_CONTROL with a CS stall along with
1148 * a Depth Flush prior to this command.
1149 */
1150 gen6_PIPE_CONTROL(cmd,
1151 GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH |
1152 GEN6_PIPE_CONTROL_CS_STALL,
Chia-I Wud6d079d2014-08-31 13:14:21 +08001153 NULL, 0, 0);
Chia-I Wu8370b402014-08-29 12:28:37 +08001154}
1155
1156static void cmd_wa_gen6_pre_ds_flush(struct intel_cmd *cmd)
1157{
1158 CMD_ASSERT(cmd, 6, 7.5);
1159
1160 if (!cmd->bind.draw_count)
1161 return;
1162
1163 /*
1164 * From the Ivy Bridge PRM, volume 2 part 1, page 315:
1165 *
1166 * "Driver must send a least one PIPE_CONTROL command with CS Stall
1167 * and a post sync operation prior to the group of depth
1168 * commands(3DSTATE_DEPTH_BUFFER, 3DSTATE_CLEAR_PARAMS,
1169 * 3DSTATE_STENCIL_BUFFER, and 3DSTATE_HIER_DEPTH_BUFFER)."
1170 *
1171 * This workaround satifies all the conditions.
1172 */
1173 cmd_wa_gen6_pre_depth_stall_write(cmd);
1174
1175 /*
1176 * From the Ivy Bridge PRM, volume 2 part 1, page 315:
1177 *
1178 * "Restriction: Prior to changing Depth/Stencil Buffer state (i.e.,
1179 * any combination of 3DSTATE_DEPTH_BUFFER, 3DSTATE_CLEAR_PARAMS,
1180 * 3DSTATE_STENCIL_BUFFER, 3DSTATE_HIER_DEPTH_BUFFER) SW must first
1181 * issue a pipelined depth stall (PIPE_CONTROL with Depth Stall bit
1182 * set), followed by a pipelined depth cache flush (PIPE_CONTROL with
1183 * Depth Flush Bit set, followed by another pipelined depth stall
1184 * (PIPE_CONTROL with Depth Stall Bit set), unless SW can otherwise
1185 * guarantee that the pipeline from WM onwards is already flushed
1186 * (e.g., via a preceding MI_FLUSH)."
1187 */
Chia-I Wud6d079d2014-08-31 13:14:21 +08001188 gen6_PIPE_CONTROL(cmd, GEN6_PIPE_CONTROL_DEPTH_STALL, NULL, 0, 0);
1189 gen6_PIPE_CONTROL(cmd, GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH, NULL, 0, 0);
1190 gen6_PIPE_CONTROL(cmd, GEN6_PIPE_CONTROL_DEPTH_STALL, NULL, 0, 0);
Chia-I Wu8370b402014-08-29 12:28:37 +08001191}
1192
Chia-I Wu525c6602014-08-27 10:22:34 +08001193void cmd_batch_flush(struct intel_cmd *cmd, uint32_t pipe_control_dw0)
1194{
1195 if (!cmd->bind.draw_count)
1196 return;
1197
1198 assert(!(pipe_control_dw0 & GEN6_PIPE_CONTROL_WRITE__MASK));
1199
Chia-I Wu8370b402014-08-29 12:28:37 +08001200 /*
1201 * From the Sandy Bridge PRM, volume 2 part 1, page 60:
1202 *
1203 * "Before a PIPE_CONTROL with Write Cache Flush Enable =1, a
1204 * PIPE_CONTROL with any non-zero post-sync-op is required."
1205 */
Chia-I Wu525c6602014-08-27 10:22:34 +08001206 if (pipe_control_dw0 & GEN6_PIPE_CONTROL_RENDER_CACHE_FLUSH)
Chia-I Wu8370b402014-08-29 12:28:37 +08001207 cmd_wa_gen6_pre_depth_stall_write(cmd);
Chia-I Wu525c6602014-08-27 10:22:34 +08001208
Chia-I Wu092279a2014-08-30 19:05:30 +08001209 /*
1210 * From the Ivy Bridge PRM, volume 2 part 1, page 61:
1211 *
1212 * "One of the following must also be set (when CS stall is set):
1213 *
1214 * * Render Target Cache Flush Enable ([12] of DW1)
1215 * * Depth Cache Flush Enable ([0] of DW1)
1216 * * Stall at Pixel Scoreboard ([1] of DW1)
1217 * * Depth Stall ([13] of DW1)
1218 * * Post-Sync Operation ([13] of DW1)"
1219 */
1220 if ((pipe_control_dw0 & GEN6_PIPE_CONTROL_CS_STALL) &&
1221 !(pipe_control_dw0 & (GEN6_PIPE_CONTROL_RENDER_CACHE_FLUSH |
1222 GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH |
1223 GEN6_PIPE_CONTROL_PIXEL_SCOREBOARD_STALL |
1224 GEN6_PIPE_CONTROL_DEPTH_STALL)))
1225 pipe_control_dw0 |= GEN6_PIPE_CONTROL_PIXEL_SCOREBOARD_STALL;
1226
Chia-I Wud6d079d2014-08-31 13:14:21 +08001227 gen6_PIPE_CONTROL(cmd, pipe_control_dw0, NULL, 0, 0);
Chia-I Wu525c6602014-08-27 10:22:34 +08001228}
1229
Chia-I Wu3fb47ce2014-10-28 11:19:36 +08001230void cmd_batch_flush_all(struct intel_cmd *cmd)
1231{
1232 cmd_batch_flush(cmd, GEN6_PIPE_CONTROL_INSTRUCTION_CACHE_INVALIDATE |
1233 GEN6_PIPE_CONTROL_RENDER_CACHE_FLUSH |
1234 GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH |
1235 GEN6_PIPE_CONTROL_VF_CACHE_INVALIDATE |
1236 GEN6_PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE |
1237 GEN6_PIPE_CONTROL_CS_STALL);
1238}
1239
Chia-I Wu759fa2e2014-08-30 18:44:47 +08001240void cmd_batch_depth_count(struct intel_cmd *cmd,
1241 struct intel_bo *bo,
1242 XGL_GPU_SIZE offset)
1243{
1244 cmd_wa_gen6_pre_depth_stall_write(cmd);
1245
1246 gen6_PIPE_CONTROL(cmd,
1247 GEN6_PIPE_CONTROL_DEPTH_STALL |
1248 GEN6_PIPE_CONTROL_WRITE_PS_DEPTH_COUNT,
Chia-I Wud6d079d2014-08-31 13:14:21 +08001249 bo, offset, 0);
Chia-I Wu759fa2e2014-08-30 18:44:47 +08001250}
1251
Chia-I Wue8dbd5d2014-08-31 13:15:58 +08001252void cmd_batch_timestamp(struct intel_cmd *cmd,
1253 struct intel_bo *bo,
1254 XGL_GPU_SIZE offset)
1255{
1256 /* need any WA or stall? */
1257 gen6_PIPE_CONTROL(cmd, GEN6_PIPE_CONTROL_WRITE_TIMESTAMP, bo, offset, 0);
1258}
1259
1260void cmd_batch_immediate(struct intel_cmd *cmd,
1261 struct intel_bo *bo,
1262 XGL_GPU_SIZE offset,
1263 uint64_t val)
1264{
1265 /* need any WA or stall? */
1266 gen6_PIPE_CONTROL(cmd, GEN6_PIPE_CONTROL_WRITE_IMM, bo, offset, val);
1267}
1268
Chia-I Wu302742d2014-08-22 10:28:29 +08001269static void gen6_cc_states(struct intel_cmd *cmd)
1270{
1271 const struct intel_blend_state *blend = cmd->bind.state.blend;
1272 const struct intel_ds_state *ds = cmd->bind.state.ds;
Chia-I Wu72292b72014-09-09 10:48:33 +08001273 uint32_t blend_offset, ds_offset, cc_offset;
Chia-I Wuce9f11f2014-08-22 10:38:51 +08001274 uint32_t stencil_ref;
1275 uint32_t blend_color[4];
Chia-I Wu302742d2014-08-22 10:28:29 +08001276
1277 CMD_ASSERT(cmd, 6, 6);
1278
Chia-I Wuce9f11f2014-08-22 10:38:51 +08001279 if (blend) {
Chia-I Wu72292b72014-09-09 10:48:33 +08001280 blend_offset = gen6_BLEND_STATE(cmd, blend);
Chia-I Wuce9f11f2014-08-22 10:38:51 +08001281 memcpy(blend_color, blend->cmd_blend_color, sizeof(blend_color));
1282 } else {
Chia-I Wu72292b72014-09-09 10:48:33 +08001283 blend_offset = 0;
Chia-I Wuce9f11f2014-08-22 10:38:51 +08001284 memset(blend_color, 0, sizeof(blend_color));
1285 }
1286
1287 if (ds) {
Chia-I Wu72292b72014-09-09 10:48:33 +08001288 ds_offset = gen6_DEPTH_STENCIL_STATE(cmd, ds);
Chia-I Wuce9f11f2014-08-22 10:38:51 +08001289 stencil_ref = ds->cmd_stencil_ref;
1290 } else {
Chia-I Wu72292b72014-09-09 10:48:33 +08001291 ds_offset = 0;
Chia-I Wuce9f11f2014-08-22 10:38:51 +08001292 stencil_ref = 0;
1293 }
1294
Chia-I Wu72292b72014-09-09 10:48:33 +08001295 cc_offset = gen6_COLOR_CALC_STATE(cmd, stencil_ref, blend_color);
Chia-I Wu302742d2014-08-22 10:28:29 +08001296
Chia-I Wu72292b72014-09-09 10:48:33 +08001297 gen6_3DSTATE_CC_STATE_POINTERS(cmd, blend_offset, ds_offset, cc_offset);
Chia-I Wu302742d2014-08-22 10:28:29 +08001298}
1299
Chia-I Wu1744cca2014-08-22 11:10:17 +08001300static void gen6_viewport_states(struct intel_cmd *cmd)
1301{
1302 const struct intel_viewport_state *viewport = cmd->bind.state.viewport;
Chia-I Wub1d450a2014-09-09 13:48:03 +08001303 uint32_t sf_offset, clip_offset, cc_offset, scissor_offset;
Chia-I Wu1744cca2014-08-22 11:10:17 +08001304
1305 if (!viewport)
1306 return;
1307
Chia-I Wub1d450a2014-09-09 13:48:03 +08001308 assert(viewport->cmd_len == (8 + 4 + 2 + 2 * viewport->scissor_enable) *
1309 viewport->viewport_count);
1310
1311 sf_offset = cmd_state_write(cmd, INTEL_CMD_ITEM_SF_VIEWPORT,
1312 GEN6_ALIGNMENT_SF_VIEWPORT * 4, 8 * viewport->viewport_count,
1313 viewport->cmd);
1314
1315 clip_offset = cmd_state_write(cmd, INTEL_CMD_ITEM_CLIP_VIEWPORT,
1316 GEN6_ALIGNMENT_CLIP_VIEWPORT * 4, 4 * viewport->viewport_count,
1317 &viewport->cmd[viewport->cmd_clip_pos]);
1318
1319 cc_offset = cmd_state_write(cmd, INTEL_CMD_ITEM_CC_VIEWPORT,
1320 GEN6_ALIGNMENT_SF_VIEWPORT * 4, 2 * viewport->viewport_count,
1321 &viewport->cmd[viewport->cmd_cc_pos]);
1322
1323 if (viewport->scissor_enable) {
1324 scissor_offset = cmd_state_write(cmd, INTEL_CMD_ITEM_SCISSOR_RECT,
1325 GEN6_ALIGNMENT_SCISSOR_RECT * 4, 2 * viewport->viewport_count,
1326 &viewport->cmd[viewport->cmd_scissor_rect_pos]);
1327 } else {
1328 scissor_offset = 0;
1329 }
Chia-I Wu1744cca2014-08-22 11:10:17 +08001330
1331 gen6_3DSTATE_VIEWPORT_STATE_POINTERS(cmd,
Chia-I Wub1d450a2014-09-09 13:48:03 +08001332 clip_offset, sf_offset, cc_offset);
Chia-I Wu1744cca2014-08-22 11:10:17 +08001333
Chia-I Wub1d450a2014-09-09 13:48:03 +08001334 gen6_3DSTATE_SCISSOR_STATE_POINTERS(cmd, scissor_offset);
Chia-I Wu1744cca2014-08-22 11:10:17 +08001335}
1336
Chia-I Wu302742d2014-08-22 10:28:29 +08001337static void gen7_cc_states(struct intel_cmd *cmd)
1338{
1339 const struct intel_blend_state *blend = cmd->bind.state.blend;
1340 const struct intel_ds_state *ds = cmd->bind.state.ds;
Chia-I Wuce9f11f2014-08-22 10:38:51 +08001341 uint32_t stencil_ref;
1342 uint32_t blend_color[4];
Chia-I Wu72292b72014-09-09 10:48:33 +08001343 uint32_t offset;
Chia-I Wu302742d2014-08-22 10:28:29 +08001344
1345 CMD_ASSERT(cmd, 7, 7.5);
1346
Chia-I Wuce9f11f2014-08-22 10:38:51 +08001347 if (!blend && !ds)
1348 return;
Chia-I Wu302742d2014-08-22 10:28:29 +08001349
Chia-I Wuce9f11f2014-08-22 10:38:51 +08001350 if (blend) {
Chia-I Wu72292b72014-09-09 10:48:33 +08001351 offset = gen6_BLEND_STATE(cmd, blend);
Chia-I Wuce9f11f2014-08-22 10:38:51 +08001352 gen7_3dstate_pointer(cmd,
Chia-I Wu72292b72014-09-09 10:48:33 +08001353 GEN7_RENDER_OPCODE_3DSTATE_BLEND_STATE_POINTERS, offset);
Chia-I Wu302742d2014-08-22 10:28:29 +08001354
Chia-I Wuce9f11f2014-08-22 10:38:51 +08001355 memcpy(blend_color, blend->cmd_blend_color, sizeof(blend_color));
1356 } else {
1357 memset(blend_color, 0, sizeof(blend_color));
1358 }
1359
1360 if (ds) {
Chia-I Wu72292b72014-09-09 10:48:33 +08001361 offset = gen6_DEPTH_STENCIL_STATE(cmd, ds);
Chia-I Wuce9f11f2014-08-22 10:38:51 +08001362 gen7_3dstate_pointer(cmd,
Chia-I Wu72292b72014-09-09 10:48:33 +08001363 GEN7_RENDER_OPCODE_3DSTATE_DEPTH_STENCIL_STATE_POINTERS,
1364 offset);
Chia-I Wuce9f11f2014-08-22 10:38:51 +08001365 } else {
1366 stencil_ref = 0;
1367 }
1368
Chia-I Wu72292b72014-09-09 10:48:33 +08001369 offset = gen6_COLOR_CALC_STATE(cmd, stencil_ref, blend_color);
Chia-I Wu302742d2014-08-22 10:28:29 +08001370 gen7_3dstate_pointer(cmd,
Chia-I Wu72292b72014-09-09 10:48:33 +08001371 GEN6_RENDER_OPCODE_3DSTATE_CC_STATE_POINTERS, offset);
Chia-I Wu302742d2014-08-22 10:28:29 +08001372}
1373
Chia-I Wu1744cca2014-08-22 11:10:17 +08001374static void gen7_viewport_states(struct intel_cmd *cmd)
1375{
1376 const struct intel_viewport_state *viewport = cmd->bind.state.viewport;
Chia-I Wu72292b72014-09-09 10:48:33 +08001377 uint32_t offset;
Chia-I Wu1744cca2014-08-22 11:10:17 +08001378
1379 if (!viewport)
1380 return;
1381
Chia-I Wub1d450a2014-09-09 13:48:03 +08001382 assert(viewport->cmd_len == (16 + 2 + 2 * viewport->scissor_enable) *
1383 viewport->viewport_count);
Chia-I Wu1744cca2014-08-22 11:10:17 +08001384
Chia-I Wub1d450a2014-09-09 13:48:03 +08001385 offset = cmd_state_write(cmd, INTEL_CMD_ITEM_SF_VIEWPORT,
1386 GEN7_ALIGNMENT_SF_CLIP_VIEWPORT * 4, 16 * viewport->viewport_count,
1387 viewport->cmd);
Chia-I Wu1744cca2014-08-22 11:10:17 +08001388 gen7_3dstate_pointer(cmd,
Chia-I Wu72292b72014-09-09 10:48:33 +08001389 GEN7_RENDER_OPCODE_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP,
1390 offset);
Chia-I Wub1d450a2014-09-09 13:48:03 +08001391
1392 offset = cmd_state_write(cmd, INTEL_CMD_ITEM_CC_VIEWPORT,
1393 GEN6_ALIGNMENT_CC_VIEWPORT * 4, 2 * viewport->viewport_count,
1394 &viewport->cmd[viewport->cmd_cc_pos]);
Chia-I Wu1744cca2014-08-22 11:10:17 +08001395 gen7_3dstate_pointer(cmd,
1396 GEN7_RENDER_OPCODE_3DSTATE_VIEWPORT_STATE_POINTERS_CC,
Chia-I Wub1d450a2014-09-09 13:48:03 +08001397 offset);
Chia-I Wu72292b72014-09-09 10:48:33 +08001398
Chia-I Wu1744cca2014-08-22 11:10:17 +08001399 if (viewport->scissor_enable) {
Chia-I Wub1d450a2014-09-09 13:48:03 +08001400 offset = cmd_state_write(cmd, INTEL_CMD_ITEM_SCISSOR_RECT,
1401 GEN6_ALIGNMENT_SCISSOR_RECT * 4, 2 * viewport->viewport_count,
1402 &viewport->cmd[viewport->cmd_scissor_rect_pos]);
Chia-I Wu1744cca2014-08-22 11:10:17 +08001403 gen7_3dstate_pointer(cmd,
1404 GEN6_RENDER_OPCODE_3DSTATE_SCISSOR_STATE_POINTERS,
Chia-I Wub1d450a2014-09-09 13:48:03 +08001405 offset);
Chia-I Wu1744cca2014-08-22 11:10:17 +08001406 }
1407}
1408
Chia-I Wu7fd5cac2014-08-27 13:19:29 +08001409static void gen6_pcb(struct intel_cmd *cmd, int subop,
Chia-I Wuf2b6d722014-09-02 08:52:27 +08001410 const struct intel_pipeline_shader *sh)
Chia-I Wu7fd5cac2014-08-27 13:19:29 +08001411{
1412 const uint8_t cmd_len = 5;
Chia-I Wu46809782014-10-07 15:40:38 +08001413 uint32_t *dw;
Chia-I Wu7fd5cac2014-08-27 13:19:29 +08001414
Chia-I Wu72292b72014-09-09 10:48:33 +08001415 cmd_batch_pointer(cmd, cmd_len, &dw);
Chia-I Wu46809782014-10-07 15:40:38 +08001416
1417 dw[0] = GEN6_RENDER_TYPE_RENDER |
1418 GEN6_RENDER_SUBTYPE_3D |
1419 subop | (cmd_len - 2);
1420 dw[1] = 0;
Chia-I Wu72292b72014-09-09 10:48:33 +08001421 dw[2] = 0;
1422 dw[3] = 0;
1423 dw[4] = 0;
Chia-I Wu7fd5cac2014-08-27 13:19:29 +08001424}
1425
1426static void gen7_pcb(struct intel_cmd *cmd, int subop,
Chia-I Wuf2b6d722014-09-02 08:52:27 +08001427 const struct intel_pipeline_shader *sh)
Chia-I Wu7fd5cac2014-08-27 13:19:29 +08001428{
1429 const uint8_t cmd_len = 7;
Chia-I Wu46809782014-10-07 15:40:38 +08001430 uint32_t *dw;
Chia-I Wuc3ddee62014-09-02 10:53:20 +08001431
Chia-I Wu72292b72014-09-09 10:48:33 +08001432 cmd_batch_pointer(cmd, cmd_len, &dw);
Chia-I Wu46809782014-10-07 15:40:38 +08001433
1434 dw[0] = GEN6_RENDER_TYPE_RENDER |
1435 GEN6_RENDER_SUBTYPE_3D |
1436 subop | (cmd_len - 2);
1437 dw[1] = 0;
Chia-I Wu72292b72014-09-09 10:48:33 +08001438 dw[2] = 0;
Chia-I Wu46809782014-10-07 15:40:38 +08001439 dw[3] = 0;
Chia-I Wu72292b72014-09-09 10:48:33 +08001440 dw[4] = 0;
1441 dw[5] = 0;
1442 dw[6] = 0;
Chia-I Wu7fd5cac2014-08-27 13:19:29 +08001443}
1444
Chia-I Wu625105f2014-10-13 15:35:29 +08001445static uint32_t emit_samplers(struct intel_cmd *cmd,
1446 const struct intel_pipeline_rmap *rmap)
Chia-I Wufc05a2e2014-10-07 00:34:13 +08001447{
1448 const XGL_UINT border_len = (cmd_gen(cmd) >= INTEL_GEN(7)) ? 4 : 12;
1449 const XGL_UINT border_stride =
1450 u_align(border_len, GEN6_ALIGNMENT_SAMPLER_BORDER_COLOR);
Chia-I Wufc05a2e2014-10-07 00:34:13 +08001451 uint32_t border_offset, *border_dw, sampler_offset, *sampler_dw;
Chia-I Wu625105f2014-10-13 15:35:29 +08001452 XGL_UINT surface_count;
Chia-I Wufc05a2e2014-10-07 00:34:13 +08001453 XGL_UINT i;
1454
1455 CMD_ASSERT(cmd, 6, 7.5);
1456
Chia-I Wu625105f2014-10-13 15:35:29 +08001457 if (!rmap || !rmap->sampler_count)
1458 return 0;
1459
1460 surface_count = rmap->rt_count + rmap->resource_count + rmap->uav_count;
1461
Chia-I Wufc05a2e2014-10-07 00:34:13 +08001462 border_offset = cmd_state_pointer(cmd, INTEL_CMD_ITEM_BLOB,
1463 GEN6_ALIGNMENT_SAMPLER_BORDER_COLOR * 4,
1464 border_stride * rmap->sampler_count, &border_dw);
1465
1466 sampler_offset = cmd_state_pointer(cmd, INTEL_CMD_ITEM_SAMPLER,
1467 GEN6_ALIGNMENT_SAMPLER_STATE * 4,
1468 4 * rmap->sampler_count, &sampler_dw);
1469
1470 for (i = 0; i < rmap->sampler_count; i++) {
1471 const struct intel_pipeline_rmap_slot *slot =
1472 &rmap->slots[surface_count + i];
1473 const struct intel_sampler *sampler;
1474
1475 switch (slot->path_len) {
1476 case 0:
1477 sampler = NULL;
1478 break;
1479 case INTEL_PIPELINE_RMAP_SLOT_RT:
1480 case INTEL_PIPELINE_RMAP_SLOT_DYN:
1481 assert(!"unexpected rmap slot type");
1482 sampler = NULL;
1483 break;
1484 case 1:
1485 {
1486 const struct intel_dset *dset = cmd->bind.dset.graphics;
1487 const XGL_UINT slot_offset = cmd->bind.dset.graphics_offset;
1488 const struct intel_dset_slot *dset_slot =
1489 &dset->slots[slot_offset + slot->u.index];
1490
1491 switch (dset_slot->type) {
1492 case INTEL_DSET_SLOT_SAMPLER:
1493 sampler = dset_slot->u.sampler;
1494 break;
1495 default:
1496 assert(!"unexpected dset slot type");
1497 sampler = NULL;
1498 break;
1499 }
1500 }
1501 break;
1502 default:
1503 assert(!"nested descriptor set unsupported");
1504 sampler = NULL;
1505 break;
1506 }
1507
1508 if (sampler) {
1509 memcpy(border_dw, &sampler->cmd[3], border_len * 4);
1510
1511 sampler_dw[0] = sampler->cmd[0];
1512 sampler_dw[1] = sampler->cmd[1];
1513 sampler_dw[2] = border_offset;
1514 sampler_dw[3] = sampler->cmd[2];
1515 } else {
1516 sampler_dw[0] = GEN6_SAMPLER_DW0_DISABLE;
1517 sampler_dw[1] = 0;
1518 sampler_dw[2] = 0;
1519 sampler_dw[3] = 0;
1520 }
1521
1522 border_offset += border_stride * 4;
1523 border_dw += border_stride;
1524 sampler_dw += 4;
1525 }
1526
Chia-I Wu625105f2014-10-13 15:35:29 +08001527 return sampler_offset;
Chia-I Wufc05a2e2014-10-07 00:34:13 +08001528}
1529
Chia-I Wu8f6043a2014-10-13 15:44:06 +08001530static uint32_t emit_binding_table(struct intel_cmd *cmd,
1531 const struct intel_pipeline_rmap *rmap)
Chia-I Wu42a56202014-08-23 16:47:48 +08001532{
Chia-I Wu72292b72014-09-09 10:48:33 +08001533 uint32_t binding_table[256], offset;
Chia-I Wu8f6043a2014-10-13 15:44:06 +08001534 XGL_UINT surface_count, i;
Chia-I Wu42a56202014-08-23 16:47:48 +08001535
Chia-I Wufc05a2e2014-10-07 00:34:13 +08001536 CMD_ASSERT(cmd, 6, 7.5);
1537
Chia-I Wu8f6043a2014-10-13 15:44:06 +08001538 surface_count = (rmap) ?
1539 rmap->rt_count + rmap->resource_count + rmap->uav_count : 0;
1540 if (!surface_count)
1541 return 0;
1542
Chia-I Wu42a56202014-08-23 16:47:48 +08001543 assert(surface_count <= ARRAY_SIZE(binding_table));
1544
1545 for (i = 0; i < surface_count; i++) {
Chia-I Wu20983762014-09-02 12:07:28 +08001546 const struct intel_pipeline_rmap_slot *slot = &rmap->slots[i];
Chia-I Wu42a56202014-08-23 16:47:48 +08001547
1548 switch (slot->path_len) {
1549 case 0:
Chia-I Wu72292b72014-09-09 10:48:33 +08001550 offset = 0;
Chia-I Wu42a56202014-08-23 16:47:48 +08001551 break;
Chia-I Wu20983762014-09-02 12:07:28 +08001552 case INTEL_PIPELINE_RMAP_SLOT_RT:
Chia-I Wu42a56202014-08-23 16:47:48 +08001553 {
1554 const struct intel_rt_view *view = cmd->bind.att.rt[i];
1555
Chia-I Wu00b51a82014-09-09 12:07:37 +08001556 offset = cmd_surface_write(cmd, INTEL_CMD_ITEM_SURFACE,
Chia-I Wu72292b72014-09-09 10:48:33 +08001557 GEN6_ALIGNMENT_SURFACE_STATE * 4,
1558 view->cmd_len, view->cmd);
Chia-I Wu42a56202014-08-23 16:47:48 +08001559
Chia-I Wu72292b72014-09-09 10:48:33 +08001560 cmd_reserve_reloc(cmd, 1);
1561 cmd_surface_reloc(cmd, offset, 1, view->img->obj.mem->bo,
1562 view->cmd[1], INTEL_RELOC_WRITE);
Chia-I Wu42a56202014-08-23 16:47:48 +08001563 }
1564 break;
Chia-I Wu20983762014-09-02 12:07:28 +08001565 case INTEL_PIPELINE_RMAP_SLOT_DYN:
Chia-I Wu42a56202014-08-23 16:47:48 +08001566 {
1567 const struct intel_mem_view *view =
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001568 &cmd->bind.dyn_view.graphics;
Chia-I Wu42a56202014-08-23 16:47:48 +08001569
Chia-I Wu00b51a82014-09-09 12:07:37 +08001570 offset = cmd_surface_write(cmd, INTEL_CMD_ITEM_SURFACE,
Chia-I Wu72292b72014-09-09 10:48:33 +08001571 GEN6_ALIGNMENT_SURFACE_STATE * 4,
1572 view->cmd_len, view->cmd);
Chia-I Wu42a56202014-08-23 16:47:48 +08001573
Chia-I Wu72292b72014-09-09 10:48:33 +08001574 cmd_reserve_reloc(cmd, 1);
1575 cmd_surface_reloc(cmd, offset, 1, view->mem->bo,
1576 view->cmd[1], INTEL_RELOC_WRITE);
Chia-I Wu42a56202014-08-23 16:47:48 +08001577 }
1578 break;
1579 case 1:
Chia-I Wufc05a2e2014-10-07 00:34:13 +08001580 {
1581 const struct intel_dset *dset = cmd->bind.dset.graphics;
1582 const XGL_UINT slot_offset = cmd->bind.dset.graphics_offset;
1583 const struct intel_dset_slot *dset_slot =
1584 &dset->slots[slot_offset + slot->u.index];
Chia-I Wu55dffd32014-11-25 11:18:44 +08001585 const uint32_t reloc_flags =
1586 (dset_slot->read_only) ? 0 : INTEL_RELOC_WRITE;
Chia-I Wufc05a2e2014-10-07 00:34:13 +08001587
1588 switch (dset_slot->type) {
1589 case INTEL_DSET_SLOT_IMG_VIEW:
1590 offset = cmd_surface_write(cmd, INTEL_CMD_ITEM_SURFACE,
1591 GEN6_ALIGNMENT_SURFACE_STATE * 4,
1592 dset_slot->u.img_view->cmd_len,
1593 dset_slot->u.img_view->cmd);
1594
1595 cmd_reserve_reloc(cmd, 1);
1596 cmd_surface_reloc(cmd, offset, 1,
1597 dset_slot->u.img_view->img->obj.mem->bo,
Chia-I Wu55dffd32014-11-25 11:18:44 +08001598 dset_slot->u.img_view->cmd[1], reloc_flags);
Chia-I Wufc05a2e2014-10-07 00:34:13 +08001599 break;
1600 case INTEL_DSET_SLOT_MEM_VIEW:
1601 offset = cmd_surface_write(cmd, INTEL_CMD_ITEM_SURFACE,
1602 GEN6_ALIGNMENT_SURFACE_STATE * 4,
1603 dset_slot->u.mem_view.cmd_len,
1604 dset_slot->u.mem_view.cmd);
1605
1606 cmd_reserve_reloc(cmd, 1);
1607 cmd_surface_reloc(cmd, offset, 1,
1608 dset_slot->u.mem_view.mem->bo,
Chia-I Wu55dffd32014-11-25 11:18:44 +08001609 dset_slot->u.mem_view.cmd[1], reloc_flags);
Chia-I Wufc05a2e2014-10-07 00:34:13 +08001610 break;
Cody Northrop47b12182014-10-06 15:41:18 -06001611 case INTEL_DSET_SLOT_SAMPLER:
1612 assert(0 == cmd->bind.dset.graphics_offset);
1613
1614 offset = cmd_surface_write(cmd, INTEL_CMD_ITEM_SURFACE,
1615 GEN6_ALIGNMENT_SURFACE_STATE * 4,
1616 16, dset_slot->u.sampler->cmd);
1617 break;
Chia-I Wufc05a2e2014-10-07 00:34:13 +08001618 default:
1619 assert(!"unexpected dset slot type");
1620 break;
1621 }
1622 }
1623 break;
Chia-I Wu42a56202014-08-23 16:47:48 +08001624 default:
Chia-I Wufc05a2e2014-10-07 00:34:13 +08001625 assert(!"nested descriptor set unsupported");
Chia-I Wu42a56202014-08-23 16:47:48 +08001626 break;
1627 }
1628
Chia-I Wu72292b72014-09-09 10:48:33 +08001629 binding_table[i] = offset;
Chia-I Wu42a56202014-08-23 16:47:48 +08001630 }
1631
Chia-I Wu8f6043a2014-10-13 15:44:06 +08001632 return cmd_state_write(cmd, INTEL_CMD_ITEM_BINDING_TABLE,
Chia-I Wu00b51a82014-09-09 12:07:37 +08001633 GEN6_ALIGNMENT_BINDING_TABLE_STATE * 4,
Chia-I Wu72292b72014-09-09 10:48:33 +08001634 surface_count, binding_table);
Chia-I Wu42a56202014-08-23 16:47:48 +08001635}
1636
Chia-I Wu1d125092014-10-08 08:49:38 +08001637static void gen6_3DSTATE_VERTEX_BUFFERS(struct intel_cmd *cmd)
1638{
1639 const struct intel_pipeline *pipeline = cmd->bind.pipeline.graphics;
Chia-I Wu1d125092014-10-08 08:49:38 +08001640 const uint8_t cmd_len = 1 + 4 * pipeline->vb_count;
1641 uint32_t *dw;
1642 XGL_UINT pos, i;
1643
1644 CMD_ASSERT(cmd, 6, 7.5);
1645
1646 if (!pipeline->vb_count)
1647 return;
1648
1649 pos = cmd_batch_pointer(cmd, cmd_len, &dw);
1650
1651 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_VERTEX_BUFFERS) | (cmd_len - 2);
1652 dw++;
1653 pos++;
1654
1655 for (i = 0; i < pipeline->vb_count; i++) {
Chia-I Wu1d125092014-10-08 08:49:38 +08001656 assert(pipeline->vb[i].strideInBytes <= 2048);
1657
1658 dw[0] = i << GEN6_VB_STATE_DW0_INDEX__SHIFT |
1659 pipeline->vb[i].strideInBytes;
1660
1661 if (cmd_gen(cmd) >= INTEL_GEN(7))
1662 dw[0] |= GEN7_VB_STATE_DW0_ADDR_MODIFIED;
1663
1664 switch (pipeline->vb[i].stepRate) {
1665 case XGL_VERTEX_INPUT_STEP_RATE_VERTEX:
1666 dw[0] |= GEN6_VB_STATE_DW0_ACCESS_VERTEXDATA;
1667 dw[3] = 0;
1668 break;
1669 case XGL_VERTEX_INPUT_STEP_RATE_INSTANCE:
1670 dw[0] |= GEN6_VB_STATE_DW0_ACCESS_INSTANCEDATA;
1671 dw[3] = 1;
1672 break;
1673 case XGL_VERTEX_INPUT_STEP_RATE_DRAW:
1674 dw[0] |= GEN6_VB_STATE_DW0_ACCESS_INSTANCEDATA;
1675 dw[3] = 0;
1676 break;
1677 default:
1678 assert(!"unknown step rate");
1679 dw[0] |= GEN6_VB_STATE_DW0_ACCESS_VERTEXDATA;
1680 dw[3] = 0;
1681 break;
1682 }
1683
Chia-I Wu3b04af52014-11-08 10:48:20 +08001684 if (cmd->bind.vertex.mem[i]) {
1685 const struct intel_mem *mem = cmd->bind.vertex.mem[i];
1686 const XGL_GPU_SIZE offset = cmd->bind.vertex.offset[i];
Chia-I Wu1d125092014-10-08 08:49:38 +08001687
1688 cmd_reserve_reloc(cmd, 2);
Chia-I Wu3b04af52014-11-08 10:48:20 +08001689 cmd_batch_reloc(cmd, pos + 1, mem->bo, offset, 0);
1690 cmd_batch_reloc(cmd, pos + 2, mem->bo, mem->size - 1, 0);
Chia-I Wu1d125092014-10-08 08:49:38 +08001691 } else {
1692 dw[0] |= GEN6_VB_STATE_DW0_IS_NULL;
1693 dw[1] = 0;
1694 dw[2] = 0;
1695 }
1696
1697 dw += 4;
1698 pos += 4;
1699 }
1700}
1701
Courtney Goeltzenleuchter3d72e8c2014-08-29 16:27:47 -06001702static void gen6_3DSTATE_VS(struct intel_cmd *cmd)
1703{
Chia-I Wu72f9b8d2014-09-02 13:27:48 +08001704 const struct intel_pipeline *pipeline = cmd->bind.pipeline.graphics;
1705 const struct intel_pipeline_shader *vs = &pipeline->vs;
1706 const uint8_t cmd_len = 6;
Courtney Goeltzenleuchter3d72e8c2014-08-29 16:27:47 -06001707 const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_VS) | (cmd_len - 2);
Chia-I Wu72292b72014-09-09 10:48:33 +08001708 uint32_t dw2, dw4, dw5, *dw;
Chia-I Wu72f9b8d2014-09-02 13:27:48 +08001709 int vue_read_len, max_threads;
Courtney Goeltzenleuchter3d72e8c2014-08-29 16:27:47 -06001710
1711 CMD_ASSERT(cmd, 6, 7.5);
1712
Courtney Goeltzenleuchter3d72e8c2014-08-29 16:27:47 -06001713 /*
Chia-I Wu72f9b8d2014-09-02 13:27:48 +08001714 * From the Sandy Bridge PRM, volume 2 part 1, page 135:
1715 *
1716 * "(Vertex URB Entry Read Length) Specifies the number of pairs of
1717 * 128-bit vertex elements to be passed into the payload for each
1718 * vertex."
1719 *
1720 * "It is UNDEFINED to set this field to 0 indicating no Vertex URB
1721 * data to be read and passed to the thread."
Courtney Goeltzenleuchter3d72e8c2014-08-29 16:27:47 -06001722 */
Chia-I Wu72f9b8d2014-09-02 13:27:48 +08001723 vue_read_len = (vs->in_count + 1) / 2;
1724 if (!vue_read_len)
1725 vue_read_len = 1;
1726
1727 dw2 = (vs->sampler_count + 3) / 4 << GEN6_THREADDISP_SAMPLER_COUNT__SHIFT |
1728 vs->surface_count << GEN6_THREADDISP_BINDING_TABLE_SIZE__SHIFT;
1729
1730 dw4 = vs->urb_grf_start << GEN6_VS_DW4_URB_GRF_START__SHIFT |
1731 vue_read_len << GEN6_VS_DW4_URB_READ_LEN__SHIFT |
1732 0 << GEN6_VS_DW4_URB_READ_OFFSET__SHIFT;
Courtney Goeltzenleuchter3d72e8c2014-08-29 16:27:47 -06001733
1734 dw5 = GEN6_VS_DW5_STATISTICS |
1735 GEN6_VS_DW5_VS_ENABLE;
Chia-I Wu72f9b8d2014-09-02 13:27:48 +08001736
1737 switch (cmd_gen(cmd)) {
1738 case INTEL_GEN(7.5):
1739 max_threads = (cmd->dev->gpu->gt >= 2) ? 280 : 70;
1740 break;
1741 case INTEL_GEN(7):
1742 max_threads = (cmd->dev->gpu->gt == 2) ? 128 : 36;
1743 break;
1744 case INTEL_GEN(6):
1745 max_threads = (cmd->dev->gpu->gt == 2) ? 60 : 24;
1746 break;
1747 default:
1748 max_threads = 1;
1749 break;
Courtney Goeltzenleuchter3d72e8c2014-08-29 16:27:47 -06001750 }
1751
Chia-I Wu72f9b8d2014-09-02 13:27:48 +08001752 if (cmd_gen(cmd) >= INTEL_GEN(7.5))
1753 dw5 |= (max_threads - 1) << GEN75_VS_DW5_MAX_THREADS__SHIFT;
1754 else
1755 dw5 |= (max_threads - 1) << GEN6_VS_DW5_MAX_THREADS__SHIFT;
1756
Chia-I Wube0a3d92014-09-02 13:20:59 +08001757 if (pipeline->disable_vs_cache)
1758 dw5 |= GEN6_VS_DW5_CACHE_DISABLE;
1759
Chia-I Wu72292b72014-09-09 10:48:33 +08001760 cmd_batch_pointer(cmd, cmd_len, &dw);
1761 dw[0] = dw0;
Chia-I Wua57761b2014-10-14 14:27:44 +08001762 dw[1] = cmd->bind.pipeline.vs_offset;
Chia-I Wu72292b72014-09-09 10:48:33 +08001763 dw[2] = dw2;
1764 dw[3] = 0; /* scratch */
1765 dw[4] = dw4;
1766 dw[5] = dw5;
Courtney Goeltzenleuchter3d72e8c2014-08-29 16:27:47 -06001767}
1768
Chia-I Wu625105f2014-10-13 15:35:29 +08001769static void emit_shader_resources(struct intel_cmd *cmd)
1770{
1771 /* five HW shader stages */
Chia-I Wu8f6043a2014-10-13 15:44:06 +08001772 uint32_t binding_tables[5], samplers[5];
Chia-I Wu625105f2014-10-13 15:35:29 +08001773
Chia-I Wu8f6043a2014-10-13 15:44:06 +08001774 binding_tables[0] = emit_binding_table(cmd,
1775 cmd->bind.pipeline.graphics->vs.rmap);
1776 binding_tables[1] = emit_binding_table(cmd,
1777 cmd->bind.pipeline.graphics->tcs.rmap);
1778 binding_tables[2] = emit_binding_table(cmd,
1779 cmd->bind.pipeline.graphics->tes.rmap);
1780 binding_tables[3] = emit_binding_table(cmd,
1781 cmd->bind.pipeline.graphics->gs.rmap);
1782 binding_tables[4] = emit_binding_table(cmd,
1783 cmd->bind.pipeline.graphics->fs.rmap);
Chia-I Wu625105f2014-10-13 15:35:29 +08001784
1785 samplers[0] = emit_samplers(cmd, cmd->bind.pipeline.graphics->vs.rmap);
1786 samplers[1] = emit_samplers(cmd, cmd->bind.pipeline.graphics->tcs.rmap);
1787 samplers[2] = emit_samplers(cmd, cmd->bind.pipeline.graphics->tes.rmap);
1788 samplers[3] = emit_samplers(cmd, cmd->bind.pipeline.graphics->gs.rmap);
1789 samplers[4] = emit_samplers(cmd, cmd->bind.pipeline.graphics->fs.rmap);
1790
1791 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
1792 gen7_3dstate_pointer(cmd,
Chia-I Wu8f6043a2014-10-13 15:44:06 +08001793 GEN7_RENDER_OPCODE_3DSTATE_BINDING_TABLE_POINTERS_VS,
1794 binding_tables[0]);
1795 gen7_3dstate_pointer(cmd,
1796 GEN7_RENDER_OPCODE_3DSTATE_BINDING_TABLE_POINTERS_HS,
1797 binding_tables[1]);
1798 gen7_3dstate_pointer(cmd,
1799 GEN7_RENDER_OPCODE_3DSTATE_BINDING_TABLE_POINTERS_DS,
1800 binding_tables[2]);
1801 gen7_3dstate_pointer(cmd,
1802 GEN7_RENDER_OPCODE_3DSTATE_BINDING_TABLE_POINTERS_GS,
1803 binding_tables[3]);
1804 gen7_3dstate_pointer(cmd,
1805 GEN7_RENDER_OPCODE_3DSTATE_BINDING_TABLE_POINTERS_PS,
1806 binding_tables[4]);
1807
1808 gen7_3dstate_pointer(cmd,
Chia-I Wu625105f2014-10-13 15:35:29 +08001809 GEN7_RENDER_OPCODE_3DSTATE_SAMPLER_STATE_POINTERS_VS,
1810 samplers[0]);
1811 gen7_3dstate_pointer(cmd,
1812 GEN7_RENDER_OPCODE_3DSTATE_SAMPLER_STATE_POINTERS_HS,
1813 samplers[1]);
1814 gen7_3dstate_pointer(cmd,
1815 GEN7_RENDER_OPCODE_3DSTATE_SAMPLER_STATE_POINTERS_DS,
1816 samplers[2]);
1817 gen7_3dstate_pointer(cmd,
1818 GEN7_RENDER_OPCODE_3DSTATE_SAMPLER_STATE_POINTERS_GS,
1819 samplers[3]);
1820 gen7_3dstate_pointer(cmd,
1821 GEN7_RENDER_OPCODE_3DSTATE_SAMPLER_STATE_POINTERS_PS,
1822 samplers[4]);
1823 } else {
Chia-I Wu8f6043a2014-10-13 15:44:06 +08001824 assert(!binding_tables[1] && !binding_tables[2]);
1825 gen6_3DSTATE_BINDING_TABLE_POINTERS(cmd,
1826 binding_tables[0], binding_tables[3], binding_tables[4]);
1827
Chia-I Wu625105f2014-10-13 15:35:29 +08001828 assert(!samplers[1] && !samplers[2]);
1829 gen6_3DSTATE_SAMPLER_STATE_POINTERS(cmd,
1830 samplers[0], samplers[3], samplers[4]);
1831 }
1832}
1833
Chia-I Wu2e5ec9b2014-10-14 13:37:21 +08001834static void emit_rt(struct intel_cmd *cmd)
1835{
1836 cmd_wa_gen6_pre_depth_stall_write(cmd);
1837 gen6_3DSTATE_DRAWING_RECTANGLE(cmd, cmd->bind.att.width,
1838 cmd->bind.att.height);
1839}
1840
1841static void emit_ds(struct intel_cmd *cmd)
1842{
1843 const struct intel_ds_view *ds = cmd->bind.att.ds;
1844
1845 if (!ds) {
1846 /* all zeros */
1847 static const struct intel_ds_view null_ds;
1848 ds = &null_ds;
1849 }
1850
1851 cmd_wa_gen6_pre_ds_flush(cmd);
1852 gen6_3DSTATE_DEPTH_BUFFER(cmd, ds);
1853 gen6_3DSTATE_STENCIL_BUFFER(cmd, ds);
1854 gen6_3DSTATE_HIER_DEPTH_BUFFER(cmd, ds);
1855
1856 if (cmd_gen(cmd) >= INTEL_GEN(7))
1857 gen7_3DSTATE_CLEAR_PARAMS(cmd, 0);
1858 else
1859 gen6_3DSTATE_CLEAR_PARAMS(cmd, 0);
1860}
1861
Chia-I Wua57761b2014-10-14 14:27:44 +08001862static uint32_t emit_shader(struct intel_cmd *cmd,
1863 const struct intel_pipeline_shader *shader)
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001864{
Chia-I Wua57761b2014-10-14 14:27:44 +08001865 struct intel_cmd_shader_cache *cache = &cmd->bind.shader_cache;
1866 uint32_t offset;
1867 XGL_UINT i;
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001868
Chia-I Wua57761b2014-10-14 14:27:44 +08001869 /* see if the shader is already in the cache */
1870 for (i = 0; i < cache->used; i++) {
1871 if (cache->entries[i].shader == (const void *) shader)
1872 return cache->entries[i].kernel_offset;
1873 }
1874
1875 offset = cmd_instruction_write(cmd, shader->codeSize, shader->pCode);
1876
1877 /* grow the cache if full */
1878 if (cache->used >= cache->count) {
1879 const XGL_UINT count = cache->count + 16;
1880 void *entries;
1881
1882 entries = icd_alloc(sizeof(cache->entries[0]) * count, 0,
1883 XGL_SYSTEM_ALLOC_INTERNAL);
1884 if (entries) {
1885 if (cache->entries) {
1886 memcpy(entries, cache->entries,
1887 sizeof(cache->entries[0]) * cache->used);
1888 icd_free(cache->entries);
1889 }
1890
1891 cache->entries = entries;
1892 cache->count = count;
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001893 }
1894 }
1895
Chia-I Wua57761b2014-10-14 14:27:44 +08001896 /* add the shader to the cache */
1897 if (cache->used < cache->count) {
1898 cache->entries[cache->used].shader = (const void *) shader;
1899 cache->entries[cache->used].kernel_offset = offset;
1900 cache->used++;
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001901 }
1902
Chia-I Wua57761b2014-10-14 14:27:44 +08001903 return offset;
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001904}
1905
Chia-I Wuc29afdd2014-10-14 13:22:31 +08001906static void emit_graphics_pipeline(struct intel_cmd *cmd)
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001907{
Chia-I Wuc29afdd2014-10-14 13:22:31 +08001908 const struct intel_pipeline *pipeline = cmd->bind.pipeline.graphics;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +08001909
Chia-I Wu8370b402014-08-29 12:28:37 +08001910 if (pipeline->wa_flags & INTEL_CMD_WA_GEN6_PRE_DEPTH_STALL_WRITE)
1911 cmd_wa_gen6_pre_depth_stall_write(cmd);
1912 if (pipeline->wa_flags & INTEL_CMD_WA_GEN6_PRE_COMMAND_SCOREBOARD_STALL)
1913 cmd_wa_gen6_pre_command_scoreboard_stall(cmd);
1914 if (pipeline->wa_flags & INTEL_CMD_WA_GEN7_PRE_VS_DEPTH_STALL_WRITE)
1915 cmd_wa_gen7_pre_vs_depth_stall_write(cmd);
Chia-I Wubb2d8ca2014-08-28 23:15:48 +08001916
1917 /* 3DSTATE_URB_VS and etc. */
Courtney Goeltzenleuchter814cd292014-08-28 13:16:27 -06001918 assert(pipeline->cmd_len);
Chia-I Wu72292b72014-09-09 10:48:33 +08001919 cmd_batch_write(cmd, pipeline->cmd_len, pipeline->cmds);
Chia-I Wubb2d8ca2014-08-28 23:15:48 +08001920
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001921 if (pipeline->active_shaders & SHADER_VERTEX_FLAG) {
Chia-I Wua57761b2014-10-14 14:27:44 +08001922 cmd->bind.pipeline.vs_offset = emit_shader(cmd, &pipeline->vs);
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001923 }
1924 if (pipeline->active_shaders & SHADER_TESS_CONTROL_FLAG) {
Chia-I Wua57761b2014-10-14 14:27:44 +08001925 cmd->bind.pipeline.tcs_offset = emit_shader(cmd, &pipeline->tcs);
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001926 }
1927 if (pipeline->active_shaders & SHADER_TESS_EVAL_FLAG) {
Chia-I Wua57761b2014-10-14 14:27:44 +08001928 cmd->bind.pipeline.tes_offset = emit_shader(cmd, &pipeline->tes);
1929 }
1930 if (pipeline->active_shaders & SHADER_GEOMETRY_FLAG) {
1931 cmd->bind.pipeline.gs_offset = emit_shader(cmd, &pipeline->gs);
1932 }
1933 if (pipeline->active_shaders & SHADER_FRAGMENT_FLAG) {
1934 cmd->bind.pipeline.fs_offset = emit_shader(cmd, &pipeline->fs);
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001935 }
Courtney Goeltzenleuchter68d9bef2014-08-28 17:35:03 -06001936
Chia-I Wud95aa2b2014-08-29 12:07:47 +08001937 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
1938 gen7_3DSTATE_GS(cmd);
1939 } else {
1940 gen6_3DSTATE_GS(cmd);
1941 }
Courtney Goeltzenleuchterf782a852014-08-28 17:44:53 -06001942
Chia-I Wu8370b402014-08-29 12:28:37 +08001943 if (pipeline->wa_flags & INTEL_CMD_WA_GEN7_POST_COMMAND_CS_STALL)
1944 cmd_wa_gen7_post_command_cs_stall(cmd);
1945 if (pipeline->wa_flags & INTEL_CMD_WA_GEN7_POST_COMMAND_DEPTH_STALL)
1946 cmd_wa_gen7_post_command_depth_stall(cmd);
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001947}
1948
Chia-I Wuc29afdd2014-10-14 13:22:31 +08001949static void emit_bounded_states(struct intel_cmd *cmd)
1950{
1951 const struct intel_msaa_state *msaa = cmd->bind.state.msaa;
1952
1953 emit_graphics_pipeline(cmd);
1954
1955 emit_rt(cmd);
1956 emit_ds(cmd);
1957
1958 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
1959 gen7_cc_states(cmd);
1960 gen7_viewport_states(cmd);
1961
1962 gen7_pcb(cmd, GEN6_RENDER_OPCODE_3DSTATE_CONSTANT_VS,
1963 &cmd->bind.pipeline.graphics->vs);
1964 gen7_pcb(cmd, GEN6_RENDER_OPCODE_3DSTATE_CONSTANT_PS,
1965 &cmd->bind.pipeline.graphics->fs);
1966
1967 gen6_3DSTATE_CLIP(cmd);
1968 gen7_3DSTATE_SF(cmd);
1969 gen7_3DSTATE_SBE(cmd);
1970 gen7_3DSTATE_WM(cmd);
1971 gen7_3DSTATE_PS(cmd);
1972 } else {
1973 gen6_cc_states(cmd);
1974 gen6_viewport_states(cmd);
1975
1976 gen6_pcb(cmd, GEN6_RENDER_OPCODE_3DSTATE_CONSTANT_VS,
1977 &cmd->bind.pipeline.graphics->vs);
1978 gen6_pcb(cmd, GEN6_RENDER_OPCODE_3DSTATE_CONSTANT_PS,
1979 &cmd->bind.pipeline.graphics->fs);
1980
1981 gen6_3DSTATE_CLIP(cmd);
1982 gen6_3DSTATE_SF(cmd);
1983 gen6_3DSTATE_WM(cmd);
1984 }
1985
1986 emit_shader_resources(cmd);
1987
1988 cmd_wa_gen6_pre_depth_stall_write(cmd);
1989 cmd_wa_gen6_pre_multisample_depth_flush(cmd);
1990
1991 /* 3DSTATE_MULTISAMPLE and 3DSTATE_SAMPLE_MASK */
1992 cmd_batch_write(cmd, msaa->cmd_len, msaa->cmd);
1993
1994 gen6_3DSTATE_VERTEX_BUFFERS(cmd);
1995 gen6_3DSTATE_VS(cmd);
1996}
1997
Chia-I Wu6032b892014-10-17 14:47:18 +08001998static void gen6_meta_dynamic_states(struct intel_cmd *cmd)
1999{
2000 const struct intel_cmd_meta *meta = cmd->bind.meta;
2001 uint32_t blend_offset, ds_offset, cc_offset, cc_vp_offset, *dw;
2002
2003 CMD_ASSERT(cmd, 6, 7.5);
2004
2005 blend_offset = 0;
2006 ds_offset = 0;
2007 cc_offset = 0;
2008 cc_vp_offset = 0;
2009
Chia-I Wu29e6f502014-11-24 14:27:29 +08002010 if (meta->mode == INTEL_CMD_META_FS_RECT) {
Chia-I Wu6032b892014-10-17 14:47:18 +08002011 /* BLEND_STATE */
2012 blend_offset = cmd_state_pointer(cmd, INTEL_CMD_ITEM_BLEND,
2013 GEN6_ALIGNMENT_BLEND_STATE * 4, 2, &dw);
2014 dw[0] = 0;
2015 dw[1] = GEN6_BLEND_DW1_COLORCLAMP_RTFORMAT | 0x3;
2016 }
2017
Chia-I Wu29e6f502014-11-24 14:27:29 +08002018 if (meta->mode != INTEL_CMD_META_VS_POINTS) {
2019 if (meta->ds.state) {
2020 const uint32_t blend_color[4] = { 0, 0, 0, 0 };
Chia-I Wu6032b892014-10-17 14:47:18 +08002021
Chia-I Wu29e6f502014-11-24 14:27:29 +08002022 /* DEPTH_STENCIL_STATE */
2023 ds_offset = gen6_DEPTH_STENCIL_STATE(cmd, meta->ds.state);
Chia-I Wu6032b892014-10-17 14:47:18 +08002024
Chia-I Wu29e6f502014-11-24 14:27:29 +08002025 /* COLOR_CALC_STATE */
2026 cc_offset = gen6_COLOR_CALC_STATE(cmd,
2027 meta->ds.state->cmd_stencil_ref, blend_color);
Chia-I Wu6032b892014-10-17 14:47:18 +08002028
Chia-I Wu29e6f502014-11-24 14:27:29 +08002029 /* CC_VIEWPORT */
2030 cc_vp_offset = cmd_state_pointer(cmd, INTEL_CMD_ITEM_CC_VIEWPORT,
2031 GEN6_ALIGNMENT_CC_VIEWPORT * 4, 2, &dw);
2032 dw[0] = u_fui(0.0f);
2033 dw[1] = u_fui(1.0f);
2034 } else {
2035 /* DEPTH_STENCIL_STATE */
2036 ds_offset = cmd_state_pointer(cmd, INTEL_CMD_ITEM_DEPTH_STENCIL,
2037 GEN6_ALIGNMENT_DEPTH_STENCIL_STATE * 4,
2038 GEN6_DEPTH_STENCIL_STATE__SIZE, &dw);
2039 memset(dw, 0, sizeof(*dw) * GEN6_DEPTH_STENCIL_STATE__SIZE);
2040 }
Chia-I Wu6032b892014-10-17 14:47:18 +08002041 }
2042
2043 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
2044 gen7_3dstate_pointer(cmd,
2045 GEN7_RENDER_OPCODE_3DSTATE_BLEND_STATE_POINTERS,
2046 blend_offset);
2047 gen7_3dstate_pointer(cmd,
2048 GEN7_RENDER_OPCODE_3DSTATE_DEPTH_STENCIL_STATE_POINTERS,
2049 ds_offset);
2050 gen7_3dstate_pointer(cmd,
2051 GEN6_RENDER_OPCODE_3DSTATE_CC_STATE_POINTERS, cc_offset);
2052
2053 gen7_3dstate_pointer(cmd,
2054 GEN7_RENDER_OPCODE_3DSTATE_VIEWPORT_STATE_POINTERS_CC,
2055 cc_vp_offset);
2056 } else {
2057 /* 3DSTATE_CC_STATE_POINTERS */
Chia-I Wu429a0aa2014-10-24 11:57:51 +08002058 gen6_3DSTATE_CC_STATE_POINTERS(cmd, blend_offset, ds_offset, cc_offset);
Chia-I Wu6032b892014-10-17 14:47:18 +08002059
2060 /* 3DSTATE_VIEWPORT_STATE_POINTERS */
2061 cmd_batch_pointer(cmd, 4, &dw);
2062 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_VIEWPORT_STATE_POINTERS) | (4 - 2) |
2063 GEN6_PTR_VP_DW0_CC_CHANGED;
2064 dw[1] = 0;
2065 dw[2] = 0;
2066 dw[3] = cc_vp_offset;
2067 }
2068}
2069
2070static void gen6_meta_surface_states(struct intel_cmd *cmd)
2071{
2072 const struct intel_cmd_meta *meta = cmd->bind.meta;
Chia-I Wu005c47c2014-10-22 13:49:13 +08002073 uint32_t binding_table[2] = { 0, 0 };
Chia-I Wu6032b892014-10-17 14:47:18 +08002074 uint32_t offset;
2075
2076 CMD_ASSERT(cmd, 6, 7.5);
2077
Chia-I Wu29e6f502014-11-24 14:27:29 +08002078 if (meta->mode == INTEL_CMD_META_DEPTH_STENCIL_RECT)
2079 return;
2080
Chia-I Wu005c47c2014-10-22 13:49:13 +08002081 /* SURFACE_STATEs */
Chia-I Wu6032b892014-10-17 14:47:18 +08002082 if (meta->src.valid) {
2083 offset = cmd_surface_write(cmd, INTEL_CMD_ITEM_SURFACE,
2084 GEN6_ALIGNMENT_SURFACE_STATE * 4,
2085 meta->src.surface_len, meta->src.surface);
2086
2087 cmd_reserve_reloc(cmd, 1);
2088 if (meta->src.reloc_flags & INTEL_CMD_RELOC_TARGET_IS_WRITER) {
2089 cmd_surface_reloc_writer(cmd, offset, 1,
2090 meta->src.reloc_target, meta->src.reloc_offset);
2091 } else {
2092 cmd_surface_reloc(cmd, offset, 1,
2093 (struct intel_bo *) meta->src.reloc_target,
2094 meta->src.reloc_offset, meta->src.reloc_flags);
2095 }
2096
Chia-I Wu005c47c2014-10-22 13:49:13 +08002097 binding_table[0] = offset;
2098 }
2099 if (meta->dst.valid) {
2100 offset = cmd_surface_write(cmd, INTEL_CMD_ITEM_SURFACE,
2101 GEN6_ALIGNMENT_SURFACE_STATE * 4,
2102 meta->dst.surface_len, meta->dst.surface);
2103
2104 cmd_reserve_reloc(cmd, 1);
2105 cmd_surface_reloc(cmd, offset, 1,
2106 (struct intel_bo *) meta->dst.reloc_target,
2107 meta->dst.reloc_offset, meta->dst.reloc_flags);
2108
2109 binding_table[1] = offset;
Chia-I Wu6032b892014-10-17 14:47:18 +08002110 }
2111
2112 /* BINDING_TABLE */
2113 offset = cmd_state_write(cmd, INTEL_CMD_ITEM_BINDING_TABLE,
2114 GEN6_ALIGNMENT_BINDING_TABLE_STATE * 4,
Chia-I Wu005c47c2014-10-22 13:49:13 +08002115 2, binding_table);
Chia-I Wu6032b892014-10-17 14:47:18 +08002116
2117 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
Chia-I Wu29e6f502014-11-24 14:27:29 +08002118 const int subop = (meta->mode == INTEL_CMD_META_VS_POINTS) ?
2119 GEN7_RENDER_OPCODE_3DSTATE_BINDING_TABLE_POINTERS_VS :
2120 GEN7_RENDER_OPCODE_3DSTATE_BINDING_TABLE_POINTERS_PS;
2121 gen7_3dstate_pointer(cmd, subop, offset);
Chia-I Wu6032b892014-10-17 14:47:18 +08002122 } else {
2123 /* 3DSTATE_BINDING_TABLE_POINTERS */
Chia-I Wu29e6f502014-11-24 14:27:29 +08002124 if (meta->mode == INTEL_CMD_META_VS_POINTS)
2125 gen6_3DSTATE_BINDING_TABLE_POINTERS(cmd, offset, 0, 0);
2126 else
2127 gen6_3DSTATE_BINDING_TABLE_POINTERS(cmd, 0, 0, offset);
Chia-I Wu6032b892014-10-17 14:47:18 +08002128 }
2129}
2130
2131static void gen6_meta_urb(struct intel_cmd *cmd)
2132{
2133 uint32_t *dw;
2134
2135 CMD_ASSERT(cmd, 6, 6);
2136
2137 /* 3DSTATE_URB */
2138 cmd_batch_pointer(cmd, 3, &dw);
2139 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_URB) | (3 - 2);
2140 dw[1] = 128 << GEN6_URB_DW1_VS_ENTRY_COUNT__SHIFT;
2141 dw[2] = 0;
2142}
2143
2144static void gen7_meta_urb(struct intel_cmd *cmd)
2145{
Chia-I Wu29e6f502014-11-24 14:27:29 +08002146 const struct intel_cmd_meta *meta = cmd->bind.meta;
Chia-I Wu6032b892014-10-17 14:47:18 +08002147 uint32_t *dw;
2148
2149 CMD_ASSERT(cmd, 7, 7.5);
2150
2151 /* 3DSTATE_PUSH_CONSTANT_ALLOC_x */
2152 cmd_batch_pointer(cmd, 10, &dw);
2153
2154 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_PUSH_CONSTANT_ALLOC_VS) | (2 - 2);
Chia-I Wu29e6f502014-11-24 14:27:29 +08002155 dw[1] = (meta->mode == INTEL_CMD_META_VS_POINTS);
Chia-I Wu6032b892014-10-17 14:47:18 +08002156 dw += 2;
2157
2158 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_PUSH_CONSTANT_ALLOC_HS) | (2 - 2);
2159 dw[1] = 0;
2160 dw += 2;
2161
2162 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_PUSH_CONSTANT_ALLOC_DS) | (2 - 2);
2163 dw[1] = 0;
2164 dw += 2;
2165
2166 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_PUSH_CONSTANT_ALLOC_GS) | (2 - 2);
2167 dw[1] = 0;
2168 dw += 2;
2169
2170 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_PUSH_CONSTANT_ALLOC_PS) | (2 - 2);
Chia-I Wu29e6f502014-11-24 14:27:29 +08002171 dw[1] = (meta->mode == INTEL_CMD_META_FS_RECT);
Chia-I Wu6032b892014-10-17 14:47:18 +08002172
2173 cmd_wa_gen7_pre_vs_depth_stall_write(cmd);
2174
2175 /* 3DSTATE_URB_x */
2176 cmd_batch_pointer(cmd, 8, &dw);
2177
2178 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_URB_VS) | (2 - 2);
2179 dw[1] = 1 << GEN7_URB_ANY_DW1_OFFSET__SHIFT |
2180 512;
2181 dw += 2;
2182
2183 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_URB_HS) | (2 - 2);
2184 dw[1] = 0;
2185 dw += 2;
2186
2187 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_URB_DS) | (2 - 2);
2188 dw[1] = 0;
2189 dw += 2;
2190
2191 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_URB_GS) | (2 - 2);
2192 dw[1] = 0;
2193 dw += 2;
2194}
2195
2196static void gen6_meta_vf(struct intel_cmd *cmd)
2197{
2198 const struct intel_cmd_meta *meta = cmd->bind.meta;
Chia-I Wu3adf7212014-10-24 15:34:07 +08002199 uint32_t vb_start, vb_end, vb_stride;
2200 int ve_format, ve_z_source;
2201 uint32_t *dw;
Chia-I Wu6032b892014-10-17 14:47:18 +08002202 XGL_UINT pos;
2203
2204 CMD_ASSERT(cmd, 6, 7.5);
2205
Chia-I Wu29e6f502014-11-24 14:27:29 +08002206 switch (meta->mode) {
2207 case INTEL_CMD_META_VS_POINTS:
2208 cmd_batch_pointer(cmd, 3, &dw);
2209 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_VERTEX_ELEMENTS) | (3 - 2);
2210 dw[1] = GEN6_VE_STATE_DW0_VALID;
2211 dw[2] = GEN6_VFCOMP_STORE_VID << GEN6_VE_STATE_DW1_COMP0__SHIFT |
2212 GEN6_VFCOMP_NOSTORE << GEN6_VE_STATE_DW1_COMP1__SHIFT |
2213 GEN6_VFCOMP_NOSTORE << GEN6_VE_STATE_DW1_COMP2__SHIFT |
2214 GEN6_VFCOMP_NOSTORE << GEN6_VE_STATE_DW1_COMP3__SHIFT;
2215 return;
2216 break;
2217 case INTEL_CMD_META_FS_RECT:
2218 {
2219 XGL_UINT vertices[3][2];
Chia-I Wu3adf7212014-10-24 15:34:07 +08002220
Chia-I Wu29e6f502014-11-24 14:27:29 +08002221 vertices[0][0] = meta->dst.x + meta->width;
2222 vertices[0][1] = meta->dst.y + meta->height;
2223 vertices[1][0] = meta->dst.x;
2224 vertices[1][1] = meta->dst.y + meta->height;
2225 vertices[2][0] = meta->dst.x;
2226 vertices[2][1] = meta->dst.y;
Chia-I Wu3adf7212014-10-24 15:34:07 +08002227
Chia-I Wu29e6f502014-11-24 14:27:29 +08002228 vb_start = cmd_state_write(cmd, INTEL_CMD_ITEM_BLOB, 32,
2229 sizeof(vertices) / 4, (const uint32_t *) vertices);
Chia-I Wu3adf7212014-10-24 15:34:07 +08002230
Chia-I Wu29e6f502014-11-24 14:27:29 +08002231 vb_end = vb_start + sizeof(vertices) - 1;
2232 vb_stride = sizeof(vertices[0]);
2233 ve_z_source = GEN6_VFCOMP_STORE_0;
2234 ve_format = GEN6_FORMAT_R32G32_USCALED;
2235 }
2236 break;
2237 case INTEL_CMD_META_DEPTH_STENCIL_RECT:
2238 {
2239 XGL_FLOAT vertices[3][3];
Chia-I Wu3adf7212014-10-24 15:34:07 +08002240
Chia-I Wu29e6f502014-11-24 14:27:29 +08002241 vertices[0][0] = (XGL_FLOAT) (meta->dst.x + meta->width);
2242 vertices[0][1] = (XGL_FLOAT) (meta->dst.y + meta->height);
2243 vertices[0][2] = u_uif(meta->clear_val[0]);
2244 vertices[1][0] = (XGL_FLOAT) meta->dst.x;
2245 vertices[1][1] = (XGL_FLOAT) (meta->dst.y + meta->height);
2246 vertices[1][2] = u_uif(meta->clear_val[0]);
2247 vertices[2][0] = (XGL_FLOAT) meta->dst.x;
2248 vertices[2][1] = (XGL_FLOAT) meta->dst.y;
2249 vertices[2][2] = u_uif(meta->clear_val[0]);
Chia-I Wu3adf7212014-10-24 15:34:07 +08002250
Chia-I Wu29e6f502014-11-24 14:27:29 +08002251 vb_start = cmd_state_write(cmd, INTEL_CMD_ITEM_BLOB, 32,
2252 sizeof(vertices) / 4, (const uint32_t *) vertices);
Chia-I Wu3adf7212014-10-24 15:34:07 +08002253
Chia-I Wu29e6f502014-11-24 14:27:29 +08002254 vb_end = vb_start + sizeof(vertices) - 1;
2255 vb_stride = sizeof(vertices[0]);
2256 ve_z_source = GEN6_VFCOMP_STORE_SRC;
2257 ve_format = GEN6_FORMAT_R32G32B32_FLOAT;
2258 }
2259 break;
2260 default:
2261 assert(!"unknown meta mode");
2262 return;
2263 break;
Chia-I Wu3adf7212014-10-24 15:34:07 +08002264 }
Chia-I Wu6032b892014-10-17 14:47:18 +08002265
2266 /* 3DSTATE_VERTEX_BUFFERS */
2267 pos = cmd_batch_pointer(cmd, 5, &dw);
Chia-I Wu3adf7212014-10-24 15:34:07 +08002268
Chia-I Wu6032b892014-10-17 14:47:18 +08002269 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_VERTEX_BUFFERS) | (5 - 2);
Chia-I Wu3adf7212014-10-24 15:34:07 +08002270 dw[1] = vb_stride;
Chia-I Wu6032b892014-10-17 14:47:18 +08002271 if (cmd_gen(cmd) >= INTEL_GEN(7))
2272 dw[1] |= GEN7_VB_STATE_DW0_ADDR_MODIFIED;
2273
2274 cmd_reserve_reloc(cmd, 2);
Chia-I Wu3adf7212014-10-24 15:34:07 +08002275 cmd_batch_reloc_writer(cmd, pos + 2, INTEL_CMD_WRITER_STATE, vb_start);
2276 cmd_batch_reloc_writer(cmd, pos + 3, INTEL_CMD_WRITER_STATE, vb_end);
Chia-I Wu6032b892014-10-17 14:47:18 +08002277
2278 dw[4] = 0;
2279
2280 /* 3DSTATE_VERTEX_ELEMENTS */
2281 cmd_batch_pointer(cmd, 5, &dw);
2282 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_VERTEX_ELEMENTS) | (5 - 2);
Chia-I Wu29e6f502014-11-24 14:27:29 +08002283 dw[1] = GEN6_VE_STATE_DW0_VALID;
Chia-I Wu6032b892014-10-17 14:47:18 +08002284 dw[2] = GEN6_VFCOMP_STORE_0 << GEN6_VE_STATE_DW1_COMP0__SHIFT | /* Reserved */
2285 GEN6_VFCOMP_STORE_0 << GEN6_VE_STATE_DW1_COMP1__SHIFT | /* Render Target Array Index */
2286 GEN6_VFCOMP_STORE_0 << GEN6_VE_STATE_DW1_COMP2__SHIFT | /* Viewport Index */
2287 GEN6_VFCOMP_STORE_0 << GEN6_VE_STATE_DW1_COMP3__SHIFT; /* Point Width */
2288 dw[3] = GEN6_VE_STATE_DW0_VALID |
Chia-I Wu3adf7212014-10-24 15:34:07 +08002289 ve_format << GEN6_VE_STATE_DW0_FORMAT__SHIFT;
Chia-I Wu6032b892014-10-17 14:47:18 +08002290 dw[4] = GEN6_VFCOMP_STORE_SRC << GEN6_VE_STATE_DW1_COMP0__SHIFT |
2291 GEN6_VFCOMP_STORE_SRC << GEN6_VE_STATE_DW1_COMP1__SHIFT |
Chia-I Wu3adf7212014-10-24 15:34:07 +08002292 ve_z_source << GEN6_VE_STATE_DW1_COMP2__SHIFT |
Chia-I Wu6032b892014-10-17 14:47:18 +08002293 GEN6_VFCOMP_STORE_1_FP << GEN6_VE_STATE_DW1_COMP3__SHIFT;
2294}
2295
Chia-I Wu29e6f502014-11-24 14:27:29 +08002296static uint32_t gen6_meta_vs_constants(struct intel_cmd *cmd)
Chia-I Wu6032b892014-10-17 14:47:18 +08002297{
Chia-I Wu3adf7212014-10-24 15:34:07 +08002298 const struct intel_cmd_meta *meta = cmd->bind.meta;
Chia-I Wu29e6f502014-11-24 14:27:29 +08002299 /* one GPR */
2300 XGL_UINT consts[8];
2301 XGL_UINT const_count;
2302
2303 CMD_ASSERT(cmd, 6, 7.5);
2304
2305 switch (meta->shader_id) {
2306 default:
2307 assert(!"unknown meta shader id");
2308 const_count = 0;
2309 break;
2310 }
2311
2312 /* this can be skipped but it makes state dumping prettier */
2313 memset(&consts[const_count], 0, sizeof(consts[0]) * (8 - const_count));
2314
2315 return cmd_state_write(cmd, INTEL_CMD_ITEM_BLOB, 32, 8, consts);
2316}
2317
2318static void gen6_meta_vs(struct intel_cmd *cmd)
2319{
2320 const struct intel_cmd_meta *meta = cmd->bind.meta;
2321 const struct intel_pipeline_shader *sh =
2322 intel_dev_get_meta_shader(cmd->dev, meta->shader_id);
2323 uint32_t offset, *dw;
2324
2325 CMD_ASSERT(cmd, 6, 7.5);
2326
2327 if (meta->mode != INTEL_CMD_META_VS_POINTS) {
2328 XGL_UINT cmd_len;
2329
2330 /* 3DSTATE_CONSTANT_VS */
2331 cmd_len = (cmd_gen(cmd) >= INTEL_GEN(7)) ? 7 : 5;
2332 cmd_batch_pointer(cmd, cmd_len, &dw);
2333 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_CONSTANT_VS) | (cmd_len - 2);
2334 memset(&dw[1], 0, sizeof(*dw) * (cmd_len - 1));
2335
2336 /* 3DSTATE_VS */
2337 cmd_batch_pointer(cmd, 6, &dw);
2338 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_VS) | (6 - 2);
2339 memset(&dw[1], 0, sizeof(*dw) * (6 - 1));
2340
2341 return;
2342 }
2343
2344 assert(meta->dst.valid && sh->uses == INTEL_SHADER_USE_VID);
2345
2346 /* 3DSTATE_CONSTANT_VS */
2347 offset = gen6_meta_vs_constants(cmd);
2348 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
2349 cmd_batch_pointer(cmd, 7, &dw);
2350 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_CONSTANT_VS) | (7 - 2);
2351 dw[1] = 1 << GEN7_PCB_ANY_DW1_PCB0_SIZE__SHIFT;
2352 dw[2] = 0;
2353 dw[3] = offset;
2354 dw[4] = 0;
2355 dw[5] = 0;
2356 dw[6] = 0;
2357 } else {
2358 cmd_batch_pointer(cmd, 5, &dw);
2359 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_CONSTANT_VS) | (5 - 2) |
2360 GEN6_PCB_ANY_DW0_PCB0_VALID;
2361 dw[1] = offset;
2362 dw[2] = 0;
2363 dw[3] = 0;
2364 dw[4] = 0;
2365 }
2366
2367 /* 3DSTATE_VS */
2368 offset = emit_shader(cmd, sh);
2369 cmd_batch_pointer(cmd, 6, &dw);
2370 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_VS) | (6 - 2);
2371 dw[1] = offset;
2372 dw[2] = GEN6_THREADDISP_SPF |
2373 (sh->sampler_count + 3) / 4 << GEN6_THREADDISP_SAMPLER_COUNT__SHIFT |
2374 sh->surface_count << GEN6_THREADDISP_BINDING_TABLE_SIZE__SHIFT;
2375 dw[3] = 0;
2376 dw[4] = sh->urb_grf_start << GEN6_VS_DW4_URB_GRF_START__SHIFT |
2377 1 << GEN6_VS_DW4_URB_READ_LEN__SHIFT;
2378
2379 dw[5] = GEN6_VS_DW5_CACHE_DISABLE |
2380 GEN6_VS_DW5_VS_ENABLE;
2381 if (cmd_gen(cmd) >= INTEL_GEN(7.5))
2382 dw[5] |= (70 - 1) << GEN75_VS_DW5_MAX_THREADS__SHIFT;
2383 else
2384 dw[5] |= (24 - 1) << GEN6_VS_DW5_MAX_THREADS__SHIFT;
2385}
2386
2387static void gen6_meta_disabled(struct intel_cmd *cmd)
2388{
Chia-I Wu6032b892014-10-17 14:47:18 +08002389 uint32_t *dw;
2390
2391 CMD_ASSERT(cmd, 6, 6);
2392
Chia-I Wu6032b892014-10-17 14:47:18 +08002393 /* 3DSTATE_CONSTANT_GS */
2394 cmd_batch_pointer(cmd, 5, &dw);
2395 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_CONSTANT_GS) | (5 - 2);
2396 dw[1] = 0;
2397 dw[2] = 0;
2398 dw[3] = 0;
2399 dw[4] = 0;
2400
2401 /* 3DSTATE_GS */
2402 cmd_batch_pointer(cmd, 7, &dw);
2403 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_GS) | (7 - 2);
2404 dw[1] = 0;
2405 dw[2] = 0;
2406 dw[3] = 0;
2407 dw[4] = 1 << GEN6_GS_DW4_URB_READ_LEN__SHIFT;
2408 dw[5] = GEN6_GS_DW5_STATISTICS;
2409 dw[6] = 0;
2410
Chia-I Wu6032b892014-10-17 14:47:18 +08002411 /* 3DSTATE_SF */
2412 cmd_batch_pointer(cmd, 20, &dw);
2413 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_SF) | (20 - 2);
2414 dw[1] = 1 << GEN7_SBE_DW1_URB_READ_LEN__SHIFT;
2415 memset(&dw[2], 0, 18 * sizeof(*dw));
2416}
2417
2418static void gen7_meta_disabled(struct intel_cmd *cmd)
2419{
2420 uint32_t *dw;
2421
2422 CMD_ASSERT(cmd, 7, 7.5);
2423
Chia-I Wu6032b892014-10-17 14:47:18 +08002424 /* 3DSTATE_CONSTANT_HS */
2425 cmd_batch_pointer(cmd, 7, &dw);
2426 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_CONSTANT_HS) | (7 - 2);
2427 memset(&dw[1], 0, sizeof(*dw) * (7 - 1));
2428
2429 /* 3DSTATE_HS */
2430 cmd_batch_pointer(cmd, 7, &dw);
2431 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_HS) | (7 - 2);
2432 memset(&dw[1], 0, sizeof(*dw) * (7 - 1));
2433
2434 /* 3DSTATE_TE */
2435 cmd_batch_pointer(cmd, 4, &dw);
2436 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_TE) | (4 - 2);
2437 memset(&dw[1], 0, sizeof(*dw) * (4 - 1));
2438
2439 /* 3DSTATE_CONSTANT_DS */
2440 cmd_batch_pointer(cmd, 7, &dw);
2441 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_CONSTANT_DS) | (7 - 2);
2442 memset(&dw[1], 0, sizeof(*dw) * (7 - 1));
2443
2444 /* 3DSTATE_DS */
2445 cmd_batch_pointer(cmd, 6, &dw);
2446 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_DS) | (6 - 2);
2447 memset(&dw[1], 0, sizeof(*dw) * (6 - 1));
2448
2449 /* 3DSTATE_CONSTANT_GS */
2450 cmd_batch_pointer(cmd, 7, &dw);
2451 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_CONSTANT_GS) | (7 - 2);
2452 memset(&dw[1], 0, sizeof(*dw) * (7 - 1));
2453
2454 /* 3DSTATE_GS */
2455 cmd_batch_pointer(cmd, 7, &dw);
2456 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_GS) | (7 - 2);
2457 memset(&dw[1], 0, sizeof(*dw) * (7 - 1));
2458
2459 /* 3DSTATE_STREAMOUT */
2460 cmd_batch_pointer(cmd, 3, &dw);
2461 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_STREAMOUT) | (3 - 2);
2462 memset(&dw[1], 0, sizeof(*dw) * (3 - 1));
2463
Chia-I Wu6032b892014-10-17 14:47:18 +08002464 /* 3DSTATE_SF */
2465 cmd_batch_pointer(cmd, 7, &dw);
2466 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_SF) | (7 - 2);
2467 memset(&dw[1], 0, sizeof(*dw) * (7 - 1));
2468
2469 /* 3DSTATE_SBE */
2470 cmd_batch_pointer(cmd, 14, &dw);
2471 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_SBE) | (14 - 2);
2472 dw[1] = 1 << GEN7_SBE_DW1_URB_READ_LEN__SHIFT;
2473 memset(&dw[2], 0, sizeof(*dw) * (14 - 2));
Chia-I Wu29e6f502014-11-24 14:27:29 +08002474}
Chia-I Wu3adf7212014-10-24 15:34:07 +08002475
Chia-I Wu29e6f502014-11-24 14:27:29 +08002476static void gen6_meta_clip(struct intel_cmd *cmd)
2477{
2478 const struct intel_cmd_meta *meta = cmd->bind.meta;
2479 uint32_t *dw;
Chia-I Wu3adf7212014-10-24 15:34:07 +08002480
Chia-I Wu29e6f502014-11-24 14:27:29 +08002481 /* 3DSTATE_CLIP */
2482 cmd_batch_pointer(cmd, 4, &dw);
2483 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_CLIP) | (4 - 2);
2484 dw[1] = 0;
2485 if (meta->mode == INTEL_CMD_META_VS_POINTS) {
2486 dw[2] = GEN6_CLIP_DW2_CLIP_ENABLE |
2487 GEN6_CLIP_DW2_CLIPMODE_REJECT_ALL;
2488 } else {
Chia-I Wu3adf7212014-10-24 15:34:07 +08002489 dw[2] = 0;
Chia-I Wu3adf7212014-10-24 15:34:07 +08002490 }
Chia-I Wu29e6f502014-11-24 14:27:29 +08002491 dw[3] = 0;
Chia-I Wu6032b892014-10-17 14:47:18 +08002492}
2493
2494static void gen6_meta_wm(struct intel_cmd *cmd)
2495{
2496 const struct intel_cmd_meta *meta = cmd->bind.meta;
2497 uint32_t *dw;
2498
2499 CMD_ASSERT(cmd, 6, 7.5);
2500
2501 cmd_wa_gen6_pre_multisample_depth_flush(cmd);
2502
2503 /* 3DSTATE_MULTISAMPLE */
2504 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
2505 cmd_batch_pointer(cmd, 4, &dw);
2506 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_MULTISAMPLE) | (4 - 2);
2507 dw[1] = (meta->samples <= 1) ? GEN6_MULTISAMPLE_DW1_NUMSAMPLES_1 :
2508 (meta->samples <= 4) ? GEN6_MULTISAMPLE_DW1_NUMSAMPLES_4 :
2509 GEN7_MULTISAMPLE_DW1_NUMSAMPLES_8;
2510 dw[2] = 0;
2511 dw[3] = 0;
2512 } else {
2513 cmd_batch_pointer(cmd, 3, &dw);
2514 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_MULTISAMPLE) | (3 - 2);
2515 dw[1] = (meta->samples <= 1) ? GEN6_MULTISAMPLE_DW1_NUMSAMPLES_1 :
2516 GEN6_MULTISAMPLE_DW1_NUMSAMPLES_4;
2517 dw[2] = 0;
2518 }
2519
2520 /* 3DSTATE_SAMPLE_MASK */
2521 cmd_batch_pointer(cmd, 2, &dw);
2522 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_SAMPLE_MASK) | (2 - 2);
2523 dw[1] = (1 << meta->samples) - 1;
2524
2525 /* 3DSTATE_DRAWING_RECTANGLE */
2526 cmd_batch_pointer(cmd, 4, &dw);
2527 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_DRAWING_RECTANGLE) | (4 - 2);
2528 dw[1] = meta->dst.y << 16 | meta->dst.x;
2529 dw[2] = (meta->dst.y + meta->height - 1) << 16 |
2530 (meta->dst.x + meta->width - 1);
2531 dw[3] = 0;
2532}
2533
2534static uint32_t gen6_meta_ps_constants(struct intel_cmd *cmd)
2535{
2536 const struct intel_cmd_meta *meta = cmd->bind.meta;
2537 XGL_UINT offset_x, offset_y;
2538 /* one GPR */
2539 XGL_UINT consts[8];
2540 XGL_UINT const_count;
2541
2542 CMD_ASSERT(cmd, 6, 7.5);
2543
2544 /* underflow is fine here */
2545 offset_x = meta->src.x - meta->dst.x;
2546 offset_y = meta->src.y - meta->dst.y;
2547
2548 switch (meta->shader_id) {
2549 case INTEL_DEV_META_FS_COPY_MEM:
2550 case INTEL_DEV_META_FS_COPY_1D:
2551 case INTEL_DEV_META_FS_COPY_1D_ARRAY:
2552 case INTEL_DEV_META_FS_COPY_2D:
2553 case INTEL_DEV_META_FS_COPY_2D_ARRAY:
2554 case INTEL_DEV_META_FS_COPY_2D_MS:
2555 consts[0] = offset_x;
2556 consts[1] = offset_y;
2557 consts[2] = meta->src.layer;
2558 consts[3] = meta->src.lod;
2559 const_count = 4;
2560 break;
2561 case INTEL_DEV_META_FS_COPY_1D_TO_MEM:
2562 case INTEL_DEV_META_FS_COPY_1D_ARRAY_TO_MEM:
2563 case INTEL_DEV_META_FS_COPY_2D_TO_MEM:
2564 case INTEL_DEV_META_FS_COPY_2D_ARRAY_TO_MEM:
2565 case INTEL_DEV_META_FS_COPY_2D_MS_TO_MEM:
2566 consts[0] = offset_x;
2567 consts[1] = offset_y;
2568 consts[2] = meta->src.layer;
2569 consts[3] = meta->src.lod;
2570 consts[4] = meta->src.x;
2571 consts[5] = meta->width;
2572 const_count = 6;
2573 break;
2574 case INTEL_DEV_META_FS_COPY_MEM_TO_IMG:
2575 consts[0] = offset_x;
2576 consts[1] = offset_y;
2577 consts[2] = meta->width;
2578 const_count = 3;
2579 break;
2580 case INTEL_DEV_META_FS_CLEAR_COLOR:
2581 consts[0] = meta->clear_val[0];
2582 consts[1] = meta->clear_val[1];
2583 consts[2] = meta->clear_val[2];
2584 consts[3] = meta->clear_val[3];
2585 const_count = 4;
2586 break;
2587 case INTEL_DEV_META_FS_CLEAR_DEPTH:
2588 consts[0] = meta->clear_val[0];
Chia-I Wu429a0aa2014-10-24 11:57:51 +08002589 consts[1] = meta->clear_val[1];
2590 const_count = 2;
Chia-I Wu6032b892014-10-17 14:47:18 +08002591 break;
2592 case INTEL_DEV_META_FS_RESOLVE_2X:
2593 case INTEL_DEV_META_FS_RESOLVE_4X:
2594 case INTEL_DEV_META_FS_RESOLVE_8X:
2595 case INTEL_DEV_META_FS_RESOLVE_16X:
2596 consts[0] = offset_x;
2597 consts[1] = offset_y;
2598 const_count = 2;
2599 break;
2600 default:
2601 assert(!"unknown meta shader id");
2602 const_count = 0;
2603 break;
2604 }
2605
2606 /* this can be skipped but it makes state dumping prettier */
2607 memset(&consts[const_count], 0, sizeof(consts[0]) * (8 - const_count));
2608
2609 return cmd_state_write(cmd, INTEL_CMD_ITEM_BLOB, 32, 8, consts);
2610}
2611
2612static void gen6_meta_ps(struct intel_cmd *cmd)
2613{
2614 const struct intel_cmd_meta *meta = cmd->bind.meta;
2615 const struct intel_pipeline_shader *sh =
2616 intel_dev_get_meta_shader(cmd->dev, meta->shader_id);
2617 uint32_t offset, *dw;
2618
2619 CMD_ASSERT(cmd, 6, 6);
2620
Chia-I Wu29e6f502014-11-24 14:27:29 +08002621 if (meta->mode != INTEL_CMD_META_FS_RECT) {
2622 /* 3DSTATE_CONSTANT_PS */
2623 cmd_batch_pointer(cmd, 5, &dw);
2624 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_CONSTANT_PS) | (5 - 2);
2625 dw[1] = 0;
2626 dw[2] = 0;
2627 dw[3] = 0;
2628 dw[4] = 0;
2629
2630 /* 3DSTATE_WM */
2631 cmd_batch_pointer(cmd, 9, &dw);
2632 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_WM) | (9 - 2);
2633 dw[1] = 0;
2634 dw[2] = 0;
2635 dw[3] = 0;
2636 dw[4] = 0;
2637 dw[5] = (40 - 1) << GEN6_WM_DW5_MAX_THREADS__SHIFT;
2638 dw[6] = 0;
2639 dw[7] = 0;
2640 dw[8] = 0;
2641
Chia-I Wu3adf7212014-10-24 15:34:07 +08002642 return;
Chia-I Wu29e6f502014-11-24 14:27:29 +08002643 }
2644
Chia-I Wu3adf7212014-10-24 15:34:07 +08002645 /* a normal color write */
2646 assert(meta->dst.valid && !sh->uses);
2647
Chia-I Wu6032b892014-10-17 14:47:18 +08002648 /* 3DSTATE_CONSTANT_PS */
2649 offset = gen6_meta_ps_constants(cmd);
2650 cmd_batch_pointer(cmd, 5, &dw);
2651 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_CONSTANT_PS) | (5 - 2) |
2652 GEN6_PCB_ANY_DW0_PCB0_VALID;
2653 dw[1] = offset;
2654 dw[2] = 0;
2655 dw[3] = 0;
2656 dw[4] = 0;
2657
2658 /* 3DSTATE_WM */
2659 offset = emit_shader(cmd, sh);
2660 cmd_batch_pointer(cmd, 9, &dw);
2661 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_WM) | (9 - 2);
2662 dw[1] = offset;
2663 dw[2] = (sh->sampler_count + 3) / 4 << GEN6_THREADDISP_SAMPLER_COUNT__SHIFT |
2664 sh->surface_count << GEN6_THREADDISP_BINDING_TABLE_SIZE__SHIFT;
2665 dw[3] = 0;
2666 dw[4] = sh->urb_grf_start << GEN6_WM_DW4_URB_GRF_START0__SHIFT;
2667 dw[5] = (40 - 1) << GEN6_WM_DW5_MAX_THREADS__SHIFT |
2668 GEN6_WM_DW5_PS_ENABLE |
Chia-I Wu005c47c2014-10-22 13:49:13 +08002669 GEN6_WM_DW5_16_PIXEL_DISPATCH;
2670
Chia-I Wu6032b892014-10-17 14:47:18 +08002671 dw[6] = sh->in_count << GEN6_WM_DW6_SF_ATTR_COUNT__SHIFT |
2672 GEN6_WM_DW6_POSOFFSET_NONE |
2673 GEN6_WM_DW6_ZW_INTERP_PIXEL |
2674 sh->barycentric_interps << GEN6_WM_DW6_BARYCENTRIC_INTERP__SHIFT |
2675 GEN6_WM_DW6_POINT_RASTRULE_UPPER_RIGHT;
2676 if (meta->samples > 1) {
2677 dw[6] |= GEN6_WM_DW6_MSRASTMODE_ON_PATTERN |
2678 GEN6_WM_DW6_MSDISPMODE_PERPIXEL;
2679 } else {
2680 dw[6] |= GEN6_WM_DW6_MSRASTMODE_OFF_PIXEL |
2681 GEN6_WM_DW6_MSDISPMODE_PERSAMPLE;
2682 }
2683 dw[7] = 0;
2684 dw[8] = 0;
2685}
2686
2687static void gen7_meta_ps(struct intel_cmd *cmd)
2688{
2689 const struct intel_cmd_meta *meta = cmd->bind.meta;
2690 const struct intel_pipeline_shader *sh =
2691 intel_dev_get_meta_shader(cmd->dev, meta->shader_id);
2692 uint32_t offset, *dw;
2693
2694 CMD_ASSERT(cmd, 7, 7.5);
2695
Chia-I Wu29e6f502014-11-24 14:27:29 +08002696 if (meta->mode != INTEL_CMD_META_FS_RECT) {
2697 /* 3DSTATE_WM */
2698 cmd_batch_pointer(cmd, 3, &dw);
2699 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_WM) | (3 - 2);
2700 memset(&dw[1], 0, sizeof(*dw) * (3 - 1));
2701
2702 /* 3DSTATE_CONSTANT_GS */
2703 cmd_batch_pointer(cmd, 7, &dw);
2704 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_CONSTANT_PS) | (7 - 2);
2705 memset(&dw[1], 0, sizeof(*dw) * (7 - 1));
2706
2707 /* 3DSTATE_PS */
2708 cmd_batch_pointer(cmd, 8, &dw);
2709 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_PS) | (8 - 2);
2710 dw[1] = 0;
2711 dw[2] = 0;
2712 dw[3] = 0;
2713 dw[4] = GEN7_PS_DW4_8_PIXEL_DISPATCH | /* required to avoid hangs */
2714 (48 - 1) << GEN7_PS_DW4_MAX_THREADS__SHIFT;
2715 dw[5] = 0;
2716 dw[6] = 0;
2717 dw[7] = 0;
2718
Chia-I Wu3adf7212014-10-24 15:34:07 +08002719 return;
Chia-I Wu29e6f502014-11-24 14:27:29 +08002720 }
2721
Chia-I Wu3adf7212014-10-24 15:34:07 +08002722 /* a normal color write */
2723 assert(meta->dst.valid && !sh->uses);
2724
Chia-I Wu6032b892014-10-17 14:47:18 +08002725 /* 3DSTATE_WM */
2726 cmd_batch_pointer(cmd, 3, &dw);
2727 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_WM) | (3 - 2);
2728 dw[1] = GEN7_WM_DW1_PS_ENABLE |
2729 GEN7_WM_DW1_ZW_INTERP_PIXEL |
2730 sh->barycentric_interps << GEN7_WM_DW1_BARYCENTRIC_INTERP__SHIFT |
2731 GEN7_WM_DW1_POINT_RASTRULE_UPPER_RIGHT;
2732 dw[2] = 0;
2733
2734 /* 3DSTATE_CONSTANT_PS */
2735 offset = gen6_meta_ps_constants(cmd);
2736 cmd_batch_pointer(cmd, 7, &dw);
2737 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_CONSTANT_PS) | (7 - 2);
2738 dw[1] = 1 << GEN7_PCB_ANY_DW1_PCB0_SIZE__SHIFT;
2739 dw[2] = 0;
2740 dw[3] = offset;
2741 dw[4] = 0;
2742 dw[5] = 0;
2743 dw[6] = 0;
2744
2745 /* 3DSTATE_PS */
2746 offset = emit_shader(cmd, sh);
2747 cmd_batch_pointer(cmd, 8, &dw);
2748 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_PS) | (8 - 2);
2749 dw[1] = offset;
2750 dw[2] = (sh->sampler_count + 3) / 4 << GEN6_THREADDISP_SAMPLER_COUNT__SHIFT |
2751 sh->surface_count << GEN6_THREADDISP_BINDING_TABLE_SIZE__SHIFT;
2752 dw[3] = 0;
2753
2754 dw[4] = GEN7_PS_DW4_PUSH_CONSTANT_ENABLE |
2755 GEN7_PS_DW4_POSOFFSET_NONE |
Chia-I Wu005c47c2014-10-22 13:49:13 +08002756 GEN7_PS_DW4_16_PIXEL_DISPATCH |
Chia-I Wu6032b892014-10-17 14:47:18 +08002757 (48 - 1) << GEN7_PS_DW4_MAX_THREADS__SHIFT;
2758 if (cmd_gen(cmd) >= INTEL_GEN(7.5))
2759 dw[4] |= ((1 << meta->samples) - 1) << GEN75_PS_DW4_SAMPLE_MASK__SHIFT;
2760
2761 dw[5] = sh->urb_grf_start << GEN7_PS_DW5_URB_GRF_START0__SHIFT;
2762 dw[6] = 0;
2763 dw[7] = 0;
2764}
2765
2766static void gen6_meta_depth_buffer(struct intel_cmd *cmd)
2767{
2768 const struct intel_cmd_meta *meta = cmd->bind.meta;
Chia-I Wu429a0aa2014-10-24 11:57:51 +08002769 const struct intel_ds_view *ds = meta->ds.view;
Chia-I Wu6032b892014-10-17 14:47:18 +08002770
2771 CMD_ASSERT(cmd, 6, 7.5);
2772
Chia-I Wube2f0ad2014-10-24 09:49:50 +08002773 if (!ds) {
2774 /* all zeros */
2775 static const struct intel_ds_view null_ds;
2776 ds = &null_ds;
Chia-I Wu6032b892014-10-17 14:47:18 +08002777 }
Chia-I Wube2f0ad2014-10-24 09:49:50 +08002778
2779 cmd_wa_gen6_pre_ds_flush(cmd);
2780 gen6_3DSTATE_DEPTH_BUFFER(cmd, ds);
2781 gen6_3DSTATE_STENCIL_BUFFER(cmd, ds);
2782 gen6_3DSTATE_HIER_DEPTH_BUFFER(cmd, ds);
2783
2784 if (cmd_gen(cmd) >= INTEL_GEN(7))
2785 gen7_3DSTATE_CLEAR_PARAMS(cmd, 0);
2786 else
2787 gen6_3DSTATE_CLEAR_PARAMS(cmd, 0);
Chia-I Wu6032b892014-10-17 14:47:18 +08002788}
2789
Chia-I Wuc29afdd2014-10-14 13:22:31 +08002790static void cmd_bind_graphics_pipeline(struct intel_cmd *cmd,
2791 const struct intel_pipeline *pipeline)
2792{
2793 cmd->bind.pipeline.graphics = pipeline;
2794}
2795
Chia-I Wu9f1722c2014-08-25 10:17:58 +08002796static void cmd_bind_compute_pipeline(struct intel_cmd *cmd,
2797 const struct intel_pipeline *pipeline)
2798{
2799 cmd->bind.pipeline.compute = pipeline;
2800}
2801
2802static void cmd_bind_graphics_delta(struct intel_cmd *cmd,
2803 const struct intel_pipeline_delta *delta)
2804{
2805 cmd->bind.pipeline.graphics_delta = delta;
2806}
2807
2808static void cmd_bind_compute_delta(struct intel_cmd *cmd,
2809 const struct intel_pipeline_delta *delta)
2810{
2811 cmd->bind.pipeline.compute_delta = delta;
2812}
2813
2814static void cmd_bind_graphics_dset(struct intel_cmd *cmd,
2815 const struct intel_dset *dset,
2816 XGL_UINT slot_offset)
2817{
2818 cmd->bind.dset.graphics = dset;
2819 cmd->bind.dset.graphics_offset = slot_offset;
2820}
2821
2822static void cmd_bind_compute_dset(struct intel_cmd *cmd,
2823 const struct intel_dset *dset,
2824 XGL_UINT slot_offset)
2825{
2826 cmd->bind.dset.compute = dset;
2827 cmd->bind.dset.compute_offset = slot_offset;
2828}
2829
2830static void cmd_bind_graphics_dyn_view(struct intel_cmd *cmd,
2831 const XGL_MEMORY_VIEW_ATTACH_INFO *info)
2832{
2833 intel_mem_view_init(&cmd->bind.dyn_view.graphics, cmd->dev, info);
2834}
2835
2836static void cmd_bind_compute_dyn_view(struct intel_cmd *cmd,
2837 const XGL_MEMORY_VIEW_ATTACH_INFO *info)
2838{
2839 intel_mem_view_init(&cmd->bind.dyn_view.compute, cmd->dev, info);
2840}
2841
Chia-I Wu3b04af52014-11-08 10:48:20 +08002842static void cmd_bind_vertex_data(struct intel_cmd *cmd,
2843 const struct intel_mem *mem,
2844 XGL_GPU_SIZE offset, XGL_UINT binding)
2845{
2846 if (binding >= ARRAY_SIZE(cmd->bind.vertex.mem)) {
2847 cmd->result = XGL_ERROR_UNKNOWN;
2848 return;
2849 }
2850
2851 cmd->bind.vertex.mem[binding] = mem;
2852 cmd->bind.vertex.offset[binding] = offset;
2853}
2854
Chia-I Wu9f1722c2014-08-25 10:17:58 +08002855static void cmd_bind_index_data(struct intel_cmd *cmd,
2856 const struct intel_mem *mem,
2857 XGL_GPU_SIZE offset, XGL_INDEX_TYPE type)
2858{
Chia-I Wuc29afdd2014-10-14 13:22:31 +08002859 cmd->bind.index.mem = mem;
2860 cmd->bind.index.offset = offset;
2861 cmd->bind.index.type = type;
Chia-I Wu9f1722c2014-08-25 10:17:58 +08002862}
2863
Chia-I Wu2e5ec9b2014-10-14 13:37:21 +08002864static void cmd_bind_attachments(struct intel_cmd *cmd,
2865 XGL_UINT rt_count,
2866 const XGL_COLOR_ATTACHMENT_BIND_INFO *rt_info,
2867 const XGL_DEPTH_STENCIL_BIND_INFO *ds_info)
Chia-I Wu9f1722c2014-08-25 10:17:58 +08002868{
Chia-I Wud88e02d2014-08-25 10:56:13 +08002869 XGL_UINT width = 0, height = 0;
Chia-I Wu9f1722c2014-08-25 10:17:58 +08002870 XGL_UINT i;
2871
Chia-I Wu2e5ec9b2014-10-14 13:37:21 +08002872 for (i = 0; i < rt_count; i++) {
2873 const XGL_COLOR_ATTACHMENT_BIND_INFO *att = &rt_info[i];
Chia-I Wu9f1722c2014-08-25 10:17:58 +08002874 const struct intel_rt_view *rt = intel_rt_view(att->view);
Chia-I Wud88e02d2014-08-25 10:56:13 +08002875 const struct intel_layout *layout = &rt->img->layout;
2876
2877 if (i == 0) {
2878 width = layout->width0;
2879 height = layout->height0;
2880 } else {
2881 if (width > layout->width0)
2882 width = layout->width0;
2883 if (height > layout->height0)
2884 height = layout->height0;
2885 }
Chia-I Wu9f1722c2014-08-25 10:17:58 +08002886
2887 cmd->bind.att.rt[i] = rt;
2888 }
2889
Chia-I Wu2e5ec9b2014-10-14 13:37:21 +08002890 cmd->bind.att.rt_count = rt_count;
Chia-I Wud88e02d2014-08-25 10:56:13 +08002891
Chia-I Wu2e5ec9b2014-10-14 13:37:21 +08002892 if (ds_info) {
2893 const struct intel_layout *layout;
Chia-I Wu9f1722c2014-08-25 10:17:58 +08002894
Chia-I Wu2e5ec9b2014-10-14 13:37:21 +08002895 cmd->bind.att.ds = intel_ds_view(ds_info->view);
2896 layout = &cmd->bind.att.ds->img->layout;
Chia-I Wu9f1722c2014-08-25 10:17:58 +08002897
Chia-I Wu2e5ec9b2014-10-14 13:37:21 +08002898 if (width > layout->width0)
2899 width = layout->width0;
2900 if (height > layout->height0)
2901 height = layout->height0;
Chia-I Wu9f1722c2014-08-25 10:17:58 +08002902 } else {
Chia-I Wu2e5ec9b2014-10-14 13:37:21 +08002903 cmd->bind.att.ds = NULL;
Chia-I Wu9f1722c2014-08-25 10:17:58 +08002904 }
2905
Chia-I Wu2e5ec9b2014-10-14 13:37:21 +08002906 cmd->bind.att.width = width;
2907 cmd->bind.att.height = height;
Chia-I Wu9f1722c2014-08-25 10:17:58 +08002908}
2909
2910static void cmd_bind_viewport_state(struct intel_cmd *cmd,
2911 const struct intel_viewport_state *state)
2912{
2913 cmd->bind.state.viewport = state;
2914}
2915
2916static void cmd_bind_raster_state(struct intel_cmd *cmd,
2917 const struct intel_raster_state *state)
2918{
2919 cmd->bind.state.raster = state;
2920}
2921
2922static void cmd_bind_ds_state(struct intel_cmd *cmd,
2923 const struct intel_ds_state *state)
2924{
2925 cmd->bind.state.ds = state;
2926}
2927
2928static void cmd_bind_blend_state(struct intel_cmd *cmd,
2929 const struct intel_blend_state *state)
2930{
2931 cmd->bind.state.blend = state;
2932}
2933
2934static void cmd_bind_msaa_state(struct intel_cmd *cmd,
2935 const struct intel_msaa_state *state)
2936{
2937 cmd->bind.state.msaa = state;
2938}
2939
2940static void cmd_draw(struct intel_cmd *cmd,
2941 XGL_UINT vertex_start,
2942 XGL_UINT vertex_count,
2943 XGL_UINT instance_start,
2944 XGL_UINT instance_count,
2945 bool indexed,
2946 XGL_UINT vertex_base)
2947{
2948 const struct intel_pipeline *p = cmd->bind.pipeline.graphics;
2949
2950 emit_bounded_states(cmd);
2951
2952 if (indexed) {
2953 if (p->primitive_restart && !gen6_can_primitive_restart(cmd))
2954 cmd->result = XGL_ERROR_UNKNOWN;
2955
2956 if (cmd_gen(cmd) >= INTEL_GEN(7.5)) {
2957 gen75_3DSTATE_VF(cmd, p->primitive_restart,
2958 p->primitive_restart_index);
Chia-I Wuc29afdd2014-10-14 13:22:31 +08002959 gen6_3DSTATE_INDEX_BUFFER(cmd, cmd->bind.index.mem,
2960 cmd->bind.index.offset, cmd->bind.index.type,
2961 false);
Chia-I Wu9f1722c2014-08-25 10:17:58 +08002962 } else {
2963 gen6_3DSTATE_INDEX_BUFFER(cmd, cmd->bind.index.mem,
2964 cmd->bind.index.offset, cmd->bind.index.type,
2965 p->primitive_restart);
2966 }
2967 } else {
2968 assert(!vertex_base);
2969 }
2970
2971 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
2972 gen7_3DPRIMITIVE(cmd, p->prim_type, indexed, vertex_count,
2973 vertex_start, instance_count, instance_start, vertex_base);
2974 } else {
2975 gen6_3DPRIMITIVE(cmd, p->prim_type, indexed, vertex_count,
2976 vertex_start, instance_count, instance_start, vertex_base);
2977 }
Chia-I Wu48c283d2014-08-25 23:13:46 +08002978
Chia-I Wu707a29e2014-08-27 12:51:47 +08002979 cmd->bind.draw_count++;
Chia-I Wu48c283d2014-08-25 23:13:46 +08002980 /* need to re-emit all workarounds */
2981 cmd->bind.wa_flags = 0;
Chia-I Wubeb07aa2014-11-22 02:58:40 +08002982
2983 if (intel_debug & INTEL_DEBUG_NOCACHE)
2984 cmd_batch_flush_all(cmd);
Chia-I Wu9f1722c2014-08-25 10:17:58 +08002985}
2986
Chia-I Wuc14d1562014-10-17 09:49:22 +08002987void cmd_draw_meta(struct intel_cmd *cmd, const struct intel_cmd_meta *meta)
2988{
Chia-I Wu6032b892014-10-17 14:47:18 +08002989 cmd->bind.meta = meta;
2990
2991 cmd_wa_gen6_pre_depth_stall_write(cmd);
Chia-I Wub4077f92014-10-28 11:19:14 +08002992 cmd_wa_gen6_pre_command_scoreboard_stall(cmd);
Chia-I Wu6032b892014-10-17 14:47:18 +08002993
2994 gen6_meta_dynamic_states(cmd);
2995 gen6_meta_surface_states(cmd);
2996
2997 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
2998 gen7_meta_urb(cmd);
2999 gen6_meta_vf(cmd);
Chia-I Wu29e6f502014-11-24 14:27:29 +08003000 gen6_meta_vs(cmd);
Chia-I Wu6032b892014-10-17 14:47:18 +08003001 gen7_meta_disabled(cmd);
Chia-I Wu29e6f502014-11-24 14:27:29 +08003002 gen6_meta_clip(cmd);
Chia-I Wu6032b892014-10-17 14:47:18 +08003003 gen6_meta_wm(cmd);
3004 gen7_meta_ps(cmd);
3005 gen6_meta_depth_buffer(cmd);
3006
3007 cmd_wa_gen7_post_command_cs_stall(cmd);
3008 cmd_wa_gen7_post_command_depth_stall(cmd);
3009
Chia-I Wu29e6f502014-11-24 14:27:29 +08003010 if (meta->mode == INTEL_CMD_META_VS_POINTS) {
3011 gen7_3DPRIMITIVE(cmd, GEN6_3DPRIM_POINTLIST, false,
3012 meta->width, 0, 1, 0, 0);
3013 } else {
3014 gen7_3DPRIMITIVE(cmd, GEN6_3DPRIM_RECTLIST, false, 3, 0, 1, 0, 0);
3015 }
Chia-I Wu6032b892014-10-17 14:47:18 +08003016 } else {
3017 gen6_meta_urb(cmd);
3018 gen6_meta_vf(cmd);
Chia-I Wu29e6f502014-11-24 14:27:29 +08003019 gen6_meta_vs(cmd);
Chia-I Wu6032b892014-10-17 14:47:18 +08003020 gen6_meta_disabled(cmd);
Chia-I Wu29e6f502014-11-24 14:27:29 +08003021 gen6_meta_clip(cmd);
Chia-I Wu6032b892014-10-17 14:47:18 +08003022 gen6_meta_wm(cmd);
3023 gen6_meta_ps(cmd);
3024 gen6_meta_depth_buffer(cmd);
3025
Chia-I Wu29e6f502014-11-24 14:27:29 +08003026 if (meta->mode == INTEL_CMD_META_VS_POINTS) {
3027 gen6_3DPRIMITIVE(cmd, GEN6_3DPRIM_POINTLIST, false,
3028 meta->width, 0, 1, 0, 0);
3029 } else {
3030 gen6_3DPRIMITIVE(cmd, GEN6_3DPRIM_RECTLIST, false, 3, 0, 1, 0, 0);
3031 }
Chia-I Wu6032b892014-10-17 14:47:18 +08003032 }
3033
3034 cmd->bind.draw_count++;
3035 /* need to re-emit all workarounds */
3036 cmd->bind.wa_flags = 0;
3037
3038 cmd->bind.meta = NULL;
Chia-I Wubeb07aa2014-11-22 02:58:40 +08003039
3040 if (intel_debug & INTEL_DEBUG_NOCACHE)
3041 cmd_batch_flush_all(cmd);
Chia-I Wuc14d1562014-10-17 09:49:22 +08003042}
3043
Chia-I Wub2755562014-08-20 13:38:52 +08003044XGL_VOID XGLAPI intelCmdBindPipeline(
3045 XGL_CMD_BUFFER cmdBuffer,
3046 XGL_PIPELINE_BIND_POINT pipelineBindPoint,
3047 XGL_PIPELINE pipeline)
3048{
3049 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
3050
3051 switch (pipelineBindPoint) {
3052 case XGL_PIPELINE_BIND_POINT_COMPUTE:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08003053 cmd_bind_compute_pipeline(cmd, intel_pipeline(pipeline));
Chia-I Wub2755562014-08-20 13:38:52 +08003054 break;
3055 case XGL_PIPELINE_BIND_POINT_GRAPHICS:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08003056 cmd_bind_graphics_pipeline(cmd, intel_pipeline(pipeline));
Chia-I Wub2755562014-08-20 13:38:52 +08003057 break;
3058 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08003059 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +08003060 break;
3061 }
3062}
3063
3064XGL_VOID XGLAPI intelCmdBindPipelineDelta(
3065 XGL_CMD_BUFFER cmdBuffer,
3066 XGL_PIPELINE_BIND_POINT pipelineBindPoint,
3067 XGL_PIPELINE_DELTA delta)
3068{
3069 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
3070
3071 switch (pipelineBindPoint) {
3072 case XGL_PIPELINE_BIND_POINT_COMPUTE:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08003073 cmd_bind_compute_delta(cmd, delta);
Chia-I Wub2755562014-08-20 13:38:52 +08003074 break;
3075 case XGL_PIPELINE_BIND_POINT_GRAPHICS:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08003076 cmd_bind_graphics_delta(cmd, delta);
Chia-I Wub2755562014-08-20 13:38:52 +08003077 break;
3078 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08003079 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +08003080 break;
3081 }
3082}
3083
3084XGL_VOID XGLAPI intelCmdBindStateObject(
3085 XGL_CMD_BUFFER cmdBuffer,
3086 XGL_STATE_BIND_POINT stateBindPoint,
3087 XGL_STATE_OBJECT state)
3088{
3089 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
3090
3091 switch (stateBindPoint) {
3092 case XGL_STATE_BIND_VIEWPORT:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08003093 cmd_bind_viewport_state(cmd,
3094 intel_viewport_state((XGL_VIEWPORT_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +08003095 break;
3096 case XGL_STATE_BIND_RASTER:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08003097 cmd_bind_raster_state(cmd,
3098 intel_raster_state((XGL_RASTER_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +08003099 break;
3100 case XGL_STATE_BIND_DEPTH_STENCIL:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08003101 cmd_bind_ds_state(cmd,
3102 intel_ds_state((XGL_DEPTH_STENCIL_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +08003103 break;
3104 case XGL_STATE_BIND_COLOR_BLEND:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08003105 cmd_bind_blend_state(cmd,
3106 intel_blend_state((XGL_COLOR_BLEND_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +08003107 break;
3108 case XGL_STATE_BIND_MSAA:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08003109 cmd_bind_msaa_state(cmd,
3110 intel_msaa_state((XGL_MSAA_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +08003111 break;
3112 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08003113 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +08003114 break;
3115 }
3116}
3117
3118XGL_VOID XGLAPI intelCmdBindDescriptorSet(
3119 XGL_CMD_BUFFER cmdBuffer,
3120 XGL_PIPELINE_BIND_POINT pipelineBindPoint,
3121 XGL_UINT index,
3122 XGL_DESCRIPTOR_SET descriptorSet,
3123 XGL_UINT slotOffset)
3124{
3125 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
3126 struct intel_dset *dset = intel_dset(descriptorSet);
3127
3128 assert(!index);
3129
3130 switch (pipelineBindPoint) {
3131 case XGL_PIPELINE_BIND_POINT_COMPUTE:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08003132 cmd_bind_compute_dset(cmd, dset, slotOffset);
Chia-I Wub2755562014-08-20 13:38:52 +08003133 break;
3134 case XGL_PIPELINE_BIND_POINT_GRAPHICS:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08003135 cmd_bind_graphics_dset(cmd, dset, slotOffset);
Chia-I Wub2755562014-08-20 13:38:52 +08003136 break;
3137 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08003138 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +08003139 break;
3140 }
3141}
3142
3143XGL_VOID XGLAPI intelCmdBindDynamicMemoryView(
3144 XGL_CMD_BUFFER cmdBuffer,
3145 XGL_PIPELINE_BIND_POINT pipelineBindPoint,
3146 const XGL_MEMORY_VIEW_ATTACH_INFO* pMemView)
3147{
3148 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
3149
3150 switch (pipelineBindPoint) {
3151 case XGL_PIPELINE_BIND_POINT_COMPUTE:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08003152 cmd_bind_compute_dyn_view(cmd, pMemView);
Chia-I Wub2755562014-08-20 13:38:52 +08003153 break;
3154 case XGL_PIPELINE_BIND_POINT_GRAPHICS:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08003155 cmd_bind_graphics_dyn_view(cmd, pMemView);
Chia-I Wub2755562014-08-20 13:38:52 +08003156 break;
3157 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08003158 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +08003159 break;
3160 }
3161}
3162
Chia-I Wu3b04af52014-11-08 10:48:20 +08003163XGL_VOID XGLAPI intelCmdBindVertexData(
3164 XGL_CMD_BUFFER cmdBuffer,
3165 XGL_GPU_MEMORY mem_,
3166 XGL_GPU_SIZE offset,
3167 XGL_UINT binding)
3168{
3169 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
3170 struct intel_mem *mem = intel_mem(mem_);
3171
3172 cmd_bind_vertex_data(cmd, mem, offset, binding);
3173}
3174
Chia-I Wub2755562014-08-20 13:38:52 +08003175XGL_VOID XGLAPI intelCmdBindIndexData(
3176 XGL_CMD_BUFFER cmdBuffer,
3177 XGL_GPU_MEMORY mem_,
3178 XGL_GPU_SIZE offset,
3179 XGL_INDEX_TYPE indexType)
3180{
3181 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
3182 struct intel_mem *mem = intel_mem(mem_);
3183
Chia-I Wu9f1722c2014-08-25 10:17:58 +08003184 cmd_bind_index_data(cmd, mem, offset, indexType);
Chia-I Wub2755562014-08-20 13:38:52 +08003185}
3186
3187XGL_VOID XGLAPI intelCmdBindAttachments(
3188 XGL_CMD_BUFFER cmdBuffer,
3189 XGL_UINT colorAttachmentCount,
3190 const XGL_COLOR_ATTACHMENT_BIND_INFO* pColorAttachments,
3191 const XGL_DEPTH_STENCIL_BIND_INFO* pDepthStencilAttachment)
3192{
3193 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
Chia-I Wub2755562014-08-20 13:38:52 +08003194
Chia-I Wu2e5ec9b2014-10-14 13:37:21 +08003195 cmd_bind_attachments(cmd, colorAttachmentCount, pColorAttachments,
3196 pDepthStencilAttachment);
Chia-I Wub2755562014-08-20 13:38:52 +08003197}
3198
3199XGL_VOID XGLAPI intelCmdDraw(
3200 XGL_CMD_BUFFER cmdBuffer,
3201 XGL_UINT firstVertex,
3202 XGL_UINT vertexCount,
3203 XGL_UINT firstInstance,
3204 XGL_UINT instanceCount)
3205{
Chia-I Wu59c097e2014-08-21 10:51:07 +08003206 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
Chia-I Wu59c097e2014-08-21 10:51:07 +08003207
Chia-I Wu9f1722c2014-08-25 10:17:58 +08003208 cmd_draw(cmd, firstVertex, vertexCount,
3209 firstInstance, instanceCount, false, 0);
Chia-I Wub2755562014-08-20 13:38:52 +08003210}
3211
3212XGL_VOID XGLAPI intelCmdDrawIndexed(
3213 XGL_CMD_BUFFER cmdBuffer,
3214 XGL_UINT firstIndex,
3215 XGL_UINT indexCount,
3216 XGL_INT vertexOffset,
3217 XGL_UINT firstInstance,
3218 XGL_UINT instanceCount)
3219{
Chia-I Wu59c097e2014-08-21 10:51:07 +08003220 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
Chia-I Wu59c097e2014-08-21 10:51:07 +08003221
Chia-I Wu9f1722c2014-08-25 10:17:58 +08003222 cmd_draw(cmd, firstIndex, indexCount,
3223 firstInstance, instanceCount, true, vertexOffset);
Chia-I Wub2755562014-08-20 13:38:52 +08003224}
3225
3226XGL_VOID XGLAPI intelCmdDrawIndirect(
3227 XGL_CMD_BUFFER cmdBuffer,
3228 XGL_GPU_MEMORY mem,
3229 XGL_GPU_SIZE offset,
3230 XGL_UINT32 count,
3231 XGL_UINT32 stride)
3232{
Chia-I Wu59c097e2014-08-21 10:51:07 +08003233 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
3234
3235 cmd->result = XGL_ERROR_UNKNOWN;
Chia-I Wub2755562014-08-20 13:38:52 +08003236}
3237
3238XGL_VOID XGLAPI intelCmdDrawIndexedIndirect(
3239 XGL_CMD_BUFFER cmdBuffer,
3240 XGL_GPU_MEMORY mem,
3241 XGL_GPU_SIZE offset,
3242 XGL_UINT32 count,
3243 XGL_UINT32 stride)
3244{
Chia-I Wu59c097e2014-08-21 10:51:07 +08003245 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
3246
3247 cmd->result = XGL_ERROR_UNKNOWN;
Chia-I Wub2755562014-08-20 13:38:52 +08003248}
3249
3250XGL_VOID XGLAPI intelCmdDispatch(
3251 XGL_CMD_BUFFER cmdBuffer,
3252 XGL_UINT x,
3253 XGL_UINT y,
3254 XGL_UINT z)
3255{
Chia-I Wu59c097e2014-08-21 10:51:07 +08003256 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
3257
3258 cmd->result = XGL_ERROR_UNKNOWN;
Chia-I Wub2755562014-08-20 13:38:52 +08003259}
3260
3261XGL_VOID XGLAPI intelCmdDispatchIndirect(
3262 XGL_CMD_BUFFER cmdBuffer,
3263 XGL_GPU_MEMORY mem,
3264 XGL_GPU_SIZE offset)
3265{
Chia-I Wu59c097e2014-08-21 10:51:07 +08003266 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
3267
3268 cmd->result = XGL_ERROR_UNKNOWN;
Chia-I Wub2755562014-08-20 13:38:52 +08003269}