mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 07:28:11 +02:00
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>
This commit is contained in:
parent
26afccb97e
commit
79800a957d
4 changed files with 16 additions and 56 deletions
|
|
@ -97,9 +97,6 @@ struct i915_fragment_shader {
|
|||
|
||||
struct draw_fragment_shader *draw_data;
|
||||
|
||||
uint *decl;
|
||||
uint decl_len;
|
||||
|
||||
uint *program;
|
||||
uint program_len;
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
for (i = 1; i < i915->fs->decl_len; i++)
|
||||
OUT_BATCH(i915->fs->decl[i]);
|
||||
/* output the program: 1 dword of header, then 3 dwords per decl/instruction */
|
||||
assert(i915->fs->program_len % 3 == 1);
|
||||
|
||||
/* output the program */
|
||||
assert(i915->fs->program_len % 3 == 0);
|
||||
for (i = 0; i < i915->fs->program_len; i += 3) {
|
||||
/* first word has the size, adjust it for fixup swizzle */
|
||||
OUT_BATCH(i915->fs->program[0] + additional_size);
|
||||
|
||||
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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue