OSDN Git Service

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 0c7221b..ff59ae7 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 30f1bac..eae4c46 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 e197627..631e409 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 690734a..693d485 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 9304ffb..493c4be 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 934e1e2..256a2bb 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 f580452..526a0ea 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 567a43c..4e72ef7 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 4631235..d9f8100 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;