blob: 896243fb220e5f9bb624e10895ad58ddcb7f09ef [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 Wue24c3292014-08-21 14:05:23 +0800183 cmd_batch_reserve(cmd, cmd_len);
184 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 Wu7fae4e32014-08-21 11:39:44 +0800208static void gen6_3DSTATE_DEPTH_BUFFER(struct intel_cmd *cmd,
209 const struct intel_ds_view *view)
210{
211 const uint8_t cmd_len = 7;
212 uint32_t dw0;
213
214 CMD_ASSERT(cmd, 6, 7.5);
215
216 dw0 = (cmd_gen(cmd) >= INTEL_GEN(7)) ?
217 GEN_RENDER_CMD(3D, GEN7, 3DSTATE_DEPTH_BUFFER) :
218 GEN_RENDER_CMD(3D, GEN6, 3DSTATE_DEPTH_BUFFER);
219 dw0 |= (cmd_len - 2);
220
Chia-I Wue24c3292014-08-21 14:05:23 +0800221 cmd_batch_reserve(cmd, cmd_len);
222 cmd_batch_write(cmd, dw0);
223 cmd_batch_write(cmd, view->cmd[0]);
224 cmd_batch_reloc(cmd, view->cmd[1], view->img->obj.mem,
225 INTEL_DOMAIN_RENDER,
226 INTEL_DOMAIN_RENDER);
227 cmd_batch_write(cmd, view->cmd[2]);
228 cmd_batch_write(cmd, view->cmd[3]);
229 cmd_batch_write(cmd, view->cmd[4]);
230 cmd_batch_write(cmd, view->cmd[5]);
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800231}
232
233static void gen6_3DSTATE_STENCIL_BUFFER(struct intel_cmd *cmd,
234 const struct intel_ds_view *view)
235{
236 const uint8_t cmd_len = 3;
237 uint32_t dw0;
238
239 CMD_ASSERT(cmd, 6, 7.5);
240
241 dw0 = (cmd_gen(cmd) >= INTEL_GEN(7)) ?
242 GEN_RENDER_CMD(3D, GEN7, 3DSTATE_STENCIL_BUFFER) :
243 GEN_RENDER_CMD(3D, GEN6, 3DSTATE_STENCIL_BUFFER);
244 dw0 |= (cmd_len - 2);
245
Chia-I Wue24c3292014-08-21 14:05:23 +0800246 cmd_batch_reserve(cmd, cmd_len);
247 cmd_batch_write(cmd, dw0);
248 cmd_batch_write(cmd, view->cmd[6]);
249 cmd_batch_reloc(cmd, view->cmd[7], view->img->obj.mem,
250 INTEL_DOMAIN_RENDER,
251 INTEL_DOMAIN_RENDER);
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800252}
253
254static void gen6_3DSTATE_HIER_DEPTH_BUFFER(struct intel_cmd *cmd,
255 const struct intel_ds_view *view)
256{
257 const uint8_t cmd_len = 3;
258 uint32_t dw0;
259
260 CMD_ASSERT(cmd, 6, 7.5);
261
262 dw0 = (cmd_gen(cmd) >= INTEL_GEN(7)) ?
263 GEN_RENDER_CMD(3D, GEN7, 3DSTATE_HIER_DEPTH_BUFFER) :
264 GEN_RENDER_CMD(3D, GEN6, 3DSTATE_HIER_DEPTH_BUFFER);
265 dw0 |= (cmd_len - 2);
266
Chia-I Wue24c3292014-08-21 14:05:23 +0800267 cmd_batch_reserve(cmd, cmd_len);
268 cmd_batch_write(cmd, dw0);
269 cmd_batch_write(cmd, view->cmd[8]);
270 cmd_batch_reloc(cmd, view->cmd[9], view->img->obj.mem,
271 INTEL_DOMAIN_RENDER,
272 INTEL_DOMAIN_RENDER);
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800273}
274
Chia-I Wu302742d2014-08-22 10:28:29 +0800275static void gen6_3DSTATE_CC_STATE_POINTERS(struct intel_cmd *cmd,
276 XGL_UINT blend_pos,
277 XGL_UINT ds_pos,
278 XGL_UINT cc_pos)
279{
280 const uint8_t cmd_len = 4;
281 uint32_t dw0;
282
283 CMD_ASSERT(cmd, 6, 6);
284
285 dw0 = GEN_RENDER_CMD(3D, GEN6, 3DSTATE_CC_STATE_POINTERS) |
286 (cmd_len - 2);
287
288 cmd_batch_reserve(cmd, cmd_len);
289 cmd_batch_write(cmd, dw0);
290 cmd_batch_write(cmd, (blend_pos << 2) | 1);
291 cmd_batch_write(cmd, (ds_pos << 2) | 1);
292 cmd_batch_write(cmd, (cc_pos << 2) | 1);
293}
294
295static void gen7_3dstate_pointer(struct intel_cmd *cmd,
296 int subop, XGL_UINT pos)
297{
298 const uint8_t cmd_len = 2;
299 const uint32_t dw0 = GEN6_RENDER_TYPE_RENDER |
300 GEN6_RENDER_SUBTYPE_3D |
301 subop | (cmd_len - 2);
302
303 cmd_batch_reserve(cmd, cmd_len);
304 cmd_batch_write(cmd, dw0);
305 cmd_batch_write(cmd, pos << 2);
306}
307
308static XGL_UINT gen6_BLEND_STATE(struct intel_cmd *cmd,
309 const struct intel_blend_state *state)
310{
311 const uint8_t cmd_align = GEN6_ALIGNMENT_BLEND_STATE;
312 const uint8_t cmd_len = XGL_MAX_COLOR_ATTACHMENTS * 2;
313
314 CMD_ASSERT(cmd, 6, 7.5);
315 STATIC_ASSERT(ARRAY_SIZE(state->cmd) >= cmd_len);
316
317 return cmd_state_copy(cmd, state->cmd, cmd_len, cmd_align);
318}
319
320static XGL_UINT gen6_DEPTH_STENCIL_STATE(struct intel_cmd *cmd,
321 const struct intel_ds_state *state)
322{
323 const uint8_t cmd_align = GEN6_ALIGNMENT_DEPTH_STENCIL_STATE;
324 const uint8_t cmd_len = 3;
325
326 CMD_ASSERT(cmd, 6, 7.5);
327 STATIC_ASSERT(ARRAY_SIZE(state->cmd) >= cmd_len);
328
329 return cmd_state_copy(cmd, state->cmd, cmd_len, cmd_align);
330}
331
332static XGL_UINT gen6_COLOR_CALC_STATE(struct intel_cmd *cmd,
333 uint32_t stencil_ref,
334 const uint32_t blend_color[4])
335{
336 const uint8_t cmd_align = GEN6_ALIGNMENT_COLOR_CALC_STATE;
337 const uint8_t cmd_len = 6;
338 XGL_UINT pos;
339 uint32_t *dw;
340
341 CMD_ASSERT(cmd, 6, 7.5);
342
343 dw = cmd_state_reserve(cmd, cmd_len, cmd_align, &pos);
344 dw[0] = stencil_ref;
345 dw[1] = 0;
346 dw[2] = blend_color[0];
347 dw[3] = blend_color[1];
348 dw[4] = blend_color[2];
349 dw[5] = blend_color[3];
350 cmd_state_advance(cmd, cmd_len);
351
352 return pos;
353}
354
355static void gen6_cc_states(struct intel_cmd *cmd)
356{
357 const struct intel_blend_state *blend = cmd->bind.state.blend;
358 const struct intel_ds_state *ds = cmd->bind.state.ds;
359 XGL_UINT blend_pos, ds_pos, cc_pos;
360
361 CMD_ASSERT(cmd, 6, 6);
362
363 blend_pos = gen6_BLEND_STATE(cmd, blend);
364 ds_pos = gen6_DEPTH_STENCIL_STATE(cmd, ds);
365 cc_pos = gen6_COLOR_CALC_STATE(cmd,
366 ds->cmd_stencil_ref, blend->cmd_blend_color);
367
368 gen6_3DSTATE_CC_STATE_POINTERS(cmd, blend_pos, ds_pos, cc_pos);
369}
370
371static void gen7_cc_states(struct intel_cmd *cmd)
372{
373 const struct intel_blend_state *blend = cmd->bind.state.blend;
374 const struct intel_ds_state *ds = cmd->bind.state.ds;
375 XGL_UINT pos;
376
377 CMD_ASSERT(cmd, 7, 7.5);
378
379 pos = gen6_BLEND_STATE(cmd, blend);
380 gen7_3dstate_pointer(cmd,
381 GEN7_RENDER_OPCODE_3DSTATE_BLEND_STATE_POINTERS, pos);
382
383 pos = gen6_DEPTH_STENCIL_STATE(cmd, ds);
384 gen7_3dstate_pointer(cmd,
385 GEN7_RENDER_OPCODE_3DSTATE_DEPTH_STENCIL_STATE_POINTERS, pos);
386
387 pos = gen6_COLOR_CALC_STATE(cmd,
388 ds->cmd_stencil_ref, blend->cmd_blend_color);
389 gen7_3dstate_pointer(cmd,
390 GEN6_RENDER_OPCODE_3DSTATE_CC_STATE_POINTERS, pos);
391}
392
Chia-I Wu52500102014-08-22 00:46:04 +0800393static void emit_bounded_states(struct intel_cmd *cmd)
394{
395 const struct intel_msaa_state *msaa = cmd->bind.state.msaa;
396
397 /* TODO more states */
398
Chia-I Wu302742d2014-08-22 10:28:29 +0800399 if (cmd_gen(cmd) >= INTEL_GEN(7))
400 gen7_cc_states(cmd);
401 else
402 gen6_cc_states(cmd);
403
Chia-I Wu52500102014-08-22 00:46:04 +0800404 /* 3DSTATE_MULTISAMPLE and 3DSTATE_SAMPLE_MASK */
405 cmd_batch_reserve(cmd, msaa->cmd_len);
406 cmd_batch_write_n(cmd, msaa->cmd, msaa->cmd_len);
407}
408
Chia-I Wub2755562014-08-20 13:38:52 +0800409XGL_VOID XGLAPI intelCmdBindPipeline(
410 XGL_CMD_BUFFER cmdBuffer,
411 XGL_PIPELINE_BIND_POINT pipelineBindPoint,
412 XGL_PIPELINE pipeline)
413{
414 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
415
416 switch (pipelineBindPoint) {
417 case XGL_PIPELINE_BIND_POINT_COMPUTE:
Chia-I Wu018a3962014-08-21 10:37:52 +0800418 cmd->bind.pipeline.compute = intel_pipeline(pipeline);
Chia-I Wub2755562014-08-20 13:38:52 +0800419 break;
420 case XGL_PIPELINE_BIND_POINT_GRAPHICS:
Chia-I Wu018a3962014-08-21 10:37:52 +0800421 cmd->bind.pipeline.graphics = intel_pipeline(pipeline);
Chia-I Wub2755562014-08-20 13:38:52 +0800422 break;
423 default:
424 break;
425 }
426}
427
428XGL_VOID XGLAPI intelCmdBindPipelineDelta(
429 XGL_CMD_BUFFER cmdBuffer,
430 XGL_PIPELINE_BIND_POINT pipelineBindPoint,
431 XGL_PIPELINE_DELTA delta)
432{
433 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
434
435 switch (pipelineBindPoint) {
436 case XGL_PIPELINE_BIND_POINT_COMPUTE:
437 cmd->bind.pipeline.compute_delta = delta;
438 break;
439 case XGL_PIPELINE_BIND_POINT_GRAPHICS:
440 cmd->bind.pipeline.graphics_delta = delta;
441 break;
442 default:
443 break;
444 }
445}
446
447XGL_VOID XGLAPI intelCmdBindStateObject(
448 XGL_CMD_BUFFER cmdBuffer,
449 XGL_STATE_BIND_POINT stateBindPoint,
450 XGL_STATE_OBJECT state)
451{
452 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
453
454 switch (stateBindPoint) {
455 case XGL_STATE_BIND_VIEWPORT:
456 cmd->bind.state.viewport =
457 intel_viewport_state((XGL_VIEWPORT_STATE_OBJECT) state);
458 break;
459 case XGL_STATE_BIND_RASTER:
460 cmd->bind.state.raster =
461 intel_raster_state((XGL_RASTER_STATE_OBJECT) state);
462 break;
463 case XGL_STATE_BIND_DEPTH_STENCIL:
464 cmd->bind.state.ds =
465 intel_ds_state((XGL_DEPTH_STENCIL_STATE_OBJECT) state);
466 break;
467 case XGL_STATE_BIND_COLOR_BLEND:
468 cmd->bind.state.blend =
469 intel_blend_state((XGL_COLOR_BLEND_STATE_OBJECT) state);
470 break;
471 case XGL_STATE_BIND_MSAA:
472 cmd->bind.state.msaa =
473 intel_msaa_state((XGL_MSAA_STATE_OBJECT) state);
474 break;
475 default:
476 break;
477 }
478}
479
480XGL_VOID XGLAPI intelCmdBindDescriptorSet(
481 XGL_CMD_BUFFER cmdBuffer,
482 XGL_PIPELINE_BIND_POINT pipelineBindPoint,
483 XGL_UINT index,
484 XGL_DESCRIPTOR_SET descriptorSet,
485 XGL_UINT slotOffset)
486{
487 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
488 struct intel_dset *dset = intel_dset(descriptorSet);
489
490 assert(!index);
491
492 switch (pipelineBindPoint) {
493 case XGL_PIPELINE_BIND_POINT_COMPUTE:
494 cmd->bind.dset.compute = dset;
495 cmd->bind.dset.compute_offset = slotOffset;
496 break;
497 case XGL_PIPELINE_BIND_POINT_GRAPHICS:
498 cmd->bind.dset.graphics = dset;
499 cmd->bind.dset.graphics_offset = slotOffset;
500 break;
501 default:
502 break;
503 }
504}
505
506XGL_VOID XGLAPI intelCmdBindDynamicMemoryView(
507 XGL_CMD_BUFFER cmdBuffer,
508 XGL_PIPELINE_BIND_POINT pipelineBindPoint,
509 const XGL_MEMORY_VIEW_ATTACH_INFO* pMemView)
510{
511 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
512
513 switch (pipelineBindPoint) {
514 case XGL_PIPELINE_BIND_POINT_COMPUTE:
515 intel_mem_view_init(&cmd->bind.mem_view.compute, cmd->dev, pMemView);
516 break;
517 case XGL_PIPELINE_BIND_POINT_GRAPHICS:
518 intel_mem_view_init(&cmd->bind.mem_view.graphics, cmd->dev, pMemView);
519 break;
520 default:
521 break;
522 }
523}
524
525XGL_VOID XGLAPI intelCmdBindIndexData(
526 XGL_CMD_BUFFER cmdBuffer,
527 XGL_GPU_MEMORY mem_,
528 XGL_GPU_SIZE offset,
529 XGL_INDEX_TYPE indexType)
530{
531 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
532 struct intel_mem *mem = intel_mem(mem_);
533
Chia-I Wu9f039862014-08-20 15:39:56 +0800534 if (cmd_gen(cmd) >= INTEL_GEN(7.5)) {
535 gen6_3DSTATE_INDEX_BUFFER(cmd, mem, offset, indexType, false);
536 } else {
537 cmd->bind.index.mem = mem;
538 cmd->bind.index.offset = offset;
539 cmd->bind.index.type = indexType;
540 }
Chia-I Wub2755562014-08-20 13:38:52 +0800541}
542
543XGL_VOID XGLAPI intelCmdBindAttachments(
544 XGL_CMD_BUFFER cmdBuffer,
545 XGL_UINT colorAttachmentCount,
546 const XGL_COLOR_ATTACHMENT_BIND_INFO* pColorAttachments,
547 const XGL_DEPTH_STENCIL_BIND_INFO* pDepthStencilAttachment)
548{
549 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800550 const struct intel_ds_view *ds;
Chia-I Wub2755562014-08-20 13:38:52 +0800551 XGL_UINT i;
552
553 for (i = 0; i < colorAttachmentCount; i++) {
554 const XGL_COLOR_ATTACHMENT_BIND_INFO *att = &pColorAttachments[i];
555 struct intel_rt_view *rt = intel_rt_view(att->view);
556
557 cmd->bind.att.rt[i] = rt;
558 }
559
560 cmd->bind.att.rt_count = colorAttachmentCount;
561
562 if (pDepthStencilAttachment) {
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800563 cmd->bind.att.ds = intel_ds_view(pDepthStencilAttachment->view);
564 ds = cmd->bind.att.ds;
565
Chia-I Wub2755562014-08-20 13:38:52 +0800566 } else {
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800567 /* all zeros */
568 static const struct intel_ds_view null_ds;
569 ds = &null_ds;
Chia-I Wub2755562014-08-20 13:38:52 +0800570 }
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800571
Chia-I Wu254db422014-08-21 11:54:29 +0800572 /* TODO workarounds */
Chia-I Wu7fae4e32014-08-21 11:39:44 +0800573 gen6_3DSTATE_DEPTH_BUFFER(cmd, ds);
574 gen6_3DSTATE_STENCIL_BUFFER(cmd, ds);
575 gen6_3DSTATE_HIER_DEPTH_BUFFER(cmd, ds);
Chia-I Wub2755562014-08-20 13:38:52 +0800576}
577
578XGL_VOID XGLAPI intelCmdDraw(
579 XGL_CMD_BUFFER cmdBuffer,
580 XGL_UINT firstVertex,
581 XGL_UINT vertexCount,
582 XGL_UINT firstInstance,
583 XGL_UINT instanceCount)
584{
Chia-I Wu59c097e2014-08-21 10:51:07 +0800585 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
Chia-I Wu254db422014-08-21 11:54:29 +0800586 const struct intel_pipeline *p = cmd->bind.pipeline.graphics;
Chia-I Wu59c097e2014-08-21 10:51:07 +0800587
Chia-I Wu52500102014-08-22 00:46:04 +0800588 emit_bounded_states(cmd);
Chia-I Wu59c097e2014-08-21 10:51:07 +0800589
590 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
Chia-I Wu254db422014-08-21 11:54:29 +0800591 gen7_3DPRIMITIVE(cmd, p->prim_type, false, vertexCount,
592 firstVertex, instanceCount, firstInstance, 0);
Chia-I Wu59c097e2014-08-21 10:51:07 +0800593 } else {
Chia-I Wu254db422014-08-21 11:54:29 +0800594 gen6_3DPRIMITIVE(cmd, p->prim_type, false, vertexCount,
595 firstVertex, instanceCount, firstInstance, 0);
Chia-I Wu59c097e2014-08-21 10:51:07 +0800596 }
Chia-I Wub2755562014-08-20 13:38:52 +0800597}
598
599XGL_VOID XGLAPI intelCmdDrawIndexed(
600 XGL_CMD_BUFFER cmdBuffer,
601 XGL_UINT firstIndex,
602 XGL_UINT indexCount,
603 XGL_INT vertexOffset,
604 XGL_UINT firstInstance,
605 XGL_UINT instanceCount)
606{
Chia-I Wu59c097e2014-08-21 10:51:07 +0800607 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
Chia-I Wu254db422014-08-21 11:54:29 +0800608 const struct intel_pipeline *p = cmd->bind.pipeline.graphics;
Chia-I Wu59c097e2014-08-21 10:51:07 +0800609
Chia-I Wu52500102014-08-22 00:46:04 +0800610 emit_bounded_states(cmd);
Chia-I Wu254db422014-08-21 11:54:29 +0800611
612 if (p->primitive_restart && !gen6_can_primitive_restart(cmd))
613 cmd->result = XGL_ERROR_UNKNOWN;
614
615 if (cmd_gen(cmd) >= INTEL_GEN(7.5)) {
616 gen75_3DSTATE_VF(cmd, p->primitive_restart,
617 p->primitive_restart_index);
618 } else {
619 gen6_3DSTATE_INDEX_BUFFER(cmd, cmd->bind.index.mem,
620 cmd->bind.index.offset, cmd->bind.index.type,
621 p->primitive_restart);
622 }
Chia-I Wu59c097e2014-08-21 10:51:07 +0800623
624 if (cmd_gen(cmd) >= INTEL_GEN(7)) {
Chia-I Wu254db422014-08-21 11:54:29 +0800625 gen7_3DPRIMITIVE(cmd, p->prim_type, true, indexCount,
626 firstIndex, instanceCount, firstInstance, 0);
Chia-I Wu59c097e2014-08-21 10:51:07 +0800627 } else {
Chia-I Wu254db422014-08-21 11:54:29 +0800628 gen6_3DPRIMITIVE(cmd, p->prim_type, true, indexCount,
629 firstIndex, instanceCount, firstInstance, 0);
Chia-I Wu59c097e2014-08-21 10:51:07 +0800630 }
Chia-I Wub2755562014-08-20 13:38:52 +0800631}
632
633XGL_VOID XGLAPI intelCmdDrawIndirect(
634 XGL_CMD_BUFFER cmdBuffer,
635 XGL_GPU_MEMORY mem,
636 XGL_GPU_SIZE offset,
637 XGL_UINT32 count,
638 XGL_UINT32 stride)
639{
Chia-I Wu59c097e2014-08-21 10:51:07 +0800640 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
641
642 cmd->result = XGL_ERROR_UNKNOWN;
Chia-I Wub2755562014-08-20 13:38:52 +0800643}
644
645XGL_VOID XGLAPI intelCmdDrawIndexedIndirect(
646 XGL_CMD_BUFFER cmdBuffer,
647 XGL_GPU_MEMORY mem,
648 XGL_GPU_SIZE offset,
649 XGL_UINT32 count,
650 XGL_UINT32 stride)
651{
Chia-I Wu59c097e2014-08-21 10:51:07 +0800652 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
653
654 cmd->result = XGL_ERROR_UNKNOWN;
Chia-I Wub2755562014-08-20 13:38:52 +0800655}
656
657XGL_VOID XGLAPI intelCmdDispatch(
658 XGL_CMD_BUFFER cmdBuffer,
659 XGL_UINT x,
660 XGL_UINT y,
661 XGL_UINT z)
662{
Chia-I Wu59c097e2014-08-21 10:51:07 +0800663 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
664
665 cmd->result = XGL_ERROR_UNKNOWN;
Chia-I Wub2755562014-08-20 13:38:52 +0800666}
667
668XGL_VOID XGLAPI intelCmdDispatchIndirect(
669 XGL_CMD_BUFFER cmdBuffer,
670 XGL_GPU_MEMORY mem,
671 XGL_GPU_SIZE offset)
672{
Chia-I Wu59c097e2014-08-21 10:51:07 +0800673 struct intel_cmd *cmd = intel_cmd(cmdBuffer);
674
675 cmd->result = XGL_ERROR_UNKNOWN;
Chia-I Wub2755562014-08-20 13:38:52 +0800676}