diff options
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/i915/i915_context.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/i915/i915_fpc_translate.c | 19 | ||||
-rw-r--r-- | src/gallium/drivers/i915/i915_state.c | 6 | ||||
-rw-r--r-- | src/gallium/drivers/i915/i915_state_emit.c | 12 |
4 files changed, 31 insertions, 9 deletions
diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h index e39c7cc137f..b019c9f342a 100644 --- a/src/gallium/drivers/i915/i915_context.h +++ b/src/gallium/drivers/i915/i915_context.h @@ -104,6 +104,9 @@ struct i915_fragment_shader struct draw_fragment_shader *draw_data; + uint *decl; + uint decl_len; + uint *program; uint program_len; diff --git a/src/gallium/drivers/i915/i915_fpc_translate.c b/src/gallium/drivers/i915/i915_fpc_translate.c index 5bfbfa0fa05..a82ad146dfd 100644 --- a/src/gallium/drivers/i915/i915_fpc_translate.c +++ b/src/gallium/drivers/i915/i915_fpc_translate.c @@ -1277,17 +1277,26 @@ i915_fini_compile(struct i915_context *i915, struct i915_fp_compile *p) /* Copy compilation results to fragment program struct: */ + assert(!ifs->decl); assert(!ifs->program); + + ifs->decl + = (uint *) MALLOC(decl_size * sizeof(uint)); ifs->program - = (uint *) MALLOC((program_size + decl_size) * sizeof(uint)); - if (ifs->program) { - ifs->program_len = program_size + decl_size; + = (uint *) MALLOC(program_size * sizeof(uint)); - memcpy(ifs->program, + if (ifs->decl) { + ifs->decl_len = decl_size; + + memcpy(ifs->decl, p->declarations, decl_size * sizeof(uint)); + } + + if (ifs->program) { + ifs->program_len = program_size; - memcpy(ifs->program + decl_size, + memcpy(ifs->program, p->program, program_size * sizeof(uint)); } diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c index 853468c6ffd..d0063e3901a 100644 --- a/src/gallium/drivers/i915/i915_state.c +++ b/src/gallium/drivers/i915/i915_state.c @@ -608,6 +608,11 @@ void i915_delete_fs_state(struct pipe_context *pipe, void *shader) { struct i915_fragment_shader *ifs = (struct i915_fragment_shader *) shader; + if (ifs->decl) { + FREE(ifs->decl); + ifs->decl = NULL; + } + if (ifs->program) { FREE(ifs->program); ifs->program = NULL; @@ -615,6 +620,7 @@ void i915_delete_fs_state(struct pipe_context *pipe, void *shader) ifs->state.tokens = NULL; } ifs->program_len = 0; + ifs->decl_len = 0; FREE(ifs); } diff --git a/src/gallium/drivers/i915/i915_state_emit.c b/src/gallium/drivers/i915/i915_state_emit.c index 9c941ae9e41..2aed3f1c7dc 100644 --- a/src/gallium/drivers/i915/i915_state_emit.c +++ b/src/gallium/drivers/i915/i915_state_emit.c @@ -366,7 +366,7 @@ validate_program(struct i915_context *i915, unsigned *batch_space) uint additional_size = i915->current.target_fixup_format ? 1 : 0; /* we need more batch space if we want to emulate rgba framebuffers */ - *batch_space = i915->fs->program_len + 3 * additional_size; + *batch_space = i915->fs->decl_len + i915->fs->program_len + 3 * additional_size; } static void @@ -378,15 +378,19 @@ emit_program(struct i915_context *i915) /* we should always have, at least, a pass-through program */ assert(i915->fs->program_len > 0); + /* output the declarations */ { /* first word has the size, we have to adjust that */ - uint size = (i915->fs->program[0]); + uint size = (i915->fs->decl[0]); size += need_target_fixup * 3; OUT_BATCH(size); } - /* output the declarations and the program */ - for (i = 1 ; i < i915->fs->program_len; i++) + for (i = 1 ; i < i915->fs->decl_len; i++) + OUT_BATCH(i915->fs->decl[i]); + + /* output the program */ + for (i = 0 ; i < i915->fs->program_len; i++) OUT_BATCH(i915->fs->program[i]); /* we emit an additional mov with swizzle to fake RGBA framebuffers */ |