* to render with that program.
*/
struct r300_fragment_program {
- struct gl_program *Base;
-
- GLboolean translated;
GLboolean error;
+ struct gl_program *Base;
struct r300_fragment_program *next;
struct r300_fragment_program_external_state state;
struct rX00_fragment_program_code code;
+ GLbitfield InputsRead;
};
struct r300_fragment_program_cont {
}
-void r300TranslateFragmentShader(GLcontext *ctx, struct r300_fragment_program *fp)
+static void translate_fragment_program(GLcontext *ctx, struct r300_fragment_program_cont *cont, struct r300_fragment_program *fp)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
struct r300_fragment_program_compiler compiler;
compiler.code = &fp->code;
compiler.state = fp->state;
- compiler.program = fp->Base;
+ compiler.program = _mesa_clone_program(ctx, &cont->Base.Base);
compiler.is_r500 = (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) ? GL_TRUE : GL_FALSE;
compiler.debug = (RADEON_DEBUG & DEBUG_PIXEL) ? GL_TRUE : GL_FALSE;
if (!r3xx_compile_fragment_program(&compiler))
fp->error = GL_TRUE;
- fp->translated = GL_TRUE;
+ fp->InputsRead = compiler.program->InputsRead;
+
+ fp->Base = compiler.program;
}
-struct r300_fragment_program *r300SelectFragmentShader(GLcontext *ctx)
+struct r300_fragment_program *r300SelectAndTranslateFragmentShader(GLcontext *ctx)
{
r300ContextPtr r300 = R300_CONTEXT(ctx);
struct r300_fragment_program_cont *fp_list;
fp = _mesa_calloc(sizeof(struct r300_fragment_program));
fp->state = state;
- fp->translated = GL_FALSE;
- fp->Base = _mesa_clone_program(ctx, &ctx->FragmentProgram._Current->Base);
fp->next = fp_list->progs;
fp_list->progs = fp;
+ translate_fragment_program(ctx, fp_list, fp);
+
return r300->selected_fp = fp;
}
#include "r300_context.h"
-extern void r300TranslateFragmentShader(GLcontext *ctx, struct r300_fragment_program *fp);
-
-struct r300_fragment_program *r300SelectFragmentShader(GLcontext *ctx);
+struct r300_fragment_program *r300SelectAndTranslateFragmentShader(GLcontext *ctx);
#endif
r300IsProgramNative(GLcontext * ctx, GLenum target, struct gl_program *prog)
{
if (target == GL_FRAGMENT_PROGRAM_ARB) {
- struct r300_fragment_program *fp = r300SelectFragmentShader(ctx);
- if (!fp->translated)
- r300TranslateFragmentShader(ctx, fp);
+ struct r300_fragment_program *fp = r300SelectAndTranslateFragmentShader(ctx);
return !fp->error;
} else {
else
RENDERINPUTS_COPY(OutputsWritten.index_bitset, r300->render_inputs_bitset);
- InputsRead = r300->selected_fp->Base->InputsRead;
+ InputsRead = r300->selected_fp->InputsRead;
R300_STATECHANGE(r300, ri);
R300_STATECHANGE(r300, rc);
else
RENDERINPUTS_COPY(OutputsWritten.index_bitset, r300->render_inputs_bitset);
- InputsRead = r300->selected_fp->Base->InputsRead;
+ InputsRead = r300->selected_fp->InputsRead;
R300_STATECHANGE(r300, ri);
R300_STATECHANGE(r300, rc);
{
struct r300_fragment_program *fp;
- fp = r300SelectFragmentShader(ctx);
- if (!fp->translated)
- r300TranslateFragmentShader(ctx, fp);
+ fp = r300SelectAndTranslateFragmentShader(ctx);
r300SwitchFallback(ctx, R300_FALLBACK_FRAGMENT_PROGRAM, fp->error);
}
}
static const GLfloat *get_fragmentprogram_constant(GLcontext *ctx,
- struct gl_program *program, struct prog_src_register srcreg)
+ struct prog_src_register srcreg)
{
static const GLfloat dummy[4] = { 0, 0, 0, 0 };
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ struct gl_program * program = rmesa->selected_fp->Base;
switch(srcreg.File) {
case PROGRAM_LOCAL_PARAM:
R300_STATECHANGE(rmesa, fpp);
rmesa->hw.fpp.cmd[R300_FPP_CMD_0] = cmdpacket0(rmesa->radeon.radeonScreen, R300_PFS_PARAM_0_X, code->const_nr * 4);
for (i = 0; i < code->const_nr; i++) {
- const GLfloat *constant = get_fragmentprogram_constant(ctx, fp->Base, code->constant[i]);
+ const GLfloat *constant = get_fragmentprogram_constant(ctx, code->constant[i]);
rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 0] = r300PackFloat24(constant[0]);
rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 1] = r300PackFloat24(constant[1]);
rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 2] = r300PackFloat24(constant[2]);
R300_STATECHANGE(rmesa, r500fp_const);
for (i = 0; i < code->const_nr; i++) {
- const GLfloat *constant = get_fragmentprogram_constant(ctx, fp->Base, code->constant[i]);
+ const GLfloat *constant = get_fragmentprogram_constant(ctx, code->constant[i]);
rmesa->hw.r500fp_const.cmd[R300_FPP_PARAM_0 + 4 * i + 0] = r300PackFloat32(constant[0]);
rmesa->hw.r500fp_const.cmd[R300_FPP_PARAM_0 + 4 * i + 1] = r300PackFloat32(constant[1]);
rmesa->hw.r500fp_const.cmd[R300_FPP_PARAM_0 + 4 * i + 2] = r300PackFloat32(constant[2]);
GLuint InputsRead = 0;
GLuint OutputsWritten = 0;
int num_attrs = 0;
- GLuint fp_reads = rmesa->selected_fp->Base->InputsRead;
+ GLuint fp_reads = rmesa->selected_fp->InputsRead;
struct vertex_attribute *attrs = rmesa->vbuf.attribs;
rmesa->swtcl.coloroffset = rmesa->swtcl.specoffset = 0;
OutputsAdded = 0;
count = 0;
- FpReads = r300->selected_fp->Base->InputsRead;
+ FpReads = r300->selected_fp->InputsRead;
ADD_OUTPUT(FRAG_ATTRIB_COL0, VERT_RESULT_COL0);
ADD_OUTPUT(FRAG_ATTRIB_COL1, VERT_RESULT_COL1);
r300ContextPtr r300 = (r300ContextPtr)(s->UserData);
GLuint fp_reads;
- fp_reads = r300->selected_fp->Base->InputsRead;
+ fp_reads = r300->selected_fp->InputsRead;
{
if (fp_reads & FRAG_BIT_COL0) {
s->Outputs[VERT_RESULT_COL0].Sourced = WRITEMASK_XYZW;
struct r300_vertex_program *vp;
vpc = (struct r300_vertex_program_cont *)ctx->VertexProgram._Current;
- wanted_key.FpReads = r300->selected_fp->Base->InputsRead;
+ wanted_key.FpReads = r300->selected_fp->InputsRead;
wanted_key.FogAttr = r300->selected_fp->code.fog_attr;
wanted_key.WPosAttr = r300->selected_fp->code.wpos_attr;