tgsi: Update for gallium interface changes.
[mesa.git] / src / gallium / auxiliary / tgsi / tgsi_exec.h
index fc40a25e09f3f9a80f1ac49846554f9834d8b368..08df15ec6a087c751810573ae6616be4baefcd97 100644 (file)
 #define TGSI_EXEC_H
 
 #include "pipe/p_compiler.h"
+#include "pipe/p_state.h"
 
 #if defined __cplusplus
 extern "C" {
 #endif
 
-#define MAX_LABELS 1024
+#define MAX_LABELS (4 * 1024)  /**< basically, max instructions */
 
 #define NUM_CHANNELS 4  /* R,G,B,A */
 #define QUAD_SIZE    4  /* 4 pixel/quad */
@@ -68,17 +69,12 @@ struct tgsi_interp_coef
    float dady[NUM_CHANNELS];
 };
 
-
-struct softpipe_tile_cache;  /**< Opaque to TGSI */
-
 /**
  * Information for sampling textures, which must be implemented
  * by code outside the TGSI executor.
  */
 struct tgsi_sampler
 {
-   const struct pipe_sampler_state *state;
-   struct pipe_texture *texture;
    /** Get samples for four fragments in a quad */
    void (*get_samples)(struct tgsi_sampler *sampler,
                        const float s[QUAD_SIZE],
@@ -86,8 +82,6 @@ struct tgsi_sampler
                        const float p[QUAD_SIZE],
                        float lodbias,
                        float rgba[NUM_CHANNELS][QUAD_SIZE]);
-   void *pipe; /*XXX temporary*/
-   struct softpipe_tile_cache *cache;
 };
 
 /**
@@ -101,7 +95,6 @@ struct tgsi_exec_labels
 
 
 #define TGSI_EXEC_NUM_TEMPS       128
-#define TGSI_EXEC_NUM_TEMP_EXTRAS   6
 #define TGSI_EXEC_NUM_IMMEDIATES  256
 
 /*
@@ -169,41 +162,69 @@ struct tgsi_exec_labels
 #define TGSI_EXEC_MASK_I            (TGSI_EXEC_NUM_TEMPS + 3)
 #define TGSI_EXEC_MASK_C            2
 
+/* 4 register buffer for various purposes */
 #define TGSI_EXEC_TEMP_R0           (TGSI_EXEC_NUM_TEMPS + 4)
+#define TGSI_EXEC_NUM_TEMP_R        4
+
+#define TGSI_EXEC_TEMP_ADDR         (TGSI_EXEC_NUM_TEMPS + 8)
+#define TGSI_EXEC_NUM_ADDRS         1
+
+/* predicate register */
+#define TGSI_EXEC_TEMP_P0           (TGSI_EXEC_NUM_TEMPS + 9)
+#define TGSI_EXEC_NUM_PREDS         1
+
+#define TGSI_EXEC_NUM_TEMP_EXTRAS   10
 
-#define TGSI_EXEC_TEMP_ADDR         (TGSI_EXEC_NUM_TEMPS + 5)
 
 
 #define TGSI_EXEC_MAX_COND_NESTING  20
 #define TGSI_EXEC_MAX_LOOP_NESTING  20
 #define TGSI_EXEC_MAX_CALL_NESTING  20
 
+/* The maximum number of input attributes per vertex. For 2D
+ * input register files, this is the stride between two 1D
+ * arrays.
+ */
+#define TGSI_EXEC_MAX_INPUT_ATTRIBS 17
+
+/* The maximum number of constant vectors per constant buffer.
+ */
+#define TGSI_EXEC_MAX_CONST_BUFFER  4096
+
+
+/** function call/activation record */
+struct tgsi_call_record
+{
+   uint CondStackTop;
+   uint LoopStackTop;
+   uint ContStackTop;
+   uint ReturnAddr;
+};
+
+
 /**
  * Run-time virtual machine state for executing TGSI shader.
  */
 struct tgsi_exec_machine
 {
    /* Total = program temporaries + internal temporaries
-    *         + 1 padding to align to 16 bytes
     */
-   struct tgsi_exec_vector       _Temps[TGSI_EXEC_NUM_TEMPS +
-                                        TGSI_EXEC_NUM_TEMP_EXTRAS + 1];
+   struct tgsi_exec_vector       Temps[TGSI_EXEC_NUM_TEMPS +
+                                       TGSI_EXEC_NUM_TEMP_EXTRAS];
+
+   float                         Imms[TGSI_EXEC_NUM_IMMEDIATES][4];
+
+   struct tgsi_exec_vector       Inputs[PIPE_MAX_ATTRIBS];
+   struct tgsi_exec_vector       Outputs[PIPE_MAX_ATTRIBS];
 
-   /*
-    * This will point to _Temps after aligning to 16B boundary.
-    */
-   struct tgsi_exec_vector       *Temps;
    struct tgsi_exec_vector       *Addrs;
 
-   struct tgsi_sampler           *Samplers;
+   struct tgsi_sampler           **Samplers;
 
-   float                         Imms[TGSI_EXEC_NUM_IMMEDIATES][4];
    unsigned                      ImmLimit;
    const float                   (*Consts)[4];
-   struct tgsi_exec_vector       *Inputs;
-   struct tgsi_exec_vector       *Outputs;
-   const struct tgsi_token       *Tokens;
-   unsigned                      Processor;
+   const struct tgsi_token       *Tokens;   /**< Declarations, instructions */
+   unsigned                      Processor; /**< TGSI_PROCESSOR_x */
 
    /* GEOMETRY processor only. */
    unsigned                      *Primitives;
@@ -227,6 +248,14 @@ struct tgsi_exec_machine
    uint LoopStack[TGSI_EXEC_MAX_LOOP_NESTING];
    int LoopStackTop;
 
+   /** Loop label stack */
+   uint LoopLabelStack[TGSI_EXEC_MAX_LOOP_NESTING];
+   int LoopLabelStackTop;
+
+   /** Loop counter stack (x = count, y = current, z = step) */
+   struct tgsi_exec_vector LoopCounterStack[TGSI_EXEC_MAX_LOOP_NESTING];
+   int LoopCounterStackTop;
+   
    /** Loop continue mask stack (see comments in tgsi_exec.c) */
    uint ContStack[TGSI_EXEC_MAX_LOOP_NESTING];
    int ContStackTop;
@@ -236,7 +265,7 @@ struct tgsi_exec_machine
    int FuncStackTop;
 
    /** Function call stack for saving/restoring the program counter */
-   uint CallStack[TGSI_EXEC_MAX_CALL_NESTING];
+   struct tgsi_call_record CallStack[TGSI_EXEC_MAX_CALL_NESTING];
    int CallStackTop;
 
    struct tgsi_full_instruction *Instructions;
@@ -248,9 +277,11 @@ struct tgsi_exec_machine
    struct tgsi_exec_labels Labels;
 };
 
+struct tgsi_exec_machine *
+tgsi_exec_machine_create( void );
+
 void
-tgsi_exec_machine_init(
-   struct tgsi_exec_machine *mach );
+tgsi_exec_machine_destroy(struct tgsi_exec_machine *mach);
 
 
 void 
@@ -258,7 +289,7 @@ tgsi_exec_machine_bind_shader(
    struct tgsi_exec_machine *mach,
    const struct tgsi_token *tokens,
    uint numSamplers,
-   struct tgsi_sampler *samplers);
+   struct tgsi_sampler **samplers);
 
 uint
 tgsi_exec_machine_run(
@@ -269,6 +300,10 @@ void
 tgsi_exec_machine_free_data(struct tgsi_exec_machine *mach);
 
 
+boolean
+tgsi_check_soa_dependencies(const struct tgsi_full_instruction *inst);
+
+
 static INLINE void
 tgsi_set_kill_mask(struct tgsi_exec_machine *mach, unsigned mask)
 {