diff options
author | Timothy Arceri <[email protected]> | 2016-10-19 13:23:37 +1100 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2016-10-26 14:29:36 +1100 |
commit | 3423488d55b9c483fcdb3996eb89b424c1031d24 (patch) | |
tree | 270d90fe3fd4c090f2c8e59a3b20d0afe7d98e72 /src/mesa/program | |
parent | 17e28a1571b6141368fefc84cc8b0a3b4e52f8ee (diff) |
st/mesa/r200/i915/i965: eliminate gl_fragment_program
Here we move OriginUpperLeft and PixelCenterInteger into gl_program
all other fields have been replace by shader_info.
V2: Don't use anonymous union/structs to hold vertex/fragment fields
suggested by Ian.
Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/mesa/program')
-rw-r--r-- | src/mesa/program/arbprogparse.c | 64 | ||||
-rw-r--r-- | src/mesa/program/arbprogparse.h | 5 | ||||
-rw-r--r-- | src/mesa/program/ir_to_mesa.cpp | 6 | ||||
-rw-r--r-- | src/mesa/program/prog_statevars.c | 8 | ||||
-rw-r--r-- | src/mesa/program/prog_to_nir.c | 7 | ||||
-rw-r--r-- | src/mesa/program/program.c | 21 | ||||
-rw-r--r-- | src/mesa/program/program.h | 24 | ||||
-rw-r--r-- | src/mesa/program/programopt.c | 31 | ||||
-rw-r--r-- | src/mesa/program/programopt.h | 5 |
9 files changed, 69 insertions, 102 deletions
diff --git a/src/mesa/program/arbprogparse.c b/src/mesa/program/arbprogparse.c index 82bdd133024..51cefe33faa 100644 --- a/src/mesa/program/arbprogparse.c +++ b/src/mesa/program/arbprogparse.c @@ -67,7 +67,7 @@ having three separate program parameter arrays. void _mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target, const GLvoid *str, GLsizei len, - struct gl_fragment_program *program) + struct gl_program *program) { struct gl_program prog; struct asm_parser_state state; @@ -85,48 +85,48 @@ _mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target, return; } - free(program->Base.String); + free(program->String); /* Copy the relevant contents of the arb_program struct into the * fragment_program struct. */ - program->Base.String = prog.String; - program->Base.NumInstructions = prog.NumInstructions; - program->Base.NumTemporaries = prog.NumTemporaries; - program->Base.NumParameters = prog.NumParameters; - program->Base.NumAttributes = prog.NumAttributes; - program->Base.NumAddressRegs = prog.NumAddressRegs; - program->Base.NumNativeInstructions = prog.NumNativeInstructions; - program->Base.NumNativeTemporaries = prog.NumNativeTemporaries; - program->Base.NumNativeParameters = prog.NumNativeParameters; - program->Base.NumNativeAttributes = prog.NumNativeAttributes; - program->Base.NumNativeAddressRegs = prog.NumNativeAddressRegs; - program->Base.NumAluInstructions = prog.NumAluInstructions; - program->Base.NumTexInstructions = prog.NumTexInstructions; - program->Base.NumTexIndirections = prog.NumTexIndirections; - program->Base.NumNativeAluInstructions = prog.NumAluInstructions; - program->Base.NumNativeTexInstructions = prog.NumTexInstructions; - program->Base.NumNativeTexIndirections = prog.NumTexIndirections; - program->Base.InputsRead = prog.InputsRead; - program->Base.OutputsWritten = prog.OutputsWritten; - program->Base.IndirectRegisterFiles = prog.IndirectRegisterFiles; + 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->InputsRead = prog.InputsRead; + program->OutputsWritten = prog.OutputsWritten; + program->IndirectRegisterFiles = prog.IndirectRegisterFiles; for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++) { - program->Base.TexturesUsed[i] = prog.TexturesUsed[i]; + program->TexturesUsed[i] = prog.TexturesUsed[i]; if (prog.TexturesUsed[i]) - program->Base.SamplersUsed |= (1 << i); + program->SamplersUsed |= (1 << i); } - program->Base.ShadowSamplers = prog.ShadowSamplers; + program->ShadowSamplers = prog.ShadowSamplers; program->OriginUpperLeft = state.option.OriginUpperLeft; program->PixelCenterInteger = state.option.PixelCenterInteger; - program->Base.info.fs.uses_discard = state.fragment.UsesKill; + program->info.fs.uses_discard = state.fragment.UsesKill; - free(program->Base.Instructions); - program->Base.Instructions = prog.Instructions; + free(program->Instructions); + program->Instructions = prog.Instructions; - if (program->Base.Parameters) - _mesa_free_parameter_list(program->Base.Parameters); - program->Base.Parameters = prog.Parameters; + if (program->Parameters) + _mesa_free_parameter_list(program->Parameters); + program->Parameters = prog.Parameters; /* Append fog instructions now if the program has "OPTION ARB_fog_exp" * or similar. We used to leave this up to drivers, but it appears @@ -145,7 +145,7 @@ _mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target, } #if DEBUG_FP - printf("____________Fragment program %u ________\n", program->Base.Id); + printf("____________Fragment program %u ________\n", program->Id); _mesa_print_program(&program->Base); #endif } diff --git a/src/mesa/program/arbprogparse.h b/src/mesa/program/arbprogparse.h index 05d93f0370b..1c39a451d07 100644 --- a/src/mesa/program/arbprogparse.h +++ b/src/mesa/program/arbprogparse.h @@ -29,8 +29,7 @@ #include "main/glheader.h" struct gl_context; -struct gl_fragment_program; -struct gl_vertex_program; +struct gl_program; extern void _mesa_parse_arb_vertex_program(struct gl_context *ctx, GLenum target, @@ -40,6 +39,6 @@ _mesa_parse_arb_vertex_program(struct gl_context *ctx, GLenum target, extern void _mesa_parse_arb_fragment_program(struct gl_context *ctx, GLenum target, const GLvoid *str, GLsizei len, - struct gl_fragment_program *program); + struct gl_program *program); #endif diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 03af1165827..5776d15c8a6 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -601,10 +601,8 @@ void ir_to_mesa_visitor::visit(ir_variable *ir) { if (strcmp(ir->name, "gl_FragCoord") == 0) { - struct gl_fragment_program *fp = (struct gl_fragment_program *)this->prog; - - fp->OriginUpperLeft = ir->data.origin_upper_left; - fp->PixelCenterInteger = ir->data.pixel_center_integer; + this->prog->OriginUpperLeft = ir->data.origin_upper_left; + this->prog->PixelCenterInteger = ir->data.pixel_center_integer; } if (ir->data.mode == ir_var_uniform && strncmp(ir->name, "gl_", 3) == 0) { diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c index 110dfda3062..f1786e5ba42 100644 --- a/src/mesa/program/prog_statevars.c +++ b/src/mesa/program/prog_statevars.c @@ -373,14 +373,14 @@ _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->Base.LocalParams) { - ctx->FragmentProgram.Current->Base.LocalParams = + if (!ctx->FragmentProgram.Current->LocalParams) { + ctx->FragmentProgram.Current->LocalParams = calloc(MAX_PROGRAM_LOCAL_PARAMS, sizeof(float[4])); - if (!ctx->FragmentProgram.Current->Base.LocalParams) + if (!ctx->FragmentProgram.Current->LocalParams) return; } - COPY_4V(value, ctx->FragmentProgram.Current->Base.LocalParams[idx]); + COPY_4V(value, ctx->FragmentProgram.Current->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 fb34b3c1e2a..f3c735e65b1 100644 --- a/src/mesa/program/prog_to_nir.c +++ b/src/mesa/program/prog_to_nir.c @@ -901,12 +901,9 @@ setup_registers_and_variables(struct ptn_compile *c) var->data.index = 0; if (c->prog->Target == GL_FRAGMENT_PROGRAM_ARB) { - struct gl_fragment_program *fp = - (struct gl_fragment_program *) c->prog; - if (i == VARYING_SLOT_POS) { - var->data.origin_upper_left = fp->OriginUpperLeft; - var->data.pixel_center_integer = fp->PixelCenterInteger; + var->data.origin_upper_left = c->prog->OriginUpperLeft; + var->data.pixel_center_integer = c->prog->PixelCenterInteger; } else if (i == VARYING_SLOT_FOGC) { /* fogcoord is defined as <f, 0.0, 0.0, 1.0>. Make the actual * input variable a float, and create a local containing the diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c index 1d9eaa0c69a..4915a09170f 100644 --- a/src/mesa/program/program.c +++ b/src/mesa/program/program.c @@ -93,8 +93,8 @@ _mesa_init_program(struct gl_context *ctx) ctx->VertexProgram.Cache = _mesa_new_program_cache(); ctx->FragmentProgram.Enabled = GL_FALSE; - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, - ctx->Shared->DefaultFragmentProgram); + _mesa_reference_program(ctx, &ctx->FragmentProgram.Current, + ctx->Shared->DefaultFragmentProgram); assert(ctx->FragmentProgram.Current); ctx->FragmentProgram.Cache = _mesa_new_program_cache(); @@ -114,7 +114,7 @@ _mesa_free_program_data(struct gl_context *ctx) { _mesa_reference_program(ctx, &ctx->VertexProgram.Current, NULL); _mesa_delete_program_cache(ctx, ctx->VertexProgram.Cache); - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, NULL); + _mesa_reference_program(ctx, &ctx->FragmentProgram.Current, NULL); _mesa_delete_shader_cache(ctx, ctx->FragmentProgram.Cache); /* XXX probably move this stuff */ @@ -141,7 +141,7 @@ _mesa_update_default_objects_program(struct gl_context *ctx) ctx->Shared->DefaultVertexProgram); assert(ctx->VertexProgram.Current); - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, + _mesa_reference_program(ctx, &ctx->FragmentProgram.Current, ctx->Shared->DefaultFragmentProgram); assert(ctx->FragmentProgram.Current); @@ -215,14 +215,11 @@ struct gl_program * _mesa_new_program(struct gl_context *ctx, GLenum target, GLuint id) { switch (target) { - case GL_FRAGMENT_PROGRAM_ARB: { - struct gl_fragment_program *prog = CALLOC_STRUCT(gl_fragment_program); - return _mesa_init_gl_program(&prog->Base, target, id); - } case GL_VERTEX_PROGRAM_ARB: /* == GL_VERTEX_PROGRAM_NV */ case GL_GEOMETRY_PROGRAM_NV: case GL_TESS_CONTROL_PROGRAM_NV: case GL_TESS_EVALUATION_PROGRAM_NV: + case GL_FRAGMENT_PROGRAM_ARB: case GL_COMPUTE_PROGRAM_NV: { struct gl_program *prog = CALLOC_STRUCT(gl_program); return _mesa_init_gl_program(prog, target, id); @@ -502,7 +499,7 @@ _mesa_find_free_register(const GLboolean used[], */ GLint _mesa_get_min_invocations_per_fragment(struct gl_context *ctx, - const struct gl_fragment_program *prog, + const struct gl_program *prog, bool ignore_sample_qualifier) { /* From ARB_sample_shading specification: @@ -521,11 +518,11 @@ _mesa_get_min_invocations_per_fragment(struct gl_context *ctx, * "Use of the "sample" qualifier on a fragment shader input * forces per-sample shading" */ - if (prog->Base.info.fs.uses_sample_qualifier && !ignore_sample_qualifier) + if (prog->info.fs.uses_sample_qualifier && !ignore_sample_qualifier) return MAX2(_mesa_geometric_samples(ctx->DrawBuffer), 1); - if (prog->Base.SystemValuesRead & (SYSTEM_BIT_SAMPLE_ID | - SYSTEM_BIT_SAMPLE_POS)) + if (prog->SystemValuesRead & (SYSTEM_BIT_SAMPLE_ID | + SYSTEM_BIT_SAMPLE_POS)) return MAX2(_mesa_geometric_samples(ctx->DrawBuffer), 1); else if (ctx->Multisample.SampleShading) return MAX2(ceil(ctx->Multisample.MinSampleShadingValue * diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h index defeb2f2a0f..6460948044f 100644 --- a/src/mesa/program/program.h +++ b/src/mesa/program/program.h @@ -89,15 +89,6 @@ _mesa_reference_program(struct gl_context *ctx, _mesa_reference_program_(ctx, ptr, prog); } -static inline void -_mesa_reference_fragprog(struct gl_context *ctx, - struct gl_fragment_program **ptr, - struct gl_fragment_program *prog) -{ - _mesa_reference_program(ctx, (struct gl_program **) ptr, - (struct gl_program *) prog); -} - extern GLboolean _mesa_insert_instructions(struct gl_program *prog, GLuint start, GLuint count); @@ -115,7 +106,7 @@ _mesa_find_free_register(const GLboolean used[], extern GLint _mesa_get_min_invocations_per_fragment(struct gl_context *ctx, - const struct gl_fragment_program *prog, + const struct gl_program *prog, bool ignore_sample_qualifier); static inline GLuint @@ -165,19 +156,6 @@ _mesa_shader_stage_to_program(unsigned stage) return GL_VERTEX_PROGRAM_ARB; } - -static inline struct gl_fragment_program * -gl_fragment_program(struct gl_program *prog) -{ - return (struct gl_fragment_program *) prog; -} - -static inline const struct gl_fragment_program * -gl_fragment_program_const(const struct gl_program *prog) -{ - return (const struct gl_fragment_program *) prog; -} - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/mesa/program/programopt.c b/src/mesa/program/programopt.c index 4610035f291..f51005d13d5 100644 --- a/src/mesa/program/programopt.c +++ b/src/mesa/program/programopt.c @@ -244,16 +244,15 @@ _mesa_insert_mvp_code(struct gl_context *ctx, struct gl_program *vprog) * to vertex programs too. */ void -_mesa_append_fog_code(struct gl_context *ctx, - struct gl_fragment_program *fprog, GLenum fog_mode, - GLboolean saturate) +_mesa_append_fog_code(struct gl_context *ctx, struct gl_program *fprog, + GLenum fog_mode, GLboolean saturate) { static const gl_state_index fogPStateOpt[STATE_LENGTH] = { STATE_INTERNAL, STATE_FOG_PARAMS_OPTIMIZED, 0, 0, 0 }; static const gl_state_index fogColorState[STATE_LENGTH] = { STATE_FOG_COLOR, 0, 0, 0, 0}; struct prog_instruction *newInst, *inst; - const GLuint origLen = fprog->Base.NumInstructions; + const GLuint origLen = fprog->NumInstructions; const GLuint newLen = origLen + 5; GLuint i; GLint fogPRefOpt, fogColorRef; /* state references */ @@ -265,7 +264,7 @@ _mesa_append_fog_code(struct gl_context *ctx, return; } - if (!(fprog->Base.OutputsWritten & (1 << FRAG_RESULT_COLOR))) { + if (!(fprog->OutputsWritten & (1 << FRAG_RESULT_COLOR))) { /* program doesn't output color, so nothing to do */ return; } @@ -279,23 +278,23 @@ _mesa_append_fog_code(struct gl_context *ctx, } /* Copy orig instructions into new instruction buffer */ - _mesa_copy_instructions(newInst, fprog->Base.Instructions, origLen); + _mesa_copy_instructions(newInst, fprog->Instructions, origLen); /* PARAM fogParamsRefOpt = internal optimized fog params; */ fogPRefOpt - = _mesa_add_state_reference(fprog->Base.Parameters, fogPStateOpt); + = _mesa_add_state_reference(fprog->Parameters, fogPStateOpt); /* PARAM fogColorRef = state.fog.color; */ fogColorRef - = _mesa_add_state_reference(fprog->Base.Parameters, fogColorState); + = _mesa_add_state_reference(fprog->Parameters, fogColorState); /* TEMP colorTemp; */ - colorTemp = fprog->Base.NumTemporaries++; + colorTemp = fprog->NumTemporaries++; /* TEMP fogFactorTemp; */ - fogFactorTemp = fprog->Base.NumTemporaries++; + fogFactorTemp = fprog->NumTemporaries++; /* Scan program to find where result.color is written */ inst = newInst; - for (i = 0; i < fprog->Base.NumInstructions; i++) { + for (i = 0; i < fprog->NumInstructions; i++) { if (inst->Opcode == OPCODE_END) break; if (inst->DstReg.File == PROGRAM_OUTPUT && @@ -404,13 +403,13 @@ _mesa_append_fog_code(struct gl_context *ctx, inst++; /* free old instructions */ - _mesa_free_instructions(fprog->Base.Instructions, origLen); + _mesa_free_instructions(fprog->Instructions, origLen); /* install new instructions */ - fprog->Base.Instructions = newInst; - fprog->Base.NumInstructions = inst - newInst; - fprog->Base.InputsRead |= VARYING_BIT_FOGC; - assert(fprog->Base.OutputsWritten & (1 << FRAG_RESULT_COLOR)); + fprog->Instructions = newInst; + fprog->NumInstructions = inst - newInst; + fprog->InputsRead |= VARYING_BIT_FOGC; + assert(fprog->OutputsWritten & (1 << FRAG_RESULT_COLOR)); } diff --git a/src/mesa/program/programopt.h b/src/mesa/program/programopt.h index 2a76da4da5e..5d70e57bc33 100644 --- a/src/mesa/program/programopt.h +++ b/src/mesa/program/programopt.h @@ -38,9 +38,8 @@ extern void _mesa_insert_mvp_code(struct gl_context *ctx, struct gl_program *vprog); extern void -_mesa_append_fog_code(struct gl_context *ctx, - struct gl_fragment_program *fprog, GLenum fog_mode, - GLboolean saturate); +_mesa_append_fog_code(struct gl_context *ctx, struct gl_program *fprog, + GLenum fog_mode, GLboolean saturate); extern void _mesa_count_texture_indirections(struct gl_program *prog); |