From 33af54af0da94e686ff6679d240a9ec246df3c7a Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sat, 18 Apr 2009 03:34:21 +0200 Subject: [PATCH] r300: merge r300/r500 fragment program compiler structure --- src/mesa/drivers/dri/r300/r300_context.h | 12 +++++++++--- src/mesa/drivers/dri/r300/r300_fragprog.c | 2 +- src/mesa/drivers/dri/r300/r300_fragprog.h | 8 -------- src/mesa/drivers/dri/r300/r300_fragprog_emit.c | 6 +++--- src/mesa/drivers/dri/r300/r300_state.c | 1 + src/mesa/drivers/dri/r300/r300_swtcl.c | 1 + src/mesa/drivers/dri/r300/r500_fragprog.c | 10 +++++----- src/mesa/drivers/dri/r300/r500_fragprog.h | 11 +---------- src/mesa/drivers/dri/r300/r500_fragprog_emit.c | 8 ++++---- 9 files changed, 25 insertions(+), 34 deletions(-) diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index 0c7221b1909..ff59ae7ecf4 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -43,6 +43,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "radeon_common.h" #include "main/mtypes.h" +#include "shader/prog_instruction.h" struct r300_context; typedef struct r300_context r300ContextRec; @@ -66,8 +67,6 @@ typedef struct r300_context *r300ContextPtr; } #include "r300_vertprog.h" -#include "r500_fragprog.h" - /* The blit width for texture uploads @@ -563,7 +562,7 @@ struct r300_fragment_program { GLboolean error; struct r300_fragment_program_external_state state; - union { + union rX00_fragment_program_code { struct r300_fragment_program_code r300; struct r500_fragment_program_code r500; } code; @@ -572,6 +571,13 @@ struct r300_fragment_program { GLuint optimization; }; +struct r300_fragment_program_compiler { + r300ContextPtr r300; + struct r300_fragment_program *fp; + union rX00_fragment_program_code *code; + struct gl_program *program; +}; + #define R300_MAX_AOS_ARRAYS 16 diff --git a/src/mesa/drivers/dri/r300/r300_fragprog.c b/src/mesa/drivers/dri/r300/r300_fragprog.c index 30f1bac72e7..eae4c46f694 100644 --- a/src/mesa/drivers/dri/r300/r300_fragprog.c +++ b/src/mesa/drivers/dri/r300/r300_fragprog.c @@ -417,7 +417,7 @@ void r300TranslateFragmentShader(GLcontext *ctx, struct gl_fragment_program *fp) compiler.r300 = r300; compiler.fp = r300_fp; - compiler.code = &r300_fp->code.r300; + compiler.code = &r300_fp->code; compiler.program = _mesa_clone_program(ctx, &fp->Base); if (RADEON_DEBUG & DEBUG_PIXEL) { diff --git a/src/mesa/drivers/dri/r300/r300_fragprog.h b/src/mesa/drivers/dri/r300/r300_fragprog.h index e1976277de9..631e40913c6 100644 --- a/src/mesa/drivers/dri/r300/r300_fragprog.h +++ b/src/mesa/drivers/dri/r300/r300_fragprog.h @@ -105,20 +105,12 @@ #endif -struct r300_fragment_program; - extern void r300TranslateFragmentShader(GLcontext *ctx, struct gl_fragment_program *fp); /** * Used internally by the r300 fragment program code to store compile-time * only data. */ -struct r300_fragment_program_compiler { - r300ContextPtr r300; - struct r300_fragment_program *fp; - struct r300_fragment_program_code *code; - struct gl_program *program; -}; extern GLboolean r300FragmentProgramEmit(struct r300_fragment_program_compiler *compiler); diff --git a/src/mesa/drivers/dri/r300/r300_fragprog_emit.c b/src/mesa/drivers/dri/r300/r300_fragprog_emit.c index 690734a1eb5..693d485de9e 100644 --- a/src/mesa/drivers/dri/r300/r300_fragprog_emit.c +++ b/src/mesa/drivers/dri/r300/r300_fragprog_emit.c @@ -47,7 +47,7 @@ #define PROG_CODE \ struct r300_fragment_program_compiler *c = (struct r300_fragment_program_compiler*)data; \ - struct r300_fragment_program_code *code = c->code + struct r300_fragment_program_code *code = &c->code->r300 #define error(fmt, args...) do { \ fprintf(stderr, "%s::%s(): " fmt "\n", \ @@ -213,7 +213,7 @@ static GLboolean emit_alu(void* data, struct radeon_pair_instruction* inst) */ static GLboolean finish_node(struct r300_fragment_program_compiler *c) { - struct r300_fragment_program_code *code = c->code; + struct r300_fragment_program_code *code = &c->code->r300; struct r300_fragment_program_node *node = &code->node[code->cur_node]; if (node->alu_end < 0) { @@ -327,7 +327,7 @@ static const struct radeon_pair_handler pair_handler = { */ GLboolean r300FragmentProgramEmit(struct r300_fragment_program_compiler *compiler) { - struct r300_fragment_program_code *code = compiler->code; + struct r300_fragment_program_code *code = &compiler->code->r300; _mesa_bzero(code, sizeof(struct r300_fragment_program_code)); code->node[0].alu_end = -1; diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index 9304ffb3428..493c4be6a00 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -61,6 +61,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r300_emit.h" #include "r300_fragprog.h" #include "r300_tex.h" +#include "r500_fragprog.h" #include "drirenderbuffer.h" diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c index 934e1e22431..256a2bb5cb2 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.c +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -34,6 +34,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "tnl/tnl.h" #include "tnl/t_pipeline.h" +#include "r300_state.h" #include "r300_swtcl.h" #include "r300_emit.h" #include "r300_tex.h" diff --git a/src/mesa/drivers/dri/r300/r500_fragprog.c b/src/mesa/drivers/dri/r300/r500_fragprog.c index f5804521ee3..526a0ea928f 100644 --- a/src/mesa/drivers/dri/r300/r500_fragprog.c +++ b/src/mesa/drivers/dri/r300/r500_fragprog.c @@ -62,8 +62,8 @@ static GLboolean transform_TEX( struct radeon_transform_context *t, struct prog_instruction* orig_inst, void* data) { - struct r500_fragment_program_compiler *compiler = - (struct r500_fragment_program_compiler*)data; + struct r300_fragment_program_compiler *compiler = + (struct r300_fragment_program_compiler*)data; struct prog_instruction inst = *orig_inst; struct prog_instruction* tgt; GLboolean destredirect = GL_FALSE; @@ -208,7 +208,7 @@ static void update_params(GLcontext *ctx, struct gl_fragment_program *fp) * \todo if/when r5xx supports the radeon_program architecture, this is a * likely candidate for code sharing. */ -static void insert_WPOS_trailer(struct r500_fragment_program_compiler *compiler) +static void insert_WPOS_trailer(struct r300_fragment_program_compiler *compiler) { GLuint InputsRead = compiler->fp->Base.Base.InputsRead; @@ -451,11 +451,11 @@ void r500TranslateFragmentShader(GLcontext *ctx, struct gl_fragment_program *fp) } if (!r300_fp->translated) { - struct r500_fragment_program_compiler compiler; + struct r300_fragment_program_compiler compiler; compiler.r300 = r300; compiler.fp = r300_fp; - compiler.code = &r300_fp->code.r500; + compiler.code = &r300_fp->code; compiler.program = _mesa_clone_program(ctx, &fp->Base); if (RADEON_DEBUG & DEBUG_PIXEL) { diff --git a/src/mesa/drivers/dri/r300/r500_fragprog.h b/src/mesa/drivers/dri/r300/r500_fragprog.h index 567a43cf613..4e72ef7aac2 100644 --- a/src/mesa/drivers/dri/r300/r500_fragprog.h +++ b/src/mesa/drivers/dri/r300/r500_fragprog.h @@ -45,17 +45,8 @@ #include "r300_state.h" #include "radeon_program.h" -struct r500_fragment_program; - extern void r500TranslateFragmentShader(GLcontext *ctx, struct gl_fragment_program *fp); -struct r500_fragment_program_compiler { - r300ContextPtr r300; - struct r300_fragment_program *fp; - struct r500_fragment_program_code *code; - struct gl_program *program; -}; - -extern GLboolean r500FragmentProgramEmit(struct r500_fragment_program_compiler *compiler); +extern GLboolean r500FragmentProgramEmit(struct r300_fragment_program_compiler *compiler); #endif diff --git a/src/mesa/drivers/dri/r300/r500_fragprog_emit.c b/src/mesa/drivers/dri/r300/r500_fragprog_emit.c index 4631235f0d3..d9f81004e8a 100644 --- a/src/mesa/drivers/dri/r300/r500_fragprog_emit.c +++ b/src/mesa/drivers/dri/r300/r500_fragprog_emit.c @@ -49,8 +49,8 @@ #define PROG_CODE \ - struct r500_fragment_program_compiler *c = (struct r500_fragment_program_compiler*)data; \ - struct r500_fragment_program_code *code = c->code + struct r300_fragment_program_compiler *c = (struct r300_fragment_program_compiler*)data; \ + struct r500_fragment_program_code *code = &c->code->r500 #define error(fmt, args...) do { \ fprintf(stderr, "%s::%s(): " fmt "\n", \ @@ -299,9 +299,9 @@ static const struct radeon_pair_handler pair_handler = { .MaxHwTemps = 128 }; -GLboolean r500FragmentProgramEmit(struct r500_fragment_program_compiler *compiler) +GLboolean r500FragmentProgramEmit(struct r300_fragment_program_compiler *compiler) { - struct r500_fragment_program_code *code = compiler->code; + struct r500_fragment_program_code *code = &compiler->code->r500; _mesa_bzero(code, sizeof(*code)); code->max_temp_idx = 1; -- 2.30.2