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/main | |
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/main')
-rw-r--r-- | src/mesa/main/arbprogram.c | 51 | ||||
-rw-r--r-- | src/mesa/main/context.c | 8 | ||||
-rw-r--r-- | src/mesa/main/ffvertex_prog.c | 5 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 33 | ||||
-rw-r--r-- | src/mesa/main/shared.c | 5 | ||||
-rw-r--r-- | src/mesa/main/state.c | 46 | ||||
-rw-r--r-- | src/mesa/main/state.h | 2 | ||||
-rw-r--r-- | src/mesa/main/texstate.c | 2 |
8 files changed, 64 insertions, 88 deletions
diff --git a/src/mesa/main/arbprogram.c b/src/mesa/main/arbprogram.c index 0b6f7cbc2d6..9c7622ad5e5 100644 --- a/src/mesa/main/arbprogram.c +++ b/src/mesa/main/arbprogram.c @@ -63,7 +63,7 @@ _mesa_BindProgramARB(GLenum target, GLuint id) } else if (target == GL_FRAGMENT_PROGRAM_ARB && ctx->Extensions.ARB_fragment_program) { - curProg = &ctx->FragmentProgram.Current->Base; + curProg = ctx->FragmentProgram.Current; } else { _mesa_error(ctx, GL_INVALID_ENUM, "glBindProgramARB(target)"); @@ -81,7 +81,7 @@ _mesa_BindProgramARB(GLenum target, GLuint id) if (target == GL_VERTEX_PROGRAM_ARB) newProg = ctx->Shared->DefaultVertexProgram; else - newProg = &ctx->Shared->DefaultFragmentProgram->Base; + newProg = ctx->Shared->DefaultFragmentProgram; } else { /* Bind a user program */ @@ -117,8 +117,7 @@ _mesa_BindProgramARB(GLenum target, GLuint id) _mesa_reference_program(ctx, &ctx->VertexProgram.Current, newProg); } else if (target == GL_FRAGMENT_PROGRAM_ARB) { - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, - gl_fragment_program(newProg)); + _mesa_reference_program(ctx, &ctx->FragmentProgram.Current, newProg); } /* Never null pointers */ @@ -166,7 +165,7 @@ _mesa_DeleteProgramsARB(GLsizei n, const GLuint *ids) break; case GL_FRAGMENT_PROGRAM_ARB: if (ctx->FragmentProgram.Current && - ctx->FragmentProgram.Current->Base.Id == ids[i]) { + ctx->FragmentProgram.Current->Id == ids[i]) { /* unbind this currently bound program */ _mesa_BindProgramARB(prog->Target, 0); } @@ -261,7 +260,7 @@ get_local_param_pointer(struct gl_context *ctx, const char *func, } else if (target == GL_FRAGMENT_PROGRAM_ARB && ctx->Extensions.ARB_fragment_program) { - prog = &(ctx->FragmentProgram.Current->Base); + prog = ctx->FragmentProgram.Current; maxParams = ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxLocalParams; } else { @@ -317,7 +316,7 @@ void GLAPIENTRY _mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len, const GLvoid *string) { - struct gl_program *base; + struct gl_program *prog; bool failed; GET_CURRENT_CONTEXT(ctx); @@ -335,17 +334,13 @@ _mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len, } if (target == GL_VERTEX_PROGRAM_ARB && ctx->Extensions.ARB_vertex_program) { - struct gl_program *prog = ctx->VertexProgram.Current; + prog = ctx->VertexProgram.Current; _mesa_parse_arb_vertex_program(ctx, target, string, len, prog); - - base = prog; } else if (target == GL_FRAGMENT_PROGRAM_ARB && ctx->Extensions.ARB_fragment_program) { - struct gl_fragment_program *prog = ctx->FragmentProgram.Current; + prog = ctx->FragmentProgram.Current; _mesa_parse_arb_fragment_program(ctx, target, string, len, prog); - - base = & prog->Base; } else { _mesa_error(ctx, GL_INVALID_ENUM, "glProgramStringARB(target)"); @@ -356,7 +351,7 @@ _mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len, if (!failed) { /* finally, give the program to the driver for translation/checking */ - if (!ctx->Driver.ProgramStringNotify(ctx, target, base)) { + if (!ctx->Driver.ProgramStringNotify(ctx, target, prog)) { failed = true; _mesa_error(ctx, GL_INVALID_OPERATION, "glProgramStringARB(rejected by driver"); @@ -368,16 +363,16 @@ _mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len, target == GL_FRAGMENT_PROGRAM_ARB ? "fragment" : "vertex"; fprintf(stderr, "ARB_%s_program source for program %d:\n", - shader_type, base->Id); + shader_type, prog->Id); fprintf(stderr, "%s\n", (const char *) string); if (failed) { fprintf(stderr, "ARB_%s_program %d failed to compile.\n", - shader_type, base->Id); + shader_type, prog->Id); } else { fprintf(stderr, "Mesa IR for ARB_%s_program %d:\n", - shader_type, base->Id); - _mesa_print_program(base); + shader_type, prog->Id); + _mesa_print_program(prog); fprintf(stderr, "\n"); } fflush(stderr); @@ -392,7 +387,7 @@ _mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len, target == GL_FRAGMENT_PROGRAM_ARB ? "fragment" : "vertex"; _mesa_snprintf(filename, sizeof(filename), "%s/%cp-%u.shader_test", - capture_path, shader_type[0], base->Id); + capture_path, shader_type[0], prog->Id); file = fopen(filename, "w"); if (file) { fprintf(file, @@ -661,7 +656,7 @@ _mesa_GetProgramivARB(GLenum target, GLenum pname, GLint *params) } else if (target == GL_FRAGMENT_PROGRAM_ARB && ctx->Extensions.ARB_fragment_program) { - prog = &(ctx->FragmentProgram.Current->Base); + prog = ctx->FragmentProgram.Current; limits = &ctx->Const.Program[MESA_SHADER_FRAGMENT]; } else { @@ -780,25 +775,25 @@ _mesa_GetProgramivARB(GLenum target, GLenum pname, GLint *params) * The following apply to fragment programs only (at this time) */ if (target == GL_FRAGMENT_PROGRAM_ARB) { - const struct gl_fragment_program *fp = ctx->FragmentProgram.Current; + const struct gl_program *fp = ctx->FragmentProgram.Current; switch (pname) { case GL_PROGRAM_ALU_INSTRUCTIONS_ARB: - *params = fp->Base.NumNativeAluInstructions; + *params = fp->NumNativeAluInstructions; return; case GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB: - *params = fp->Base.NumAluInstructions; + *params = fp->NumAluInstructions; return; case GL_PROGRAM_TEX_INSTRUCTIONS_ARB: - *params = fp->Base.NumTexInstructions; + *params = fp->NumTexInstructions; return; case GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB: - *params = fp->Base.NumNativeTexInstructions; + *params = fp->NumNativeTexInstructions; return; case GL_PROGRAM_TEX_INDIRECTIONS_ARB: - *params = fp->Base.NumTexIndirections; + *params = fp->NumTexIndirections; return; case GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB: - *params = fp->Base.NumNativeTexIndirections; + *params = fp->NumNativeTexIndirections; return; case GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB: *params = limits->MaxAluInstructions; @@ -840,7 +835,7 @@ _mesa_GetProgramStringARB(GLenum target, GLenum pname, GLvoid *string) prog = ctx->VertexProgram.Current; } else if (target == GL_FRAGMENT_PROGRAM_ARB) { - prog = &(ctx->FragmentProgram.Current->Base); + prog = ctx->FragmentProgram.Current; } else { _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramStringARB(target)"); diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 1ae1ab5d5a2..44b315eec65 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -743,7 +743,7 @@ check_context_limits(struct gl_context *ctx) assert(VARYING_SLOT_MAX <= (8 * sizeof(ctx->VertexProgram._Current->OutputsWritten))); assert(VARYING_SLOT_MAX <= - (8 * sizeof(ctx->FragmentProgram._Current->Base.InputsRead))); + (8 * sizeof(ctx->FragmentProgram._Current->InputsRead))); /* shader-related checks */ assert(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxLocalParams <= MAX_PROGRAM_LOCAL_PARAMS); @@ -1301,9 +1301,9 @@ _mesa_free_context_data( struct gl_context *ctx ) _mesa_reference_program(ctx, &ctx->TessEvalProgram._Current, NULL); _mesa_reference_program(ctx, &ctx->GeometryProgram._Current, NULL); - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, NULL); - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL); - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, NULL); + _mesa_reference_program(ctx, &ctx->FragmentProgram.Current, NULL); + _mesa_reference_program(ctx, &ctx->FragmentProgram._Current, NULL); + _mesa_reference_program(ctx, &ctx->FragmentProgram._TexEnvProgram, NULL); _mesa_reference_vao(ctx, &ctx->Array.VAO, NULL); _mesa_reference_vao(ctx, &ctx->Array.DefaultVAO, NULL); diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c index 15997ccfdca..b318793fbb4 100644 --- a/src/mesa/main/ffvertex_prog.c +++ b/src/mesa/main/ffvertex_prog.c @@ -148,11 +148,10 @@ static GLboolean check_active_shininess( struct gl_context *ctx, static void make_state_key( struct gl_context *ctx, struct state_key *key ) { - const struct gl_fragment_program *fp; + const struct gl_program *fp = ctx->FragmentProgram._Current; GLbitfield mask; memset(key, 0, sizeof(struct state_key)); - fp = ctx->FragmentProgram._Current; /* This now relies on texenvprogram.c being active: */ @@ -160,7 +159,7 @@ static void make_state_key( struct gl_context *ctx, struct state_key *key ) key->need_eye_coords = ctx->_NeedEyeCoords; - key->fragprog_inputs_read = fp->Base.InputsRead; + key->fragprog_inputs_read = fp->InputsRead; key->varying_vp_inputs = ctx->varying_vp_inputs; if (ctx->RenderMode == GL_FEEDBACK) { diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 261995e98fd..f03f64e129e 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1937,13 +1937,13 @@ struct gl_program GLboolean UsesGather; /**< Does this program use gather4 at all? */ - /** - * For vertex and geometry shaders, true if the program uses the - * gl_ClipDistance output. Ignored for fragment shaders. - */ + /* Vertex and geometry shaders fields */ unsigned ClipDistanceArraySize; unsigned CullDistanceArraySize; + /* Fragement shader only fields */ + GLboolean OriginUpperLeft; + GLboolean PixelCenterInteger; /** Named parameters, constants, etc. from program text */ struct gl_program_parameter_list *Parameters; @@ -1995,23 +1995,6 @@ struct gl_program }; -/** Fragment program object */ -struct gl_fragment_program -{ - struct gl_program Base; /**< base class */ - GLboolean UsesKill; /**< shader uses KIL instruction */ - GLboolean OriginUpperLeft; - GLboolean PixelCenterInteger; - enum gl_frag_depth_layout FragDepthLayout; - - /** - * Bitfield indicating, for each fragment shader input, 1 if that input - * uses sample interpolation, 0 otherwise. Unused inputs are 0. - */ - GLbitfield64 IsSample; -}; - - /** * State common to vertex and fragment programs. */ @@ -2095,13 +2078,13 @@ struct gl_fragment_program_state { GLboolean Enabled; /**< User-set fragment program enable flag */ GLboolean _Enabled; /**< Enabled and _valid_ user program? */ - struct gl_fragment_program *Current; /**< User-bound fragment program */ + struct gl_program *Current; /**< User-bound fragment program */ /** Currently enabled and valid fragment program (including internal * programs, user-defined fragment programs and GLSL fragment shaders). * This is the program we must use when rendering. */ - struct gl_fragment_program *_Current; + struct gl_program *_Current; GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */ @@ -2109,7 +2092,7 @@ struct gl_fragment_program_state GLboolean _MaintainTexEnvProgram; /** Program to emulate fixed-function texture env/combine (see above) */ - struct gl_fragment_program *_TexEnvProgram; + struct gl_program *_TexEnvProgram; /** Cache of fixed-function programs */ struct gl_program_cache *Cache; @@ -3063,7 +3046,7 @@ struct gl_shared_state /*@{*/ struct _mesa_HashTable *Programs; /**< All vertex/fragment programs */ struct gl_program *DefaultVertexProgram; - struct gl_fragment_program *DefaultFragmentProgram; + struct gl_program *DefaultFragmentProgram; /*@}*/ /* GL_ATI_fragment_shader */ diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c index 5ff0b69764f..04e54439a84 100644 --- a/src/mesa/main/shared.c +++ b/src/mesa/main/shared.c @@ -72,8 +72,7 @@ _mesa_alloc_shared_state(struct gl_context *ctx) shared->DefaultVertexProgram = ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0); shared->DefaultFragmentProgram = - gl_fragment_program(ctx->Driver.NewProgram(ctx, - GL_FRAGMENT_PROGRAM_ARB, 0)); + ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0); shared->ATIShaders = _mesa_NewHashTable(); shared->DefaultFragmentShader = _mesa_new_ati_fragment_shader(ctx, 0); @@ -332,7 +331,7 @@ free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared) _mesa_DeleteHashTable(shared->Programs); _mesa_reference_program(ctx, &shared->DefaultVertexProgram, NULL); - _mesa_reference_fragprog(ctx, &shared->DefaultFragmentProgram, NULL); + _mesa_reference_program(ctx, &shared->DefaultFragmentProgram, NULL); _mesa_HashDeleteAll(shared->ATIShaders, delete_fragshader_cb, ctx); _mesa_DeleteHashTable(shared->ATIShaders); diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 2f810b497b8..721f0ef48a9 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -72,7 +72,7 @@ update_program_enables(struct gl_context *ctx) ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled && ctx->VertexProgram.Current->Instructions; ctx->FragmentProgram._Enabled = ctx->FragmentProgram.Enabled - && ctx->FragmentProgram.Current->Base.Instructions; + && ctx->FragmentProgram.Current->Instructions; ctx->ATIFragmentShader._Enabled = ctx->ATIFragmentShader.Enabled && ctx->ATIFragmentShader.Current->Instructions[0]; } @@ -108,7 +108,7 @@ update_program(struct gl_context *ctx) const struct gl_shader_program *csProg = ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE]; const struct gl_program *prevVP = ctx->VertexProgram._Current; - const struct gl_fragment_program *prevFP = ctx->FragmentProgram._Current; + const struct gl_program *prevFP = ctx->FragmentProgram._Current; const struct gl_program *prevGP = ctx->GeometryProgram._Current; const struct gl_program *prevTCP = ctx->TessCtrlProgram._Current; const struct gl_program *prevTEP = ctx->TessEvalProgram._Current; @@ -138,20 +138,20 @@ update_program(struct gl_context *ctx) _mesa_reference_shader_program(ctx, &ctx->_Shader->_CurrentFragmentProgram, fsProg); - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, - gl_fragment_program(fsProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program)); - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, - NULL); + _mesa_reference_program(ctx, &ctx->FragmentProgram._Current, + fsProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program); + _mesa_reference_program(ctx, &ctx->FragmentProgram._TexEnvProgram, + NULL); } else if (ctx->FragmentProgram._Enabled) { /* Use user-defined fragment program */ _mesa_reference_shader_program(ctx, &ctx->_Shader->_CurrentFragmentProgram, NULL); - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, - ctx->FragmentProgram.Current); - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, - NULL); + _mesa_reference_program(ctx, &ctx->FragmentProgram._Current, + ctx->FragmentProgram.Current); + _mesa_reference_program(ctx, &ctx->FragmentProgram._TexEnvProgram, + NULL); } else if (ctx->ATIFragmentShader._Enabled && ctx->ATIFragmentShader.Current->Program) { @@ -159,10 +159,10 @@ update_program(struct gl_context *ctx) _mesa_reference_shader_program(ctx, &ctx->_Shader->_CurrentFragmentProgram, NULL); - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, - gl_fragment_program(ctx->ATIFragmentShader.Current->Program)); - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, - NULL); + _mesa_reference_program(ctx, &ctx->FragmentProgram._Current, + ctx->ATIFragmentShader.Current->Program); + _mesa_reference_program(ctx, &ctx->FragmentProgram._TexEnvProgram, + NULL); } else if (ctx->FragmentProgram._MaintainTexEnvProgram) { /* Use fragment program generated from fixed-function state */ @@ -171,16 +171,16 @@ update_program(struct gl_context *ctx) _mesa_reference_shader_program(ctx, &ctx->_Shader->_CurrentFragmentProgram, f); - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, - gl_fragment_program(f->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program)); - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, - gl_fragment_program(f->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program)); + _mesa_reference_program(ctx, &ctx->FragmentProgram._Current, + f->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program); + _mesa_reference_program(ctx, &ctx->FragmentProgram._TexEnvProgram, + f->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program); } else { /* No fragment program */ - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL); - _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, - NULL); + _mesa_reference_program(ctx, &ctx->FragmentProgram._Current, NULL); + _mesa_reference_program(ctx, &ctx->FragmentProgram._TexEnvProgram, + NULL); } if (gsProg && gsProg->LinkStatus @@ -258,7 +258,7 @@ update_program(struct gl_context *ctx) new_state |= _NEW_PROGRAM; if (ctx->Driver.BindProgram) { ctx->Driver.BindProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, - (struct gl_program *) ctx->FragmentProgram._Current); + ctx->FragmentProgram._Current); } } @@ -316,7 +316,7 @@ update_program_constants(struct gl_context *ctx) if (ctx->FragmentProgram._Current) { const struct gl_program_parameter_list *params = - ctx->FragmentProgram._Current->Base.Parameters; + ctx->FragmentProgram._Current->Parameters; if (params && params->StateFlags & ctx->NewState) { new_state |= _NEW_PROGRAM_CONSTANTS; } diff --git a/src/mesa/main/state.h b/src/mesa/main/state.h index 95cde32eac4..8b6f54b9ca8 100644 --- a/src/mesa/main/state.h +++ b/src/mesa/main/state.h @@ -66,7 +66,7 @@ _mesa_need_secondary_color(const struct gl_context *ctx) if (ctx->FragmentProgram._Current && (ctx->FragmentProgram._Current != ctx->FragmentProgram._TexEnvProgram) && - (ctx->FragmentProgram._Current->Base.InputsRead & VARYING_BIT_COL1)) + (ctx->FragmentProgram._Current->InputsRead & VARYING_BIT_COL1)) return GL_TRUE; return GL_FALSE; diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 94caf2a9ca8..95ea5bd58ee 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -705,7 +705,7 @@ update_texture_state( struct gl_context *ctx ) prog[i] = ctx->_Shader->CurrentProgram[i]->_LinkedShaders[i]->Program; } else { if (i == MESA_SHADER_FRAGMENT && ctx->FragmentProgram._Enabled) - prog[i] = &ctx->FragmentProgram.Current->Base; + prog[i] = ctx->FragmentProgram.Current; else prog[i] = NULL; } |