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_SHADER_H
     29 #define ILO_STATE_SHADER_H
     30 
     31 #include "genhw/genhw.h"
     32 
     33 #include "ilo_core.h"
     34 #include "ilo_dev.h"
     35 
     36 /**
     37  * Kernel information.
     38  */
     39 struct ilo_state_shader_kernel_info {
     40    /* usually 0 unless the shader has multiple kernels */
     41    uint32_t offset;
     42 
     43    uint8_t grf_start;
     44    uint8_t pcb_attr_count;
     45 };
     46 
     47 /**
     48  * Shader resources.
     49  */
     50 struct ilo_state_shader_resource_info {
     51    /* for prefetches */
     52    uint8_t sampler_count;
     53    uint8_t surface_count;
     54 
     55    bool has_uav;
     56 };
     57 
     58 /**
     59  * URB inputs/outputs.
     60  */
     61 struct ilo_state_shader_urb_info {
     62    uint8_t cv_input_attr_count;
     63 
     64    uint8_t read_base;
     65    uint8_t read_count;
     66 
     67    uint8_t output_attr_count;
     68 
     69    uint8_t user_cull_enables;
     70    uint8_t user_clip_enables;
     71 };
     72 
     73 struct ilo_state_vs_info {
     74    struct ilo_state_shader_kernel_info kernel;
     75    struct ilo_state_shader_resource_info resource;
     76    struct ilo_state_shader_urb_info urb;
     77 
     78    uint32_t per_thread_scratch_size;
     79    bool dispatch_enable;
     80    bool stats_enable;
     81 };
     82 
     83 struct ilo_state_hs_info {
     84    struct ilo_state_shader_kernel_info kernel;
     85    struct ilo_state_shader_resource_info resource;
     86    struct ilo_state_shader_urb_info urb;
     87 
     88    uint32_t per_thread_scratch_size;
     89    bool dispatch_enable;
     90    bool stats_enable;
     91 };
     92 
     93 struct ilo_state_ds_info {
     94    struct ilo_state_shader_kernel_info kernel;
     95    struct ilo_state_shader_resource_info resource;
     96    struct ilo_state_shader_urb_info urb;
     97 
     98    uint32_t per_thread_scratch_size;
     99    bool dispatch_enable;
    100    bool stats_enable;
    101 };
    102 
    103 /**
    104  * Stream output.  Must be consistent with ilo_state_sol_info.
    105  */
    106 struct ilo_state_gs_sol_info {
    107    bool sol_enable;
    108    bool stats_enable;
    109    bool render_disable;
    110 
    111    uint16_t svbi_post_inc;
    112 
    113    enum gen_reorder_mode tristrip_reorder;
    114 };
    115 
    116 struct ilo_state_gs_info {
    117    struct ilo_state_shader_kernel_info kernel;
    118    struct ilo_state_shader_resource_info resource;
    119    struct ilo_state_shader_urb_info urb;
    120 
    121    struct ilo_state_gs_sol_info sol;
    122 
    123    uint32_t per_thread_scratch_size;
    124    bool dispatch_enable;
    125    bool stats_enable;
    126 };
    127 
    128 struct ilo_state_ps_io_info {
    129    /* inputs */
    130    enum gen_position_offset posoffset;
    131    uint8_t attr_count;
    132    bool use_z;
    133    bool use_w;
    134    bool use_coverage_mask;
    135 
    136    /* outputs */
    137    enum gen_pscdepth_mode pscdepth;
    138    bool has_rt_write;
    139    bool write_pixel_mask;
    140    bool write_omask;
    141 };
    142 
    143 struct ilo_state_ps_params_info {
    144    /* compatibility with raster states */
    145    uint32_t sample_mask;
    146    bool earlyz_control_psexec;
    147 
    148    /* compatibility with cc states */
    149    bool alpha_may_kill;
    150    bool dual_source_blending;
    151    bool has_writeable_rt;
    152 };
    153 
    154 struct ilo_state_ps_info {
    155    struct ilo_state_shader_kernel_info kernel_8;
    156    struct ilo_state_shader_kernel_info kernel_16;
    157    struct ilo_state_shader_kernel_info kernel_32;
    158    struct ilo_state_shader_resource_info resource;
    159 
    160    struct ilo_state_ps_io_info io;
    161    struct ilo_state_ps_params_info params;
    162 
    163    uint32_t per_thread_scratch_size;
    164 
    165    /* bitmask of GEN6_PS_DISPATCH_x */
    166    uint8_t valid_kernels;
    167    bool per_sample_dispatch;
    168    bool sample_count_one;
    169    bool cv_per_sample_interp;
    170    bool cv_has_earlyz_op;
    171 
    172    bool rt_clear_enable;
    173    bool rt_resolve_enable;
    174 
    175    bool cv_has_depth_buffer;
    176 };
    177 
    178 struct ilo_state_vs {
    179    uint32_t vs[5];
    180    uint32_t scratch_size;
    181 };
    182 
    183 struct ilo_state_hs {
    184    uint32_t hs[4];
    185    uint32_t scratch_size;
    186 };
    187 
    188 struct ilo_state_ds {
    189    uint32_t te[3];
    190    uint32_t ds[5];
    191    uint32_t scratch_size;
    192 };
    193 
    194 struct ilo_state_gs {
    195    uint32_t gs[5];
    196    uint32_t scratch_size;
    197 };
    198 
    199 struct ilo_state_ps {
    200    uint32_t ps[8];
    201    uint32_t scratch_size;
    202 
    203    struct ilo_state_ps_dispatch_conds {
    204       bool ps_valid;
    205 
    206       bool has_rt_write;
    207       bool write_odepth;
    208       bool write_ostencil;
    209       bool has_uav_write;
    210       bool ps_may_kill;
    211    } conds;
    212 };
    213 
    214 bool
    215 ilo_state_vs_init(struct ilo_state_vs *vs,
    216                   const struct ilo_dev *dev,
    217                   const struct ilo_state_vs_info *info);
    218 
    219 bool
    220 ilo_state_vs_init_disabled(struct ilo_state_vs *vs,
    221                            const struct ilo_dev *dev);
    222 
    223 static inline uint32_t
    224 ilo_state_vs_get_scratch_size(const struct ilo_state_vs *vs)
    225 {
    226    return vs->scratch_size;
    227 }
    228 
    229 bool
    230 ilo_state_hs_init(struct ilo_state_hs *hs,
    231                   const struct ilo_dev *dev,
    232                   const struct ilo_state_hs_info *info);
    233 
    234 bool
    235 ilo_state_hs_init_disabled(struct ilo_state_hs *hs,
    236                            const struct ilo_dev *dev);
    237 
    238 
    239 static inline uint32_t
    240 ilo_state_hs_get_scratch_size(const struct ilo_state_hs *hs)
    241 {
    242    return hs->scratch_size;
    243 }
    244 
    245 bool
    246 ilo_state_ds_init(struct ilo_state_ds *ds,
    247                   const struct ilo_dev *dev,
    248                   const struct ilo_state_ds_info *info);
    249 
    250 bool
    251 ilo_state_ds_init_disabled(struct ilo_state_ds *ds,
    252                            const struct ilo_dev *dev);
    253 
    254 static inline uint32_t
    255 ilo_state_ds_get_scratch_size(const struct ilo_state_ds *ds)
    256 {
    257    return ds->scratch_size;
    258 }
    259 
    260 bool
    261 ilo_state_gs_init(struct ilo_state_gs *gs,
    262                   const struct ilo_dev *dev,
    263                   const struct ilo_state_gs_info *info);
    264 
    265 bool
    266 ilo_state_gs_init_disabled(struct ilo_state_gs *gs,
    267                            const struct ilo_dev *dev);
    268 
    269 static inline uint32_t
    270 ilo_state_gs_get_scratch_size(const struct ilo_state_gs *gs)
    271 {
    272    return gs->scratch_size;
    273 }
    274 
    275 bool
    276 ilo_state_ps_init(struct ilo_state_ps *ps,
    277                   const struct ilo_dev *dev,
    278                   const struct ilo_state_ps_info *info);
    279 
    280 bool
    281 ilo_state_ps_init_disabled(struct ilo_state_ps *ps,
    282                            const struct ilo_dev *dev);
    283 
    284 bool
    285 ilo_state_ps_set_params(struct ilo_state_ps *ps,
    286                         const struct ilo_dev *dev,
    287                         const struct ilo_state_ps_params_info *params);
    288 
    289 static inline uint32_t
    290 ilo_state_ps_get_scratch_size(const struct ilo_state_ps *ps)
    291 {
    292    return ps->scratch_size;
    293 }
    294 
    295 #endif /* ILO_STATE_SHADER_H */
    296