blob: 2bfc59daf0adc1fd187fbf5f9e85a379fed80065 [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 Wu59c097e2014-08-21 10:51:07 +080034static void gen6_3DPRIMITIVE(struct intel_cmd *cmd,
Chia-I Wu254db422014-08-21 11:54:29 +080035 int prim_type, bool indexed,
Chia-I Wu59c097e2014-08-21 10:51:07 +080036 uint32_t vertex_count,
37 uint32_t vertex_start,
38 uint32_t instance_count,
39 uint32_t instance_start,
40 uint32_t vertex_base)
41{
42 const uint8_t cmd_len = 6;
43 uint32_t dw0;
44
45 CMD_ASSERT(cmd, 6, 6);
46
Chia-I Wub0b9f692014-08-21 11:33:29 +080047 dw0 = GEN_RENDER_CMD(3D, GEN6, 3DPRIMITIVE) |
Chia-I Wu254db422014-08-21 11:54:29 +080048 prim_type << GEN6_3DPRIM_DW0_TYPE__SHIFT |
Chia-I Wu59c097e2014-08-21 10:51:07 +080049 (cmd_len - 2);
50
51 if (indexed)
52 dw0 |= GEN6_3DPRIM_DW0_ACCESS_RANDOM;
53
Chia-I Wue24c3292014-08-21 14:05:23 +080054 cmd_batch_reserve(cmd, cmd_len);
55 cmd_batch_write(cmd, dw0);
56 cmd_batch_write(cmd, vertex_count);
57 cmd_batch_write(cmd, vertex_start);
58 cmd_batch_write(cmd, instance_count);
59 cmd_batch_write(cmd, instance_start);
60 cmd_batch_write(cmd, vertex_base);
Chia-I Wu59c097e2014-08-21 10:51:07 +080061}
62
63static void gen7_3DPRIMITIVE(struct intel_cmd *cmd,
Chia-I Wu254db422014-08-21 11:54:29 +080064 int prim_type, bool indexed,
Chia-I Wu59c097e2014-08-21 10:51:07 +080065 uint32_t vertex_count,
66 uint32_t vertex_start,
67 uint32_t instance_count,
68 uint32_t instance_start,
69 uint32_t vertex_base)
70{
71 const uint8_t cmd_len = 7;
72 uint32_t dw0, dw1;
73
74 CMD_ASSERT(cmd, 7, 7.5);
75
Chia-I Wub0b9f692014-08-21 11:33:29 +080076 dw0 = GEN_RENDER_CMD(3D, GEN6, 3DPRIMITIVE) | (cmd_len - 2);
Chia-I Wu254db422014-08-21 11:54:29 +080077 dw1 = prim_type << GEN7_3DPRIM_DW1_TYPE__SHIFT;
Chia-I Wu59c097e2014-08-21 10:51:07 +080078
79 if (indexed)
80 dw1 |= GEN7_3DPRIM_DW1_ACCESS_RANDOM;
81
Chia-I Wue24c3292014-08-21 14:05:23 +080082 cmd_batch_reserve(cmd, cmd_len);
83 cmd_batch_write(cmd, dw0);
84 cmd_batch_write(cmd, dw1);
85 cmd_batch_write(cmd, vertex_count);
86 cmd_batch_write(cmd, vertex_start);
87 cmd_batch_write(cmd, instance_count);
88 cmd_batch_write(cmd, instance_start);
89 cmd_batch_write(cmd, vertex_base);
Chia-I Wu59c097e2014-08-21 10:51:07 +080090}
91
Chia-I Wu254db422014-08-21 11:54:29 +080092static bool gen6_can_primitive_restart(const struct intel_cmd *cmd)
93{
94 const struct intel_pipeline *p = cmd->bind.pipeline.graphics;
95 bool supported;
96
97 CMD_ASSERT(cmd, 6, 7.5);
98
99 if (cmd_gen(cmd) >= INTEL_GEN(7.5))
100 return (p->prim_type != GEN6_3DPRIM_RECTLIST);
101
102 switch (p->prim_type) {
103 case GEN6_3DPRIM_POINTLIST:
104 case GEN6_3DPRIM_LINELIST:
105 case GEN6_3DPRIM_LINESTRIP:
106 case GEN6_3DPRIM_TRILIST:
107 case GEN6_3DPRIM_TRISTRIP:
108 supported = true;
109 break;
110 default:
111 supported = false;
112 break;
113 }
114
115 if (!supported)
116 return false;
117
118 switch (cmd->bind.index.type) {
119 case XGL_INDEX_8:
120 supported = (p->primitive_restart_index != 0xffu);
121 break;
122 case XGL_INDEX_16:
123 supported = (p->primitive_restart_index != 0xffffu);
124 break;
125 case XGL_INDEX_32:
126 supported = (p->primitive_restart_index != 0xffffffffu);
127 break;
128 default:
129 supported = false;
130 break;
131 }
132
133 return supported;
134}
135
Chia-I Wu59c097e2014-08-21 10:51:07 +0800136static void gen6_3DSTATE_INDEX_BUFFER(struct intel_cmd *cmd,
Chia-I Wu958d1b72014-08-21 11:28:11 +0800137 const struct intel_mem *mem,
Chia-I Wu59c097e2014-08-21 10:51:07 +0800138 XGL_GPU_SIZE offset,
139 XGL_INDEX_TYPE type,
140 bool enable_cut_index)
141{
142 const uint8_t cmd_len = 3;
143 uint32_t dw0, end_offset;
144 unsigned offset_align;
145
146 CMD_ASSERT(cmd, 6, 7.5);
147
Chia-I Wub0b9f692014-08-21 11:33:29 +0800148 dw0 = GEN_RENDER_CMD(3D, GEN6, 3DSTATE_INDEX_BUFFER) | (cmd_len - 2);
Chia-I Wu59c097e2014-08-21 10:51:07 +0800149
150 /* the bit is moved to 3DSTATE_VF */
151 if (cmd_gen(cmd) >= INTEL_GEN(7.5))
152 assert(!enable_cut_index);
153 if (enable_cut_index)
154 dw0 |= GEN6_IB_DW0_CUT_INDEX_ENABLE;
155
156 switch (type) {
157 case XGL_INDEX_8:
158 dw0 |= GEN6_IB_DW0_FORMAT_BYTE;
159 offset_align = 1;
160 break;
161 case XGL_INDEX_16:
162 dw0 |= GEN6_IB_DW0_FORMAT_WORD;
163 offset_align = 2;
164 break;
165 case XGL_INDEX_32:
166 dw0 |= GEN6_IB_DW0_FORMAT_DWORD;
167 offset_align = 4;
168 break;
169 default:
170 cmd->result = XGL_ERROR_INVALID_VALUE;
171 return;
172 break;
173 }
174
175 if (offset % offset_align) {
176 cmd->result = XGL_ERROR_INVALID_VALUE;
177 return;
178 }
179
180 /* aligned and inclusive */
181 end_offset = mem->size - (mem->size % offset_align) - 1;
182
Chia-I Wu2de65d02014-08-25 10:02:53 +0800183 cmd_batch_reserve_reloc(cmd, cmd_len, 2);
Chia-I Wue24c3292014-08-21 14:05:23 +0800184 cmd_batch_write(cmd, dw0);
185 cmd_batch_reloc(cmd, offset, mem, INTEL_DOMAIN_VERTEX, 0);
186 cmd_batch_reloc(cmd, end_offset, mem, INTEL_DOMAIN_VERTEX, 0);
Chia-I Wu59c097e2014-08-21 10:51:07 +0800187}
188
Chia-I Wu254db422014-08-21 11:54:29 +0800189static inline void
190gen75_3DSTATE_VF(struct intel_cmd *cmd,
191 bool enable_cut_index,
192 uint32_t cut_index)
193{
194 const uint8_t cmd_len = 2;
195 uint32_t dw0;
196
197 CMD_ASSERT(cmd, 7.5, 7.5);
198
199 dw0 = GEN_RENDER_CMD(3D, GEN75, 3DSTATE_VF) | (cmd_len - 2);
200 if (enable_cut_index)
201 dw0 |= GEN75_VF_DW0_CUT_INDEX_ENABLE;
202
Chia-I Wue24c3292014-08-21 14:05:23 +0800203 cmd_batch_reserve(cmd, cmd_len);
204 cmd_batch_write(cmd, dw0);
205 cmd_batch_write(cmd, cut_index);
Chia-I Wu254db422014-08-21 11:54:29 +0800206}
207
Chia-I Wud88e02d2014-08-25 10:56:13 +0800208static void gen6_3DSTATE_DRAWING_RECTANGLE(struct intel_cmd *cmd,
209 XGL_UINT width, XGL_UINT height)
210{
211 const uint8_t cmd_len = 4;
212 const uint32_t dw0 = GEN_RENDER_CMD(3D, GEN6, 3DSTATE_DRAWING_RECTANGLE) |
213 (cmd_len - 2);
214
215 CMD_ASSERT(cmd, 6, 7.5);
216
217 cmd_batch_reserve(cmd, cmd_len);
218 cmd_batch_write(cmd, dw0);
219 if (width && height) {
220 cmd_batch_write(cmd, 0);
221 cmd_batch_write(cmd, (height - 1) << 16 |
222 (width - 1));
223 } else {
224 cmd_batch_write(cmd, 1);
225 cmd_batch_write(cmd, 0);
226 }
227 cmd_batch_write(cmd, 0);
228}
229
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800230static void gen6_3DSTATE_DEPTH_BUFFER(struct intel_cmd *cmd,
231 const struct intel_ds_view *view)
232{
233 const uint8_t cmd_len = 7;
234 uint32_t dw0;
235
236 CMD_ASSERT(cmd, 6, 7.5);
237
238 dw0 = (cmd_gen(cmd) >= INTEL_GEN(7)) ?
239 GEN_RENDER_CMD(3D, GEN7, 3DSTATE_DEPTH_BUFFER) :
240 GEN_RENDER_CMD(3D, GEN6, 3DSTATE_DEPTH_BUFFER);
241 dw0 |= (cmd_len - 2);
242
Chia-I Wu2de65d02014-08-25 10:02:53 +0800243 cmd_batch_reserve_reloc(cmd, cmd_len, (bool) view->img);
Chia-I Wue24c3292014-08-21 14:05:23 +0800244 cmd_batch_write(cmd, dw0);
245 cmd_batch_write(cmd, view->cmd[0]);
Courtney Goeltzenleuchtere316d972014-08-22 16:25:24 -0600246 if (view->img) {
247 cmd_batch_reloc(cmd, view->cmd[1], view->img->obj.mem,
248 INTEL_DOMAIN_RENDER,
249 INTEL_DOMAIN_RENDER);
250 } else {
251 cmd_batch_write(cmd, 0);
252 }
Chia-I Wue24c3292014-08-21 14:05:23 +0800253 cmd_batch_write(cmd, view->cmd[2]);
254 cmd_batch_write(cmd, view->cmd[3]);
255 cmd_batch_write(cmd, view->cmd[4]);
256 cmd_batch_write(cmd, view->cmd[5]);
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800257}
258
259static void gen6_3DSTATE_STENCIL_BUFFER(struct intel_cmd *cmd,
260 const struct intel_ds_view *view)
261{
262 const uint8_t cmd_len = 3;
263 uint32_t dw0;
264
265 CMD_ASSERT(cmd, 6, 7.5);
266
267 dw0 = (cmd_gen(cmd) >= INTEL_GEN(7)) ?
268 GEN_RENDER_CMD(3D, GEN7, 3DSTATE_STENCIL_BUFFER) :
269 GEN_RENDER_CMD(3D, GEN6, 3DSTATE_STENCIL_BUFFER);
270 dw0 |= (cmd_len - 2);
271
Chia-I Wu2de65d02014-08-25 10:02:53 +0800272 cmd_batch_reserve_reloc(cmd, cmd_len, (bool) view->img);
Chia-I Wue24c3292014-08-21 14:05:23 +0800273 cmd_batch_write(cmd, dw0);
274 cmd_batch_write(cmd, view->cmd[6]);
Courtney Goeltzenleuchtere316d972014-08-22 16:25:24 -0600275 if (view->img) {
276 cmd_batch_reloc(cmd, view->cmd[7], view->img->obj.mem,
277 INTEL_DOMAIN_RENDER,
278 INTEL_DOMAIN_RENDER);
279 } else {
280 cmd_batch_write(cmd, 0);
281 }
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800282}
283
284static void gen6_3DSTATE_HIER_DEPTH_BUFFER(struct intel_cmd *cmd,
285 const struct intel_ds_view *view)
286{
287 const uint8_t cmd_len = 3;
288 uint32_t dw0;
289
290 CMD_ASSERT(cmd, 6, 7.5);
291
292 dw0 = (cmd_gen(cmd) >= INTEL_GEN(7)) ?
293 GEN_RENDER_CMD(3D, GEN7, 3DSTATE_HIER_DEPTH_BUFFER) :
294 GEN_RENDER_CMD(3D, GEN6, 3DSTATE_HIER_DEPTH_BUFFER);
295 dw0 |= (cmd_len - 2);
296
Chia-I Wu2de65d02014-08-25 10:02:53 +0800297 cmd_batch_reserve_reloc(cmd, cmd_len, (bool) view->img);
Chia-I Wue24c3292014-08-21 14:05:23 +0800298 cmd_batch_write(cmd, dw0);
299 cmd_batch_write(cmd, view->cmd[8]);
Courtney Goeltzenleuchtere316d972014-08-22 16:25:24 -0600300 if (view->img) {
301 cmd_batch_reloc(cmd, view->cmd[9], view->img->obj.mem,
302 INTEL_DOMAIN_RENDER,
303 INTEL_DOMAIN_RENDER);
304 } else {
305 cmd_batch_write(cmd, 0);
306 }
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800307}
308
Chia-I Wuf8231032014-08-25 10:44:45 +0800309static void gen6_3DSTATE_CLEAR_PARAMS(struct intel_cmd *cmd,
310 uint32_t clear_val)
311{
312 const uint8_t cmd_len = 2;
313 const uint32_t dw0 = GEN_RENDER_CMD(3D, GEN6, 3DSTATE_CLEAR_PARAMS) |
314 GEN6_CLEAR_PARAMS_DW0_VALID |
315 (cmd_len - 2);
316
317 CMD_ASSERT(cmd, 6, 6);
318
319 cmd_batch_reserve(cmd, cmd_len);
320 cmd_batch_write(cmd, dw0);
321 cmd_batch_write(cmd, clear_val);
322}
323
324static void gen7_3DSTATE_CLEAR_PARAMS(struct intel_cmd *cmd,
325 uint32_t clear_val)
326{
327 const uint8_t cmd_len = 3;
328 const uint32_t dw0 = GEN_RENDER_CMD(3D, GEN7, 3DSTATE_CLEAR_PARAMS) |
329 (cmd_len - 2);
330
331 CMD_ASSERT(cmd, 7, 7.5);
332
333 cmd_batch_reserve(cmd, cmd_len);
334 cmd_batch_write(cmd, dw0);
335 cmd_batch_write(cmd, clear_val);
336 cmd_batch_write(cmd, 1);
337}
338
Chia-I Wu302742d2014-08-22 10:28:29 +0800339static void gen6_3DSTATE_CC_STATE_POINTERS(struct intel_cmd *cmd,
340 XGL_UINT blend_pos,
341 XGL_UINT ds_pos,
342 XGL_UINT cc_pos)
343{
344 const uint8_t cmd_len = 4;
345 uint32_t dw0;
346
347 CMD_ASSERT(cmd, 6, 6);
348
349 dw0 = GEN_RENDER_CMD(3D, GEN6, 3DSTATE_CC_STATE_POINTERS) |
350 (cmd_len - 2);
351
352 cmd_batch_reserve(cmd, cmd_len);
353 cmd_batch_write(cmd, dw0);
354 cmd_batch_write(cmd, (blend_pos << 2) | 1);
355 cmd_batch_write(cmd, (ds_pos << 2) | 1);
356 cmd_batch_write(cmd, (cc_pos << 2) | 1);
357}
358
Chia-I Wu1744cca2014-08-22 11:10:17 +0800359static void gen6_3DSTATE_VIEWPORT_STATE_POINTERS(struct intel_cmd *cmd,
360 XGL_UINT clip_pos,
361 XGL_UINT sf_pos,
362 XGL_UINT cc_pos)
363{
364 const uint8_t cmd_len = 4;
365 uint32_t dw0;
366
367 CMD_ASSERT(cmd, 6, 6);
368
369 dw0 = GEN_RENDER_CMD(3D, GEN6, 3DSTATE_VIEWPORT_STATE_POINTERS) |
370 GEN6_PTR_VP_DW0_CLIP_CHANGED |
371 GEN6_PTR_VP_DW0_SF_CHANGED |
372 GEN6_PTR_VP_DW0_CC_CHANGED |
373 (cmd_len - 2);
374
375 cmd_batch_reserve(cmd, cmd_len);
376 cmd_batch_write(cmd, dw0);
377 cmd_batch_write(cmd, clip_pos << 2);
378 cmd_batch_write(cmd, sf_pos << 2);
379 cmd_batch_write(cmd, cc_pos << 2);
380}
381
382static void gen6_3DSTATE_SCISSOR_STATE_POINTERS(struct intel_cmd *cmd,
383 XGL_UINT scissor_pos)
384{
385 const uint8_t cmd_len = 2;
386 uint32_t dw0;
387
388 CMD_ASSERT(cmd, 6, 6);
389
390 dw0 = GEN_RENDER_CMD(3D, GEN6, 3DSTATE_SCISSOR_STATE_POINTERS) |
391 (cmd_len - 2);
392
393 cmd_batch_reserve(cmd, cmd_len);
394 cmd_batch_write(cmd, dw0);
395 cmd_batch_write(cmd, scissor_pos << 2);
396}
397
Chia-I Wu42a56202014-08-23 16:47:48 +0800398static void gen6_3DSTATE_BINDING_TABLE_POINTERS(struct intel_cmd *cmd,
399 XGL_UINT vs_pos,
400 XGL_UINT gs_pos,
401 XGL_UINT ps_pos)
402{
403 const uint8_t cmd_len = 4;
404 uint32_t dw0;
405
406 CMD_ASSERT(cmd, 6, 6);
407
408 dw0 = GEN_RENDER_CMD(3D, GEN6, 3DSTATE_BINDING_TABLE_POINTERS) |
409 GEN6_PTR_BINDING_TABLE_DW0_VS_CHANGED |
410 GEN6_PTR_BINDING_TABLE_DW0_GS_CHANGED |
411 GEN6_PTR_BINDING_TABLE_DW0_PS_CHANGED |
412 (cmd_len - 2);
413
414 cmd_batch_reserve(cmd, cmd_len);
415 cmd_batch_write(cmd, dw0);
416 cmd_batch_write(cmd, vs_pos << 2);
417 cmd_batch_write(cmd, gs_pos << 2);
418 cmd_batch_write(cmd, ps_pos << 2);
419}
420
Chia-I Wu302742d2014-08-22 10:28:29 +0800421static void gen7_3dstate_pointer(struct intel_cmd *cmd,
422 int subop, XGL_UINT pos)
423{
424 const uint8_t cmd_len = 2;
425 const uint32_t dw0 = GEN6_RENDER_TYPE_RENDER |
426 GEN6_RENDER_SUBTYPE_3D |
427 subop | (cmd_len - 2);
428
429 cmd_batch_reserve(cmd, cmd_len);
430 cmd_batch_write(cmd, dw0);
431 cmd_batch_write(cmd, pos << 2);
432}
433
434static XGL_UINT gen6_BLEND_STATE(struct intel_cmd *cmd,
435 const struct intel_blend_state *state)
436{
437 const uint8_t cmd_align = GEN6_ALIGNMENT_BLEND_STATE;
438 const uint8_t cmd_len = XGL_MAX_COLOR_ATTACHMENTS * 2;
439
440 CMD_ASSERT(cmd, 6, 7.5);
441 STATIC_ASSERT(ARRAY_SIZE(state->cmd) >= cmd_len);
442
443 return cmd_state_copy(cmd, state->cmd, cmd_len, cmd_align);
444}
445
446static XGL_UINT gen6_DEPTH_STENCIL_STATE(struct intel_cmd *cmd,
447 const struct intel_ds_state *state)
448{
449 const uint8_t cmd_align = GEN6_ALIGNMENT_DEPTH_STENCIL_STATE;
450 const uint8_t cmd_len = 3;
451
452 CMD_ASSERT(cmd, 6, 7.5);
453 STATIC_ASSERT(ARRAY_SIZE(state->cmd) >= cmd_len);
454
455 return cmd_state_copy(cmd, state->cmd, cmd_len, cmd_align);
456}
457
458static XGL_UINT gen6_COLOR_CALC_STATE(struct intel_cmd *cmd,
459 uint32_t stencil_ref,
460 const uint32_t blend_color[4])
461{
462 const uint8_t cmd_align = GEN6_ALIGNMENT_COLOR_CALC_STATE;
463 const uint8_t cmd_len = 6;
464 XGL_UINT pos;
465 uint32_t *dw;
466
467 CMD_ASSERT(cmd, 6, 7.5);
468
469 dw = cmd_state_reserve(cmd, cmd_len, cmd_align, &pos);
470 dw[0] = stencil_ref;
471 dw[1] = 0;
472 dw[2] = blend_color[0];
473 dw[3] = blend_color[1];
474 dw[4] = blend_color[2];
475 dw[5] = blend_color[3];
476 cmd_state_advance(cmd, cmd_len);
477
478 return pos;
479}
480
481static void gen6_cc_states(struct intel_cmd *cmd)
482{
483 const struct intel_blend_state *blend = cmd->bind.state.blend;
484 const struct intel_ds_state *ds = cmd->bind.state.ds;
485 XGL_UINT blend_pos, ds_pos, cc_pos;
Chia-I Wuce9f11f2014-08-22 10:38:51 +0800486 uint32_t stencil_ref;
487 uint32_t blend_color[4];
Chia-I Wu302742d2014-08-22 10:28:29 +0800488
489 CMD_ASSERT(cmd, 6, 6);
490
Chia-I Wuce9f11f2014-08-22 10:38:51 +0800491 if (blend) {
492 blend_pos = gen6_BLEND_STATE(cmd, blend);
493 memcpy(blend_color, blend->cmd_blend_color, sizeof(blend_color));
494 } else {
495 blend_pos = 0;
496 memset(blend_color, 0, sizeof(blend_color));
497 }
498
499 if (ds) {
500 ds_pos = gen6_DEPTH_STENCIL_STATE(cmd, ds);
501 stencil_ref = ds->cmd_stencil_ref;
502 } else {
503 ds_pos = 0;
504 stencil_ref = 0;
505 }
506
507 cc_pos = gen6_COLOR_CALC_STATE(cmd, stencil_ref, blend_color);
Chia-I Wu302742d2014-08-22 10:28:29 +0800508
509 gen6_3DSTATE_CC_STATE_POINTERS(cmd, blend_pos, ds_pos, cc_pos);
510}
511
Chia-I Wu1744cca2014-08-22 11:10:17 +0800512static void gen6_viewport_states(struct intel_cmd *cmd)
513{
514 const struct intel_viewport_state *viewport = cmd->bind.state.viewport;
515 XGL_UINT pos;
516
517 if (!viewport)
518 return;
519
520 pos = cmd_state_copy(cmd, viewport->cmd, viewport->cmd_len,
521 viewport->cmd_align);
522
523 gen6_3DSTATE_VIEWPORT_STATE_POINTERS(cmd,
524 pos + viewport->cmd_clip_offset,
525 pos,
526 pos + viewport->cmd_cc_offset);
527
528 pos = (viewport->scissor_enable) ?
529 pos + viewport->cmd_scissor_rect_offset : 0;
530
531 gen6_3DSTATE_SCISSOR_STATE_POINTERS(cmd, pos);
532}
533
Chia-I Wu302742d2014-08-22 10:28:29 +0800534static void gen7_cc_states(struct intel_cmd *cmd)
535{
536 const struct intel_blend_state *blend = cmd->bind.state.blend;
537 const struct intel_ds_state *ds = cmd->bind.state.ds;
Chia-I Wuce9f11f2014-08-22 10:38:51 +0800538 uint32_t stencil_ref;
539 uint32_t blend_color[4];
Chia-I Wu302742d2014-08-22 10:28:29 +0800540 XGL_UINT pos;
541
542 CMD_ASSERT(cmd, 7, 7.5);
543
Chia-I Wuce9f11f2014-08-22 10:38:51 +0800544 if (!blend && !ds)
545 return;
Chia-I Wu302742d2014-08-22 10:28:29 +0800546
Chia-I Wuce9f11f2014-08-22 10:38:51 +0800547 if (blend) {
548 pos = gen6_BLEND_STATE(cmd, blend);
549 gen7_3dstate_pointer(cmd,
550 GEN7_RENDER_OPCODE_3DSTATE_BLEND_STATE_POINTERS, pos);
Chia-I Wu302742d2014-08-22 10:28:29 +0800551
Chia-I Wuce9f11f2014-08-22 10:38:51 +0800552 memcpy(blend_color, blend->cmd_blend_color, sizeof(blend_color));
553 } else {
554 memset(blend_color, 0, sizeof(blend_color));
555 }
556
557 if (ds) {
558 pos = gen6_DEPTH_STENCIL_STATE(cmd, ds);
559 gen7_3dstate_pointer(cmd,
560 GEN7_RENDER_OPCODE_3DSTATE_DEPTH_STENCIL_STATE_POINTERS, pos);
561 } else {
562 stencil_ref = 0;
563 }
564
565 pos = gen6_COLOR_CALC_STATE(cmd, stencil_ref, blend_color);
Chia-I Wu302742d2014-08-22 10:28:29 +0800566 gen7_3dstate_pointer(cmd,
567 GEN6_RENDER_OPCODE_3DSTATE_CC_STATE_POINTERS, pos);
568}
569
Chia-I Wu1744cca2014-08-22 11:10:17 +0800570static void gen7_viewport_states(struct intel_cmd *cmd)
571{
572 const struct intel_viewport_state *viewport = cmd->bind.state.viewport;
573 XGL_UINT pos;
574
575 if (!viewport)
576 return;
577
578 pos = cmd_state_copy(cmd, viewport->cmd, viewport->cmd_len,
579 viewport->cmd_align);
580
581 gen7_3dstate_pointer(cmd,
582 GEN7_RENDER_OPCODE_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP, pos);
583 gen7_3dstate_pointer(cmd,
584 GEN7_RENDER_OPCODE_3DSTATE_VIEWPORT_STATE_POINTERS_CC,
585 pos + viewport->cmd_cc_offset);
586 if (viewport->scissor_enable) {
587 gen7_3dstate_pointer(cmd,
588 GEN6_RENDER_OPCODE_3DSTATE_SCISSOR_STATE_POINTERS,
589 pos + viewport->cmd_scissor_rect_offset);
590 }
591}
592
Chia-I Wu42a56202014-08-23 16:47:48 +0800593static void emit_ps_resources(struct intel_cmd *cmd,
594 const struct intel_rmap *rmap)
595{
596 const XGL_UINT surface_count = rmap->rt_count +
597 rmap->resource_count + rmap->uav_count;
598 uint32_t binding_table[256];
599 XGL_UINT pos, i;
600
601 assert(surface_count <= ARRAY_SIZE(binding_table));
602
603 for (i = 0; i < surface_count; i++) {
604 const struct intel_rmap_slot *slot = &rmap->slots[i];
605 uint32_t *dw;
606
607 switch (slot->path_len) {
608 case 0:
609 pos = 0;
610 break;
611 case INTEL_RMAP_SLOT_RT:
612 {
613 const struct intel_rt_view *view = cmd->bind.att.rt[i];
614
615 dw = cmd_state_reserve_reloc(cmd, view->cmd_len, 1,
616 GEN6_ALIGNMENT_SURFACE_STATE, &pos);
617
618 memcpy(dw, view->cmd, sizeof(uint32_t) * view->cmd_len);
619 cmd_writer_add_reloc(cmd, &cmd->state,
620 1, view->cmd[1], view->img->obj.mem,
621 INTEL_DOMAIN_RENDER, INTEL_DOMAIN_RENDER);
622 cmd_state_advance(cmd, view->cmd_len);
623 }
624 break;
625 case INTEL_RMAP_SLOT_DYN:
626 {
627 const struct intel_mem_view *view =
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800628 &cmd->bind.dyn_view.graphics;
Chia-I Wu42a56202014-08-23 16:47:48 +0800629
630 dw = cmd_state_reserve_reloc(cmd, view->cmd_len, 1,
631 GEN6_ALIGNMENT_SURFACE_STATE, &pos);
632
633 memcpy(dw, view->cmd, sizeof(uint32_t) * view->cmd_len);
634 cmd_writer_add_reloc(cmd, &cmd->state,
635 1, view->cmd[1], view->mem,
636 INTEL_DOMAIN_RENDER, INTEL_DOMAIN_RENDER);
637 cmd_state_advance(cmd, view->cmd_len);
638 }
639 break;
640 case 1:
641 default:
642 /* TODO */
643 assert(!"no dset support");
644 break;
645 }
646
647 binding_table[i] = pos << 2;
648 }
649
650 pos = cmd_state_copy(cmd, binding_table, surface_count,
651 GEN6_ALIGNMENT_BINDING_TABLE_STATE);
652
653 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
654 gen7_3dstate_pointer(cmd,
655 GEN7_RENDER_OPCODE_3DSTATE_BINDING_TABLE_POINTERS_PS, pos);
656 } else {
657 gen6_3DSTATE_BINDING_TABLE_POINTERS(cmd, 0, 0, pos);
658 }
659}
660
Chia-I Wu52500102014-08-22 00:46:04 +0800661static void emit_bounded_states(struct intel_cmd *cmd)
662{
663 const struct intel_msaa_state *msaa = cmd->bind.state.msaa;
664
665 /* TODO more states */
666
Chia-I Wu1744cca2014-08-22 11:10:17 +0800667 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
Chia-I Wu302742d2014-08-22 10:28:29 +0800668 gen7_cc_states(cmd);
Chia-I Wu1744cca2014-08-22 11:10:17 +0800669 gen7_viewport_states(cmd);
670 } else {
Chia-I Wu302742d2014-08-22 10:28:29 +0800671 gen6_cc_states(cmd);
Chia-I Wu1744cca2014-08-22 11:10:17 +0800672 gen6_viewport_states(cmd);
673 }
Chia-I Wu302742d2014-08-22 10:28:29 +0800674
Chia-I Wu42a56202014-08-23 16:47:48 +0800675 emit_ps_resources(cmd, cmd->bind.pipeline.graphics->fs_rmap);
676
Chia-I Wu52500102014-08-22 00:46:04 +0800677 /* 3DSTATE_MULTISAMPLE and 3DSTATE_SAMPLE_MASK */
678 cmd_batch_reserve(cmd, msaa->cmd_len);
679 cmd_batch_write_n(cmd, msaa->cmd, msaa->cmd_len);
680}
681
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800682static void cmd_bind_graphics_pipeline(struct intel_cmd *cmd,
683 const struct intel_pipeline *pipeline)
684{
685 cmd->bind.pipeline.graphics = pipeline;
686}
687
688static void cmd_bind_compute_pipeline(struct intel_cmd *cmd,
689 const struct intel_pipeline *pipeline)
690{
691 cmd->bind.pipeline.compute = pipeline;
692}
693
694static void cmd_bind_graphics_delta(struct intel_cmd *cmd,
695 const struct intel_pipeline_delta *delta)
696{
697 cmd->bind.pipeline.graphics_delta = delta;
698}
699
700static void cmd_bind_compute_delta(struct intel_cmd *cmd,
701 const struct intel_pipeline_delta *delta)
702{
703 cmd->bind.pipeline.compute_delta = delta;
704}
705
706static void cmd_bind_graphics_dset(struct intel_cmd *cmd,
707 const struct intel_dset *dset,
708 XGL_UINT slot_offset)
709{
710 cmd->bind.dset.graphics = dset;
711 cmd->bind.dset.graphics_offset = slot_offset;
712}
713
714static void cmd_bind_compute_dset(struct intel_cmd *cmd,
715 const struct intel_dset *dset,
716 XGL_UINT slot_offset)
717{
718 cmd->bind.dset.compute = dset;
719 cmd->bind.dset.compute_offset = slot_offset;
720}
721
722static void cmd_bind_graphics_dyn_view(struct intel_cmd *cmd,
723 const XGL_MEMORY_VIEW_ATTACH_INFO *info)
724{
725 intel_mem_view_init(&cmd->bind.dyn_view.graphics, cmd->dev, info);
726}
727
728static void cmd_bind_compute_dyn_view(struct intel_cmd *cmd,
729 const XGL_MEMORY_VIEW_ATTACH_INFO *info)
730{
731 intel_mem_view_init(&cmd->bind.dyn_view.compute, cmd->dev, info);
732}
733
734static void cmd_bind_index_data(struct intel_cmd *cmd,
735 const struct intel_mem *mem,
736 XGL_GPU_SIZE offset, XGL_INDEX_TYPE type)
737{
738 if (cmd_gen(cmd) >= INTEL_GEN(7.5)) {
739 gen6_3DSTATE_INDEX_BUFFER(cmd, mem, offset, type, false);
740 } else {
741 cmd->bind.index.mem = mem;
742 cmd->bind.index.offset = offset;
743 cmd->bind.index.type = type;
744 }
745}
746
747static void cmd_bind_rt(struct intel_cmd *cmd,
748 const XGL_COLOR_ATTACHMENT_BIND_INFO *attachments,
749 XGL_UINT count)
750{
Chia-I Wud88e02d2014-08-25 10:56:13 +0800751 XGL_UINT width = 0, height = 0;
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800752 XGL_UINT i;
753
754 for (i = 0; i < count; i++) {
755 const XGL_COLOR_ATTACHMENT_BIND_INFO *att = &attachments[i];
756 const struct intel_rt_view *rt = intel_rt_view(att->view);
Chia-I Wud88e02d2014-08-25 10:56:13 +0800757 const struct intel_layout *layout = &rt->img->layout;
758
759 if (i == 0) {
760 width = layout->width0;
761 height = layout->height0;
762 } else {
763 if (width > layout->width0)
764 width = layout->width0;
765 if (height > layout->height0)
766 height = layout->height0;
767 }
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800768
769 cmd->bind.att.rt[i] = rt;
770 }
771
772 cmd->bind.att.rt_count = count;
Chia-I Wud88e02d2014-08-25 10:56:13 +0800773
774 gen6_3DSTATE_DRAWING_RECTANGLE(cmd, width, height);
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800775}
776
777static void cmd_bind_ds(struct intel_cmd *cmd,
778 const XGL_DEPTH_STENCIL_BIND_INFO *info)
779{
780 const struct intel_ds_view *ds;
781
782 if (info) {
783 cmd->bind.att.ds = intel_ds_view(info->view);
784 ds = cmd->bind.att.ds;
785 } else {
786 /* all zeros */
787 static const struct intel_ds_view null_ds;
788 ds = &null_ds;
789 }
790
791 /* TODO workarounds */
792 gen6_3DSTATE_DEPTH_BUFFER(cmd, ds);
793 gen6_3DSTATE_STENCIL_BUFFER(cmd, ds);
794 gen6_3DSTATE_HIER_DEPTH_BUFFER(cmd, ds);
Chia-I Wuf8231032014-08-25 10:44:45 +0800795
796 if (cmd_gen(cmd) >= INTEL_GEN(7))
797 gen7_3DSTATE_CLEAR_PARAMS(cmd, 0);
798 else
799 gen6_3DSTATE_CLEAR_PARAMS(cmd, 0);
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800800}
801
802static void cmd_bind_viewport_state(struct intel_cmd *cmd,
803 const struct intel_viewport_state *state)
804{
805 cmd->bind.state.viewport = state;
806}
807
808static void cmd_bind_raster_state(struct intel_cmd *cmd,
809 const struct intel_raster_state *state)
810{
811 cmd->bind.state.raster = state;
812}
813
814static void cmd_bind_ds_state(struct intel_cmd *cmd,
815 const struct intel_ds_state *state)
816{
817 cmd->bind.state.ds = state;
818}
819
820static void cmd_bind_blend_state(struct intel_cmd *cmd,
821 const struct intel_blend_state *state)
822{
823 cmd->bind.state.blend = state;
824}
825
826static void cmd_bind_msaa_state(struct intel_cmd *cmd,
827 const struct intel_msaa_state *state)
828{
829 cmd->bind.state.msaa = state;
830}
831
832static void cmd_draw(struct intel_cmd *cmd,
833 XGL_UINT vertex_start,
834 XGL_UINT vertex_count,
835 XGL_UINT instance_start,
836 XGL_UINT instance_count,
837 bool indexed,
838 XGL_UINT vertex_base)
839{
840 const struct intel_pipeline *p = cmd->bind.pipeline.graphics;
841
842 emit_bounded_states(cmd);
843
844 if (indexed) {
845 if (p->primitive_restart && !gen6_can_primitive_restart(cmd))
846 cmd->result = XGL_ERROR_UNKNOWN;
847
848 if (cmd_gen(cmd) >= INTEL_GEN(7.5)) {
849 gen75_3DSTATE_VF(cmd, p->primitive_restart,
850 p->primitive_restart_index);
851 } else {
852 gen6_3DSTATE_INDEX_BUFFER(cmd, cmd->bind.index.mem,
853 cmd->bind.index.offset, cmd->bind.index.type,
854 p->primitive_restart);
855 }
856 } else {
857 assert(!vertex_base);
858 }
859
860 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
861 gen7_3DPRIMITIVE(cmd, p->prim_type, indexed, vertex_count,
862 vertex_start, instance_count, instance_start, vertex_base);
863 } else {
864 gen6_3DPRIMITIVE(cmd, p->prim_type, indexed, vertex_count,
865 vertex_start, instance_count, instance_start, vertex_base);
866 }
867}
868
Chia-I Wub2755562014-08-20 13:38:52 +0800869XGL_VOID XGLAPI intelCmdBindPipeline(
870 XGL_CMD_BUFFER cmdBuffer,
871 XGL_PIPELINE_BIND_POINT pipelineBindPoint,
872 XGL_PIPELINE pipeline)
873{
874 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
875
876 switch (pipelineBindPoint) {
877 case XGL_PIPELINE_BIND_POINT_COMPUTE:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800878 cmd_bind_compute_pipeline(cmd, intel_pipeline(pipeline));
Chia-I Wub2755562014-08-20 13:38:52 +0800879 break;
880 case XGL_PIPELINE_BIND_POINT_GRAPHICS:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800881 cmd_bind_graphics_pipeline(cmd, intel_pipeline(pipeline));
Chia-I Wub2755562014-08-20 13:38:52 +0800882 break;
883 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800884 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +0800885 break;
886 }
887}
888
889XGL_VOID XGLAPI intelCmdBindPipelineDelta(
890 XGL_CMD_BUFFER cmdBuffer,
891 XGL_PIPELINE_BIND_POINT pipelineBindPoint,
892 XGL_PIPELINE_DELTA delta)
893{
894 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
895
896 switch (pipelineBindPoint) {
897 case XGL_PIPELINE_BIND_POINT_COMPUTE:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800898 cmd_bind_compute_delta(cmd, delta);
Chia-I Wub2755562014-08-20 13:38:52 +0800899 break;
900 case XGL_PIPELINE_BIND_POINT_GRAPHICS:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800901 cmd_bind_graphics_delta(cmd, delta);
Chia-I Wub2755562014-08-20 13:38:52 +0800902 break;
903 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800904 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +0800905 break;
906 }
907}
908
909XGL_VOID XGLAPI intelCmdBindStateObject(
910 XGL_CMD_BUFFER cmdBuffer,
911 XGL_STATE_BIND_POINT stateBindPoint,
912 XGL_STATE_OBJECT state)
913{
914 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
915
916 switch (stateBindPoint) {
917 case XGL_STATE_BIND_VIEWPORT:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800918 cmd_bind_viewport_state(cmd,
919 intel_viewport_state((XGL_VIEWPORT_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +0800920 break;
921 case XGL_STATE_BIND_RASTER:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800922 cmd_bind_raster_state(cmd,
923 intel_raster_state((XGL_RASTER_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +0800924 break;
925 case XGL_STATE_BIND_DEPTH_STENCIL:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800926 cmd_bind_ds_state(cmd,
927 intel_ds_state((XGL_DEPTH_STENCIL_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +0800928 break;
929 case XGL_STATE_BIND_COLOR_BLEND:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800930 cmd_bind_blend_state(cmd,
931 intel_blend_state((XGL_COLOR_BLEND_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +0800932 break;
933 case XGL_STATE_BIND_MSAA:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800934 cmd_bind_msaa_state(cmd,
935 intel_msaa_state((XGL_MSAA_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +0800936 break;
937 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800938 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +0800939 break;
940 }
941}
942
943XGL_VOID XGLAPI intelCmdBindDescriptorSet(
944 XGL_CMD_BUFFER cmdBuffer,
945 XGL_PIPELINE_BIND_POINT pipelineBindPoint,
946 XGL_UINT index,
947 XGL_DESCRIPTOR_SET descriptorSet,
948 XGL_UINT slotOffset)
949{
950 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
951 struct intel_dset *dset = intel_dset(descriptorSet);
952
953 assert(!index);
954
955 switch (pipelineBindPoint) {
956 case XGL_PIPELINE_BIND_POINT_COMPUTE:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800957 cmd_bind_compute_dset(cmd, dset, slotOffset);
Chia-I Wub2755562014-08-20 13:38:52 +0800958 break;
959 case XGL_PIPELINE_BIND_POINT_GRAPHICS:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800960 cmd_bind_graphics_dset(cmd, dset, slotOffset);
Chia-I Wub2755562014-08-20 13:38:52 +0800961 break;
962 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800963 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +0800964 break;
965 }
966}
967
968XGL_VOID XGLAPI intelCmdBindDynamicMemoryView(
969 XGL_CMD_BUFFER cmdBuffer,
970 XGL_PIPELINE_BIND_POINT pipelineBindPoint,
971 const XGL_MEMORY_VIEW_ATTACH_INFO* pMemView)
972{
973 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
974
975 switch (pipelineBindPoint) {
976 case XGL_PIPELINE_BIND_POINT_COMPUTE:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800977 cmd_bind_compute_dyn_view(cmd, pMemView);
Chia-I Wub2755562014-08-20 13:38:52 +0800978 break;
979 case XGL_PIPELINE_BIND_POINT_GRAPHICS:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800980 cmd_bind_graphics_dyn_view(cmd, pMemView);
Chia-I Wub2755562014-08-20 13:38:52 +0800981 break;
982 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800983 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +0800984 break;
985 }
986}
987
988XGL_VOID XGLAPI intelCmdBindIndexData(
989 XGL_CMD_BUFFER cmdBuffer,
990 XGL_GPU_MEMORY mem_,
991 XGL_GPU_SIZE offset,
992 XGL_INDEX_TYPE indexType)
993{
994 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
995 struct intel_mem *mem = intel_mem(mem_);
996
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800997 cmd_bind_index_data(cmd, mem, offset, indexType);
Chia-I Wub2755562014-08-20 13:38:52 +0800998}
999
1000XGL_VOID XGLAPI intelCmdBindAttachments(
1001 XGL_CMD_BUFFER cmdBuffer,
1002 XGL_UINT colorAttachmentCount,
1003 const XGL_COLOR_ATTACHMENT_BIND_INFO* pColorAttachments,
1004 const XGL_DEPTH_STENCIL_BIND_INFO* pDepthStencilAttachment)
1005{
1006 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
Chia-I Wub2755562014-08-20 13:38:52 +08001007
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001008 cmd_bind_rt(cmd, pColorAttachments, colorAttachmentCount);
1009 cmd_bind_ds(cmd, pDepthStencilAttachment);
Chia-I Wub2755562014-08-20 13:38:52 +08001010}
1011
1012XGL_VOID XGLAPI intelCmdDraw(
1013 XGL_CMD_BUFFER cmdBuffer,
1014 XGL_UINT firstVertex,
1015 XGL_UINT vertexCount,
1016 XGL_UINT firstInstance,
1017 XGL_UINT instanceCount)
1018{
Chia-I Wu59c097e2014-08-21 10:51:07 +08001019 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
Chia-I Wu59c097e2014-08-21 10:51:07 +08001020
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001021 cmd_draw(cmd, firstVertex, vertexCount,
1022 firstInstance, instanceCount, false, 0);
Chia-I Wub2755562014-08-20 13:38:52 +08001023}
1024
1025XGL_VOID XGLAPI intelCmdDrawIndexed(
1026 XGL_CMD_BUFFER cmdBuffer,
1027 XGL_UINT firstIndex,
1028 XGL_UINT indexCount,
1029 XGL_INT vertexOffset,
1030 XGL_UINT firstInstance,
1031 XGL_UINT instanceCount)
1032{
Chia-I Wu59c097e2014-08-21 10:51:07 +08001033 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
Chia-I Wu59c097e2014-08-21 10:51:07 +08001034
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001035 cmd_draw(cmd, firstIndex, indexCount,
1036 firstInstance, instanceCount, true, vertexOffset);
Chia-I Wub2755562014-08-20 13:38:52 +08001037}
1038
1039XGL_VOID XGLAPI intelCmdDrawIndirect(
1040 XGL_CMD_BUFFER cmdBuffer,
1041 XGL_GPU_MEMORY mem,
1042 XGL_GPU_SIZE offset,
1043 XGL_UINT32 count,
1044 XGL_UINT32 stride)
1045{
Chia-I Wu59c097e2014-08-21 10:51:07 +08001046 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1047
1048 cmd->result = XGL_ERROR_UNKNOWN;
Chia-I Wub2755562014-08-20 13:38:52 +08001049}
1050
1051XGL_VOID XGLAPI intelCmdDrawIndexedIndirect(
1052 XGL_CMD_BUFFER cmdBuffer,
1053 XGL_GPU_MEMORY mem,
1054 XGL_GPU_SIZE offset,
1055 XGL_UINT32 count,
1056 XGL_UINT32 stride)
1057{
Chia-I Wu59c097e2014-08-21 10:51:07 +08001058 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1059
1060 cmd->result = XGL_ERROR_UNKNOWN;
Chia-I Wub2755562014-08-20 13:38:52 +08001061}
1062
1063XGL_VOID XGLAPI intelCmdDispatch(
1064 XGL_CMD_BUFFER cmdBuffer,
1065 XGL_UINT x,
1066 XGL_UINT y,
1067 XGL_UINT z)
1068{
Chia-I Wu59c097e2014-08-21 10:51:07 +08001069 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1070
1071 cmd->result = XGL_ERROR_UNKNOWN;
Chia-I Wub2755562014-08-20 13:38:52 +08001072}
1073
1074XGL_VOID XGLAPI intelCmdDispatchIndirect(
1075 XGL_CMD_BUFFER cmdBuffer,
1076 XGL_GPU_MEMORY mem,
1077 XGL_GPU_SIZE offset)
1078{
Chia-I Wu59c097e2014-08-21 10:51:07 +08001079 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1080
1081 cmd->result = XGL_ERROR_UNKNOWN;
Chia-I Wub2755562014-08-20 13:38:52 +08001082}