mesa: add bool param to _mesa_free_context_data
[mesa.git] / src / mesa / drivers / dri / radeon / radeon_common_context.h
index 80ae2d1e380e22c8c76d6c266bc582f9df9093ac..bd7343f4082300ad920e4edce9c9daefd08e903d 100644 (file)
@@ -2,13 +2,12 @@
 #ifndef COMMON_CONTEXT_H
 #define COMMON_CONTEXT_H
 
-#include "main/mm.h"
 #include "math/m_vector.h"
 #include "tnl/t_context.h"
 #include "main/colormac.h"
 
-#include "radeon_debug.h"
 #include "radeon_screen.h"
+#include "radeon_debug.h"
 #include "radeon_drm.h"
 #include "dri_util.h"
 #include "tnl/t_vertex.h"
@@ -110,28 +109,18 @@ struct radeon_framebuffer
 
 
 struct radeon_colorbuffer_state {
-       GLuint clear;
        int roundEnable;
        struct gl_renderbuffer *rb;
        uint32_t draw_offset; /* offset into color renderbuffer - FBOs */
 };
 
 struct radeon_depthbuffer_state {
-       GLuint clear;
        struct gl_renderbuffer *rb;
 };
 
 struct radeon_scissor_state {
        drm_clip_rect_t rect;
        GLboolean enabled;
-
-       GLuint numClipRects;    /* Cliprects active */
-       GLuint numAllocedClipRects;     /* Cliprects available */
-       drm_clip_rect_t *pClipRects;
-};
-
-struct radeon_stencilbuffer_state {
-       GLuint clear;           /* rb3d_stencilrefmask value */
 };
 
 struct radeon_state_atom {
@@ -181,7 +170,7 @@ struct _radeon_texture_image {
 };
 
 
-static INLINE radeon_texture_image *get_radeon_texture_image(struct gl_texture_image *image)
+static inline radeon_texture_image *get_radeon_texture_image(struct gl_texture_image *image)
 {
        return (radeon_texture_image*)image;
 }
@@ -223,7 +212,7 @@ struct radeon_tex_obj {
        GLboolean border_fallback;
 };
 
-static INLINE radeonTexObj* radeon_tex_obj(struct gl_texture_object *texObj)
+static inline radeonTexObj* radeon_tex_obj(struct gl_texture_object *texObj)
 {
        return (radeonTexObj*)texObj;
 }
@@ -326,7 +315,7 @@ struct radeon_prim {
        GLuint prim;
 };
 
-static INLINE GLuint radeonPackColor(GLuint cpp,
+static inline GLuint radeonPackColor(GLuint cpp,
                                      GLubyte r, GLubyte g,
                                      GLubyte b, GLubyte a)
 {
@@ -352,17 +341,6 @@ struct radeon_store {
        int elts_start;
 };
 
-struct radeon_dri_mirror {
-       __DRIcontext *context;  /* DRI context */
-       __DRIscreen *screen;    /* DRI screen */
-
-       drm_context_t hwContext;
-       drm_hw_lock_t *hwLock;
-       int hwLockCount;
-       int fd;
-       int drmMinor;
-};
-
 typedef void (*radeon_tri_func) (radeonContextPtr,
                                 radeonVertex *,
                                 radeonVertex *, radeonVertex *);
@@ -377,7 +355,6 @@ struct radeon_state {
        struct radeon_colorbuffer_state color;
        struct radeon_depthbuffer_state depth;
        struct radeon_scissor_state scissor;
-       struct radeon_stencilbuffer_state stencil;
 };
 
 /**
@@ -395,7 +372,8 @@ struct radeon_cmdbuf {
 };
 
 struct radeon_context {
-   struct gl_context *glCtx;
+   struct gl_context glCtx;             /**< base class, must be first */
+   __DRIcontext *driContext;               /* DRI context */
    radeonScreenPtr radeonScreen;       /* Screen private DRI data */
 
    /* Texture object bookkeeping
@@ -417,10 +395,6 @@ struct radeon_context {
 
    /* Drawable information */
    unsigned int lastStamp;
-   drm_radeon_sarea_t *sarea;  /* Private SAREA data */
-
-   /* Mirrors of some DRI state */
-   struct radeon_dri_mirror dri;
 
    /* Busy waiting */
    GLuint do_usleeps;
@@ -445,51 +419,30 @@ struct radeon_context {
   GLboolean front_cliprects;
 
    /**
-    * Set if rendering has occured to the drawable's front buffer.
+    * Set if rendering has occurred 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;
-
-   /**
-    * 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 {
        struct radeon_query_object *current;
        struct radeon_state_atom queryobj;
    } query;
 
    struct {
-          void (*get_lock)(radeonContextPtr radeon);
-          void (*update_viewport_offset)(struct gl_context *ctx);
-          void (*emit_cs_header)(struct radeon_cs *cs, radeonContextPtr rmesa);
           void (*swtcl_flush)(struct gl_context *ctx, uint32_t offset);
-          void (*pre_emit_atoms)(radeonContextPtr rmesa);
           void (*pre_emit_state)(radeonContextPtr rmesa);
           void (*fallback)(struct gl_context *ctx, GLuint bit, GLboolean mode);
           void (*free_context)(struct gl_context *ctx);
           void (*emit_query_finish)(radeonContextPtr radeon);
           void (*update_scissor)(struct gl_context *ctx);
-          unsigned (*check_blit)(gl_format mesa_format, uint32_t dst_pitch);
+          unsigned (*check_blit)(mesa_format mesa_format, uint32_t dst_pitch);
           unsigned (*blit)(struct gl_context *ctx,
                         struct radeon_bo *src_bo,
                         intptr_t src_offset,
-                        gl_format src_mesaformat,
+                        mesa_format src_mesaformat,
                         unsigned src_pitch,
                         unsigned src_width,
                         unsigned src_height,
@@ -497,7 +450,7 @@ struct radeon_context {
                         unsigned src_y_offset,
                         struct radeon_bo *dst_bo,
                         intptr_t dst_offset,
-                        gl_format dst_mesaformat,
+                        mesa_format dst_mesaformat,
                         unsigned dst_pitch,
                         unsigned dst_width,
                         unsigned dst_height,
@@ -506,23 +459,32 @@ struct radeon_context {
                         unsigned reg_width,
                         unsigned reg_height,
                         unsigned flip_y);
-          unsigned (*is_format_renderable)(gl_format mesa_format);
+          unsigned (*is_format_renderable)(mesa_format mesa_format);
+          GLboolean (*revalidate_all_buffers)(struct gl_context *ctx);
    } vtbl;
 };
 
-#define RADEON_CONTEXT(glctx) ((radeonContextPtr)(ctx->DriverCtx))
+static inline radeonContextPtr RADEON_CONTEXT(struct gl_context *ctx)
+{
+       return (radeonContextPtr) ctx;
+}
 
 static inline __DRIdrawable* radeon_get_drawable(radeonContextPtr radeon)
 {
-       return radeon->dri.context->driDrawablePriv;
+       return radeon->driContext->driDrawablePriv;
 }
 
 static inline __DRIdrawable* radeon_get_readable(radeonContextPtr radeon)
 {
-       return radeon->dri.context->driReadablePriv;
+       return radeon->driContext->driReadablePriv;
 }
 
+extern const char *const radeonVendorString;
+
+const char *radeonGetRendererString(radeonScreenPtr radeonScreen);
+
 GLboolean radeonInitContext(radeonContextPtr radeon,
+                            gl_api api,
                            struct dd_function_table* functions,
                            const struct gl_config * glVisual,
                            __DRIcontext * driContextPriv,