i965: Share emit_fb_write() between brw_wm_emit.c and brw_wm_glsl.c
[mesa.git] / src / mesa / drivers / dri / i965 / brw_wm.h
index ae98b5492db98c6eb793cf88942d56ca847700d3..bde0c366bd1c9d2a4227c92263e899f04668adea 100644 (file)
@@ -38,6 +38,8 @@
 #include "brw_context.h"
 #include "brw_eu.h"
 
+#define SATURATE (1<<5)
+
 /* A big lookup table is used to figure out which and how many
  * additional regs will inserted before the main payload in the WM
  * program execution.  These mainly relate to depth and stencil
@@ -65,17 +67,18 @@ struct brw_wm_prog_key {
    GLuint flat_shade:1;
    GLuint linear_color:1;  /**< linear interpolation vs perspective interp */
    GLuint runtime_check_aads_emit:1;
+   GLuint nr_color_regions:2;
    
    GLbitfield proj_attrib_mask; /**< one bit per fragment program attribute */
    GLuint shadowtex_mask:16;
    GLuint yuvtex_mask:16;
    GLuint yuvtex_swap_mask:16; /* UV swaped */
 
-   GLuint tex_swizzles[BRW_MAX_TEX_UNIT];
+   GLushort tex_swizzles[BRW_MAX_TEX_UNIT];
 
    GLuint program_string_id:32;
-   GLuint origin_x, origin_y;
-   GLuint drawable_height;
+   GLushort origin_x, origin_y;
+   GLushort drawable_height;
    GLuint vp_outputs_written;
 };
 
@@ -151,15 +154,16 @@ struct brw_wm_instruction {
 };
 
 
-#define BRW_WM_MAX_INSN  (MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS*3 + FRAG_ATTRIB_MAX + 3)
+#define BRW_WM_MAX_INSN  (MAX_PROGRAM_INSTRUCTIONS*3 + FRAG_ATTRIB_MAX + 3)
 #define BRW_WM_MAX_GRF   128           /* hardware limit */
 #define BRW_WM_MAX_VREG  (BRW_WM_MAX_INSN * 4)
 #define BRW_WM_MAX_REF   (BRW_WM_MAX_INSN * 12)
 #define BRW_WM_MAX_PARAM 256
 #define BRW_WM_MAX_CONST 256
-#define BRW_WM_MAX_KILLS MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS
 #define BRW_WM_MAX_SUBROUTINE 16
 
+/* used in masks next to WRITEMASK_*. */
+#define SATURATE (1<<5)
 
 
 /* New opcodes to track internal operations required for WM unit.
@@ -203,7 +207,6 @@ struct brw_wm_compile {
    GLuint fp_temp;
    GLuint fp_interp_emitted;
    GLuint fp_fragcolor_emitted;
-   GLuint fp_deriv_emitted;
 
    struct prog_src_register pixel_xy;
    struct prog_src_register delta_xy;
@@ -270,6 +273,12 @@ struct brw_wm_compile {
 };
 
 
+/** Bits for prog_instruction::Aux field */
+#define INST_AUX_EOT      0x1
+#define INST_AUX_TARGET(T)  (T << 1)
+#define INST_AUX_GET_TARGET(AUX) ((AUX) >> 1)
+
+
 GLuint brw_wm_nr_args( GLuint opcode );
 GLuint brw_wm_is_scalar_result( GLuint opcode );
 
@@ -299,5 +308,116 @@ void brw_wm_lookup_iz( GLuint line_aa,
 GLboolean brw_wm_is_glsl(const struct gl_fragment_program *fp);
 void brw_wm_glsl_emit(struct brw_context *brw, struct brw_wm_compile *c);
 
+/* brw_wm_emit.c */
+void emit_alu1(struct brw_compile *p,
+              struct brw_instruction *(*func)(struct brw_compile *,
+                                              struct brw_reg,
+                                              struct brw_reg),
+              const struct brw_reg *dst,
+              GLuint mask,
+              const struct brw_reg *arg0);
+void emit_alu2(struct brw_compile *p,
+              struct brw_instruction *(*func)(struct brw_compile *,
+                                              struct brw_reg,
+                                              struct brw_reg,
+                                              struct brw_reg),
+              const struct brw_reg *dst,
+              GLuint mask,
+              const struct brw_reg *arg0,
+              const struct brw_reg *arg1);
+void emit_cinterp(struct brw_compile *p,
+                 const struct brw_reg *dst,
+                 GLuint mask,
+                 const struct brw_reg *arg0);
+void emit_ddxy(struct brw_compile *p,
+              const struct brw_reg *dst,
+              GLuint mask,
+              GLboolean is_ddx,
+              const struct brw_reg *arg0);
+void emit_delta_xy(struct brw_compile *p,
+                  const struct brw_reg *dst,
+                  GLuint mask,
+                  const struct brw_reg *arg0);
+void emit_dp3(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1);
+void emit_dp4(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1);
+void emit_dph(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1);
+void emit_fb_write(struct brw_wm_compile *c,
+                  struct brw_reg *arg0,
+                  struct brw_reg *arg1,
+                  struct brw_reg *arg2,
+                  GLuint target,
+                  GLuint eot);
+void emit_frontfacing(struct brw_compile *p,
+                     const struct brw_reg *dst,
+                     GLuint mask);
+void emit_linterp(struct brw_compile *p,
+                 const struct brw_reg *dst,
+                 GLuint mask,
+                 const struct brw_reg *arg0,
+                 const struct brw_reg *deltas);
+void emit_lrp(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1,
+             const struct brw_reg *arg2);
+void emit_mad(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1,
+             const struct brw_reg *arg2);
+void emit_math1(struct brw_wm_compile *c,
+               GLuint function,
+               const struct brw_reg *dst,
+               GLuint mask,
+               const struct brw_reg *arg0);
+void emit_math2(struct brw_wm_compile *c,
+               GLuint function,
+               const struct brw_reg *dst,
+               GLuint mask,
+               const struct brw_reg *arg0,
+               const struct brw_reg *arg1);
+void emit_pinterp(struct brw_compile *p,
+                 const struct brw_reg *dst,
+                 GLuint mask,
+                 const struct brw_reg *arg0,
+                 const struct brw_reg *deltas,
+                 const struct brw_reg *w);
+void emit_pixel_xy(struct brw_wm_compile *c,
+                  const struct brw_reg *dst,
+                  GLuint mask);
+void emit_pixel_w(struct brw_wm_compile *c,
+                 const struct brw_reg *dst,
+                 GLuint mask,
+                 const struct brw_reg *arg0,
+                 const struct brw_reg *deltas);
+void emit_sop(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             GLuint cond,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1);
+void emit_wpos_xy(struct brw_wm_compile *c,
+                 const struct brw_reg *dst,
+                 GLuint mask,
+                 const struct brw_reg *arg0);
+void emit_xpd(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1);
 
 #endif