Home | History | Annotate | Download | only in ilo
      1 /*
      2  * Mesa 3-D graphics library
      3  *
      4  * Copyright (C) 2012-2013 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_SHADER_H
     29 #define ILO_SHADER_H
     30 
     31 #include "core/ilo_state_shader.h"
     32 
     33 #include "ilo_common.h"
     34 
     35 enum ilo_kernel_param {
     36    ILO_KERNEL_INPUT_COUNT,
     37    ILO_KERNEL_OUTPUT_COUNT,
     38    ILO_KERNEL_SAMPLER_COUNT,
     39    ILO_KERNEL_SKIP_CBUF0_UPLOAD,
     40    ILO_KERNEL_PCB_CBUF0_SIZE,
     41 
     42    ILO_KERNEL_SURFACE_TOTAL_COUNT,
     43    ILO_KERNEL_SURFACE_TEX_BASE,
     44    ILO_KERNEL_SURFACE_TEX_COUNT,
     45    ILO_KERNEL_SURFACE_CONST_BASE,
     46    ILO_KERNEL_SURFACE_CONST_COUNT,
     47    ILO_KERNEL_SURFACE_RES_BASE,
     48    ILO_KERNEL_SURFACE_RES_COUNT,
     49 
     50    ILO_KERNEL_VS_INPUT_INSTANCEID,
     51    ILO_KERNEL_VS_INPUT_VERTEXID,
     52    ILO_KERNEL_VS_INPUT_EDGEFLAG,
     53    ILO_KERNEL_VS_PCB_UCP_SIZE,
     54    ILO_KERNEL_VS_GEN6_SO,
     55    ILO_KERNEL_VS_GEN6_SO_POINT_OFFSET,
     56    ILO_KERNEL_VS_GEN6_SO_LINE_OFFSET,
     57    ILO_KERNEL_VS_GEN6_SO_TRI_OFFSET,
     58    ILO_KERNEL_VS_GEN6_SO_SURFACE_COUNT,
     59 
     60    ILO_KERNEL_GS_DISCARD_ADJACENCY,
     61    ILO_KERNEL_GS_GEN6_SVBI_POST_INC,
     62    ILO_KERNEL_GS_GEN6_SURFACE_SO_BASE,
     63    ILO_KERNEL_GS_GEN6_SURFACE_SO_COUNT,
     64 
     65    ILO_KERNEL_FS_BARYCENTRIC_INTERPOLATIONS,
     66    ILO_KERNEL_FS_DISPATCH_16_OFFSET,
     67    ILO_KERNEL_FS_SURFACE_RT_BASE,
     68    ILO_KERNEL_FS_SURFACE_RT_COUNT,
     69 
     70    ILO_KERNEL_CS_LOCAL_SIZE,
     71    ILO_KERNEL_CS_PRIVATE_SIZE,
     72    ILO_KERNEL_CS_INPUT_SIZE,
     73    ILO_KERNEL_CS_SIMD_SIZE,
     74    ILO_KERNEL_CS_SURFACE_GLOBAL_BASE,
     75    ILO_KERNEL_CS_SURFACE_GLOBAL_COUNT,
     76 
     77    ILO_KERNEL_PARAM_COUNT,
     78 };
     79 
     80 struct intel_bo;
     81 struct ilo_builder;
     82 struct ilo_rasterizer_state;
     83 struct ilo_shader_cache;
     84 struct ilo_shader_state;
     85 struct ilo_state_sbe;
     86 struct ilo_state_sol;
     87 struct ilo_state_vector;
     88 
     89 union ilo_shader_cso {
     90    struct ilo_state_vs vs;
     91    struct ilo_state_hs hs;
     92    struct ilo_state_ds ds;
     93    struct ilo_state_gs gs;
     94    struct ilo_state_ps ps;
     95 
     96    struct {
     97       struct ilo_state_vs vs;
     98       struct ilo_state_gs sol;
     99    } vs_sol;
    100 };
    101 
    102 struct ilo_shader_cache *
    103 ilo_shader_cache_create(void);
    104 
    105 void
    106 ilo_shader_cache_destroy(struct ilo_shader_cache *shc);
    107 
    108 void
    109 ilo_shader_cache_add(struct ilo_shader_cache *shc,
    110                      struct ilo_shader_state *shader);
    111 
    112 void
    113 ilo_shader_cache_remove(struct ilo_shader_cache *shc,
    114                         struct ilo_shader_state *shader);
    115 
    116 void
    117 ilo_shader_cache_upload(struct ilo_shader_cache *shc,
    118                         struct ilo_builder *builder);
    119 
    120 void
    121 ilo_shader_cache_invalidate(struct ilo_shader_cache *shc);
    122 
    123 void
    124 ilo_shader_cache_get_max_scratch_sizes(const struct ilo_shader_cache *shc,
    125                                        int *vs_scratch_size,
    126                                        int *gs_scratch_size,
    127                                        int *fs_scratch_size);
    128 
    129 struct ilo_shader_state *
    130 ilo_shader_create_vs(const struct ilo_dev *dev,
    131                      const struct pipe_shader_state *state,
    132                      const struct ilo_state_vector *precompile);
    133 
    134 struct ilo_shader_state *
    135 ilo_shader_create_gs(const struct ilo_dev *dev,
    136                      const struct pipe_shader_state *state,
    137                      const struct ilo_state_vector *precompile);
    138 
    139 struct ilo_shader_state *
    140 ilo_shader_create_fs(const struct ilo_dev *dev,
    141                      const struct pipe_shader_state *state,
    142                      const struct ilo_state_vector *precompile);
    143 
    144 struct ilo_shader_state *
    145 ilo_shader_create_cs(const struct ilo_dev *dev,
    146                      const struct pipe_compute_state *state,
    147                      const struct ilo_state_vector *precompile);
    148 
    149 void
    150 ilo_shader_destroy(struct ilo_shader_state *shader);
    151 
    152 bool
    153 ilo_shader_select_kernel(struct ilo_shader_state *shader,
    154                          const struct ilo_state_vector *vec,
    155                          uint32_t dirty);
    156 
    157 bool
    158 ilo_shader_select_kernel_sbe(struct ilo_shader_state *shader,
    159                              const struct ilo_shader_state *source,
    160                              const struct ilo_rasterizer_state *rasterizer);
    161 
    162 uint32_t
    163 ilo_shader_get_kernel_offset(const struct ilo_shader_state *shader);
    164 
    165 int
    166 ilo_shader_get_kernel_param(const struct ilo_shader_state *shader,
    167                             enum ilo_kernel_param param);
    168 
    169 const union ilo_shader_cso *
    170 ilo_shader_get_kernel_cso(const struct ilo_shader_state *shader);
    171 
    172 const struct pipe_stream_output_info *
    173 ilo_shader_get_kernel_so_info(const struct ilo_shader_state *shader);
    174 
    175 const struct ilo_state_sol *
    176 ilo_shader_get_kernel_sol(const struct ilo_shader_state *shader);
    177 
    178 const struct ilo_state_sbe *
    179 ilo_shader_get_kernel_sbe(const struct ilo_shader_state *shader);
    180 
    181 #endif /* ILO_SHADER_H */
    182