1 /************************************************************************** 2 * 3 * Copyright (C) 2014 Red Hat Inc. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included 13 * in all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21 * OTHER DEALINGS IN THE SOFTWARE. 22 * 23 **************************************************************************/ 24 25 #ifndef VREND_SHADER_H 26 #define VREND_SHADER_H 27 28 #include "pipe/p_state.h" 29 #include "pipe/p_shader_tokens.h" 30 31 /* need to store patching info for interpolation */ 32 struct vrend_interp_info { 33 int semantic_name; 34 int semantic_index; 35 int interpolate; 36 unsigned location; 37 }; 38 39 struct vrend_array { 40 int first; 41 int array_size; 42 }; 43 44 struct vrend_shader_info { 45 uint32_t samplers_used_mask; 46 uint32_t images_used_mask; 47 uint32_t ssbo_used_mask; 48 int num_consts; 49 int num_inputs; 50 int num_interps; 51 int num_outputs; 52 int num_ubos; 53 int ubo_idx[32]; 54 bool ubo_indirect; 55 uint8_t num_indirect_generic_outputs; 56 uint8_t num_indirect_patch_outputs; 57 uint8_t num_indirect_generic_inputs; 58 uint8_t num_indirect_patch_inputs; 59 int num_ucp; 60 int glsl_ver; 61 bool has_pervertex_out; 62 bool has_sample_input; 63 uint8_t num_clip_out; 64 uint8_t num_cull_out; 65 uint32_t shadow_samp_mask; 66 int gs_out_prim; 67 int tes_prim; 68 bool tes_point_mode; 69 uint32_t attrib_input_mask; 70 71 struct vrend_array *sampler_arrays; 72 int num_sampler_arrays; 73 74 struct vrend_array *image_arrays; 75 int num_image_arrays; 76 77 struct pipe_stream_output_info so_info; 78 79 struct vrend_interp_info *interpinfo; 80 char **so_names; 81 }; 82 83 struct vrend_shader_key { 84 uint32_t coord_replace; 85 bool invert_fs_origin; 86 bool pstipple_tex; 87 bool add_alpha_test; 88 bool color_two_side; 89 uint8_t alpha_test; 90 uint8_t clip_plane_enable; 91 bool gs_present; 92 bool tcs_present; 93 bool tes_present; 94 bool flatshade; 95 bool prev_stage_pervertex_out; 96 uint8_t prev_stage_num_clip_out; 97 uint8_t prev_stage_num_cull_out; 98 float alpha_ref_val; 99 uint32_t cbufs_are_a8_bitmask; 100 uint8_t num_indirect_generic_outputs; 101 uint8_t num_indirect_patch_outputs; 102 uint8_t num_indirect_generic_inputs; 103 uint8_t num_indirect_patch_inputs; 104 }; 105 106 struct vrend_shader_cfg { 107 int glsl_version; 108 int max_draw_buffers; 109 bool use_gles; 110 bool use_core_profile; 111 bool use_explicit_locations; 112 }; 113 114 bool vrend_patch_vertex_shader_interpolants(struct vrend_shader_cfg *cfg, 115 char *program, 116 struct vrend_shader_info *vs_info, 117 struct vrend_shader_info *fs_info, 118 const char *oprefix, bool flatshade); 119 120 char *vrend_convert_shader(struct vrend_shader_cfg *cfg, 121 const struct tgsi_token *tokens, 122 uint32_t req_local_mem, 123 struct vrend_shader_key *key, 124 struct vrend_shader_info *sinfo); 125 const char *vrend_shader_samplertypeconv(int sampler_type, int *is_shad); 126 char vrend_shader_samplerreturnconv(enum tgsi_return_type type); 127 128 int shader_lookup_sampler_array(struct vrend_shader_info *sinfo, int index); 129 #endif 130