2 * Mesa 3-D graphics library
4 * Copyright (C) 2014 LunarG, Inc.
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:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
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.
25 * Chia-I Wu <olv@lunarg.com>
28 #ifndef ILO_BUILDER_3D_H
29 #define ILO_BUILDER_3D_H
31 #include "genhw/genhw.h"
33 #include "ilo_common.h"
34 #include "ilo_builder_3d_top.h"
35 #include "ilo_builder_3d_bottom.h"
38 gen6_3DPRIMITIVE(struct ilo_builder
*builder
,
39 const struct pipe_draw_info
*info
,
40 const struct ilo_ib_state
*ib
)
42 const uint8_t cmd_len
= 6;
43 const int prim
= gen6_3d_translate_pipe_prim(info
->mode
);
44 const int vb_access
= (info
->indexed
) ?
45 GEN6_3DPRIM_DW0_ACCESS_RANDOM
: GEN6_3DPRIM_DW0_ACCESS_SEQUENTIAL
;
46 const uint32_t vb_start
= info
->start
+
47 ((info
->indexed
) ? ib
->draw_start_offset
: 0);
50 ILO_DEV_ASSERT(builder
->dev
, 6, 6);
52 ilo_builder_batch_pointer(builder
, cmd_len
, &dw
);
54 dw
[0] = GEN6_RENDER_CMD(3D
, 3DPRIMITIVE
) |
56 prim
<< GEN6_3DPRIM_DW0_TYPE__SHIFT
|
60 dw
[3] = info
->instance_count
;
61 dw
[4] = info
->start_instance
;
62 dw
[5] = info
->index_bias
;
66 gen7_3DPRIMITIVE(struct ilo_builder
*builder
,
67 const struct pipe_draw_info
*info
,
68 const struct ilo_ib_state
*ib
)
70 const uint8_t cmd_len
= 7;
71 const int prim
= gen6_3d_translate_pipe_prim(info
->mode
);
72 const int vb_access
= (info
->indexed
) ?
73 GEN7_3DPRIM_DW1_ACCESS_RANDOM
: GEN7_3DPRIM_DW1_ACCESS_SEQUENTIAL
;
74 const uint32_t vb_start
= info
->start
+
75 ((info
->indexed
) ? ib
->draw_start_offset
: 0);
78 ILO_DEV_ASSERT(builder
->dev
, 7, 8);
80 ilo_builder_batch_pointer(builder
, cmd_len
, &dw
);
82 dw
[0] = GEN6_RENDER_CMD(3D
, 3DPRIMITIVE
) | (cmd_len
- 2);
83 dw
[1] = vb_access
| prim
;
86 dw
[4] = info
->instance_count
;
87 dw
[5] = info
->start_instance
;
88 dw
[6] = info
->index_bias
;
91 #endif /* ILO_BUILDER_3D_H */