aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/i965/brw_wm.c
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2011-05-16 11:49:57 -0700
committerKenneth Graunke <[email protected]>2011-05-17 23:32:58 -0700
commit774fb90db3e83d5e7326b7a72e05ce805c306b24 (patch)
tree6d729d4fc538835cbe4fef4134c8721cd4befe9c /src/mesa/drivers/dri/i965/brw_wm.c
parentebeea9857339da5f0f0455c45a8350190bbad189 (diff)
i965: Get a ralloc context into brw_compile.
This would be so much easier if we were using C++; we could simply use constructors and destructors. Instead, we have to update all the callers. While we're at it, ralloc various brw_wm_compile fields rather than explicitly calloc/free'ing them. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_wm.c')
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index 06512de940f..40589b0d2e4 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -35,6 +35,8 @@
#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 )
{
@@ -193,7 +195,7 @@ static void do_wm_prog( struct brw_context *brw,
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
@@ -202,11 +204,10 @@ static void do_wm_prog( struct brw_context *brw,
*/
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;
@@ -223,7 +224,7 @@ static void do_wm_prog( struct brw_context *brw,
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. */