Enable use of new DRI interface in Unichrome driver.
This commit is contained in:
parent
e3a07ba609
commit
45e7b47d56
|
@ -42,6 +42,11 @@
|
|||
#include "via_dri.h"
|
||||
extern viaContextPtr current_mesa;
|
||||
|
||||
#ifdef USE_NEW_INTERFACE
|
||||
static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
|
||||
#endif /* USE_NEW_INTERFACE */
|
||||
|
||||
|
||||
static drmBufMapPtr via_create_empty_buffers(void)
|
||||
{
|
||||
drmBufMapPtr retval;
|
||||
|
@ -67,8 +72,7 @@ viaInitDriver(__DRIscreenPrivate *sPriv)
|
|||
#ifdef DEBUG
|
||||
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
|
||||
#endif
|
||||
if (!driCheckDriDdxDrmVersions(sPriv, "Via", 4, 0, 4, 0, 1, 1))
|
||||
return GL_FALSE;
|
||||
|
||||
|
||||
/* Allocate the private area */
|
||||
viaScreen = (viaScreenPrivate *) CALLOC(sizeof(viaScreenPrivate));
|
||||
|
@ -286,6 +290,7 @@ static struct __DriverAPIRec viaAPI = {
|
|||
* The __driCreateScreen name is the symbol that libGL.so fetches.
|
||||
* Return: pointer to a __DRIscreenPrivate.
|
||||
*/
|
||||
#if !defined(DRI_NEW_INTERFACE_ONLY)
|
||||
#ifndef _SOLO
|
||||
void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
|
||||
int numConfigs, __GLXvisualConfig *config)
|
||||
|
@ -303,3 +308,121 @@ void *__driCreateScreen(struct DRIDriverRec *driver,
|
|||
return (void *) psp;
|
||||
}
|
||||
#endif
|
||||
#endif /* !defined(DRI_NEW_INTERFACE_ONLY) */
|
||||
|
||||
|
||||
#ifdef USE_NEW_INTERFACE
|
||||
static __GLcontextModes *
|
||||
viaFillInModes( unsigned pixel_bits, GLboolean have_back_buffer )
|
||||
{
|
||||
__GLcontextModes * modes;
|
||||
__GLcontextModes * m;
|
||||
unsigned num_modes;
|
||||
const unsigned back_buffer_factor = (have_back_buffer) ? 2 : 1;
|
||||
GLenum fb_format;
|
||||
GLenum fb_type;
|
||||
|
||||
/* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy
|
||||
* enough to add support. Basically, if a context is created with an
|
||||
* fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping
|
||||
* will never be used.
|
||||
*/
|
||||
static const GLenum back_buffer_modes[] = {
|
||||
GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */
|
||||
};
|
||||
|
||||
/* The 32-bit depth-buffer mode isn't supported yet, so don't actually
|
||||
* enable it.
|
||||
*/
|
||||
static const uint8_t depth_bits_array[4] = { 0, 16, 24, 32 };
|
||||
static const uint8_t stencil_bits_array[4] = { 0, 0, 8, 0 };
|
||||
const unsigned depth_buffer_factor = 3;
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
else {
|
||||
fb_format = GL_BGR;
|
||||
fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
}
|
||||
|
||||
modes = (*create_context_modes)( 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__, __LINE__ );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return modes;
|
||||
}
|
||||
#endif /* USE_NEW_INTERFACE */
|
||||
|
||||
|
||||
/**
|
||||
* This is the bootstrap function for the driver. libGL supplies all of the
|
||||
* requisite information about the system, and the driver initializes itself.
|
||||
* This routine also fills in the linked list pointed to by \c driver_modes
|
||||
* with the \c __GLcontextModes that the driver can support for windows or
|
||||
* pbuffers.
|
||||
*
|
||||
* \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
|
||||
* failure.
|
||||
*/
|
||||
#ifdef USE_NEW_INTERFACE
|
||||
void * __driCreateNewScreen( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
|
||||
const __GLcontextModes * modes,
|
||||
const __DRIversion * ddx_version,
|
||||
const __DRIversion * dri_version,
|
||||
const __DRIversion * drm_version,
|
||||
const __DRIframebuffer * frame_buffer,
|
||||
drmAddress pSAREA, int fd,
|
||||
int internal_api_version,
|
||||
__GLcontextModes ** driver_modes )
|
||||
|
||||
{
|
||||
__DRIscreenPrivate *psp;
|
||||
static const __DRIversion ddx_expected = { 4, 0, 0 };
|
||||
static const __DRIversion dri_expected = { 4, 0, 0 };
|
||||
static const __DRIversion drm_expected = { 1, 1, 0 };
|
||||
|
||||
if ( ! driCheckDriDdxDrmVersions2( "Unichrome",
|
||||
dri_version, & dri_expected,
|
||||
ddx_version, & ddx_expected,
|
||||
drm_version, & drm_expected ) ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
|
||||
ddx_version, dri_version, drm_version,
|
||||
frame_buffer, pSAREA, fd,
|
||||
internal_api_version, &viaAPI);
|
||||
if ( psp != NULL ) {
|
||||
create_context_modes = (PFNGLXCREATECONTEXTMODES)
|
||||
glXGetProcAddress( (const GLubyte *) "__glXCreateContextModes" );
|
||||
if ( create_context_modes != NULL ) {
|
||||
VIADRIPtr dri_priv = (VIADRIPtr) psp->pDevPriv;
|
||||
*driver_modes = viaFillInModes( dri_priv->bytesPerPixel * 8,
|
||||
GL_TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
return (void *) psp;
|
||||
}
|
||||
#endif /* USE_NEW_INTERFACE */
|
||||
|
|
Loading…
Reference in New Issue