summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2009-07-16 22:58:13 +0200
committerNicolai Hähnle <[email protected]>2009-07-27 20:32:04 +0200
commitf70d3ee3710a3453289aabf637f6818e198c67a5 (patch)
tree0a0470c07064b3c8d0d34cfc987a8e2c45abe25c /src
parentb54e0832012e6793b9c381d64aafbb8185b7144d (diff)
r300: Remove some dependencies on additional fragment program copies
The copy is still needed because some program transforms add state variables or constants. Signed-off-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/r300/r300_context.h5
-rw-r--r--src/mesa/drivers/dri/r300/r300_fragprog_common.c14
-rw-r--r--src/mesa/drivers/dri/r300/r300_fragprog_common.h4
-rw-r--r--src/mesa/drivers/dri/r300/r300_shader.c4
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.c16
-rw-r--r--src/mesa/drivers/dri/r300/r300_swtcl.c2
-rw-r--r--src/mesa/drivers/dri/r300/r300_vertprog.c6
7 files changed, 24 insertions, 27 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h
index b692f8bf809..ea30d3e12ff 100644
--- a/src/mesa/drivers/dri/r300/r300_context.h
+++ b/src/mesa/drivers/dri/r300/r300_context.h
@@ -445,14 +445,13 @@ struct r300_vertex_program_cont {
* 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 {
diff --git a/src/mesa/drivers/dri/r300/r300_fragprog_common.c b/src/mesa/drivers/dri/r300/r300_fragprog_common.c
index b37f2969126..1c57ba49e5b 100644
--- a/src/mesa/drivers/dri/r300/r300_fragprog_common.c
+++ b/src/mesa/drivers/dri/r300/r300_fragprog_common.c
@@ -90,24 +90,26 @@ static void build_state(
}
-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;
@@ -128,11 +130,11 @@ struct r300_fragment_program *r300SelectFragmentShader(GLcontext *ctx)
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;
}
diff --git a/src/mesa/drivers/dri/r300/r300_fragprog_common.h b/src/mesa/drivers/dri/r300/r300_fragprog_common.h
index 5e103ee4086..3d64c08cee9 100644
--- a/src/mesa/drivers/dri/r300/r300_fragprog_common.h
+++ b/src/mesa/drivers/dri/r300/r300_fragprog_common.h
@@ -32,8 +32,6 @@
#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
diff --git a/src/mesa/drivers/dri/r300/r300_shader.c b/src/mesa/drivers/dri/r300/r300_shader.c
index 62228a3786e..06c893881e5 100644
--- a/src/mesa/drivers/dri/r300/r300_shader.c
+++ b/src/mesa/drivers/dri/r300/r300_shader.c
@@ -122,9 +122,7 @@ static GLboolean
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 {
diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c
index 62a03281ca8..66d9a69622a 100644
--- a/src/mesa/drivers/dri/r300/r300_state.c
+++ b/src/mesa/drivers/dri/r300/r300_state.c
@@ -1462,7 +1462,7 @@ static void r300SetupRSUnit(GLcontext * ctx)
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);
@@ -1556,7 +1556,7 @@ static void r500SetupRSUnit(GLcontext * ctx)
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);
@@ -1995,9 +1995,7 @@ void r300UpdateShaders(r300ContextPtr rmesa)
{
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);
}
@@ -2034,9 +2032,11 @@ void r300UpdateShaders(r300ContextPtr rmesa)
}
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:
@@ -2103,7 +2103,7 @@ static void r300SetupPixelShader(GLcontext *ctx)
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]);
@@ -2164,7 +2164,7 @@ static void r500SetupPixelShader(GLcontext *ctx)
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]);
diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c
index a7e8e711499..1e4ea2c5775 100644
--- a/src/mesa/drivers/dri/r300/r300_swtcl.c
+++ b/src/mesa/drivers/dri/r300/r300_swtcl.c
@@ -76,7 +76,7 @@ void r300ChooseSwtclVertexFormat(GLcontext *ctx, GLuint *_InputsRead, GLuint *_
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;
diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c
index f98de34e93c..cf4788411fe 100644
--- a/src/mesa/drivers/dri/r300/r300_vertprog.c
+++ b/src/mesa/drivers/dri/r300/r300_vertprog.c
@@ -1452,7 +1452,7 @@ static void addArtificialOutputs(GLcontext *ctx, struct gl_program *prog)
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);
@@ -1499,7 +1499,7 @@ static void nqssadceInit(struct nqssadce_state* s)
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;
@@ -1639,7 +1639,7 @@ struct r300_vertex_program * r300SelectVertexShader(GLcontext *ctx)
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;