Home | History | Annotate | Download | only in core
      1 /*
      2  * Mesa 3-D graphics library
      3  *
      4  * Copyright (C) 2015 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_STATE_RASTER_H
     29 #define ILO_STATE_RASTER_H
     30 
     31 #include "genhw/genhw.h"
     32 
     33 #include "ilo_core.h"
     34 #include "ilo_dev.h"
     35 
     36 enum ilo_state_raster_dirty_bits {
     37    ILO_STATE_RASTER_3DSTATE_CLIP                   = (1 << 0),
     38    ILO_STATE_RASTER_3DSTATE_SF                     = (1 << 1),
     39    ILO_STATE_RASTER_3DSTATE_RASTER                 = (1 << 2),
     40    ILO_STATE_RASTER_3DSTATE_MULTISAMPLE            = (1 << 3),
     41    ILO_STATE_RASTER_3DSTATE_SAMPLE_MASK            = (1 << 4),
     42    ILO_STATE_RASTER_3DSTATE_WM                     = (1 << 5),
     43    ILO_STATE_RASTER_3DSTATE_WM_HZ_OP               = (1 << 6),
     44    ILO_STATE_RASTER_3DSTATE_AA_LINE_PARAMETERS     = (1 << 7),
     45 };
     46 
     47 enum ilo_state_raster_earlyz_op {
     48    ILO_STATE_RASTER_EARLYZ_NORMAL,
     49    ILO_STATE_RASTER_EARLYZ_DEPTH_CLEAR,
     50    ILO_STATE_RASTER_EARLYZ_DEPTH_RESOLVE,
     51    ILO_STATE_RASTER_EARLYZ_HIZ_RESOLVE,
     52 };
     53 
     54 /**
     55  * VUE readback, VertexClipTest, ClipDetermination, and primitive output.
     56  */
     57 struct ilo_state_raster_clip_info {
     58    bool clip_enable;
     59    /* CL_INVOCATION_COUNT and CL_PRIMITIVES_COUNT */
     60    bool stats_enable;
     61 
     62    uint8_t viewport_count;
     63    bool force_rtaindex_zero;
     64 
     65    /* these should be mutually exclusive */
     66    uint8_t user_cull_enables;
     67    uint8_t user_clip_enables;
     68 
     69    bool gb_test_enable;
     70    bool xy_test_enable;
     71 
     72    /* far/near must be enabled together prior to Gen9 */
     73    bool z_far_enable;
     74    bool z_near_enable;
     75    bool z_near_zero;
     76 };
     77 
     78 /**
     79  * Primitive assembly, viewport transformation, scissoring, MSAA, etc.
     80  */
     81 struct ilo_state_raster_setup_info {
     82    bool cv_is_rectangle;
     83 
     84    bool first_vertex_provoking;
     85    bool viewport_transform;
     86 
     87    bool scissor_enable;
     88 
     89    /* MSAA enables for lines and non-lines */
     90    bool msaa_enable;
     91    bool line_msaa_enable;
     92 };
     93 
     94 /**
     95  * 3DOBJ_POINT rasterization rules.
     96  */
     97 struct ilo_state_raster_point_info {
     98    /* ignored when msaa_enable is set */
     99    bool aa_enable;
    100 
    101    bool programmable_width;
    102 };
    103 
    104 /**
    105  * 3DOBJ_LINE rasterization rules.
    106  */
    107 struct ilo_state_raster_line_info {
    108    /* ignored when line_msaa_enable is set */
    109    bool aa_enable;
    110 
    111    /* ignored when line_msaa_enable or aa_enable is set */
    112    bool stipple_enable;
    113    bool giq_enable;
    114    bool giq_last_pixel;
    115 };
    116 
    117 /**
    118  * 3DOBJ_TRIANGLE rasterization rules.
    119  */
    120 struct ilo_state_raster_tri_info {
    121    enum gen_front_winding front_winding;
    122    enum gen_cull_mode cull_mode;
    123    enum gen_fill_mode fill_mode_front;
    124    enum gen_fill_mode fill_mode_back;
    125 
    126    enum gen_depth_format depth_offset_format;
    127    bool depth_offset_solid;
    128    bool depth_offset_wireframe;
    129    bool depth_offset_point;
    130 
    131    bool poly_stipple_enable;
    132 };
    133 
    134 /**
    135  * Scan conversion.
    136  */
    137 struct ilo_state_raster_scan_info {
    138    /* PS_DEPTH_COUNT and PS_INVOCATION_COUNT */
    139    bool stats_enable;
    140 
    141    uint8_t sample_count;
    142 
    143    /* pixel location for non-MSAA or 1x-MSAA */
    144    enum gen_pixel_location pixloc;
    145 
    146    uint32_t sample_mask;
    147 
    148    /* interpolations */
    149    enum gen_zw_interp zw_interp;
    150    uint8_t barycentric_interps;
    151 
    152    /* Gen7+ only */
    153    enum gen_edsc_mode earlyz_control;
    154    enum ilo_state_raster_earlyz_op earlyz_op;
    155    bool earlyz_stencil_clear;
    156 };
    157 
    158 /**
    159  * Raster parameters.
    160  */
    161 struct ilo_state_raster_params_info {
    162    bool any_integer_rt;
    163    bool hiz_enable;
    164 
    165    float point_width;
    166    float line_width;
    167 
    168    /* const term will be scaled by 'r' */
    169    float depth_offset_const;
    170    float depth_offset_scale;
    171    float depth_offset_clamp;
    172 };
    173 
    174 struct ilo_state_raster_info {
    175    struct ilo_state_raster_clip_info clip;
    176    struct ilo_state_raster_setup_info setup;
    177    struct ilo_state_raster_point_info point;
    178    struct ilo_state_raster_line_info line;
    179    struct ilo_state_raster_tri_info tri;
    180    struct ilo_state_raster_scan_info scan;
    181 
    182    struct ilo_state_raster_params_info params;
    183 };
    184 
    185 struct ilo_state_raster {
    186    uint32_t clip[3];
    187    uint32_t sf[3];
    188    uint32_t raster[4];
    189    uint32_t sample[2];
    190    uint32_t wm[3];
    191 
    192    bool line_aa_enable;
    193    bool line_giq_enable;
    194 };
    195 
    196 struct ilo_state_raster_delta {
    197    uint32_t dirty;
    198 };
    199 
    200 struct ilo_state_sample_pattern_offset_info {
    201    /* in U0.4 */
    202    uint8_t x;
    203    uint8_t y;
    204 };
    205 
    206 struct ilo_state_sample_pattern_info {
    207    struct ilo_state_sample_pattern_offset_info pattern_1x[1];
    208    struct ilo_state_sample_pattern_offset_info pattern_2x[2];
    209    struct ilo_state_sample_pattern_offset_info pattern_4x[4];
    210    struct ilo_state_sample_pattern_offset_info pattern_8x[8];
    211    struct ilo_state_sample_pattern_offset_info pattern_16x[16];
    212 };
    213 
    214 struct ilo_state_sample_pattern {
    215    uint8_t pattern_1x[1];
    216    uint8_t pattern_2x[2];
    217    uint8_t pattern_4x[4];
    218    uint8_t pattern_8x[8];
    219    uint8_t pattern_16x[16];
    220 };
    221 
    222 struct ilo_state_line_stipple_info {
    223    uint16_t pattern;
    224    uint16_t repeat_count;
    225 };
    226 
    227 struct ilo_state_line_stipple {
    228    uint32_t stipple[2];
    229 };
    230 
    231 struct ilo_state_poly_stipple_info {
    232    uint32_t pattern[32];
    233 };
    234 
    235 struct ilo_state_poly_stipple {
    236    uint32_t stipple[32];
    237 };
    238 
    239 bool
    240 ilo_state_raster_init(struct ilo_state_raster *rs,
    241                       const struct ilo_dev *dev,
    242                       const struct ilo_state_raster_info *info);
    243 
    244 bool
    245 ilo_state_raster_init_for_rectlist(struct ilo_state_raster *rs,
    246                                    const struct ilo_dev *dev,
    247                                    uint8_t sample_count,
    248                                    enum ilo_state_raster_earlyz_op earlyz_op,
    249                                    bool earlyz_stencil_clear);
    250 
    251 bool
    252 ilo_state_raster_set_info(struct ilo_state_raster *rs,
    253                           const struct ilo_dev *dev,
    254                           const struct ilo_state_raster_info *info);
    255 
    256 bool
    257 ilo_state_raster_set_params(struct ilo_state_raster *rs,
    258                             const struct ilo_dev *dev,
    259                             const struct ilo_state_raster_params_info *params);
    260 
    261 void
    262 ilo_state_raster_full_delta(const struct ilo_state_raster *rs,
    263                             const struct ilo_dev *dev,
    264                             struct ilo_state_raster_delta *delta);
    265 
    266 void
    267 ilo_state_raster_get_delta(const struct ilo_state_raster *rs,
    268                            const struct ilo_dev *dev,
    269                            const struct ilo_state_raster *old,
    270                            struct ilo_state_raster_delta *delta);
    271 
    272 bool
    273 ilo_state_sample_pattern_init(struct ilo_state_sample_pattern *pattern,
    274                               const struct ilo_dev *dev,
    275                               const struct ilo_state_sample_pattern_info *info);
    276 
    277 bool
    278 ilo_state_sample_pattern_init_default(struct ilo_state_sample_pattern *pattern,
    279                                       const struct ilo_dev *dev);
    280 
    281 const uint8_t *
    282 ilo_state_sample_pattern_get_packed_offsets(const struct ilo_state_sample_pattern *pattern,
    283                                             const struct ilo_dev *dev,
    284                                             uint8_t sample_count);
    285 
    286 void
    287 ilo_state_sample_pattern_get_offset(const struct ilo_state_sample_pattern *pattern,
    288                                     const struct ilo_dev *dev,
    289                                     uint8_t sample_count, uint8_t sample_index,
    290                                     uint8_t *x, uint8_t *y);
    291 bool
    292 ilo_state_line_stipple_set_info(struct ilo_state_line_stipple *stipple,
    293                                 const struct ilo_dev *dev,
    294                                 const struct ilo_state_line_stipple_info *info);
    295 
    296 bool
    297 ilo_state_poly_stipple_set_info(struct ilo_state_poly_stipple *stipple,
    298                                 const struct ilo_dev *dev,
    299                                 const struct ilo_state_poly_stipple_info *info);
    300 
    301 #endif /* ILO_STATE_RASTER_H */
    302