Go to the source code of this file.
Functions | |
static void | compile_gs_prog (struct brw_context *brw, struct brw_gs_prog_key *key) |
static boolean | search_cache (struct brw_context *brw, struct brw_gs_prog_key *key) |
static void | populate_key (struct brw_context *brw, struct brw_gs_prog_key *key) |
static void | upload_gs_prog (struct brw_context *brw) |
Variables | |
static const int | gs_prim [PIPE_PRIM_POLYGON+1] |
struct brw_tracked_state | brw_gs_prog |
static void compile_gs_prog | ( | struct brw_context * | brw, | |
struct brw_gs_prog_key * | key | |||
) | [static] |
Definition at line 41 of file brw_gs.c.
References brw_gs_prog_key::attrs, brw_count_bits(), brw_get_program(), brw_gs_lines(), brw_gs_points(), BRW_GS_PROG, brw_gs_quad_strip(), brw_gs_quads(), brw_gs_tris(), brw_init_compile(), BRW_MASK_DISABLE, brw_set_mask_control(), brw_upload_cache(), brw_context::cache, brw_gs_compile::func, brw_context::gs, brw_gs_prog_key::hint_gs_always, brw_gs_compile::key, brw_gs_compile::nr_attrs, brw_gs_compile::nr_bytes, brw_gs_compile::nr_regs, PIPE_PRIM_LINE_LOOP, PIPE_PRIM_LINES, PIPE_PRIM_POINTS, PIPE_PRIM_QUAD_STRIP, PIPE_PRIM_QUADS, PIPE_PRIM_TRIANGLES, brw_gs_prog_key::primitive, brw_context::prog_data, brw_gs_compile::prog_data, brw_context::prog_gs_offset, REG_SIZE, and brw_compile::single_program_flow.
00043 { 00044 struct brw_gs_compile c; 00045 const unsigned *program; 00046 unsigned program_size; 00047 00048 memset(&c, 0, sizeof(c)); 00049 00050 c.key = *key; 00051 00052 /* Need to locate the two positions present in vertex + header. 00053 * These are currently hardcoded: 00054 */ 00055 c.nr_attrs = brw_count_bits(c.key.attrs); 00056 c.nr_regs = (c.nr_attrs + 1) / 2 + 1; /* are vertices packed, or reg-aligned? */ 00057 c.nr_bytes = c.nr_regs * REG_SIZE; 00058 00059 00060 /* Begin the compilation: 00061 */ 00062 brw_init_compile(&c.func); 00063 00064 c.func.single_program_flow = 1; 00065 00066 /* For some reason the thread is spawned with only 4 channels 00067 * unmasked. 00068 */ 00069 brw_set_mask_control(&c.func, BRW_MASK_DISABLE); 00070 00071 00072 /* Note that primitives which don't require a GS program have 00073 * already been weeded out by this stage: 00074 */ 00075 switch (key->primitive) { 00076 case PIPE_PRIM_QUADS: 00077 brw_gs_quads( &c ); 00078 break; 00079 case PIPE_PRIM_QUAD_STRIP: 00080 brw_gs_quad_strip( &c ); 00081 break; 00082 case PIPE_PRIM_LINE_LOOP: 00083 brw_gs_lines( &c ); 00084 break; 00085 case PIPE_PRIM_LINES: 00086 if (key->hint_gs_always) 00087 brw_gs_lines( &c ); 00088 else { 00089 return; 00090 } 00091 break; 00092 case PIPE_PRIM_TRIANGLES: 00093 if (key->hint_gs_always) 00094 brw_gs_tris( &c ); 00095 else { 00096 return; 00097 } 00098 break; 00099 case PIPE_PRIM_POINTS: 00100 if (key->hint_gs_always) 00101 brw_gs_points( &c ); 00102 else { 00103 return; 00104 } 00105 break; 00106 default: 00107 return; 00108 } 00109 00110 /* get the program 00111 */ 00112 program = brw_get_program(&c.func, &program_size); 00113 00114 /* Upload 00115 */ 00116 brw->gs.prog_gs_offset = brw_upload_cache( &brw->cache[BRW_GS_PROG], 00117 &c.key, 00118 sizeof(c.key), 00119 program, 00120 program_size, 00121 &c.prog_data, 00122 &brw->gs.prog_data ); 00123 }
static void populate_key | ( | struct brw_context * | brw, | |
struct brw_gs_prog_key * | key | |||
) | [static] |
Definition at line 149 of file brw_gs.c.
References brw_gs_prog_key::attrs, gs_prim, brw_gs_prog_key::hint_gs_always, brw_gs_prog_key::need_gs_prog, brw_vs_prog_data::outputs_written, PIPE_PRIM_LINE_LOOP, PIPE_PRIM_QUAD_STRIP, PIPE_PRIM_QUADS, brw_context::primitive, brw_gs_prog_key::primitive, brw_context::prog_data, and brw_context::vs.
00151 { 00152 memset(key, 0, sizeof(*key)); 00153 00154 /* CACHE_NEW_VS_PROG */ 00155 key->attrs = brw->vs.prog_data->outputs_written; 00156 00157 /* BRW_NEW_PRIMITIVE */ 00158 key->primitive = gs_prim[brw->primitive]; 00159 00160 key->hint_gs_always = 0; /* debug code? */ 00161 00162 key->need_gs_prog = (key->hint_gs_always || 00163 brw->primitive == PIPE_PRIM_QUADS || 00164 brw->primitive == PIPE_PRIM_QUAD_STRIP || 00165 brw->primitive == PIPE_PRIM_LINE_LOOP); 00166 }
static boolean search_cache | ( | struct brw_context * | brw, | |
struct brw_gs_prog_key * | key | |||
) | [static] |
Definition at line 126 of file brw_gs.c.
References BRW_GS_PROG, brw_search_cache(), brw_context::cache, brw_context::gs, brw_context::prog_data, and brw_context::prog_gs_offset.
00128 { 00129 return brw_search_cache(&brw->cache[BRW_GS_PROG], 00130 key, sizeof(*key), 00131 &brw->gs.prog_data, 00132 &brw->gs.prog_gs_offset); 00133 }
static void upload_gs_prog | ( | struct brw_context * | brw | ) | [static] |
Definition at line 170 of file brw_gs.c.
References brw_state_flags::cache, CACHE_NEW_GS_PROG, compile_gs_prog(), brw_context::dirty, brw_context::gs, brw_gs_prog_key::need_gs_prog, populate_key(), brw_context::prog_active, search_cache(), and brw_context::state.
00171 { 00172 struct brw_gs_prog_key key; 00173 00174 /* Populate the key: 00175 */ 00176 populate_key(brw, &key); 00177 00178 if (brw->gs.prog_active != key.need_gs_prog) { 00179 brw->state.dirty.cache |= CACHE_NEW_GS_PROG; 00180 brw->gs.prog_active = key.need_gs_prog; 00181 } 00182 00183 if (brw->gs.prog_active) { 00184 if (!search_cache(brw, &key)) 00185 compile_gs_prog( brw, &key ); 00186 } 00187 }
struct brw_tracked_state brw_gs_prog |
Initial value:
{ .dirty = { .brw = 0x100000 , .cache = (1<<BRW_VS_PROG) }, .update = upload_gs_prog }
const int gs_prim[PIPE_PRIM_POLYGON+1] [static] |
Initial value:
{ PIPE_PRIM_POINTS, PIPE_PRIM_LINES, PIPE_PRIM_LINE_LOOP, PIPE_PRIM_LINES, PIPE_PRIM_TRIANGLES, PIPE_PRIM_TRIANGLES, PIPE_PRIM_TRIANGLES, PIPE_PRIM_QUADS, PIPE_PRIM_QUAD_STRIP, PIPE_PRIM_TRIANGLES }