GLfloat *params)
{
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (!ctx->_CurrentProgram)
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
if (target == GL_FRAGMENT_PROGRAM_ARB
&& ctx->Extensions.ARB_fragment_program) {
{
struct program *prog;
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (!ctx->_CurrentProgram)
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
if (target == GL_VERTEX_PROGRAM_ARB
&& ctx->Extensions.ARB_vertex_program) {
{
struct program *prog;
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (!ctx->_CurrentProgram)
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
if (target == GL_VERTEX_PROGRAM_ARB) {
prog = &(ctx->VertexProgram.Current->Base);
break;
case GL_VERTEX_PROGRAM_ARB: /* == GL_VERTEX_PROGRAM_NV */
if (!ctx->Extensions.ARB_vertex_program &&
- !ctx->Extensions.ARB_vertex_program) {
+ !ctx->Extensions.NV_vertex_program) {
_mesa_error(ctx, GL_INVALID_ENUM, "glProgramCallbackMESA(target)");
return;
}
GLint i;
for (i = 0; i < ctx->Const.MaxVertexProgramAttribs; i++) {
const char *name = _mesa_nv_vertex_input_register_name(i);
- if (_mesa_strncmp(reg + 2, name, 4) == 0) {
+ char number[10];
+ sprintf(number, "%d", i);
+ if (_mesa_strncmp(reg + 2, name, 4) == 0 ||
+ _mesa_strncmp(reg + 2, number, _mesa_strlen(number)) == 0) {
COPY_4V(v, ctx->VertexProgram.Machine.Registers
[VP_INPUT_REG_START + i]);
return;
if (!params)
return;
- /* We need this in order to get correct results for
- * GL_OCCLUSION_TEST_RESULT_HP. There might be other important cases.
- */
- FLUSH_VERTICES(ctx, 0);
-
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glGetBooleanv %s\n", _mesa_lookup_enum_by_nr(pname));
+ if (!ctx->_CurrentProgram) {
+ /* We need this in order to get correct results for
+ * GL_OCCLUSION_TEST_RESULT_HP. There might be other important cases.
+ */
+ FLUSH_VERTICES(ctx, 0);
+ }
+
if (ctx->Driver.GetBooleanv
&& (*ctx->Driver.GetBooleanv)(ctx, pname, params))
return;
if (!params)
return;
- /* We need this in order to get correct results for
- * GL_OCCLUSION_TEST_RESULT_HP. There might be other important cases.
- */
- FLUSH_VERTICES(ctx, 0);
-
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glGetDoublev %s\n", _mesa_lookup_enum_by_nr(pname));
+ if (!ctx->_CurrentProgram) {
+ /* We need this in order to get correct results for
+ * GL_OCCLUSION_TEST_RESULT_HP. There might be other important cases.
+ */
+ FLUSH_VERTICES(ctx, 0);
+ }
+
if (ctx->Driver.GetDoublev && (*ctx->Driver.GetDoublev)(ctx, pname, params))
return;
if (!params)
return;
- /* We need this in order to get correct results for
- * GL_OCCLUSION_TEST_RESULT_HP. There might be other important cases.
- */
- FLUSH_VERTICES(ctx, 0);
-
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glGetFloatv %s\n", _mesa_lookup_enum_by_nr(pname));
+ if (!ctx->_CurrentProgram) {
+ /* We need this in order to get correct results for
+ * GL_OCCLUSION_TEST_RESULT_HP. There might be other important cases.
+ */
+ FLUSH_VERTICES(ctx, 0);
+ }
+
if (ctx->Driver.GetFloatv && (*ctx->Driver.GetFloatv)(ctx, pname, params))
return;
if (!params)
return;
-#if 0
- /* We need this in order to get correct results for
- * GL_OCCLUSION_TEST_RESULT_HP. There might be other important cases.
- */
- FLUSH_VERTICES(ctx, 0);
-
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glGetIntegerv %s\n", _mesa_lookup_enum_by_nr(pname));
+ if (!ctx->_CurrentProgram) {
+ /* We need this in order to get correct results for
+ * GL_OCCLUSION_TEST_RESULT_HP. There might be other important cases.
+ */
+ FLUSH_VERTICES(ctx, 0);
+ }
+
if (ctx->Driver.GetIntegerv
&& (*ctx->Driver.GetIntegerv)(ctx, pname, params))
return;
-#endif
switch (pname) {
case GL_ACCUM_RED_BITS:
GLuint _NeedEyeCoords;
GLuint _ForceEyeCoords;
GLboolean _RotateMode;
+ GLenum _CurrentProgram; /* currently executing program */
struct gl_shine_tab *_ShineTable[2]; /**< Active shine tables */
struct gl_shine_tab *_ShineTabList; /**< MRU list of inactive shine tables */
{
struct program *prog;
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (!ctx->_CurrentProgram)
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
prog = (struct program *) _mesa_HashLookup(ctx->Shared->Programs, id);
if (!prog) {
{
struct program *prog;
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (!ctx->_CurrentProgram)
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
if (pname != GL_PROGRAM_STRING_NV) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivNV(pname)");
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramStringNV(pname)");
return;
}
prog = (struct program *) _mesa_HashLookup(ctx->Shared->Programs, id);
if (!prog) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glGetProgramivNV");
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetProgramStringNV");
return;
}
struct fragment_program *fragProg;
GLint i;
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (!ctx->_CurrentProgram)
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
prog = (struct program *) _mesa_HashLookup(ctx->Shared->Programs, id);
if (!prog || prog->Target != GL_FRAGMENT_PROGRAM_NV) {
_mesa_GetProgramNamedParameterfvNV(id, len, name, floatParams);
COPY_4V(params, floatParams);
}
-
-
-#if 000
-void
-_mesa_ProgramLocalParameter4fARB(GLenum target, GLuint index,
- GLfloat x, GLfloat y, GLfloat z, GLfloat w)
-{
- GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
-
- if (target == GL_FRAGMENT_PROGRAM_NV) {
- struct fragment_program *fprog = ctx->FragmentProgram.Current;
- if (!fprog) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glProgramLocalParameterARB");
- return;
- }
- if (index >= MAX_NV_FRAGMENT_PROGRAM_PARAMS) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameterARB");
- return;
- }
- fprog->Base.LocalParams[index][0] = x;
- fprog->Base.LocalParams[index][1] = y;
- fprog->Base.LocalParams[index][2] = z;
- fprog->Base.LocalParams[index][3] = w;
- }
- else {
- _mesa_error(ctx, GL_INVALID_ENUM, "glProgramLocalParameterARB");
- return;
- }
-}
-
-
-/* XXX move into arbprogram.c */
-void
-_mesa_ProgramLocalParameter4fvARB(GLenum target, GLuint index,
- const GLfloat *params)
-{
- _mesa_ProgramLocalParameter4fARB(target, index, params[0], params[1],
- params[2], params[3]);
-}
-
-
-/* XXX move into arbprogram.c */
-void
-_mesa_ProgramLocalParameter4dARB(GLenum target, GLuint index,
- GLdouble x, GLdouble y,
- GLdouble z, GLdouble w)
-{
- _mesa_ProgramLocalParameter4fARB(target, index, (GLfloat)x, (GLfloat)y,
- (GLfloat)z, (GLfloat)w);
-}
-
-
-/* XXX move into arbprogram.c */
-void
-_mesa_ProgramLocalParameter4dvARB(GLenum target, GLuint index,
- const GLdouble *params)
-{
- _mesa_ProgramLocalParameter4fARB(target, index, (GLfloat)params[0],
- (GLfloat)params[1], (GLfloat)params[2],
- (GLfloat)params[3]);
-}
-
-
-/* XXX move into arbprogram.c */
-void
-_mesa_GetProgramLocalParameterfvARB(GLenum target, GLuint index,
- GLfloat *params)
-{
- GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
-
- if (target == GL_FRAGMENT_PROGRAM_NV) {
- struct fragment_program *fprog = ctx->FragmentProgram.Current;
- if (!fprog) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramLocalParameterARB");
- return;
- }
- if (index >= MAX_NV_FRAGMENT_PROGRAM_PARAMS) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramLocalParameterARB");
- return;
- }
- params[0] = fprog->Base.LocalParams[index][0];
- params[1] = fprog->Base.LocalParams[index][1];
- params[2] = fprog->Base.LocalParams[index][2];
- params[3] = fprog->Base.LocalParams[index][3];
- }
- else {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramLocalParameterARB");
- return;
- }
-}
-
-
-/* XXX move into arbprogram.c */
-void
-_mesa_GetProgramLocalParameterdvARB(GLenum target, GLuint index,
- GLdouble *params)
-{
- GLfloat floatParams[4];
- _mesa_GetProgramLocalParameterfvARB(target, index, floatParams);
- COPY_4V(params, floatParams);
-}
-#endif
struct vp_machine *machine = &ctx->VertexProgram.Machine;
const struct vp_instruction *inst;
+ ctx->_CurrentProgram = GL_VERTEX_PROGRAM_ARB; /* or NV, doesn't matter */
+
for (inst = program->Instructions; inst->Opcode != VP_OPCODE_END; inst++) {
+
+ if (ctx->VertexProgram.CallbackEnabled &&
+ ctx->VertexProgram.Callback) {
+ ctx->VertexProgram.CurrentPosition = inst->StringPos;
+ ctx->VertexProgram.Callback(program->Base.Target,
+ ctx->VertexProgram.CallbackData);
+ }
+
switch (inst->Opcode) {
case VP_OPCODE_MOV:
{
* infinity. This may need some tweaking.
*/
#ifdef VMS
- if (abs_t0 == __MAXFLOAT) {
+ if (abs_t0 == __MAXFLOAT)
#else
- if (IS_INF_OR_NAN(abs_t0)) {
+ if (IS_INF_OR_NAN(abs_t0))
#endif
+ {
SET_POS_INFINITY(q[0]);
q[1] = 1.0F;
SET_POS_INFINITY(q[2]);
q[1] = (GLfloat) (2.0 * mantissa); /* map [.5, 1) -> [1, 2) */
q[2] = (GLfloat) (q[0] + LOG2(q[1]));
}
- }
+ }
else {
SET_NEG_INFINITY(q[0]);
q[1] = 1.0F;
break;
case VP_OPCODE_END:
+ ctx->_CurrentProgram = 0;
return;
default:
/* bad instruction opcode */
_mesa_problem(ctx, "Bad VP Opcode in _mesa_exec_vertex_program");
+ ctx->_CurrentProgram = 0;
return;
- }
- }
+ } /* switch */
+ } /* for */
+
+ ctx->_CurrentProgram = 0;
}
GLcontext *ctx;
const GLubyte *start;
const GLubyte *pos;
+ const GLubyte *curLine;
GLboolean isStateProgram;
GLboolean isPositionInvariant;
GLboolean isVersion1_1;
* \return <= 0 we found an error, else, return number of characters parsed.
*/
static GLint
-GetToken(const GLubyte *str, GLubyte *token)
+GetToken(struct parse_state *parseState, GLubyte *token)
{
+ const GLubyte *str = parseState->pos;
GLint i = 0, j = 0;
token[0] = 0;
while (str[i] && (str[i] != '\n' && str[i] != '\r')) {
i++;
}
+ if (str[i] == '\n' || str[i] == '\r')
+ parseState->curLine = str + i + 1;
}
else {
/* skip whitespace */
+ if (str[i] == '\n' || str[i] == '\r')
+ parseState->curLine = str + i + 1;
i++;
}
}
return i;
}
- /* punctuation */
+ /* punctuation character */
if (str[i]) {
token[0] = str[i++];
token[1] = 0;
Parse_Token(struct parse_state *parseState, GLubyte *token)
{
GLint i;
- i = GetToken(parseState->pos, token);
+ i = GetToken(parseState, token);
if (i <= 0) {
parseState->pos += (-i);
return GL_FALSE;
Peek_Token(struct parse_state *parseState, GLubyte *token)
{
GLint i, len;
- i = GetToken(parseState->pos, token);
+ i = GetToken(parseState, token);
if (i <= 0) {
parseState->pos += (-i);
return GL_FALSE;
while (*parseState->pos && (*parseState->pos != '\n' && *parseState->pos != '\r')) {
parseState->pos += 1;
}
+ if (*parseState->pos == '\n' || *parseState->pos == '\r')
+ parseState->curLine = parseState->pos + 1;
}
else {
/* skip whitespace */
+ if (*parseState->pos == '\n' || *parseState->pos == '\r')
+ parseState->curLine = parseState->pos + 1;
parseState->pos += 1;
}
}
RETURN_ERROR1("ABS illegal for vertex program 1.0");
inst->Opcode = opcode;
+ inst->StringPos = parseState->curLine - parseState->start;
/* dest reg */
if (!Parse_MaskedDstReg(parseState, &inst->DstReg))
RETURN_ERROR1("SUB illegal for vertex program 1.0");
inst->Opcode = opcode;
+ inst->StringPos = parseState->curLine - parseState->start;
/* dest reg */
if (!Parse_MaskedDstReg(parseState, &inst->DstReg))
struct vp_instruction *inst, enum vp_opcode opcode)
{
inst->Opcode = opcode;
+ inst->StringPos = parseState->curLine - parseState->start;
/* dest reg */
if (!Parse_MaskedDstReg(parseState, &inst->DstReg))
RETURN_ERROR1("RCC illegal for vertex program 1.0");
inst->Opcode = opcode;
+ inst->StringPos = parseState->curLine - parseState->start;
/* dest reg */
if (!Parse_MaskedDstReg(parseState, &inst->DstReg))
Parse_AddressInstruction(struct parse_state *parseState, struct vp_instruction *inst)
{
inst->Opcode = VP_OPCODE_ARL;
+ inst->StringPos = parseState->curLine - parseState->start;
/* dest A0 reg */
if (!Parse_AddrReg(parseState))
GLubyte token[100];
inst->Opcode = VP_OPCODE_END;
+ inst->StringPos = parseState->curLine - parseState->start;
/* this should fail! */
if (Parse_Token(parseState, token))
enum vp_opcode Opcode;
struct vp_src_register SrcReg[3];
struct vp_dst_register DstReg;
+#if FEATURE_MESA_program_debug
+ GLint StringPos;
+#endif
};
const struct fragment_program *program = ctx->FragmentProgram.Current;
GLuint i;
+ ctx->_CurrentProgram = GL_FRAGMENT_PROGRAM_ARB; /* or NV, doesn't matter */
+
for (i = 0; i < span->end; i++) {
if (span->array->mask[i]) {
init_machine(ctx, &ctx->FragmentProgram.Machine,
span->array->z[i] = IROUND(ctx->FragmentProgram.Machine.Registers[FP_OUTPUT_REG_START + 2][0] * ctx->DepthMaxF);
}
}
+
+ ctx->_CurrentProgram = 0;
}