r300/compiler: add full viewport transformation support in WPOS codegen
authorMarek Olšák <maraeo@gmail.com>
Thu, 24 Dec 2009 12:31:27 +0000 (13:31 +0100)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 6 Jan 2010 20:49:15 +0000 (12:49 -0800)
src/mesa/drivers/dri/r300/compiler/radeon_code.h
src/mesa/drivers/dri/r300/compiler/radeon_compiler.c
src/mesa/drivers/dri/r300/compiler/radeon_compiler.h
src/mesa/drivers/dri/r300/r300_fragprog_common.c

index 902b7cfa53b791e46e9bdcd84812fe477af09ffd..6d979bbaecf7b17060dc66e426e31b9dcf0dde37 100644 (file)
@@ -59,7 +59,9 @@ enum {
        RC_STATE_SHADOW_AMBIENT = 0,
 
        RC_STATE_R300_WINDOW_DIMENSION,
-       RC_STATE_R300_TEXRECT_FACTOR
+       RC_STATE_R300_TEXRECT_FACTOR,
+       RC_STATE_R300_VIEWPORT_SCALE,
+       RC_STATE_R300_VIEWPORT_OFFSET
 };
 
 struct rc_constant {
index 41ea23ee3274428785bbca0f9f3225e730e0acd9..272f9072d4ae19e53d44d8637717b7558e52c3c7 100644 (file)
@@ -229,7 +229,8 @@ void rc_copy_output(struct radeon_compiler * c, unsigned output, unsigned dup_ou
 /**
  * Introduce standard code fragment to deal with fragment.position.
  */
-void rc_transform_fragment_wpos(struct radeon_compiler * c, unsigned wpos, unsigned new_input)
+void rc_transform_fragment_wpos(struct radeon_compiler * c, unsigned wpos, unsigned new_input,
+                                int full_vtransform)
 {
        unsigned tempregi = rc_find_free_temporary(c);
        struct rc_instruction * inst_rcp;
@@ -279,13 +280,19 @@ void rc_transform_fragment_wpos(struct radeon_compiler * c, unsigned wpos, unsig
        inst_mad->U.I.SrcReg[0].Swizzle = RC_MAKE_SWIZZLE(RC_SWIZZLE_X, RC_SWIZZLE_Y, RC_SWIZZLE_Z, RC_SWIZZLE_ZERO);
 
        inst_mad->U.I.SrcReg[1].File = RC_FILE_CONSTANT;
-       inst_mad->U.I.SrcReg[1].Index = rc_constants_add_state(&c->Program.Constants, RC_STATE_R300_WINDOW_DIMENSION, 0);
        inst_mad->U.I.SrcReg[1].Swizzle = RC_MAKE_SWIZZLE(RC_SWIZZLE_X, RC_SWIZZLE_Y, RC_SWIZZLE_Z, RC_SWIZZLE_ZERO);
 
        inst_mad->U.I.SrcReg[2].File = RC_FILE_CONSTANT;
-       inst_mad->U.I.SrcReg[2].Index = inst_mad->U.I.SrcReg[1].Index;
        inst_mad->U.I.SrcReg[2].Swizzle = RC_MAKE_SWIZZLE(RC_SWIZZLE_X, RC_SWIZZLE_Y, RC_SWIZZLE_Z, RC_SWIZZLE_ZERO);
 
+       if (full_vtransform) {
+               inst_mad->U.I.SrcReg[1].Index = rc_constants_add_state(&c->Program.Constants, RC_STATE_R300_VIEWPORT_SCALE, 0);
+               inst_mad->U.I.SrcReg[2].Index = rc_constants_add_state(&c->Program.Constants, RC_STATE_R300_VIEWPORT_OFFSET, 0);
+       } else {
+               inst_mad->U.I.SrcReg[1].Index =
+               inst_mad->U.I.SrcReg[2].Index = rc_constants_add_state(&c->Program.Constants, RC_STATE_R300_WINDOW_DIMENSION, 0);
+       }
+
        for (inst = inst_mad->Next; inst != &c->Program.Instructions; inst = inst->Next) {
                const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
                unsigned i;
index 87a732cd90d08489a56a98c5790b2bdd2ebe148e..731adc1af2b772085152bee21c7d486f544f9f34 100644 (file)
@@ -73,7 +73,8 @@ void rc_calculate_inputs_outputs(struct radeon_compiler * c);
 void rc_move_input(struct radeon_compiler * c, unsigned input, struct rc_src_register new_input);
 void rc_move_output(struct radeon_compiler * c, unsigned output, unsigned new_output, unsigned writemask);
 void rc_copy_output(struct radeon_compiler * c, unsigned output, unsigned dup_output);
-void rc_transform_fragment_wpos(struct radeon_compiler * c, unsigned wpos, unsigned new_input);
+void rc_transform_fragment_wpos(struct radeon_compiler * c, unsigned wpos, unsigned new_input,
+                                int full_vtransform);
 
 struct r300_fragment_program_compiler {
        struct radeon_compiler Base;
index 267ee81a7a6a1b04fe099794cb7a833c07827f02..2933d31136c400ce8f86b3d2052c27e1fadad3d3 100644 (file)
@@ -120,7 +120,7 @@ static void insert_WPOS_trailer(struct r300_fragment_program_compiler *compiler,
                return;
        }
 
-       rc_transform_fragment_wpos(&compiler->Base, FRAG_ATTRIB_WPOS, fp->wpos_attr);
+       rc_transform_fragment_wpos(&compiler->Base, FRAG_ATTRIB_WPOS, fp->wpos_attr, GL_FALSE);
 }
 
 /**