ilo: update outdated gen assertions for Gen8
[mesa.git] / src / gallium / drivers / ilo / ilo_builder_3d.h
1 /*
2 * Mesa 3-D graphics library
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 * Authors:
25 * Chia-I Wu <olv@lunarg.com>
26 */
27
28 #ifndef ILO_BUILDER_3D_H
29 #define ILO_BUILDER_3D_H
30
31 #include "genhw/genhw.h"
32
33 #include "ilo_common.h"
34 #include "ilo_builder_3d_top.h"
35 #include "ilo_builder_3d_bottom.h"
36
37 static inline void
38 gen6_3DPRIMITIVE(struct ilo_builder *builder,
39 const struct pipe_draw_info *info,
40 const struct ilo_ib_state *ib)
41 {
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);
48 uint32_t *dw;
49
50 ILO_DEV_ASSERT(builder->dev, 6, 6);
51
52 ilo_builder_batch_pointer(builder, cmd_len, &dw);
53
54 dw[0] = GEN6_RENDER_CMD(3D, 3DPRIMITIVE) |
55 vb_access |
56 prim << GEN6_3DPRIM_DW0_TYPE__SHIFT |
57 (cmd_len - 2);
58 dw[1] = info->count;
59 dw[2] = vb_start;
60 dw[3] = info->instance_count;
61 dw[4] = info->start_instance;
62 dw[5] = info->index_bias;
63 }
64
65 static inline void
66 gen7_3DPRIMITIVE(struct ilo_builder *builder,
67 const struct pipe_draw_info *info,
68 const struct ilo_ib_state *ib)
69 {
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);
76 uint32_t *dw;
77
78 ILO_DEV_ASSERT(builder->dev, 7, 8);
79
80 ilo_builder_batch_pointer(builder, cmd_len, &dw);
81
82 dw[0] = GEN6_RENDER_CMD(3D, 3DPRIMITIVE) | (cmd_len - 2);
83 dw[1] = vb_access | prim;
84 dw[2] = info->count;
85 dw[3] = vb_start;
86 dw[4] = info->instance_count;
87 dw[5] = info->start_instance;
88 dw[6] = info->index_bias;
89 }
90
91 #endif /* ILO_BUILDER_3D_H */