#include "brw_state.h"
#include "brw_gs.h"
-
+#include "glsl/ralloc.h"
static void compile_gs_prog( struct brw_context *brw,
struct brw_gs_prog_key *key )
struct intel_context *intel = &brw->intel;
struct brw_gs_compile c;
const GLuint *program;
+ void *mem_ctx;
GLuint program_size;
+ /* Gen6: VF has already converted into polygon, and LINELOOP is
+ * converted to LINESTRIP at the beginning of the 3D pipeline.
+ */
+ if (intel->gen >= 6)
+ return;
+
memset(&c, 0, sizeof(c));
c.key = *key;
c.nr_bytes = c.nr_regs * REG_SIZE;
+ mem_ctx = NULL;
/* Begin the compilation:
*/
- brw_init_compile(brw, &c.func);
+ brw_init_compile(brw, &c.func, mem_ctx);
c.func.single_program_flow = 1;
* already been weeded out by this stage:
*/
- /* Gen6: VF has already converted into polygon, and LINELOOP is
- * converted to LINESTRIP at the beginning of the 3D pipeline.
- */
- if (intel->gen == 6)
- return;
-
switch (key->primitive) {
case GL_QUADS:
brw_gs_quads( &c, key );
brw_gs_lines( &c );
break;
default:
+ ralloc_free(mem_ctx);
return;
}
printf("\n");
}
- /* Upload
- */
- drm_intel_bo_unreference(brw->gs.prog_bo);
- brw->gs.prog_bo = brw_upload_cache(&brw->cache, BRW_GS_PROG,
- &c.key, sizeof(c.key),
- program, program_size,
- &c.prog_data, sizeof(c.prog_data),
- &brw->gs.prog_data);
+ brw_upload_cache(&brw->cache, BRW_GS_PROG,
+ &c.key, sizeof(c.key),
+ program, program_size,
+ &c.prog_data, sizeof(c.prog_data),
+ &brw->gs.prog_offset, &brw->gs.prog_data);
+ ralloc_free(mem_ctx);
}
static const GLenum gs_prim[GL_POLYGON+1] = {
key->pv_first = GL_TRUE;
}
- key->need_gs_prog = (intel->gen == 6)
+ key->need_gs_prog = (intel->gen >= 6)
? 0
: (brw->primitive == GL_QUADS ||
brw->primitive == GL_QUAD_STRIP ||
brw->gs.prog_active = key.need_gs_prog;
}
- drm_intel_bo_unreference(brw->gs.prog_bo);
- brw->gs.prog_bo = NULL;
-
if (brw->gs.prog_active) {
- brw->gs.prog_bo = brw_search_cache(&brw->cache, BRW_GS_PROG,
- &key, sizeof(key),
- &brw->gs.prog_data);
- if (brw->gs.prog_bo == NULL)
+ if (!brw_search_cache(&brw->cache, BRW_GS_PROG,
+ &key, sizeof(key),
+ &brw->gs.prog_offset, &brw->gs.prog_data)) {
compile_gs_prog( brw, &key );
+ }
}
}