radeon/r200/r300: Fix swtcl prediction to work after primitie change.
[mesa.git] / src / mesa / drivers / dri / radeon / radeon_common_context.h
index 061168fe96b0300fb7538aa2472525d8106f925d..427eb946ffa8316d0754567f3d33f3efb1aec55b 100644 (file)
 #include "dri_util.h"
 #include "tnl/t_vertex.h"
 
+#include "dri_metaops.h"
 struct radeon_context;
 
 #include "radeon_bocs_wrapper.h"
 
+/* From http://gcc. gnu.org/onlinedocs/gcc-3.2.3/gcc/Variadic-Macros.html .
+   I suppose we could inline this and use macro to fetch out __LINE__ and stuff in case we run into trouble
+   with other compilers ... GLUE!
+*/
+#define WARN_ONCE(a, ...)      { \
+       static int warn##__LINE__=1; \
+       if(warn##__LINE__){ \
+               fprintf(stderr, "*********************************WARN_ONCE*********************************\n"); \
+               fprintf(stderr, "File %s function %s line %d\n", \
+                       __FILE__, __FUNCTION__, __LINE__); \
+               fprintf(stderr,  a, ## __VA_ARGS__);\
+               fprintf(stderr, "***************************************************************************\n"); \
+               warn##__LINE__=0;\
+               } \
+       }
+
 /* This union is used to avoid warnings/miscompilation
    with float to uint32_t casts due to strict-aliasing */
 typedef union { GLfloat f; uint32_t ui32; } float_ui32_type;
@@ -83,8 +100,6 @@ struct radeon_renderbuffer
        unsigned int cpp;
        /* unsigned int offset; */
        unsigned int pitch;
-       unsigned int width;
-       unsigned int height;
 
        uint32_t draw_offset; /* FBO */
        /* boo Xorg 6.8.2 compat */
@@ -164,6 +179,7 @@ struct radeon_hw_state {
        /* Head of the linked list of state atoms. */
        struct radeon_state_atom atomlist;
        int max_state_size;     /* Number of bytes necessary for a full state emit. */
+       int max_post_flush_size; /* Number of bytes necessary for post flushing emits */
        GLboolean is_dirty, all_dirty;
 };
 
@@ -227,6 +243,24 @@ struct radeon_tex_obj {
 
         GLuint pp_txfilter_1;  /*  r300 */
 
+       /* r700 texture states */
+       GLuint SQ_TEX_RESOURCE0;
+       GLuint SQ_TEX_RESOURCE1;
+       GLuint SQ_TEX_RESOURCE2;
+       GLuint SQ_TEX_RESOURCE3;
+       GLuint SQ_TEX_RESOURCE4;
+       GLuint SQ_TEX_RESOURCE5;
+       GLuint SQ_TEX_RESOURCE6;
+
+       GLuint SQ_TEX_SAMPLER0;
+       GLuint SQ_TEX_SAMPLER1;
+       GLuint SQ_TEX_SAMPLER2;
+
+       GLuint TD_PS_SAMPLER0_BORDER_RED;
+       GLuint TD_PS_SAMPLER0_BORDER_GREEN;
+       GLuint TD_PS_SAMPLER0_BORDER_BLUE;
+       GLuint TD_PS_SAMPLER0_BORDER_ALPHA;
+
        GLboolean border_fallback;
 
 
@@ -237,6 +271,17 @@ static INLINE radeonTexObj* radeon_tex_obj(struct gl_texture_object *texObj)
        return (radeonTexObj*)texObj;
 }
 
+/* occlusion query */
+struct radeon_query_object {
+       struct gl_query_object Base;
+       struct radeon_bo *bo;
+       int curr_offset;
+       GLboolean emitted_begin;
+
+       /* Double linked list of not flushed query objects */
+       struct radeon_query_object *prev, *next;
+};
+
 /* Need refcounting on dma buffers:
  */
 struct radeon_dma_buffer {
@@ -252,14 +297,25 @@ struct radeon_aos {
        int count; /** Number of vertices */
 };
 
+#define DMA_BO_FREE_TIME 100
+
+struct radeon_dma_bo {
+  struct radeon_dma_bo *next, *prev;
+  struct radeon_bo *bo;
+  int expire_counter;
+};
+
 struct radeon_dma {
         /* Active dma region.  Allocations for vertices and retained
          * regions come from here.  Also used for emitting random vertices,
          * these may be flushed by calling flush_current();
          */
-        struct radeon_bo *current; /** Buffer that DMA memory is allocated from */
-        int current_used; /** Number of bytes allocated and forgotten about */
-        int current_vertexptr; /** End of active vertex region */
+       struct radeon_dma_bo free;
+       struct radeon_dma_bo wait;
+       struct radeon_dma_bo reserved;
+        size_t current_used; /** Number of bytes allocated and forgotten about */
+        size_t current_vertexptr; /** End of active vertex region */
+        size_t minimum_size;
 
         /**
          * If current_vertexptr != current_used then flush must be non-zero.
@@ -267,12 +323,6 @@ struct radeon_dma {
          * performed.
          */
         void (*flush) (GLcontext *);
-
-        /* Number of "in-flight" DMA buffers, i.e. the number of buffers
-         * for which a DISCARD command is currently queued in the command buffer
-.
-         */
-        GLuint nr_released_bufs;
 };
 
 /* radeon_swtcl.c
@@ -292,6 +342,7 @@ struct radeon_swtcl_info {
        struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
        GLuint vertex_attr_count;
 
+       GLuint emit_prediction;
 };
 
 #define RADEON_MAX_AOS_ARRAYS          16
@@ -304,7 +355,8 @@ struct radeon_tcl_info {
 
 struct radeon_ioctl {
        GLuint vertex_offset;
-        struct radeon_bo *bo;
+       GLuint vertex_max;
+       struct radeon_bo *bo;
        GLuint vertex_size;
 };
 
@@ -348,6 +400,7 @@ struct radeon_dri_mirror {
 
        drm_context_t hwContext;
        drm_hw_lock_t *hwLock;
+       int hwLockCount;
        int fd;
        int drmMinor;
 };
@@ -412,6 +465,8 @@ struct radeon_context {
    int                   texture_depth;
    float                 initialMaxAnisotropy;
    uint32_t              texture_row_align;
+   uint32_t              texture_rect_row_align;
+   uint32_t              texture_compressed_row_align;
 
   struct radeon_dma dma;
   struct radeon_hw_state hw;
@@ -426,7 +481,6 @@ struct radeon_context {
    GLuint numClipRects;        /* Cliprects for the draw buffer */
    drm_clip_rect_t *pClipRects;
    unsigned int lastStamp;
-   GLboolean lost_context;
    drm_radeon_sarea_t *sarea;  /* Private SAREA data */
 
    /* Mirrors of some DRI state */
@@ -469,19 +523,22 @@ struct radeon_context {
     */
    GLboolean is_front_buffer_rendering;
 
-  struct {
-      struct gl_fragment_program *bitmap_fp;
-      struct gl_vertex_program *passthrough_vp;
+   /**
+    * Track whether front-buffer is the current read target.
+    *
+    * This is closely associated with is_front_buffer_rendering, but may
+    * be set separately.  The DRI2 fake front buffer must be referenced
+    * either way.
+    */
+   GLboolean is_front_buffer_reading;
 
-      struct gl_fragment_program *saved_fp;
-      GLboolean saved_fp_enable;
-      struct gl_vertex_program *saved_vp;
-      GLboolean saved_vp_enable;
+   struct dri_metaops meta;
 
-      GLint saved_vp_x, saved_vp_y;
-      GLsizei saved_vp_width, saved_vp_height;
-      GLenum saved_matrix_mode;
-   } meta;
+   struct {
+       struct radeon_query_object *current;
+       struct radeon_query_object not_flushed_head;
+       struct radeon_state_atom queryobj;
+   } query;
 
    struct {
           void (*get_lock)(radeonContextPtr radeon);
@@ -492,6 +549,8 @@ struct radeon_context {
           void (*pre_emit_state)(radeonContextPtr rmesa);
           void (*fallback)(GLcontext *ctx, GLuint bit, GLboolean mode);
           void (*free_context)(GLcontext *ctx);
+          void (*emit_query_finish)(radeonContextPtr radeon);
+          void (*update_scissor)(GLcontext *ctx);
    } vtbl;
 };
 
@@ -507,7 +566,6 @@ static inline __DRIdrawablePrivate* radeon_get_readable(radeonContextPtr radeon)
        return radeon->dri.context->driReadablePriv;
 }
 
-
 /**
  * This function takes a float and packs it into a uint32_t
  */