radeon: reading back to scratch reg through status map doesn't work
[mesa.git] / src / mesa / drivers / dri / radeon / radeon_common_context.h
index b88aeab0518633e14a6b62484b1e30cae23be516..af05f4ae32e0c1db6f0884575cf887ea908eea76 100644 (file)
 #include "dri_util.h"
 #include "tnl/t_vertex.h"
 
+struct radeon_context;
+
+#include "radeon_bocs_wrapper.h"
+
 /* 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;
@@ -39,6 +43,8 @@ typedef struct radeon_context *radeonContextPtr;
 #define RADEON_FALLBACK_BLEND_FUNC     0x0020
 #define RADEON_FALLBACK_DISABLE        0x0040
 #define RADEON_FALLBACK_BORDER_MODE    0x0080
+#define RADEON_FALLBACK_DEPTH_BUFFER   0x0100
+#define RADEON_FALLBACK_STENCIL_BUFFER  0x0200
 
 #define R200_FALLBACK_TEXTURE           0x01
 #define R200_FALLBACK_DRAW_BUFFER       0x02
@@ -68,16 +74,60 @@ typedef struct radeon_context *radeonContextPtr;
 #include "tnl_dd/t_dd_vertex.h"
 #undef TAG
 
+#define RADEON_RB_CLASS 0xdeadbeef
+
+struct radeon_renderbuffer
+{
+       struct gl_renderbuffer base;
+       struct radeon_bo *bo;
+       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 */
+       int has_surface;
+
+       GLuint pf_pending;  /**< sequence number of pending flip */
+       GLuint vbl_pending;   /**< vblank sequence number of pending flip */
+       __DRIdrawablePrivate *dPriv;
+};
+
+struct radeon_framebuffer
+{
+       struct gl_framebuffer base;
+
+       struct radeon_renderbuffer *color_rb[2];
+
+       GLuint vbl_waited;
+
+       /* buffer swap */
+       int64_t swap_ust;
+       int64_t swap_missed_ust;
+
+       GLuint swap_count;
+       GLuint swap_missed_count;
+
+       /* Drawable page flipping state */
+       GLboolean pf_active;
+       GLint pf_current_page;
+       GLint pf_num_pages;
+
+};
+
 struct radeon_colorbuffer_state {
        GLuint clear;
        int roundEnable;
-       struct radeon_renderbuffer *rrb;
+       struct gl_renderbuffer *rb;
+       uint32_t draw_offset; /* offset into color renderbuffer - FBOs */
 };
 
 struct radeon_depthbuffer_state {
        GLuint clear;
-       GLfloat scale;
-       struct radeon_renderbuffer *rrb;
+       struct gl_renderbuffer *rb;
 };
 
 struct radeon_scissor_state {
@@ -90,7 +140,6 @@ struct radeon_scissor_state {
 };
 
 struct radeon_stencilbuffer_state {
-       GLboolean hwBuffer;
        GLuint clear;           /* rb3d_stencilrefmask value */
 };
 
@@ -154,7 +203,6 @@ typedef struct radeon_tex_obj radeonTexObj, *radeonTexObjPtr;
 /* Texture object in locally shared texture space.
  */
 struct radeon_tex_obj {
-  //   driTextureObject base;
        struct gl_texture_object base;
        struct _radeon_mipmap_tree *mt;
 
@@ -169,26 +217,9 @@ struct radeon_tex_obj {
        GLuint tile_bits;       /* hw texture tile bits used on this texture */
         struct radeon_bo *bo;
 
-       GLuint bufAddr;         /* Offset to start of locally
-                                  shared texture block */
-
-       GLuint dirty_state;     /* Flags (1 per texunit) for
-                                  whether or not this texobj
-                                  has dirty hardware state
-                                  (pp_*) that needs to be
-                                  brought into the
-                                  texunit. */
-
-       drm_radeon_tex_image_t image[6][RADEON_MAX_TEXTURE_LEVELS];
-       /* Six, for the cube faces */
-
-
-
        GLuint pp_txfilter;     /* hardware register values */
        GLuint pp_txformat;
-        GLuint pp_txformat_x;
-       GLuint pp_txoffset;     /* Image location in texmem.
-                                  All cube faces follow. */
+       GLuint pp_txformat_x;
        GLuint pp_txsize;       /* npot only */
        GLuint pp_txpitch;      /* npot only */
        GLuint pp_border_color;
@@ -263,6 +294,14 @@ struct radeon_swtcl_info {
 
 };
 
+#define RADEON_MAX_AOS_ARRAYS          16
+struct radeon_tcl_info {
+       struct radeon_aos aos[RADEON_MAX_AOS_ARRAYS];
+       GLuint aos_count;
+       struct radeon_bo *elt_dma_bo; /** Buffer object that contains element indices */
+       int elt_dma_offset; /** Offset into this buffer object, in bytes */
+};
+
 struct radeon_ioctl {
        GLuint vertex_offset;
         struct radeon_bo *bo;
@@ -340,7 +379,6 @@ struct radeon_dri_mirror {
 #define DEBUG_MEMORY    0x4000
 
 
-
 typedef void (*radeon_tri_func) (radeonContextPtr,
                                 radeonVertex *,
                                 radeonVertex *, radeonVertex *);
@@ -350,11 +388,15 @@ typedef void (*radeon_line_func) (radeonContextPtr,
 
 typedef void (*radeon_point_func) (radeonContextPtr, radeonVertex *);
 
+#define RADEON_MAX_BOS 24
 struct radeon_state {
        struct radeon_colorbuffer_state color;
        struct radeon_depthbuffer_state depth;
        struct radeon_scissor_state scissor;
        struct radeon_stencilbuffer_state stencil;
+
+       struct radeon_cs_space_check bos[RADEON_MAX_BOS];
+       int validated_bo_count;
 };
 
 /**
@@ -377,11 +419,9 @@ struct radeon_context {
   
    /* Texture object bookkeeping
     */
-   unsigned              nr_heaps;
-   driTexHeap          * texture_heaps[ RADEON_NR_TEX_HEAPS ];
-   driTextureObject      swapped;
    int                   texture_depth;
    float                 initialMaxAnisotropy;
+   uint32_t              texture_row_align;
 
   struct radeon_dma dma;
   struct radeon_hw_state hw;
@@ -392,9 +432,6 @@ struct radeon_context {
    GLuint NewGLState;
    DECLARE_RENDERINPUTS(tnl_index_bitset);     /* index of bits for last tnl_install_attrs */
 
-   /* Page flipping */
-   GLuint doPageFlip;
-
    /* Drawable, cliprect and scissor information */
    GLuint numClipRects;        /* Cliprects for the draw buffer */
    drm_clip_rect_t *pClipRects;
@@ -411,31 +448,60 @@ struct radeon_context {
    GLuint irqsEmitted;
    drm_radeon_irq_wait_t iw;
 
-   /* buffer swap */
-   int64_t swap_ust;
-   int64_t swap_missed_ust;
-
-   GLuint swap_count;
-   GLuint swap_missed_count;
-
    /* Derived state - for r300 only */
    struct radeon_state state;
 
    struct radeon_swtcl_info swtcl;
+   struct radeon_tcl_info tcl;
    /* Configuration cache
     */
    driOptionCache optionCache;
 
    struct radeon_cmdbuf cmdbuf;
+       
+  drm_clip_rect_t fboRect;
+  GLboolean constant_cliprect; /* use for FBO or DRI2 rendering */
+  GLboolean front_cliprects;
+
+   /**
+    * Set if rendering has occured to the drawable's front buffer.
+    *
+    * This is used in the DRI2 case to detect that glFlush should also copy
+    * the contents of the fake front buffer to the real front buffer.
+    */
+   GLboolean front_buffer_dirty;
+
+   /**
+    * Track whether front-buffer rendering is currently enabled
+    *
+    * A separate flag is used to track this in order to support MRT more
+    * easily.
+    */
+   GLboolean is_front_buffer_rendering;
+
+  struct {
+      struct gl_fragment_program *bitmap_fp;
+      struct gl_vertex_program *passthrough_vp;
+
+      struct gl_fragment_program *saved_fp;
+      GLboolean saved_fp_enable;
+      struct gl_vertex_program *saved_vp;
+      GLboolean saved_vp_enable;
+
+      GLint saved_vp_x, saved_vp_y;
+      GLsizei saved_vp_width, saved_vp_height;
+      GLenum saved_matrix_mode;
+   } meta;
 
    struct {
           void (*get_lock)(radeonContextPtr radeon);
           void (*update_viewport_offset)(GLcontext *ctx);
-          void (*update_draw_buffer)(GLcontext *ctx);
           void (*emit_cs_header)(struct radeon_cs *cs, radeonContextPtr rmesa);
           void (*swtcl_flush)(GLcontext *ctx, uint32_t offset);
           void (*pre_emit_atoms)(radeonContextPtr rmesa);
           void (*pre_emit_state)(radeonContextPtr rmesa);
+          void (*fallback)(GLcontext *ctx, GLuint bit, GLboolean mode);
+          void (*free_context)(GLcontext *ctx);
    } vtbl;
 };
 
@@ -498,6 +564,7 @@ void radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
 GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv,
                            __DRIdrawablePrivate * driDrawPriv,
                            __DRIdrawablePrivate * driReadPriv);
+extern void radeonDestroyContext(__DRIcontextPrivate * driContextPriv);
 
 /* ================================================================
  * Debugging: