Home | History | Annotate | Download | only in core
      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_BOTTOM_H
     29 #define ILO_BUILDER_3D_BOTTOM_H
     30 
     31 #include "genhw/genhw.h"
     32 #include "intel_winsys.h"
     33 
     34 #include "ilo_core.h"
     35 #include "ilo_dev.h"
     36 #include "ilo_state_cc.h"
     37 #include "ilo_state_raster.h"
     38 #include "ilo_state_sbe.h"
     39 #include "ilo_state_shader.h"
     40 #include "ilo_state_viewport.h"
     41 #include "ilo_state_zs.h"
     42 #include "ilo_vma.h"
     43 #include "ilo_builder.h"
     44 #include "ilo_builder_3d_top.h"
     45 
     46 static inline void
     47 gen6_3DSTATE_CLIP(struct ilo_builder *builder,
     48                   const struct ilo_state_raster *rs)
     49 {
     50    const uint8_t cmd_len = 4;
     51    uint32_t *dw;
     52 
     53    ILO_DEV_ASSERT(builder->dev, 6, 8);
     54 
     55    ilo_builder_batch_pointer(builder, cmd_len, &dw);
     56 
     57    dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_CLIP) | (cmd_len - 2);
     58    /* see raster_set_gen6_3DSTATE_CLIP() */
     59    dw[1] = rs->clip[0];
     60    dw[2] = rs->clip[1];
     61    dw[3] = rs->clip[2];
     62 }
     63 
     64 static inline void
     65 gen6_3DSTATE_SF(struct ilo_builder *builder,
     66                 const struct ilo_state_raster *rs,
     67                 const struct ilo_state_sbe *sbe)
     68 {
     69    const uint8_t cmd_len = 20;
     70    uint32_t *dw;
     71 
     72    ILO_DEV_ASSERT(builder->dev, 6, 6);
     73 
     74    ilo_builder_batch_pointer(builder, cmd_len, &dw);
     75 
     76    dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_SF) | (cmd_len - 2);
     77    /* see sbe_set_gen8_3DSTATE_SBE() */
     78    dw[1] = sbe->sbe[0];
     79 
     80    /* see raster_set_gen7_3DSTATE_SF() */
     81    dw[2] = rs->sf[0];
     82    dw[3] = rs->sf[1];
     83    dw[4] = rs->sf[2];
     84    dw[5] = rs->raster[1];
     85    dw[6] = rs->raster[2];
     86    dw[7] = rs->raster[3];
     87 
     88    /* see sbe_set_gen8_3DSTATE_SBE_SWIZ() */
     89    memcpy(&dw[8], sbe->swiz, sizeof(*dw) * 8);
     90 
     91    dw[16] = sbe->sbe[1];
     92    dw[17] = sbe->sbe[2];
     93    /* WrapShortest enables */
     94    dw[18] = 0;
     95    dw[19] = 0;
     96 }
     97 
     98 static inline void
     99 gen7_3DSTATE_SF(struct ilo_builder *builder,
    100                 const struct ilo_state_raster *rs)
    101 {
    102    const uint8_t cmd_len = (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) ? 4 : 7;
    103    uint32_t *dw;
    104 
    105    ILO_DEV_ASSERT(builder->dev, 7, 8);
    106 
    107    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    108 
    109    dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_SF) | (cmd_len - 2);
    110 
    111    /* see raster_set_gen7_3DSTATE_SF() or raster_set_gen8_3DSTATE_SF() */
    112    dw[1] = rs->sf[0];
    113    dw[2] = rs->sf[1];
    114    dw[3] = rs->sf[2];
    115    if (ilo_dev_gen(builder->dev) < ILO_GEN(8)) {
    116       dw[4] = rs->raster[1];
    117       dw[5] = rs->raster[2];
    118       dw[6] = rs->raster[3];
    119    }
    120 }
    121 
    122 static inline void
    123 gen7_3DSTATE_SBE(struct ilo_builder *builder,
    124                  const struct ilo_state_sbe *sbe)
    125 {
    126    const uint8_t cmd_len = 14;
    127    uint32_t *dw;
    128 
    129    ILO_DEV_ASSERT(builder->dev, 7, 7.5);
    130 
    131    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    132 
    133    dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_SBE) | (cmd_len - 2);
    134    /* see sbe_set_gen8_3DSTATE_SBE() and sbe_set_gen8_3DSTATE_SBE_SWIZ() */
    135    dw[1] = sbe->sbe[0];
    136    memcpy(&dw[2], sbe->swiz, sizeof(*dw) * 8);
    137    dw[10] = sbe->sbe[1];
    138    dw[11] = sbe->sbe[2];
    139 
    140    /* WrapShortest enables */
    141    dw[12] = 0;
    142    dw[13] = 0;
    143 }
    144 
    145 static inline void
    146 gen8_3DSTATE_SBE(struct ilo_builder *builder,
    147                  const struct ilo_state_sbe *sbe)
    148 {
    149    const uint8_t cmd_len = 4;
    150    uint32_t *dw;
    151 
    152    ILO_DEV_ASSERT(builder->dev, 8, 8);
    153 
    154    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    155 
    156    /* see sbe_set_gen8_3DSTATE_SBE() */
    157    dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_SBE) | (cmd_len - 2);
    158    dw[1] = sbe->sbe[0];
    159    dw[2] = sbe->sbe[1];
    160    dw[3] = sbe->sbe[2];
    161 }
    162 
    163 static inline void
    164 gen8_3DSTATE_SBE_SWIZ(struct ilo_builder *builder,
    165                       const struct ilo_state_sbe *sbe)
    166 {
    167    const uint8_t cmd_len = 11;
    168    uint32_t *dw;
    169 
    170    ILO_DEV_ASSERT(builder->dev, 8, 8);
    171 
    172    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    173 
    174    dw[0] = GEN8_RENDER_CMD(3D, 3DSTATE_SBE_SWIZ) | (cmd_len - 2);
    175    /* see sbe_set_gen8_3DSTATE_SBE_SWIZ() */
    176    memcpy(&dw[1], sbe->swiz, sizeof(*dw) * 8);
    177    /* WrapShortest enables */
    178    dw[9] = 0;
    179    dw[10] = 0;
    180 }
    181 
    182 static inline void
    183 gen8_3DSTATE_RASTER(struct ilo_builder *builder,
    184                     const struct ilo_state_raster *rs)
    185 {
    186    const uint8_t cmd_len = 5;
    187    uint32_t *dw;
    188 
    189    ILO_DEV_ASSERT(builder->dev, 8, 8);
    190 
    191    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    192 
    193    dw[0] = GEN8_RENDER_CMD(3D, 3DSTATE_RASTER) | (cmd_len - 2);
    194    /* see raster_set_gen8_3DSTATE_RASTER() */
    195    dw[1] = rs->raster[0];
    196    dw[2] = rs->raster[1];
    197    dw[3] = rs->raster[2];
    198    dw[4] = rs->raster[3];
    199 }
    200 
    201 static inline void
    202 gen6_3DSTATE_WM(struct ilo_builder *builder,
    203                 const struct ilo_state_raster *rs,
    204                 const struct ilo_state_ps *ps,
    205                 uint32_t kernel_offset,
    206                 struct intel_bo *scratch_bo)
    207 {
    208    const uint8_t cmd_len = 9;
    209    uint32_t *dw;
    210    unsigned pos;
    211 
    212    ILO_DEV_ASSERT(builder->dev, 6, 6);
    213 
    214    pos = ilo_builder_batch_pointer(builder, cmd_len, &dw);
    215 
    216    dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_WM) | (cmd_len - 2);
    217    dw[1] = kernel_offset;
    218    /* see raster_set_gen6_3dstate_wm() and ps_set_gen6_3dstate_wm() */
    219    dw[2] = ps->ps[0];
    220    dw[3] = ps->ps[1];
    221    dw[4] = rs->wm[0] | ps->ps[2];
    222    dw[5] = rs->wm[1] | ps->ps[3];
    223    dw[6] = rs->wm[2] | ps->ps[4];
    224    dw[7] = 0; /* kernel 1 */
    225    dw[8] = 0; /* kernel 2 */
    226 
    227    if (ilo_state_ps_get_scratch_size(ps)) {
    228       ilo_builder_batch_reloc(builder, pos + 2, scratch_bo,
    229             ps->ps[0], 0);
    230    }
    231 }
    232 
    233 static inline void
    234 gen7_3DSTATE_WM(struct ilo_builder *builder,
    235                 const struct ilo_state_raster *rs,
    236                 const struct ilo_state_ps *ps)
    237 {
    238    const uint8_t cmd_len = 3;
    239    uint32_t *dw;
    240 
    241    ILO_DEV_ASSERT(builder->dev, 7, 7.5);
    242 
    243    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    244 
    245    dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_WM) | (cmd_len - 2);
    246    /* see raster_set_gen8_3DSTATE_WM() and ps_set_gen7_3dstate_wm() */
    247    dw[1] = rs->wm[0] | ps->ps[0];
    248    dw[2] = ps->ps[1];
    249 }
    250 
    251 static inline void
    252 gen8_3DSTATE_WM(struct ilo_builder *builder,
    253                 const struct ilo_state_raster *rs)
    254 {
    255    const uint8_t cmd_len = 2;
    256    uint32_t *dw;
    257 
    258    ILO_DEV_ASSERT(builder->dev, 8, 8);
    259 
    260    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    261 
    262    dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_WM) | (cmd_len - 2);
    263    /* see raster_set_gen8_3DSTATE_WM() */
    264    dw[1] = rs->wm[0];
    265 }
    266 
    267 static inline void
    268 gen8_3DSTATE_WM_DEPTH_STENCIL(struct ilo_builder *builder,
    269                               const struct ilo_state_cc *cc)
    270 {
    271    const uint8_t cmd_len = 3;
    272    uint32_t *dw;
    273 
    274    ILO_DEV_ASSERT(builder->dev, 8, 8);
    275 
    276    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    277 
    278    dw[0] = GEN8_RENDER_CMD(3D, 3DSTATE_WM_DEPTH_STENCIL) | (cmd_len - 2);
    279    /* see cc_set_gen8_3DSTATE_WM_DEPTH_STENCIL() */
    280    dw[1] = cc->ds[0];
    281    dw[2] = cc->ds[1];
    282 }
    283 
    284 static inline void
    285 gen8_3DSTATE_WM_HZ_OP(struct ilo_builder *builder,
    286                       const struct ilo_state_raster *rs,
    287                       uint16_t width, uint16_t height)
    288 {
    289    const uint8_t cmd_len = 5;
    290    uint32_t *dw;
    291 
    292    ILO_DEV_ASSERT(builder->dev, 8, 8);
    293 
    294    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    295 
    296    dw[0] = GEN8_RENDER_CMD(3D, 3DSTATE_WM_HZ_OP) | (cmd_len - 2);
    297    /* see raster_set_gen8_3dstate_wm_hz_op() */
    298    dw[1] = rs->wm[1];
    299    dw[2] = 0;
    300    /* exclusive */
    301    dw[3] = height << 16 | width;
    302    dw[4] = rs->wm[2];
    303 }
    304 
    305 static inline void
    306 gen8_disable_3DSTATE_WM_HZ_OP(struct ilo_builder *builder)
    307 {
    308    const uint8_t cmd_len = 5;
    309    uint32_t *dw;
    310 
    311    ILO_DEV_ASSERT(builder->dev, 8, 8);
    312 
    313    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    314 
    315    dw[0] = GEN8_RENDER_CMD(3D, 3DSTATE_WM_HZ_OP) | (cmd_len - 2);
    316    dw[1] = 0;
    317    dw[2] = 0;
    318    dw[3] = 0;
    319    dw[4] = 0;
    320 }
    321 
    322 static inline void
    323 gen8_3DSTATE_WM_CHROMAKEY(struct ilo_builder *builder)
    324 {
    325    const uint8_t cmd_len = 2;
    326    uint32_t *dw;
    327 
    328    ILO_DEV_ASSERT(builder->dev, 8, 8);
    329 
    330    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    331 
    332    dw[0] = GEN8_RENDER_CMD(3D, 3DSTATE_WM_CHROMAKEY) | (cmd_len - 2);
    333    dw[1] = 0;
    334 }
    335 
    336 static inline void
    337 gen7_3DSTATE_PS(struct ilo_builder *builder,
    338                 const struct ilo_state_ps *ps,
    339                 uint32_t kernel_offset,
    340                 struct intel_bo *scratch_bo)
    341 {
    342    const uint8_t cmd_len = 8;
    343    uint32_t *dw;
    344    unsigned pos;
    345 
    346    ILO_DEV_ASSERT(builder->dev, 7, 7.5);
    347 
    348    pos = ilo_builder_batch_pointer(builder, cmd_len, &dw);
    349 
    350    dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_PS) | (cmd_len - 2);
    351    dw[1] = kernel_offset;
    352    /* see ps_set_gen7_3DSTATE_PS() */
    353    dw[2] = ps->ps[2];
    354    dw[3] = ps->ps[3];
    355    dw[4] = ps->ps[4];
    356    dw[5] = ps->ps[5];
    357    dw[6] = 0; /* kernel 1 */
    358    dw[7] = 0; /* kernel 2 */
    359 
    360    if (ilo_state_ps_get_scratch_size(ps)) {
    361       ilo_builder_batch_reloc(builder, pos + 3, scratch_bo,
    362             ps->ps[3], 0);
    363    }
    364 }
    365 
    366 static inline void
    367 gen8_3DSTATE_PS(struct ilo_builder *builder,
    368                 const struct ilo_state_ps *ps,
    369                 uint32_t kernel_offset,
    370                 struct intel_bo *scratch_bo)
    371 {
    372    const uint8_t cmd_len = 12;
    373    uint32_t *dw;
    374    unsigned pos;
    375 
    376    ILO_DEV_ASSERT(builder->dev, 8, 8);
    377 
    378    pos = ilo_builder_batch_pointer(builder, cmd_len, &dw);
    379 
    380    dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_PS) | (cmd_len - 2);
    381    dw[1] = kernel_offset;
    382    dw[2] = 0;
    383    /* see ps_set_gen8_3DSTATE_PS() */
    384    dw[3] = ps->ps[0];
    385    dw[4] = ps->ps[1];
    386    dw[5] = 0;
    387    dw[6] = ps->ps[2];
    388    dw[7] = ps->ps[3];
    389    dw[8] = 0; /* kernel 1 */
    390    dw[9] = 0;
    391    dw[10] = 0; /* kernel 2 */
    392    dw[11] = 0;
    393 
    394    if (ilo_state_ps_get_scratch_size(ps)) {
    395       ilo_builder_batch_reloc64(builder, pos + 4, scratch_bo,
    396             ps->ps[1], 0);
    397    }
    398 }
    399 
    400 static inline void
    401 gen8_3DSTATE_PS_EXTRA(struct ilo_builder *builder,
    402                       const struct ilo_state_ps *ps)
    403 {
    404    const uint8_t cmd_len = 2;
    405    uint32_t *dw;
    406 
    407    ILO_DEV_ASSERT(builder->dev, 8, 8);
    408 
    409    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    410 
    411    dw[0] = GEN8_RENDER_CMD(3D, 3DSTATE_PS_EXTRA) | (cmd_len - 2);
    412    /* see ps_set_gen8_3DSTATE_PS_EXTRA() */
    413    dw[1] = ps->ps[4];
    414 }
    415 
    416 static inline void
    417 gen8_3DSTATE_PS_BLEND(struct ilo_builder *builder,
    418                       const struct ilo_state_cc *cc)
    419 {
    420    const uint8_t cmd_len = 2;
    421    uint32_t *dw;
    422 
    423    ILO_DEV_ASSERT(builder->dev, 8, 8);
    424 
    425    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    426 
    427    dw[0] = GEN8_RENDER_CMD(3D, 3DSTATE_PS_BLEND) | (cmd_len - 2);
    428    /* see cc_set_gen8_3DSTATE_PS_BLEND() */
    429    dw[1] = cc->blend[0];
    430 }
    431 
    432 static inline void
    433 gen6_3DSTATE_CONSTANT_PS(struct ilo_builder *builder,
    434                          const uint32_t *bufs, const int *sizes,
    435                          int num_bufs)
    436 {
    437    gen6_3dstate_constant(builder, GEN6_RENDER_OPCODE_3DSTATE_CONSTANT_PS,
    438          bufs, sizes, num_bufs);
    439 }
    440 
    441 static inline void
    442 gen7_3DSTATE_CONSTANT_PS(struct ilo_builder *builder,
    443                          const uint32_t *bufs, const int *sizes,
    444                          int num_bufs)
    445 {
    446    gen7_3dstate_constant(builder, GEN6_RENDER_OPCODE_3DSTATE_CONSTANT_PS,
    447          bufs, sizes, num_bufs);
    448 }
    449 
    450 static inline void
    451 gen7_3DSTATE_BINDING_TABLE_POINTERS_PS(struct ilo_builder *builder,
    452                                        uint32_t binding_table)
    453 {
    454    ILO_DEV_ASSERT(builder->dev, 7, 8);
    455 
    456    gen7_3dstate_pointer(builder,
    457          GEN7_RENDER_OPCODE_3DSTATE_BINDING_TABLE_POINTERS_PS,
    458          binding_table);
    459 }
    460 
    461 static inline void
    462 gen7_3DSTATE_SAMPLER_STATE_POINTERS_PS(struct ilo_builder *builder,
    463                                        uint32_t sampler_state)
    464 {
    465    ILO_DEV_ASSERT(builder->dev, 7, 8);
    466 
    467    gen7_3dstate_pointer(builder,
    468          GEN7_RENDER_OPCODE_3DSTATE_SAMPLER_STATE_POINTERS_PS,
    469          sampler_state);
    470 }
    471 
    472 static inline void
    473 gen6_3DSTATE_MULTISAMPLE(struct ilo_builder *builder,
    474                          const struct ilo_state_raster *rs,
    475                          const struct ilo_state_sample_pattern *pattern,
    476                          uint8_t sample_count)
    477 {
    478    const uint8_t cmd_len = (ilo_dev_gen(builder->dev) >= ILO_GEN(7)) ? 4 : 3;
    479    const uint32_t *packed = (const uint32_t *)
    480       ilo_state_sample_pattern_get_packed_offsets(pattern,
    481             builder->dev, sample_count);
    482    uint32_t *dw;
    483 
    484    ILO_DEV_ASSERT(builder->dev, 6, 7.5);
    485 
    486    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    487 
    488    dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_MULTISAMPLE) | (cmd_len - 2);
    489    /* see raster_set_gen8_3DSTATE_MULTISAMPLE() */
    490    dw[1] = rs->sample[0];
    491 
    492    /* see sample_pattern_set_gen8_3DSTATE_SAMPLE_PATTERN() */
    493    dw[2] = (sample_count >= 4) ? packed[0] : 0;
    494    if (ilo_dev_gen(builder->dev) >= ILO_GEN(7))
    495       dw[3] = (sample_count >= 8) ? packed[1] : 0;
    496 }
    497 
    498 static inline void
    499 gen8_3DSTATE_MULTISAMPLE(struct ilo_builder *builder,
    500                          const struct ilo_state_raster *rs)
    501 {
    502    const uint8_t cmd_len = 2;
    503    uint32_t *dw;
    504 
    505    ILO_DEV_ASSERT(builder->dev, 8, 8);
    506 
    507    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    508 
    509    dw[0] = GEN8_RENDER_CMD(3D, 3DSTATE_MULTISAMPLE) | (cmd_len - 2);
    510    /* see raster_set_gen8_3DSTATE_MULTISAMPLE() */
    511    dw[1] = rs->sample[0];
    512 }
    513 
    514 static inline void
    515 gen8_3DSTATE_SAMPLE_PATTERN(struct ilo_builder *builder,
    516                             const struct ilo_state_sample_pattern *pattern)
    517 {
    518    const uint8_t cmd_len = 9;
    519    uint32_t *dw;
    520 
    521    ILO_DEV_ASSERT(builder->dev, 8, 8);
    522 
    523    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    524 
    525    dw[0] = GEN8_RENDER_CMD(3D, 3DSTATE_SAMPLE_PATTERN) | (cmd_len - 2);
    526    dw[1] = 0;
    527    dw[2] = 0;
    528    dw[3] = 0;
    529    dw[4] = 0;
    530    /* see sample_pattern_set_gen8_3DSTATE_SAMPLE_PATTERN() */
    531    dw[5] = ((const uint32_t *) pattern->pattern_8x)[1];
    532    dw[6] = ((const uint32_t *) pattern->pattern_8x)[0];
    533    dw[7] = ((const uint32_t *) pattern->pattern_4x)[0];
    534    dw[8] = pattern->pattern_1x[0] << 16 |
    535            ((const uint16_t *) pattern->pattern_2x)[0];
    536 }
    537 
    538 static inline void
    539 gen6_3DSTATE_SAMPLE_MASK(struct ilo_builder *builder,
    540                          const struct ilo_state_raster *rs)
    541 {
    542    const uint8_t cmd_len = 2;
    543    uint32_t *dw;
    544 
    545    ILO_DEV_ASSERT(builder->dev, 6, 8);
    546 
    547    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    548 
    549    dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_SAMPLE_MASK) | (cmd_len - 2);
    550    /* see raster_set_gen6_3DSTATE_SAMPLE_MASK() */
    551    dw[1] = rs->sample[1];
    552 }
    553 
    554 static inline void
    555 gen6_3DSTATE_DRAWING_RECTANGLE(struct ilo_builder *builder,
    556                                unsigned x, unsigned y,
    557                                unsigned width, unsigned height)
    558 {
    559    const uint8_t cmd_len = 4;
    560    unsigned xmax = x + width - 1;
    561    unsigned ymax = y + height - 1;
    562    unsigned rect_limit;
    563    uint32_t *dw;
    564 
    565    ILO_DEV_ASSERT(builder->dev, 6, 8);
    566 
    567    if (ilo_dev_gen(builder->dev) >= ILO_GEN(7)) {
    568       rect_limit = 16383;
    569    }
    570    else {
    571       /*
    572        * From the Sandy Bridge PRM, volume 2 part 1, page 230:
    573        *
    574        *     "[DevSNB] Errata: This field (Clipped Drawing Rectangle Y Min)
    575        *      must be an even number"
    576        */
    577       assert(y % 2 == 0);
    578 
    579       rect_limit = 8191;
    580    }
    581 
    582    if (x > rect_limit) x = rect_limit;
    583    if (y > rect_limit) y = rect_limit;
    584    if (xmax > rect_limit) xmax = rect_limit;
    585    if (ymax > rect_limit) ymax = rect_limit;
    586 
    587    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    588 
    589    dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_DRAWING_RECTANGLE) | (cmd_len - 2);
    590    dw[1] = y << 16 | x;
    591    dw[2] = ymax << 16 | xmax;
    592    /*
    593     * There is no need to set the origin.  It is intended to support front
    594     * buffer rendering.
    595     */
    596    dw[3] = 0;
    597 }
    598 
    599 static inline void
    600 gen6_3DSTATE_POLY_STIPPLE_OFFSET(struct ilo_builder *builder,
    601                                  const struct ilo_state_poly_stipple *stipple)
    602 {
    603    const uint8_t cmd_len = 2;
    604    uint32_t *dw;
    605 
    606    ILO_DEV_ASSERT(builder->dev, 6, 8);
    607 
    608    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    609 
    610    dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_POLY_STIPPLE_OFFSET) | (cmd_len - 2);
    611    /* constant */
    612    dw[1] = 0;
    613 }
    614 
    615 static inline void
    616 gen6_3DSTATE_POLY_STIPPLE_PATTERN(struct ilo_builder *builder,
    617                                   const struct ilo_state_poly_stipple *stipple)
    618 {
    619    const uint8_t cmd_len = 33;
    620    uint32_t *dw;
    621 
    622    ILO_DEV_ASSERT(builder->dev, 6, 8);
    623 
    624    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    625 
    626    dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_POLY_STIPPLE_PATTERN) | (cmd_len - 2);
    627    /* see poly_stipple_set_gen6_3DSTATE_POLY_STIPPLE_PATTERN() */
    628    memcpy(&dw[1], stipple->stipple, sizeof(stipple->stipple));
    629 }
    630 
    631 static inline void
    632 gen6_3DSTATE_LINE_STIPPLE(struct ilo_builder *builder,
    633                           const struct ilo_state_line_stipple *stipple)
    634 {
    635    const uint8_t cmd_len = 3;
    636    uint32_t *dw;
    637 
    638    ILO_DEV_ASSERT(builder->dev, 6, 8);
    639 
    640    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    641 
    642    dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_LINE_STIPPLE) | (cmd_len - 2);
    643    /* see line_stipple_set_gen6_3DSTATE_LINE_STIPPLE() */
    644    dw[1] = stipple->stipple[0];
    645    dw[2] = stipple->stipple[1];
    646 }
    647 
    648 static inline void
    649 gen6_3DSTATE_AA_LINE_PARAMETERS(struct ilo_builder *builder,
    650                                 const struct ilo_state_raster *rs)
    651 {
    652    const uint8_t cmd_len = 3;
    653    uint32_t *dw;
    654 
    655    ILO_DEV_ASSERT(builder->dev, 6, 8);
    656 
    657    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    658 
    659    dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_AA_LINE_PARAMETERS) | (cmd_len - 2);
    660    /* constant */
    661    dw[1] = 0 << GEN6_AA_LINE_DW1_BIAS__SHIFT |
    662            0 << GEN6_AA_LINE_DW1_SLOPE__SHIFT;
    663    dw[2] = 0 << GEN6_AA_LINE_DW2_CAP_BIAS__SHIFT |
    664            0 << GEN6_AA_LINE_DW2_CAP_SLOPE__SHIFT;
    665 }
    666 
    667 static inline void
    668 gen6_3DSTATE_DEPTH_BUFFER(struct ilo_builder *builder,
    669                           const struct ilo_state_zs *zs)
    670 {
    671    const uint32_t cmd = (ilo_dev_gen(builder->dev) >= ILO_GEN(7)) ?
    672       GEN7_RENDER_CMD(3D, 3DSTATE_DEPTH_BUFFER) :
    673       GEN6_RENDER_CMD(3D, 3DSTATE_DEPTH_BUFFER);
    674    const uint8_t cmd_len = (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) ? 8 : 7;
    675    uint32_t *dw;
    676    unsigned pos;
    677 
    678    ILO_DEV_ASSERT(builder->dev, 6, 8);
    679 
    680    pos = ilo_builder_batch_pointer(builder, cmd_len, &dw);
    681 
    682    dw[0] = cmd | (cmd_len - 2);
    683 
    684    /*
    685     * see zs_set_gen6_3DSTATE_DEPTH_BUFFER() and
    686     * zs_set_gen7_3DSTATE_DEPTH_BUFFER()
    687     */
    688    if (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) {
    689       dw[1] = zs->depth[0];
    690       dw[2] = 0;
    691       dw[3] = 0;
    692       dw[4] = zs->depth[2];
    693       dw[5] = zs->depth[3];
    694       dw[6] = 0;
    695       dw[7] = zs->depth[4];
    696 
    697       dw[5] |= builder->mocs << GEN8_DEPTH_DW5_MOCS__SHIFT;
    698 
    699       if (zs->z_vma) {
    700          ilo_builder_batch_reloc64(builder, pos + 2, zs->z_vma->bo,
    701                zs->z_vma->bo_offset + zs->depth[1],
    702                (zs->z_readonly) ? 0 : INTEL_RELOC_WRITE);
    703       }
    704    } else {
    705       dw[1] = zs->depth[0];
    706       dw[2] = 0;
    707       dw[3] = zs->depth[2];
    708       dw[4] = zs->depth[3];
    709       dw[5] = 0;
    710       dw[6] = zs->depth[4];
    711 
    712       if (ilo_dev_gen(builder->dev) >= ILO_GEN(7))
    713          dw[4] |= builder->mocs << GEN7_DEPTH_DW4_MOCS__SHIFT;
    714       else
    715          dw[6] |= builder->mocs << GEN6_DEPTH_DW6_MOCS__SHIFT;
    716 
    717       if (zs->z_vma) {
    718          ilo_builder_batch_reloc(builder, pos + 2, zs->z_vma->bo,
    719                zs->z_vma->bo_offset + zs->depth[1],
    720                (zs->z_readonly) ? 0 : INTEL_RELOC_WRITE);
    721       }
    722    }
    723 }
    724 
    725 static inline void
    726 gen6_3DSTATE_STENCIL_BUFFER(struct ilo_builder *builder,
    727                             const struct ilo_state_zs *zs)
    728 {
    729    const uint32_t cmd = (ilo_dev_gen(builder->dev) >= ILO_GEN(7)) ?
    730       GEN7_RENDER_CMD(3D, 3DSTATE_STENCIL_BUFFER) :
    731       GEN6_RENDER_CMD(3D, 3DSTATE_STENCIL_BUFFER);
    732    const uint8_t cmd_len = (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) ? 5 : 3;
    733    uint32_t *dw;
    734    unsigned pos;
    735 
    736    ILO_DEV_ASSERT(builder->dev, 6, 8);
    737 
    738    pos = ilo_builder_batch_pointer(builder, cmd_len, &dw);
    739 
    740    dw[0] = cmd | (cmd_len - 2);
    741 
    742    /* see zs_set_gen6_3DSTATE_STENCIL_BUFFER() */
    743    if (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) {
    744       dw[1] = zs->stencil[0];
    745       dw[2] = 0;
    746       dw[3] = 0;
    747       dw[4] = zs->stencil[2];
    748 
    749       dw[1] |= builder->mocs << GEN8_STENCIL_DW1_MOCS__SHIFT;
    750 
    751       if (zs->s_vma) {
    752          ilo_builder_batch_reloc64(builder, pos + 2, zs->s_vma->bo,
    753                zs->s_vma->bo_offset + zs->stencil[1],
    754                (zs->s_readonly) ? 0 : INTEL_RELOC_WRITE);
    755       }
    756    } else {
    757       dw[1] = zs->stencil[0];
    758       dw[2] = 0;
    759 
    760       dw[1] |= builder->mocs << GEN6_STENCIL_DW1_MOCS__SHIFT;
    761 
    762       if (zs->s_vma) {
    763          ilo_builder_batch_reloc(builder, pos + 2, zs->s_vma->bo,
    764                zs->s_vma->bo_offset + zs->stencil[1],
    765                (zs->s_readonly) ? 0 : INTEL_RELOC_WRITE);
    766       }
    767    }
    768 }
    769 
    770 static inline void
    771 gen6_3DSTATE_HIER_DEPTH_BUFFER(struct ilo_builder *builder,
    772                                const struct ilo_state_zs *zs)
    773 {
    774    const uint32_t cmd = (ilo_dev_gen(builder->dev) >= ILO_GEN(7)) ?
    775       GEN7_RENDER_CMD(3D, 3DSTATE_HIER_DEPTH_BUFFER) :
    776       GEN6_RENDER_CMD(3D, 3DSTATE_HIER_DEPTH_BUFFER);
    777    const uint8_t cmd_len = (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) ? 5 : 3;
    778    uint32_t *dw;
    779    unsigned pos;
    780 
    781    ILO_DEV_ASSERT(builder->dev, 6, 8);
    782 
    783    pos = ilo_builder_batch_pointer(builder, cmd_len, &dw);
    784 
    785    dw[0] = cmd | (cmd_len - 2);
    786 
    787    /* see zs_set_gen6_3DSTATE_HIER_DEPTH_BUFFER() */
    788    if (ilo_dev_gen(builder->dev) >= ILO_GEN(8)) {
    789       dw[1] = zs->hiz[0];
    790       dw[2] = 0;
    791       dw[3] = 0;
    792       dw[4] = zs->hiz[2];
    793 
    794       dw[1] |= builder->mocs << GEN8_HIZ_DW1_MOCS__SHIFT;
    795 
    796       if (zs->hiz_vma) {
    797          ilo_builder_batch_reloc64(builder, pos + 2, zs->hiz_vma->bo,
    798                zs->hiz_vma->bo_offset + zs->hiz[1],
    799                (zs->z_readonly) ? 0 : INTEL_RELOC_WRITE);
    800       }
    801    } else {
    802       dw[1] = zs->hiz[0];
    803       dw[2] = 0;
    804 
    805       dw[1] |= builder->mocs << GEN6_HIZ_DW1_MOCS__SHIFT;
    806 
    807       if (zs->hiz_vma) {
    808          ilo_builder_batch_reloc(builder, pos + 2, zs->hiz_vma->bo,
    809                zs->hiz_vma->bo_offset + zs->hiz[1],
    810                (zs->z_readonly) ? 0 : INTEL_RELOC_WRITE);
    811       }
    812    }
    813 }
    814 
    815 static inline void
    816 gen6_3DSTATE_CLEAR_PARAMS(struct ilo_builder *builder,
    817                           uint32_t clear_val)
    818 {
    819    const uint8_t cmd_len = 2;
    820    uint32_t *dw;
    821 
    822    ILO_DEV_ASSERT(builder->dev, 6, 6);
    823 
    824    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    825 
    826    dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_CLEAR_PARAMS) |
    827            GEN6_CLEAR_PARAMS_DW0_VALID |
    828            (cmd_len - 2);
    829    dw[1] = clear_val;
    830 }
    831 
    832 static inline void
    833 gen7_3DSTATE_CLEAR_PARAMS(struct ilo_builder *builder,
    834                           uint32_t clear_val)
    835 {
    836    const uint8_t cmd_len = 3;
    837    uint32_t *dw;
    838 
    839    ILO_DEV_ASSERT(builder->dev, 7, 8);
    840 
    841    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    842 
    843    dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_CLEAR_PARAMS) | (cmd_len - 2);
    844    dw[1] = clear_val;
    845    dw[2] = GEN7_CLEAR_PARAMS_DW2_VALID;
    846 }
    847 
    848 static inline void
    849 gen6_3DSTATE_VIEWPORT_STATE_POINTERS(struct ilo_builder *builder,
    850                                      uint32_t clip_viewport,
    851                                      uint32_t sf_viewport,
    852                                      uint32_t cc_viewport)
    853 {
    854    const uint8_t cmd_len = 4;
    855    uint32_t *dw;
    856 
    857    ILO_DEV_ASSERT(builder->dev, 6, 6);
    858 
    859    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    860 
    861    dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_VIEWPORT_STATE_POINTERS) |
    862            GEN6_VP_PTR_DW0_CLIP_CHANGED |
    863            GEN6_VP_PTR_DW0_SF_CHANGED |
    864            GEN6_VP_PTR_DW0_CC_CHANGED |
    865            (cmd_len - 2);
    866    dw[1] = clip_viewport;
    867    dw[2] = sf_viewport;
    868    dw[3] = cc_viewport;
    869 }
    870 
    871 static inline void
    872 gen6_3DSTATE_SCISSOR_STATE_POINTERS(struct ilo_builder *builder,
    873                                     uint32_t scissor_rect)
    874 {
    875    const uint8_t cmd_len = 2;
    876    uint32_t *dw;
    877 
    878    ILO_DEV_ASSERT(builder->dev, 6, 8);
    879 
    880    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    881 
    882    dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_SCISSOR_STATE_POINTERS) |
    883            (cmd_len - 2);
    884    dw[1] = scissor_rect;
    885 }
    886 
    887 static inline void
    888 gen6_3DSTATE_CC_STATE_POINTERS(struct ilo_builder *builder,
    889                                uint32_t blend_state,
    890                                uint32_t depth_stencil_state,
    891                                uint32_t color_calc_state)
    892 {
    893    const uint8_t cmd_len = 4;
    894    uint32_t *dw;
    895 
    896    ILO_DEV_ASSERT(builder->dev, 6, 6);
    897 
    898    ilo_builder_batch_pointer(builder, cmd_len, &dw);
    899 
    900    dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_CC_STATE_POINTERS) | (cmd_len - 2);
    901    dw[1] = blend_state | GEN6_CC_PTR_DW1_BLEND_CHANGED;
    902    dw[2] = depth_stencil_state | GEN6_CC_PTR_DW2_ZS_CHANGED;
    903    dw[3] = color_calc_state | GEN6_CC_PTR_DW3_CC_CHANGED;
    904 }
    905 
    906 static inline void
    907 gen7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP(struct ilo_builder *builder,
    908                                              uint32_t sf_clip_viewport)
    909 {
    910    ILO_DEV_ASSERT(builder->dev, 7, 8);
    911 
    912    gen7_3dstate_pointer(builder,
    913          GEN7_RENDER_OPCODE_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP,
    914          sf_clip_viewport);
    915 }
    916 
    917 static inline void
    918 gen7_3DSTATE_VIEWPORT_STATE_POINTERS_CC(struct ilo_builder *builder,
    919                                         uint32_t cc_viewport)
    920 {
    921    ILO_DEV_ASSERT(builder->dev, 7, 8);
    922 
    923    gen7_3dstate_pointer(builder,
    924          GEN7_RENDER_OPCODE_3DSTATE_VIEWPORT_STATE_POINTERS_CC,
    925          cc_viewport);
    926 }
    927 
    928 static inline void
    929 gen7_3DSTATE_CC_STATE_POINTERS(struct ilo_builder *builder,
    930                                uint32_t color_calc_state)
    931 {
    932    ILO_DEV_ASSERT(builder->dev, 7, 8);
    933 
    934    if (ilo_dev_gen(builder->dev) >= ILO_GEN(8))
    935       color_calc_state |= 1;
    936 
    937    gen7_3dstate_pointer(builder,
    938          GEN6_RENDER_OPCODE_3DSTATE_CC_STATE_POINTERS, color_calc_state);
    939 }
    940 
    941 static inline void
    942 gen7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS(struct ilo_builder *builder,
    943                                           uint32_t depth_stencil_state)
    944 {
    945    ILO_DEV_ASSERT(builder->dev, 7, 8);
    946 
    947    gen7_3dstate_pointer(builder,
    948          GEN7_RENDER_OPCODE_3DSTATE_DEPTH_STENCIL_STATE_POINTERS,
    949          depth_stencil_state);
    950 }
    951 
    952 static inline void
    953 gen7_3DSTATE_BLEND_STATE_POINTERS(struct ilo_builder *builder,
    954                                   uint32_t blend_state)
    955 {
    956    ILO_DEV_ASSERT(builder->dev, 7, 8);
    957 
    958    if (ilo_dev_gen(builder->dev) >= ILO_GEN(8))
    959       blend_state |= 1;
    960 
    961    gen7_3dstate_pointer(builder,
    962          GEN7_RENDER_OPCODE_3DSTATE_BLEND_STATE_POINTERS,
    963          blend_state);
    964 }
    965 
    966 static inline uint32_t
    967 gen6_CLIP_VIEWPORT(struct ilo_builder *builder,
    968                    const struct ilo_state_viewport *vp)
    969 {
    970    const int state_align = 32;
    971    const int state_len = 4 * vp->count;
    972    uint32_t state_offset, *dw;
    973    int i;
    974 
    975    ILO_DEV_ASSERT(builder->dev, 6, 6);
    976 
    977    state_offset = ilo_builder_dynamic_pointer(builder,
    978          ILO_BUILDER_ITEM_CLIP_VIEWPORT, state_align, state_len, &dw);
    979 
    980    for (i = 0; i < vp->count; i++) {
    981       /* see viewport_matrix_set_gen7_SF_CLIP_VIEWPORT() */
    982       dw[0] = vp->sf_clip[i][8];
    983       dw[1] = vp->sf_clip[i][9];
    984       dw[2] = vp->sf_clip[i][10];
    985       dw[3] = vp->sf_clip[i][11];
    986 
    987       dw += 4;
    988    }
    989 
    990    return state_offset;
    991 }
    992 
    993 static inline uint32_t
    994 gen6_SF_VIEWPORT(struct ilo_builder *builder,
    995                  const struct ilo_state_viewport *vp)
    996 {
    997    const int state_align = 32;
    998    const int state_len = 8 * vp->count;
    999    uint32_t state_offset, *dw;
   1000    int i;
   1001 
   1002    ILO_DEV_ASSERT(builder->dev, 6, 6);
   1003 
   1004    state_offset = ilo_builder_dynamic_pointer(builder,
   1005          ILO_BUILDER_ITEM_SF_VIEWPORT, state_align, state_len, &dw);
   1006 
   1007    for (i = 0; i < vp->count; i++) {
   1008       /* see viewport_matrix_set_gen7_SF_CLIP_VIEWPORT() */
   1009       memcpy(dw, vp->sf_clip[i], sizeof(*dw) * 8);
   1010 
   1011       dw += 8;
   1012    }
   1013 
   1014    return state_offset;
   1015 }
   1016 
   1017 static inline uint32_t
   1018 gen7_SF_CLIP_VIEWPORT(struct ilo_builder *builder,
   1019                       const struct ilo_state_viewport *vp)
   1020 {
   1021    const int state_align = 64;
   1022    const int state_len = 16 * vp->count;
   1023 
   1024    ILO_DEV_ASSERT(builder->dev, 7, 8);
   1025 
   1026    /* see viewport_matrix_set_gen7_SF_CLIP_VIEWPORT() */
   1027    return ilo_builder_dynamic_write(builder, ILO_BUILDER_ITEM_SF_VIEWPORT,
   1028          state_align, state_len, (const uint32_t *) vp->sf_clip);
   1029 }
   1030 
   1031 static inline uint32_t
   1032 gen6_CC_VIEWPORT(struct ilo_builder *builder,
   1033                  const struct ilo_state_viewport *vp)
   1034 {
   1035    const int state_align = 32;
   1036    const int state_len = 2 * vp->count;
   1037 
   1038    ILO_DEV_ASSERT(builder->dev, 6, 8);
   1039 
   1040    /* see viewport_matrix_set_gen6_CC_VIEWPORT() */
   1041    return ilo_builder_dynamic_write(builder, ILO_BUILDER_ITEM_CC_VIEWPORT,
   1042          state_align, state_len, (const uint32_t *) vp->cc);
   1043 }
   1044 
   1045 static inline uint32_t
   1046 gen6_SCISSOR_RECT(struct ilo_builder *builder,
   1047                   const struct ilo_state_viewport *vp)
   1048 {
   1049    const int state_align = 32;
   1050    const int state_len = 2 * vp->count;
   1051 
   1052    ILO_DEV_ASSERT(builder->dev, 6, 8);
   1053 
   1054    /* see viewport_scissor_set_gen6_SCISSOR_RECT() */
   1055    return ilo_builder_dynamic_write(builder, ILO_BUILDER_ITEM_SCISSOR_RECT,
   1056          state_align, state_len, (const uint32_t *) vp->scissor);
   1057 }
   1058 
   1059 static inline uint32_t
   1060 gen6_COLOR_CALC_STATE(struct ilo_builder *builder,
   1061                       const struct ilo_state_cc *cc)
   1062 {
   1063    const int state_align = 64;
   1064    const int state_len = 6;
   1065 
   1066    ILO_DEV_ASSERT(builder->dev, 6, 8);
   1067 
   1068    /* see cc_params_set_gen6_COLOR_CALC_STATE() */
   1069    return ilo_builder_dynamic_write(builder, ILO_BUILDER_ITEM_COLOR_CALC,
   1070          state_align, state_len, cc->cc);
   1071 }
   1072 
   1073 static inline uint32_t
   1074 gen6_DEPTH_STENCIL_STATE(struct ilo_builder *builder,
   1075                          const struct ilo_state_cc *cc)
   1076 {
   1077    const int state_align = 64;
   1078    const int state_len = 3;
   1079 
   1080    ILO_DEV_ASSERT(builder->dev, 6, 7.5);
   1081 
   1082    /* see cc_set_gen6_DEPTH_STENCIL_STATE() */
   1083    return ilo_builder_dynamic_write(builder, ILO_BUILDER_ITEM_DEPTH_STENCIL,
   1084          state_align, state_len, cc->ds);
   1085 }
   1086 
   1087 static inline uint32_t
   1088 gen6_BLEND_STATE(struct ilo_builder *builder,
   1089                  const struct ilo_state_cc *cc)
   1090 {
   1091    const int state_align = 64;
   1092    const int state_len = 2 * cc->blend_state_count;
   1093 
   1094    ILO_DEV_ASSERT(builder->dev, 6, 7.5);
   1095 
   1096    if (!state_len)
   1097       return 0;
   1098 
   1099    /* see cc_set_gen6_BLEND_STATE() */
   1100    return ilo_builder_dynamic_write(builder, ILO_BUILDER_ITEM_BLEND,
   1101          state_align, state_len, cc->blend);
   1102 }
   1103 
   1104 static inline uint32_t
   1105 gen8_BLEND_STATE(struct ilo_builder *builder,
   1106                  const struct ilo_state_cc *cc)
   1107 {
   1108    const int state_align = 64;
   1109    const int state_len = 1 + 2 * cc->blend_state_count;
   1110 
   1111    ILO_DEV_ASSERT(builder->dev, 8, 8);
   1112 
   1113    /* see cc_set_gen8_BLEND_STATE() */
   1114    return ilo_builder_dynamic_write(builder, ILO_BUILDER_ITEM_BLEND,
   1115          state_align, state_len, &cc->blend[1]);
   1116 }
   1117 
   1118 #endif /* ILO_BUILDER_3D_BOTTOM_H */
   1119