summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
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/main
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/main')
-rw-r--r--src/mesa/main/arbprogram.c41
-rw-r--r--src/mesa/main/ffvertex_prog.c32
-rw-r--r--src/mesa/main/mtypes.h91
-rw-r--r--src/mesa/main/state.c4
4 files changed, 86 insertions, 82 deletions
diff --git a/src/mesa/main/arbprogram.c b/src/mesa/main/arbprogram.c
index 8b25699b6bf..cb67fe33bb5 100644
--- a/src/mesa/main/arbprogram.c
+++ b/src/mesa/main/arbprogram.c
@@ -274,15 +274,14 @@ get_local_param_pointer(struct gl_context *ctx, const char *func,
return GL_FALSE;
}
- if (!prog->LocalParams) {
- prog->LocalParams = rzalloc_array_size(prog, sizeof(float[4]),
+ if (!prog->arb.LocalParams) {
+ prog->arb.LocalParams = rzalloc_array_size(prog, sizeof(float[4]),
maxParams);
-
- if (!prog->LocalParams)
+ if (!prog->arb.LocalParams)
return GL_FALSE;
}
- *param = prog->LocalParams[index];
+ *param = prog->arb.LocalParams[index];
return GL_TRUE;
}
@@ -682,61 +681,61 @@ _mesa_GetProgramivARB(GLenum target, GLenum pname, GLint *params)
*params = prog->Id;
return;
case GL_PROGRAM_INSTRUCTIONS_ARB:
- *params = prog->NumInstructions;
+ *params = prog->arb.NumInstructions;
return;
case GL_MAX_PROGRAM_INSTRUCTIONS_ARB:
*params = limits->MaxInstructions;
return;
case GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB:
- *params = prog->NumNativeInstructions;
+ *params = prog->arb.NumNativeInstructions;
return;
case GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB:
*params = limits->MaxNativeInstructions;
return;
case GL_PROGRAM_TEMPORARIES_ARB:
- *params = prog->NumTemporaries;
+ *params = prog->arb.NumTemporaries;
return;
case GL_MAX_PROGRAM_TEMPORARIES_ARB:
*params = limits->MaxTemps;
return;
case GL_PROGRAM_NATIVE_TEMPORARIES_ARB:
- *params = prog->NumNativeTemporaries;
+ *params = prog->arb.NumNativeTemporaries;
return;
case GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB:
*params = limits->MaxNativeTemps;
return;
case GL_PROGRAM_PARAMETERS_ARB:
- *params = prog->NumParameters;
+ *params = prog->arb.NumParameters;
return;
case GL_MAX_PROGRAM_PARAMETERS_ARB:
*params = limits->MaxParameters;
return;
case GL_PROGRAM_NATIVE_PARAMETERS_ARB:
- *params = prog->NumNativeParameters;
+ *params = prog->arb.NumNativeParameters;
return;
case GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB:
*params = limits->MaxNativeParameters;
return;
case GL_PROGRAM_ATTRIBS_ARB:
- *params = prog->NumAttributes;
+ *params = prog->arb.NumAttributes;
return;
case GL_MAX_PROGRAM_ATTRIBS_ARB:
*params = limits->MaxAttribs;
return;
case GL_PROGRAM_NATIVE_ATTRIBS_ARB:
- *params = prog->NumNativeAttributes;
+ *params = prog->arb.NumNativeAttributes;
return;
case GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB:
*params = limits->MaxNativeAttribs;
return;
case GL_PROGRAM_ADDRESS_REGISTERS_ARB:
- *params = prog->NumAddressRegs;
+ *params = prog->arb.NumAddressRegs;
return;
case GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB:
*params = limits->MaxAddressRegs;
return;
case GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB:
- *params = prog->NumNativeAddressRegs;
+ *params = prog->arb.NumNativeAddressRegs;
return;
case GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB:
*params = limits->MaxNativeAddressRegs;
@@ -780,22 +779,22 @@ _mesa_GetProgramivARB(GLenum target, GLenum pname, GLint *params)
const struct gl_program *fp = ctx->FragmentProgram.Current;
switch (pname) {
case GL_PROGRAM_ALU_INSTRUCTIONS_ARB:
- *params = fp->NumNativeAluInstructions;
+ *params = fp->arb.NumNativeAluInstructions;
return;
case GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB:
- *params = fp->NumAluInstructions;
+ *params = fp->arb.NumAluInstructions;
return;
case GL_PROGRAM_TEX_INSTRUCTIONS_ARB:
- *params = fp->NumTexInstructions;
+ *params = fp->arb.NumTexInstructions;
return;
case GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB:
- *params = fp->NumNativeTexInstructions;
+ *params = fp->arb.NumNativeTexInstructions;
return;
case GL_PROGRAM_TEX_INDIRECTIONS_ARB:
- *params = fp->NumTexIndirections;
+ *params = fp->arb.NumTexIndirections;
return;
case GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB:
- *params = fp->NumNativeTexIndirections;
+ *params = fp->arb.NumNativeTexIndirections;
return;
case GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB:
*params = limits->MaxAluInstructions;
diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
index 5bc64f18c74..c917b41e9dc 100644
--- a/src/mesa/main/ffvertex_prog.c
+++ b/src/mesa/main/ffvertex_prog.c
@@ -383,8 +383,8 @@ static struct ureg get_temp( struct tnl_program *p )
exit(1);
}
- if ((GLuint) bit > p->program->NumTemporaries)
- p->program->NumTemporaries = bit;
+ if ((GLuint) bit > p->program->arb.NumTemporaries)
+ p->program->arb.NumTemporaries = bit;
p->temp_in_use |= 1<<(bit-1);
return make_ureg(PROGRAM_TEMPORARY, bit-1);
@@ -577,9 +577,9 @@ static void emit_op3fn(struct tnl_program *p,
GLuint nr;
struct prog_instruction *inst;
- assert(p->program->NumInstructions <= p->max_inst);
+ assert(p->program->arb.NumInstructions <= p->max_inst);
- if (p->program->NumInstructions == p->max_inst) {
+ if (p->program->arb.NumInstructions == p->max_inst) {
/* need to extend the program's instruction array */
struct prog_instruction *newInst;
@@ -593,17 +593,17 @@ static void emit_op3fn(struct tnl_program *p,
return;
}
- _mesa_copy_instructions(newInst, p->program->Instructions,
- p->program->NumInstructions);
+ _mesa_copy_instructions(newInst, p->program->arb.Instructions,
+ p->program->arb.NumInstructions);
- ralloc_free(p->program->Instructions);
+ ralloc_free(p->program->arb.Instructions);
- p->program->Instructions = newInst;
+ p->program->arb.Instructions = newInst;
}
- nr = p->program->NumInstructions++;
+ nr = p->program->arb.NumInstructions++;
- inst = &p->program->Instructions[nr];
+ inst = &p->program->arb.Instructions[nr];
inst->Opcode = (enum prog_opcode) op;
emit_arg( &inst->SrcReg[0], src0 );
@@ -1632,13 +1632,13 @@ create_new_program( const struct state_key *key,
* If we need more, we'll grow the instruction array as needed.
*/
p.max_inst = 32;
- p.program->Instructions = rzalloc_array(program, struct prog_instruction,
- p.max_inst);
+ p.program->arb.Instructions =
+ rzalloc_array(program, struct prog_instruction, p.max_inst);
p.program->String = NULL;
- p.program->NumInstructions =
- p.program->NumTemporaries =
- p.program->NumParameters =
- p.program->NumAttributes = p.program->NumAddressRegs = 0;
+ p.program->arb.NumInstructions =
+ p.program->arb.NumTemporaries =
+ p.program->arb.NumParameters =
+ p.program->arb.NumAttributes = p.program->arb.NumAddressRegs = 0;
p.program->Parameters = _mesa_new_parameter_list();
p.program->info.inputs_read = 0;
p.program->info.outputs_written = 0;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 66bc07e5963..d2c1e583004 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1921,8 +1921,6 @@ struct gl_program
GLenum Target; /**< GL_VERTEX/FRAGMENT_PROGRAM_ARB, GL_GEOMETRY_PROGRAM_NV */
GLenum Format; /**< String encoding format */
- struct prog_instruction *Instructions;
-
struct nir_shader *nir;
GLbitfield64 SecondaryOutputsWritten; /**< Subset of OutputsWritten outputs written with non-zero index. */
@@ -1942,50 +1940,57 @@ struct gl_program
/** Named parameters, constants, etc. from program text */
struct gl_program_parameter_list *Parameters;
- /**
- * Local parameters used by the program.
- *
- * It's dynamically allocated because it is rarely used (just
- * assembly-style programs), and MAX_PROGRAM_LOCAL_PARAMS entries once it's
- * allocated.
- */
- GLfloat (*LocalParams)[4];
-
/** Map from sampler unit to texture unit (set by glUniform1i()) */
GLubyte SamplerUnits[MAX_SAMPLERS];
- /** Bitmask of which register files are read/written with indirect
- * addressing. Mask of (1 << PROGRAM_x) bits.
- */
- GLbitfield IndirectRegisterFiles;
-
- /** Logical counts */
- /*@{*/
- GLuint NumInstructions;
- GLuint NumTemporaries;
- GLuint NumParameters;
- GLuint NumAttributes;
- GLuint NumAddressRegs;
- GLuint NumAluInstructions;
- GLuint NumTexInstructions;
- GLuint NumTexIndirections;
- /*@}*/
- /** Native, actual h/w counts */
- /*@{*/
- GLuint NumNativeInstructions;
- GLuint NumNativeTemporaries;
- GLuint NumNativeParameters;
- GLuint NumNativeAttributes;
- GLuint NumNativeAddressRegs;
- GLuint NumNativeAluInstructions;
- GLuint NumNativeTexInstructions;
- GLuint NumNativeTexIndirections;
- /*@}*/
-
- /** Used by ARB assembly-style programs. Can only be true for vertex
- * programs.
- */
- GLboolean IsPositionInvariant;
+ union {
+ /** ARB assembly-style program fields */
+ struct {
+ struct prog_instruction *Instructions;
+
+ /**
+ * Local parameters used by the program.
+ *
+ * It's dynamically allocated because it is rarely used (just
+ * assembly-style programs), and MAX_PROGRAM_LOCAL_PARAMS entries
+ * once it's allocated.
+ */
+ GLfloat (*LocalParams)[4];
+
+ /** Bitmask of which register files are read/written with indirect
+ * addressing. Mask of (1 << PROGRAM_x) bits.
+ */
+ GLbitfield IndirectRegisterFiles;
+
+ /** Logical counts */
+ /*@{*/
+ GLuint NumInstructions;
+ GLuint NumTemporaries;
+ GLuint NumParameters;
+ GLuint NumAttributes;
+ GLuint NumAddressRegs;
+ GLuint NumAluInstructions;
+ GLuint NumTexInstructions;
+ GLuint NumTexIndirections;
+ /*@}*/
+ /** Native, actual h/w counts */
+ /*@{*/
+ GLuint NumNativeInstructions;
+ GLuint NumNativeTemporaries;
+ GLuint NumNativeParameters;
+ GLuint NumNativeAttributes;
+ GLuint NumNativeAddressRegs;
+ GLuint NumNativeAluInstructions;
+ GLuint NumNativeTexInstructions;
+ GLuint NumNativeTexIndirections;
+ /*@}*/
+
+ /** Used by ARB assembly-style programs. Can only be true for vertex
+ * programs.
+ */
+ GLboolean IsPositionInvariant;
+ } arb;
+ };
};
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 721f0ef48a9..42956fd5d91 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -70,9 +70,9 @@ update_program_enables(struct gl_context *ctx)
* GLSL shaders not relevant here.
*/
ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled
- && ctx->VertexProgram.Current->Instructions;
+ && ctx->VertexProgram.Current->arb.Instructions;
ctx->FragmentProgram._Enabled = ctx->FragmentProgram.Enabled
- && ctx->FragmentProgram.Current->Instructions;
+ && ctx->FragmentProgram.Current->arb.Instructions;
ctx->ATIFragmentShader._Enabled = ctx->ATIFragmentShader.Enabled
&& ctx->ATIFragmentShader.Current->Instructions[0];
}