- struct intel_context *intel = &brw->intel;
- struct brw_sf_compile c;
- const GLuint *program;
- GLuint program_size;
- GLuint i, idx;
-
- memset(&c, 0, sizeof(c));
-
- /* Begin the compilation:
- */
- brw_init_compile(brw, &c.func);
-
- c.key = *key;
- c.nr_attrs = brw_count_bits(c.key.attrs);
- c.nr_attr_regs = (c.nr_attrs+1)/2;
- c.nr_setup_attrs = brw_count_bits(c.key.attrs);
- c.nr_setup_regs = (c.nr_setup_attrs+1)/2;
-
- c.prog_data.urb_read_length = c.nr_attr_regs;
- c.prog_data.urb_entry_size = c.nr_setup_regs * 2;
-
- /* Construct map from attribute number to position in the vertex.
- */
- for (i = idx = 0; i < VERT_RESULT_MAX; i++) {
- if (c.key.attrs & BITFIELD64_BIT(i)) {
- c.attr_to_idx[i] = idx;
- c.idx_to_attr[idx] = i;
- idx++;
- }
- }
-
- /* Which primitive? Or all three?
- */
- switch (key->primitive) {
- case SF_TRIANGLES:
- c.nr_verts = 3;
- brw_emit_tri_setup( &c, GL_TRUE );
- break;
- case SF_LINES:
- c.nr_verts = 2;
- brw_emit_line_setup( &c, GL_TRUE );
- break;
- case SF_POINTS:
- c.nr_verts = 1;
- if (key->do_point_sprite)
- brw_emit_point_sprite_setup( &c, GL_TRUE );
- else
- brw_emit_point_setup( &c, GL_TRUE );
- break;
- case SF_UNFILLED_TRIS:
- c.nr_verts = 3;
- brw_emit_anyprim_setup( &c );
- break;
- default:
- assert(0);
- return;
- }
-
- /* get the program
- */
- program = brw_get_program(&c.func, &program_size);
-
- if (unlikely(INTEL_DEBUG & DEBUG_SF)) {
- printf("sf:\n");
- for (i = 0; i < program_size / sizeof(struct brw_instruction); i++)
- brw_disasm(stdout, &((struct brw_instruction *)program)[i],
- intel->gen);
- printf("\n");
- }
-
- /* Upload
- */
- drm_intel_bo_unreference(brw->sf.prog_bo);
- brw->sf.prog_bo = brw_upload_cache_with_auxdata(&brw->cache, BRW_SF_PROG,
- &c.key, sizeof(c.key),
- NULL, 0,
- program, program_size,
- &c.prog_data,
- sizeof(c.prog_data),
- &brw->sf.prog_data);
+ const unsigned *program;
+ void *mem_ctx;
+ unsigned program_size;
+
+ mem_ctx = ralloc_context(NULL);
+
+ struct brw_sf_prog_data prog_data;
+ program = brw_compile_sf(brw->screen->compiler, mem_ctx, key, &prog_data,
+ &brw->vue_map_geom_out, &program_size);
+
+ brw_upload_cache(&brw->cache, BRW_CACHE_SF_PROG,
+ key, sizeof(*key),
+ program, program_size,
+ &prog_data, sizeof(prog_data),
+ &brw->sf.prog_offset, &brw->sf.prog_data);
+ ralloc_free(mem_ctx);