diff options
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/arbprogram.c | 4 | ||||
-rw-r--r-- | src/mesa/main/ffvertex_prog.c | 7 | ||||
-rw-r--r-- | src/mesa/main/nvprogram.c | 21 | ||||
-rw-r--r-- | src/mesa/main/shared.c | 10 | ||||
-rw-r--r-- | src/mesa/main/state.c | 15 | ||||
-rw-r--r-- | src/mesa/program/program.c | 29 |
6 files changed, 37 insertions, 49 deletions
diff --git a/src/mesa/main/arbprogram.c b/src/mesa/main/arbprogram.c index b83369d9e04..ae91fd5a323 100644 --- a/src/mesa/main/arbprogram.c +++ b/src/mesa/main/arbprogram.c @@ -138,12 +138,12 @@ _mesa_BindProgram(GLenum target, GLuint id) /* bind newProg */ if (target == GL_VERTEX_PROGRAM_ARB) { /* == GL_VERTEX_PROGRAM_NV */ _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, - (struct gl_vertex_program *) newProg); + gl_vertex_program(newProg)); } else if (target == GL_FRAGMENT_PROGRAM_NV || target == GL_FRAGMENT_PROGRAM_ARB) { _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, - (struct gl_fragment_program *) newProg); + gl_fragment_program(newProg)); } /* Never null pointers */ diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c index 5577683115a..e8a11d006d1 100644 --- a/src/mesa/main/ffvertex_prog.c +++ b/src/mesa/main/ffvertex_prog.c @@ -1672,16 +1672,15 @@ _mesa_get_fixed_func_vertex_program(struct gl_context *ctx) /* Look for an already-prepared program for this state: */ - prog = (struct gl_vertex_program *) - _mesa_search_program_cache(ctx->VertexProgram.Cache, &key, sizeof(key)); + prog = gl_vertex_program( + _mesa_search_program_cache(ctx->VertexProgram.Cache, &key, sizeof(key))); if (!prog) { /* OK, we'll have to build a new one */ if (0) printf("Build new TNL program\n"); - prog = (struct gl_vertex_program *) - ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0); + prog = gl_vertex_program(ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0)); if (!prog) return NULL; diff --git a/src/mesa/main/nvprogram.c b/src/mesa/main/nvprogram.c index dae11566e39..fc5749afc8a 100644 --- a/src/mesa/main/nvprogram.c +++ b/src/mesa/main/nvprogram.c @@ -71,7 +71,7 @@ _mesa_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params) FLUSH_VERTICES(ctx, _NEW_PROGRAM); - vprog = (struct gl_vertex_program *) _mesa_lookup_program(ctx, id); + vprog = gl_vertex_program(_mesa_lookup_program(ctx, id)); if (!vprog || vprog->Base.Target != GL_VERTEX_STATE_PROGRAM_NV) { _mesa_error(ctx, GL_INVALID_OPERATION, "glExecuteProgramNV"); @@ -627,10 +627,9 @@ _mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len, if ((target == GL_VERTEX_PROGRAM_NV || target == GL_VERTEX_STATE_PROGRAM_NV) && ctx->Extensions.NV_vertex_program) { - struct gl_vertex_program *vprog = (struct gl_vertex_program *) prog; + struct gl_vertex_program *vprog = gl_vertex_program(prog); if (!vprog || prog == &_mesa_DummyProgram) { - vprog = (struct gl_vertex_program *) - ctx->Driver.NewProgram(ctx, target, id); + vprog = gl_vertex_program(ctx->Driver.NewProgram(ctx, target, id)); if (!vprog) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); return; @@ -647,10 +646,9 @@ _mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len, } else if (target == GL_FRAGMENT_PROGRAM_NV && ctx->Extensions.NV_fragment_program) { - struct gl_fragment_program *fprog = (struct gl_fragment_program *) prog; + struct gl_fragment_program *fprog = gl_fragment_program(prog); if (!fprog || prog == &_mesa_DummyProgram) { - fprog = (struct gl_fragment_program *) - ctx->Driver.NewProgram(ctx, target, id); + fprog = gl_fragment_program(ctx->Driver.NewProgram(ctx, target, id)); if (!fprog) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); return; @@ -661,10 +659,9 @@ _mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len, } else if (target == GL_FRAGMENT_PROGRAM_ARB && ctx->Extensions.ARB_fragment_program) { - struct gl_fragment_program *fprog = (struct gl_fragment_program *) prog; + struct gl_fragment_program *fprog = gl_fragment_program(prog); if (!fprog || prog == &_mesa_DummyProgram) { - fprog = (struct gl_fragment_program *) - ctx->Driver.NewProgram(ctx, target, id); + fprog = gl_fragment_program(ctx->Driver.NewProgram(ctx, target, id)); if (!fprog) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); return; @@ -830,7 +827,7 @@ _mesa_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name, return; } - fragProg = (struct gl_fragment_program *) prog; + fragProg = gl_fragment_program(prog); v = _mesa_lookup_parameter_value(fragProg->Base.Parameters, len, (char *) name); if (v) { @@ -895,7 +892,7 @@ _mesa_GetProgramNamedParameterfvNV(GLuint id, GLsizei len, const GLubyte *name, return; } - fragProg = (struct gl_fragment_program *) prog; + fragProg = gl_fragment_program(prog); v = _mesa_lookup_parameter_value(fragProg->Base.Parameters, len, (char *) name); if (v) { diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c index 226947638ca..58cbc525065 100644 --- a/src/mesa/main/shared.c +++ b/src/mesa/main/shared.c @@ -71,13 +71,15 @@ _mesa_alloc_shared_state(struct gl_context *ctx) shared->Programs = _mesa_NewHashTable(); #if FEATURE_ARB_vertex_program - shared->DefaultVertexProgram = (struct gl_vertex_program *) - ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0); + shared->DefaultVertexProgram = + gl_vertex_program(ctx->Driver.NewProgram(ctx, + GL_VERTEX_PROGRAM_ARB, 0)); #endif #if FEATURE_ARB_fragment_program - shared->DefaultFragmentProgram = (struct gl_fragment_program *) - ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0); + shared->DefaultFragmentProgram = + gl_fragment_program(ctx->Driver.NewProgram(ctx, + GL_FRAGMENT_PROGRAM_ARB, 0)); #endif #if FEATURE_ATI_fragment_shader diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index db0cc30ec9d..76946bd93eb 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -134,8 +134,7 @@ update_program(struct gl_context *ctx) &ctx->Shader._CurrentFragmentProgram, fsProg); _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, - (struct gl_fragment_program *) - fsProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program); + gl_fragment_program(fsProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program)); _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, NULL); } @@ -157,11 +156,9 @@ update_program(struct gl_context *ctx) &ctx->Shader._CurrentFragmentProgram, f); _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, - (struct gl_fragment_program *) - f->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program); + gl_fragment_program(f->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program)); _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, - (struct gl_fragment_program *) - f->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program); + gl_fragment_program(f->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program)); } else { /* No fragment program */ @@ -174,8 +171,7 @@ update_program(struct gl_context *ctx) && gsProg->_LinkedShaders[MESA_SHADER_GEOMETRY]) { /* Use GLSL geometry shader */ _mesa_reference_geomprog(ctx, &ctx->GeometryProgram._Current, - (struct gl_geometry_program *) - gsProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program); + gl_geometry_program(gsProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program)); } else { /* No geometry program */ _mesa_reference_geomprog(ctx, &ctx->GeometryProgram._Current, NULL); @@ -189,8 +185,7 @@ update_program(struct gl_context *ctx) && vsProg->_LinkedShaders[MESA_SHADER_VERTEX]) { /* Use GLSL vertex shader */ _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, - (struct gl_vertex_program *) - vsProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program); + gl_vertex_program(vsProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program)); } else if (ctx->VertexProgram._Enabled) { /* Use user-defined vertex program */ diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c index 582cbccf8fa..23138eae85b 100644 --- a/src/mesa/program/program.c +++ b/src/mesa/program/program.c @@ -169,22 +169,19 @@ _mesa_update_default_objects_program(struct gl_context *ctx) { #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, - (struct gl_vertex_program *) ctx->Shared->DefaultVertexProgram); assert(ctx->VertexProgram.Current); #endif #if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, - (struct gl_fragment_program *) ctx->Shared->DefaultFragmentProgram); assert(ctx->FragmentProgram.Current); #endif #if FEATURE_ARB_geometry_shader4 _mesa_reference_geomprog(ctx, &ctx->GeometryProgram.Current, - (struct gl_geometry_program *) - ctx->Shared->DefaultGeometryProgram); + ctx->Shared->DefaultGeometryProgram); #endif /* XXX probably move this stuff */ @@ -538,18 +535,16 @@ _mesa_clone_program(struct gl_context *ctx, const struct gl_program *prog) switch (prog->Target) { case GL_VERTEX_PROGRAM_ARB: { - const struct gl_vertex_program *vp - = (const struct gl_vertex_program *) prog; - struct gl_vertex_program *vpc = (struct gl_vertex_program *) clone; + const struct gl_vertex_program *vp = gl_vertex_program_const(prog); + struct gl_vertex_program *vpc = gl_vertex_program(clone); vpc->IsPositionInvariant = vp->IsPositionInvariant; vpc->IsNVProgram = vp->IsNVProgram; } break; case GL_FRAGMENT_PROGRAM_ARB: { - const struct gl_fragment_program *fp - = (const struct gl_fragment_program *) prog; - struct gl_fragment_program *fpc = (struct gl_fragment_program *) clone; + const struct gl_fragment_program *fp = gl_fragment_program_const(prog); + struct gl_fragment_program *fpc = gl_fragment_program(clone); fpc->UsesKill = fp->UsesKill; fpc->OriginUpperLeft = fp->OriginUpperLeft; fpc->PixelCenterInteger = fp->PixelCenterInteger; @@ -557,9 +552,8 @@ _mesa_clone_program(struct gl_context *ctx, const struct gl_program *prog) break; case MESA_GEOMETRY_PROGRAM: { - const struct gl_geometry_program *gp - = (const struct gl_geometry_program *) prog; - struct gl_geometry_program *gpc = (struct gl_geometry_program *) clone; + const struct gl_geometry_program *gp = gl_geometry_program_const(prog); + struct gl_geometry_program *gpc = gl_geometry_program(clone); gpc->VerticesOut = gp->VerticesOut; gpc->InputType = gp->InputType; gpc->OutputType = gp->OutputType; @@ -763,13 +757,14 @@ _mesa_combine_programs(struct gl_context *ctx, usedTemps, MAX_PROGRAM_TEMPS); if (newProg->Target == GL_FRAGMENT_PROGRAM_ARB) { - struct gl_fragment_program *fprogA, *fprogB, *newFprog; + const struct gl_fragment_program *fprogA, *fprogB; + struct gl_fragment_program *newFprog; GLbitfield progB_inputsRead = progB->InputsRead; GLint progB_colorFile, progB_colorIndex; - fprogA = (struct gl_fragment_program *) progA; - fprogB = (struct gl_fragment_program *) progB; - newFprog = (struct gl_fragment_program *) newProg; + fprogA = gl_fragment_program_const(progA); + fprogB = gl_fragment_program_const(progB); + newFprog = gl_fragment_program(newProg); newFprog->UsesKill = fprogA->UsesKill || fprogB->UsesKill; |