- struct intel_context *intel = &brw->intel;
- struct brw_clip_compile c;
- const GLuint *program;
- GLuint program_size;
- GLuint delta;
- GLuint i;
-
- memset(&c, 0, sizeof(c));
-
- /* Begin the compilation:
- */
- brw_init_compile(brw, &c.func);
-
- c.func.single_program_flow = 1;
-
- c.key = *key;
-
- /* Need to locate the two positions present in vertex + header.
- * These are currently hardcoded:
- */
- c.header_position_offset = ATTR_SIZE;
-
- if (intel->gen == 5)
- delta = 3 * REG_SIZE;
- else
- delta = REG_SIZE;
-
- for (i = 0; i < VERT_RESULT_MAX; i++)
- if (c.key.attrs & BITFIELD64_BIT(i)) {
- c.offset[i] = delta;
- delta += ATTR_SIZE;
- }
-
- c.nr_attrs = brw_count_bits(c.key.attrs);
-
- if (intel->gen == 5)
- c.nr_regs = (c.nr_attrs + 1) / 2 + 3; /* are vertices packed, or reg-aligned? */
- else
- c.nr_regs = (c.nr_attrs + 1) / 2 + 1; /* are vertices packed, or reg-aligned? */
-
- c.nr_bytes = c.nr_regs * REG_SIZE;
-
- c.prog_data.clip_mode = c.key.clip_mode; /* XXX */
-
- /* For some reason the thread is spawned with only 4 channels
- * unmasked.
- */
- brw_set_mask_control(&c.func, BRW_MASK_DISABLE);
-
-
- /* Would ideally have the option of producing a program which could
- * do all three:
- */
- switch (key->primitive) {
- case GL_TRIANGLES:
- if (key->do_unfilled)
- brw_emit_unfilled_clip( &c );
- else
- brw_emit_tri_clip( &c );
- break;
- case GL_LINES:
- brw_emit_line_clip( &c );
- break;
- case GL_POINTS:
- brw_emit_point_clip( &c );
- break;
- default:
- assert(0);
- return;
- }
-
-
-
- /* get the program
- */
- program = brw_get_program(&c.func, &program_size);
-
- /* Upload
- */
- dri_bo_unreference(brw->clip.prog_bo);
- brw->clip.prog_bo = brw_upload_cache_with_auxdata(&brw->cache,
- BRW_CLIP_PROG,
- &c.key, sizeof(c.key),
- NULL, 0,
- program, program_size,
- &c.prog_data,
- sizeof(c.prog_data),
- &brw->clip.prog_data);
+ const unsigned *program;
+ void *mem_ctx;
+ unsigned program_size;
+
+ mem_ctx = ralloc_context(NULL);
+
+ struct brw_clip_prog_data prog_data;
+ program = brw_compile_clip(brw->screen->compiler, mem_ctx, key, &prog_data,
+ &brw->vue_map_geom_out, &program_size);
+
+ brw_upload_cache(&brw->cache,
+ BRW_CACHE_CLIP_PROG,
+ key, sizeof(*key),
+ program, program_size,
+ &prog_data, sizeof(prog_data),
+ &brw->clip.prog_offset, &brw->clip.prog_data);
+ ralloc_free(mem_ctx);