1 /* 2 Copyright (C) Intel Corp. 2006. All Rights Reserved. 3 Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to 4 develop this 3D driver. 5 6 Permission is hereby granted, free of charge, to any person obtaining 7 a copy of this software and associated documentation files (the 8 "Software"), to deal in the Software without restriction, including 9 without limitation the rights to use, copy, modify, merge, publish, 10 distribute, sublicense, and/or sell copies of the Software, and to 11 permit persons to whom the Software is furnished to do so, subject to 12 the following conditions: 13 14 The above copyright notice and this permission notice (including the 15 next paragraph) shall be included in all copies or substantial 16 portions of the Software. 17 18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE 22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 26 **********************************************************************/ 27 /* 28 * Authors: 29 * Keith Whitwell <keith (at) tungstengraphics.com> 30 */ 31 32 33 #ifndef BRW_VS_H 34 #define BRW_VS_H 35 36 37 #include "brw_context.h" 38 #include "brw_eu.h" 39 #include "brw_program.h" 40 #include "program/program.h" 41 42 43 struct brw_vs_prog_key { 44 GLuint program_string_id; 45 /** 46 * Number of channels of the vertex attribute that need GL_FIXED rescaling 47 */ 48 uint8_t gl_fixed_input_size[VERT_ATTRIB_MAX]; 49 50 /** 51 * True if at least one clip flag is enabled, regardless of whether the 52 * shader uses clip planes or gl_ClipDistance. 53 */ 54 GLuint userclip_active:1; 55 56 /** 57 * How many user clipping planes are being uploaded to the vertex shader as 58 * push constants. 59 */ 60 GLuint nr_userclip_plane_consts:4; 61 62 /** 63 * True if the shader uses gl_ClipDistance, regardless of whether any clip 64 * flags are enabled. 65 */ 66 GLuint uses_clip_distance:1; 67 68 /** 69 * For pre-Gen6 hardware, a bitfield indicating which clipping planes are 70 * enabled. This is used to compact clip planes. 71 * 72 * For Gen6 and later hardware, clip planes are not compacted, so this 73 * value is zero to avoid provoking unnecessary shader recompiles. 74 */ 75 GLuint userclip_planes_enabled_gen_4_5:MAX_CLIP_PLANES; 76 77 GLuint copy_edgeflag:1; 78 GLuint point_coord_replace:8; 79 GLuint clamp_vertex_color:1; 80 81 struct brw_sampler_prog_key_data tex; 82 }; 83 84 85 struct brw_vs_compile { 86 struct brw_compile func; 87 struct brw_vs_prog_key key; 88 struct brw_vs_prog_data prog_data; 89 int8_t constant_map[1024]; 90 91 struct brw_vertex_program *vp; 92 93 GLuint nr_inputs; 94 95 GLuint first_output; 96 GLuint last_scratch; /**< measured in 32-byte (register size) units */ 97 98 GLuint first_tmp; 99 GLuint last_tmp; 100 101 struct brw_reg r0; 102 struct brw_reg r1; 103 struct brw_reg regs[PROGRAM_ADDRESS+1][128]; 104 struct brw_reg tmp; 105 106 struct { 107 bool used_in_src; 108 struct brw_reg reg; 109 } output_regs[128]; 110 111 struct brw_reg userplane[MAX_CLIP_PLANES]; 112 113 /** we may need up to 3 constants per instruction (if use_const_buffer) */ 114 struct { 115 GLint index; 116 struct brw_reg reg; 117 } current_const[3]; 118 }; 119 120 bool brw_vs_emit(struct gl_shader_program *prog, struct brw_vs_compile *c); 121 void brw_old_vs_emit(struct brw_vs_compile *c); 122 bool brw_vs_precompile(struct gl_context *ctx, struct gl_shader_program *prog); 123 void brw_vs_debug_recompile(struct brw_context *brw, 124 struct gl_shader_program *prog, 125 const struct brw_vs_prog_key *key); 126 127 #endif 128