#include "brw_state.h"
#include "brw_clip.h"
+#include "../glsl/ralloc.h"
+
#define FRONT_UNFILLED_BIT 0x1
#define BACK_UNFILLED_BIT 0x2
struct intel_context *intel = &brw->intel;
struct brw_clip_compile c;
const GLuint *program;
+ void *mem_ctx;
GLuint program_size;
GLuint delta;
GLuint i;
GLuint header_regs;
memset(&c, 0, sizeof(c));
+
+ mem_ctx = ralloc_context(NULL);
/* Begin the compilation:
*/
- brw_init_compile(brw, &c.func);
+ brw_init_compile(brw, &c.func, mem_ctx);
c.func.single_program_flow = 1;
program, program_size,
&c.prog_data, sizeof(c.prog_data),
&brw->clip.prog_data);
+ ralloc_free(mem_ctx);
}
/* Calculate interpolants for triangle and line rasterization.
/***********************************************************************
*/
-void brw_init_compile( struct brw_context *brw, struct brw_compile *p )
+void
+brw_init_compile(struct brw_context *brw, struct brw_compile *p, void *mem_ctx)
{
p->brw = brw;
p->nr_insn = 0;
p->compressed = false;
memset(p->current, 0, sizeof(p->current[0]));
+ p->mem_ctx = mem_ctx;
+
/* Some defaults?
*/
brw_set_mask_control(p, BRW_MASK_ENABLE); /* what does this do? */
struct brw_instruction store[BRW_EU_MAX_INSN];
GLuint nr_insn;
+ void *mem_ctx;
+
/* Allow clients to push/pop instruction state:
*/
struct brw_instruction stack[BRW_EU_MAX_INSN_STACK];
void brw_set_conditionalmod( struct brw_compile *p, GLuint conditional );
void brw_set_acc_write_control(struct brw_compile *p, GLuint value);
-void brw_init_compile( struct brw_context *, struct brw_compile *p );
+void brw_init_compile(struct brw_context *, struct brw_compile *p,
+ void *mem_ctx);
const GLuint *brw_get_program( struct brw_compile *p, GLuint *sz );
#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
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;
brw_gs_lines( &c );
break;
default:
+ ralloc_free(mem_ctx);
return;
}
program, program_size,
&c.prog_data, sizeof(c.prog_data),
&brw->gs.prog_data);
+ ralloc_free(mem_ctx);
}
static const GLenum gs_prim[GL_POLYGON+1] = {
#include "brw_sf.h"
#include "brw_state.h"
+#include "../glsl/ralloc.h"
+
static void compile_sf_prog( struct brw_context *brw,
struct brw_sf_prog_key *key )
{
struct intel_context *intel = &brw->intel;
struct brw_sf_compile c;
const GLuint *program;
+ void *mem_ctx;
GLuint program_size;
GLuint i, idx;
memset(&c, 0, sizeof(c));
+ mem_ctx = ralloc_context(NULL);
/* Begin the compilation:
*/
- brw_init_compile(brw, &c.func);
+ brw_init_compile(brw, &c.func, mem_ctx);
c.key = *key;
c.nr_attrs = brw_count_bits(c.key.attrs);
program, program_size,
&c.prog_data, sizeof(c.prog_data),
&brw->sf.prog_data);
+ ralloc_free(mem_ctx);
}
/* Calculate interpolants for triangle and line rasterization.
#include "program/prog_print.h"
#include "program/prog_parameter.h"
-
+#include "../glsl/ralloc.h"
static void do_vs_prog( struct brw_context *brw,
struct brw_vertex_program *vp,
GLuint program_size;
const GLuint *program;
struct brw_vs_compile c;
+ void *mem_ctx;
int aux_size;
int i;
memset(&c, 0, sizeof(c));
memcpy(&c.key, key, sizeof(*key));
- brw_init_compile(brw, &c.func);
+ mem_ctx = ralloc_context(NULL);
+
+ brw_init_compile(brw, &c.func, mem_ctx);
c.vp = vp;
c.prog_data.outputs_written = vp->program.Base.OutputsWritten;
program, program_size,
&c.prog_data, aux_size,
&brw->vs.prog_data);
+ ralloc_free(mem_ctx);
}
#include "brw_vs.h"
#include "brw_wm.h"
+#include "../glsl/ralloc.h"
+
static void
dri_bo_release(drm_intel_bo **bo)
{
brw_destroy_state(brw);
brw_draw_destroy( brw );
brw_clear_validated_bos(brw);
- if (brw->wm.compile_data) {
- free(brw->wm.compile_data->instruction);
- free(brw->wm.compile_data->vreg);
- free(brw->wm.compile_data->refs);
- free(brw->wm.compile_data->prog_instructions);
- free(brw->wm.compile_data);
- }
+ ralloc_free(brw->wm.compile_data);
intel_region_release(&brw->state.depth_region);
#include "main/formats.h"
#include "main/samplerobj.h"
+#include "../glsl/ralloc.h"
+
/** Return number of src args for given instruction */
GLuint brw_wm_nr_args( GLuint opcode )
{
c = brw->wm.compile_data;
if (c == NULL) {
- brw->wm.compile_data = calloc(1, sizeof(*brw->wm.compile_data));
+ brw->wm.compile_data = rzalloc(NULL, struct brw_wm_compile);
c = brw->wm.compile_data;
if (c == NULL) {
/* Ouch - big out of memory problem. Can't continue
*/
return;
}
- c->instruction = calloc(1, BRW_WM_MAX_INSN * sizeof(*c->instruction));
- c->prog_instructions = calloc(1, BRW_WM_MAX_INSN *
- sizeof(*c->prog_instructions));
- c->vreg = calloc(1, BRW_WM_MAX_VREG * sizeof(*c->vreg));
- c->refs = calloc(1, BRW_WM_MAX_REF * sizeof(*c->refs));
+ c->instruction = rzalloc_array(c, struct brw_wm_instruction, BRW_WM_MAX_INSN);
+ c->prog_instructions = rzalloc_array(c, struct prog_instruction, BRW_WM_MAX_INSN);
+ c->vreg = rzalloc_array(c, struct brw_wm_value, BRW_WM_MAX_VREG);
+ c->refs = rzalloc_array(c, struct brw_wm_ref, BRW_WM_MAX_REF);
} else {
void *instruction = c->instruction;
void *prog_instructions = c->prog_instructions;
c->fp = fp;
c->env_param = brw->intel.ctx.FragmentProgram.Parameters;
- brw_init_compile(brw, &c->func);
+ brw_init_compile(brw, &c->func, c);
if (!brw_wm_fs_emit(brw, c)) {
/* Fallback for fixed function and ARB_fp shaders. */