summaryrefslogtreecommitdiffstats
path: root/src/mesa/program
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-11-17 10:52:28 +1100
committerTimothy Arceri <[email protected]>2016-11-17 12:53:12 +1100
commitc3df65c123c6392b0b116900395a89fd3dbb9b85 (patch)
tree2b7c4a89aff0ccbbfb7f9fec4e0b0459858b58bb /src/mesa/program
parentd6bdb3a86293da2164e9355f0262ef83afeece7f (diff)
st/mesa/r200/i915/i965: move ARB program fields into a union
It's common for games to compile 2000 programs or more so at 32bits x 2000 programs x 22 fields x 2 (at least) stages This should give us something like 352 kilobytes in savings once we add some more glsl only fields. Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/mesa/program')
-rw-r--r--src/mesa/program/arbprogparse.c68
-rw-r--r--src/mesa/program/ir_to_mesa.cpp12
-rw-r--r--src/mesa/program/prog_execute.c18
-rw-r--r--src/mesa/program/prog_opt_constant_fold.c4
-rw-r--r--src/mesa/program/prog_optimize.c53
-rw-r--r--src/mesa/program/prog_print.c17
-rw-r--r--src/mesa/program/prog_statevars.c18
-rw-r--r--src/mesa/program/prog_to_nir.c12
-rw-r--r--src/mesa/program/program.c36
-rw-r--r--src/mesa/program/program_parse.y51
-rw-r--r--src/mesa/program/programopt.c69
11 files changed, 183 insertions, 175 deletions
diff --git a/src/mesa/program/arbprogparse.c b/src/mesa/program/arbprogparse.c
index a7e21d91672..196d30f4daf 100644
--- a/src/mesa/program/arbprogparse.c
+++ b/src/mesa/program/arbprogparse.c
@@ -91,25 +91,25 @@ _mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target,
* fragment_program struct.
*/
program->String = prog.String;
- program->NumInstructions = prog.NumInstructions;
- program->NumTemporaries = prog.NumTemporaries;
- program->NumParameters = prog.NumParameters;
- program->NumAttributes = prog.NumAttributes;
- program->NumAddressRegs = prog.NumAddressRegs;
- program->NumNativeInstructions = prog.NumNativeInstructions;
- program->NumNativeTemporaries = prog.NumNativeTemporaries;
- program->NumNativeParameters = prog.NumNativeParameters;
- program->NumNativeAttributes = prog.NumNativeAttributes;
- program->NumNativeAddressRegs = prog.NumNativeAddressRegs;
- program->NumAluInstructions = prog.NumAluInstructions;
- program->NumTexInstructions = prog.NumTexInstructions;
- program->NumTexIndirections = prog.NumTexIndirections;
- program->NumNativeAluInstructions = prog.NumAluInstructions;
- program->NumNativeTexInstructions = prog.NumTexInstructions;
- program->NumNativeTexIndirections = prog.NumTexIndirections;
+ program->arb.NumInstructions = prog.arb.NumInstructions;
+ program->arb.NumTemporaries = prog.arb.NumTemporaries;
+ program->arb.NumParameters = prog.arb.NumParameters;
+ program->arb.NumAttributes = prog.arb.NumAttributes;
+ program->arb.NumAddressRegs = prog.arb.NumAddressRegs;
+ program->arb.NumNativeInstructions = prog.arb.NumNativeInstructions;
+ program->arb.NumNativeTemporaries = prog.arb.NumNativeTemporaries;
+ program->arb.NumNativeParameters = prog.arb.NumNativeParameters;
+ program->arb.NumNativeAttributes = prog.arb.NumNativeAttributes;
+ program->arb.NumNativeAddressRegs = prog.arb.NumNativeAddressRegs;
+ program->arb.NumAluInstructions = prog.arb.NumAluInstructions;
+ program->arb.NumTexInstructions = prog.arb.NumTexInstructions;
+ program->arb.NumTexIndirections = prog.arb.NumTexIndirections;
+ program->arb.NumNativeAluInstructions = prog.arb.NumAluInstructions;
+ program->arb.NumNativeTexInstructions = prog.arb.NumTexInstructions;
+ program->arb.NumNativeTexIndirections = prog.arb.NumTexIndirections;
program->info.inputs_read = prog.info.inputs_read;
program->info.outputs_written = prog.info.outputs_written;
- program->IndirectRegisterFiles = prog.IndirectRegisterFiles;
+ program->arb.IndirectRegisterFiles = prog.arb.IndirectRegisterFiles;
for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++) {
program->TexturesUsed[i] = prog.TexturesUsed[i];
if (prog.TexturesUsed[i])
@@ -121,8 +121,8 @@ _mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target,
program->info.fs.uses_discard = state.fragment.UsesKill;
- free(program->Instructions);
- program->Instructions = prog.Instructions;
+ free(program->arb.Instructions);
+ program->arb.Instructions = prog.arb.Instructions;
if (program->Parameters)
_mesa_free_parameter_list(program->Parameters);
@@ -174,7 +174,7 @@ _mesa_parse_arb_vertex_program(struct gl_context *ctx, GLenum target,
if (!_mesa_parse_arb_program(ctx, target, (const GLubyte*) str, len,
&state)) {
- ralloc_free(prog.Instructions);
+ ralloc_free(prog.arb.Instructions);
ralloc_free(prog.String);
_mesa_error(ctx, GL_INVALID_OPERATION, "glProgramString(bad program)");
return;
@@ -189,24 +189,24 @@ _mesa_parse_arb_vertex_program(struct gl_context *ctx, GLenum target,
* vertex_program struct.
*/
program->String = prog.String;
- program->NumInstructions = prog.NumInstructions;
- program->NumTemporaries = prog.NumTemporaries;
- program->NumParameters = prog.NumParameters;
- program->NumAttributes = prog.NumAttributes;
- program->NumAddressRegs = prog.NumAddressRegs;
- program->NumNativeInstructions = prog.NumNativeInstructions;
- program->NumNativeTemporaries = prog.NumNativeTemporaries;
- program->NumNativeParameters = prog.NumNativeParameters;
- program->NumNativeAttributes = prog.NumNativeAttributes;
- program->NumNativeAddressRegs = prog.NumNativeAddressRegs;
+ program->arb.NumInstructions = prog.arb.NumInstructions;
+ program->arb.NumTemporaries = prog.arb.NumTemporaries;
+ program->arb.NumParameters = prog.arb.NumParameters;
+ program->arb.NumAttributes = prog.arb.NumAttributes;
+ program->arb.NumAddressRegs = prog.arb.NumAddressRegs;
+ program->arb.NumNativeInstructions = prog.arb.NumNativeInstructions;
+ program->arb.NumNativeTemporaries = prog.arb.NumNativeTemporaries;
+ program->arb.NumNativeParameters = prog.arb.NumNativeParameters;
+ program->arb.NumNativeAttributes = prog.arb.NumNativeAttributes;
+ program->arb.NumNativeAddressRegs = prog.arb.NumNativeAddressRegs;
program->info.inputs_read = prog.info.inputs_read;
program->info.outputs_written = prog.info.outputs_written;
- program->IndirectRegisterFiles = prog.IndirectRegisterFiles;
- program->IsPositionInvariant = (state.option.PositionInvariant)
+ program->arb.IndirectRegisterFiles = prog.arb.IndirectRegisterFiles;
+ program->arb.IsPositionInvariant = (state.option.PositionInvariant)
? GL_TRUE : GL_FALSE;
- ralloc_free(program->Instructions);
- program->Instructions = prog.Instructions;
+ ralloc_free(program->arb.Instructions);
+ program->arb.Instructions = prog.arb.Instructions;
if (program->Parameters)
_mesa_free_parameter_list(program->Parameters);
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 7ea375f0362..c42c19b4110 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2810,7 +2810,7 @@ get_mesa_program(struct gl_context *ctx,
visit_exec_list(shader->ir, &v);
v.emit(NULL, OPCODE_END);
- prog->NumTemporaries = v.next_temp;
+ prog->arb.NumTemporaries = v.next_temp;
unsigned num_instructions = v.instructions.length();
@@ -2844,12 +2844,12 @@ get_mesa_program(struct gl_context *ctx,
/* Set IndirectRegisterFiles. */
if (mesa_inst->DstReg.RelAddr)
- prog->IndirectRegisterFiles |= 1 << mesa_inst->DstReg.File;
+ prog->arb.IndirectRegisterFiles |= 1 << mesa_inst->DstReg.File;
/* Update program's bitmask of indirectly accessed register files */
for (unsigned src = 0; src < 3; src++)
if (mesa_inst->SrcReg[src].RelAddr)
- prog->IndirectRegisterFiles |= 1 << mesa_inst->SrcReg[src].File;
+ prog->arb.IndirectRegisterFiles |= 1 << mesa_inst->SrcReg[src].File;
switch (mesa_inst->Opcode) {
case OPCODE_IF:
@@ -2877,7 +2877,7 @@ get_mesa_program(struct gl_context *ctx,
}
break;
case OPCODE_ARL:
- prog->NumAddressRegs = 1;
+ prog->arb.NumAddressRegs = 1;
break;
default:
break;
@@ -2910,8 +2910,8 @@ get_mesa_program(struct gl_context *ctx,
fflush(stderr);
}
- prog->Instructions = mesa_instructions;
- prog->NumInstructions = num_instructions;
+ prog->arb.Instructions = mesa_instructions;
+ prog->arb.NumInstructions = num_instructions;
/* Setting this to NULL prevents a possible double free in the fail_exit
* path (far below).
diff --git a/src/mesa/program/prog_execute.c b/src/mesa/program/prog_execute.c
index cb06e625451..12684762794 100644
--- a/src/mesa/program/prog_execute.c
+++ b/src/mesa/program/prog_execute.c
@@ -374,7 +374,7 @@ _mesa_execute_program(struct gl_context * ctx,
const struct gl_program *program,
struct gl_program_machine *machine)
{
- const GLuint numInst = program->NumInstructions;
+ const GLuint numInst = program->arb.NumInstructions;
const GLuint maxExec = 65536;
GLuint pc, numExec = 0;
@@ -392,7 +392,7 @@ _mesa_execute_program(struct gl_context * ctx,
}
for (pc = 0; pc < numInst; pc++) {
- const struct prog_instruction *inst = program->Instructions + pc;
+ const struct prog_instruction *inst = program->arb.Instructions + pc;
if (DEBUG_PROG) {
_mesa_print_instruction(inst);
@@ -439,12 +439,12 @@ _mesa_execute_program(struct gl_context * ctx,
break;
case OPCODE_BGNLOOP:
/* no-op */
- assert(program->Instructions[inst->BranchTarget].Opcode
+ assert(program->arb.Instructions[inst->BranchTarget].Opcode
== OPCODE_ENDLOOP);
break;
case OPCODE_ENDLOOP:
/* subtract 1 here since pc is incremented by for(pc) loop */
- assert(program->Instructions[inst->BranchTarget].Opcode
+ assert(program->arb.Instructions[inst->BranchTarget].Opcode
== OPCODE_BGNLOOP);
pc = inst->BranchTarget - 1; /* go to matching BNGLOOP */
break;
@@ -453,14 +453,14 @@ _mesa_execute_program(struct gl_context * ctx,
case OPCODE_ENDSUB: /* end subroutine */
break;
case OPCODE_BRK: /* break out of loop (conditional) */
- assert(program->Instructions[inst->BranchTarget].Opcode
+ assert(program->arb.Instructions[inst->BranchTarget].Opcode
== OPCODE_ENDLOOP);
/* break out of loop */
/* pc++ at end of for-loop will put us after the ENDLOOP inst */
pc = inst->BranchTarget;
break;
case OPCODE_CONT: /* continue loop (conditional) */
- assert(program->Instructions[inst->BranchTarget].Opcode
+ assert(program->arb.Instructions[inst->BranchTarget].Opcode
== OPCODE_ENDLOOP);
/* continue at ENDLOOP */
/* Subtract 1 here since we'll do pc++ at end of for-loop */
@@ -645,9 +645,9 @@ _mesa_execute_program(struct gl_context * ctx,
case OPCODE_IF:
{
GLboolean cond;
- assert(program->Instructions[inst->BranchTarget].Opcode
+ assert(program->arb.Instructions[inst->BranchTarget].Opcode
== OPCODE_ELSE ||
- program->Instructions[inst->BranchTarget].Opcode
+ program->arb.Instructions[inst->BranchTarget].Opcode
== OPCODE_ENDIF);
/* eval condition */
GLfloat a[4];
@@ -669,7 +669,7 @@ _mesa_execute_program(struct gl_context * ctx,
break;
case OPCODE_ELSE:
/* goto ENDIF */
- assert(program->Instructions[inst->BranchTarget].Opcode
+ assert(program->arb.Instructions[inst->BranchTarget].Opcode
== OPCODE_ENDIF);
assert(inst->BranchTarget >= 0);
pc = inst->BranchTarget;
diff --git a/src/mesa/program/prog_opt_constant_fold.c b/src/mesa/program/prog_opt_constant_fold.c
index d17e206c9fc..ba4a954186a 100644
--- a/src/mesa/program/prog_opt_constant_fold.c
+++ b/src/mesa/program/prog_opt_constant_fold.c
@@ -127,8 +127,8 @@ _mesa_constant_fold(struct gl_program *prog)
bool progress = false;
unsigned i;
- for (i = 0; i < prog->NumInstructions; i++) {
- struct prog_instruction *const inst = &prog->Instructions[i];
+ for (i = 0; i < prog->arb.NumInstructions; i++) {
+ struct prog_instruction *const inst = &prog->arb.Instructions[i];
switch (inst->Opcode) {
case OPCODE_ADD:
diff --git a/src/mesa/program/prog_optimize.c b/src/mesa/program/prog_optimize.c
index d8bba6d42e7..6a228ba2583 100644
--- a/src/mesa/program/prog_optimize.c
+++ b/src/mesa/program/prog_optimize.c
@@ -166,7 +166,7 @@ remove_instructions(struct gl_program *prog, const GLboolean *removeFlags,
GLuint totalRemoved = 0;
/* go backward */
- for (i = prog->NumInstructions - 1; i >= 0; i--) {
+ for (i = prog->arb.NumInstructions - 1; i >= 0; i--) {
if (removeFlags[i]) {
totalRemoved++;
if (removeCount == 0) {
@@ -210,8 +210,8 @@ replace_regs(struct gl_program *prog, gl_register_file file, const GLint map[])
{
GLuint i;
- for (i = 0; i < prog->NumInstructions; i++) {
- struct prog_instruction *inst = prog->Instructions + i;
+ for (i = 0; i < prog->arb.NumInstructions; i++) {
+ struct prog_instruction *inst = prog->arb.Instructions + i;
const GLuint numSrc = _mesa_num_inst_src_regs(inst->Opcode);
GLuint j;
for (j = 0; j < numSrc; j++) {
@@ -251,11 +251,11 @@ _mesa_remove_dead_code_global(struct gl_program *prog, void *mem_ctx)
}
removeInst =
- calloc(prog->NumInstructions, sizeof(GLboolean));
+ calloc(prog->arb.NumInstructions, sizeof(GLboolean));
/* Determine which temps are read and written */
- for (i = 0; i < prog->NumInstructions; i++) {
- const struct prog_instruction *inst = prog->Instructions + i;
+ for (i = 0; i < prog->arb.NumInstructions; i++) {
+ const struct prog_instruction *inst = prog->arb.Instructions + i;
const GLuint numSrc = _mesa_num_inst_src_regs(inst->Opcode);
GLuint j;
@@ -297,8 +297,8 @@ _mesa_remove_dead_code_global(struct gl_program *prog, void *mem_ctx)
}
/* find instructions that write to dead registers, flag for removal */
- for (i = 0; i < prog->NumInstructions; i++) {
- struct prog_instruction *inst = prog->Instructions + i;
+ for (i = 0; i < prog->arb.NumInstructions; i++) {
+ struct prog_instruction *inst = prog->arb.Instructions + i;
const GLuint numDst = _mesa_num_inst_dst_regs(inst->Opcode);
if (numDst != 0 && inst->DstReg.File == PROGRAM_TEMPORARY) {
@@ -365,8 +365,8 @@ find_next_use(const struct gl_program *prog,
{
GLuint i;
- for (i = start; i < prog->NumInstructions; i++) {
- const struct prog_instruction *inst = prog->Instructions + i;
+ for (i = start; i < prog->arb.NumInstructions; i++) {
+ const struct prog_instruction *inst = prog->arb.Instructions + i;
switch (inst->Opcode) {
case OPCODE_BGNLOOP:
case OPCODE_BGNSUB:
@@ -482,8 +482,8 @@ _mesa_remove_extra_move_use(struct gl_program *prog)
* FOO tmpY, arg0, arg1;
*/
- for (i = 0; i + 1 < prog->NumInstructions; i++) {
- const struct prog_instruction *mov = prog->Instructions + i;
+ for (i = 0; i + 1 < prog->arb.NumInstructions; i++) {
+ const struct prog_instruction *mov = prog->arb.Instructions + i;
GLuint dst_mask, src_mask;
if (can_upward_mov_be_modifed(mov) == GL_FALSE)
continue;
@@ -498,8 +498,8 @@ _mesa_remove_extra_move_use(struct gl_program *prog)
* rewritten or we get into some flow-control, eliminating the use of
* this MOV.
*/
- for (j = i + 1; j < prog->NumInstructions; j++) {
- struct prog_instruction *inst2 = prog->Instructions + j;
+ for (j = i + 1; j < prog->arb.NumInstructions; j++) {
+ struct prog_instruction *inst2 = prog->arb.Instructions + j;
GLuint arg;
if (_mesa_is_flow_control_opcode(inst2->Opcode))
@@ -575,10 +575,10 @@ _mesa_remove_dead_code_local(struct gl_program *prog, void *mem_ctx)
GLuint i, arg, rem = 0;
removeInst =
- calloc(prog->NumInstructions, sizeof(GLboolean));
+ calloc(prog->arb.NumInstructions, sizeof(GLboolean));
- for (i = 0; i < prog->NumInstructions; i++) {
- const struct prog_instruction *inst = prog->Instructions + i;
+ for (i = 0; i < prog->arb.NumInstructions; i++) {
+ const struct prog_instruction *inst = prog->arb.Instructions + i;
const GLuint index = inst->DstReg.Index;
const GLuint mask = inst->DstReg.WriteMask;
enum inst_use use;
@@ -716,7 +716,7 @@ _mesa_remove_extra_moves(struct gl_program *prog, void *mem_ctx)
}
removeInst =
- calloc(prog->NumInstructions, sizeof(GLboolean));
+ calloc(prog->arb.NumInstructions, sizeof(GLboolean));
/*
* Look for sequences such as this:
@@ -726,8 +726,8 @@ _mesa_remove_extra_moves(struct gl_program *prog, void *mem_ctx)
* FOO tmpY, arg0, arg1;
*/
- for (i = 0; i < prog->NumInstructions; i++) {
- const struct prog_instruction *mov = prog->Instructions + i;
+ for (i = 0; i < prog->arb.NumInstructions; i++) {
+ const struct prog_instruction *mov = prog->arb.Instructions + i;
switch (mov->Opcode) {
case OPCODE_BGNLOOP:
@@ -756,7 +756,7 @@ _mesa_remove_extra_moves(struct gl_program *prog, void *mem_ctx)
prevI = i - 1;
while (prevI > 0 && removeInst[prevI])
prevI--;
- prevInst = prog->Instructions + prevI;
+ prevInst = prog->arb.Instructions + prevI;
if (prevInst->DstReg.File == PROGRAM_TEMPORARY &&
prevInst->DstReg.Index == id &&
@@ -1034,7 +1034,8 @@ find_live_intervals(struct gl_program *prog,
}
/* build intermediate arrays */
- if (!_mesa_find_temp_intervals(prog->Instructions, prog->NumInstructions,
+ if (!_mesa_find_temp_intervals(prog->arb.Instructions,
+ prog->arb.NumInstructions,
intBegin, intEnd))
return GL_FALSE;
@@ -1194,7 +1195,7 @@ _mesa_reallocate_registers(struct gl_program *prog)
*/
replace_regs(prog, PROGRAM_TEMPORARY, registerMap);
- prog->NumTemporaries = maxTemp + 1;
+ prog->arb.NumTemporaries = maxTemp + 1;
}
if (dbg) {
@@ -1209,7 +1210,7 @@ _mesa_reallocate_registers(struct gl_program *prog)
#if 0
static void
print_it(struct gl_context *ctx, struct gl_program *program, const char *txt) {
- fprintf(stderr, "%s (%u inst):\n", txt, program->NumInstructions);
+ fprintf(stderr, "%s (%u inst):\n", txt, program->arb.NumInstructions);
_mesa_print_program(program);
_mesa_print_program_parameters(ctx, program);
fprintf(stderr, "\n\n");
@@ -1257,8 +1258,8 @@ _mesa_simplify_cmp(struct gl_program * program)
outputWrites[i] = 0;
}
- for (i = 0; i < program->NumInstructions; i++) {
- struct prog_instruction *inst = program->Instructions + i;
+ for (i = 0; i < program->arb.NumInstructions; i++) {
+ struct prog_instruction *inst = program->arb.Instructions + i;
GLuint prevWriteMask;
/* Give up if we encounter relative addressing or flow control. */
diff --git a/src/mesa/program/prog_print.c b/src/mesa/program/prog_print.c
index d34187f7adf..bdeb8fd6752 100644
--- a/src/mesa/program/prog_print.c
+++ b/src/mesa/program/prog_print.c
@@ -803,10 +803,10 @@ _mesa_fprint_program_opt(FILE *f,
fprintf(f, "# Geometry Shader\n");
}
- for (i = 0; i < prog->NumInstructions; i++) {
+ for (i = 0; i < prog->arb.NumInstructions; i++) {
if (lineNumbers)
fprintf(f, "%3d: ", i);
- indent = _mesa_fprint_instruction_opt(f, prog->Instructions + i,
+ indent = _mesa_fprint_instruction_opt(f, prog->arb.Instructions + i,
indent, mode, prog);
}
}
@@ -862,13 +862,14 @@ _mesa_fprint_program_parameters(FILE *f,
fprintf(f, "OutputsWritten: %" PRIx64 " (0b%s)\n",
(uint64_t) prog->info.outputs_written,
binary(prog->info.outputs_written));
- fprintf(f, "NumInstructions=%d\n", prog->NumInstructions);
- fprintf(f, "NumTemporaries=%d\n", prog->NumTemporaries);
- fprintf(f, "NumParameters=%d\n", prog->NumParameters);
- fprintf(f, "NumAttributes=%d\n", prog->NumAttributes);
- fprintf(f, "NumAddressRegs=%d\n", prog->NumAddressRegs);
+ fprintf(f, "NumInstructions=%d\n", prog->arb.NumInstructions);
+ fprintf(f, "NumTemporaries=%d\n", prog->arb.NumTemporaries);
+ fprintf(f, "NumParameters=%d\n", prog->arb.NumParameters);
+ fprintf(f, "NumAttributes=%d\n", prog->arb.NumAttributes);
+ fprintf(f, "NumAddressRegs=%d\n", prog->arb.NumAddressRegs);
fprintf(f, "IndirectRegisterFiles: 0x%x (0b%s)\n",
- prog->IndirectRegisterFiles, binary(prog->IndirectRegisterFiles));
+ prog->arb.IndirectRegisterFiles,
+ binary(prog->arb.IndirectRegisterFiles));
fprintf(f, "SamplersUsed: 0x%x (0b%s)\n",
prog->SamplersUsed, binary(prog->SamplersUsed));
fprintf(f, "Samplers=[ ");
diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c
index 82ee5d4cbd4..22527a0184f 100644
--- a/src/mesa/program/prog_statevars.c
+++ b/src/mesa/program/prog_statevars.c
@@ -373,16 +373,17 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[],
COPY_4V(value, ctx->FragmentProgram.Parameters[idx]);
return;
case STATE_LOCAL:
- if (!ctx->FragmentProgram.Current->LocalParams) {
- ctx->FragmentProgram.Current->LocalParams =
+ if (!ctx->FragmentProgram.Current->arb.LocalParams) {
+ ctx->FragmentProgram.Current->arb.LocalParams =
rzalloc_array_size(ctx->FragmentProgram.Current,
sizeof(float[4]),
MAX_PROGRAM_LOCAL_PARAMS);
- if (!ctx->FragmentProgram.Current->LocalParams)
+ if (!ctx->FragmentProgram.Current->arb.LocalParams)
return;
}
- COPY_4V(value, ctx->FragmentProgram.Current->LocalParams[idx]);
+ COPY_4V(value,
+ ctx->FragmentProgram.Current->arb.LocalParams[idx]);
return;
default:
_mesa_problem(ctx, "Bad state switch in _mesa_fetch_state()");
@@ -401,16 +402,17 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[],
COPY_4V(value, ctx->VertexProgram.Parameters[idx]);
return;
case STATE_LOCAL:
- if (!ctx->VertexProgram.Current->LocalParams) {
- ctx->VertexProgram.Current->LocalParams =
+ if (!ctx->VertexProgram.Current->arb.LocalParams) {
+ ctx->VertexProgram.Current->arb.LocalParams =
rzalloc_array_size(ctx->VertexProgram.Current,
sizeof(float[4]),
MAX_PROGRAM_LOCAL_PARAMS);
- if (!ctx->VertexProgram.Current->LocalParams)
+ if (!ctx->VertexProgram.Current->arb.LocalParams)
return;
}
- COPY_4V(value, ctx->VertexProgram.Current->LocalParams[idx]);
+ COPY_4V(value,
+ ctx->VertexProgram.Current->arb.LocalParams[idx]);
return;
default:
_mesa_problem(ctx, "Bad state switch in _mesa_fetch_state()");
diff --git a/src/mesa/program/prog_to_nir.c b/src/mesa/program/prog_to_nir.c
index 08df05dc776..f4eb8b67bbb 100644
--- a/src/mesa/program/prog_to_nir.c
+++ b/src/mesa/program/prog_to_nir.c
@@ -159,7 +159,8 @@ ptn_get_src(struct ptn_compile *c, const struct prog_src_register *prog_src)
switch (file) {
case PROGRAM_CONSTANT:
- if ((c->prog->IndirectRegisterFiles & (1 << PROGRAM_CONSTANT)) == 0) {
+ if ((c->prog->arb.IndirectRegisterFiles &
+ (1 << PROGRAM_CONSTANT)) == 0) {
float *v = (float *) plist->ParameterValues[prog_src->Index];
src.src = nir_src_for_ssa(nir_imm_vec4(b, v[0], v[1], v[2], v[3]));
break;
@@ -977,10 +978,11 @@ setup_registers_and_variables(struct ptn_compile *c)
}
/* Create temporary registers. */
- c->temp_regs = rzalloc_array(c, nir_register *, c->prog->NumTemporaries);
+ c->temp_regs = rzalloc_array(c, nir_register *,
+ c->prog->arb.NumTemporaries);
nir_register *reg;
- for (unsigned i = 0; i < c->prog->NumTemporaries; i++) {
+ for (unsigned i = 0; i < c->prog->arb.NumTemporaries; i++) {
reg = nir_local_reg_create(b->impl);
if (!reg) {
c->error = true;
@@ -1036,8 +1038,8 @@ prog_to_nir(const struct gl_program *prog,
if (unlikely(c->error))
goto fail;
- for (unsigned int i = 0; i < prog->NumInstructions; i++) {
- ptn_emit_instruction(c, &prog->Instructions[i]);
+ for (unsigned int i = 0; i < prog->arb.NumInstructions; i++) {
+ ptn_emit_instruction(c, &prog->arb.Instructions[i]);
if (unlikely(c->error))
break;
diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c
index 25ec4893e51..e5eb06cb4b7 100644
--- a/src/mesa/program/program.c
+++ b/src/mesa/program/program.c
@@ -336,14 +336,14 @@ _mesa_reference_program_(struct gl_context *ctx,
GLboolean
_mesa_insert_instructions(struct gl_program *prog, GLuint start, GLuint count)
{
- const GLuint origLen = prog->NumInstructions;
+ const GLuint origLen = prog->arb.NumInstructions;
const GLuint newLen = origLen + count;
struct prog_instruction *newInst;
GLuint i;
/* adjust branches */
- for (i = 0; i < prog->NumInstructions; i++) {
- struct prog_instruction *inst = prog->Instructions + i;
+ for (i = 0; i < prog->arb.NumInstructions; i++) {
+ struct prog_instruction *inst = prog->arb.Instructions + i;
if (inst->BranchTarget > 0) {
if ((GLuint)inst->BranchTarget >= start) {
inst->BranchTarget += count;
@@ -358,22 +358,22 @@ _mesa_insert_instructions(struct gl_program *prog, GLuint start, GLuint count)
}
/* Copy 'start' instructions into new instruction buffer */
- _mesa_copy_instructions(newInst, prog->Instructions, start);
+ _mesa_copy_instructions(newInst, prog->arb.Instructions, start);
/* init the new instructions */
_mesa_init_instructions(newInst + start, count);
/* Copy the remaining/tail instructions to new inst buffer */
_mesa_copy_instructions(newInst + start + count,
- prog->Instructions + start,
+ prog->arb.Instructions + start,
origLen - start);
/* free old instructions */
- ralloc_free(prog->Instructions);
+ ralloc_free(prog->arb.Instructions);
/* install new instructions */
- prog->Instructions = newInst;
- prog->NumInstructions = newLen;
+ prog->arb.Instructions = newInst;
+ prog->arb.NumInstructions = newLen;
return GL_TRUE;
}
@@ -386,14 +386,14 @@ GLboolean
_mesa_delete_instructions(struct gl_program *prog, GLuint start, GLuint count,
void *mem_ctx)
{
- const GLuint origLen = prog->NumInstructions;
+ const GLuint origLen = prog->arb.NumInstructions;
const GLuint newLen = origLen - count;
struct prog_instruction *newInst;
GLuint i;
/* adjust branches */
- for (i = 0; i < prog->NumInstructions; i++) {
- struct prog_instruction *inst = prog->Instructions + i;
+ for (i = 0; i < prog->arb.NumInstructions; i++) {
+ struct prog_instruction *inst = prog->arb.Instructions + i;
if (inst->BranchTarget > 0) {
if (inst->BranchTarget > (GLint) start) {
inst->BranchTarget -= count;
@@ -408,19 +408,19 @@ _mesa_delete_instructions(struct gl_program *prog, GLuint start, GLuint count,
}
/* Copy 'start' instructions into new instruction buffer */
- _mesa_copy_instructions(newInst, prog->Instructions, start);
+ _mesa_copy_instructions(newInst, prog->arb.Instructions, start);
/* Copy the remaining/tail instructions to new inst buffer */
_mesa_copy_instructions(newInst + start,
- prog->Instructions + start + count,
+ prog->arb.Instructions + start + count,
newLen - start);
/* free old instructions */
- ralloc_free(prog->Instructions);
+ ralloc_free(prog->arb.Instructions);
/* install new instructions */
- prog->Instructions = newInst;
- prog->NumInstructions = newLen;
+ prog->arb.Instructions = newInst;
+ prog->arb.NumInstructions = newLen;
return GL_TRUE;
}
@@ -442,8 +442,8 @@ _mesa_find_used_registers(const struct gl_program *prog,
memset(used, 0, usedSize);
- for (i = 0; i < prog->NumInstructions; i++) {
- const struct prog_instruction *inst = prog->Instructions + i;
+ for (i = 0; i < prog->arb.NumInstructions; i++) {
+ const struct prog_instruction *inst = prog->arb.Instructions + i;
const GLuint n = _mesa_num_inst_src_regs(inst->Opcode);
if (inst->DstReg.File == file) {
diff --git a/src/mesa/program/program_parse.y b/src/mesa/program/program_parse.y
index e861340a023..f3adea6677c 100644
--- a/src/mesa/program/program_parse.y
+++ b/src/mesa/program/program_parse.y
@@ -348,7 +348,7 @@ statement: instruction ';'
state->inst_tail = $1;
$1->next = NULL;
- state->prog->NumInstructions++;
+ state->prog->arb.NumInstructions++;
}
}
| namingStatement ';'
@@ -357,12 +357,12 @@ statement: instruction ';'
instruction: ALU_instruction
{
$$ = $1;
- state->prog->NumAluInstructions++;
+ state->prog->arb.NumAluInstructions++;
}
| TexInstruction
{
$$ = $1;
- state->prog->NumTexInstructions++;
+ state->prog->arb.NumTexInstructions++;
}
;
@@ -785,7 +785,7 @@ srcReg: USED_IDENTIFIER /* temporaryReg | progParamSingle */
$$.Base.File = $1->param_binding_type;
if ($3.Base.RelAddr) {
- state->prog->IndirectRegisterFiles |= (1 << $$.Base.File);
+ state->prog->arb.IndirectRegisterFiles |= (1 << $$.Base.File);
$1->param_accessed_indirectly = 1;
$$.Base.RelAddr = 1;
@@ -2247,18 +2247,19 @@ declare_variable(struct asm_parser_state *state, char *name, enum asm_type t,
switch (t) {
case at_temp:
- if (state->prog->NumTemporaries >= state->limits->MaxTemps) {
+ if (state->prog->arb.NumTemporaries >= state->limits->MaxTemps) {
yyerror(locp, state, "too many temporaries declared");
free(s);
return NULL;
}
- s->temp_binding = state->prog->NumTemporaries;
- state->prog->NumTemporaries++;
+ s->temp_binding = state->prog->arb.NumTemporaries;
+ state->prog->arb.NumTemporaries++;
break;
case at_address:
- if (state->prog->NumAddressRegs >= state->limits->MaxAddressRegs) {
+ if (state->prog->arb.NumAddressRegs >=
+ state->limits->MaxAddressRegs) {
yyerror(locp, state, "too many address registers declared");
free(s);
return NULL;
@@ -2266,7 +2267,7 @@ declare_variable(struct asm_parser_state *state, char *name, enum asm_type t,
/* FINISHME: Add support for multiple address registers.
*/
- state->prog->NumAddressRegs++;
+ state->prog->arb.NumAddressRegs++;
break;
default:
@@ -2564,43 +2565,43 @@ _mesa_parse_arb_program(struct gl_context *ctx, GLenum target, const GLubyte *st
/* Add one instruction to store the "END" instruction.
*/
- state->prog->Instructions =
+ state->prog->arb.Instructions =
rzalloc_array(state->mem_ctx, struct prog_instruction,
- state->prog->NumInstructions + 1);
+ state->prog->arb.NumInstructions + 1);
- if (state->prog->Instructions == NULL) {
+ if (state->prog->arb.Instructions == NULL) {
goto error;
}
inst = state->inst_head;
- for (i = 0; i < state->prog->NumInstructions; i++) {
+ for (i = 0; i < state->prog->arb.NumInstructions; i++) {
struct asm_instruction *const temp = inst->next;
- state->prog->Instructions[i] = inst->Base;
+ state->prog->arb.Instructions[i] = inst->Base;
inst = temp;
}
/* Finally, tag on an OPCODE_END instruction */
{
- const GLuint numInst = state->prog->NumInstructions;
- _mesa_init_instructions(state->prog->Instructions + numInst, 1);
- state->prog->Instructions[numInst].Opcode = OPCODE_END;
+ const GLuint numInst = state->prog->arb.NumInstructions;
+ _mesa_init_instructions(state->prog->arb.Instructions + numInst, 1);
+ state->prog->arb.Instructions[numInst].Opcode = OPCODE_END;
}
- state->prog->NumInstructions++;
+ state->prog->arb.NumInstructions++;
- state->prog->NumParameters = state->prog->Parameters->NumParameters;
- state->prog->NumAttributes =
+ state->prog->arb.NumParameters = state->prog->Parameters->NumParameters;
+ state->prog->arb.NumAttributes =
_mesa_bitcount_64(state->prog->info.inputs_read);
/*
* Initialize native counts to logical counts. The device driver may
* change them if program is translated into a hardware program.
*/
- state->prog->NumNativeInstructions = state->prog->NumInstructions;
- state->prog->NumNativeTemporaries = state->prog->NumTemporaries;
- state->prog->NumNativeParameters = state->prog->NumParameters;
- state->prog->NumNativeAttributes = state->prog->NumAttributes;
- state->prog->NumNativeAddressRegs = state->prog->NumAddressRegs;
+ state->prog->arb.NumNativeInstructions = state->prog->arb.NumInstructions;
+ state->prog->arb.NumNativeTemporaries = state->prog->arb.NumTemporaries;
+ state->prog->arb.NumNativeParameters = state->prog->arb.NumParameters;
+ state->prog->arb.NumNativeAttributes = state->prog->arb.NumAttributes;
+ state->prog->arb.NumNativeAddressRegs = state->prog->arb.NumAddressRegs;
result = GL_TRUE;
diff --git a/src/mesa/program/programopt.c b/src/mesa/program/programopt.c
index e7cb8aab4d3..501acde0d0d 100644
--- a/src/mesa/program/programopt.c
+++ b/src/mesa/program/programopt.c
@@ -49,7 +49,7 @@ static void
_mesa_insert_mvp_dp4_code(struct gl_context *ctx, struct gl_program *vprog)
{
struct prog_instruction *newInst;
- const GLuint origLen = vprog->NumInstructions;
+ const GLuint origLen = vprog->arb.NumInstructions;
const GLuint newLen = origLen + 4;
GLuint i;
@@ -99,14 +99,14 @@ _mesa_insert_mvp_dp4_code(struct gl_context *ctx, struct gl_program *vprog)
}
/* Append original instructions after new instructions */
- _mesa_copy_instructions (newInst + 4, vprog->Instructions, origLen);
+ _mesa_copy_instructions (newInst + 4, vprog->arb.Instructions, origLen);
/* free old instructions */
- ralloc_free(vprog->Instructions);
+ ralloc_free(vprog->arb.Instructions);
/* install new instructions */
- vprog->Instructions = newInst;
- vprog->NumInstructions = newLen;
+ vprog->arb.Instructions = newInst;
+ vprog->arb.NumInstructions = newLen;
vprog->info.inputs_read |= VERT_BIT_POS;
vprog->info.outputs_written |= BITFIELD64_BIT(VARYING_SLOT_POS);
}
@@ -116,7 +116,7 @@ static void
_mesa_insert_mvp_mad_code(struct gl_context *ctx, struct gl_program *vprog)
{
struct prog_instruction *newInst;
- const GLuint origLen = vprog->NumInstructions;
+ const GLuint origLen = vprog->arb.NumInstructions;
const GLuint newLen = origLen + 4;
GLuint hposTemp;
GLuint i;
@@ -146,7 +146,7 @@ _mesa_insert_mvp_mad_code(struct gl_context *ctx, struct gl_program *vprog)
}
/* TEMP hposTemp; */
- hposTemp = vprog->NumTemporaries++;
+ hposTemp = vprog->arb.NumTemporaries++;
/*
* Generated instructions:
@@ -200,14 +200,14 @@ _mesa_insert_mvp_mad_code(struct gl_context *ctx, struct gl_program *vprog)
/* Append original instructions after new instructions */
- _mesa_copy_instructions (newInst + 4, vprog->Instructions, origLen);
+ _mesa_copy_instructions (newInst + 4, vprog->arb.Instructions, origLen);
/* free old instructions */
- ralloc_free(vprog->Instructions);
+ ralloc_free(vprog->arb.Instructions);
/* install new instructions */
- vprog->Instructions = newInst;
- vprog->NumInstructions = newLen;
+ vprog->arb.Instructions = newInst;
+ vprog->arb.NumInstructions = newLen;
vprog->info.inputs_read |= VERT_BIT_POS;
vprog->info.outputs_written |= BITFIELD64_BIT(VARYING_SLOT_POS);
}
@@ -252,7 +252,7 @@ _mesa_append_fog_code(struct gl_context *ctx, struct gl_program *fprog,
static const gl_state_index fogColorState[STATE_LENGTH]
= { STATE_FOG_COLOR, 0, 0, 0, 0};
struct prog_instruction *newInst, *inst;
- const GLuint origLen = fprog->NumInstructions;
+ const GLuint origLen = fprog->arb.NumInstructions;
const GLuint newLen = origLen + 5;
GLuint i;
GLint fogPRefOpt, fogColorRef; /* state references */
@@ -278,7 +278,7 @@ _mesa_append_fog_code(struct gl_context *ctx, struct gl_program *fprog,
}
/* Copy orig instructions into new instruction buffer */
- _mesa_copy_instructions(newInst, fprog->Instructions, origLen);
+ _mesa_copy_instructions(newInst, fprog->arb.Instructions, origLen);
/* PARAM fogParamsRefOpt = internal optimized fog params; */
fogPRefOpt
@@ -288,13 +288,13 @@ _mesa_append_fog_code(struct gl_context *ctx, struct gl_program *fprog,
= _mesa_add_state_reference(fprog->Parameters, fogColorState);
/* TEMP colorTemp; */
- colorTemp = fprog->NumTemporaries++;
+ colorTemp = fprog->arb.NumTemporaries++;
/* TEMP fogFactorTemp; */
- fogFactorTemp = fprog->NumTemporaries++;
+ fogFactorTemp = fprog->arb.NumTemporaries++;
/* Scan program to find where result.color is written */
inst = newInst;
- for (i = 0; i < fprog->NumInstructions; i++) {
+ for (i = 0; i < fprog->arb.NumInstructions; i++) {
if (inst->Opcode == OPCODE_END)
break;
if (inst->DstReg.File == PROGRAM_OUTPUT &&
@@ -403,11 +403,11 @@ _mesa_append_fog_code(struct gl_context *ctx, struct gl_program *fprog,
inst++;
/* free old instructions */
- ralloc_free(fprog->Instructions);
+ ralloc_free(fprog->arb.Instructions);
/* install new instructions */
- fprog->Instructions = newInst;
- fprog->NumInstructions = inst - newInst;
+ fprog->arb.Instructions = newInst;
+ fprog->arb.NumInstructions = inst - newInst;
fprog->info.inputs_read |= VARYING_BIT_FOGC;
assert(fprog->info.outputs_written & (1 << FRAG_RESULT_COLOR));
}
@@ -445,8 +445,8 @@ _mesa_count_texture_indirections(struct gl_program *prog)
GLbitfield aluTemps = 0x0;
GLuint i;
- for (i = 0; i < prog->NumInstructions; i++) {
- const struct prog_instruction *inst = prog->Instructions + i;
+ for (i = 0; i < prog->arb.NumInstructions; i++) {
+ const struct prog_instruction *inst = prog->arb.Instructions + i;
if (is_texture_instruction(inst)) {
if (((inst->SrcReg[0].File == PROGRAM_TEMPORARY) &&
@@ -474,7 +474,7 @@ _mesa_count_texture_indirections(struct gl_program *prog)
tempsOutput |= (1 << inst->DstReg.Index);
}
- prog->NumTexIndirections = indirections;
+ prog->arb.NumTexIndirections = indirections;
}
@@ -486,9 +486,10 @@ void
_mesa_count_texture_instructions(struct gl_program *prog)
{
GLuint i;
- prog->NumTexInstructions = 0;
- for (i = 0; i < prog->NumInstructions; i++) {
- prog->NumTexInstructions += is_texture_instruction(prog->Instructions + i);
+ prog->arb.NumTexInstructions = 0;
+ for (i = 0; i < prog->arb.NumInstructions; i++) {
+ prog->arb.NumTexInstructions +=
+ is_texture_instruction(prog->arb.Instructions + i);
}
}
@@ -517,8 +518,8 @@ _mesa_remove_output_reads(struct gl_program *prog, gl_register_file type)
outputMap[i] = -1;
/* look for instructions which read from varying vars */
- for (i = 0; i < prog->NumInstructions; i++) {
- struct prog_instruction *inst = prog->Instructions + i;
+ for (i = 0; i < prog->arb.NumInstructions; i++) {
+ struct prog_instruction *inst = prog->arb.Instructions + i;
const GLuint numSrc = _mesa_num_inst_src_regs(inst->Opcode);
GLuint j;
for (j = 0; j < numSrc; j++) {
@@ -542,8 +543,8 @@ _mesa_remove_output_reads(struct gl_program *prog, gl_register_file type)
return; /* nothing to be done */
/* look for instructions which write to the varying vars identified above */
- for (i = 0; i < prog->NumInstructions; i++) {
- struct prog_instruction *inst = prog->Instructions + i;
+ for (i = 0; i < prog->arb.NumInstructions; i++) {
+ struct prog_instruction *inst = prog->arb.Instructions + i;
if (inst->DstReg.File == type &&
outputMap[inst->DstReg.Index] >= 0) {
/* change inst to write to the temp reg, instead of the varying */
@@ -559,8 +560,8 @@ _mesa_remove_output_reads(struct gl_program *prog, gl_register_file type)
/* Look for END instruction and insert the new varying writes */
endPos = -1;
- for (i = 0; i < prog->NumInstructions; i++) {
- struct prog_instruction *inst = prog->Instructions + i;
+ for (i = 0; i < prog->arb.NumInstructions; i++) {
+ struct prog_instruction *inst = prog->arb.Instructions + i;
if (inst->Opcode == OPCODE_END) {
endPos = i;
_mesa_insert_instructions(prog, i, numVaryingReads);
@@ -571,7 +572,7 @@ _mesa_remove_output_reads(struct gl_program *prog, gl_register_file type)
assert(endPos >= 0);
/* insert new MOV instructions here */
- inst = prog->Instructions + endPos;
+ inst = prog->arb.Instructions + endPos;
for (var = 0; var < VARYING_SLOT_MAX; var++) {
if (outputMap[var] >= 0) {
/* MOV VAR[var], TEMP[tmp]; */
@@ -598,8 +599,8 @@ _mesa_program_fragment_position_to_sysval(struct gl_program *prog)
prog->info.inputs_read &= ~BITFIELD64_BIT(VARYING_SLOT_POS);
prog->info.system_values_read |= 1 << SYSTEM_VALUE_FRAG_COORD;
- for (i = 0; i < prog->NumInstructions; i++) {
- struct prog_instruction *inst = prog->Instructions + i;
+ for (i = 0; i < prog->arb.NumInstructions; i++) {
+ struct prog_instruction *inst = prog->arb.Instructions + i;
const GLuint numSrc = _mesa_num_inst_src_regs(inst->Opcode);
GLuint j;