gallium/util: add 1d/2d mipmap generation support
[mesa.git] / src / gallium / auxiliary / draw / draw_vs_aos.h
index 16fef6451c4c09e1795426a45cb015f960e8ed04..55e63d8b9fabbc68a8319e25b23a4abde062767d 100644 (file)
 #ifndef DRAW_VS_AOS_H
 #define DRAW_VS_AOS_H
 
+#include "pipe/p_config.h"
+#include "tgsi/tgsi_exec.h"
+#include "draw_vs.h"
+
+#ifdef PIPE_ARCH_X86
 
 struct tgsi_token;
 struct x86_function;
@@ -48,40 +53,80 @@ struct x86_function;
 #define W    3
 
 #define MAX_INPUTS     PIPE_MAX_ATTRIBS
-#define MAX_OUTPUTS    PIPE_MAX_ATTRIBS
-#define MAX_TEMPS      PIPE_MAX_ATTRIBS /* say */
-#define MAX_CONSTANTS  PIPE_MAX_ATTRIBS /* say */
-#define MAX_IMMEDIATES PIPE_MAX_ATTRIBS /* say */
-#define MAX_INTERNALS  4
+#define MAX_OUTPUTS    PIPE_MAX_SHADER_OUTPUTS
+#define MAX_TEMPS      TGSI_EXEC_NUM_TEMPS
+#define MAX_CONSTANTS  1024  /** only used for sanity checking */
+#define MAX_IMMEDIATES 1024  /** only used for sanity checking */
+#define MAX_INTERNALS  8     /** see IMM_x values below */
 
 #define AOS_FILE_INTERNAL TGSI_FILE_COUNT
 
-/* This is the temporary storage used by all the aos_sse vs varients.
+#define FPU_RND_NEG    1
+#define FPU_RND_NEAREST 2
+
+struct aos_machine;
+typedef void (PIPE_CDECL *lit_func)( struct aos_machine *,
+                                    float *result,
+                                    const float *in,
+                                    unsigned count );
+
+void PIPE_CDECL aos_do_lit( struct aos_machine *machine,
+                            float *result,
+                            const float *in,
+                            unsigned count );
+
+struct shine_tab {
+   float exponent;
+   float values[258];
+   unsigned last_used;
+};
+
+struct lit_info {
+   lit_func func;
+   struct shine_tab *shine_tab;
+};
+
+#define MAX_SHINE_TAB    4
+#define MAX_LIT_INFO     16
+
+struct aos_buffer {
+   const void *base_ptr;
+   unsigned stride;
+   void *ptr;                   /* updated per vertex */
+};
+
+
+
+
+/* This is the temporary storage used by all the aos_sse vs variants.
  * Create one per context and reuse by passing a pointer in at
- * vs_varient creation??
+ * vs_variant creation??
  */
 struct aos_machine {
    float input    [MAX_INPUTS    ][4];
    float output   [MAX_OUTPUTS   ][4];
    float temp     [MAX_TEMPS     ][4];
-   float constant [MAX_CONSTANTS ][4]; /* fixme -- should just be a pointer */
-   float immediate[MAX_IMMEDIATES][4]; /* fixme -- should just be a pointer */
    float internal [MAX_INTERNALS ][4];
 
    float scale[4];              /* viewport */
    float translate[4];          /* viewport */
 
-   ushort fpu_round_nearest;
-   ushort fpu_round_neg_inf;
+   float tmp[2][4];             /* scratch space for LIT */
+
+   struct shine_tab shine_tab[MAX_SHINE_TAB];
+   struct lit_info  lit_info[MAX_LIT_INFO];
+   unsigned now;
+   
+
+   ushort fpu_rnd_nearest;
+   ushort fpu_rnd_neg_inf;
    ushort fpu_restore;
    ushort fpucntl;              /* one of FPU_* above */
 
-   struct {
-      const void *input_ptr;
-      unsigned input_stride;
+   const float (*immediates)[4];     /* points to shader data */
+   const void *constants[PIPE_MAX_CONSTANT_BUFFERS]; /* points to draw data */
 
-      unsigned output_offset;
-   } attrib[PIPE_MAX_ATTRIBS];
+   const struct aos_buffer *buffer; /* points to ? */
 };
 
 
@@ -89,10 +134,12 @@ struct aos_machine {
 
 struct aos_compilation {
    struct x86_function *func;
-   struct draw_vs_varient_aos_sse *vaos;
+   struct draw_vs_variant_aos_sse *vaos;
 
    unsigned insn_counter;
    unsigned num_immediates;
+   unsigned count;
+   unsigned lit_count;
 
    struct {
       unsigned idx:16;
@@ -101,6 +148,7 @@ struct aos_compilation {
       unsigned last_used;
    } xmm[8];
 
+   unsigned x86_reg[2];                /* one of X86_* */
 
    boolean input_fetched[PIPE_MAX_ATTRIBS];
    unsigned output_last_write[PIPE_MAX_ATTRIBS];
@@ -117,6 +165,8 @@ struct aos_compilation {
    struct x86_reg outbuf_ECX;
    struct x86_reg machine_EDX;
    struct x86_reg count_ESI;    /* decrements to zero */
+   struct x86_reg temp_EBP;
+   struct x86_reg stack_ESP;
 };
 
 struct x86_reg aos_get_xmm_reg( struct aos_compilation *cp );
@@ -128,59 +178,78 @@ void aos_adopt_xmm_reg( struct aos_compilation *cp,
                         unsigned idx,
                         unsigned dirty );
 
+void aos_spill_all( struct aos_compilation *cp );
+
 struct x86_reg aos_get_shader_reg( struct aos_compilation *cp, 
                                    unsigned file,
                                    unsigned idx );
 
-boolean aos_fetch_inputs( struct aos_compilation *cp,
-                          boolean linear );
+boolean aos_init_inputs( struct aos_compilation *cp, boolean linear );
+boolean aos_fetch_inputs( struct aos_compilation *cp, boolean linear );
+boolean aos_incr_inputs( struct aos_compilation *cp, boolean linear );
 
 boolean aos_emit_outputs( struct aos_compilation *cp );
 
 
 #define IMM_ONES     0              /* 1, 1,1,1 */
-#define IMM_NEGS     1              /* 1,-1,0,0 */
+#define IMM_SWZ      1              /* 1,-1,0, 0xffffffff */
 #define IMM_IDENTITY 2              /* 0, 0,0,1 */
 #define IMM_INV_255  3              /* 1/255, 1/255, 1/255, 1/255 */
 #define IMM_255      4              /* 255, 255, 255, 255 */
+#define IMM_NEGS     5              /* -1,-1,-1,-1 */
+#define IMM_RSQ      6              /* -.5,1.5,_,_ */
+#define IMM_PSIZE    7              /* not really an immediate - updated each run */
 
 struct x86_reg aos_get_internal( struct aos_compilation *cp,
                                  unsigned imm );
+struct x86_reg aos_get_internal_xmm( struct aos_compilation *cp,
+                                     unsigned imm );
 
 
-#define ERROR(cp, msg)                                                  \
+#define AOS_ERROR(cp, msg)                                                  \
 do {                                                                    \
-   debug_printf("%s: x86 translation failed: %s\n", __FUNCTION__, msg); \
+   if (0) debug_printf("%s: x86 translation failed: %s\n", __FUNCTION__, msg); \
    cp->error = 1;                                                       \
-   assert(0);                                                           \
 } while (0)
 
 
+#define X86_NULL       0
+#define X86_IMMEDIATES 1
+#define X86_CONSTANTS  2
+#define X86_BUFFERS    3
 
+struct x86_reg aos_get_x86( struct aos_compilation *cp,
+                            unsigned which_reg,
+                            unsigned value );
 
 
+typedef void (PIPE_CDECL *vaos_run_elts_func)( struct aos_machine *,
+                                               const unsigned *elts,
+                                               unsigned count,
+                                               void *output_buffer);
 
-struct draw_vs_varient_aos_sse {
-   struct draw_vs_varient base;
-   struct draw_context *draw;
+typedef void (PIPE_CDECL *vaos_run_linear_func)( struct aos_machine *,
+                                                unsigned start,
+                                                unsigned count,
+                                                void *output_buffer);
 
-#if 0
-   struct {
-      const void *ptr;
-      unsigned stride;
-   } attrib[PIPE_MAX_ATTRIBS];
-#endif
 
-   struct aos_machine *machine; /* XXX: temporarily unshared */
+struct draw_vs_variant_aos_sse {
+   struct draw_vs_variant base;
+   struct draw_context *draw;
+
+   struct aos_buffer *buffer;
+   unsigned nr_vb;
 
-   vsv_run_linear_func gen_run_linear;
-   vsv_run_elts_func gen_run_elts;
+   vaos_run_linear_func gen_run_linear;
+   vaos_run_elts_func gen_run_elts;
 
 
    struct x86_function func[2];
 };
 
 
+#endif
 
 #endif