Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  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_core.h"
  34. #include "ilo_dev.h"
  35. #include "ilo_builder_3d_top.h"
  36. #include "ilo_builder_3d_bottom.h"
  37.  
  38. static inline void
  39. gen6_3DPRIMITIVE(struct ilo_builder *builder,
  40.                  const struct pipe_draw_info *info,
  41.                  const struct ilo_ib_state *ib)
  42. {
  43.    const uint8_t cmd_len = 6;
  44.    const int prim = gen6_3d_translate_pipe_prim(info->mode);
  45.    const int vb_access = (info->indexed) ?
  46.       GEN6_3DPRIM_DW0_ACCESS_RANDOM : GEN6_3DPRIM_DW0_ACCESS_SEQUENTIAL;
  47.    const uint32_t vb_start = info->start +
  48.       ((info->indexed) ? ib->draw_start_offset : 0);
  49.    uint32_t *dw;
  50.  
  51.    ILO_DEV_ASSERT(builder->dev, 6, 6);
  52.  
  53.    ilo_builder_batch_pointer(builder, cmd_len, &dw);
  54.  
  55.    dw[0] = GEN6_RENDER_CMD(3D, 3DPRIMITIVE) |
  56.            vb_access |
  57.            prim << GEN6_3DPRIM_DW0_TYPE__SHIFT |
  58.            (cmd_len - 2);
  59.    dw[1] = info->count;
  60.    dw[2] = vb_start;
  61.    dw[3] = info->instance_count;
  62.    dw[4] = info->start_instance;
  63.    dw[5] = info->index_bias;
  64. }
  65.  
  66. static inline void
  67. gen7_3DPRIMITIVE(struct ilo_builder *builder,
  68.                  const struct pipe_draw_info *info,
  69.                  const struct ilo_ib_state *ib)
  70. {
  71.    const uint8_t cmd_len = 7;
  72.    const int prim = gen6_3d_translate_pipe_prim(info->mode);
  73.    const int vb_access = (info->indexed) ?
  74.       GEN7_3DPRIM_DW1_ACCESS_RANDOM : GEN7_3DPRIM_DW1_ACCESS_SEQUENTIAL;
  75.    const uint32_t vb_start = info->start +
  76.       ((info->indexed) ? ib->draw_start_offset : 0);
  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.    dw[1] = vb_access | prim;
  85.    dw[2] = info->count;
  86.    dw[3] = vb_start;
  87.    dw[4] = info->instance_count;
  88.    dw[5] = info->start_instance;
  89.    dw[6] = info->index_bias;
  90. }
  91.  
  92. #endif /* ILO_BUILDER_3D_H */
  93.