r300/compiler: use perspective division only for TXP in shadow samplers
[mesa.git] / src / mesa / drivers / dri / r300 / compiler / radeon_compiler.h
index e63ab8840abbfc104cdbc39f08d2280b8aa088fe..09794a52ad82709ef6efa85371a4d8931c2fb12c 100644 (file)
 #ifndef RADEON_COMPILER_H
 #define RADEON_COMPILER_H
 
-#include "main/mtypes.h"
-#include "shader/prog_instruction.h"
+#include "../../../../main/compiler.h"
 
 #include "memory_pool.h"
 #include "radeon_code.h"
+#include "radeon_program.h"
 
-
-struct rc_instruction {
-       struct rc_instruction * Prev;
-       struct rc_instruction * Next;
-       struct prog_instruction I;
-};
-
-struct rc_program {
-       /**
-        * Instructions.Next points to the first instruction,
-        * Instructions.Prev points to the last instruction.
-        */
-       struct rc_instruction Instructions;
-
-       /* Long term, we should probably remove InputsRead & OutputsWritten,
-        * since updating dependent state can be fragile, and they aren't
-        * actually used very often. */
-       uint32_t InputsRead;
-       uint32_t OutputsWritten;
-       uint32_t ShadowSamplers; /**< Texture units used for shadow sampling. */
-
-       struct rc_constant_list Constants;
-};
+struct rc_swizzle_caps;
 
 struct radeon_compiler {
        struct memory_pool Pool;
@@ -59,6 +37,14 @@ struct radeon_compiler {
        unsigned Debug:1;
        unsigned Error:1;
        char * ErrorMsg;
+
+       /**
+        * Variables used internally, not be touched by callers
+        * of the compiler
+        */
+       /*@{*/
+       struct rc_swizzle_caps * SwizzleCaps;
+       /*@}*/
 };
 
 void rc_init(struct radeon_compiler * c);
@@ -67,22 +53,44 @@ void rc_destroy(struct radeon_compiler * c);
 void rc_debug(struct radeon_compiler * c, const char * fmt, ...);
 void rc_error(struct radeon_compiler * c, const char * fmt, ...);
 
-void rc_mesa_to_rc_program(struct radeon_compiler * c, struct gl_program * program);
+int rc_if_fail_helper(struct radeon_compiler * c, const char * file, int line, const char * assertion);
+
+/**
+ * This macro acts like an if-statement that can be used to implement
+ * non-aborting assertions in the compiler.
+ *
+ * It checks whether \p cond is true. If not, an internal compiler error is
+ * flagged and the if-clause is run.
+ *
+ * A typical use-case would be:
+ *
+ *  if (rc_assert(c, condition-that-must-be-true))
+ *     return;
+ */
+#define rc_assert(c, cond) \
+       (!(cond) && rc_if_fail_helper(c, __FILE__, __LINE__, #cond))
 
 void rc_calculate_inputs_outputs(struct radeon_compiler * c);
 
-void rc_move_input(struct radeon_compiler * c, unsigned input, struct prog_src_register new_input);
+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;
        struct rX00_fragment_program_code *code;
+       /* Optional transformations and features. */
        struct r300_fragment_program_external_state state;
+       unsigned enable_shadow_ambient;
+       /* Hardware specification. */
        unsigned is_r500;
+       unsigned max_temp_regs;
+    /* Register corresponding to the depthbuffer. */
        unsigned OutputDepth;
-       unsigned OutputColor;
+    /* Registers corresponding to the four colorbuffers. */
+       unsigned OutputColor[4];
 
        void * UserData;
        void (*AllocateHwInputs)(
@@ -97,7 +105,7 @@ void r3xx_compile_fragment_program(struct r300_fragment_program_compiler* c);
 struct r300_vertex_program_compiler {
        struct radeon_compiler Base;
        struct r300_vertex_program_code *code;
-       GLbitfield RequiredOutputs;
+       uint32_t RequiredOutputs;
 
        void * UserData;
        void (*SetHwInputOutput)(struct r300_vertex_program_compiler * c);