blob: a75b8f27b4b74c9c952b169de069727ea2a6052b [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);
Chia-I Wu9ee38722014-08-25 12:11:36 +0800185 cmd_batch_reloc(cmd, offset, mem->bo, INTEL_DOMAIN_VERTEX, 0);
186 cmd_batch_reloc(cmd, end_offset, mem->bo, 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) {
Chia-I Wu9ee38722014-08-25 12:11:36 +0800247 cmd_batch_reloc(cmd, view->cmd[1], view->img->obj.mem->bo,
Courtney Goeltzenleuchtere316d972014-08-22 16:25:24 -0600248 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) {
Chia-I Wu9ee38722014-08-25 12:11:36 +0800276 cmd_batch_reloc(cmd, view->cmd[7], view->img->obj.mem->bo,
Courtney Goeltzenleuchtere316d972014-08-22 16:25:24 -0600277 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) {
Chia-I Wu9ee38722014-08-25 12:11:36 +0800301 cmd_batch_reloc(cmd, view->cmd[9], view->img->obj.mem->bo,
Courtney Goeltzenleuchtere316d972014-08-22 16:25:24 -0600302 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);
Chia-I Wubda55fd2014-08-25 12:46:10 +0800619 cmd_state_reloc(cmd, 1, view->cmd[1], view->img->obj.mem->bo,
Chia-I Wu42a56202014-08-23 16:47:48 +0800620 INTEL_DOMAIN_RENDER, INTEL_DOMAIN_RENDER);
621 cmd_state_advance(cmd, view->cmd_len);
622 }
623 break;
624 case INTEL_RMAP_SLOT_DYN:
625 {
626 const struct intel_mem_view *view =
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800627 &cmd->bind.dyn_view.graphics;
Chia-I Wu42a56202014-08-23 16:47:48 +0800628
629 dw = cmd_state_reserve_reloc(cmd, view->cmd_len, 1,
630 GEN6_ALIGNMENT_SURFACE_STATE, &pos);
631
632 memcpy(dw, view->cmd, sizeof(uint32_t) * view->cmd_len);
Chia-I Wubda55fd2014-08-25 12:46:10 +0800633 cmd_state_reloc(cmd, 1, view->cmd[1], view->mem->bo,
Chia-I Wu42a56202014-08-23 16:47:48 +0800634 INTEL_DOMAIN_RENDER, INTEL_DOMAIN_RENDER);
635 cmd_state_advance(cmd, view->cmd_len);
636 }
637 break;
638 case 1:
639 default:
640 /* TODO */
641 assert(!"no dset support");
642 break;
643 }
644
645 binding_table[i] = pos << 2;
646 }
647
648 pos = cmd_state_copy(cmd, binding_table, surface_count,
649 GEN6_ALIGNMENT_BINDING_TABLE_STATE);
650
651 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
652 gen7_3dstate_pointer(cmd,
653 GEN7_RENDER_OPCODE_3DSTATE_BINDING_TABLE_POINTERS_PS, pos);
654 } else {
655 gen6_3DSTATE_BINDING_TABLE_POINTERS(cmd, 0, 0, pos);
656 }
657}
658
Chia-I Wu52500102014-08-22 00:46:04 +0800659static void emit_bounded_states(struct intel_cmd *cmd)
660{
661 const struct intel_msaa_state *msaa = cmd->bind.state.msaa;
662
663 /* TODO more states */
664
Chia-I Wu1744cca2014-08-22 11:10:17 +0800665 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
Chia-I Wu302742d2014-08-22 10:28:29 +0800666 gen7_cc_states(cmd);
Chia-I Wu1744cca2014-08-22 11:10:17 +0800667 gen7_viewport_states(cmd);
668 } else {
Chia-I Wu302742d2014-08-22 10:28:29 +0800669 gen6_cc_states(cmd);
Chia-I Wu1744cca2014-08-22 11:10:17 +0800670 gen6_viewport_states(cmd);
671 }
Chia-I Wu302742d2014-08-22 10:28:29 +0800672
Chia-I Wu42a56202014-08-23 16:47:48 +0800673 emit_ps_resources(cmd, cmd->bind.pipeline.graphics->fs_rmap);
674
Chia-I Wu52500102014-08-22 00:46:04 +0800675 /* 3DSTATE_MULTISAMPLE and 3DSTATE_SAMPLE_MASK */
676 cmd_batch_reserve(cmd, msaa->cmd_len);
677 cmd_batch_write_n(cmd, msaa->cmd, msaa->cmd_len);
678}
679
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800680static void cmd_bind_graphics_pipeline(struct intel_cmd *cmd,
681 const struct intel_pipeline *pipeline)
682{
683 cmd->bind.pipeline.graphics = pipeline;
684}
685
686static void cmd_bind_compute_pipeline(struct intel_cmd *cmd,
687 const struct intel_pipeline *pipeline)
688{
689 cmd->bind.pipeline.compute = pipeline;
690}
691
692static void cmd_bind_graphics_delta(struct intel_cmd *cmd,
693 const struct intel_pipeline_delta *delta)
694{
695 cmd->bind.pipeline.graphics_delta = delta;
696}
697
698static void cmd_bind_compute_delta(struct intel_cmd *cmd,
699 const struct intel_pipeline_delta *delta)
700{
701 cmd->bind.pipeline.compute_delta = delta;
702}
703
704static void cmd_bind_graphics_dset(struct intel_cmd *cmd,
705 const struct intel_dset *dset,
706 XGL_UINT slot_offset)
707{
708 cmd->bind.dset.graphics = dset;
709 cmd->bind.dset.graphics_offset = slot_offset;
710}
711
712static void cmd_bind_compute_dset(struct intel_cmd *cmd,
713 const struct intel_dset *dset,
714 XGL_UINT slot_offset)
715{
716 cmd->bind.dset.compute = dset;
717 cmd->bind.dset.compute_offset = slot_offset;
718}
719
720static void cmd_bind_graphics_dyn_view(struct intel_cmd *cmd,
721 const XGL_MEMORY_VIEW_ATTACH_INFO *info)
722{
723 intel_mem_view_init(&cmd->bind.dyn_view.graphics, cmd->dev, info);
724}
725
726static void cmd_bind_compute_dyn_view(struct intel_cmd *cmd,
727 const XGL_MEMORY_VIEW_ATTACH_INFO *info)
728{
729 intel_mem_view_init(&cmd->bind.dyn_view.compute, cmd->dev, info);
730}
731
732static void cmd_bind_index_data(struct intel_cmd *cmd,
733 const struct intel_mem *mem,
734 XGL_GPU_SIZE offset, XGL_INDEX_TYPE type)
735{
736 if (cmd_gen(cmd) >= INTEL_GEN(7.5)) {
737 gen6_3DSTATE_INDEX_BUFFER(cmd, mem, offset, type, false);
738 } else {
739 cmd->bind.index.mem = mem;
740 cmd->bind.index.offset = offset;
741 cmd->bind.index.type = type;
742 }
743}
744
745static void cmd_bind_rt(struct intel_cmd *cmd,
746 const XGL_COLOR_ATTACHMENT_BIND_INFO *attachments,
747 XGL_UINT count)
748{
Chia-I Wud88e02d2014-08-25 10:56:13 +0800749 XGL_UINT width = 0, height = 0;
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800750 XGL_UINT i;
751
752 for (i = 0; i < count; i++) {
753 const XGL_COLOR_ATTACHMENT_BIND_INFO *att = &attachments[i];
754 const struct intel_rt_view *rt = intel_rt_view(att->view);
Chia-I Wud88e02d2014-08-25 10:56:13 +0800755 const struct intel_layout *layout = &rt->img->layout;
756
757 if (i == 0) {
758 width = layout->width0;
759 height = layout->height0;
760 } else {
761 if (width > layout->width0)
762 width = layout->width0;
763 if (height > layout->height0)
764 height = layout->height0;
765 }
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800766
767 cmd->bind.att.rt[i] = rt;
768 }
769
770 cmd->bind.att.rt_count = count;
Chia-I Wud88e02d2014-08-25 10:56:13 +0800771
772 gen6_3DSTATE_DRAWING_RECTANGLE(cmd, width, height);
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800773}
774
775static void cmd_bind_ds(struct intel_cmd *cmd,
776 const XGL_DEPTH_STENCIL_BIND_INFO *info)
777{
778 const struct intel_ds_view *ds;
779
780 if (info) {
781 cmd->bind.att.ds = intel_ds_view(info->view);
782 ds = cmd->bind.att.ds;
783 } else {
784 /* all zeros */
785 static const struct intel_ds_view null_ds;
786 ds = &null_ds;
787 }
788
789 /* TODO workarounds */
790 gen6_3DSTATE_DEPTH_BUFFER(cmd, ds);
791 gen6_3DSTATE_STENCIL_BUFFER(cmd, ds);
792 gen6_3DSTATE_HIER_DEPTH_BUFFER(cmd, ds);
Chia-I Wuf8231032014-08-25 10:44:45 +0800793
794 if (cmd_gen(cmd) >= INTEL_GEN(7))
795 gen7_3DSTATE_CLEAR_PARAMS(cmd, 0);
796 else
797 gen6_3DSTATE_CLEAR_PARAMS(cmd, 0);
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800798}
799
800static void cmd_bind_viewport_state(struct intel_cmd *cmd,
801 const struct intel_viewport_state *state)
802{
803 cmd->bind.state.viewport = state;
804}
805
806static void cmd_bind_raster_state(struct intel_cmd *cmd,
807 const struct intel_raster_state *state)
808{
809 cmd->bind.state.raster = state;
810}
811
812static void cmd_bind_ds_state(struct intel_cmd *cmd,
813 const struct intel_ds_state *state)
814{
815 cmd->bind.state.ds = state;
816}
817
818static void cmd_bind_blend_state(struct intel_cmd *cmd,
819 const struct intel_blend_state *state)
820{
821 cmd->bind.state.blend = state;
822}
823
824static void cmd_bind_msaa_state(struct intel_cmd *cmd,
825 const struct intel_msaa_state *state)
826{
827 cmd->bind.state.msaa = state;
828}
829
830static void cmd_draw(struct intel_cmd *cmd,
831 XGL_UINT vertex_start,
832 XGL_UINT vertex_count,
833 XGL_UINT instance_start,
834 XGL_UINT instance_count,
835 bool indexed,
836 XGL_UINT vertex_base)
837{
838 const struct intel_pipeline *p = cmd->bind.pipeline.graphics;
839
840 emit_bounded_states(cmd);
841
842 if (indexed) {
843 if (p->primitive_restart && !gen6_can_primitive_restart(cmd))
844 cmd->result = XGL_ERROR_UNKNOWN;
845
846 if (cmd_gen(cmd) >= INTEL_GEN(7.5)) {
847 gen75_3DSTATE_VF(cmd, p->primitive_restart,
848 p->primitive_restart_index);
849 } else {
850 gen6_3DSTATE_INDEX_BUFFER(cmd, cmd->bind.index.mem,
851 cmd->bind.index.offset, cmd->bind.index.type,
852 p->primitive_restart);
853 }
854 } else {
855 assert(!vertex_base);
856 }
857
858 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
859 gen7_3DPRIMITIVE(cmd, p->prim_type, indexed, vertex_count,
860 vertex_start, instance_count, instance_start, vertex_base);
861 } else {
862 gen6_3DPRIMITIVE(cmd, p->prim_type, indexed, vertex_count,
863 vertex_start, instance_count, instance_start, vertex_base);
864 }
865}
866
Chia-I Wub2755562014-08-20 13:38:52 +0800867XGL_VOID XGLAPI intelCmdBindPipeline(
868 XGL_CMD_BUFFER cmdBuffer,
869 XGL_PIPELINE_BIND_POINT pipelineBindPoint,
870 XGL_PIPELINE pipeline)
871{
872 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
873
874 switch (pipelineBindPoint) {
875 case XGL_PIPELINE_BIND_POINT_COMPUTE:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800876 cmd_bind_compute_pipeline(cmd, intel_pipeline(pipeline));
Chia-I Wub2755562014-08-20 13:38:52 +0800877 break;
878 case XGL_PIPELINE_BIND_POINT_GRAPHICS:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800879 cmd_bind_graphics_pipeline(cmd, intel_pipeline(pipeline));
Chia-I Wub2755562014-08-20 13:38:52 +0800880 break;
881 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800882 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +0800883 break;
884 }
885}
886
887XGL_VOID XGLAPI intelCmdBindPipelineDelta(
888 XGL_CMD_BUFFER cmdBuffer,
889 XGL_PIPELINE_BIND_POINT pipelineBindPoint,
890 XGL_PIPELINE_DELTA delta)
891{
892 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
893
894 switch (pipelineBindPoint) {
895 case XGL_PIPELINE_BIND_POINT_COMPUTE:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800896 cmd_bind_compute_delta(cmd, delta);
Chia-I Wub2755562014-08-20 13:38:52 +0800897 break;
898 case XGL_PIPELINE_BIND_POINT_GRAPHICS:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800899 cmd_bind_graphics_delta(cmd, delta);
Chia-I Wub2755562014-08-20 13:38:52 +0800900 break;
901 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800902 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +0800903 break;
904 }
905}
906
907XGL_VOID XGLAPI intelCmdBindStateObject(
908 XGL_CMD_BUFFER cmdBuffer,
909 XGL_STATE_BIND_POINT stateBindPoint,
910 XGL_STATE_OBJECT state)
911{
912 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
913
914 switch (stateBindPoint) {
915 case XGL_STATE_BIND_VIEWPORT:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800916 cmd_bind_viewport_state(cmd,
917 intel_viewport_state((XGL_VIEWPORT_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +0800918 break;
919 case XGL_STATE_BIND_RASTER:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800920 cmd_bind_raster_state(cmd,
921 intel_raster_state((XGL_RASTER_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +0800922 break;
923 case XGL_STATE_BIND_DEPTH_STENCIL:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800924 cmd_bind_ds_state(cmd,
925 intel_ds_state((XGL_DEPTH_STENCIL_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +0800926 break;
927 case XGL_STATE_BIND_COLOR_BLEND:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800928 cmd_bind_blend_state(cmd,
929 intel_blend_state((XGL_COLOR_BLEND_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +0800930 break;
931 case XGL_STATE_BIND_MSAA:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800932 cmd_bind_msaa_state(cmd,
933 intel_msaa_state((XGL_MSAA_STATE_OBJECT) state));
Chia-I Wub2755562014-08-20 13:38:52 +0800934 break;
935 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800936 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +0800937 break;
938 }
939}
940
941XGL_VOID XGLAPI intelCmdBindDescriptorSet(
942 XGL_CMD_BUFFER cmdBuffer,
943 XGL_PIPELINE_BIND_POINT pipelineBindPoint,
944 XGL_UINT index,
945 XGL_DESCRIPTOR_SET descriptorSet,
946 XGL_UINT slotOffset)
947{
948 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
949 struct intel_dset *dset = intel_dset(descriptorSet);
950
951 assert(!index);
952
953 switch (pipelineBindPoint) {
954 case XGL_PIPELINE_BIND_POINT_COMPUTE:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800955 cmd_bind_compute_dset(cmd, dset, slotOffset);
Chia-I Wub2755562014-08-20 13:38:52 +0800956 break;
957 case XGL_PIPELINE_BIND_POINT_GRAPHICS:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800958 cmd_bind_graphics_dset(cmd, dset, slotOffset);
Chia-I Wub2755562014-08-20 13:38:52 +0800959 break;
960 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800961 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +0800962 break;
963 }
964}
965
966XGL_VOID XGLAPI intelCmdBindDynamicMemoryView(
967 XGL_CMD_BUFFER cmdBuffer,
968 XGL_PIPELINE_BIND_POINT pipelineBindPoint,
969 const XGL_MEMORY_VIEW_ATTACH_INFO* pMemView)
970{
971 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
972
973 switch (pipelineBindPoint) {
974 case XGL_PIPELINE_BIND_POINT_COMPUTE:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800975 cmd_bind_compute_dyn_view(cmd, pMemView);
Chia-I Wub2755562014-08-20 13:38:52 +0800976 break;
977 case XGL_PIPELINE_BIND_POINT_GRAPHICS:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800978 cmd_bind_graphics_dyn_view(cmd, pMemView);
Chia-I Wub2755562014-08-20 13:38:52 +0800979 break;
980 default:
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800981 cmd->result = XGL_ERROR_INVALID_VALUE;
Chia-I Wub2755562014-08-20 13:38:52 +0800982 break;
983 }
984}
985
986XGL_VOID XGLAPI intelCmdBindIndexData(
987 XGL_CMD_BUFFER cmdBuffer,
988 XGL_GPU_MEMORY mem_,
989 XGL_GPU_SIZE offset,
990 XGL_INDEX_TYPE indexType)
991{
992 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
993 struct intel_mem *mem = intel_mem(mem_);
994
Chia-I Wu9f1722c2014-08-25 10:17:58 +0800995 cmd_bind_index_data(cmd, mem, offset, indexType);
Chia-I Wub2755562014-08-20 13:38:52 +0800996}
997
998XGL_VOID XGLAPI intelCmdBindAttachments(
999 XGL_CMD_BUFFER cmdBuffer,
1000 XGL_UINT colorAttachmentCount,
1001 const XGL_COLOR_ATTACHMENT_BIND_INFO* pColorAttachments,
1002 const XGL_DEPTH_STENCIL_BIND_INFO* pDepthStencilAttachment)
1003{
1004 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
Chia-I Wub2755562014-08-20 13:38:52 +08001005
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001006 cmd_bind_rt(cmd, pColorAttachments, colorAttachmentCount);
1007 cmd_bind_ds(cmd, pDepthStencilAttachment);
Chia-I Wub2755562014-08-20 13:38:52 +08001008}
1009
1010XGL_VOID XGLAPI intelCmdDraw(
1011 XGL_CMD_BUFFER cmdBuffer,
1012 XGL_UINT firstVertex,
1013 XGL_UINT vertexCount,
1014 XGL_UINT firstInstance,
1015 XGL_UINT instanceCount)
1016{
Chia-I Wu59c097e2014-08-21 10:51:07 +08001017 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
Chia-I Wu59c097e2014-08-21 10:51:07 +08001018
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001019 cmd_draw(cmd, firstVertex, vertexCount,
1020 firstInstance, instanceCount, false, 0);
Chia-I Wub2755562014-08-20 13:38:52 +08001021}
1022
1023XGL_VOID XGLAPI intelCmdDrawIndexed(
1024 XGL_CMD_BUFFER cmdBuffer,
1025 XGL_UINT firstIndex,
1026 XGL_UINT indexCount,
1027 XGL_INT vertexOffset,
1028 XGL_UINT firstInstance,
1029 XGL_UINT instanceCount)
1030{
Chia-I Wu59c097e2014-08-21 10:51:07 +08001031 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
Chia-I Wu59c097e2014-08-21 10:51:07 +08001032
Chia-I Wu9f1722c2014-08-25 10:17:58 +08001033 cmd_draw(cmd, firstIndex, indexCount,
1034 firstInstance, instanceCount, true, vertexOffset);
Chia-I Wub2755562014-08-20 13:38:52 +08001035}
1036
1037XGL_VOID XGLAPI intelCmdDrawIndirect(
1038 XGL_CMD_BUFFER cmdBuffer,
1039 XGL_GPU_MEMORY mem,
1040 XGL_GPU_SIZE offset,
1041 XGL_UINT32 count,
1042 XGL_UINT32 stride)
1043{
Chia-I Wu59c097e2014-08-21 10:51:07 +08001044 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1045
1046 cmd->result = XGL_ERROR_UNKNOWN;
Chia-I Wub2755562014-08-20 13:38:52 +08001047}
1048
1049XGL_VOID XGLAPI intelCmdDrawIndexedIndirect(
1050 XGL_CMD_BUFFER cmdBuffer,
1051 XGL_GPU_MEMORY mem,
1052 XGL_GPU_SIZE offset,
1053 XGL_UINT32 count,
1054 XGL_UINT32 stride)
1055{
Chia-I Wu59c097e2014-08-21 10:51:07 +08001056 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1057
1058 cmd->result = XGL_ERROR_UNKNOWN;
Chia-I Wub2755562014-08-20 13:38:52 +08001059}
1060
1061XGL_VOID XGLAPI intelCmdDispatch(
1062 XGL_CMD_BUFFER cmdBuffer,
1063 XGL_UINT x,
1064 XGL_UINT y,
1065 XGL_UINT z)
1066{
Chia-I Wu59c097e2014-08-21 10:51:07 +08001067 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1068
1069 cmd->result = XGL_ERROR_UNKNOWN;
Chia-I Wub2755562014-08-20 13:38:52 +08001070}
1071
1072XGL_VOID XGLAPI intelCmdDispatchIndirect(
1073 XGL_CMD_BUFFER cmdBuffer,
1074 XGL_GPU_MEMORY mem,
1075 XGL_GPU_SIZE offset)
1076{
Chia-I Wu59c097e2014-08-21 10:51:07 +08001077 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
1078
1079 cmd->result = XGL_ERROR_UNKNOWN;
Chia-I Wub2755562014-08-20 13:38:52 +08001080}