util: rename xmlpool.h to driconf.h
[mesa.git] / src / mesa / drivers / dri / radeon / radeon_common_context.c
index 9699dcbfcdcba815f5e5dc0da6234de077095b41..416d2d988fec06c882b354d3aa6ce94495d23949 100644 (file)
@@ -33,7 +33,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 **************************************************************************/
 
 #include "radeon_common.h"
-#include "xmlpool.h"           /* for symbolic values of enum-type options */
+#include "util/driconf.h"              /* for symbolic values of enum-type options */
 #include "utils.h"
 #include "drivers/common/meta.h"
 #include "main/context.h"
@@ -70,7 +70,7 @@ static const char* get_chip_family_name(int chip_family)
        }
 }
 
-const char const *radeonVendorString = "Mesa Project";
+const char *const radeonVendorString = "Mesa Project";
 
 /* Return complete renderer string.
  */
@@ -162,10 +162,7 @@ GLboolean radeonInitContext(radeonContextPtr radeon,
        _mesa_meta_init(ctx);
 
        /* DRI fields */
-       radeon->dri.context = driContextPriv;
-       radeon->dri.screen = sPriv;
-       radeon->dri.fd = sPriv->fd;
-       radeon->dri.drmMinor = sPriv->drm_version.minor;
+       radeon->driContext = driContextPriv;
 
        /* Setup IRQs */
        fthrottle_mode = driQueryOptioni(&radeon->optionCache, "fthrottle_mode");
@@ -185,7 +182,7 @@ GLboolean radeonInitContext(radeonContextPtr radeon,
         radeon->texture_depth = driQueryOptioni (&radeon->optionCache,
                                                "texture_depth");
         if (radeon->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)
-                radeon->texture_depth = ( glVisual->rgbBits > 16 ) ?
+                radeon->texture_depth = (glVisual == NULL || glVisual->rgbBits > 16) ?
                DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;
 
        radeon->texture_row_align = 32;
@@ -194,6 +191,29 @@ GLboolean radeonInitContext(radeonContextPtr radeon,
 
        radeon_init_dma(radeon);
 
+        /* _mesa_initialize_context calls _mesa_init_queryobj which
+         * initializes all of the counter sizes to 64.  The counters on r100
+         * and r200 are only 32-bits for occlusion queries.  Those are the
+         * only counters, so set the other sizes to zero.
+         */
+        radeon->glCtx.Const.QueryCounterBits.SamplesPassed = 32;
+
+        radeon->glCtx.Const.QueryCounterBits.TimeElapsed = 0;
+        radeon->glCtx.Const.QueryCounterBits.Timestamp = 0;
+        radeon->glCtx.Const.QueryCounterBits.PrimitivesGenerated = 0;
+        radeon->glCtx.Const.QueryCounterBits.PrimitivesWritten = 0;
+        radeon->glCtx.Const.QueryCounterBits.VerticesSubmitted = 0;
+        radeon->glCtx.Const.QueryCounterBits.PrimitivesSubmitted = 0;
+        radeon->glCtx.Const.QueryCounterBits.VsInvocations = 0;
+        radeon->glCtx.Const.QueryCounterBits.TessPatches = 0;
+        radeon->glCtx.Const.QueryCounterBits.TessInvocations = 0;
+        radeon->glCtx.Const.QueryCounterBits.GsInvocations = 0;
+        radeon->glCtx.Const.QueryCounterBits.GsPrimitives = 0;
+        radeon->glCtx.Const.QueryCounterBits.FsInvocations = 0;
+        radeon->glCtx.Const.QueryCounterBits.ComputeInvocations = 0;
+        radeon->glCtx.Const.QueryCounterBits.ClInPrimitives = 0;
+        radeon->glCtx.Const.QueryCounterBits.ClOutPrimitives = 0;
+
        return GL_TRUE;
 }
 
@@ -302,7 +322,7 @@ radeon_bits_per_pixel(const struct radeon_renderbuffer *rb)
  */
 void radeon_prepare_render(radeonContextPtr radeon)
 {
-    __DRIcontext *driContext = radeon->dri.context;
+    __DRIcontext *driContext = radeon->driContext;
     __DRIdrawable *drawable;
     __DRIscreen *screen;
 
@@ -332,7 +352,7 @@ void radeon_prepare_render(radeonContextPtr radeon)
      * that will happen next will probably dirty the front buffer.  So
      * mark it as dirty here.
      */
-    if (radeon->is_front_buffer_rendering)
+    if (_mesa_is_front_buffer_drawing(radeon->glCtx.DrawBuffer))
        radeon->front_buffer_dirty = GL_TRUE;
 }
 
@@ -369,10 +389,10 @@ radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable,
                struct radeon_renderbuffer *stencil_rb;
 
                i = 0;
-               if ((front_only || radeon->is_front_buffer_rendering ||
-                    radeon->is_front_buffer_reading ||
-                    !draw->color_rb[1])
-                   && draw->color_rb[0]) {
+                if ((front_only || _mesa_is_front_buffer_drawing(&draw->base) ||
+                     _mesa_is_front_buffer_reading(&draw->base) ||
+                     !draw->color_rb[1])
+                    && draw->color_rb[0]) {
                        attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
                        attachments[i++] = radeon_bits_per_pixel(draw->color_rb[0]);
                }
@@ -398,12 +418,12 @@ radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable,
                        }
                }
 
-               buffers = (*screen->dri2.loader->getBuffersWithFormat)(drawable,
-                                                               &drawable->w,
-                                                               &drawable->h,
-                                                               attachments, i / 2,
-                                                               &count,
-                                                               drawable->loaderPrivate);
+               buffers = screen->dri2.loader->getBuffersWithFormat(drawable,
+                                                                   &drawable->w,
+                                                                   &drawable->h,
+                                                                   attachments, i / 2,
+                                                                   &count,
+                                                                   drawable->loaderPrivate);
        } else if (screen->dri2.loader) {
                i = 0;
                if (draw->color_rb[0])
@@ -417,12 +437,12 @@ radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable,
                                attachments[i++] = __DRI_BUFFER_STENCIL;
                }
 
-               buffers = (*screen->dri2.loader->getBuffers)(drawable,
-                                                                &drawable->w,
-                                                                &drawable->h,
-                                                                attachments, i,
-                                                                &count,
-                                                                drawable->loaderPrivate);
+               buffers = screen->dri2.loader->getBuffers(drawable,
+                                                         &drawable->w,
+                                                         &drawable->h,
+                                                         attachments, i,
+                                                         &count,
+                                                         drawable->loaderPrivate);
        }
 
        if (buffers == NULL)