Mesa (main): i915g: Bake the decls and program together.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Jun 28 22:17:31 UTC 2021
Module: Mesa
Branch: main
Commit: 79800a957d532febdb7ba307c424923fde2629b4
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=79800a957d532febdb7ba307c424923fde2629b4
Author: Emma Anholt <emma at anholt.net>
Date: Sat Jun 26 21:31:00 2021 -0700
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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11617>
---
src/gallium/drivers/i915/i915_context.h | 3 ---
src/gallium/drivers/i915/i915_fpc_translate.c | 27 ++++---------------
src/gallium/drivers/i915/i915_state.c | 4 ---
src/gallium/drivers/i915/i915_state_emit.c | 38 ++++++++-------------------
4 files changed, 16 insertions(+), 56 deletions(-)
diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h
index 6c158b7556f..385e9ca6e00 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 361d8708b0f..1fc5ab1786f 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 93b85b0d269..e31b96f2442 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 8f971f5e7a8..cc55a2c1d37 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) {
More information about the mesa-commit
mailing list