From: Emma Anholt Date: Sun, 27 Jun 2021 04:31:00 +0000 (-0700) Subject: i915g: Bake the decls and program together. X-Git-Tag: upstream/21.2.3~1193 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=79800a957d532febdb7ba307c424923fde2629b4;p=platform%2Fupstream%2Fmesa.git i915g: Bake the decls and program together. Simplifies program upload a bunch, and will let us disasm the program independently of the whole cmd buffer. Part-of: --- diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h index 6c158b7..385e9ca 100644 --- a/src/gallium/drivers/i915/i915_context.h +++ b/src/gallium/drivers/i915/i915_context.h @@ -97,9 +97,6 @@ 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 361d870..1fc5ab1 100644 --- a/src/gallium/drivers/i915/i915_fpc_translate.c +++ b/src/gallium/drivers/i915/i915_fpc_translate.c @@ -49,11 +49,8 @@ * Simple pass-through fragment shader to use when we don't have * a real shader (or it fails to compile for some reason). */ -static unsigned passthrough_decl[] = { - _3DSTATE_PIXEL_SHADER_PROGRAM | ((1 * 3) - 1), -}; - static unsigned passthrough_program[] = { + _3DSTATE_PIXEL_SHADER_PROGRAM | ((1 * 3) - 1), /* move to output color: */ (A0_MOV | (REG_TYPE_OC << A0_DEST_TYPE_SHIFT) | A0_DEST_CHANNEL_ALL | @@ -98,12 +95,9 @@ static void i915_use_passthrough_shader(struct i915_fragment_shader *fs) { fs->program = (uint *)MALLOC(sizeof(passthrough_program)); - fs->decl = (uint *)MALLOC(sizeof(passthrough_decl)); if (fs->program) { memcpy(fs->program, passthrough_program, sizeof(passthrough_program)); - memcpy(fs->decl, passthrough_decl, sizeof(passthrough_decl)); fs->program_len = ARRAY_SIZE(passthrough_program); - fs->decl_len = ARRAY_SIZE(passthrough_decl); } fs->num_constants = 0; } @@ -1008,23 +1002,12 @@ 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 * sizeof(uint)); - - 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, p->program, program_size * sizeof(uint)); - } + ifs->program_len = decl_size + program_size; + ifs->program = (uint *)MALLOC(ifs->program_len * sizeof(uint)); + memcpy(ifs->program, p->declarations, decl_size * sizeof(uint)); + memcpy(&ifs->program[decl_size], p->program, program_size * sizeof(uint)); } /* Release the compilation struct: diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c index 93b85b0..e31b96f 100644 --- a/src/gallium/drivers/i915/i915_state.c +++ b/src/gallium/drivers/i915/i915_state.c @@ -555,16 +555,12 @@ i915_delete_fs_state(struct pipe_context *pipe, void *shader) { struct i915_fragment_shader *ifs = (struct i915_fragment_shader *)shader; - FREE(ifs->decl); - ifs->decl = NULL; - FREE(ifs->program); ifs->program = NULL; FREE((struct tgsi_token *)ifs->state.tokens); 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 8f971f5e..cc55a2c 100644 --- a/src/gallium/drivers/i915/i915_state_emit.c +++ b/src/gallium/drivers/i915/i915_state_emit.c @@ -368,45 +368,29 @@ emit_constants(struct i915_context *i915) static void validate_program(struct i915_context *i915, unsigned *batch_space) { - uint additional_size = 0; - - additional_size += i915->current.fixup_swizzle ? 3 : 0; - /* we need more batch space if we want to emulate rgba framebuffers */ - *batch_space = i915->fs->decl_len + i915->fs->program_len + additional_size; + *batch_space = i915->fs->program_len + (i915->current.fixup_swizzle ? 3 : 0); } static void emit_program(struct i915_context *i915) { - uint additional_size = 0; - uint i; - - /* count how much additional space we'll need */ - validate_program(i915, &additional_size); - additional_size -= i915->fs->decl_len + i915->fs->program_len; - /* 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->decl[0]); - size += additional_size; - OUT_BATCH(size); - } + /* If we're doing a fixup swizzle, that's 3 more dwords to add. */ + uint32_t additional_size = 0; + if (i915->current.fixup_swizzle) + additional_size = 3; + + /* output the program: 1 dword of header, then 3 dwords per decl/instruction */ + assert(i915->fs->program_len % 3 == 1); - for (i = 1; i < i915->fs->decl_len; i++) - OUT_BATCH(i915->fs->decl[i]); + /* first word has the size, adjust it for fixup swizzle */ + OUT_BATCH(i915->fs->program[0] + additional_size); - /* output the program */ - assert(i915->fs->program_len % 3 == 0); - for (i = 0; i < i915->fs->program_len; i += 3) { + for (int i = 1; i < i915->fs->program_len; i++) OUT_BATCH(i915->fs->program[i]); - OUT_BATCH(i915->fs->program[i + 1]); - OUT_BATCH(i915->fs->program[i + 2]); - } /* we emit an additional mov with swizzle to fake RGBA framebuffers */ if (i915->current.fixup_swizzle) {