Go to the source code of this file.
Defines | |
#define | FRONT_UNFILLED_BIT 0x1 |
#define | BACK_UNFILLED_BIT 0x2 |
Functions | |
static void | compile_clip_prog (struct brw_context *brw, struct brw_clip_prog_key *key) |
static boolean | search_cache (struct brw_context *brw, struct brw_clip_prog_key *key) |
static void | upload_clip_prog (struct brw_context *brw) |
Variables | |
struct brw_tracked_state | brw_clip_prog |
#define BACK_UNFILLED_BIT 0x2 |
Definition at line 40 of file brw_clip.c.
#define FRONT_UNFILLED_BIT 0x1 |
Definition at line 39 of file brw_clip.c.
static void compile_clip_prog | ( | struct brw_context * | brw, | |
struct brw_clip_prog_key * | key | |||
) | [static] |
Definition at line 43 of file brw_clip.c.
References assert, ATTR_SIZE, brw_clip_prog_key::attrs, BRW_CLIP_PROG, brw_count_bits(), brw_emit_line_clip(), brw_emit_point_clip(), brw_emit_tri_clip(), brw_emit_unfilled_clip(), brw_get_program(), brw_init_compile(), BRW_MASK_DISABLE, brw_set_mask_control(), brw_upload_cache(), brw_context::cache, brw_context::clip, brw_clip_prog_key::clip_mode, brw_clip_prog_data::clip_mode, brw_clip_prog_key::do_unfilled, brw_clip_compile::func, brw_clip_compile::header_position_offset, brw_clip_compile::key, brw_clip_compile::nr_attrs, brw_clip_compile::nr_bytes, brw_clip_compile::nr_regs, brw_clip_compile::offset, PIPE_MAX_SHADER_OUTPUTS, PIPE_PRIM_LINES, PIPE_PRIM_POINTS, PIPE_PRIM_TRIANGLES, brw_clip_prog_key::primitive, brw_context::prog_data, brw_clip_compile::prog_data, brw_context::prog_gs_offset, REG_SIZE, and brw_compile::single_program_flow.
00045 { 00046 struct brw_clip_compile c; 00047 const unsigned *program; 00048 unsigned program_size; 00049 unsigned delta; 00050 unsigned i; 00051 00052 memset(&c, 0, sizeof(c)); 00053 00054 /* Begin the compilation: 00055 */ 00056 brw_init_compile(&c.func); 00057 00058 c.func.single_program_flow = 1; 00059 00060 c.key = *key; 00061 00062 00063 /* Need to locate the two positions present in vertex + header. 00064 * These are currently hardcoded: 00065 */ 00066 c.header_position_offset = ATTR_SIZE; 00067 00068 for (i = 0, delta = REG_SIZE; i < PIPE_MAX_SHADER_OUTPUTS; i++) 00069 if (c.key.attrs & (1<<i)) { 00070 c.offset[i] = delta; 00071 delta += ATTR_SIZE; 00072 } 00073 00074 c.nr_attrs = brw_count_bits(c.key.attrs); 00075 c.nr_regs = (c.nr_attrs + 1) / 2 + 1; /* are vertices packed, or reg-aligned? */ 00076 c.nr_bytes = c.nr_regs * REG_SIZE; 00077 00078 c.prog_data.clip_mode = c.key.clip_mode; /* XXX */ 00079 00080 /* For some reason the thread is spawned with only 4 channels 00081 * unmasked. 00082 */ 00083 brw_set_mask_control(&c.func, BRW_MASK_DISABLE); 00084 00085 00086 /* Would ideally have the option of producing a program which could 00087 * do all three: 00088 */ 00089 switch (key->primitive) { 00090 case PIPE_PRIM_TRIANGLES: 00091 #if 0 00092 if (key->do_unfilled) 00093 brw_emit_unfilled_clip( &c ); 00094 else 00095 #endif 00096 brw_emit_tri_clip( &c ); 00097 break; 00098 case PIPE_PRIM_LINES: 00099 brw_emit_line_clip( &c ); 00100 break; 00101 case PIPE_PRIM_POINTS: 00102 brw_emit_point_clip( &c ); 00103 break; 00104 default: 00105 assert(0); 00106 return; 00107 } 00108 00109 00110 00111 /* get the program 00112 */ 00113 program = brw_get_program(&c.func, &program_size); 00114 00115 /* Upload 00116 */ 00117 brw->clip.prog_gs_offset = brw_upload_cache( &brw->cache[BRW_CLIP_PROG], 00118 &c.key, 00119 sizeof(c.key), 00120 program, 00121 program_size, 00122 &c.prog_data, 00123 &brw->clip.prog_data ); 00124 }
static boolean search_cache | ( | struct brw_context * | brw, | |
struct brw_clip_prog_key * | key | |||
) | [static] |
Definition at line 127 of file brw_clip.c.
References BRW_CLIP_PROG, brw_search_cache(), brw_context::cache, brw_context::clip, brw_context::prog_data, and brw_context::prog_gs_offset.
00129 { 00130 return brw_search_cache(&brw->cache[BRW_CLIP_PROG], 00131 key, sizeof(*key), 00132 &brw->clip.prog_data, 00133 &brw->clip.prog_gs_offset); 00134 }
static void upload_clip_prog | ( | struct brw_context * | brw | ) | [static] |
Definition at line 141 of file brw_clip.c.
References brw_context::attribs, brw_clip_prog_key::attrs, BRW_CLIPMODE_ACCEPT_ALL, BRW_CLIPMODE_CLIP_NON_REJECTED, BRW_CLIPMODE_NORMAL, BRW_CLIPMODE_REJECT_ALL, brw_context::Clip, CLIP_CULL, brw_clip_prog_key::clip_mode, compile_clip_prog(), brw_clip_prog_key::copy_bfc_cw, pipe_rasterizer_state::cull_mode, brw_clip_prog_key::do_flat_shading, brw_clip_prog_key::do_unfilled, brw_clip_prog_key::fill_ccw, pipe_rasterizer_state::fill_ccw, brw_clip_prog_key::fill_cw, pipe_rasterizer_state::fill_cw, pipe_rasterizer_state::flatshade, pipe_rasterizer_state::light_twoside, pipe_clip_state::nr, brw_clip_prog_key::nr_userclip, brw_clip_prog_key::offset_ccw, pipe_rasterizer_state::offset_ccw, brw_clip_prog_key::offset_cw, pipe_rasterizer_state::offset_cw, brw_clip_prog_key::offset_factor, pipe_rasterizer_state::offset_scale, pipe_rasterizer_state::offset_units, brw_clip_prog_key::offset_units, brw_vs_prog_data::outputs_written, PIPE_POLYGON_MODE_FILL, PIPE_PRIM_TRIANGLES, PIPE_WINDING_BOTH, brw_clip_prog_key::primitive, brw_context::prog_data, brw_context::Raster, brw_context::reduced_primitive, search_cache(), and brw_context::vs.
00142 { 00143 struct brw_clip_prog_key key; 00144 00145 memset(&key, 0, sizeof(key)); 00146 00147 /* Populate the key: 00148 */ 00149 /* BRW_NEW_REDUCED_PRIMITIVE */ 00150 key.primitive = brw->reduced_primitive; 00151 /* CACHE_NEW_VS_PROG */ 00152 key.attrs = brw->vs.prog_data->outputs_written; 00153 /* BRW_NEW_RASTER */ 00154 key.do_flat_shading = (brw->attribs.Raster->flatshade); 00155 /* BRW_NEW_CLIP */ 00156 key.nr_userclip = brw->attribs.Clip.nr; /* XXX */ 00157 00158 #if 0 00159 key.clip_mode = BRW_CLIPMODE_NORMAL; 00160 00161 if (key.primitive == PIPE_PRIM_TRIANGLES) { 00162 if (brw->attribs.Raster->cull_mode == PIPE_WINDING_BOTH) 00163 key.clip_mode = BRW_CLIPMODE_REJECT_ALL; 00164 else { 00165 if (brw->attribs.Raster->fill_cw != PIPE_POLYGON_MODE_FILL || 00166 brw->attribs.Raster->fill_ccw != PIPE_POLYGON_MODE_FILL) 00167 key.do_unfilled = 1; 00168 00169 /* Most cases the fixed function units will handle. Cases where 00170 * one or more polygon faces are unfilled will require help: 00171 */ 00172 if (key.do_unfilled) { 00173 key.clip_mode = BRW_CLIPMODE_CLIP_NON_REJECTED; 00174 00175 if (brw->attribs.Raster->offset_cw || 00176 brw->attribs.Raster->offset_ccw) { 00177 key.offset_units = brw->attribs.Raster->offset_units; 00178 key.offset_factor = brw->attribs.Raster->offset_scale; 00179 } 00180 key.fill_ccw = brw->attribs.Raster->fill_ccw; 00181 key.fill_cw = brw->attribs.Raster->fill_cw; 00182 key.offset_ccw = brw->attribs.Raster->offset_ccw; 00183 key.offset_cw = brw->attribs.Raster->offset_cw; 00184 if (brw->attribs.Raster->light_twoside && 00185 key.fill_cw != CLIP_CULL) 00186 key.copy_bfc_cw = 1; 00187 } 00188 } 00189 } 00190 #else 00191 key.clip_mode = BRW_CLIPMODE_ACCEPT_ALL; 00192 #endif 00193 00194 if (!search_cache(brw, &key)) 00195 compile_clip_prog( brw, &key ); 00196 }
struct brw_tracked_state brw_clip_prog |
Initial value:
{ .dirty = { .brw = ( 0x2 | 0x10 | 0x80000 ), .cache = (1<<BRW_VS_PROG) }, .update = upload_clip_prog }
Definition at line 198 of file brw_clip.c.