blob: fe07f30414e33c569b5ff286d13d3a7cfb88ad19 [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.
23 */
24
Chia-I Wu9f039862014-08-20 15:39:56 +080025#include "genhw/genhw.h"
Chia-I Wub2755562014-08-20 13:38:52 +080026#include "dset.h"
Chia-I Wu7fae4e32014-08-21 11:39:44 +080027#include "img.h"
Chia-I Wub2755562014-08-20 13:38:52 +080028#include "mem.h"
Chia-I Wu018a3962014-08-21 10:37:52 +080029#include "pipeline.h"
Chia-I Wu1f2fd292014-08-29 15:07:09 +080030#include "shader.h"
Chia-I Wub2755562014-08-20 13:38:52 +080031#include "state.h"
32#include "view.h"
33#include "cmd_priv.h"
34
Chia-I Wu59c097e2014-08-21 10:51:07 +080035static void gen6_3DPRIMITIVE(struct intel_cmd *cmd,
Chia-I Wu254db422014-08-21 11:54:29 +080036 int prim_type, bool indexed,
Chia-I Wu59c097e2014-08-21 10:51:07 +080037 uint32_t vertex_count,
38 uint32_t vertex_start,
39 uint32_t instance_count,
40 uint32_t instance_start,
41 uint32_t vertex_base)
42{
43 const uint8_t cmd_len = 6;
44 uint32_t dw0;
45
46 CMD_ASSERT(cmd, 6, 6);
47
Chia-I Wu426072d2014-08-26 14:31:55 +080048 dw0 = GEN6_RENDER_CMD(3D, 3DPRIMITIVE) |
Chia-I Wu254db422014-08-21 11:54:29 +080049 prim_type << GEN6_3DPRIM_DW0_TYPE__SHIFT |
Chia-I Wu59c097e2014-08-21 10:51:07 +080050 (cmd_len - 2);
51
52 if (indexed)
53 dw0 |= GEN6_3DPRIM_DW0_ACCESS_RANDOM;
54
Chia-I Wue24c3292014-08-21 14:05:23 +080055 cmd_batch_reserve(cmd, cmd_len);
56 cmd_batch_write(cmd, dw0);
57 cmd_batch_write(cmd, vertex_count);
58 cmd_batch_write(cmd, vertex_start);
59 cmd_batch_write(cmd, instance_count);
60 cmd_batch_write(cmd, instance_start);
61 cmd_batch_write(cmd, vertex_base);
Chia-I Wu59c097e2014-08-21 10:51:07 +080062}
63
64static void gen7_3DPRIMITIVE(struct intel_cmd *cmd,
Chia-I Wu254db422014-08-21 11:54:29 +080065 int prim_type, bool indexed,
Chia-I Wu59c097e2014-08-21 10:51:07 +080066 uint32_t vertex_count,
67 uint32_t vertex_start,
68 uint32_t instance_count,
69 uint32_t instance_start,
70 uint32_t vertex_base)
71{
72 const uint8_t cmd_len = 7;
73 uint32_t dw0, dw1;
74
75 CMD_ASSERT(cmd, 7, 7.5);
76
Chia-I Wu426072d2014-08-26 14:31:55 +080077 dw0 = GEN6_RENDER_CMD(3D, 3DPRIMITIVE) | (cmd_len - 2);
Chia-I Wu254db422014-08-21 11:54:29 +080078 dw1 = prim_type << GEN7_3DPRIM_DW1_TYPE__SHIFT;
Chia-I Wu59c097e2014-08-21 10:51:07 +080079
80 if (indexed)
81 dw1 |= GEN7_3DPRIM_DW1_ACCESS_RANDOM;
82
Chia-I Wue24c3292014-08-21 14:05:23 +080083 cmd_batch_reserve(cmd, cmd_len);
84 cmd_batch_write(cmd, dw0);
85 cmd_batch_write(cmd, dw1);
86 cmd_batch_write(cmd, vertex_count);
87 cmd_batch_write(cmd, vertex_start);
88 cmd_batch_write(cmd, instance_count);
89 cmd_batch_write(cmd, instance_start);
90 cmd_batch_write(cmd, vertex_base);
Chia-I Wu59c097e2014-08-21 10:51:07 +080091}
92
Chia-I Wu270b1e82014-08-25 15:53:39 +080093static void gen6_PIPE_CONTROL(struct intel_cmd *cmd, uint32_t dw1,
94 struct intel_bo *bo, uint32_t bo_offset)
95{
96 const uint8_t cmd_len = 5;
Chia-I Wu426072d2014-08-26 14:31:55 +080097 const uint32_t dw0 = GEN6_RENDER_CMD(3D, PIPE_CONTROL) |
Chia-I Wu270b1e82014-08-25 15:53:39 +080098 (cmd_len - 2);
Chia-I Wu270b1e82014-08-25 15:53:39 +080099
100 CMD_ASSERT(cmd, 6, 7.5);
101
102 assert(bo_offset % 8 == 0);
103
104 if (dw1 & GEN6_PIPE_CONTROL_CS_STALL) {
105 /*
106 * From the Sandy Bridge PRM, volume 2 part 1, page 73:
107 *
108 * "1 of the following must also be set (when CS stall is set):
109 *
110 * * Depth Cache Flush Enable ([0] of DW1)
111 * * Stall at Pixel Scoreboard ([1] of DW1)
112 * * Depth Stall ([13] of DW1)
113 * * Post-Sync Operation ([13] of DW1)
114 * * Render Target Cache Flush Enable ([12] of DW1)
115 * * Notify Enable ([8] of DW1)"
116 *
117 * From the Ivy Bridge PRM, volume 2 part 1, page 61:
118 *
119 * "One of the following must also be set (when CS stall is set):
120 *
121 * * Render Target Cache Flush Enable ([12] of DW1)
122 * * Depth Cache Flush Enable ([0] of DW1)
123 * * Stall at Pixel Scoreboard ([1] of DW1)
124 * * Depth Stall ([13] of DW1)
125 * * Post-Sync Operation ([13] of DW1)"
126 */
127 uint32_t bit_test = GEN6_PIPE_CONTROL_RENDER_CACHE_FLUSH |
128 GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH |
129 GEN6_PIPE_CONTROL_PIXEL_SCOREBOARD_STALL |
130 GEN6_PIPE_CONTROL_DEPTH_STALL;
131
132 /* post-sync op */
133 bit_test |= GEN6_PIPE_CONTROL_WRITE_IMM |
134 GEN6_PIPE_CONTROL_WRITE_PS_DEPTH_COUNT |
135 GEN6_PIPE_CONTROL_WRITE_TIMESTAMP;
136
137 if (cmd_gen(cmd) == INTEL_GEN(6))
138 bit_test |= GEN6_PIPE_CONTROL_NOTIFY_ENABLE;
139
140 assert(dw1 & bit_test);
141 }
142
143 if (dw1 & GEN6_PIPE_CONTROL_DEPTH_STALL) {
144 /*
145 * From the Sandy Bridge PRM, volume 2 part 1, page 73:
146 *
147 * "Following bits must be clear (when Depth Stall is set):
148 *
149 * * Render Target Cache Flush Enable ([12] of DW1)
150 * * Depth Cache Flush Enable ([0] of DW1)"
151 */
152 assert(!(dw1 & (GEN6_PIPE_CONTROL_RENDER_CACHE_FLUSH |
153 GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH)));
154 }
155
156 /*
157 * From the Sandy Bridge PRM, volume 1 part 3, page 19:
158 *
159 * "[DevSNB] PPGTT memory writes by MI_* (such as MI_STORE_DATA_IMM)
160 * and PIPE_CONTROL are not supported."
161 *
162 * The kernel will add the mapping automatically (when write domain is
163 * INTEL_DOMAIN_INSTRUCTION).
164 */
165 if (cmd_gen(cmd) == INTEL_GEN(6) && bo)
166 bo_offset |= GEN6_PIPE_CONTROL_DW2_USE_GGTT;
167
168 cmd_batch_reserve_reloc(cmd, cmd_len, (bool) bo);
169 cmd_batch_write(cmd, dw0);
170 cmd_batch_write(cmd, dw1);
Chia-I Wu32a22462014-08-26 14:13:46 +0800171 if (bo) {
172 cmd_batch_reloc(cmd, bo_offset, bo, INTEL_RELOC_GGTT |
173 INTEL_RELOC_WRITE);
174 } else {
Chia-I Wu270b1e82014-08-25 15:53:39 +0800175 cmd_batch_write(cmd, 0);
Chia-I Wu32a22462014-08-26 14:13:46 +0800176 }
Chia-I Wu270b1e82014-08-25 15:53:39 +0800177 cmd_batch_write(cmd, 0);
178 cmd_batch_write(cmd, 0);
179}
180
Chia-I Wu254db422014-08-21 11:54:29 +0800181static bool gen6_can_primitive_restart(const struct intel_cmd *cmd)
182{
183 const struct intel_pipeline *p = cmd->bind.pipeline.graphics;
184 bool supported;
185
186 CMD_ASSERT(cmd, 6, 7.5);
187
188 if (cmd_gen(cmd) >= INTEL_GEN(7.5))
189 return (p->prim_type != GEN6_3DPRIM_RECTLIST);
190
191 switch (p->prim_type) {
192 case GEN6_3DPRIM_POINTLIST:
193 case GEN6_3DPRIM_LINELIST:
194 case GEN6_3DPRIM_LINESTRIP:
195 case GEN6_3DPRIM_TRILIST:
196 case GEN6_3DPRIM_TRISTRIP:
197 supported = true;
198 break;
199 default:
200 supported = false;
201 break;
202 }
203
204 if (!supported)
205 return false;
206
207 switch (cmd->bind.index.type) {
208 case XGL_INDEX_8:
209 supported = (p->primitive_restart_index != 0xffu);
210 break;
211 case XGL_INDEX_16:
212 supported = (p->primitive_restart_index != 0xffffu);
213 break;
214 case XGL_INDEX_32:
215 supported = (p->primitive_restart_index != 0xffffffffu);
216 break;
217 default:
218 supported = false;
219 break;
220 }
221
222 return supported;
223}
224
Chia-I Wu59c097e2014-08-21 10:51:07 +0800225static void gen6_3DSTATE_INDEX_BUFFER(struct intel_cmd *cmd,
Chia-I Wu958d1b72014-08-21 11:28:11 +0800226 const struct intel_mem *mem,
Chia-I Wu59c097e2014-08-21 10:51:07 +0800227 XGL_GPU_SIZE offset,
228 XGL_INDEX_TYPE type,
229 bool enable_cut_index)
230{
231 const uint8_t cmd_len = 3;
232 uint32_t dw0, end_offset;
233 unsigned offset_align;
234
235 CMD_ASSERT(cmd, 6, 7.5);
236
Chia-I Wu426072d2014-08-26 14:31:55 +0800237 dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_INDEX_BUFFER) | (cmd_len - 2);
Chia-I Wu59c097e2014-08-21 10:51:07 +0800238
239 /* the bit is moved to 3DSTATE_VF */
240 if (cmd_gen(cmd) >= INTEL_GEN(7.5))
241 assert(!enable_cut_index);
242 if (enable_cut_index)
243 dw0 |= GEN6_IB_DW0_CUT_INDEX_ENABLE;
244
245 switch (type) {
246 case XGL_INDEX_8:
247 dw0 |= GEN6_IB_DW0_FORMAT_BYTE;
248 offset_align = 1;
249 break;
250 case XGL_INDEX_16:
251 dw0 |= GEN6_IB_DW0_FORMAT_WORD;
252 offset_align = 2;
253 break;
254 case XGL_INDEX_32:
255 dw0 |= GEN6_IB_DW0_FORMAT_DWORD;
256 offset_align = 4;
257 break;
258 default:
259 cmd->result = XGL_ERROR_INVALID_VALUE;
260 return;
261 break;
262 }
263
264 if (offset % offset_align) {
265 cmd->result = XGL_ERROR_INVALID_VALUE;
266 return;
267 }
268
269 /* aligned and inclusive */
270 end_offset = mem->size - (mem->size % offset_align) - 1;
271
Chia-I Wu2de65d02014-08-25 10:02:53 +0800272 cmd_batch_reserve_reloc(cmd, cmd_len, 2);
Chia-I Wue24c3292014-08-21 14:05:23 +0800273 cmd_batch_write(cmd, dw0);
Chia-I Wu32a22462014-08-26 14:13:46 +0800274 cmd_batch_reloc(cmd, offset, mem->bo, 0);
275 cmd_batch_reloc(cmd, end_offset, mem->bo, 0);
Chia-I Wu59c097e2014-08-21 10:51:07 +0800276}
277
Chia-I Wu62a7f252014-08-29 11:31:16 +0800278static void gen75_3DSTATE_VF(struct intel_cmd *cmd,
279 bool enable_cut_index,
280 uint32_t cut_index)
Chia-I Wu254db422014-08-21 11:54:29 +0800281{
282 const uint8_t cmd_len = 2;
283 uint32_t dw0;
284
285 CMD_ASSERT(cmd, 7.5, 7.5);
286
Chia-I Wu426072d2014-08-26 14:31:55 +0800287 dw0 = GEN75_RENDER_CMD(3D, 3DSTATE_VF) | (cmd_len - 2);
Chia-I Wu254db422014-08-21 11:54:29 +0800288 if (enable_cut_index)
289 dw0 |= GEN75_VF_DW0_CUT_INDEX_ENABLE;
290
Chia-I Wue24c3292014-08-21 14:05:23 +0800291 cmd_batch_reserve(cmd, cmd_len);
292 cmd_batch_write(cmd, dw0);
293 cmd_batch_write(cmd, cut_index);
Chia-I Wu254db422014-08-21 11:54:29 +0800294}
295
Chia-I Wud95aa2b2014-08-29 12:07:47 +0800296static void gen6_3DSTATE_GS(struct intel_cmd *cmd)
297{
298 const uint8_t cmd_len = 7;
299 const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_GS) | (cmd_len - 2);
300
301 CMD_ASSERT(cmd, 6, 6);
302
303 assert(cmd->bind.gs.shader == NULL);
304
305 cmd_batch_reserve(cmd, cmd_len);
306 cmd_batch_write(cmd, dw0);
307 cmd_batch_write(cmd, 0);
308 cmd_batch_write(cmd, 0);
309 cmd_batch_write(cmd, 0);
310 cmd_batch_write(cmd, 1 << GEN6_GS_DW4_URB_READ_LEN__SHIFT);
311 cmd_batch_write(cmd, GEN6_GS_DW5_STATISTICS);
312 cmd_batch_write(cmd, 0);
313}
314
Chia-I Wu62a7f252014-08-29 11:31:16 +0800315static void gen7_3DSTATE_GS(struct intel_cmd *cmd)
316{
317 const uint8_t cmd_len = 7;
318 const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_GS) | (cmd_len - 2);
319
320 CMD_ASSERT(cmd, 7, 7.5);
321
322 assert(cmd->bind.gs.shader == NULL);
323
324 cmd_batch_reserve(cmd, cmd_len);
325 cmd_batch_write(cmd, dw0);
326 cmd_batch_write(cmd, 0);
327 cmd_batch_write(cmd, 0);
328 cmd_batch_write(cmd, 0);
329 cmd_batch_write(cmd, 0);
330 cmd_batch_write(cmd, GEN6_GS_DW5_STATISTICS);
331 cmd_batch_write(cmd, 0);
332}
333
Chia-I Wud88e02d2014-08-25 10:56:13 +0800334static void gen6_3DSTATE_DRAWING_RECTANGLE(struct intel_cmd *cmd,
335 XGL_UINT width, XGL_UINT height)
336{
337 const uint8_t cmd_len = 4;
Chia-I Wu426072d2014-08-26 14:31:55 +0800338 const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_DRAWING_RECTANGLE) |
Chia-I Wud88e02d2014-08-25 10:56:13 +0800339 (cmd_len - 2);
340
341 CMD_ASSERT(cmd, 6, 7.5);
342
343 cmd_batch_reserve(cmd, cmd_len);
344 cmd_batch_write(cmd, dw0);
345 if (width && height) {
346 cmd_batch_write(cmd, 0);
347 cmd_batch_write(cmd, (height - 1) << 16 |
348 (width - 1));
349 } else {
350 cmd_batch_write(cmd, 1);
351 cmd_batch_write(cmd, 0);
352 }
353 cmd_batch_write(cmd, 0);
354}
355
Chia-I Wu1f2fd292014-08-29 15:07:09 +0800356static void gen6_3DSTATE_WM(struct intel_cmd *cmd)
357{
358 const int max_threads = (cmd->dev->gpu->gt == 2) ? 80 : 40;
359 const struct intel_pipeline *pipeline = cmd->bind.pipeline.graphics;
360 const struct intel_shader *fs = intel_shader(pipeline->fs.shader);
361 const struct intel_msaa_state *msaa = cmd->bind.state.msaa;
362 const uint8_t cmd_len = 9;
363 uint32_t dw0, dw2, dw4, dw5, dw6;
364
365 CMD_ASSERT(cmd, 6, 6);
366
367 dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_WM) | (cmd_len - 2);
368
369 dw2 = (fs->sampler_count + 3) / 4 << GEN6_THREADDISP_SAMPLER_COUNT__SHIFT |
370 fs->surface_count << GEN6_THREADDISP_BINDING_TABLE_SIZE__SHIFT;
371
372 dw4 = GEN6_WM_DW4_STATISTICS |
373 fs->urb_grf_start << GEN6_WM_DW4_URB_GRF_START0__SHIFT |
374 0 << GEN6_WM_DW4_URB_GRF_START1__SHIFT |
375 0 << GEN6_WM_DW4_URB_GRF_START2__SHIFT;
376
377 dw5 = (max_threads - 1) << GEN6_WM_DW5_MAX_THREADS__SHIFT |
378 GEN6_WM_DW5_PS_ENABLE |
379 GEN6_WM_DW5_8_PIXEL_DISPATCH;
380
381 if (fs->uses & INTEL_SHADER_USE_KILL ||
382 pipeline->cb_state.alphaToCoverageEnable)
383 dw5 |= GEN6_WM_DW5_PS_KILL;
384
385 if (fs->uses & INTEL_SHADER_USE_COMPUTED_DEPTH)
386 dw5 |= GEN6_WM_DW5_PS_COMPUTE_DEPTH;
387 if (fs->uses & INTEL_SHADER_USE_DEPTH)
388 dw5 |= GEN6_WM_DW5_PS_USE_DEPTH;
389 if (fs->uses & INTEL_SHADER_USE_W)
390 dw5 |= GEN6_WM_DW5_PS_USE_W;
391
392 if (pipeline->cb_state.dualSourceBlendEnable)
393 dw5 |= GEN6_WM_DW5_DUAL_SOURCE_BLEND;
394
395 dw6 = fs->in_count << GEN6_WM_DW6_SF_ATTR_COUNT__SHIFT |
396 GEN6_WM_DW6_POSOFFSET_NONE |
397 GEN6_WM_DW6_ZW_INTERP_PIXEL |
398 fs->barycentric_interps << GEN6_WM_DW6_BARYCENTRIC_INTERP__SHIFT |
399 GEN6_WM_DW6_POINT_RASTRULE_UPPER_RIGHT;
400
401 if (msaa->sample_count > 1) {
402 dw6 |= GEN6_WM_DW6_MSRASTMODE_ON_PATTERN |
403 GEN6_WM_DW6_MSDISPMODE_PERPIXEL;
404 } else {
405 dw6 |= GEN6_WM_DW6_MSRASTMODE_OFF_PIXEL |
406 GEN6_WM_DW6_MSDISPMODE_PERSAMPLE;
407 }
408
409 cmd_batch_reserve(cmd, cmd_len);
410 cmd_batch_write(cmd, dw0);
411 cmd_batch_write(cmd, cmd->bind.fs.kernel_pos << 2);
412 cmd_batch_write(cmd, dw2);
413 cmd_batch_write(cmd, 0); /* scratch */
414 cmd_batch_write(cmd, dw4);
415 cmd_batch_write(cmd, dw5);
416 cmd_batch_write(cmd, dw6);
417 cmd_batch_write(cmd, 0); /* kernel 1 */
418 cmd_batch_write(cmd, 0); /* kernel 2 */
419}
420
421static void gen7_3DSTATE_WM(struct intel_cmd *cmd)
422{
423 const struct intel_pipeline *pipeline = cmd->bind.pipeline.graphics;
424 const struct intel_shader *fs = intel_shader(pipeline->fs.shader);
425 const struct intel_msaa_state *msaa = cmd->bind.state.msaa;
426 const uint8_t cmd_len = 3;
427 uint32_t dw0, dw1, dw2;
428
429 CMD_ASSERT(cmd, 7, 7.5);
430
431 dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_WM) | (cmd_len - 2);
432
433 dw1 = GEN7_WM_DW1_STATISTICS |
434 GEN7_WM_DW1_PS_ENABLE |
435 GEN7_WM_DW1_ZW_INTERP_PIXEL |
436 fs->barycentric_interps << GEN7_WM_DW1_BARYCENTRIC_INTERP__SHIFT |
437 GEN7_WM_DW1_POINT_RASTRULE_UPPER_RIGHT;
438
439 if (fs->uses & INTEL_SHADER_USE_KILL ||
440 pipeline->cb_state.alphaToCoverageEnable)
441 dw1 |= GEN7_WM_DW1_PS_KILL;
442
443 if (fs->uses & INTEL_SHADER_USE_COMPUTED_DEPTH)
444 dw1 |= GEN7_WM_DW1_PSCDEPTH_ON;
445 if (fs->uses & INTEL_SHADER_USE_DEPTH)
446 dw1 |= GEN7_WM_DW1_PS_USE_DEPTH;
447 if (fs->uses & INTEL_SHADER_USE_W)
448 dw1 |= GEN7_WM_DW1_PS_USE_W;
449
450 dw2 = 0;
451
452 if (msaa->sample_count > 1) {
453 dw1 |= GEN7_WM_DW1_MSRASTMODE_ON_PATTERN;
454 dw2 |= GEN7_WM_DW2_MSDISPMODE_PERPIXEL;
455 } else {
456 dw1 |= GEN7_WM_DW1_MSRASTMODE_OFF_PIXEL;
457 dw2 |= GEN7_WM_DW2_MSDISPMODE_PERSAMPLE;
458 }
459
460 cmd_batch_reserve(cmd, cmd_len);
461 cmd_batch_write(cmd, dw0);
462 cmd_batch_write(cmd, dw1);
463 cmd_batch_write(cmd, dw2);
464}
465
466static void gen7_3DSTATE_PS(struct intel_cmd *cmd)
467{
468 const struct intel_pipeline *pipeline = cmd->bind.pipeline.graphics;
469 const struct intel_shader *fs = intel_shader(pipeline->fs.shader);
470 const struct intel_msaa_state *msaa = cmd->bind.state.msaa;
471 const uint8_t cmd_len = 8;
472 uint32_t dw0, dw2, dw4, dw5;
473
474 CMD_ASSERT(cmd, 7, 7.5);
475
476 dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_PS) | (cmd_len - 2);
477
478 dw2 = (fs->sampler_count + 3) / 4 << GEN6_THREADDISP_SAMPLER_COUNT__SHIFT |
479 fs->surface_count << GEN6_THREADDISP_BINDING_TABLE_SIZE__SHIFT;
480
481 dw4 = GEN7_PS_DW4_POSOFFSET_NONE |
482 GEN7_PS_DW4_8_PIXEL_DISPATCH;
483
484 if (cmd_gen(cmd) >= INTEL_GEN(7.5)) {
485 const int max_threads =
486 (cmd->dev->gpu->gt == 3) ? 408 :
487 (cmd->dev->gpu->gt == 2) ? 204 : 102;
488 dw4 |= (max_threads - 1) << GEN75_PS_DW4_MAX_THREADS__SHIFT;
489 dw4 |= msaa->cmd[msaa->cmd_len - 1] << GEN75_PS_DW4_SAMPLE_MASK__SHIFT;
490 } else {
491 const int max_threads = (cmd->dev->gpu->gt == 2) ? 172 : 48;
492 dw4 |= (max_threads - 1) << GEN7_PS_DW4_MAX_THREADS__SHIFT;
493 }
494
495 if (pipeline->fs.linkConstBufferCount)
496 dw4 |= GEN7_PS_DW4_PUSH_CONSTANT_ENABLE;
497
498 if (fs->in_count)
499 dw4 |= GEN7_PS_DW4_ATTR_ENABLE;
500
501 if (pipeline->cb_state.dualSourceBlendEnable)
502 dw4 |= GEN7_PS_DW4_DUAL_SOURCE_BLEND;
503
504 dw5 = fs->urb_grf_start << GEN7_PS_DW5_URB_GRF_START0__SHIFT |
505 0 << GEN7_PS_DW5_URB_GRF_START1__SHIFT |
506 0 << GEN7_PS_DW5_URB_GRF_START2__SHIFT;
507
508 cmd_batch_reserve(cmd, cmd_len);
509 cmd_batch_write(cmd, dw0);
510 cmd_batch_write(cmd, cmd->bind.fs.kernel_pos << 2);
511 cmd_batch_write(cmd, dw2);
512 cmd_batch_write(cmd, 0); /* scratch */
513 cmd_batch_write(cmd, dw4);
514 cmd_batch_write(cmd, dw5);
515 cmd_batch_write(cmd, 0); /* kernel 1 */
516 cmd_batch_write(cmd, 0); /* kernel 2 */
517}
518
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800519static void gen6_3DSTATE_DEPTH_BUFFER(struct intel_cmd *cmd,
520 const struct intel_ds_view *view)
521{
522 const uint8_t cmd_len = 7;
523 uint32_t dw0;
524
525 CMD_ASSERT(cmd, 6, 7.5);
526
527 dw0 = (cmd_gen(cmd) >= INTEL_GEN(7)) ?
Chia-I Wu426072d2014-08-26 14:31:55 +0800528 GEN7_RENDER_CMD(3D, 3DSTATE_DEPTH_BUFFER) :
529 GEN6_RENDER_CMD(3D, 3DSTATE_DEPTH_BUFFER);
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800530 dw0 |= (cmd_len - 2);
531
Chia-I Wu2de65d02014-08-25 10:02:53 +0800532 cmd_batch_reserve_reloc(cmd, cmd_len, (bool) view->img);
Chia-I Wue24c3292014-08-21 14:05:23 +0800533 cmd_batch_write(cmd, dw0);
534 cmd_batch_write(cmd, view->cmd[0]);
Courtney Goeltzenleuchtere316d972014-08-22 16:25:24 -0600535 if (view->img) {
Chia-I Wu9ee38722014-08-25 12:11:36 +0800536 cmd_batch_reloc(cmd, view->cmd[1], view->img->obj.mem->bo,
Chia-I Wu32a22462014-08-26 14:13:46 +0800537 INTEL_RELOC_WRITE);
Courtney Goeltzenleuchtere316d972014-08-22 16:25:24 -0600538 } else {
539 cmd_batch_write(cmd, 0);
540 }
Chia-I Wue24c3292014-08-21 14:05:23 +0800541 cmd_batch_write(cmd, view->cmd[2]);
542 cmd_batch_write(cmd, view->cmd[3]);
543 cmd_batch_write(cmd, view->cmd[4]);
544 cmd_batch_write(cmd, view->cmd[5]);
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800545}
546
547static void gen6_3DSTATE_STENCIL_BUFFER(struct intel_cmd *cmd,
548 const struct intel_ds_view *view)
549{
550 const uint8_t cmd_len = 3;
551 uint32_t dw0;
552
553 CMD_ASSERT(cmd, 6, 7.5);
554
555 dw0 = (cmd_gen(cmd) >= INTEL_GEN(7)) ?
Chia-I Wu426072d2014-08-26 14:31:55 +0800556 GEN7_RENDER_CMD(3D, 3DSTATE_STENCIL_BUFFER) :
557 GEN6_RENDER_CMD(3D, 3DSTATE_STENCIL_BUFFER);
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800558 dw0 |= (cmd_len - 2);
559
Chia-I Wu2de65d02014-08-25 10:02:53 +0800560 cmd_batch_reserve_reloc(cmd, cmd_len, (bool) view->img);
Chia-I Wue24c3292014-08-21 14:05:23 +0800561 cmd_batch_write(cmd, dw0);
562 cmd_batch_write(cmd, view->cmd[6]);
Courtney Goeltzenleuchtere316d972014-08-22 16:25:24 -0600563 if (view->img) {
Chia-I Wu9ee38722014-08-25 12:11:36 +0800564 cmd_batch_reloc(cmd, view->cmd[7], view->img->obj.mem->bo,
Chia-I Wu32a22462014-08-26 14:13:46 +0800565 INTEL_RELOC_WRITE);
Courtney Goeltzenleuchtere316d972014-08-22 16:25:24 -0600566 } else {
567 cmd_batch_write(cmd, 0);
568 }
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800569}
570
571static void gen6_3DSTATE_HIER_DEPTH_BUFFER(struct intel_cmd *cmd,
572 const struct intel_ds_view *view)
573{
574 const uint8_t cmd_len = 3;
575 uint32_t dw0;
576
577 CMD_ASSERT(cmd, 6, 7.5);
578
579 dw0 = (cmd_gen(cmd) >= INTEL_GEN(7)) ?
Chia-I Wu426072d2014-08-26 14:31:55 +0800580 GEN7_RENDER_CMD(3D, 3DSTATE_HIER_DEPTH_BUFFER) :
581 GEN6_RENDER_CMD(3D, 3DSTATE_HIER_DEPTH_BUFFER);
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800582 dw0 |= (cmd_len - 2);
583
Chia-I Wu2de65d02014-08-25 10:02:53 +0800584 cmd_batch_reserve_reloc(cmd, cmd_len, (bool) view->img);
Chia-I Wue24c3292014-08-21 14:05:23 +0800585 cmd_batch_write(cmd, dw0);
586 cmd_batch_write(cmd, view->cmd[8]);
Courtney Goeltzenleuchtere316d972014-08-22 16:25:24 -0600587 if (view->img) {
Chia-I Wu9ee38722014-08-25 12:11:36 +0800588 cmd_batch_reloc(cmd, view->cmd[9], view->img->obj.mem->bo,
Chia-I Wu32a22462014-08-26 14:13:46 +0800589 INTEL_RELOC_WRITE);
Courtney Goeltzenleuchtere316d972014-08-22 16:25:24 -0600590 } else {
591 cmd_batch_write(cmd, 0);
592 }
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800593}
594
Chia-I Wuf8231032014-08-25 10:44:45 +0800595static void gen6_3DSTATE_CLEAR_PARAMS(struct intel_cmd *cmd,
596 uint32_t clear_val)
597{
598 const uint8_t cmd_len = 2;
Chia-I Wu426072d2014-08-26 14:31:55 +0800599 const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_CLEAR_PARAMS) |
Chia-I Wuf8231032014-08-25 10:44:45 +0800600 GEN6_CLEAR_PARAMS_DW0_VALID |
601 (cmd_len - 2);
602
603 CMD_ASSERT(cmd, 6, 6);
604
605 cmd_batch_reserve(cmd, cmd_len);
606 cmd_batch_write(cmd, dw0);
607 cmd_batch_write(cmd, clear_val);
608}
609
610static void gen7_3DSTATE_CLEAR_PARAMS(struct intel_cmd *cmd,
611 uint32_t clear_val)
612{
613 const uint8_t cmd_len = 3;
Chia-I Wu426072d2014-08-26 14:31:55 +0800614 const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_CLEAR_PARAMS) |
Chia-I Wuf8231032014-08-25 10:44:45 +0800615 (cmd_len - 2);
616
617 CMD_ASSERT(cmd, 7, 7.5);
618
619 cmd_batch_reserve(cmd, cmd_len);
620 cmd_batch_write(cmd, dw0);
621 cmd_batch_write(cmd, clear_val);
622 cmd_batch_write(cmd, 1);
623}
624
Chia-I Wu302742d2014-08-22 10:28:29 +0800625static void gen6_3DSTATE_CC_STATE_POINTERS(struct intel_cmd *cmd,
626 XGL_UINT blend_pos,
627 XGL_UINT ds_pos,
628 XGL_UINT cc_pos)
629{
630 const uint8_t cmd_len = 4;
631 uint32_t dw0;
632
633 CMD_ASSERT(cmd, 6, 6);
634
Chia-I Wu426072d2014-08-26 14:31:55 +0800635 dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_CC_STATE_POINTERS) |
Chia-I Wu302742d2014-08-22 10:28:29 +0800636 (cmd_len - 2);
637
638 cmd_batch_reserve(cmd, cmd_len);
639 cmd_batch_write(cmd, dw0);
640 cmd_batch_write(cmd, (blend_pos << 2) | 1);
641 cmd_batch_write(cmd, (ds_pos << 2) | 1);
642 cmd_batch_write(cmd, (cc_pos << 2) | 1);
643}
644
Chia-I Wu1744cca2014-08-22 11:10:17 +0800645static void gen6_3DSTATE_VIEWPORT_STATE_POINTERS(struct intel_cmd *cmd,
646 XGL_UINT clip_pos,
647 XGL_UINT sf_pos,
648 XGL_UINT cc_pos)
649{
650 const uint8_t cmd_len = 4;
651 uint32_t dw0;
652
653 CMD_ASSERT(cmd, 6, 6);
654
Chia-I Wu426072d2014-08-26 14:31:55 +0800655 dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_VIEWPORT_STATE_POINTERS) |
Chia-I Wu1744cca2014-08-22 11:10:17 +0800656 GEN6_PTR_VP_DW0_CLIP_CHANGED |
657 GEN6_PTR_VP_DW0_SF_CHANGED |
658 GEN6_PTR_VP_DW0_CC_CHANGED |
659 (cmd_len - 2);
660
661 cmd_batch_reserve(cmd, cmd_len);
662 cmd_batch_write(cmd, dw0);
663 cmd_batch_write(cmd, clip_pos << 2);
664 cmd_batch_write(cmd, sf_pos << 2);
665 cmd_batch_write(cmd, cc_pos << 2);
666}
667
668static void gen6_3DSTATE_SCISSOR_STATE_POINTERS(struct intel_cmd *cmd,
669 XGL_UINT scissor_pos)
670{
671 const uint8_t cmd_len = 2;
672 uint32_t dw0;
673
674 CMD_ASSERT(cmd, 6, 6);
675
Chia-I Wu426072d2014-08-26 14:31:55 +0800676 dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_SCISSOR_STATE_POINTERS) |
Chia-I Wu1744cca2014-08-22 11:10:17 +0800677 (cmd_len - 2);
678
679 cmd_batch_reserve(cmd, cmd_len);
680 cmd_batch_write(cmd, dw0);
681 cmd_batch_write(cmd, scissor_pos << 2);
682}
683
Chia-I Wu42a56202014-08-23 16:47:48 +0800684static void gen6_3DSTATE_BINDING_TABLE_POINTERS(struct intel_cmd *cmd,
685 XGL_UINT vs_pos,
686 XGL_UINT gs_pos,
687 XGL_UINT ps_pos)
688{
689 const uint8_t cmd_len = 4;
690 uint32_t dw0;
691
692 CMD_ASSERT(cmd, 6, 6);
693
Chia-I Wu426072d2014-08-26 14:31:55 +0800694 dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_BINDING_TABLE_POINTERS) |
Chia-I Wu42a56202014-08-23 16:47:48 +0800695 GEN6_PTR_BINDING_TABLE_DW0_VS_CHANGED |
696 GEN6_PTR_BINDING_TABLE_DW0_GS_CHANGED |
697 GEN6_PTR_BINDING_TABLE_DW0_PS_CHANGED |
698 (cmd_len - 2);
699
700 cmd_batch_reserve(cmd, cmd_len);
701 cmd_batch_write(cmd, dw0);
702 cmd_batch_write(cmd, vs_pos << 2);
703 cmd_batch_write(cmd, gs_pos << 2);
704 cmd_batch_write(cmd, ps_pos << 2);
705}
706
Chia-I Wu257e75e2014-08-29 14:06:35 +0800707static void gen6_3DSTATE_SAMPLER_STATE_POINTERS(struct intel_cmd *cmd,
708 XGL_UINT vs_pos,
709 XGL_UINT gs_pos,
710 XGL_UINT ps_pos)
711{
712 const uint8_t cmd_len = 4;
713 uint32_t dw0;
714
715 CMD_ASSERT(cmd, 6, 6);
716
717 dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_SAMPLER_STATE_POINTERS) |
718 GEN6_PTR_SAMPLER_DW0_VS_CHANGED |
719 GEN6_PTR_SAMPLER_DW0_GS_CHANGED |
720 GEN6_PTR_SAMPLER_DW0_PS_CHANGED |
721 (cmd_len - 2);
722
723 cmd_batch_reserve(cmd, cmd_len);
724 cmd_batch_write(cmd, dw0);
725 cmd_batch_write(cmd, vs_pos << 2);
726 cmd_batch_write(cmd, gs_pos << 2);
727 cmd_batch_write(cmd, ps_pos << 2);
728}
729
Chia-I Wu302742d2014-08-22 10:28:29 +0800730static void gen7_3dstate_pointer(struct intel_cmd *cmd,
731 int subop, XGL_UINT pos)
732{
733 const uint8_t cmd_len = 2;
734 const uint32_t dw0 = GEN6_RENDER_TYPE_RENDER |
735 GEN6_RENDER_SUBTYPE_3D |
736 subop | (cmd_len - 2);
737
738 cmd_batch_reserve(cmd, cmd_len);
739 cmd_batch_write(cmd, dw0);
740 cmd_batch_write(cmd, pos << 2);
741}
742
743static XGL_UINT gen6_BLEND_STATE(struct intel_cmd *cmd,
744 const struct intel_blend_state *state)
745{
746 const uint8_t cmd_align = GEN6_ALIGNMENT_BLEND_STATE;
747 const uint8_t cmd_len = XGL_MAX_COLOR_ATTACHMENTS * 2;
748
749 CMD_ASSERT(cmd, 6, 7.5);
750 STATIC_ASSERT(ARRAY_SIZE(state->cmd) >= cmd_len);
751
752 return cmd_state_copy(cmd, state->cmd, cmd_len, cmd_align);
753}
754
755static XGL_UINT gen6_DEPTH_STENCIL_STATE(struct intel_cmd *cmd,
756 const struct intel_ds_state *state)
757{
758 const uint8_t cmd_align = GEN6_ALIGNMENT_DEPTH_STENCIL_STATE;
759 const uint8_t cmd_len = 3;
760
761 CMD_ASSERT(cmd, 6, 7.5);
762 STATIC_ASSERT(ARRAY_SIZE(state->cmd) >= cmd_len);
763
764 return cmd_state_copy(cmd, state->cmd, cmd_len, cmd_align);
765}
766
767static XGL_UINT gen6_COLOR_CALC_STATE(struct intel_cmd *cmd,
768 uint32_t stencil_ref,
769 const uint32_t blend_color[4])
770{
771 const uint8_t cmd_align = GEN6_ALIGNMENT_COLOR_CALC_STATE;
772 const uint8_t cmd_len = 6;
773 XGL_UINT pos;
774 uint32_t *dw;
775
776 CMD_ASSERT(cmd, 6, 7.5);
777
778 dw = cmd_state_reserve(cmd, cmd_len, cmd_align, &pos);
779 dw[0] = stencil_ref;
780 dw[1] = 0;
781 dw[2] = blend_color[0];
782 dw[3] = blend_color[1];
783 dw[4] = blend_color[2];
784 dw[5] = blend_color[3];
785 cmd_state_advance(cmd, cmd_len);
786
787 return pos;
788}
789
Chia-I Wu8370b402014-08-29 12:28:37 +0800790static void cmd_wa_gen6_pre_depth_stall_write(struct intel_cmd *cmd)
Chia-I Wu48c283d2014-08-25 23:13:46 +0800791{
Chia-I Wu8370b402014-08-29 12:28:37 +0800792 CMD_ASSERT(cmd, 6, 7.5);
793
Chia-I Wu707a29e2014-08-27 12:51:47 +0800794 if (!cmd->bind.draw_count)
795 return;
796
Chia-I Wu8370b402014-08-29 12:28:37 +0800797 if (cmd->bind.wa_flags & INTEL_CMD_WA_GEN6_PRE_DEPTH_STALL_WRITE)
Chia-I Wu48c283d2014-08-25 23:13:46 +0800798 return;
799
Chia-I Wu8370b402014-08-29 12:28:37 +0800800 cmd->bind.wa_flags |= INTEL_CMD_WA_GEN6_PRE_DEPTH_STALL_WRITE;
Chia-I Wu48c283d2014-08-25 23:13:46 +0800801
802 /*
803 * From the Sandy Bridge PRM, volume 2 part 1, page 60:
804 *
805 * "Pipe-control with CS-stall bit set must be sent BEFORE the
806 * pipe-control with a post-sync op and no write-cache flushes."
807 *
808 * The workaround below necessitates this workaround.
809 */
810 gen6_PIPE_CONTROL(cmd,
811 GEN6_PIPE_CONTROL_CS_STALL |
812 GEN6_PIPE_CONTROL_PIXEL_SCOREBOARD_STALL,
813 NULL, 0);
814
Chia-I Wu8370b402014-08-29 12:28:37 +0800815 gen6_PIPE_CONTROL(cmd, GEN6_PIPE_CONTROL_WRITE_IMM, cmd->scratch_bo, 0);
Chia-I Wu48c283d2014-08-25 23:13:46 +0800816}
817
Chia-I Wu8370b402014-08-29 12:28:37 +0800818static void cmd_wa_gen6_pre_command_scoreboard_stall(struct intel_cmd *cmd)
Courtney Goeltzenleuchterf9e1a412014-08-27 13:59:36 -0600819{
Chia-I Wu48c283d2014-08-25 23:13:46 +0800820 CMD_ASSERT(cmd, 6, 7.5);
821
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800822 if (!cmd->bind.draw_count)
823 return;
824
Chia-I Wu8370b402014-08-29 12:28:37 +0800825 gen6_PIPE_CONTROL(cmd, GEN6_PIPE_CONTROL_PIXEL_SCOREBOARD_STALL, NULL, 0);
826}
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800827
Chia-I Wu8370b402014-08-29 12:28:37 +0800828static void cmd_wa_gen7_pre_vs_depth_stall_write(struct intel_cmd *cmd)
829{
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800830 CMD_ASSERT(cmd, 7, 7.5);
831
Chia-I Wu8370b402014-08-29 12:28:37 +0800832 if (!cmd->bind.draw_count)
833 return;
834
835 cmd_wa_gen6_pre_depth_stall_write(cmd);
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800836
837 gen6_PIPE_CONTROL(cmd,
838 GEN6_PIPE_CONTROL_DEPTH_STALL | GEN6_PIPE_CONTROL_WRITE_IMM,
839 cmd->scratch_bo, 0);
840}
841
Chia-I Wu8370b402014-08-29 12:28:37 +0800842static void cmd_wa_gen7_post_command_cs_stall(struct intel_cmd *cmd)
843{
844 CMD_ASSERT(cmd, 7, 7.5);
845
846 if (!cmd->bind.draw_count)
847 return;
848
849 /*
850 * From the Ivy Bridge PRM, volume 2 part 1, page 61:
851 *
852 * "One of the following must also be set (when CS stall is set):
853 *
854 * * Render Target Cache Flush Enable ([12] of DW1)
855 * * Depth Cache Flush Enable ([0] of DW1)
856 * * Stall at Pixel Scoreboard ([1] of DW1)
857 * * Depth Stall ([13] of DW1)
858 * * Post-Sync Operation ([13] of DW1)"
859 */
860 gen6_PIPE_CONTROL(cmd,
861 GEN6_PIPE_CONTROL_CS_STALL |
862 GEN6_PIPE_CONTROL_PIXEL_SCOREBOARD_STALL,
863 NULL, 0);
864}
865
866static void cmd_wa_gen7_post_command_depth_stall(struct intel_cmd *cmd)
867{
868 CMD_ASSERT(cmd, 7, 7.5);
869
870 if (!cmd->bind.draw_count)
871 return;
872
873 cmd_wa_gen6_pre_depth_stall_write(cmd);
874
875 gen6_PIPE_CONTROL(cmd, GEN6_PIPE_CONTROL_DEPTH_STALL, NULL, 0);
876}
877
878static void cmd_wa_gen6_pre_multisample_depth_flush(struct intel_cmd *cmd)
879{
880 CMD_ASSERT(cmd, 6, 7.5);
881
882 if (!cmd->bind.draw_count)
883 return;
884
885 /*
886 * From the Sandy Bridge PRM, volume 2 part 1, page 305:
887 *
888 * "Driver must guarentee that all the caches in the depth pipe are
889 * flushed before this command (3DSTATE_MULTISAMPLE) is parsed. This
890 * requires driver to send a PIPE_CONTROL with a CS stall along with
891 * a Depth Flush prior to this command."
892 *
893 * From the Ivy Bridge PRM, volume 2 part 1, page 304:
894 *
895 * "Driver must ierarchi that all the caches in the depth pipe are
896 * flushed before this command (3DSTATE_MULTISAMPLE) is parsed. This
897 * requires driver to send a PIPE_CONTROL with a CS stall along with
898 * a Depth Flush prior to this command.
899 */
900 gen6_PIPE_CONTROL(cmd,
901 GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH |
902 GEN6_PIPE_CONTROL_CS_STALL,
903 0, 0);
904}
905
906static void cmd_wa_gen6_pre_ds_flush(struct intel_cmd *cmd)
907{
908 CMD_ASSERT(cmd, 6, 7.5);
909
910 if (!cmd->bind.draw_count)
911 return;
912
913 /*
914 * From the Ivy Bridge PRM, volume 2 part 1, page 315:
915 *
916 * "Driver must send a least one PIPE_CONTROL command with CS Stall
917 * and a post sync operation prior to the group of depth
918 * commands(3DSTATE_DEPTH_BUFFER, 3DSTATE_CLEAR_PARAMS,
919 * 3DSTATE_STENCIL_BUFFER, and 3DSTATE_HIER_DEPTH_BUFFER)."
920 *
921 * This workaround satifies all the conditions.
922 */
923 cmd_wa_gen6_pre_depth_stall_write(cmd);
924
925 /*
926 * From the Ivy Bridge PRM, volume 2 part 1, page 315:
927 *
928 * "Restriction: Prior to changing Depth/Stencil Buffer state (i.e.,
929 * any combination of 3DSTATE_DEPTH_BUFFER, 3DSTATE_CLEAR_PARAMS,
930 * 3DSTATE_STENCIL_BUFFER, 3DSTATE_HIER_DEPTH_BUFFER) SW must first
931 * issue a pipelined depth stall (PIPE_CONTROL with Depth Stall bit
932 * set), followed by a pipelined depth cache flush (PIPE_CONTROL with
933 * Depth Flush Bit set, followed by another pipelined depth stall
934 * (PIPE_CONTROL with Depth Stall Bit set), unless SW can otherwise
935 * guarantee that the pipeline from WM onwards is already flushed
936 * (e.g., via a preceding MI_FLUSH)."
937 */
938 gen6_PIPE_CONTROL(cmd, GEN6_PIPE_CONTROL_DEPTH_STALL, NULL, 0);
939 gen6_PIPE_CONTROL(cmd, GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH, NULL, 0);
940 gen6_PIPE_CONTROL(cmd, GEN6_PIPE_CONTROL_DEPTH_STALL, NULL, 0);
941}
942
Chia-I Wu525c6602014-08-27 10:22:34 +0800943void cmd_batch_flush(struct intel_cmd *cmd, uint32_t pipe_control_dw0)
944{
945 if (!cmd->bind.draw_count)
946 return;
947
948 assert(!(pipe_control_dw0 & GEN6_PIPE_CONTROL_WRITE__MASK));
949
Chia-I Wu8370b402014-08-29 12:28:37 +0800950 /*
951 * From the Sandy Bridge PRM, volume 2 part 1, page 60:
952 *
953 * "Before a PIPE_CONTROL with Write Cache Flush Enable =1, a
954 * PIPE_CONTROL with any non-zero post-sync-op is required."
955 */
Chia-I Wu525c6602014-08-27 10:22:34 +0800956 if (pipe_control_dw0 & GEN6_PIPE_CONTROL_RENDER_CACHE_FLUSH)
Chia-I Wu8370b402014-08-29 12:28:37 +0800957 cmd_wa_gen6_pre_depth_stall_write(cmd);
Chia-I Wu525c6602014-08-27 10:22:34 +0800958
959 gen6_PIPE_CONTROL(cmd, pipe_control_dw0, NULL, 0);
960}
961
Chia-I Wu302742d2014-08-22 10:28:29 +0800962static void gen6_cc_states(struct intel_cmd *cmd)
963{
964 const struct intel_blend_state *blend = cmd->bind.state.blend;
965 const struct intel_ds_state *ds = cmd->bind.state.ds;
966 XGL_UINT blend_pos, ds_pos, cc_pos;
Chia-I Wuce9f11f2014-08-22 10:38:51 +0800967 uint32_t stencil_ref;
968 uint32_t blend_color[4];
Chia-I Wu302742d2014-08-22 10:28:29 +0800969
970 CMD_ASSERT(cmd, 6, 6);
971
Chia-I Wuce9f11f2014-08-22 10:38:51 +0800972 if (blend) {
973 blend_pos = gen6_BLEND_STATE(cmd, blend);
974 memcpy(blend_color, blend->cmd_blend_color, sizeof(blend_color));
975 } else {
976 blend_pos = 0;
977 memset(blend_color, 0, sizeof(blend_color));
978 }
979
980 if (ds) {
981 ds_pos = gen6_DEPTH_STENCIL_STATE(cmd, ds);
982 stencil_ref = ds->cmd_stencil_ref;
983 } else {
984 ds_pos = 0;
985 stencil_ref = 0;
986 }
987
988 cc_pos = gen6_COLOR_CALC_STATE(cmd, stencil_ref, blend_color);
Chia-I Wu302742d2014-08-22 10:28:29 +0800989
990 gen6_3DSTATE_CC_STATE_POINTERS(cmd, blend_pos, ds_pos, cc_pos);
991}
992
Chia-I Wu1744cca2014-08-22 11:10:17 +0800993static void gen6_viewport_states(struct intel_cmd *cmd)
994{
995 const struct intel_viewport_state *viewport = cmd->bind.state.viewport;
996 XGL_UINT pos;
997
998 if (!viewport)
999 return;
1000
1001 pos = cmd_state_copy(cmd, viewport->cmd, viewport->cmd_len,
1002 viewport->cmd_align);
1003
1004 gen6_3DSTATE_VIEWPORT_STATE_POINTERS(cmd,
1005 pos + viewport->cmd_clip_offset,
1006 pos,
1007 pos + viewport->cmd_cc_offset);
1008
1009 pos = (viewport->scissor_enable) ?
1010 pos + viewport->cmd_scissor_rect_offset : 0;
1011
1012 gen6_3DSTATE_SCISSOR_STATE_POINTERS(cmd, pos);
1013}
1014
Chia-I Wu302742d2014-08-22 10:28:29 +08001015static void gen7_cc_states(struct intel_cmd *cmd)
1016{
1017 const struct intel_blend_state *blend = cmd->bind.state.blend;
1018 const struct intel_ds_state *ds = cmd->bind.state.ds;
Chia-I Wuce9f11f2014-08-22 10:38:51 +08001019 uint32_t stencil_ref;
1020 uint32_t blend_color[4];
Chia-I Wu302742d2014-08-22 10:28:29 +08001021 XGL_UINT pos;
1022
1023 CMD_ASSERT(cmd, 7, 7.5);
1024
Chia-I Wuce9f11f2014-08-22 10:38:51 +08001025 if (!blend && !ds)
1026 return;
Chia-I Wu302742d2014-08-22 10:28:29 +08001027
Chia-I Wuce9f11f2014-08-22 10:38:51 +08001028 if (blend) {
1029 pos = gen6_BLEND_STATE(cmd, blend);
1030 gen7_3dstate_pointer(cmd,
1031 GEN7_RENDER_OPCODE_3DSTATE_BLEND_STATE_POINTERS, pos);
Chia-I Wu302742d2014-08-22 10:28:29 +08001032
Chia-I Wuce9f11f2014-08-22 10:38:51 +08001033 memcpy(blend_color, blend->cmd_blend_color, sizeof(blend_color));
1034 } else {
1035 memset(blend_color, 0, sizeof(blend_color));
1036 }
1037
1038 if (ds) {
1039 pos = gen6_DEPTH_STENCIL_STATE(cmd, ds);
1040 gen7_3dstate_pointer(cmd,
1041 GEN7_RENDER_OPCODE_3DSTATE_DEPTH_STENCIL_STATE_POINTERS, pos);
1042 } else {
1043 stencil_ref = 0;
1044 }
1045
1046 pos = gen6_COLOR_CALC_STATE(cmd, stencil_ref, blend_color);
Chia-I Wu302742d2014-08-22 10:28:29 +08001047 gen7_3dstate_pointer(cmd,
1048 GEN6_RENDER_OPCODE_3DSTATE_CC_STATE_POINTERS, pos);
1049}
1050
Chia-I Wu1744cca2014-08-22 11:10:17 +08001051static void gen7_viewport_states(struct intel_cmd *cmd)
1052{
1053 const struct intel_viewport_state *viewport = cmd->bind.state.viewport;
1054 XGL_UINT pos;
1055
1056 if (!viewport)
1057 return;
1058
1059 pos = cmd_state_copy(cmd, viewport->cmd, viewport->cmd_len,
1060 viewport->cmd_align);
1061
1062 gen7_3dstate_pointer(cmd,
1063 GEN7_RENDER_OPCODE_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP, pos);
1064 gen7_3dstate_pointer(cmd,
1065 GEN7_RENDER_OPCODE_3DSTATE_VIEWPORT_STATE_POINTERS_CC,
1066 pos + viewport->cmd_cc_offset);
1067 if (viewport->scissor_enable) {
1068 gen7_3dstate_pointer(cmd,
1069 GEN6_RENDER_OPCODE_3DSTATE_SCISSOR_STATE_POINTERS,
1070 pos + viewport->cmd_scissor_rect_offset);
1071 }
1072}
1073
Chia-I Wu7fd5cac2014-08-27 13:19:29 +08001074static void gen6_pcb(struct intel_cmd *cmd, int subop,
1075 const XGL_PIPELINE_SHADER *sh)
1076{
1077 const uint8_t cmd_len = 5;
1078 const XGL_UINT alignment = 32;
1079 const XGL_UINT max_size =
1080 (subop == GEN6_RENDER_OPCODE_3DSTATE_CONSTANT_VS) ? 1024 : 2048;
1081 const XGL_UINT max_pcb = 4;
1082 uint32_t pcb[4] = { 0, 0, 0, 0 };
1083 XGL_FLAGS pcb_enables = 0;
1084 XGL_SIZE total_size = 0;
1085 uint32_t dw0;
1086 XGL_UINT i;
1087
1088 for (i = 0; i < sh->linkConstBufferCount; i++) {
1089 const XGL_LINK_CONST_BUFFER *info = &sh->pLinkConstBufferInfo[i];
1090 const XGL_SIZE size = u_align(info->bufferSize, alignment);
1091 void *ptr;
1092
1093 if (info->bufferId >= max_pcb ||
1094 pcb_enables & ((1 << info->bufferId)) ||
1095 total_size + info->bufferSize > max_size) {
1096 cmd->result = XGL_ERROR_UNKNOWN;
1097 return;
1098 }
1099 if (!size)
1100 continue;
1101
1102 pcb_enables |= 1 << info->bufferId;
1103 total_size += size;
1104
1105 ptr = cmd_state_reserve(cmd, size / sizeof(uint32_t),
1106 alignment / sizeof(uint32_t), &pcb[info->bufferId]);
1107 memcpy(ptr, info->pBufferData, info->bufferSize);
1108 cmd_state_advance(cmd, size / sizeof(uint32_t));
1109
1110 pcb[info->bufferId] |= size / alignment - 1;
1111 }
1112
1113 dw0 = GEN6_RENDER_TYPE_RENDER |
1114 GEN6_RENDER_SUBTYPE_3D |
1115 subop |
1116 pcb_enables << 12 |
1117 (cmd_len - 2);
1118
1119 cmd_batch_reserve(cmd, cmd_len);
1120 cmd_batch_write(cmd, dw0);
1121 cmd_batch_write(cmd, pcb[0]);
1122 cmd_batch_write(cmd, pcb[1]);
1123 cmd_batch_write(cmd, pcb[2]);
1124 cmd_batch_write(cmd, pcb[3]);
1125}
1126
1127static void gen7_pcb(struct intel_cmd *cmd, int subop,
1128 const XGL_PIPELINE_SHADER *sh)
1129{
1130 const uint8_t cmd_len = 7;
1131 const uint32_t dw0 = GEN6_RENDER_TYPE_RENDER |
1132 GEN6_RENDER_SUBTYPE_3D |
1133 subop |
1134 (cmd_len - 2);
1135 const XGL_UINT alignment = 32;
1136 const XGL_UINT max_size = 2048;
1137 const XGL_UINT max_pcb = 4;
1138 uint16_t pcb_len[4] = { 0, 0, 0, 0 };
1139 uint32_t pcb[4] = { 0, 0, 0, 0 };
1140 XGL_FLAGS pcb_enables = 0;
1141 XGL_SIZE total_size = 0;
1142 XGL_UINT i;
1143
1144 for (i = 0; i < sh->linkConstBufferCount; i++) {
1145 const XGL_LINK_CONST_BUFFER *info = &sh->pLinkConstBufferInfo[i];
1146 const XGL_SIZE size = u_align(info->bufferSize, alignment);
1147 void *ptr;
1148
1149 if (info->bufferId >= max_pcb ||
1150 pcb_enables & ((1 << info->bufferId)) ||
1151 total_size + info->bufferSize > max_size) {
1152 cmd->result = XGL_ERROR_UNKNOWN;
1153 return;
1154 }
1155 if (!size)
1156 continue;
1157
1158 pcb_enables |= 1 << info->bufferId;
1159 total_size += size;
1160
1161 pcb_len[info->bufferId] = size / alignment;
1162
1163 ptr = cmd_state_reserve(cmd, size / sizeof(uint32_t),
1164 alignment / sizeof(uint32_t), &pcb[info->bufferId]);
1165 memcpy(ptr, info->pBufferData, info->bufferSize);
1166 cmd_state_advance(cmd, size / sizeof(uint32_t));
1167 }
1168
1169 /* no holes */
1170 if (!u_is_pow2(pcb_enables + 1)) {
1171 cmd->result = XGL_ERROR_UNKNOWN;
1172 return;
1173 }
1174
1175 cmd_batch_reserve(cmd, cmd_len);
1176 cmd_batch_write(cmd, dw0);
1177 cmd_batch_write(cmd, pcb_len[1] << 16 | pcb_len[0]);
1178 cmd_batch_write(cmd, pcb_len[3] << 16 | pcb_len[2]);
1179 cmd_batch_write(cmd, pcb[0]);
1180 cmd_batch_write(cmd, pcb[1]);
1181 cmd_batch_write(cmd, pcb[2]);
1182 cmd_batch_write(cmd, pcb[3]);
1183}
1184
Chia-I Wu42a56202014-08-23 16:47:48 +08001185static void emit_ps_resources(struct intel_cmd *cmd,
1186 const struct intel_rmap *rmap)
1187{
1188 const XGL_UINT surface_count = rmap->rt_count +
1189 rmap->resource_count + rmap->uav_count;
1190 uint32_t binding_table[256];
1191 XGL_UINT pos, i;
1192
1193 assert(surface_count <= ARRAY_SIZE(binding_table));
1194
1195 for (i = 0; i < surface_count; i++) {
1196 const struct intel_rmap_slot *slot = &rmap->slots[i];
1197 uint32_t *dw;
1198
1199 switch (slot->path_len) {
1200 case 0:
1201 pos = 0;
1202 break;
1203 case INTEL_RMAP_SLOT_RT:
1204 {
1205 const struct intel_rt_view *view = cmd->bind.att.rt[i];
1206
1207 dw = cmd_state_reserve_reloc(cmd, view->cmd_len, 1,
1208 GEN6_ALIGNMENT_SURFACE_STATE, &pos);
1209
1210 memcpy(dw, view->cmd, sizeof(uint32_t) * view->cmd_len);
Chia-I Wubda55fd2014-08-25 12:46:10 +08001211 cmd_state_reloc(cmd, 1, view->cmd[1], view->img->obj.mem->bo,
Chia-I Wu32a22462014-08-26 14:13:46 +08001212 INTEL_RELOC_WRITE);
Chia-I Wu42a56202014-08-23 16:47:48 +08001213 cmd_state_advance(cmd, view->cmd_len);
1214 }
1215 break;
1216 case INTEL_RMAP_SLOT_DYN:
1217 {
1218 const struct intel_mem_view *view =
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001219 &cmd->bind.dyn_view.graphics;
Chia-I Wu42a56202014-08-23 16:47:48 +08001220
1221 dw = cmd_state_reserve_reloc(cmd, view->cmd_len, 1,
1222 GEN6_ALIGNMENT_SURFACE_STATE, &pos);
1223
1224 memcpy(dw, view->cmd, sizeof(uint32_t) * view->cmd_len);
Chia-I Wubda55fd2014-08-25 12:46:10 +08001225 cmd_state_reloc(cmd, 1, view->cmd[1], view->mem->bo,
Chia-I Wu32a22462014-08-26 14:13:46 +08001226 INTEL_RELOC_WRITE);
Chia-I Wu42a56202014-08-23 16:47:48 +08001227 cmd_state_advance(cmd, view->cmd_len);
1228 }
1229 break;
1230 case 1:
1231 default:
1232 /* TODO */
1233 assert(!"no dset support");
1234 break;
1235 }
1236
1237 binding_table[i] = pos << 2;
1238 }
1239
1240 pos = cmd_state_copy(cmd, binding_table, surface_count,
1241 GEN6_ALIGNMENT_BINDING_TABLE_STATE);
1242
1243 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
1244 gen7_3dstate_pointer(cmd,
1245 GEN7_RENDER_OPCODE_3DSTATE_BINDING_TABLE_POINTERS_PS, pos);
Chia-I Wu257e75e2014-08-29 14:06:35 +08001246
1247 gen7_3dstate_pointer(cmd,
1248 GEN7_RENDER_OPCODE_3DSTATE_BINDING_TABLE_POINTERS_VS, 0);
1249 gen7_3dstate_pointer(cmd,
1250 GEN7_RENDER_OPCODE_3DSTATE_BINDING_TABLE_POINTERS_HS, 0);
1251 gen7_3dstate_pointer(cmd,
1252 GEN7_RENDER_OPCODE_3DSTATE_BINDING_TABLE_POINTERS_DS, 0);
1253 gen7_3dstate_pointer(cmd,
1254 GEN7_RENDER_OPCODE_3DSTATE_BINDING_TABLE_POINTERS_GS, 0);
1255
1256 gen7_3dstate_pointer(cmd,
1257 GEN7_RENDER_OPCODE_3DSTATE_SAMPLER_STATE_POINTERS_VS, 0);
1258 gen7_3dstate_pointer(cmd,
1259 GEN7_RENDER_OPCODE_3DSTATE_SAMPLER_STATE_POINTERS_HS, 0);
1260 gen7_3dstate_pointer(cmd,
1261 GEN7_RENDER_OPCODE_3DSTATE_SAMPLER_STATE_POINTERS_DS, 0);
1262 gen7_3dstate_pointer(cmd,
1263 GEN7_RENDER_OPCODE_3DSTATE_SAMPLER_STATE_POINTERS_GS, 0);
1264 gen7_3dstate_pointer(cmd,
1265 GEN7_RENDER_OPCODE_3DSTATE_SAMPLER_STATE_POINTERS_PS, 0);
Chia-I Wu42a56202014-08-23 16:47:48 +08001266 } else {
1267 gen6_3DSTATE_BINDING_TABLE_POINTERS(cmd, 0, 0, pos);
Chia-I Wu257e75e2014-08-29 14:06:35 +08001268 gen6_3DSTATE_SAMPLER_STATE_POINTERS(cmd, 0, 0, 0);
Chia-I Wu42a56202014-08-23 16:47:48 +08001269 }
1270}
1271
Chia-I Wu52500102014-08-22 00:46:04 +08001272static void emit_bounded_states(struct intel_cmd *cmd)
1273{
1274 const struct intel_msaa_state *msaa = cmd->bind.state.msaa;
1275
1276 /* TODO more states */
1277
Chia-I Wu1744cca2014-08-22 11:10:17 +08001278 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
Chia-I Wu302742d2014-08-22 10:28:29 +08001279 gen7_cc_states(cmd);
Chia-I Wu1744cca2014-08-22 11:10:17 +08001280 gen7_viewport_states(cmd);
Chia-I Wu7fd5cac2014-08-27 13:19:29 +08001281
1282 gen7_pcb(cmd, GEN6_RENDER_OPCODE_3DSTATE_CONSTANT_VS,
1283 &cmd->bind.pipeline.graphics->vs);
1284 gen7_pcb(cmd, GEN6_RENDER_OPCODE_3DSTATE_CONSTANT_PS,
1285 &cmd->bind.pipeline.graphics->fs);
Chia-I Wu1f2fd292014-08-29 15:07:09 +08001286
1287 gen7_3DSTATE_WM(cmd);
1288 gen7_3DSTATE_PS(cmd);
Chia-I Wu1744cca2014-08-22 11:10:17 +08001289 } else {
Chia-I Wu302742d2014-08-22 10:28:29 +08001290 gen6_cc_states(cmd);
Chia-I Wu1744cca2014-08-22 11:10:17 +08001291 gen6_viewport_states(cmd);
Chia-I Wu7fd5cac2014-08-27 13:19:29 +08001292
1293 gen6_pcb(cmd, GEN6_RENDER_OPCODE_3DSTATE_CONSTANT_VS,
1294 &cmd->bind.pipeline.graphics->vs);
1295 gen6_pcb(cmd, GEN6_RENDER_OPCODE_3DSTATE_CONSTANT_PS,
1296 &cmd->bind.pipeline.graphics->fs);
Chia-I Wu1f2fd292014-08-29 15:07:09 +08001297
1298 gen6_3DSTATE_WM(cmd);
Chia-I Wu1744cca2014-08-22 11:10:17 +08001299 }
Chia-I Wu302742d2014-08-22 10:28:29 +08001300
Chia-I Wu42a56202014-08-23 16:47:48 +08001301 emit_ps_resources(cmd, cmd->bind.pipeline.graphics->fs_rmap);
1302
Chia-I Wu8370b402014-08-29 12:28:37 +08001303 cmd_wa_gen6_pre_depth_stall_write(cmd);
1304 cmd_wa_gen6_pre_multisample_depth_flush(cmd);
Chia-I Wu9cb84ee2014-08-28 10:12:34 +08001305 /* 3DSTATE_MULTISAMPLE and 3DSTATE_SAMPLE_MASK */
Chia-I Wu52500102014-08-22 00:46:04 +08001306 cmd_batch_reserve(cmd, msaa->cmd_len);
1307 cmd_batch_write_n(cmd, msaa->cmd, msaa->cmd_len);
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001308}
1309
1310static void emit_shader(struct intel_cmd *cmd,
Courtney Goeltzenleuchterba305812014-08-28 17:27:47 -06001311 const struct intel_pipe_shader *shader,
1312 struct intel_cmd_shader *pCmdShader)
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001313{
1314 uint32_t i;
1315 struct intel_cmd_shader *cmdShader;
1316
1317 for (i=0; i<cmd->bind.shaderCache.used; i++) {
Chia-I Wu338fe642014-08-28 10:43:04 +08001318 if (cmd->bind.shaderCache.shaderArray[i].shader == shader) {
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001319 /* shader is already part of pipeline */
1320 return;
1321 }
1322 }
1323
Chia-I Wu338fe642014-08-28 10:43:04 +08001324 if (cmd->bind.shaderCache.used == cmd->bind.shaderCache.count) {
1325 const XGL_UINT new_count = cmd->bind.shaderCache.count + 16;
1326
1327 cmdShader = cmd->bind.shaderCache.shaderArray;
1328
1329 cmd->bind.shaderCache.shaderArray =
1330 icd_alloc(sizeof(*cmdShader) * new_count,
1331 0, XGL_SYSTEM_ALLOC_INTERNAL);
1332 if (cmd->bind.shaderCache.shaderArray == NULL) {
1333 cmd->bind.shaderCache.shaderArray = cmdShader;
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001334 cmd->result = XGL_ERROR_OUT_OF_MEMORY;
1335 return;
1336 }
Chia-I Wu338fe642014-08-28 10:43:04 +08001337
1338 if (cmdShader) {
1339 memcpy(cmd->bind.shaderCache.shaderArray, cmdShader,
1340 sizeof(*cmdShader) * cmd->bind.shaderCache.used);
1341 icd_free(cmdShader);
1342 }
1343
1344 cmd->bind.shaderCache.count = new_count;
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001345 }
1346
Chia-I Wu338fe642014-08-28 10:43:04 +08001347 cmdShader = &cmd->bind.shaderCache.shaderArray[cmd->bind.shaderCache.used];
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001348 cmdShader->shader = shader;
1349 cmdShader->kernel_pos = cmd_kernel_copy(cmd, shader->pCode, shader->codeSize);
Courtney Goeltzenleuchterba305812014-08-28 17:27:47 -06001350 *pCmdShader = *cmdShader;
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001351 cmd->bind.shaderCache.used++;
1352 return;
1353}
1354
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001355static void cmd_bind_graphics_pipeline(struct intel_cmd *cmd,
Chia-I Wu338fe642014-08-28 10:43:04 +08001356 const struct intel_pipeline *pipeline)
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001357{
1358 cmd->bind.pipeline.graphics = pipeline;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +08001359
Chia-I Wu8370b402014-08-29 12:28:37 +08001360 if (pipeline->wa_flags & INTEL_CMD_WA_GEN6_PRE_DEPTH_STALL_WRITE)
1361 cmd_wa_gen6_pre_depth_stall_write(cmd);
1362 if (pipeline->wa_flags & INTEL_CMD_WA_GEN6_PRE_COMMAND_SCOREBOARD_STALL)
1363 cmd_wa_gen6_pre_command_scoreboard_stall(cmd);
1364 if (pipeline->wa_flags & INTEL_CMD_WA_GEN7_PRE_VS_DEPTH_STALL_WRITE)
1365 cmd_wa_gen7_pre_vs_depth_stall_write(cmd);
Chia-I Wubb2d8ca2014-08-28 23:15:48 +08001366
1367 /* 3DSTATE_URB_VS and etc. */
Courtney Goeltzenleuchter814cd292014-08-28 13:16:27 -06001368 assert(pipeline->cmd_len);
Chia-I Wub08727d2014-08-29 14:54:54 +08001369 cmd_batch_reserve(cmd, pipeline->cmd_len);
Courtney Goeltzenleuchterba305812014-08-28 17:27:47 -06001370 cmd_batch_write_n(cmd, pipeline->cmds, pipeline->cmd_len);
Chia-I Wubb2d8ca2014-08-28 23:15:48 +08001371
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001372 if (pipeline->active_shaders & SHADER_VERTEX_FLAG) {
Courtney Goeltzenleuchterba305812014-08-28 17:27:47 -06001373 emit_shader(cmd, &pipeline->intel_vs, &cmd->bind.vs);
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001374 }
1375 if (pipeline->active_shaders & SHADER_GEOMETRY_FLAG) {
Courtney Goeltzenleuchterba305812014-08-28 17:27:47 -06001376 emit_shader(cmd, &pipeline->gs, &cmd->bind.gs);
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001377 }
1378 if (pipeline->active_shaders & SHADER_FRAGMENT_FLAG) {
Courtney Goeltzenleuchterba305812014-08-28 17:27:47 -06001379 emit_shader(cmd, &pipeline->intel_fs, &cmd->bind.fs);
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001380 }
1381 if (pipeline->active_shaders & SHADER_TESS_CONTROL_FLAG) {
Courtney Goeltzenleuchterba305812014-08-28 17:27:47 -06001382 emit_shader(cmd, &pipeline->tess_control, &cmd->bind.tess_control);
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001383 }
1384 if (pipeline->active_shaders & SHADER_TESS_EVAL_FLAG) {
Courtney Goeltzenleuchterba305812014-08-28 17:27:47 -06001385 emit_shader(cmd, &pipeline->tess_eval, &cmd->bind.tess_eval);
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001386 }
Courtney Goeltzenleuchter68d9bef2014-08-28 17:35:03 -06001387
Chia-I Wud95aa2b2014-08-29 12:07:47 +08001388 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
1389 gen7_3DSTATE_GS(cmd);
1390 } else {
1391 gen6_3DSTATE_GS(cmd);
1392 }
Courtney Goeltzenleuchterf782a852014-08-28 17:44:53 -06001393
Chia-I Wu8370b402014-08-29 12:28:37 +08001394 if (pipeline->wa_flags & INTEL_CMD_WA_GEN7_POST_COMMAND_CS_STALL)
1395 cmd_wa_gen7_post_command_cs_stall(cmd);
1396 if (pipeline->wa_flags & INTEL_CMD_WA_GEN7_POST_COMMAND_DEPTH_STALL)
1397 cmd_wa_gen7_post_command_depth_stall(cmd);
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001398}
1399
1400static void cmd_bind_compute_pipeline(struct intel_cmd *cmd,
1401 const struct intel_pipeline *pipeline)
1402{
1403 cmd->bind.pipeline.compute = pipeline;
1404}
1405
1406static void cmd_bind_graphics_delta(struct intel_cmd *cmd,
1407 const struct intel_pipeline_delta *delta)
1408{
1409 cmd->bind.pipeline.graphics_delta = delta;
1410}
1411
1412static void cmd_bind_compute_delta(struct intel_cmd *cmd,
1413 const struct intel_pipeline_delta *delta)
1414{
1415 cmd->bind.pipeline.compute_delta = delta;
1416}
1417
1418static void cmd_bind_graphics_dset(struct intel_cmd *cmd,
1419 const struct intel_dset *dset,
1420 XGL_UINT slot_offset)
1421{
1422 cmd->bind.dset.graphics = dset;
1423 cmd->bind.dset.graphics_offset = slot_offset;
1424}
1425
1426static void cmd_bind_compute_dset(struct intel_cmd *cmd,
1427 const struct intel_dset *dset,
1428 XGL_UINT slot_offset)
1429{
1430 cmd->bind.dset.compute = dset;
1431 cmd->bind.dset.compute_offset = slot_offset;
1432}
1433
1434static void cmd_bind_graphics_dyn_view(struct intel_cmd *cmd,
1435 const XGL_MEMORY_VIEW_ATTACH_INFO *info)
1436{
1437 intel_mem_view_init(&cmd->bind.dyn_view.graphics, cmd->dev, info);
1438}
1439
1440static void cmd_bind_compute_dyn_view(struct intel_cmd *cmd,
1441 const XGL_MEMORY_VIEW_ATTACH_INFO *info)
1442{
1443 intel_mem_view_init(&cmd->bind.dyn_view.compute, cmd->dev, info);
1444}
1445
1446static void cmd_bind_index_data(struct intel_cmd *cmd,
1447 const struct intel_mem *mem,
1448 XGL_GPU_SIZE offset, XGL_INDEX_TYPE type)
1449{
1450 if (cmd_gen(cmd) >= INTEL_GEN(7.5)) {
1451 gen6_3DSTATE_INDEX_BUFFER(cmd, mem, offset, type, false);
1452 } else {
1453 cmd->bind.index.mem = mem;
1454 cmd->bind.index.offset = offset;
1455 cmd->bind.index.type = type;
1456 }
1457}
1458
1459static void cmd_bind_rt(struct intel_cmd *cmd,
1460 const XGL_COLOR_ATTACHMENT_BIND_INFO *attachments,
1461 XGL_UINT count)
1462{
Chia-I Wud88e02d2014-08-25 10:56:13 +08001463 XGL_UINT width = 0, height = 0;
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001464 XGL_UINT i;
1465
1466 for (i = 0; i < count; i++) {
1467 const XGL_COLOR_ATTACHMENT_BIND_INFO *att = &attachments[i];
1468 const struct intel_rt_view *rt = intel_rt_view(att->view);
Chia-I Wud88e02d2014-08-25 10:56:13 +08001469 const struct intel_layout *layout = &rt->img->layout;
1470
1471 if (i == 0) {
1472 width = layout->width0;
1473 height = layout->height0;
1474 } else {
1475 if (width > layout->width0)
1476 width = layout->width0;
1477 if (height > layout->height0)
1478 height = layout->height0;
1479 }
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001480
1481 cmd->bind.att.rt[i] = rt;
1482 }
1483
1484 cmd->bind.att.rt_count = count;
Chia-I Wud88e02d2014-08-25 10:56:13 +08001485
Chia-I Wu8370b402014-08-29 12:28:37 +08001486 cmd_wa_gen6_pre_depth_stall_write(cmd);
Chia-I Wud88e02d2014-08-25 10:56:13 +08001487 gen6_3DSTATE_DRAWING_RECTANGLE(cmd, width, height);
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001488}
1489
1490static void cmd_bind_ds(struct intel_cmd *cmd,
1491 const XGL_DEPTH_STENCIL_BIND_INFO *info)
1492{
1493 const struct intel_ds_view *ds;
1494
1495 if (info) {
1496 cmd->bind.att.ds = intel_ds_view(info->view);
1497 ds = cmd->bind.att.ds;
1498 } else {
1499 /* all zeros */
1500 static const struct intel_ds_view null_ds;
1501 ds = &null_ds;
1502 }
1503
Chia-I Wu8370b402014-08-29 12:28:37 +08001504 cmd_wa_gen6_pre_ds_flush(cmd);
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001505 gen6_3DSTATE_DEPTH_BUFFER(cmd, ds);
1506 gen6_3DSTATE_STENCIL_BUFFER(cmd, ds);
1507 gen6_3DSTATE_HIER_DEPTH_BUFFER(cmd, ds);
Chia-I Wuf8231032014-08-25 10:44:45 +08001508
1509 if (cmd_gen(cmd) >= INTEL_GEN(7))
1510 gen7_3DSTATE_CLEAR_PARAMS(cmd, 0);
1511 else
1512 gen6_3DSTATE_CLEAR_PARAMS(cmd, 0);
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001513}
1514
1515static void cmd_bind_viewport_state(struct intel_cmd *cmd,
1516 const struct intel_viewport_state *state)
1517{
1518 cmd->bind.state.viewport = state;
1519}
1520
1521static void cmd_bind_raster_state(struct intel_cmd *cmd,
1522 const struct intel_raster_state *state)
1523{
1524 cmd->bind.state.raster = state;
1525}
1526
1527static void cmd_bind_ds_state(struct intel_cmd *cmd,
1528 const struct intel_ds_state *state)
1529{
1530 cmd->bind.state.ds = state;
1531}
1532
1533static void cmd_bind_blend_state(struct intel_cmd *cmd,
1534 const struct intel_blend_state *state)
1535{
1536 cmd->bind.state.blend = state;
1537}
1538
1539static void cmd_bind_msaa_state(struct intel_cmd *cmd,
1540 const struct intel_msaa_state *state)
1541{
1542 cmd->bind.state.msaa = state;
1543}
1544
1545static void cmd_draw(struct intel_cmd *cmd,
1546 XGL_UINT vertex_start,
1547 XGL_UINT vertex_count,
1548 XGL_UINT instance_start,
1549 XGL_UINT instance_count,
1550 bool indexed,
1551 XGL_UINT vertex_base)
1552{
1553 const struct intel_pipeline *p = cmd->bind.pipeline.graphics;
1554
1555 emit_bounded_states(cmd);
1556
1557 if (indexed) {
1558 if (p->primitive_restart && !gen6_can_primitive_restart(cmd))
1559 cmd->result = XGL_ERROR_UNKNOWN;
1560
1561 if (cmd_gen(cmd) >= INTEL_GEN(7.5)) {
1562 gen75_3DSTATE_VF(cmd, p->primitive_restart,
1563 p->primitive_restart_index);
1564 } else {
1565 gen6_3DSTATE_INDEX_BUFFER(cmd, cmd->bind.index.mem,
1566 cmd->bind.index.offset, cmd->bind.index.type,
1567 p->primitive_restart);
1568 }
1569 } else {
1570 assert(!vertex_base);
1571 }
1572
1573 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
1574 gen7_3DPRIMITIVE(cmd, p->prim_type, indexed, vertex_count,
1575 vertex_start, instance_count, instance_start, vertex_base);
1576 } else {
1577 gen6_3DPRIMITIVE(cmd, p->prim_type, indexed, vertex_count,
1578 vertex_start, instance_count, instance_start, vertex_base);
1579 }
Chia-I Wu48c283d2014-08-25 23:13:46 +08001580
Chia-I Wu707a29e2014-08-27 12:51:47 +08001581 cmd->bind.draw_count++;
Chia-I Wu48c283d2014-08-25 23:13:46 +08001582 /* need to re-emit all workarounds */
1583 cmd->bind.wa_flags = 0;
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001584}
1585
Chia-I Wub2755562014-08-20 13:38:52 +08001586XGL_VOID XGLAPI intelCmdBindPipeline(
1587 XGL_CMD_BUFFER cmdBuffer,
1588 XGL_PIPELINE_BIND_POINT pipelineBindPoint,
1589 XGL_PIPELINE pipeline)
1590{
1591 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1592
1593 switch (pipelineBindPoint) {
1594 case XGL_PIPELINE_BIND_POINT_COMPUTE:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001595 cmd_bind_compute_pipeline(cmd, intel_pipeline(pipeline));
Chia-I Wub2755562014-08-20 13:38:52 +08001596 break;
1597 case XGL_PIPELINE_BIND_POINT_GRAPHICS:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001598 cmd_bind_graphics_pipeline(cmd, intel_pipeline(pipeline));
Chia-I Wub2755562014-08-20 13:38:52 +08001599 break;
1600 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001601 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +08001602 break;
1603 }
1604}
1605
1606XGL_VOID XGLAPI intelCmdBindPipelineDelta(
1607 XGL_CMD_BUFFER cmdBuffer,
1608 XGL_PIPELINE_BIND_POINT pipelineBindPoint,
1609 XGL_PIPELINE_DELTA delta)
1610{
1611 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1612
1613 switch (pipelineBindPoint) {
1614 case XGL_PIPELINE_BIND_POINT_COMPUTE:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001615 cmd_bind_compute_delta(cmd, delta);
Chia-I Wub2755562014-08-20 13:38:52 +08001616 break;
1617 case XGL_PIPELINE_BIND_POINT_GRAPHICS:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001618 cmd_bind_graphics_delta(cmd, delta);
Chia-I Wub2755562014-08-20 13:38:52 +08001619 break;
1620 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001621 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +08001622 break;
1623 }
1624}
1625
1626XGL_VOID XGLAPI intelCmdBindStateObject(
1627 XGL_CMD_BUFFER cmdBuffer,
1628 XGL_STATE_BIND_POINT stateBindPoint,
1629 XGL_STATE_OBJECT state)
1630{
1631 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1632
1633 switch (stateBindPoint) {
1634 case XGL_STATE_BIND_VIEWPORT:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001635 cmd_bind_viewport_state(cmd,
1636 intel_viewport_state((XGL_VIEWPORT_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +08001637 break;
1638 case XGL_STATE_BIND_RASTER:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001639 cmd_bind_raster_state(cmd,
1640 intel_raster_state((XGL_RASTER_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +08001641 break;
1642 case XGL_STATE_BIND_DEPTH_STENCIL:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001643 cmd_bind_ds_state(cmd,
1644 intel_ds_state((XGL_DEPTH_STENCIL_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +08001645 break;
1646 case XGL_STATE_BIND_COLOR_BLEND:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001647 cmd_bind_blend_state(cmd,
1648 intel_blend_state((XGL_COLOR_BLEND_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +08001649 break;
1650 case XGL_STATE_BIND_MSAA:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001651 cmd_bind_msaa_state(cmd,
1652 intel_msaa_state((XGL_MSAA_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +08001653 break;
1654 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001655 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +08001656 break;
1657 }
1658}
1659
1660XGL_VOID XGLAPI intelCmdBindDescriptorSet(
1661 XGL_CMD_BUFFER cmdBuffer,
1662 XGL_PIPELINE_BIND_POINT pipelineBindPoint,
1663 XGL_UINT index,
1664 XGL_DESCRIPTOR_SET descriptorSet,
1665 XGL_UINT slotOffset)
1666{
1667 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1668 struct intel_dset *dset = intel_dset(descriptorSet);
1669
1670 assert(!index);
1671
1672 switch (pipelineBindPoint) {
1673 case XGL_PIPELINE_BIND_POINT_COMPUTE:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001674 cmd_bind_compute_dset(cmd, dset, slotOffset);
Chia-I Wub2755562014-08-20 13:38:52 +08001675 break;
1676 case XGL_PIPELINE_BIND_POINT_GRAPHICS:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001677 cmd_bind_graphics_dset(cmd, dset, slotOffset);
Chia-I Wub2755562014-08-20 13:38:52 +08001678 break;
1679 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001680 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +08001681 break;
1682 }
1683}
1684
1685XGL_VOID XGLAPI intelCmdBindDynamicMemoryView(
1686 XGL_CMD_BUFFER cmdBuffer,
1687 XGL_PIPELINE_BIND_POINT pipelineBindPoint,
1688 const XGL_MEMORY_VIEW_ATTACH_INFO* pMemView)
1689{
1690 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1691
1692 switch (pipelineBindPoint) {
1693 case XGL_PIPELINE_BIND_POINT_COMPUTE:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001694 cmd_bind_compute_dyn_view(cmd, pMemView);
Chia-I Wub2755562014-08-20 13:38:52 +08001695 break;
1696 case XGL_PIPELINE_BIND_POINT_GRAPHICS:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001697 cmd_bind_graphics_dyn_view(cmd, pMemView);
Chia-I Wub2755562014-08-20 13:38:52 +08001698 break;
1699 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001700 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +08001701 break;
1702 }
1703}
1704
1705XGL_VOID XGLAPI intelCmdBindIndexData(
1706 XGL_CMD_BUFFER cmdBuffer,
1707 XGL_GPU_MEMORY mem_,
1708 XGL_GPU_SIZE offset,
1709 XGL_INDEX_TYPE indexType)
1710{
1711 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1712 struct intel_mem *mem = intel_mem(mem_);
1713
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001714 cmd_bind_index_data(cmd, mem, offset, indexType);
Chia-I Wub2755562014-08-20 13:38:52 +08001715}
1716
1717XGL_VOID XGLAPI intelCmdBindAttachments(
1718 XGL_CMD_BUFFER cmdBuffer,
1719 XGL_UINT colorAttachmentCount,
1720 const XGL_COLOR_ATTACHMENT_BIND_INFO* pColorAttachments,
1721 const XGL_DEPTH_STENCIL_BIND_INFO* pDepthStencilAttachment)
1722{
1723 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
Chia-I Wub2755562014-08-20 13:38:52 +08001724
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001725 cmd_bind_rt(cmd, pColorAttachments, colorAttachmentCount);
1726 cmd_bind_ds(cmd, pDepthStencilAttachment);
Chia-I Wub2755562014-08-20 13:38:52 +08001727}
1728
1729XGL_VOID XGLAPI intelCmdDraw(
1730 XGL_CMD_BUFFER cmdBuffer,
1731 XGL_UINT firstVertex,
1732 XGL_UINT vertexCount,
1733 XGL_UINT firstInstance,
1734 XGL_UINT instanceCount)
1735{
Chia-I Wu59c097e2014-08-21 10:51:07 +08001736 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
Chia-I Wu59c097e2014-08-21 10:51:07 +08001737
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001738 cmd_draw(cmd, firstVertex, vertexCount,
1739 firstInstance, instanceCount, false, 0);
Chia-I Wub2755562014-08-20 13:38:52 +08001740}
1741
1742XGL_VOID XGLAPI intelCmdDrawIndexed(
1743 XGL_CMD_BUFFER cmdBuffer,
1744 XGL_UINT firstIndex,
1745 XGL_UINT indexCount,
1746 XGL_INT vertexOffset,
1747 XGL_UINT firstInstance,
1748 XGL_UINT instanceCount)
1749{
Chia-I Wu59c097e2014-08-21 10:51:07 +08001750 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
Chia-I Wu59c097e2014-08-21 10:51:07 +08001751
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001752 cmd_draw(cmd, firstIndex, indexCount,
1753 firstInstance, instanceCount, true, vertexOffset);
Chia-I Wub2755562014-08-20 13:38:52 +08001754}
1755
1756XGL_VOID XGLAPI intelCmdDrawIndirect(
1757 XGL_CMD_BUFFER cmdBuffer,
1758 XGL_GPU_MEMORY mem,
1759 XGL_GPU_SIZE offset,
1760 XGL_UINT32 count,
1761 XGL_UINT32 stride)
1762{
Chia-I Wu59c097e2014-08-21 10:51:07 +08001763 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1764
1765 cmd->result = XGL_ERROR_UNKNOWN;
Chia-I Wub2755562014-08-20 13:38:52 +08001766}
1767
1768XGL_VOID XGLAPI intelCmdDrawIndexedIndirect(
1769 XGL_CMD_BUFFER cmdBuffer,
1770 XGL_GPU_MEMORY mem,
1771 XGL_GPU_SIZE offset,
1772 XGL_UINT32 count,
1773 XGL_UINT32 stride)
1774{
Chia-I Wu59c097e2014-08-21 10:51:07 +08001775 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1776
1777 cmd->result = XGL_ERROR_UNKNOWN;
Chia-I Wub2755562014-08-20 13:38:52 +08001778}
1779
1780XGL_VOID XGLAPI intelCmdDispatch(
1781 XGL_CMD_BUFFER cmdBuffer,
1782 XGL_UINT x,
1783 XGL_UINT y,
1784 XGL_UINT z)
1785{
Chia-I Wu59c097e2014-08-21 10:51:07 +08001786 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1787
1788 cmd->result = XGL_ERROR_UNKNOWN;
Chia-I Wub2755562014-08-20 13:38:52 +08001789}
1790
1791XGL_VOID XGLAPI intelCmdDispatchIndirect(
1792 XGL_CMD_BUFFER cmdBuffer,
1793 XGL_GPU_MEMORY mem,
1794 XGL_GPU_SIZE offset)
1795{
Chia-I Wu59c097e2014-08-21 10:51:07 +08001796 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1797
1798 cmd->result = XGL_ERROR_UNKNOWN;
Chia-I Wub2755562014-08-20 13:38:52 +08001799}