#include "main/mtypes.h"
#include "main/dispatch.h"
#include "main/atifragshader.h"
+#include "program/program.h"
#define MESA_DEBUG_ATI_FS 0
_mesa_delete_ati_fragment_shader(struct gl_context *ctx, struct ati_fragment_shader *s)
{
GLuint i;
+
+ if (s == &DummyShader)
+ return;
+
for (i = 0; i < MAX_NUM_PASSES_ATI; i++) {
free(s->Instructions[i]);
free(s->SetupInst[i]);
}
+ _mesa_reference_program(ctx, &s->Program, NULL);
free(s);
}
op_name = atifs_ops[(arg_count-1)+(optype?3:0)];
- fprintf(stderr, "%s(%s, %s", op_name, _mesa_lookup_enum_by_nr(op),
- _mesa_lookup_enum_by_nr(dst));
+ fprintf(stderr, "%s(%s, %s", op_name, _mesa_enum_to_string(op),
+ _mesa_enum_to_string(dst));
if (!optype)
fprintf(stderr, ", %d", dstMask);
fprintf(stderr, ", %s", create_dst_mod_str(dstMod));
- fprintf(stderr, ", %s, %s, %d", _mesa_lookup_enum_by_nr(arg1),
- _mesa_lookup_enum_by_nr(arg1Rep), arg1Mod);
+ fprintf(stderr, ", %s, %s, %d", _mesa_enum_to_string(arg1),
+ _mesa_enum_to_string(arg1Rep), arg1Mod);
if (arg_count>1)
- fprintf(stderr, ", %s, %s, %d", _mesa_lookup_enum_by_nr(arg2),
- _mesa_lookup_enum_by_nr(arg2Rep), arg2Mod);
+ fprintf(stderr, ", %s, %s, %d", _mesa_enum_to_string(arg2),
+ _mesa_enum_to_string(arg2Rep), arg2Mod);
if (arg_count>2)
- fprintf(stderr, ", %s, %s, %d", _mesa_lookup_enum_by_nr(arg3),
- _mesa_lookup_enum_by_nr(arg3Rep), arg3Mod);
+ fprintf(stderr, ", %s, %s, %d", _mesa_enum_to_string(arg3),
+ _mesa_enum_to_string(arg3Rep), arg3Mod);
fprintf(stderr,")\n");
return 0;
}
+ _mesa_HashLockMutex(ctx->Shared->ATIShaders);
+
first = _mesa_HashFindFreeKeyBlock(ctx->Shared->ATIShaders, range);
for (i = 0; i < range; i++) {
- _mesa_HashInsert(ctx->Shared->ATIShaders, first + i, &DummyShader);
+ _mesa_HashInsertLocked(ctx->Shared->ATIShaders, first + i, &DummyShader);
}
+ _mesa_HashUnlockMutex(ctx->Shared->ATIShaders);
+
return first;
}
assert(ctx->ATIFragmentShader.Current);
if (newProg)
newProg->RefCount++;
-
- /*if (ctx->Driver.BindProgram)
- ctx->Driver.BindProgram(ctx, target, prog); */
}
void GLAPIENTRY
if (prog) {
prog->RefCount--;
if (prog->RefCount <= 0) {
- assert(prog != &DummyShader);
- free(prog);
+ _mesa_delete_ati_fragment_shader(ctx, prog);
}
}
}
free(ctx->ATIFragmentShader.Current->SetupInst[i]);
}
+ _mesa_reference_program(ctx, &ctx->ATIFragmentShader.Current->Program, NULL);
+
/* malloc the instructions here - not sure if the best place but its
a start */
for (i = 0; i < MAX_NUM_PASSES_ATI; i++) {
ctx->ATIFragmentShader.Current->isValid = GL_FALSE;
ctx->ATIFragmentShader.Current->swizzlerq = 0;
ctx->ATIFragmentShader.Compiling = 1;
+#if MESA_DEBUG_ATI_FS
+ _mesa_debug(ctx, "%s %u\n", __func__, ctx->ATIFragmentShader.Current->Id);
+#endif
}
void GLAPIENTRY
for (j = 0; j < MAX_NUM_PASSES_ATI; j++) {
for (i = 0; i < MAX_NUM_FRAGMENT_REGISTERS_ATI; i++) {
GLuint op = curProg->SetupInst[j][i].Opcode;
- const char *op_enum = op > 5 ? _mesa_lookup_enum_by_nr(op) : "0";
+ const char *op_enum = op > 5 ? _mesa_enum_to_string(op) : "0";
GLuint src = curProg->SetupInst[j][i].src;
GLuint swizzle = curProg->SetupInst[j][i].swizzle;
fprintf(stderr, "%2d %04X %s %d %04X\n", i, op, op_enum, src,
for (i = 0; i < curProg->numArithInstr[j]; i++) {
GLuint op0 = curProg->Instructions[j][i].Opcode[0];
GLuint op1 = curProg->Instructions[j][i].Opcode[1];
- const char *op0_enum = op0 > 5 ? _mesa_lookup_enum_by_nr(op0) : "0";
- const char *op1_enum = op1 > 5 ? _mesa_lookup_enum_by_nr(op1) : "0";
+ const char *op0_enum = op0 > 5 ? _mesa_enum_to_string(op0) : "0";
+ const char *op1_enum = op1 > 5 ? _mesa_enum_to_string(op1) : "0";
GLuint count0 = curProg->Instructions[j][i].ArgCount[0];
GLuint count1 = curProg->Instructions[j][i].ArgCount[1];
fprintf(stderr, "%2d %04X %s %d %04X %s %d\n", i, op0, op0_enum, count0,
}
#endif
- if (!ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_SHADER_ATI, NULL)) {
+ if (ctx->Driver.NewATIfs) {
+ struct gl_program *prog = ctx->Driver.NewATIfs(ctx,
+ ctx->ATIFragmentShader.Current);
+ _mesa_reference_program(ctx, &ctx->ATIFragmentShader.Current->Program, prog);
+ }
+
+ if (!ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_SHADER_ATI,
+ curProg->Program)) {
ctx->ATIFragmentShader.Current->isValid = GL_FALSE;
/* XXX is this the right error? */
_mesa_error(ctx, GL_INVALID_OPERATION,
curI->swizzle = swizzle;
#if MESA_DEBUG_ATI_FS
- _mesa_debug(ctx, "%s(%s, %s, %s)\n", __FUNCTION__,
- _mesa_lookup_enum_by_nr(dst), _mesa_lookup_enum_by_nr(coord),
- _mesa_lookup_enum_by_nr(swizzle));
+ _mesa_debug(ctx, "%s(%s, %s, %s)\n", __func__,
+ _mesa_enum_to_string(dst), _mesa_enum_to_string(coord),
+ _mesa_enum_to_string(swizzle));
#endif
}
curI->swizzle = swizzle;
#if MESA_DEBUG_ATI_FS
- _mesa_debug(ctx, "%s(%s, %s, %s)\n", __FUNCTION__,
- _mesa_lookup_enum_by_nr(dst), _mesa_lookup_enum_by_nr(interp),
- _mesa_lookup_enum_by_nr(swizzle));
+ _mesa_debug(ctx, "%s(%s, %s, %s)\n", __func__,
+ _mesa_enum_to_string(dst), _mesa_enum_to_string(interp),
+ _mesa_enum_to_string(swizzle));
#endif
}