r300: merge r300/r500 fragment program compiler structure
authorMaciej Cencora <m.cencora@gmail.com>
Sat, 18 Apr 2009 01:34:21 +0000 (03:34 +0200)
committerDave Airlie <airlied@linux.ie>
Sun, 19 Apr 2009 12:14:46 +0000 (22:14 +1000)
src/mesa/drivers/dri/r300/r300_context.h
src/mesa/drivers/dri/r300/r300_fragprog.c
src/mesa/drivers/dri/r300/r300_fragprog.h
src/mesa/drivers/dri/r300/r300_fragprog_emit.c
src/mesa/drivers/dri/r300/r300_state.c
src/mesa/drivers/dri/r300/r300_swtcl.c
src/mesa/drivers/dri/r300/r500_fragprog.c
src/mesa/drivers/dri/r300/r500_fragprog.h
src/mesa/drivers/dri/r300/r500_fragprog_emit.c

index 0c7221b190982c7a1b12db3b824437063a8ae719..ff59ae7ecf4f39e401d30bd0e330b9abd36edacc 100644 (file)
@@ -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
 
 
index 30f1bac72e707e1e9c80ea0a5353fc5a1348526c..eae4c46f694cbab5cbc3605f52e2b325dbc091fe 100644 (file)
@@ -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) {
index e1976277de99db8b87b02f1a74622a62fba1b919..631e40913c648a2f075bb95043ad21ca8d877c00 100644 (file)
 
 #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);
 
index 690734a1eb535532dd92abe420ed97b9db6bbc40..693d485de9e620fff08ca277866b2c59c8ceb92d 100644 (file)
@@ -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;
index 9304ffb34284b229512393e35f128faf0e04fa5a..493c4be6a0064d37ca5100a077325138315988bc 100644 (file)
@@ -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"
 
index 934e1e22431ff2b3b4a94083a402458408d0e3d7..256a2bb5cb2ce242b43d9fbaf53d99150b554eb4 100644 (file)
@@ -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"
index f5804521ee323167a9dd52f58d5b68f98d458878..526a0ea928fa82dfc8396c8828d3a9ab485dd3ef 100644 (file)
@@ -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) {
index 567a43cf613cf202383bab9c6235187c45762d51..4e72ef7aac2979e8153194a4eea273a961042823 100644 (file)
 #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
index 4631235f0d3eae07d3ddecf79edfcbeb39c7a1f4..d9f81004e8a30ed3ce3746da425bad98550d2510 100644 (file)
@@ -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;