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 (at) 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_core.h" 34 #include "ilo_dev.h" 35 #include "ilo_builder_3d_top.h" 36 #include "ilo_builder_3d_bottom.h" 37 38 struct gen6_3dprimitive_info { 39 enum gen_3dprim_type topology; 40 bool indexed; 41 42 uint32_t vertex_count; 43 uint32_t vertex_start; 44 uint32_t instance_count; 45 uint32_t instance_start; 46 int32_t vertex_base; 47 }; 48 49 static inline void 50 gen6_3DPRIMITIVE(struct ilo_builder *builder, 51 const struct gen6_3dprimitive_info *info) 52 { 53 const uint8_t cmd_len = 6; 54 uint32_t *dw; 55 56 ILO_DEV_ASSERT(builder->dev, 6, 6); 57 58 ilo_builder_batch_pointer(builder, cmd_len, &dw); 59 60 dw[0] = GEN6_RENDER_CMD(3D, 3DPRIMITIVE) | (cmd_len - 2) | 61 info->topology << GEN6_3DPRIM_DW0_TYPE__SHIFT; 62 if (info->indexed) 63 dw[0] |= GEN6_3DPRIM_DW0_ACCESS_RANDOM; 64 65 dw[1] = info->vertex_count; 66 dw[2] = info->vertex_start; 67 dw[3] = info->instance_count; 68 dw[4] = info->instance_start; 69 dw[5] = info->vertex_base; 70 } 71 72 static inline void 73 gen7_3DPRIMITIVE(struct ilo_builder *builder, 74 const struct gen6_3dprimitive_info *info) 75 { 76 const uint8_t cmd_len = 7; 77 uint32_t *dw; 78 79 ILO_DEV_ASSERT(builder->dev, 7, 8); 80 81 ilo_builder_batch_pointer(builder, cmd_len, &dw); 82 83 dw[0] = GEN6_RENDER_CMD(3D, 3DPRIMITIVE) | (cmd_len - 2); 84 85 dw[1] = info->topology << GEN7_3DPRIM_DW1_TYPE__SHIFT; 86 if (info->indexed) 87 dw[1] |= GEN7_3DPRIM_DW1_ACCESS_RANDOM; 88 89 dw[2] = info->vertex_count; 90 dw[3] = info->vertex_start; 91 dw[4] = info->instance_count; 92 dw[5] = info->instance_start; 93 dw[6] = info->vertex_base; 94 } 95 96 #endif /* ILO_BUILDER_3D_H */ 97