summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/intel
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri/intel')
-rw-r--r--src/mesa/drivers/dri/intel/intel_context.c86
-rw-r--r--src/mesa/drivers/dri/intel/intel_screen.c111
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_image.c11
3 files changed, 93 insertions, 115 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c
index e2388dbb09..47e7d1afc2 100644
--- a/src/mesa/drivers/dri/intel/intel_context.c
+++ b/src/mesa/drivers/dri/intel/intel_context.c
@@ -848,7 +848,6 @@ intelContendedLock(struct intel_context *intel, GLuint flags)
__DRIdrawablePrivate *dPriv = intel->driDrawable;
__DRIscreenPrivate *sPriv = intel->driScreen;
volatile struct drm_i915_sarea *sarea = intel->sarea;
- int drawable_changed = 0;
int me = intel->hHWContext;
drmGetLock(intel->driFd, intel->hHWContext, flags);
@@ -862,12 +861,8 @@ intelContendedLock(struct intel_context *intel, GLuint flags)
* NOTE: This releases and regains the hw lock, so all state
* checking must be done *after* this call:
*/
- if (dPriv) {
- if (sPriv->dri2.enabled)
- drawable_changed = __driParseEvents(dPriv->driContextPriv, dPriv);
- else
- DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
- }
+ if (dPriv)
+ DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
if (sarea && sarea->ctxOwner != me) {
if (INTEL_DEBUG & DEBUG_BUFMGR) {
@@ -892,48 +887,43 @@ intelContendedLock(struct intel_context *intel, GLuint flags)
sarea->ctxOwner, intel->hHWContext);
}
- if (!sPriv->dri2.enabled) {
- if (sarea->width != intel->width || sarea->height != intel->height) {
- int numClipRects = intel->numClipRects;
+ if (sarea->width != intel->width || sarea->height != intel->height) {
+ int numClipRects = intel->numClipRects;
- /*
- * FIXME: Really only need to do this when drawing to a
- * common back- or front buffer.
- */
+ /*
+ * FIXME: Really only need to do this when drawing to a
+ * common back- or front buffer.
+ */
- /*
- * This will essentially drop the outstanding batchbuffer on
- * the floor.
- */
- intel->numClipRects = 0;
+ /*
+ * This will essentially drop the outstanding batchbuffer on
+ * the floor.
+ */
+ intel->numClipRects = 0;
- if (intel->Fallback)
- _swrast_flush(&intel->ctx);
+ if (intel->Fallback)
+ _swrast_flush(&intel->ctx);
- if (!IS_965(intel->intelScreen->deviceID))
- INTEL_FIREVERTICES(intel);
+ if (!IS_965(intel->intelScreen->deviceID))
+ INTEL_FIREVERTICES(intel);
- if (intel->batch->map != intel->batch->ptr)
- intel_batchbuffer_flush(intel->batch);
+ if (intel->batch->map != intel->batch->ptr)
+ intel_batchbuffer_flush(intel->batch);
- intel->numClipRects = numClipRects;
+ intel->numClipRects = numClipRects;
- /* force window update */
- intel->lastStamp = 0;
+ /* force window update */
+ intel->lastStamp = 0;
- intel->width = sarea->width;
- intel->height = sarea->height;
- }
+ intel->width = sarea->width;
+ intel->height = sarea->height;
+ }
- /* Drawable changed?
- */
- if (dPriv && intel->lastStamp != dPriv->lastStamp) {
- intelWindowMoved(intel);
- intel->lastStamp = dPriv->lastStamp;
- }
- } else if (drawable_changed) {
- intelWindowMoved(intel);
- intel_draw_buffer(&intel->ctx, intel->ctx.DrawBuffer);
+ /* Drawable changed?
+ */
+ if (dPriv && intel->lastStamp != dPriv->lastStamp) {
+ intelWindowMoved(intel);
+ intel->lastStamp = dPriv->lastStamp;
}
}
@@ -944,13 +934,15 @@ _glthread_DECLARE_STATIC_MUTEX(lockMutex);
*/
void LOCK_HARDWARE( struct intel_context *intel )
{
- __DRIdrawablePrivate *dPriv = intel->driDrawable;
+ __DRIdrawable *dPriv = intel->driDrawable;
+ __DRIscreen *sPriv = intel->driScreen;
char __ret = 0;
struct intel_framebuffer *intel_fb = NULL;
struct intel_renderbuffer *intel_rb = NULL;
_glthread_LOCK_MUTEX(lockMutex);
assert(!intel->locked);
+ intel->locked = 1;
if (intel->driDrawable) {
intel_fb = intel->driDrawable->driverPrivate;
@@ -980,10 +972,18 @@ void LOCK_HARDWARE( struct intel_context *intel )
DRM_CAS(intel->driHwLock, intel->hHWContext,
(DRM_LOCK_HELD|intel->hHWContext), __ret);
- if (__ret)
+ if (sPriv->dri2.enabled) {
+ if (__ret)
+ drmGetLock(intel->driFd, intel->hHWContext, 0);
+ if (__driParseEvents(dPriv->driContextPriv, dPriv)) {
+ intelWindowMoved(intel);
+ intel_draw_buffer(&intel->ctx, intel->ctx.DrawBuffer);
+ }
+ } else if (__ret) {
intelContendedLock( intel, 0 );
+ }
+
- intel->locked = 1;
if (INTEL_DEBUG & DEBUG_LOCK)
_mesa_printf("%s - locked\n", __progname);
}
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
index 3d46073daa..5aeb2a18f4 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -394,7 +394,7 @@ static const __DRItexBufferExtension intelTexBufferExtension = {
intelSetTexBuffer,
};
-static const __DRIextension *intelExtensions[] = {
+static const __DRIextension *intelScreenExtensions[] = {
&driReadDrawableExtension,
&driCopySubBufferExtension.base,
&driSwapControlExtension.base,
@@ -479,7 +479,7 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv)
&intelScreen->allow_batchbuffer))
return GL_FALSE;
- sPriv->extensions = intelExtensions;
+ sPriv->extensions = intelScreenExtensions;
return GL_TRUE;
}
@@ -653,39 +653,18 @@ intelCreateContext(const __GLcontextModes * mesaVis,
}
-static const struct __DriverAPIRec intelAPI = {
- .DestroyScreen = intelDestroyScreen,
- .CreateContext = intelCreateContext,
- .DestroyContext = intelDestroyContext,
- .CreateBuffer = intelCreateBuffer,
- .DestroyBuffer = intelDestroyBuffer,
- .SwapBuffers = intelSwapBuffers,
- .MakeCurrent = intelMakeCurrent,
- .UnbindContext = intelUnbindContext,
- .GetSwapInfo = intelGetSwapInfo,
- .GetDrawableMSC = driDrawableGetMSC32,
- .WaitForMSC = driWaitForMSC32,
- .WaitForSBC = NULL,
- .SwapBuffersMSC = NULL,
- .CopySubBuffer = intelCopySubBuffer,
-
- .HandleDrawableConfig = intelHandleDrawableConfig,
- .HandleBufferAttach = intelHandleBufferAttach,
-};
-
-
-static __GLcontextModes *
+static __DRIconfig **
intelFillInModes(__DRIscreenPrivate *psp,
unsigned pixel_bits, unsigned depth_bits,
unsigned stencil_bits, GLboolean have_back_buffer)
{
- __GLcontextModes *modes;
+ __DRIconfig **configs;
__GLcontextModes *m;
- unsigned num_modes;
unsigned depth_buffer_factor;
unsigned back_buffer_factor;
GLenum fb_format;
GLenum fb_type;
+ int i;
/* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
* support pageflipping at all.
@@ -697,7 +676,6 @@ intelFillInModes(__DRIscreenPrivate *psp,
u_int8_t depth_bits_array[3];
u_int8_t stencil_bits_array[3];
-
depth_bits_array[0] = 0;
depth_bits_array[1] = depth_bits;
depth_bits_array[2] = depth_bits;
@@ -716,8 +694,6 @@ intelFillInModes(__DRIscreenPrivate *psp,
depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 3 : 1;
back_buffer_factor = (have_back_buffer) ? 3 : 1;
- num_modes = depth_buffer_factor * back_buffer_factor * 4;
-
if (pixel_bits == 16) {
fb_format = GL_RGB;
fb_type = GL_UNSIGNED_SHORT_5_6_5;
@@ -727,36 +703,26 @@ intelFillInModes(__DRIscreenPrivate *psp,
fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
}
- modes =
- (*psp->contextModes->createContextModes) (num_modes,
- sizeof(__GLcontextModes));
- m = modes;
- if (!driFillInModes(&m, fb_format, fb_type,
- depth_bits_array, stencil_bits_array,
- depth_buffer_factor, back_buffer_modes,
- back_buffer_factor, GLX_TRUE_COLOR)) {
- fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
- __LINE__);
- return NULL;
- }
- if (!driFillInModes(&m, fb_format, fb_type,
- depth_bits_array, stencil_bits_array,
- depth_buffer_factor, back_buffer_modes,
- back_buffer_factor, GLX_DIRECT_COLOR)) {
- fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
+ configs = driCreateConfigs(fb_format, fb_type,
+ depth_bits_array, stencil_bits_array,
+ depth_buffer_factor, back_buffer_modes,
+ back_buffer_factor);
+ if (configs == NULL) {
+ fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
__LINE__);
return NULL;
}
/* Mark the visual as slow if there are "fake" stencil bits.
*/
- for (m = modes; m != NULL; m = m->next) {
+ for (i = 0; configs[i]; i++) {
+ m = &configs[i]->modes;
if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
m->visualRating = GLX_SLOW_CONFIG;
}
}
- return modes;
+ return configs;
}
@@ -767,7 +733,7 @@ intelFillInModes(__DRIscreenPrivate *psp,
*
* \return the __GLcontextModes supported by this driver
*/
-PUBLIC __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
+static const __DRIconfig **intelInitScreen(__DRIscreenPrivate *psp)
{
#ifdef I915
static const __DRIversion ddx_expected = { 1, 5, 0 };
@@ -778,8 +744,6 @@ PUBLIC __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
static const __DRIversion drm_expected = { 1, 5, 0 };
I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv;
- psp->DriverAPI = intelAPI;
-
if (!driCheckDriDdxDrmVersions2("i915",
&psp->dri_version, &dri_expected,
&psp->ddx_version, &ddx_expected,
@@ -802,9 +766,12 @@ PUBLIC __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
if (!intelInitDriver(psp))
return NULL;
- return intelFillInModes(psp, dri_priv->cpp * 8,
- (dri_priv->cpp == 2) ? 16 : 24,
- (dri_priv->cpp == 2) ? 0 : 8, 1);
+ psp->extensions = intelScreenExtensions;
+
+ return (const __DRIconfig **)
+ intelFillInModes(psp, dri_priv->cpp * 8,
+ (dri_priv->cpp == 2) ? 16 : 24,
+ (dri_priv->cpp == 2) ? 0 : 8, 1);
}
struct intel_context *intelScreenContext(intelScreenPrivate *intelScreen)
@@ -827,12 +794,10 @@ struct intel_context *intelScreenContext(intelScreenPrivate *intelScreen)
*
* \return the __GLcontextModes supported by this driver
*/
-PUBLIC __GLcontextModes *__dri2DriverInitScreen(__DRIscreenPrivate *psp)
+static const
+__DRIconfig **intelInitScreen2(__DRIscreenPrivate *psp)
{
intelScreenPrivate *intelScreen;
- __GLcontextModes *modes, *m;
-
- psp->DriverAPI = intelAPI;
/* Calling driInitExtensions here, with a NULL context pointer,
* does not actually enable the extensions. It just makes sure
@@ -881,12 +846,28 @@ PUBLIC __GLcontextModes *__dri2DriverInitScreen(__DRIscreenPrivate *psp)
return GL_FALSE;
}
- psp->extensions = intelExtensions;
+ psp->extensions = intelScreenExtensions;
- modes = intelFillInModes(psp, 16, 16, 0, 1);
- for (m = modes; m->next != NULL; m = m->next)
- ;
- m->next = intelFillInModes(psp, 32, 24, 8, 1);
-
- return modes;
+ return driConcatConfigs(intelFillInModes(psp, 16, 16, 0, 1),
+ intelFillInModes(psp, 32, 24, 8, 1));
}
+
+const struct __DriverAPIRec driDriverAPI = {
+ .InitScreen = intelInitScreen,
+ .DestroyScreen = intelDestroyScreen,
+ .CreateContext = intelCreateContext,
+ .DestroyContext = intelDestroyContext,
+ .CreateBuffer = intelCreateBuffer,
+ .DestroyBuffer = intelDestroyBuffer,
+ .SwapBuffers = intelSwapBuffers,
+ .MakeCurrent = intelMakeCurrent,
+ .UnbindContext = intelUnbindContext,
+ .GetSwapInfo = intelGetSwapInfo,
+ .GetDrawableMSC = driDrawableGetMSC32,
+ .WaitForMSC = driWaitForMSC32,
+ .CopySubBuffer = intelCopySubBuffer,
+
+ .InitScreen2 = intelInitScreen2,
+ .HandleDrawableConfig = intelHandleDrawableConfig,
+ .HandleBufferAttach = intelHandleBufferAttach,
+};
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
index dd8fbeaa91..a56a395646 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -676,8 +676,7 @@ void
intelSetTexOffset(__DRIcontext *pDRICtx, GLint texname,
unsigned long long offset, GLint depth, GLuint pitch)
{
- struct intel_context *intel = (struct intel_context*)
- ((__DRIcontextPrivate*)pDRICtx->private)->driverPrivate;
+ struct intel_context *intel = pDRICtx->driverPrivate;
struct gl_texture_object *tObj = _mesa_lookup_texture(&intel->ctx, texname);
struct intel_texture_object *intelObj = intel_texture_object(tObj);
@@ -696,12 +695,10 @@ intelSetTexOffset(__DRIcontext *pDRICtx, GLint texname,
}
void
-intelSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *pDraw)
+intelSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv)
{
- __DRIcontextPrivate *driContext = pDRICtx->private;
- __DRIdrawablePrivate *dPriv = pDraw->private;
struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
- struct intel_context *intel = driContext->driverPrivate;
+ struct intel_context *intel = pDRICtx->driverPrivate;
struct intel_texture_object *intelObj;
struct intel_texture_image *intelImage;
struct intel_mipmap_tree *mt;
@@ -718,7 +715,7 @@ intelSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *pDraw)
if (!intelObj)
return;
- __driParseEvents(driContext, dPriv);
+ __driParseEvents(pDRICtx, dPriv);
rb = intel_fb->color_rb[0];
type = GL_BGRA;