mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 02:20:11 +01:00
mesa: put constants before state vars for ARB programs
This moves state vars to the end of the parameter list, so that state vars can be loaded directly into a buffer instead of loaded into the parameter list. Also, state vars don't need to be searched in the parameter list anymore, because we will know their index range. (this will make gallium faster) This commit just wraps a for loop around the existing code. Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6946>
This commit is contained in:
parent
06a141469b
commit
b9bff76b63
1 changed files with 82 additions and 70 deletions
|
|
@ -128,17 +128,23 @@ _mesa_layout_parameters(struct asm_parser_state *state)
|
|||
{
|
||||
struct gl_program_parameter_list *layout;
|
||||
struct asm_instruction *inst;
|
||||
unsigned i;
|
||||
|
||||
layout =
|
||||
_mesa_new_parameter_list_sized(state->prog->Parameters->NumParameters);
|
||||
|
||||
for (unsigned f = 0; f < 2; f++) {
|
||||
unsigned file = !f ? PROGRAM_CONSTANT : PROGRAM_STATE_VAR;
|
||||
|
||||
/* PASS 1: Move any parameters that are accessed indirectly from the
|
||||
* original parameter list to the new parameter list.
|
||||
*/
|
||||
for (inst = state->inst_head; inst != NULL; inst = inst->next) {
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (unsigned i = 0; i < 3; i++) {
|
||||
if (inst->SrcReg[i].Base.RelAddr) {
|
||||
unsigned begin = inst->SrcReg[i].Symbol->param_binding_begin;
|
||||
if (state->prog->Parameters->Parameters[begin].Type != file)
|
||||
continue;
|
||||
|
||||
/* Only attempt to add the to the new parameter list once.
|
||||
*/
|
||||
if (!inst->SrcReg[i].Symbol->pass1_done) {
|
||||
|
|
@ -171,7 +177,7 @@ _mesa_layout_parameters(struct asm_parser_state *state)
|
|||
* original parameter list to the new parameter list.
|
||||
*/
|
||||
for (inst = state->inst_head; inst != NULL; inst = inst->next) {
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (unsigned i = 0; i < 3; i++) {
|
||||
const struct gl_program_parameter *p;
|
||||
const int idx = inst->SrcReg[i].Base.Index;
|
||||
unsigned swizzle = SWIZZLE_NOOP;
|
||||
|
|
@ -183,13 +189,18 @@ _mesa_layout_parameters(struct asm_parser_state *state)
|
|||
continue;
|
||||
}
|
||||
|
||||
p = &state->prog->Parameters->Parameters[idx];
|
||||
|
||||
if ((inst->SrcReg[i].Base.File <= PROGRAM_OUTPUT)
|
||||
|| (inst->SrcReg[i].Base.File >= PROGRAM_WRITE_ONLY)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (p->Type != file) {
|
||||
continue;
|
||||
}
|
||||
|
||||
inst->Base.SrcReg[i] = inst->SrcReg[i].Base;
|
||||
p = & state->prog->Parameters->Parameters[idx];
|
||||
|
||||
switch (p->Type) {
|
||||
case PROGRAM_CONSTANT: {
|
||||
|
|
@ -218,6 +229,7 @@ _mesa_layout_parameters(struct asm_parser_state *state)
|
|||
inst->Base.SrcReg[i].File = p->Type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
layout->StateFlags = state->prog->Parameters->StateFlags;
|
||||
_mesa_free_parameter_list(state->prog->Parameters);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue