summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/arbprogram.c19
-rw-r--r--src/mesa/main/context.c8
-rw-r--r--src/mesa/main/ff_fragment_shader.cpp2
-rw-r--r--src/mesa/main/ffvertex_prog.c72
-rw-r--r--src/mesa/main/ffvertex_prog.h2
-rw-r--r--src/mesa/main/mtypes.h19
-rw-r--r--src/mesa/main/shared.c5
-rw-r--r--src/mesa/main/state.c26
-rw-r--r--src/mesa/main/state.h2
9 files changed, 74 insertions, 81 deletions
diff --git a/src/mesa/main/arbprogram.c b/src/mesa/main/arbprogram.c
index 911b6fa3960..0b6f7cbc2d6 100644
--- a/src/mesa/main/arbprogram.c
+++ b/src/mesa/main/arbprogram.c
@@ -59,7 +59,7 @@ _mesa_BindProgramARB(GLenum target, GLuint id)
/* Error-check target and get curProg */
if (target == GL_VERTEX_PROGRAM_ARB && ctx->Extensions.ARB_vertex_program) {
- curProg = &ctx->VertexProgram.Current->Base;
+ curProg = ctx->VertexProgram.Current;
}
else if (target == GL_FRAGMENT_PROGRAM_ARB
&& ctx->Extensions.ARB_fragment_program) {
@@ -79,7 +79,7 @@ _mesa_BindProgramARB(GLenum target, GLuint id)
/* Bind a default program */
newProg = NULL;
if (target == GL_VERTEX_PROGRAM_ARB)
- newProg = &ctx->Shared->DefaultVertexProgram->Base;
+ newProg = ctx->Shared->DefaultVertexProgram;
else
newProg = &ctx->Shared->DefaultFragmentProgram->Base;
}
@@ -114,8 +114,7 @@ _mesa_BindProgramARB(GLenum target, GLuint id)
/* bind newProg */
if (target == GL_VERTEX_PROGRAM_ARB) {
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current,
- gl_vertex_program(newProg));
+ _mesa_reference_program(ctx, &ctx->VertexProgram.Current, newProg);
}
else if (target == GL_FRAGMENT_PROGRAM_ARB) {
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current,
@@ -160,7 +159,7 @@ _mesa_DeleteProgramsARB(GLsizei n, const GLuint *ids)
switch (prog->Target) {
case GL_VERTEX_PROGRAM_ARB:
if (ctx->VertexProgram.Current &&
- ctx->VertexProgram.Current->Base.Id == ids[i]) {
+ ctx->VertexProgram.Current->Id == ids[i]) {
/* unbind this currently bound program */
_mesa_BindProgramARB(prog->Target, 0);
}
@@ -257,7 +256,7 @@ get_local_param_pointer(struct gl_context *ctx, const char *func,
if (target == GL_VERTEX_PROGRAM_ARB
&& ctx->Extensions.ARB_vertex_program) {
- prog = &(ctx->VertexProgram.Current->Base);
+ prog = ctx->VertexProgram.Current;
maxParams = ctx->Const.Program[MESA_SHADER_VERTEX].MaxLocalParams;
}
else if (target == GL_FRAGMENT_PROGRAM_ARB
@@ -336,10 +335,10 @@ _mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
}
if (target == GL_VERTEX_PROGRAM_ARB && ctx->Extensions.ARB_vertex_program) {
- struct gl_vertex_program *prog = ctx->VertexProgram.Current;
+ struct gl_program *prog = ctx->VertexProgram.Current;
_mesa_parse_arb_vertex_program(ctx, target, string, len, prog);
- base = & prog->Base;
+ base = prog;
}
else if (target == GL_FRAGMENT_PROGRAM_ARB
&& ctx->Extensions.ARB_fragment_program) {
@@ -657,7 +656,7 @@ _mesa_GetProgramivARB(GLenum target, GLenum pname, GLint *params)
if (target == GL_VERTEX_PROGRAM_ARB
&& ctx->Extensions.ARB_vertex_program) {
- prog = &(ctx->VertexProgram.Current->Base);
+ prog = ctx->VertexProgram.Current;
limits = &ctx->Const.Program[MESA_SHADER_VERTEX];
}
else if (target == GL_FRAGMENT_PROGRAM_ARB
@@ -838,7 +837,7 @@ _mesa_GetProgramStringARB(GLenum target, GLenum pname, GLvoid *string)
GET_CURRENT_CONTEXT(ctx);
if (target == GL_VERTEX_PROGRAM_ARB) {
- prog = &(ctx->VertexProgram.Current->Base);
+ prog = ctx->VertexProgram.Current;
}
else if (target == GL_FRAGMENT_PROGRAM_ARB) {
prog = &(ctx->FragmentProgram.Current->Base);
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 757dbfc6613..1ae1ab5d5a2 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -741,7 +741,7 @@ check_context_limits(struct gl_context *ctx)
/* check that we don't exceed the size of various bitfields */
assert(VARYING_SLOT_MAX <=
- (8 * sizeof(ctx->VertexProgram._Current->Base.OutputsWritten)));
+ (8 * sizeof(ctx->VertexProgram._Current->OutputsWritten)));
assert(VARYING_SLOT_MAX <=
(8 * sizeof(ctx->FragmentProgram._Current->Base.InputsRead)));
@@ -1293,9 +1293,9 @@ _mesa_free_context_data( struct gl_context *ctx )
_mesa_reference_framebuffer(&ctx->DrawBuffer, NULL);
_mesa_reference_framebuffer(&ctx->ReadBuffer, NULL);
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, NULL);
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL);
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram._TnlProgram, NULL);
+ _mesa_reference_program(ctx, &ctx->VertexProgram.Current, NULL);
+ _mesa_reference_program(ctx, &ctx->VertexProgram._Current, NULL);
+ _mesa_reference_program(ctx, &ctx->VertexProgram._TnlProgram, NULL);
_mesa_reference_program(ctx, &ctx->TessCtrlProgram._Current, NULL);
_mesa_reference_program(ctx, &ctx->TessEvalProgram._Current, NULL);
diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
index db3736eae77..530033579e9 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -368,7 +368,7 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx )
if (vertexShader)
vprog = ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
else
- vprog = &ctx->VertexProgram.Current->Base;
+ vprog = ctx->VertexProgram.Current;
vp_outputs = vprog->OutputsWritten;
diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
index 9bf0f6892de..15997ccfdca 100644
--- a/src/mesa/main/ffvertex_prog.c
+++ b/src/mesa/main/ffvertex_prog.c
@@ -305,7 +305,7 @@ struct ureg {
struct tnl_program {
const struct state_key *state;
- struct gl_vertex_program *program;
+ struct gl_program *program;
GLuint max_inst; /** number of instructions allocated for program */
GLboolean mvp_with_dp4;
@@ -384,8 +384,8 @@ static struct ureg get_temp( struct tnl_program *p )
exit(1);
}
- if ((GLuint) bit > p->program->Base.NumTemporaries)
- p->program->Base.NumTemporaries = bit;
+ if ((GLuint) bit > p->program->NumTemporaries)
+ p->program->NumTemporaries = bit;
p->temp_in_use |= 1<<(bit-1);
return make_ureg(PROGRAM_TEMPORARY, bit-1);
@@ -428,7 +428,7 @@ static struct ureg register_param5(struct tnl_program *p,
tokens[2] = s2;
tokens[3] = s3;
tokens[4] = s4;
- idx = _mesa_add_state_reference( p->program->Base.Parameters, tokens );
+ idx = _mesa_add_state_reference(p->program->Parameters, tokens );
return make_ureg(PROGRAM_STATE_VAR, idx);
}
@@ -448,7 +448,7 @@ static struct ureg register_input( struct tnl_program *p, GLuint input )
assert(input < VERT_ATTRIB_MAX);
if (p->state->varying_vp_inputs & VERT_BIT(input)) {
- p->program->Base.InputsRead |= VERT_BIT(input);
+ p->program->InputsRead |= VERT_BIT(input);
return make_ureg(PROGRAM_INPUT, input);
}
else {
@@ -462,7 +462,7 @@ static struct ureg register_input( struct tnl_program *p, GLuint input )
*/
static struct ureg register_output( struct tnl_program *p, GLuint output )
{
- p->program->Base.OutputsWritten |= BITFIELD64_BIT(output);
+ p->program->OutputsWritten |= BITFIELD64_BIT(output);
return make_ureg(PROGRAM_OUTPUT, output);
}
@@ -480,8 +480,8 @@ static struct ureg register_const4f( struct tnl_program *p,
values[1].f = s1;
values[2].f = s2;
values[3].f = s3;
- idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4,
- &swizzle );
+ idx = _mesa_add_unnamed_constant(p->program->Parameters, values, 4,
+ &swizzle );
assert(swizzle == SWIZZLE_NOOP);
return make_ureg(PROGRAM_CONSTANT, idx);
}
@@ -578,9 +578,9 @@ static void emit_op3fn(struct tnl_program *p,
GLuint nr;
struct prog_instruction *inst;
- assert(p->program->Base.NumInstructions <= p->max_inst);
+ assert(p->program->NumInstructions <= p->max_inst);
- if (p->program->Base.NumInstructions == p->max_inst) {
+ if (p->program->NumInstructions == p->max_inst) {
/* need to extend the program's instruction array */
struct prog_instruction *newInst;
@@ -593,19 +593,18 @@ static void emit_op3fn(struct tnl_program *p,
return;
}
- _mesa_copy_instructions(newInst,
- p->program->Base.Instructions,
- p->program->Base.NumInstructions);
+ _mesa_copy_instructions(newInst, p->program->Instructions,
+ p->program->NumInstructions);
- _mesa_free_instructions(p->program->Base.Instructions,
- p->program->Base.NumInstructions);
+ _mesa_free_instructions(p->program->Instructions,
+ p->program->NumInstructions);
- p->program->Base.Instructions = newInst;
+ p->program->Instructions = newInst;
}
- nr = p->program->Base.NumInstructions++;
+ nr = p->program->NumInstructions++;
- inst = &p->program->Base.Instructions[nr];
+ inst = &p->program->Instructions[nr];
inst->Opcode = (enum prog_opcode) op;
emit_arg( &inst->SrcReg[0], src0 );
@@ -1608,7 +1607,7 @@ static void build_tnl_program( struct tnl_program *p )
static void
create_new_program( const struct state_key *key,
- struct gl_vertex_program *program,
+ struct gl_program *program,
GLboolean mvp_with_dp4,
GLuint max_temps)
{
@@ -1634,15 +1633,15 @@ 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->Base.Instructions = _mesa_alloc_instructions(p.max_inst);
- p.program->Base.String = NULL;
- p.program->Base.NumInstructions =
- p.program->Base.NumTemporaries =
- p.program->Base.NumParameters =
- p.program->Base.NumAttributes = p.program->Base.NumAddressRegs = 0;
- p.program->Base.Parameters = _mesa_new_parameter_list();
- p.program->Base.InputsRead = 0;
- p.program->Base.OutputsWritten = 0;
+ p.program->Instructions = _mesa_alloc_instructions(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->Parameters = _mesa_new_parameter_list();
+ p.program->InputsRead = 0;
+ p.program->OutputsWritten = 0;
build_tnl_program( &p );
}
@@ -1652,10 +1651,10 @@ create_new_program( const struct state_key *key,
* Return a vertex program which implements the current fixed-function
* transform/lighting/texgen operations.
*/
-struct gl_vertex_program *
+struct gl_program *
_mesa_get_fixed_func_vertex_program(struct gl_context *ctx)
{
- struct gl_vertex_program *prog;
+ struct gl_program *prog;
struct state_key key;
/* Grab all the relevant state and put it in a single structure:
@@ -1664,15 +1663,15 @@ _mesa_get_fixed_func_vertex_program(struct gl_context *ctx)
/* Look for an already-prepared program for this state:
*/
- prog = gl_vertex_program(
- _mesa_search_program_cache(ctx->VertexProgram.Cache, &key, sizeof(key)));
+ prog = _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 = gl_vertex_program(ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0));
+ prog = ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
if (!prog)
return NULL;
@@ -1681,11 +1680,10 @@ _mesa_get_fixed_func_vertex_program(struct gl_context *ctx)
ctx->Const.Program[MESA_SHADER_VERTEX].MaxTemps );
if (ctx->Driver.ProgramStringNotify)
- ctx->Driver.ProgramStringNotify( ctx, GL_VERTEX_PROGRAM_ARB,
- &prog->Base );
+ ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB, prog);
- _mesa_program_cache_insert(ctx, ctx->VertexProgram.Cache,
- &key, sizeof(key), &prog->Base);
+ _mesa_program_cache_insert(ctx, ctx->VertexProgram.Cache, &key,
+ sizeof(key), prog);
}
return prog;
diff --git a/src/mesa/main/ffvertex_prog.h b/src/mesa/main/ffvertex_prog.h
index 648befdcb5a..0a67d488194 100644
--- a/src/mesa/main/ffvertex_prog.h
+++ b/src/mesa/main/ffvertex_prog.h
@@ -32,7 +32,7 @@
struct gl_context;
-struct gl_vertex_program *
+struct gl_program *
_mesa_get_fixed_func_vertex_program(struct gl_context *ctx);
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 65f73f4cc37..451ede8043f 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1987,13 +1987,10 @@ struct gl_program
GLuint NumNativeTexInstructions;
GLuint NumNativeTexIndirections;
/*@}*/
-};
-
-/** Vertex program object */
-struct gl_vertex_program
-{
- struct gl_program Base; /**< base class */
+ /** Used by ARB assembly-style programs. Can only be true for vertex
+ * programs.
+ */
GLboolean IsPositionInvariant;
};
@@ -2066,13 +2063,13 @@ struct gl_vertex_program_state
GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
/** Computed two sided lighting for fixed function/programs. */
GLboolean _TwoSideEnabled;
- struct gl_vertex_program *Current; /**< User-bound vertex program */
+ struct gl_program *Current; /**< User-bound vertex program */
/** Currently enabled and valid vertex program (including internal
* programs, user-defined vertex programs and GLSL vertex shaders).
* This is the program we must use when rendering.
*/
- struct gl_vertex_program *_Current;
+ struct gl_program *_Current;
GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
@@ -2080,7 +2077,7 @@ struct gl_vertex_program_state
GLboolean _MaintainTnlProgram;
/** Program to emulate fixed-function T&L (see above) */
- struct gl_vertex_program *_TnlProgram;
+ struct gl_program *_TnlProgram;
/** Cache of fixed-function programs */
struct gl_program_cache *Cache;
@@ -2775,7 +2772,7 @@ struct gl_shader_program
/** Vertex shader state */
struct {
/**
- * True if gl_ClipDistance is written to. Copied into gl_vertex_program
+ * True if gl_ClipDistance is written to. Copied into gl_program
* by _mesa_copy_linked_program_data().
*/
GLuint ClipDistanceArraySize; /**< Size of the gl_ClipDistance array, or
@@ -3095,7 +3092,7 @@ struct gl_shared_state
*/
/*@{*/
struct _mesa_HashTable *Programs; /**< All vertex/fragment programs */
- struct gl_vertex_program *DefaultVertexProgram;
+ struct gl_program *DefaultVertexProgram;
struct gl_fragment_program *DefaultFragmentProgram;
/*@}*/
diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c
index 49e5f028045..5ff0b69764f 100644
--- a/src/mesa/main/shared.c
+++ b/src/mesa/main/shared.c
@@ -70,8 +70,7 @@ _mesa_alloc_shared_state(struct gl_context *ctx)
shared->Programs = _mesa_NewHashTable();
shared->DefaultVertexProgram =
- gl_vertex_program(ctx->Driver.NewProgram(ctx,
- GL_VERTEX_PROGRAM_ARB, 0));
+ ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
shared->DefaultFragmentProgram =
gl_fragment_program(ctx->Driver.NewProgram(ctx,
GL_FRAGMENT_PROGRAM_ARB, 0));
@@ -332,7 +331,7 @@ free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared)
_mesa_HashDeleteAll(shared->Programs, delete_program_cb, ctx);
_mesa_DeleteHashTable(shared->Programs);
- _mesa_reference_vertprog(ctx, &shared->DefaultVertexProgram, NULL);
+ _mesa_reference_program(ctx, &shared->DefaultVertexProgram, NULL);
_mesa_reference_fragprog(ctx, &shared->DefaultFragmentProgram, NULL);
_mesa_HashDeleteAll(shared->ATIShaders, delete_fragshader_cb, ctx);
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 407ff385482..b09b3fefec8 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -70,7 +70,7 @@ update_program_enables(struct gl_context *ctx)
* GLSL shaders not relevant here.
*/
ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled
- && ctx->VertexProgram.Current->Base.Instructions;
+ && ctx->VertexProgram.Current->Instructions;
ctx->FragmentProgram._Enabled = ctx->FragmentProgram.Enabled
&& ctx->FragmentProgram.Current->Base.Instructions;
ctx->ATIFragmentShader._Enabled = ctx->ATIFragmentShader.Enabled
@@ -107,7 +107,7 @@ update_program(struct gl_context *ctx)
ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT];
const struct gl_shader_program *csProg =
ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
- const struct gl_vertex_program *prevVP = ctx->VertexProgram._Current;
+ const struct gl_program *prevVP = ctx->VertexProgram._Current;
const struct gl_fragment_program *prevFP = ctx->FragmentProgram._Current;
const struct gl_program *prevGP = ctx->GeometryProgram._Current;
const struct gl_program *prevTCP = ctx->TessCtrlProgram._Current;
@@ -222,24 +222,24 @@ update_program(struct gl_context *ctx)
if (vsProg && vsProg->LinkStatus
&& vsProg->_LinkedShaders[MESA_SHADER_VERTEX]) {
/* Use GLSL vertex shader */
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
- gl_vertex_program(vsProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program));
+ _mesa_reference_program(ctx, &ctx->VertexProgram._Current,
+ vsProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program);
}
else if (ctx->VertexProgram._Enabled) {
/* Use user-defined vertex program */
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
- ctx->VertexProgram.Current);
+ _mesa_reference_program(ctx, &ctx->VertexProgram._Current,
+ ctx->VertexProgram.Current);
}
else if (ctx->VertexProgram._MaintainTnlProgram) {
/* Use vertex program generated from fixed-function state */
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
- _mesa_get_fixed_func_vertex_program(ctx));
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram._TnlProgram,
- ctx->VertexProgram._Current);
+ _mesa_reference_program(ctx, &ctx->VertexProgram._Current,
+ _mesa_get_fixed_func_vertex_program(ctx));
+ _mesa_reference_program(ctx, &ctx->VertexProgram._TnlProgram,
+ ctx->VertexProgram._Current);
}
else {
/* no vertex program */
- _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL);
+ _mesa_reference_program(ctx, &ctx->VertexProgram._Current, NULL);
}
if (csProg && csProg->LinkStatus
@@ -290,7 +290,7 @@ update_program(struct gl_context *ctx)
new_state |= _NEW_PROGRAM;
if (ctx->Driver.BindProgram) {
ctx->Driver.BindProgram(ctx, GL_VERTEX_PROGRAM_ARB,
- (struct gl_program *) ctx->VertexProgram._Current);
+ ctx->VertexProgram._Current);
}
}
@@ -328,7 +328,7 @@ update_program_constants(struct gl_context *ctx)
if (ctx->VertexProgram._Current) {
const struct gl_program_parameter_list *params =
- ctx->VertexProgram._Current->Base.Parameters;
+ ctx->VertexProgram._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 c57dc0edbb1..95cde32eac4 100644
--- a/src/mesa/main/state.h
+++ b/src/mesa/main/state.h
@@ -61,7 +61,7 @@ _mesa_need_secondary_color(const struct gl_context *ctx)
if (ctx->VertexProgram._Current &&
(ctx->VertexProgram._Current != ctx->VertexProgram._TnlProgram) &&
- (ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_COLOR1))
+ (ctx->VertexProgram._Current->InputsRead & VERT_BIT_COLOR1))
return GL_TRUE;
if (ctx->FragmentProgram._Current &&