void
_mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target,
const GLvoid *str, GLsizei len,
- struct gl_fragment_program *program)
+ struct gl_program *program)
{
struct gl_program prog;
struct asm_parser_state state;
return;
}
- free(program->Base.String);
+ ralloc_free(program->String);
/* Copy the relevant contents of the arb_program struct into the
* fragment_program struct.
*/
- program->Base.String = prog.String;
- program->Base.NumInstructions = prog.NumInstructions;
- program->Base.NumTemporaries = prog.NumTemporaries;
- program->Base.NumParameters = prog.NumParameters;
- program->Base.NumAttributes = prog.NumAttributes;
- program->Base.NumAddressRegs = prog.NumAddressRegs;
- program->Base.NumNativeInstructions = prog.NumNativeInstructions;
- program->Base.NumNativeTemporaries = prog.NumNativeTemporaries;
- program->Base.NumNativeParameters = prog.NumNativeParameters;
- program->Base.NumNativeAttributes = prog.NumNativeAttributes;
- program->Base.NumNativeAddressRegs = prog.NumNativeAddressRegs;
- program->Base.NumAluInstructions = prog.NumAluInstructions;
- program->Base.NumTexInstructions = prog.NumTexInstructions;
- program->Base.NumTexIndirections = prog.NumTexIndirections;
- program->Base.NumNativeAluInstructions = prog.NumAluInstructions;
- program->Base.NumNativeTexInstructions = prog.NumTexInstructions;
- program->Base.NumNativeTexIndirections = prog.NumTexIndirections;
- program->Base.InputsRead = prog.InputsRead;
- program->Base.OutputsWritten = prog.OutputsWritten;
- program->Base.IndirectRegisterFiles = prog.IndirectRegisterFiles;
+ program->String = prog.String;
+ program->arb.NumInstructions = prog.arb.NumInstructions;
+ program->arb.NumTemporaries = prog.arb.NumTemporaries;
+ program->arb.NumParameters = prog.arb.NumParameters;
+ program->arb.NumAttributes = prog.arb.NumAttributes;
+ program->arb.NumAddressRegs = prog.arb.NumAddressRegs;
+ program->arb.NumNativeInstructions = prog.arb.NumNativeInstructions;
+ program->arb.NumNativeTemporaries = prog.arb.NumNativeTemporaries;
+ program->arb.NumNativeParameters = prog.arb.NumNativeParameters;
+ program->arb.NumNativeAttributes = prog.arb.NumNativeAttributes;
+ program->arb.NumNativeAddressRegs = prog.arb.NumNativeAddressRegs;
+ program->arb.NumAluInstructions = prog.arb.NumAluInstructions;
+ program->arb.NumTexInstructions = prog.arb.NumTexInstructions;
+ program->arb.NumTexIndirections = prog.arb.NumTexIndirections;
+ program->arb.NumNativeAluInstructions = prog.arb.NumAluInstructions;
+ program->arb.NumNativeTexInstructions = prog.arb.NumTexInstructions;
+ program->arb.NumNativeTexIndirections = prog.arb.NumTexIndirections;
+ program->info.inputs_read = prog.info.inputs_read;
+ program->info.outputs_written = prog.info.outputs_written;
+ program->arb.IndirectRegisterFiles = prog.arb.IndirectRegisterFiles;
for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++) {
- program->Base.TexturesUsed[i] = prog.TexturesUsed[i];
+ program->TexturesUsed[i] = prog.TexturesUsed[i];
if (prog.TexturesUsed[i])
- program->Base.SamplersUsed |= (1 << i);
+ program->SamplersUsed |= (1 << i);
}
- program->Base.ShadowSamplers = prog.ShadowSamplers;
+ program->ShadowSamplers = prog.ShadowSamplers;
program->OriginUpperLeft = state.option.OriginUpperLeft;
program->PixelCenterInteger = state.option.PixelCenterInteger;
- program->UsesKill = state.fragment.UsesKill;
+ program->info.fs.uses_discard = state.fragment.UsesKill;
- free(program->Base.Instructions);
- program->Base.Instructions = prog.Instructions;
+ ralloc_free(program->arb.Instructions);
+ program->arb.Instructions = prog.arb.Instructions;
- if (program->Base.Parameters)
- _mesa_free_parameter_list(program->Base.Parameters);
- program->Base.Parameters = prog.Parameters;
+ if (program->Parameters)
+ _mesa_free_parameter_list(program->Parameters);
+ program->Parameters = prog.Parameters;
/* Append fog instructions now if the program has "OPTION ARB_fog_exp"
* or similar. We used to leave this up to drivers, but it appears
}
#if DEBUG_FP
- printf("____________Fragment program %u ________\n", program->Base.Id);
+ printf("____________Fragment program %u ________\n", program->Id);
_mesa_print_program(&program->Base);
#endif
}
void
_mesa_parse_arb_vertex_program(struct gl_context *ctx, GLenum target,
const GLvoid *str, GLsizei len,
- struct gl_vertex_program *program)
+ struct gl_program *program)
{
struct gl_program prog;
struct asm_parser_state state;
memset(&prog, 0, sizeof(prog));
memset(&state, 0, sizeof(state));
state.prog = &prog;
+ state.mem_ctx = program;
if (!_mesa_parse_arb_program(ctx, target, (const GLubyte*) str, len,
&state)) {
+ ralloc_free(prog.arb.Instructions);
+ ralloc_free(prog.String);
_mesa_error(ctx, GL_INVALID_OPERATION, "glProgramString(bad program)");
return;
}
if ((ctx->_Shader->Flags & GLSL_NO_OPT) == 0)
- _mesa_optimize_program(ctx, &prog);
+ _mesa_optimize_program(ctx, &prog, program);
- free(program->Base.String);
+ ralloc_free(program->String);
/* Copy the relevant contents of the arb_program struct into the
* vertex_program struct.
*/
- program->Base.String = prog.String;
- program->Base.NumInstructions = prog.NumInstructions;
- program->Base.NumTemporaries = prog.NumTemporaries;
- program->Base.NumParameters = prog.NumParameters;
- program->Base.NumAttributes = prog.NumAttributes;
- program->Base.NumAddressRegs = prog.NumAddressRegs;
- program->Base.NumNativeInstructions = prog.NumNativeInstructions;
- program->Base.NumNativeTemporaries = prog.NumNativeTemporaries;
- program->Base.NumNativeParameters = prog.NumNativeParameters;
- program->Base.NumNativeAttributes = prog.NumNativeAttributes;
- program->Base.NumNativeAddressRegs = prog.NumNativeAddressRegs;
- program->Base.InputsRead = prog.InputsRead;
- program->Base.OutputsWritten = prog.OutputsWritten;
- program->Base.IndirectRegisterFiles = prog.IndirectRegisterFiles;
- program->IsPositionInvariant = (state.option.PositionInvariant)
+ program->String = prog.String;
+ program->arb.NumInstructions = prog.arb.NumInstructions;
+ program->arb.NumTemporaries = prog.arb.NumTemporaries;
+ program->arb.NumParameters = prog.arb.NumParameters;
+ program->arb.NumAttributes = prog.arb.NumAttributes;
+ program->arb.NumAddressRegs = prog.arb.NumAddressRegs;
+ program->arb.NumNativeInstructions = prog.arb.NumNativeInstructions;
+ program->arb.NumNativeTemporaries = prog.arb.NumNativeTemporaries;
+ program->arb.NumNativeParameters = prog.arb.NumNativeParameters;
+ program->arb.NumNativeAttributes = prog.arb.NumNativeAttributes;
+ program->arb.NumNativeAddressRegs = prog.arb.NumNativeAddressRegs;
+ program->info.inputs_read = prog.info.inputs_read;
+ program->info.outputs_written = prog.info.outputs_written;
+ program->arb.IndirectRegisterFiles = prog.arb.IndirectRegisterFiles;
+ program->arb.IsPositionInvariant = (state.option.PositionInvariant)
? GL_TRUE : GL_FALSE;
- free(program->Base.Instructions);
- program->Base.Instructions = prog.Instructions;
+ ralloc_free(program->arb.Instructions);
+ program->arb.Instructions = prog.arb.Instructions;
- if (program->Base.Parameters)
- _mesa_free_parameter_list(program->Base.Parameters);
- program->Base.Parameters = prog.Parameters;
+ if (program->Parameters)
+ _mesa_free_parameter_list(program->Parameters);
+ program->Parameters = prog.Parameters;
#if DEBUG_VP
- printf("____________Vertex program %u __________\n", program->Base.Id);
- _mesa_print_program(&program->Base);
+ printf("____________Vertex program %u __________\n", program->Id);
+ _mesa_print_program(program);
#endif
}