diff options
author | Kristian Høgsberg <[email protected]> | 2008-03-26 19:26:59 -0400 |
---|---|---|
committer | Kristian Høgsberg <[email protected]> | 2008-03-31 16:51:26 -0400 |
commit | e82dd8c6e1fa2fff5b960de26961080ba5e9651d (patch) | |
tree | 1bd230661a032b1ab539998f947573de1acaf80d /src/mesa/drivers/dri/mach64 | |
parent | 63d8a8417d68365cd10c11178516378411c09f87 (diff) |
DRI interface changes and DRI2 direct rendering support.
Add DRI2 direct rendering support to libGL and add DRI2 client side
protocol code. Extend the GLX 1.3 create drawable functions in
glx_pbuffer.c to call into the DRI driver when possible.
Introduce __DRIconfig, opaque struct that represents a DRI driver
configuration. Get's rid of the open coded __GLcontextModes in the
DRI driver interface and the context modes create and destroy
functions that the loader was requires to provide. glcore.h is no
longer part of the DRI driver interface. The DRI config is GL binding
agnostic, that is, not specific to GLX, EGL or other bindings.
The core API is now also an extension, and the driver exports a list
of extensions as the symbol __driDriverExtensions, which the loader
must dlsym() for. The list of extension will always include the DRI
core extension, which allows creating and manipulating DRI screens,
drawables and contexts. The DRI legacy extension, when available,
provides alternative entry points for creating the DRI objects that
work with the XF86DRI infrastructure.
Change DRI2 client code to not use drm drawables or contexts. We
never used drm_drawable_t's and the only use for drm_context_t was as
a unique identifier when taking the lock. We now just allocate a
unique lock ID out of the DRILock sarea block. Once we get rid of the
lock entirely, we can drop this hack.
Change the interface between dri_util.c and the drivers, so that the
drivers now export the DriverAPI struct as driDriverAPI instead of the
InitScreen entry point. This lets us avoid dlsym()'ing for the DRI2
init screen function to see if DRI2 is supported by the driver.
Diffstat (limited to 'src/mesa/drivers/dri/mach64')
-rw-r--r-- | src/mesa/drivers/dri/mach64/mach64_screen.c | 165 |
1 files changed, 51 insertions, 114 deletions
diff --git a/src/mesa/drivers/dri/mach64/mach64_screen.c b/src/mesa/drivers/dri/mach64/mach64_screen.c index 63b9d8077dc..2dba50fc1fa 100644 --- a/src/mesa/drivers/dri/mach64/mach64_screen.c +++ b/src/mesa/drivers/dri/mach64/mach64_screen.c @@ -69,80 +69,15 @@ static const GLuint __driNConfigOptions = 2; extern const struct dri_extension card_extensions[]; -static __GLcontextModes * fill_in_modes( __GLcontextModes * modes, - unsigned pixel_bits, - unsigned depth_bits, - unsigned stencil_bits, - const GLenum * db_modes, - unsigned num_db_modes, - int visType ) -{ - static const u_int8_t bits[2][4] = { - { 5, 6, 5, 0 }, - { 8, 8, 8, 0 } - }; - - static const u_int32_t masks[2][4] = { - { 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 }, - { 0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000 } - }; - - unsigned i; - unsigned j; - const unsigned index = ((pixel_bits + 15) / 16) - 1; - - for ( i = 0 ; i < num_db_modes ; i++ ) { - for ( j = 0 ; j < 2 ; j++ ) { - - modes->redBits = bits[index][0]; - modes->greenBits = bits[index][1]; - modes->blueBits = bits[index][2]; - modes->alphaBits = bits[index][3]; - modes->redMask = masks[index][0]; - modes->greenMask = masks[index][1]; - modes->blueMask = masks[index][2]; - modes->alphaMask = masks[index][3]; - modes->rgbBits = modes->redBits + modes->greenBits - + modes->blueBits + modes->alphaBits; - - modes->accumRedBits = 16 * j; - modes->accumGreenBits = 16 * j; - modes->accumBlueBits = 16 * j; - modes->accumAlphaBits = 0; - modes->visualRating = (j == 0) ? GLX_NONE : GLX_SLOW_CONFIG; - modes->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT; - modes->stencilBits = stencil_bits; - modes->depthBits = depth_bits; - - modes->visualType = visType; - modes->renderType = GLX_RGBA_BIT; - modes->rgbMode = GL_TRUE; - - if ( db_modes[i] == GLX_NONE ) { - - modes->doubleBufferMode = GL_FALSE; - } - else { - modes->doubleBufferMode = GL_TRUE; - modes->swapMethod = db_modes[i]; - } - - modes = modes->next; - } - } - - return modes; -} - - -static __GLcontextModes * +static const __DRIconfig ** mach64FillInModes( __DRIscreenPrivate *psp, unsigned pixel_bits, unsigned depth_bits, unsigned stencil_bits, GLboolean have_back_buffer ) { - __GLcontextModes * modes; + __DRIconfig **configs; __GLcontextModes * m; - unsigned num_modes; + GLenum fb_format; + GLenum fb_type; unsigned depth_buffer_factor; unsigned back_buffer_factor; unsigned i; @@ -156,49 +91,51 @@ mach64FillInModes( __DRIscreenPrivate *psp, GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */ }; - int depth_buffer_modes[2][2]; - + u_int8_t depth_bits_array[2]; + u_int8_t stencil_bits_array[2]; - depth_buffer_modes[0][0] = depth_bits; - depth_buffer_modes[1][0] = depth_bits; + depth_bits_array[0] = depth_bits; + depth_bits_array[1] = depth_bits; /* Just like with the accumulation buffer, always provide some modes * with a stencil buffer. It will be a sw fallback, but some apps won't * care about that. */ - depth_buffer_modes[0][1] = 0; - depth_buffer_modes[1][1] = (stencil_bits == 0) ? 8 : stencil_bits; + stencil_bits_array[0] = 0; + stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits; depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1; back_buffer_factor = (have_back_buffer) ? 2 : 1; - num_modes = depth_buffer_factor * back_buffer_factor * 4; - - modes = (*psp->contextModes->createContextModes)( num_modes, sizeof( __GLcontextModes ) ); - m = modes; - for ( i = 0 ; i < depth_buffer_factor ; i++ ) { - m = fill_in_modes( m, pixel_bits, - depth_buffer_modes[i][0], depth_buffer_modes[i][1], - back_buffer_modes, back_buffer_factor, - GLX_TRUE_COLOR ); + if (pixel_bits == 16) { + fb_format = GL_RGB; + fb_type = GL_UNSIGNED_SHORT_5_6_5; + } + else { + fb_format = GL_BGRA; + fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; } - for ( i = 0 ; i < depth_buffer_factor ; i++ ) { - m = fill_in_modes( m, pixel_bits, - depth_buffer_modes[i][0], depth_buffer_modes[i][1], - back_buffer_modes, back_buffer_factor, - GLX_DIRECT_COLOR ); + 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 ) { - if ( (m->stencilBits != 0) && (m->stencilBits != stencil_bits) ){ - m->visualRating = GLX_SLOW_CONFIG; - } + 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 (const __DRIconfig **) configs; } @@ -473,24 +410,6 @@ mach64InitDriver( __DRIscreenPrivate *driScreen ) return GL_TRUE; } - -static struct __DriverAPIRec mach64API = { - .DestroyScreen = mach64DestroyScreen, - .CreateContext = mach64CreateContext, - .DestroyContext = mach64DestroyContext, - .CreateBuffer = mach64CreateBuffer, - .DestroyBuffer = mach64DestroyBuffer, - .SwapBuffers = mach64SwapBuffers, - .MakeCurrent = mach64MakeCurrent, - .UnbindContext = mach64UnbindContext, - .GetSwapInfo = NULL, - .GetDrawableMSC = driDrawableGetMSC32, - .WaitForMSC = driWaitForMSC32, - .WaitForSBC = NULL, - .SwapBuffersMSC = NULL -}; - - /** * This is the driver specific part of the createNewScreen entry point. * @@ -498,14 +417,14 @@ static struct __DriverAPIRec mach64API = { * * \return the __GLcontextModes supported by this driver */ -__GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp) +static const __DRIconfig ** +mach64InitScreen(__DRIscreenPrivate *psp) { static const __DRIversion ddx_expected = { 6, 4, 0 }; static const __DRIversion dri_expected = { 4, 0, 0 }; static const __DRIversion drm_expected = { 2, 0, 0 }; ATIDRIPtr dri_priv = (ATIDRIPtr) psp->pDevPriv; - psp->DriverAPI = mach64API; if ( ! driCheckDriDdxDrmVersions2( "Mach64", &psp->dri_version, & dri_expected, &psp->ddx_version, & ddx_expected, @@ -530,3 +449,21 @@ __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp) return mach64FillInModes( psp, dri_priv->cpp * 8, 16, 0, 1); } + +const struct __DriverAPIRec driDriverAPI = { + .InitScreen = mach64InitScreen, + .DestroyScreen = mach64DestroyScreen, + .CreateContext = mach64CreateContext, + .DestroyContext = mach64DestroyContext, + .CreateBuffer = mach64CreateBuffer, + .DestroyBuffer = mach64DestroyBuffer, + .SwapBuffers = mach64SwapBuffers, + .MakeCurrent = mach64MakeCurrent, + .UnbindContext = mach64UnbindContext, + .GetSwapInfo = NULL, + .GetDrawableMSC = driDrawableGetMSC32, + .WaitForMSC = driWaitForMSC32, + .WaitForSBC = NULL, + .SwapBuffersMSC = NULL +}; + |