blob: 4961f2c9a7d7fd5744eb672ba0e9cfa02aab7d9b [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 Wub2755562014-08-20 13:38:52 +080030#include "state.h"
31#include "view.h"
32#include "cmd_priv.h"
33
Chia-I Wu48c283d2014-08-25 23:13:46 +080034enum {
35 GEN6_WA_POST_SYNC_FLUSH = 1 << 0,
Chia-I Wubb2d8ca2014-08-28 23:15:48 +080036 GEN6_WA_GEN7_VS_FLUSH = 1 << 1,
Chia-I Wu48c283d2014-08-25 23:13:46 +080037};
38
Chia-I Wu59c097e2014-08-21 10:51:07 +080039static void gen6_3DPRIMITIVE(struct intel_cmd *cmd,
Chia-I Wu254db422014-08-21 11:54:29 +080040 int prim_type, bool indexed,
Chia-I Wu59c097e2014-08-21 10:51:07 +080041 uint32_t vertex_count,
42 uint32_t vertex_start,
43 uint32_t instance_count,
44 uint32_t instance_start,
45 uint32_t vertex_base)
46{
47 const uint8_t cmd_len = 6;
48 uint32_t dw0;
49
50 CMD_ASSERT(cmd, 6, 6);
51
Chia-I Wu426072d2014-08-26 14:31:55 +080052 dw0 = GEN6_RENDER_CMD(3D, 3DPRIMITIVE) |
Chia-I Wu254db422014-08-21 11:54:29 +080053 prim_type << GEN6_3DPRIM_DW0_TYPE__SHIFT |
Chia-I Wu59c097e2014-08-21 10:51:07 +080054 (cmd_len - 2);
55
56 if (indexed)
57 dw0 |= GEN6_3DPRIM_DW0_ACCESS_RANDOM;
58
Chia-I Wue24c3292014-08-21 14:05:23 +080059 cmd_batch_reserve(cmd, cmd_len);
60 cmd_batch_write(cmd, dw0);
61 cmd_batch_write(cmd, vertex_count);
62 cmd_batch_write(cmd, vertex_start);
63 cmd_batch_write(cmd, instance_count);
64 cmd_batch_write(cmd, instance_start);
65 cmd_batch_write(cmd, vertex_base);
Chia-I Wu59c097e2014-08-21 10:51:07 +080066}
67
68static void gen7_3DPRIMITIVE(struct intel_cmd *cmd,
Chia-I Wu254db422014-08-21 11:54:29 +080069 int prim_type, bool indexed,
Chia-I Wu59c097e2014-08-21 10:51:07 +080070 uint32_t vertex_count,
71 uint32_t vertex_start,
72 uint32_t instance_count,
73 uint32_t instance_start,
74 uint32_t vertex_base)
75{
76 const uint8_t cmd_len = 7;
77 uint32_t dw0, dw1;
78
79 CMD_ASSERT(cmd, 7, 7.5);
80
Chia-I Wu426072d2014-08-26 14:31:55 +080081 dw0 = GEN6_RENDER_CMD(3D, 3DPRIMITIVE) | (cmd_len - 2);
Chia-I Wu254db422014-08-21 11:54:29 +080082 dw1 = prim_type << GEN7_3DPRIM_DW1_TYPE__SHIFT;
Chia-I Wu59c097e2014-08-21 10:51:07 +080083
84 if (indexed)
85 dw1 |= GEN7_3DPRIM_DW1_ACCESS_RANDOM;
86
Chia-I Wue24c3292014-08-21 14:05:23 +080087 cmd_batch_reserve(cmd, cmd_len);
88 cmd_batch_write(cmd, dw0);
89 cmd_batch_write(cmd, dw1);
90 cmd_batch_write(cmd, vertex_count);
91 cmd_batch_write(cmd, vertex_start);
92 cmd_batch_write(cmd, instance_count);
93 cmd_batch_write(cmd, instance_start);
94 cmd_batch_write(cmd, vertex_base);
Chia-I Wu59c097e2014-08-21 10:51:07 +080095}
96
Chia-I Wu270b1e82014-08-25 15:53:39 +080097static void gen6_PIPE_CONTROL(struct intel_cmd *cmd, uint32_t dw1,
98 struct intel_bo *bo, uint32_t bo_offset)
99{
100 const uint8_t cmd_len = 5;
Chia-I Wu426072d2014-08-26 14:31:55 +0800101 const uint32_t dw0 = GEN6_RENDER_CMD(3D, PIPE_CONTROL) |
Chia-I Wu270b1e82014-08-25 15:53:39 +0800102 (cmd_len - 2);
Chia-I Wu270b1e82014-08-25 15:53:39 +0800103
104 CMD_ASSERT(cmd, 6, 7.5);
105
106 assert(bo_offset % 8 == 0);
107
108 if (dw1 & GEN6_PIPE_CONTROL_CS_STALL) {
109 /*
110 * From the Sandy Bridge PRM, volume 2 part 1, page 73:
111 *
112 * "1 of the following must also be set (when CS stall is set):
113 *
114 * * Depth Cache Flush Enable ([0] of DW1)
115 * * Stall at Pixel Scoreboard ([1] of DW1)
116 * * Depth Stall ([13] of DW1)
117 * * Post-Sync Operation ([13] of DW1)
118 * * Render Target Cache Flush Enable ([12] of DW1)
119 * * Notify Enable ([8] of DW1)"
120 *
121 * From the Ivy Bridge PRM, volume 2 part 1, page 61:
122 *
123 * "One of the following must also be set (when CS stall is set):
124 *
125 * * Render Target Cache Flush Enable ([12] of DW1)
126 * * Depth Cache Flush Enable ([0] of DW1)
127 * * Stall at Pixel Scoreboard ([1] of DW1)
128 * * Depth Stall ([13] of DW1)
129 * * Post-Sync Operation ([13] of DW1)"
130 */
131 uint32_t bit_test = GEN6_PIPE_CONTROL_RENDER_CACHE_FLUSH |
132 GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH |
133 GEN6_PIPE_CONTROL_PIXEL_SCOREBOARD_STALL |
134 GEN6_PIPE_CONTROL_DEPTH_STALL;
135
136 /* post-sync op */
137 bit_test |= GEN6_PIPE_CONTROL_WRITE_IMM |
138 GEN6_PIPE_CONTROL_WRITE_PS_DEPTH_COUNT |
139 GEN6_PIPE_CONTROL_WRITE_TIMESTAMP;
140
141 if (cmd_gen(cmd) == INTEL_GEN(6))
142 bit_test |= GEN6_PIPE_CONTROL_NOTIFY_ENABLE;
143
144 assert(dw1 & bit_test);
145 }
146
147 if (dw1 & GEN6_PIPE_CONTROL_DEPTH_STALL) {
148 /*
149 * From the Sandy Bridge PRM, volume 2 part 1, page 73:
150 *
151 * "Following bits must be clear (when Depth Stall is set):
152 *
153 * * Render Target Cache Flush Enable ([12] of DW1)
154 * * Depth Cache Flush Enable ([0] of DW1)"
155 */
156 assert(!(dw1 & (GEN6_PIPE_CONTROL_RENDER_CACHE_FLUSH |
157 GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH)));
158 }
159
160 /*
161 * From the Sandy Bridge PRM, volume 1 part 3, page 19:
162 *
163 * "[DevSNB] PPGTT memory writes by MI_* (such as MI_STORE_DATA_IMM)
164 * and PIPE_CONTROL are not supported."
165 *
166 * The kernel will add the mapping automatically (when write domain is
167 * INTEL_DOMAIN_INSTRUCTION).
168 */
169 if (cmd_gen(cmd) == INTEL_GEN(6) && bo)
170 bo_offset |= GEN6_PIPE_CONTROL_DW2_USE_GGTT;
171
172 cmd_batch_reserve_reloc(cmd, cmd_len, (bool) bo);
173 cmd_batch_write(cmd, dw0);
174 cmd_batch_write(cmd, dw1);
Chia-I Wu32a22462014-08-26 14:13:46 +0800175 if (bo) {
176 cmd_batch_reloc(cmd, bo_offset, bo, INTEL_RELOC_GGTT |
177 INTEL_RELOC_WRITE);
178 } else {
Chia-I Wu270b1e82014-08-25 15:53:39 +0800179 cmd_batch_write(cmd, 0);
Chia-I Wu32a22462014-08-26 14:13:46 +0800180 }
Chia-I Wu270b1e82014-08-25 15:53:39 +0800181 cmd_batch_write(cmd, 0);
182 cmd_batch_write(cmd, 0);
183}
184
Chia-I Wu254db422014-08-21 11:54:29 +0800185static bool gen6_can_primitive_restart(const struct intel_cmd *cmd)
186{
187 const struct intel_pipeline *p = cmd->bind.pipeline.graphics;
188 bool supported;
189
190 CMD_ASSERT(cmd, 6, 7.5);
191
192 if (cmd_gen(cmd) >= INTEL_GEN(7.5))
193 return (p->prim_type != GEN6_3DPRIM_RECTLIST);
194
195 switch (p->prim_type) {
196 case GEN6_3DPRIM_POINTLIST:
197 case GEN6_3DPRIM_LINELIST:
198 case GEN6_3DPRIM_LINESTRIP:
199 case GEN6_3DPRIM_TRILIST:
200 case GEN6_3DPRIM_TRISTRIP:
201 supported = true;
202 break;
203 default:
204 supported = false;
205 break;
206 }
207
208 if (!supported)
209 return false;
210
211 switch (cmd->bind.index.type) {
212 case XGL_INDEX_8:
213 supported = (p->primitive_restart_index != 0xffu);
214 break;
215 case XGL_INDEX_16:
216 supported = (p->primitive_restart_index != 0xffffu);
217 break;
218 case XGL_INDEX_32:
219 supported = (p->primitive_restart_index != 0xffffffffu);
220 break;
221 default:
222 supported = false;
223 break;
224 }
225
226 return supported;
227}
228
Chia-I Wu59c097e2014-08-21 10:51:07 +0800229static void gen6_3DSTATE_INDEX_BUFFER(struct intel_cmd *cmd,
Chia-I Wu958d1b72014-08-21 11:28:11 +0800230 const struct intel_mem *mem,
Chia-I Wu59c097e2014-08-21 10:51:07 +0800231 XGL_GPU_SIZE offset,
232 XGL_INDEX_TYPE type,
233 bool enable_cut_index)
234{
235 const uint8_t cmd_len = 3;
236 uint32_t dw0, end_offset;
237 unsigned offset_align;
238
239 CMD_ASSERT(cmd, 6, 7.5);
240
Chia-I Wu426072d2014-08-26 14:31:55 +0800241 dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_INDEX_BUFFER) | (cmd_len - 2);
Chia-I Wu59c097e2014-08-21 10:51:07 +0800242
243 /* the bit is moved to 3DSTATE_VF */
244 if (cmd_gen(cmd) >= INTEL_GEN(7.5))
245 assert(!enable_cut_index);
246 if (enable_cut_index)
247 dw0 |= GEN6_IB_DW0_CUT_INDEX_ENABLE;
248
249 switch (type) {
250 case XGL_INDEX_8:
251 dw0 |= GEN6_IB_DW0_FORMAT_BYTE;
252 offset_align = 1;
253 break;
254 case XGL_INDEX_16:
255 dw0 |= GEN6_IB_DW0_FORMAT_WORD;
256 offset_align = 2;
257 break;
258 case XGL_INDEX_32:
259 dw0 |= GEN6_IB_DW0_FORMAT_DWORD;
260 offset_align = 4;
261 break;
262 default:
263 cmd->result = XGL_ERROR_INVALID_VALUE;
264 return;
265 break;
266 }
267
268 if (offset % offset_align) {
269 cmd->result = XGL_ERROR_INVALID_VALUE;
270 return;
271 }
272
273 /* aligned and inclusive */
274 end_offset = mem->size - (mem->size % offset_align) - 1;
275
Chia-I Wu2de65d02014-08-25 10:02:53 +0800276 cmd_batch_reserve_reloc(cmd, cmd_len, 2);
Chia-I Wue24c3292014-08-21 14:05:23 +0800277 cmd_batch_write(cmd, dw0);
Chia-I Wu32a22462014-08-26 14:13:46 +0800278 cmd_batch_reloc(cmd, offset, mem->bo, 0);
279 cmd_batch_reloc(cmd, end_offset, mem->bo, 0);
Chia-I Wu59c097e2014-08-21 10:51:07 +0800280}
281
Chia-I Wu254db422014-08-21 11:54:29 +0800282static inline void
283gen75_3DSTATE_VF(struct intel_cmd *cmd,
284 bool enable_cut_index,
285 uint32_t cut_index)
286{
287 const uint8_t cmd_len = 2;
288 uint32_t dw0;
289
290 CMD_ASSERT(cmd, 7.5, 7.5);
291
Chia-I Wu426072d2014-08-26 14:31:55 +0800292 dw0 = GEN75_RENDER_CMD(3D, 3DSTATE_VF) | (cmd_len - 2);
Chia-I Wu254db422014-08-21 11:54:29 +0800293 if (enable_cut_index)
294 dw0 |= GEN75_VF_DW0_CUT_INDEX_ENABLE;
295
Chia-I Wue24c3292014-08-21 14:05:23 +0800296 cmd_batch_reserve(cmd, cmd_len);
297 cmd_batch_write(cmd, dw0);
298 cmd_batch_write(cmd, cut_index);
Chia-I Wu254db422014-08-21 11:54:29 +0800299}
300
Chia-I Wud88e02d2014-08-25 10:56:13 +0800301static void gen6_3DSTATE_DRAWING_RECTANGLE(struct intel_cmd *cmd,
302 XGL_UINT width, XGL_UINT height)
303{
304 const uint8_t cmd_len = 4;
Chia-I Wu426072d2014-08-26 14:31:55 +0800305 const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_DRAWING_RECTANGLE) |
Chia-I Wud88e02d2014-08-25 10:56:13 +0800306 (cmd_len - 2);
307
308 CMD_ASSERT(cmd, 6, 7.5);
309
310 cmd_batch_reserve(cmd, cmd_len);
311 cmd_batch_write(cmd, dw0);
312 if (width && height) {
313 cmd_batch_write(cmd, 0);
314 cmd_batch_write(cmd, (height - 1) << 16 |
315 (width - 1));
316 } else {
317 cmd_batch_write(cmd, 1);
318 cmd_batch_write(cmd, 0);
319 }
320 cmd_batch_write(cmd, 0);
321}
322
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800323static void gen6_3DSTATE_DEPTH_BUFFER(struct intel_cmd *cmd,
324 const struct intel_ds_view *view)
325{
326 const uint8_t cmd_len = 7;
327 uint32_t dw0;
328
329 CMD_ASSERT(cmd, 6, 7.5);
330
331 dw0 = (cmd_gen(cmd) >= INTEL_GEN(7)) ?
Chia-I Wu426072d2014-08-26 14:31:55 +0800332 GEN7_RENDER_CMD(3D, 3DSTATE_DEPTH_BUFFER) :
333 GEN6_RENDER_CMD(3D, 3DSTATE_DEPTH_BUFFER);
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800334 dw0 |= (cmd_len - 2);
335
Chia-I Wu2de65d02014-08-25 10:02:53 +0800336 cmd_batch_reserve_reloc(cmd, cmd_len, (bool) view->img);
Chia-I Wue24c3292014-08-21 14:05:23 +0800337 cmd_batch_write(cmd, dw0);
338 cmd_batch_write(cmd, view->cmd[0]);
Courtney Goeltzenleuchtere316d972014-08-22 16:25:24 -0600339 if (view->img) {
Chia-I Wu9ee38722014-08-25 12:11:36 +0800340 cmd_batch_reloc(cmd, view->cmd[1], view->img->obj.mem->bo,
Chia-I Wu32a22462014-08-26 14:13:46 +0800341 INTEL_RELOC_WRITE);
Courtney Goeltzenleuchtere316d972014-08-22 16:25:24 -0600342 } else {
343 cmd_batch_write(cmd, 0);
344 }
Chia-I Wue24c3292014-08-21 14:05:23 +0800345 cmd_batch_write(cmd, view->cmd[2]);
346 cmd_batch_write(cmd, view->cmd[3]);
347 cmd_batch_write(cmd, view->cmd[4]);
348 cmd_batch_write(cmd, view->cmd[5]);
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800349}
350
351static void gen6_3DSTATE_STENCIL_BUFFER(struct intel_cmd *cmd,
352 const struct intel_ds_view *view)
353{
354 const uint8_t cmd_len = 3;
355 uint32_t dw0;
356
357 CMD_ASSERT(cmd, 6, 7.5);
358
359 dw0 = (cmd_gen(cmd) >= INTEL_GEN(7)) ?
Chia-I Wu426072d2014-08-26 14:31:55 +0800360 GEN7_RENDER_CMD(3D, 3DSTATE_STENCIL_BUFFER) :
361 GEN6_RENDER_CMD(3D, 3DSTATE_STENCIL_BUFFER);
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800362 dw0 |= (cmd_len - 2);
363
Chia-I Wu2de65d02014-08-25 10:02:53 +0800364 cmd_batch_reserve_reloc(cmd, cmd_len, (bool) view->img);
Chia-I Wue24c3292014-08-21 14:05:23 +0800365 cmd_batch_write(cmd, dw0);
366 cmd_batch_write(cmd, view->cmd[6]);
Courtney Goeltzenleuchtere316d972014-08-22 16:25:24 -0600367 if (view->img) {
Chia-I Wu9ee38722014-08-25 12:11:36 +0800368 cmd_batch_reloc(cmd, view->cmd[7], view->img->obj.mem->bo,
Chia-I Wu32a22462014-08-26 14:13:46 +0800369 INTEL_RELOC_WRITE);
Courtney Goeltzenleuchtere316d972014-08-22 16:25:24 -0600370 } else {
371 cmd_batch_write(cmd, 0);
372 }
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800373}
374
375static void gen6_3DSTATE_HIER_DEPTH_BUFFER(struct intel_cmd *cmd,
376 const struct intel_ds_view *view)
377{
378 const uint8_t cmd_len = 3;
379 uint32_t dw0;
380
381 CMD_ASSERT(cmd, 6, 7.5);
382
383 dw0 = (cmd_gen(cmd) >= INTEL_GEN(7)) ?
Chia-I Wu426072d2014-08-26 14:31:55 +0800384 GEN7_RENDER_CMD(3D, 3DSTATE_HIER_DEPTH_BUFFER) :
385 GEN6_RENDER_CMD(3D, 3DSTATE_HIER_DEPTH_BUFFER);
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800386 dw0 |= (cmd_len - 2);
387
Chia-I Wu2de65d02014-08-25 10:02:53 +0800388 cmd_batch_reserve_reloc(cmd, cmd_len, (bool) view->img);
Chia-I Wue24c3292014-08-21 14:05:23 +0800389 cmd_batch_write(cmd, dw0);
390 cmd_batch_write(cmd, view->cmd[8]);
Courtney Goeltzenleuchtere316d972014-08-22 16:25:24 -0600391 if (view->img) {
Chia-I Wu9ee38722014-08-25 12:11:36 +0800392 cmd_batch_reloc(cmd, view->cmd[9], view->img->obj.mem->bo,
Chia-I Wu32a22462014-08-26 14:13:46 +0800393 INTEL_RELOC_WRITE);
Courtney Goeltzenleuchtere316d972014-08-22 16:25:24 -0600394 } else {
395 cmd_batch_write(cmd, 0);
396 }
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800397}
398
Chia-I Wuf8231032014-08-25 10:44:45 +0800399static void gen6_3DSTATE_CLEAR_PARAMS(struct intel_cmd *cmd,
400 uint32_t clear_val)
401{
402 const uint8_t cmd_len = 2;
Chia-I Wu426072d2014-08-26 14:31:55 +0800403 const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_CLEAR_PARAMS) |
Chia-I Wuf8231032014-08-25 10:44:45 +0800404 GEN6_CLEAR_PARAMS_DW0_VALID |
405 (cmd_len - 2);
406
407 CMD_ASSERT(cmd, 6, 6);
408
409 cmd_batch_reserve(cmd, cmd_len);
410 cmd_batch_write(cmd, dw0);
411 cmd_batch_write(cmd, clear_val);
412}
413
414static void gen7_3DSTATE_CLEAR_PARAMS(struct intel_cmd *cmd,
415 uint32_t clear_val)
416{
417 const uint8_t cmd_len = 3;
Chia-I Wu426072d2014-08-26 14:31:55 +0800418 const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_CLEAR_PARAMS) |
Chia-I Wuf8231032014-08-25 10:44:45 +0800419 (cmd_len - 2);
420
421 CMD_ASSERT(cmd, 7, 7.5);
422
423 cmd_batch_reserve(cmd, cmd_len);
424 cmd_batch_write(cmd, dw0);
425 cmd_batch_write(cmd, clear_val);
426 cmd_batch_write(cmd, 1);
427}
428
Chia-I Wu302742d2014-08-22 10:28:29 +0800429static void gen6_3DSTATE_CC_STATE_POINTERS(struct intel_cmd *cmd,
430 XGL_UINT blend_pos,
431 XGL_UINT ds_pos,
432 XGL_UINT cc_pos)
433{
434 const uint8_t cmd_len = 4;
435 uint32_t dw0;
436
437 CMD_ASSERT(cmd, 6, 6);
438
Chia-I Wu426072d2014-08-26 14:31:55 +0800439 dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_CC_STATE_POINTERS) |
Chia-I Wu302742d2014-08-22 10:28:29 +0800440 (cmd_len - 2);
441
442 cmd_batch_reserve(cmd, cmd_len);
443 cmd_batch_write(cmd, dw0);
444 cmd_batch_write(cmd, (blend_pos << 2) | 1);
445 cmd_batch_write(cmd, (ds_pos << 2) | 1);
446 cmd_batch_write(cmd, (cc_pos << 2) | 1);
447}
448
Chia-I Wu1744cca2014-08-22 11:10:17 +0800449static void gen6_3DSTATE_VIEWPORT_STATE_POINTERS(struct intel_cmd *cmd,
450 XGL_UINT clip_pos,
451 XGL_UINT sf_pos,
452 XGL_UINT cc_pos)
453{
454 const uint8_t cmd_len = 4;
455 uint32_t dw0;
456
457 CMD_ASSERT(cmd, 6, 6);
458
Chia-I Wu426072d2014-08-26 14:31:55 +0800459 dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_VIEWPORT_STATE_POINTERS) |
Chia-I Wu1744cca2014-08-22 11:10:17 +0800460 GEN6_PTR_VP_DW0_CLIP_CHANGED |
461 GEN6_PTR_VP_DW0_SF_CHANGED |
462 GEN6_PTR_VP_DW0_CC_CHANGED |
463 (cmd_len - 2);
464
465 cmd_batch_reserve(cmd, cmd_len);
466 cmd_batch_write(cmd, dw0);
467 cmd_batch_write(cmd, clip_pos << 2);
468 cmd_batch_write(cmd, sf_pos << 2);
469 cmd_batch_write(cmd, cc_pos << 2);
470}
471
472static void gen6_3DSTATE_SCISSOR_STATE_POINTERS(struct intel_cmd *cmd,
473 XGL_UINT scissor_pos)
474{
475 const uint8_t cmd_len = 2;
476 uint32_t dw0;
477
478 CMD_ASSERT(cmd, 6, 6);
479
Chia-I Wu426072d2014-08-26 14:31:55 +0800480 dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_SCISSOR_STATE_POINTERS) |
Chia-I Wu1744cca2014-08-22 11:10:17 +0800481 (cmd_len - 2);
482
483 cmd_batch_reserve(cmd, cmd_len);
484 cmd_batch_write(cmd, dw0);
485 cmd_batch_write(cmd, scissor_pos << 2);
486}
487
Chia-I Wu42a56202014-08-23 16:47:48 +0800488static void gen6_3DSTATE_BINDING_TABLE_POINTERS(struct intel_cmd *cmd,
489 XGL_UINT vs_pos,
490 XGL_UINT gs_pos,
491 XGL_UINT ps_pos)
492{
493 const uint8_t cmd_len = 4;
494 uint32_t dw0;
495
496 CMD_ASSERT(cmd, 6, 6);
497
Chia-I Wu426072d2014-08-26 14:31:55 +0800498 dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_BINDING_TABLE_POINTERS) |
Chia-I Wu42a56202014-08-23 16:47:48 +0800499 GEN6_PTR_BINDING_TABLE_DW0_VS_CHANGED |
500 GEN6_PTR_BINDING_TABLE_DW0_GS_CHANGED |
501 GEN6_PTR_BINDING_TABLE_DW0_PS_CHANGED |
502 (cmd_len - 2);
503
504 cmd_batch_reserve(cmd, cmd_len);
505 cmd_batch_write(cmd, dw0);
506 cmd_batch_write(cmd, vs_pos << 2);
507 cmd_batch_write(cmd, gs_pos << 2);
508 cmd_batch_write(cmd, ps_pos << 2);
509}
510
Chia-I Wu302742d2014-08-22 10:28:29 +0800511static void gen7_3dstate_pointer(struct intel_cmd *cmd,
512 int subop, XGL_UINT pos)
513{
514 const uint8_t cmd_len = 2;
515 const uint32_t dw0 = GEN6_RENDER_TYPE_RENDER |
516 GEN6_RENDER_SUBTYPE_3D |
517 subop | (cmd_len - 2);
518
519 cmd_batch_reserve(cmd, cmd_len);
520 cmd_batch_write(cmd, dw0);
521 cmd_batch_write(cmd, pos << 2);
522}
523
524static XGL_UINT gen6_BLEND_STATE(struct intel_cmd *cmd,
525 const struct intel_blend_state *state)
526{
527 const uint8_t cmd_align = GEN6_ALIGNMENT_BLEND_STATE;
528 const uint8_t cmd_len = XGL_MAX_COLOR_ATTACHMENTS * 2;
529
530 CMD_ASSERT(cmd, 6, 7.5);
531 STATIC_ASSERT(ARRAY_SIZE(state->cmd) >= cmd_len);
532
533 return cmd_state_copy(cmd, state->cmd, cmd_len, cmd_align);
534}
535
536static XGL_UINT gen6_DEPTH_STENCIL_STATE(struct intel_cmd *cmd,
537 const struct intel_ds_state *state)
538{
539 const uint8_t cmd_align = GEN6_ALIGNMENT_DEPTH_STENCIL_STATE;
540 const uint8_t cmd_len = 3;
541
542 CMD_ASSERT(cmd, 6, 7.5);
543 STATIC_ASSERT(ARRAY_SIZE(state->cmd) >= cmd_len);
544
545 return cmd_state_copy(cmd, state->cmd, cmd_len, cmd_align);
546}
547
548static XGL_UINT gen6_COLOR_CALC_STATE(struct intel_cmd *cmd,
549 uint32_t stencil_ref,
550 const uint32_t blend_color[4])
551{
552 const uint8_t cmd_align = GEN6_ALIGNMENT_COLOR_CALC_STATE;
553 const uint8_t cmd_len = 6;
554 XGL_UINT pos;
555 uint32_t *dw;
556
557 CMD_ASSERT(cmd, 6, 7.5);
558
559 dw = cmd_state_reserve(cmd, cmd_len, cmd_align, &pos);
560 dw[0] = stencil_ref;
561 dw[1] = 0;
562 dw[2] = blend_color[0];
563 dw[3] = blend_color[1];
564 dw[4] = blend_color[2];
565 dw[5] = blend_color[3];
566 cmd_state_advance(cmd, cmd_len);
567
568 return pos;
569}
570
Chia-I Wu48c283d2014-08-25 23:13:46 +0800571static void gen6_wa_post_sync_flush(struct intel_cmd *cmd)
572{
Chia-I Wu707a29e2014-08-27 12:51:47 +0800573 if (!cmd->bind.draw_count)
574 return;
575
Chia-I Wu48c283d2014-08-25 23:13:46 +0800576 if (cmd->bind.wa_flags & GEN6_WA_POST_SYNC_FLUSH)
577 return;
578
579 CMD_ASSERT(cmd, 6, 7.5);
580
581 cmd->bind.wa_flags |= GEN6_WA_POST_SYNC_FLUSH;
582
583 /*
584 * From the Sandy Bridge PRM, volume 2 part 1, page 60:
585 *
586 * "Pipe-control with CS-stall bit set must be sent BEFORE the
587 * pipe-control with a post-sync op and no write-cache flushes."
588 *
589 * The workaround below necessitates this workaround.
590 */
591 gen6_PIPE_CONTROL(cmd,
592 GEN6_PIPE_CONTROL_CS_STALL |
593 GEN6_PIPE_CONTROL_PIXEL_SCOREBOARD_STALL,
594 NULL, 0);
595
596 /*
597 * From the Sandy Bridge PRM, volume 2 part 1, page 60:
598 *
599 * "Before any depth stall flush (including those produced by
600 * non-pipelined state commands), software needs to first send a
601 * PIPE_CONTROL with no bits set except Post-Sync Operation != 0."
602 *
603 * "Before a PIPE_CONTROL with Write Cache Flush Enable =1, a
604 * PIPE_CONTROL with any non-zero post-sync-op is required."
605 */
606 gen6_PIPE_CONTROL(cmd, GEN6_PIPE_CONTROL_WRITE_IMM, cmd->scratch_bo, 0);
607}
608
Courtney Goeltzenleuchterf9e1a412014-08-27 13:59:36 -0600609static void gen6_wa_wm_multisample_flush(struct intel_cmd *cmd)
610{
Chia-I Wu9cb84ee2014-08-28 10:12:34 +0800611 if (!cmd->bind.draw_count)
612 return;
613
Courtney Goeltzenleuchterf9e1a412014-08-27 13:59:36 -0600614 CMD_ASSERT(cmd, 6, 6);
615
616 gen6_wa_post_sync_flush(cmd);
617
618 /*
619 * From the Sandy Bridge PRM, volume 2 part 1, page 305:
620 *
621 * "Driver must guarentee that all the caches in the depth pipe are
622 * flushed before this command (3DSTATE_MULTISAMPLE) is parsed. This
623 * requires driver to send a PIPE_CONTROL with a CS stall along with a
624 * Depth Flush prior to this command."
625 */
626 gen6_PIPE_CONTROL(cmd,
627 GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH |
628 GEN6_PIPE_CONTROL_CS_STALL,
629 0, 0);
630}
631
Chia-I Wu48c283d2014-08-25 23:13:46 +0800632static void gen6_wa_ds_flush(struct intel_cmd *cmd)
633{
Chia-I Wu707a29e2014-08-27 12:51:47 +0800634 if (!cmd->bind.draw_count)
635 return;
636
Chia-I Wu48c283d2014-08-25 23:13:46 +0800637 CMD_ASSERT(cmd, 6, 7.5);
638
Chia-I Wu48c283d2014-08-25 23:13:46 +0800639 gen6_wa_post_sync_flush(cmd);
640
641 gen6_PIPE_CONTROL(cmd, GEN6_PIPE_CONTROL_DEPTH_STALL, NULL, 0);
642 gen6_PIPE_CONTROL(cmd, GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH, NULL, 0);
643 gen6_PIPE_CONTROL(cmd, GEN6_PIPE_CONTROL_DEPTH_STALL, NULL, 0);
644}
645
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800646static void gen7_wa_vs_flush(struct intel_cmd *cmd)
647{
648 if (!cmd->bind.draw_count)
649 return;
650
651 if (cmd->bind.wa_flags & GEN6_WA_GEN7_VS_FLUSH)
652 return;
653
654 CMD_ASSERT(cmd, 7, 7.5);
655
656 cmd->bind.wa_flags |= GEN6_WA_GEN7_VS_FLUSH;
657
658 gen6_PIPE_CONTROL(cmd,
659 GEN6_PIPE_CONTROL_DEPTH_STALL | GEN6_PIPE_CONTROL_WRITE_IMM,
660 cmd->scratch_bo, 0);
661}
662
Chia-I Wu525c6602014-08-27 10:22:34 +0800663void cmd_batch_flush(struct intel_cmd *cmd, uint32_t pipe_control_dw0)
664{
665 if (!cmd->bind.draw_count)
666 return;
667
668 assert(!(pipe_control_dw0 & GEN6_PIPE_CONTROL_WRITE__MASK));
669
670 if (pipe_control_dw0 & GEN6_PIPE_CONTROL_RENDER_CACHE_FLUSH)
671 gen6_wa_post_sync_flush(cmd);
672
673 gen6_PIPE_CONTROL(cmd, pipe_control_dw0, NULL, 0);
674}
675
Chia-I Wu302742d2014-08-22 10:28:29 +0800676static void gen6_cc_states(struct intel_cmd *cmd)
677{
678 const struct intel_blend_state *blend = cmd->bind.state.blend;
679 const struct intel_ds_state *ds = cmd->bind.state.ds;
680 XGL_UINT blend_pos, ds_pos, cc_pos;
Chia-I Wuce9f11f2014-08-22 10:38:51 +0800681 uint32_t stencil_ref;
682 uint32_t blend_color[4];
Chia-I Wu302742d2014-08-22 10:28:29 +0800683
684 CMD_ASSERT(cmd, 6, 6);
685
Chia-I Wuce9f11f2014-08-22 10:38:51 +0800686 if (blend) {
687 blend_pos = gen6_BLEND_STATE(cmd, blend);
688 memcpy(blend_color, blend->cmd_blend_color, sizeof(blend_color));
689 } else {
690 blend_pos = 0;
691 memset(blend_color, 0, sizeof(blend_color));
692 }
693
694 if (ds) {
695 ds_pos = gen6_DEPTH_STENCIL_STATE(cmd, ds);
696 stencil_ref = ds->cmd_stencil_ref;
697 } else {
698 ds_pos = 0;
699 stencil_ref = 0;
700 }
701
702 cc_pos = gen6_COLOR_CALC_STATE(cmd, stencil_ref, blend_color);
Chia-I Wu302742d2014-08-22 10:28:29 +0800703
704 gen6_3DSTATE_CC_STATE_POINTERS(cmd, blend_pos, ds_pos, cc_pos);
705}
706
Chia-I Wu1744cca2014-08-22 11:10:17 +0800707static void gen6_viewport_states(struct intel_cmd *cmd)
708{
709 const struct intel_viewport_state *viewport = cmd->bind.state.viewport;
710 XGL_UINT pos;
711
712 if (!viewport)
713 return;
714
715 pos = cmd_state_copy(cmd, viewport->cmd, viewport->cmd_len,
716 viewport->cmd_align);
717
718 gen6_3DSTATE_VIEWPORT_STATE_POINTERS(cmd,
719 pos + viewport->cmd_clip_offset,
720 pos,
721 pos + viewport->cmd_cc_offset);
722
723 pos = (viewport->scissor_enable) ?
724 pos + viewport->cmd_scissor_rect_offset : 0;
725
726 gen6_3DSTATE_SCISSOR_STATE_POINTERS(cmd, pos);
727}
728
Chia-I Wu302742d2014-08-22 10:28:29 +0800729static void gen7_cc_states(struct intel_cmd *cmd)
730{
731 const struct intel_blend_state *blend = cmd->bind.state.blend;
732 const struct intel_ds_state *ds = cmd->bind.state.ds;
Chia-I Wuce9f11f2014-08-22 10:38:51 +0800733 uint32_t stencil_ref;
734 uint32_t blend_color[4];
Chia-I Wu302742d2014-08-22 10:28:29 +0800735 XGL_UINT pos;
736
737 CMD_ASSERT(cmd, 7, 7.5);
738
Chia-I Wuce9f11f2014-08-22 10:38:51 +0800739 if (!blend && !ds)
740 return;
Chia-I Wu302742d2014-08-22 10:28:29 +0800741
Chia-I Wuce9f11f2014-08-22 10:38:51 +0800742 if (blend) {
743 pos = gen6_BLEND_STATE(cmd, blend);
744 gen7_3dstate_pointer(cmd,
745 GEN7_RENDER_OPCODE_3DSTATE_BLEND_STATE_POINTERS, pos);
Chia-I Wu302742d2014-08-22 10:28:29 +0800746
Chia-I Wuce9f11f2014-08-22 10:38:51 +0800747 memcpy(blend_color, blend->cmd_blend_color, sizeof(blend_color));
748 } else {
749 memset(blend_color, 0, sizeof(blend_color));
750 }
751
752 if (ds) {
753 pos = gen6_DEPTH_STENCIL_STATE(cmd, ds);
754 gen7_3dstate_pointer(cmd,
755 GEN7_RENDER_OPCODE_3DSTATE_DEPTH_STENCIL_STATE_POINTERS, pos);
756 } else {
757 stencil_ref = 0;
758 }
759
760 pos = gen6_COLOR_CALC_STATE(cmd, stencil_ref, blend_color);
Chia-I Wu302742d2014-08-22 10:28:29 +0800761 gen7_3dstate_pointer(cmd,
762 GEN6_RENDER_OPCODE_3DSTATE_CC_STATE_POINTERS, pos);
763}
764
Chia-I Wu1744cca2014-08-22 11:10:17 +0800765static void gen7_viewport_states(struct intel_cmd *cmd)
766{
767 const struct intel_viewport_state *viewport = cmd->bind.state.viewport;
768 XGL_UINT pos;
769
770 if (!viewport)
771 return;
772
773 pos = cmd_state_copy(cmd, viewport->cmd, viewport->cmd_len,
774 viewport->cmd_align);
775
776 gen7_3dstate_pointer(cmd,
777 GEN7_RENDER_OPCODE_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP, pos);
778 gen7_3dstate_pointer(cmd,
779 GEN7_RENDER_OPCODE_3DSTATE_VIEWPORT_STATE_POINTERS_CC,
780 pos + viewport->cmd_cc_offset);
781 if (viewport->scissor_enable) {
782 gen7_3dstate_pointer(cmd,
783 GEN6_RENDER_OPCODE_3DSTATE_SCISSOR_STATE_POINTERS,
784 pos + viewport->cmd_scissor_rect_offset);
785 }
786}
787
Chia-I Wu7fd5cac2014-08-27 13:19:29 +0800788static void gen6_pcb(struct intel_cmd *cmd, int subop,
789 const XGL_PIPELINE_SHADER *sh)
790{
791 const uint8_t cmd_len = 5;
792 const XGL_UINT alignment = 32;
793 const XGL_UINT max_size =
794 (subop == GEN6_RENDER_OPCODE_3DSTATE_CONSTANT_VS) ? 1024 : 2048;
795 const XGL_UINT max_pcb = 4;
796 uint32_t pcb[4] = { 0, 0, 0, 0 };
797 XGL_FLAGS pcb_enables = 0;
798 XGL_SIZE total_size = 0;
799 uint32_t dw0;
800 XGL_UINT i;
801
802 for (i = 0; i < sh->linkConstBufferCount; i++) {
803 const XGL_LINK_CONST_BUFFER *info = &sh->pLinkConstBufferInfo[i];
804 const XGL_SIZE size = u_align(info->bufferSize, alignment);
805 void *ptr;
806
807 if (info->bufferId >= max_pcb ||
808 pcb_enables & ((1 << info->bufferId)) ||
809 total_size + info->bufferSize > max_size) {
810 cmd->result = XGL_ERROR_UNKNOWN;
811 return;
812 }
813 if (!size)
814 continue;
815
816 pcb_enables |= 1 << info->bufferId;
817 total_size += size;
818
819 ptr = cmd_state_reserve(cmd, size / sizeof(uint32_t),
820 alignment / sizeof(uint32_t), &pcb[info->bufferId]);
821 memcpy(ptr, info->pBufferData, info->bufferSize);
822 cmd_state_advance(cmd, size / sizeof(uint32_t));
823
824 pcb[info->bufferId] |= size / alignment - 1;
825 }
826
827 dw0 = GEN6_RENDER_TYPE_RENDER |
828 GEN6_RENDER_SUBTYPE_3D |
829 subop |
830 pcb_enables << 12 |
831 (cmd_len - 2);
832
833 cmd_batch_reserve(cmd, cmd_len);
834 cmd_batch_write(cmd, dw0);
835 cmd_batch_write(cmd, pcb[0]);
836 cmd_batch_write(cmd, pcb[1]);
837 cmd_batch_write(cmd, pcb[2]);
838 cmd_batch_write(cmd, pcb[3]);
839}
840
841static void gen7_pcb(struct intel_cmd *cmd, int subop,
842 const XGL_PIPELINE_SHADER *sh)
843{
844 const uint8_t cmd_len = 7;
845 const uint32_t dw0 = GEN6_RENDER_TYPE_RENDER |
846 GEN6_RENDER_SUBTYPE_3D |
847 subop |
848 (cmd_len - 2);
849 const XGL_UINT alignment = 32;
850 const XGL_UINT max_size = 2048;
851 const XGL_UINT max_pcb = 4;
852 uint16_t pcb_len[4] = { 0, 0, 0, 0 };
853 uint32_t pcb[4] = { 0, 0, 0, 0 };
854 XGL_FLAGS pcb_enables = 0;
855 XGL_SIZE total_size = 0;
856 XGL_UINT i;
857
858 for (i = 0; i < sh->linkConstBufferCount; i++) {
859 const XGL_LINK_CONST_BUFFER *info = &sh->pLinkConstBufferInfo[i];
860 const XGL_SIZE size = u_align(info->bufferSize, alignment);
861 void *ptr;
862
863 if (info->bufferId >= max_pcb ||
864 pcb_enables & ((1 << info->bufferId)) ||
865 total_size + info->bufferSize > max_size) {
866 cmd->result = XGL_ERROR_UNKNOWN;
867 return;
868 }
869 if (!size)
870 continue;
871
872 pcb_enables |= 1 << info->bufferId;
873 total_size += size;
874
875 pcb_len[info->bufferId] = size / alignment;
876
877 ptr = cmd_state_reserve(cmd, size / sizeof(uint32_t),
878 alignment / sizeof(uint32_t), &pcb[info->bufferId]);
879 memcpy(ptr, info->pBufferData, info->bufferSize);
880 cmd_state_advance(cmd, size / sizeof(uint32_t));
881 }
882
883 /* no holes */
884 if (!u_is_pow2(pcb_enables + 1)) {
885 cmd->result = XGL_ERROR_UNKNOWN;
886 return;
887 }
888
889 cmd_batch_reserve(cmd, cmd_len);
890 cmd_batch_write(cmd, dw0);
891 cmd_batch_write(cmd, pcb_len[1] << 16 | pcb_len[0]);
892 cmd_batch_write(cmd, pcb_len[3] << 16 | pcb_len[2]);
893 cmd_batch_write(cmd, pcb[0]);
894 cmd_batch_write(cmd, pcb[1]);
895 cmd_batch_write(cmd, pcb[2]);
896 cmd_batch_write(cmd, pcb[3]);
897}
898
Chia-I Wu42a56202014-08-23 16:47:48 +0800899static void emit_ps_resources(struct intel_cmd *cmd,
900 const struct intel_rmap *rmap)
901{
902 const XGL_UINT surface_count = rmap->rt_count +
903 rmap->resource_count + rmap->uav_count;
904 uint32_t binding_table[256];
905 XGL_UINT pos, i;
906
907 assert(surface_count <= ARRAY_SIZE(binding_table));
908
909 for (i = 0; i < surface_count; i++) {
910 const struct intel_rmap_slot *slot = &rmap->slots[i];
911 uint32_t *dw;
912
913 switch (slot->path_len) {
914 case 0:
915 pos = 0;
916 break;
917 case INTEL_RMAP_SLOT_RT:
918 {
919 const struct intel_rt_view *view = cmd->bind.att.rt[i];
920
921 dw = cmd_state_reserve_reloc(cmd, view->cmd_len, 1,
922 GEN6_ALIGNMENT_SURFACE_STATE, &pos);
923
924 memcpy(dw, view->cmd, sizeof(uint32_t) * view->cmd_len);
Chia-I Wubda55fd2014-08-25 12:46:10 +0800925 cmd_state_reloc(cmd, 1, view->cmd[1], view->img->obj.mem->bo,
Chia-I Wu32a22462014-08-26 14:13:46 +0800926 INTEL_RELOC_WRITE);
Chia-I Wu42a56202014-08-23 16:47:48 +0800927 cmd_state_advance(cmd, view->cmd_len);
928 }
929 break;
930 case INTEL_RMAP_SLOT_DYN:
931 {
932 const struct intel_mem_view *view =
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800933 &cmd->bind.dyn_view.graphics;
Chia-I Wu42a56202014-08-23 16:47:48 +0800934
935 dw = cmd_state_reserve_reloc(cmd, view->cmd_len, 1,
936 GEN6_ALIGNMENT_SURFACE_STATE, &pos);
937
938 memcpy(dw, view->cmd, sizeof(uint32_t) * view->cmd_len);
Chia-I Wubda55fd2014-08-25 12:46:10 +0800939 cmd_state_reloc(cmd, 1, view->cmd[1], view->mem->bo,
Chia-I Wu32a22462014-08-26 14:13:46 +0800940 INTEL_RELOC_WRITE);
Chia-I Wu42a56202014-08-23 16:47:48 +0800941 cmd_state_advance(cmd, view->cmd_len);
942 }
943 break;
944 case 1:
945 default:
946 /* TODO */
947 assert(!"no dset support");
948 break;
949 }
950
951 binding_table[i] = pos << 2;
952 }
953
954 pos = cmd_state_copy(cmd, binding_table, surface_count,
955 GEN6_ALIGNMENT_BINDING_TABLE_STATE);
956
957 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
958 gen7_3dstate_pointer(cmd,
959 GEN7_RENDER_OPCODE_3DSTATE_BINDING_TABLE_POINTERS_PS, pos);
960 } else {
961 gen6_3DSTATE_BINDING_TABLE_POINTERS(cmd, 0, 0, pos);
962 }
963}
964
Chia-I Wu52500102014-08-22 00:46:04 +0800965static void emit_bounded_states(struct intel_cmd *cmd)
966{
967 const struct intel_msaa_state *msaa = cmd->bind.state.msaa;
968
969 /* TODO more states */
970
Chia-I Wu1744cca2014-08-22 11:10:17 +0800971 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
Chia-I Wu302742d2014-08-22 10:28:29 +0800972 gen7_cc_states(cmd);
Chia-I Wu1744cca2014-08-22 11:10:17 +0800973 gen7_viewport_states(cmd);
Chia-I Wu7fd5cac2014-08-27 13:19:29 +0800974
975 gen7_pcb(cmd, GEN6_RENDER_OPCODE_3DSTATE_CONSTANT_VS,
976 &cmd->bind.pipeline.graphics->vs);
977 gen7_pcb(cmd, GEN6_RENDER_OPCODE_3DSTATE_CONSTANT_PS,
978 &cmd->bind.pipeline.graphics->fs);
Chia-I Wu1744cca2014-08-22 11:10:17 +0800979 } else {
Chia-I Wu302742d2014-08-22 10:28:29 +0800980 gen6_cc_states(cmd);
Chia-I Wu1744cca2014-08-22 11:10:17 +0800981 gen6_viewport_states(cmd);
Chia-I Wu7fd5cac2014-08-27 13:19:29 +0800982
983 gen6_pcb(cmd, GEN6_RENDER_OPCODE_3DSTATE_CONSTANT_VS,
984 &cmd->bind.pipeline.graphics->vs);
985 gen6_pcb(cmd, GEN6_RENDER_OPCODE_3DSTATE_CONSTANT_PS,
986 &cmd->bind.pipeline.graphics->fs);
Chia-I Wu1744cca2014-08-22 11:10:17 +0800987 }
Chia-I Wu302742d2014-08-22 10:28:29 +0800988
Chia-I Wu42a56202014-08-23 16:47:48 +0800989 emit_ps_resources(cmd, cmd->bind.pipeline.graphics->fs_rmap);
990
Chia-I Wu48c283d2014-08-25 23:13:46 +0800991 gen6_wa_post_sync_flush(cmd);
Chia-I Wu9cb84ee2014-08-28 10:12:34 +0800992 /* need multisample flush on gen6 */
993 if (cmd_gen(cmd) == INTEL_GEN(6))
994 gen6_wa_wm_multisample_flush(cmd);
995 /* 3DSTATE_MULTISAMPLE and 3DSTATE_SAMPLE_MASK */
Chia-I Wu52500102014-08-22 00:46:04 +0800996 cmd_batch_reserve(cmd, msaa->cmd_len);
997 cmd_batch_write_n(cmd, msaa->cmd, msaa->cmd_len);
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -0600998}
999
1000static void emit_shader(struct intel_cmd *cmd,
Chia-I Wu338fe642014-08-28 10:43:04 +08001001 const struct intel_pipe_shader *shader)
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001002{
1003 uint32_t i;
1004 struct intel_cmd_shader *cmdShader;
1005
1006 for (i=0; i<cmd->bind.shaderCache.used; i++) {
Chia-I Wu338fe642014-08-28 10:43:04 +08001007 if (cmd->bind.shaderCache.shaderArray[i].shader == shader) {
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001008 /* shader is already part of pipeline */
1009 return;
1010 }
1011 }
1012
Chia-I Wu338fe642014-08-28 10:43:04 +08001013 if (cmd->bind.shaderCache.used == cmd->bind.shaderCache.count) {
1014 const XGL_UINT new_count = cmd->bind.shaderCache.count + 16;
1015
1016 cmdShader = cmd->bind.shaderCache.shaderArray;
1017
1018 cmd->bind.shaderCache.shaderArray =
1019 icd_alloc(sizeof(*cmdShader) * new_count,
1020 0, XGL_SYSTEM_ALLOC_INTERNAL);
1021 if (cmd->bind.shaderCache.shaderArray == NULL) {
1022 cmd->bind.shaderCache.shaderArray = cmdShader;
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001023 cmd->result = XGL_ERROR_OUT_OF_MEMORY;
1024 return;
1025 }
Chia-I Wu338fe642014-08-28 10:43:04 +08001026
1027 if (cmdShader) {
1028 memcpy(cmd->bind.shaderCache.shaderArray, cmdShader,
1029 sizeof(*cmdShader) * cmd->bind.shaderCache.used);
1030 icd_free(cmdShader);
1031 }
1032
1033 cmd->bind.shaderCache.count = new_count;
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001034 }
1035
Chia-I Wu338fe642014-08-28 10:43:04 +08001036 cmdShader = &cmd->bind.shaderCache.shaderArray[cmd->bind.shaderCache.used];
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001037 cmdShader->shader = shader;
1038 cmdShader->kernel_pos = cmd_kernel_copy(cmd, shader->pCode, shader->codeSize);
1039 cmd->bind.shaderCache.used++;
1040 return;
1041}
1042
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001043static void cmd_bind_graphics_pipeline(struct intel_cmd *cmd,
Chia-I Wu338fe642014-08-28 10:43:04 +08001044 const struct intel_pipeline *pipeline)
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001045{
1046 cmd->bind.pipeline.graphics = pipeline;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +08001047
1048 if (cmd_gen(cmd) >= INTEL_GEN(7))
1049 gen7_wa_vs_flush(cmd);
1050
1051 /* 3DSTATE_URB_VS and etc. */
1052 assert(pipeline->cmd_urb_alloc_len);
1053 cmd_batch_write_n(cmd, pipeline->cmd_urb_alloc,
1054 pipeline->cmd_urb_alloc_len);
1055
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -06001056 if (pipeline->active_shaders & SHADER_VERTEX_FLAG) {
1057 emit_shader(cmd, &pipeline->intel_vs);
1058 }
1059 if (pipeline->active_shaders & SHADER_GEOMETRY_FLAG) {
1060 emit_shader(cmd, &pipeline->gs);
1061 }
1062 if (pipeline->active_shaders & SHADER_FRAGMENT_FLAG) {
1063 emit_shader(cmd, &pipeline->intel_fs);
1064 }
1065 if (pipeline->active_shaders & SHADER_TESS_CONTROL_FLAG) {
1066 emit_shader(cmd, &pipeline->tess_control);
1067 }
1068 if (pipeline->active_shaders & SHADER_TESS_EVAL_FLAG) {
1069 emit_shader(cmd, &pipeline->tess_eval);
1070 }
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001071}
1072
1073static void cmd_bind_compute_pipeline(struct intel_cmd *cmd,
1074 const struct intel_pipeline *pipeline)
1075{
1076 cmd->bind.pipeline.compute = pipeline;
1077}
1078
1079static void cmd_bind_graphics_delta(struct intel_cmd *cmd,
1080 const struct intel_pipeline_delta *delta)
1081{
1082 cmd->bind.pipeline.graphics_delta = delta;
1083}
1084
1085static void cmd_bind_compute_delta(struct intel_cmd *cmd,
1086 const struct intel_pipeline_delta *delta)
1087{
1088 cmd->bind.pipeline.compute_delta = delta;
1089}
1090
1091static void cmd_bind_graphics_dset(struct intel_cmd *cmd,
1092 const struct intel_dset *dset,
1093 XGL_UINT slot_offset)
1094{
1095 cmd->bind.dset.graphics = dset;
1096 cmd->bind.dset.graphics_offset = slot_offset;
1097}
1098
1099static void cmd_bind_compute_dset(struct intel_cmd *cmd,
1100 const struct intel_dset *dset,
1101 XGL_UINT slot_offset)
1102{
1103 cmd->bind.dset.compute = dset;
1104 cmd->bind.dset.compute_offset = slot_offset;
1105}
1106
1107static void cmd_bind_graphics_dyn_view(struct intel_cmd *cmd,
1108 const XGL_MEMORY_VIEW_ATTACH_INFO *info)
1109{
1110 intel_mem_view_init(&cmd->bind.dyn_view.graphics, cmd->dev, info);
1111}
1112
1113static void cmd_bind_compute_dyn_view(struct intel_cmd *cmd,
1114 const XGL_MEMORY_VIEW_ATTACH_INFO *info)
1115{
1116 intel_mem_view_init(&cmd->bind.dyn_view.compute, cmd->dev, info);
1117}
1118
1119static void cmd_bind_index_data(struct intel_cmd *cmd,
1120 const struct intel_mem *mem,
1121 XGL_GPU_SIZE offset, XGL_INDEX_TYPE type)
1122{
1123 if (cmd_gen(cmd) >= INTEL_GEN(7.5)) {
1124 gen6_3DSTATE_INDEX_BUFFER(cmd, mem, offset, type, false);
1125 } else {
1126 cmd->bind.index.mem = mem;
1127 cmd->bind.index.offset = offset;
1128 cmd->bind.index.type = type;
1129 }
1130}
1131
1132static void cmd_bind_rt(struct intel_cmd *cmd,
1133 const XGL_COLOR_ATTACHMENT_BIND_INFO *attachments,
1134 XGL_UINT count)
1135{
Chia-I Wud88e02d2014-08-25 10:56:13 +08001136 XGL_UINT width = 0, height = 0;
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001137 XGL_UINT i;
1138
1139 for (i = 0; i < count; i++) {
1140 const XGL_COLOR_ATTACHMENT_BIND_INFO *att = &attachments[i];
1141 const struct intel_rt_view *rt = intel_rt_view(att->view);
Chia-I Wud88e02d2014-08-25 10:56:13 +08001142 const struct intel_layout *layout = &rt->img->layout;
1143
1144 if (i == 0) {
1145 width = layout->width0;
1146 height = layout->height0;
1147 } else {
1148 if (width > layout->width0)
1149 width = layout->width0;
1150 if (height > layout->height0)
1151 height = layout->height0;
1152 }
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001153
1154 cmd->bind.att.rt[i] = rt;
1155 }
1156
1157 cmd->bind.att.rt_count = count;
Chia-I Wud88e02d2014-08-25 10:56:13 +08001158
Chia-I Wu48c283d2014-08-25 23:13:46 +08001159 gen6_wa_post_sync_flush(cmd);
Chia-I Wud88e02d2014-08-25 10:56:13 +08001160 gen6_3DSTATE_DRAWING_RECTANGLE(cmd, width, height);
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001161}
1162
1163static void cmd_bind_ds(struct intel_cmd *cmd,
1164 const XGL_DEPTH_STENCIL_BIND_INFO *info)
1165{
1166 const struct intel_ds_view *ds;
1167
1168 if (info) {
1169 cmd->bind.att.ds = intel_ds_view(info->view);
1170 ds = cmd->bind.att.ds;
1171 } else {
1172 /* all zeros */
1173 static const struct intel_ds_view null_ds;
1174 ds = &null_ds;
1175 }
1176
Chia-I Wu48c283d2014-08-25 23:13:46 +08001177 gen6_wa_ds_flush(cmd);
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001178 gen6_3DSTATE_DEPTH_BUFFER(cmd, ds);
1179 gen6_3DSTATE_STENCIL_BUFFER(cmd, ds);
1180 gen6_3DSTATE_HIER_DEPTH_BUFFER(cmd, ds);
Chia-I Wuf8231032014-08-25 10:44:45 +08001181
1182 if (cmd_gen(cmd) >= INTEL_GEN(7))
1183 gen7_3DSTATE_CLEAR_PARAMS(cmd, 0);
1184 else
1185 gen6_3DSTATE_CLEAR_PARAMS(cmd, 0);
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001186}
1187
1188static void cmd_bind_viewport_state(struct intel_cmd *cmd,
1189 const struct intel_viewport_state *state)
1190{
1191 cmd->bind.state.viewport = state;
1192}
1193
1194static void cmd_bind_raster_state(struct intel_cmd *cmd,
1195 const struct intel_raster_state *state)
1196{
1197 cmd->bind.state.raster = state;
1198}
1199
1200static void cmd_bind_ds_state(struct intel_cmd *cmd,
1201 const struct intel_ds_state *state)
1202{
1203 cmd->bind.state.ds = state;
1204}
1205
1206static void cmd_bind_blend_state(struct intel_cmd *cmd,
1207 const struct intel_blend_state *state)
1208{
1209 cmd->bind.state.blend = state;
1210}
1211
1212static void cmd_bind_msaa_state(struct intel_cmd *cmd,
1213 const struct intel_msaa_state *state)
1214{
1215 cmd->bind.state.msaa = state;
1216}
1217
1218static void cmd_draw(struct intel_cmd *cmd,
1219 XGL_UINT vertex_start,
1220 XGL_UINT vertex_count,
1221 XGL_UINT instance_start,
1222 XGL_UINT instance_count,
1223 bool indexed,
1224 XGL_UINT vertex_base)
1225{
1226 const struct intel_pipeline *p = cmd->bind.pipeline.graphics;
1227
1228 emit_bounded_states(cmd);
1229
1230 if (indexed) {
1231 if (p->primitive_restart && !gen6_can_primitive_restart(cmd))
1232 cmd->result = XGL_ERROR_UNKNOWN;
1233
1234 if (cmd_gen(cmd) >= INTEL_GEN(7.5)) {
1235 gen75_3DSTATE_VF(cmd, p->primitive_restart,
1236 p->primitive_restart_index);
1237 } else {
1238 gen6_3DSTATE_INDEX_BUFFER(cmd, cmd->bind.index.mem,
1239 cmd->bind.index.offset, cmd->bind.index.type,
1240 p->primitive_restart);
1241 }
1242 } else {
1243 assert(!vertex_base);
1244 }
1245
1246 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
1247 gen7_3DPRIMITIVE(cmd, p->prim_type, indexed, vertex_count,
1248 vertex_start, instance_count, instance_start, vertex_base);
1249 } else {
1250 gen6_3DPRIMITIVE(cmd, p->prim_type, indexed, vertex_count,
1251 vertex_start, instance_count, instance_start, vertex_base);
1252 }
Chia-I Wu48c283d2014-08-25 23:13:46 +08001253
Chia-I Wu707a29e2014-08-27 12:51:47 +08001254 cmd->bind.draw_count++;
Chia-I Wu48c283d2014-08-25 23:13:46 +08001255 /* need to re-emit all workarounds */
1256 cmd->bind.wa_flags = 0;
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001257}
1258
Chia-I Wub2755562014-08-20 13:38:52 +08001259XGL_VOID XGLAPI intelCmdBindPipeline(
1260 XGL_CMD_BUFFER cmdBuffer,
1261 XGL_PIPELINE_BIND_POINT pipelineBindPoint,
1262 XGL_PIPELINE pipeline)
1263{
1264 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1265
1266 switch (pipelineBindPoint) {
1267 case XGL_PIPELINE_BIND_POINT_COMPUTE:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001268 cmd_bind_compute_pipeline(cmd, intel_pipeline(pipeline));
Chia-I Wub2755562014-08-20 13:38:52 +08001269 break;
1270 case XGL_PIPELINE_BIND_POINT_GRAPHICS:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001271 cmd_bind_graphics_pipeline(cmd, intel_pipeline(pipeline));
Chia-I Wub2755562014-08-20 13:38:52 +08001272 break;
1273 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001274 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +08001275 break;
1276 }
1277}
1278
1279XGL_VOID XGLAPI intelCmdBindPipelineDelta(
1280 XGL_CMD_BUFFER cmdBuffer,
1281 XGL_PIPELINE_BIND_POINT pipelineBindPoint,
1282 XGL_PIPELINE_DELTA delta)
1283{
1284 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1285
1286 switch (pipelineBindPoint) {
1287 case XGL_PIPELINE_BIND_POINT_COMPUTE:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001288 cmd_bind_compute_delta(cmd, delta);
Chia-I Wub2755562014-08-20 13:38:52 +08001289 break;
1290 case XGL_PIPELINE_BIND_POINT_GRAPHICS:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001291 cmd_bind_graphics_delta(cmd, delta);
Chia-I Wub2755562014-08-20 13:38:52 +08001292 break;
1293 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001294 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +08001295 break;
1296 }
1297}
1298
1299XGL_VOID XGLAPI intelCmdBindStateObject(
1300 XGL_CMD_BUFFER cmdBuffer,
1301 XGL_STATE_BIND_POINT stateBindPoint,
1302 XGL_STATE_OBJECT state)
1303{
1304 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1305
1306 switch (stateBindPoint) {
1307 case XGL_STATE_BIND_VIEWPORT:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001308 cmd_bind_viewport_state(cmd,
1309 intel_viewport_state((XGL_VIEWPORT_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +08001310 break;
1311 case XGL_STATE_BIND_RASTER:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001312 cmd_bind_raster_state(cmd,
1313 intel_raster_state((XGL_RASTER_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +08001314 break;
1315 case XGL_STATE_BIND_DEPTH_STENCIL:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001316 cmd_bind_ds_state(cmd,
1317 intel_ds_state((XGL_DEPTH_STENCIL_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +08001318 break;
1319 case XGL_STATE_BIND_COLOR_BLEND:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001320 cmd_bind_blend_state(cmd,
1321 intel_blend_state((XGL_COLOR_BLEND_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +08001322 break;
1323 case XGL_STATE_BIND_MSAA:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001324 cmd_bind_msaa_state(cmd,
1325 intel_msaa_state((XGL_MSAA_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +08001326 break;
1327 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001328 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +08001329 break;
1330 }
1331}
1332
1333XGL_VOID XGLAPI intelCmdBindDescriptorSet(
1334 XGL_CMD_BUFFER cmdBuffer,
1335 XGL_PIPELINE_BIND_POINT pipelineBindPoint,
1336 XGL_UINT index,
1337 XGL_DESCRIPTOR_SET descriptorSet,
1338 XGL_UINT slotOffset)
1339{
1340 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1341 struct intel_dset *dset = intel_dset(descriptorSet);
1342
1343 assert(!index);
1344
1345 switch (pipelineBindPoint) {
1346 case XGL_PIPELINE_BIND_POINT_COMPUTE:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001347 cmd_bind_compute_dset(cmd, dset, slotOffset);
Chia-I Wub2755562014-08-20 13:38:52 +08001348 break;
1349 case XGL_PIPELINE_BIND_POINT_GRAPHICS:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001350 cmd_bind_graphics_dset(cmd, dset, slotOffset);
Chia-I Wub2755562014-08-20 13:38:52 +08001351 break;
1352 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001353 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +08001354 break;
1355 }
1356}
1357
1358XGL_VOID XGLAPI intelCmdBindDynamicMemoryView(
1359 XGL_CMD_BUFFER cmdBuffer,
1360 XGL_PIPELINE_BIND_POINT pipelineBindPoint,
1361 const XGL_MEMORY_VIEW_ATTACH_INFO* pMemView)
1362{
1363 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1364
1365 switch (pipelineBindPoint) {
1366 case XGL_PIPELINE_BIND_POINT_COMPUTE:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001367 cmd_bind_compute_dyn_view(cmd, pMemView);
Chia-I Wub2755562014-08-20 13:38:52 +08001368 break;
1369 case XGL_PIPELINE_BIND_POINT_GRAPHICS:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001370 cmd_bind_graphics_dyn_view(cmd, pMemView);
Chia-I Wub2755562014-08-20 13:38:52 +08001371 break;
1372 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001373 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +08001374 break;
1375 }
1376}
1377
1378XGL_VOID XGLAPI intelCmdBindIndexData(
1379 XGL_CMD_BUFFER cmdBuffer,
1380 XGL_GPU_MEMORY mem_,
1381 XGL_GPU_SIZE offset,
1382 XGL_INDEX_TYPE indexType)
1383{
1384 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1385 struct intel_mem *mem = intel_mem(mem_);
1386
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001387 cmd_bind_index_data(cmd, mem, offset, indexType);
Chia-I Wub2755562014-08-20 13:38:52 +08001388}
1389
1390XGL_VOID XGLAPI intelCmdBindAttachments(
1391 XGL_CMD_BUFFER cmdBuffer,
1392 XGL_UINT colorAttachmentCount,
1393 const XGL_COLOR_ATTACHMENT_BIND_INFO* pColorAttachments,
1394 const XGL_DEPTH_STENCIL_BIND_INFO* pDepthStencilAttachment)
1395{
1396 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
Chia-I Wub2755562014-08-20 13:38:52 +08001397
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001398 cmd_bind_rt(cmd, pColorAttachments, colorAttachmentCount);
1399 cmd_bind_ds(cmd, pDepthStencilAttachment);
Chia-I Wub2755562014-08-20 13:38:52 +08001400}
1401
1402XGL_VOID XGLAPI intelCmdDraw(
1403 XGL_CMD_BUFFER cmdBuffer,
1404 XGL_UINT firstVertex,
1405 XGL_UINT vertexCount,
1406 XGL_UINT firstInstance,
1407 XGL_UINT instanceCount)
1408{
Chia-I Wu59c097e2014-08-21 10:51:07 +08001409 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
Chia-I Wu59c097e2014-08-21 10:51:07 +08001410
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001411 cmd_draw(cmd, firstVertex, vertexCount,
1412 firstInstance, instanceCount, false, 0);
Chia-I Wub2755562014-08-20 13:38:52 +08001413}
1414
1415XGL_VOID XGLAPI intelCmdDrawIndexed(
1416 XGL_CMD_BUFFER cmdBuffer,
1417 XGL_UINT firstIndex,
1418 XGL_UINT indexCount,
1419 XGL_INT vertexOffset,
1420 XGL_UINT firstInstance,
1421 XGL_UINT instanceCount)
1422{
Chia-I Wu59c097e2014-08-21 10:51:07 +08001423 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
Chia-I Wu59c097e2014-08-21 10:51:07 +08001424
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001425 cmd_draw(cmd, firstIndex, indexCount,
1426 firstInstance, instanceCount, true, vertexOffset);
Chia-I Wub2755562014-08-20 13:38:52 +08001427}
1428
1429XGL_VOID XGLAPI intelCmdDrawIndirect(
1430 XGL_CMD_BUFFER cmdBuffer,
1431 XGL_GPU_MEMORY mem,
1432 XGL_GPU_SIZE offset,
1433 XGL_UINT32 count,
1434 XGL_UINT32 stride)
1435{
Chia-I Wu59c097e2014-08-21 10:51:07 +08001436 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1437
1438 cmd->result = XGL_ERROR_UNKNOWN;
Chia-I Wub2755562014-08-20 13:38:52 +08001439}
1440
1441XGL_VOID XGLAPI intelCmdDrawIndexedIndirect(
1442 XGL_CMD_BUFFER cmdBuffer,
1443 XGL_GPU_MEMORY mem,
1444 XGL_GPU_SIZE offset,
1445 XGL_UINT32 count,
1446 XGL_UINT32 stride)
1447{
Chia-I Wu59c097e2014-08-21 10:51:07 +08001448 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1449
1450 cmd->result = XGL_ERROR_UNKNOWN;
Chia-I Wub2755562014-08-20 13:38:52 +08001451}
1452
1453XGL_VOID XGLAPI intelCmdDispatch(
1454 XGL_CMD_BUFFER cmdBuffer,
1455 XGL_UINT x,
1456 XGL_UINT y,
1457 XGL_UINT z)
1458{
Chia-I Wu59c097e2014-08-21 10:51:07 +08001459 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1460
1461 cmd->result = XGL_ERROR_UNKNOWN;
Chia-I Wub2755562014-08-20 13:38:52 +08001462}
1463
1464XGL_VOID XGLAPI intelCmdDispatchIndirect(
1465 XGL_CMD_BUFFER cmdBuffer,
1466 XGL_GPU_MEMORY mem,
1467 XGL_GPU_SIZE offset)
1468{
Chia-I Wu59c097e2014-08-21 10:51:07 +08001469 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1470
1471 cmd->result = XGL_ERROR_UNKNOWN;
Chia-I Wub2755562014-08-20 13:38:52 +08001472}