aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2004-06-07 19:13:18 +0000
committerEric Anholt <[email protected]>2004-06-07 19:13:18 +0000
commit635ba1565cfbb02fbdd19de72651dbda9bb3c3b3 (patch)
treea35529429eea9176cdfb880b7015fcfe019e79e0
parent1312498709d864b8d28b3179cfa7597a92f12bbe (diff)
Add NEW_INTERFACE bits.
-rw-r--r--src/mesa/drivers/dri/sis/sis_screen.c130
1 files changed, 128 insertions, 2 deletions
diff --git a/src/mesa/drivers/dri/sis/sis_screen.c b/src/mesa/drivers/dri/sis/sis_screen.c
index df4cc7b2324..e67370f172a 100644
--- a/src/mesa/drivers/dri/sis/sis_screen.c
+++ b/src/mesa/drivers/dri/sis/sis_screen.c
@@ -41,6 +41,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "xmlpool.h"
+#ifndef _SOLO
+#include "GL/internal/dri_interface.h"
+#endif
+
const char __driConfigOptions[] =
DRI_CONF_BEGIN
DRI_CONF_SECTION_DEBUG
@@ -54,6 +58,72 @@ DRI_CONF_BEGIN
DRI_CONF_END;
static const GLuint __driNConfigOptions = 2;
+#ifdef USE_NEW_INTERFACE
+static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
+#endif /* USE_NEW_INTERFACE */
+
+#ifdef USE_NEW_INTERFACE
+static __GLcontextModes *
+sisFillInModes(int bpp)
+{
+ __GLcontextModes *modes;
+ __GLcontextModes *m;
+ unsigned num_modes;
+ unsigned depth_buffer_factor;
+ unsigned back_buffer_factor;
+ GLenum fb_format;
+ GLenum fb_type;
+ static const GLenum back_buffer_modes[] = {
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML
+ };
+ uint8_t depth_bits_array[4];
+ uint8_t stencil_bits_array[4];
+
+ depth_bits_array[0] = 0;
+ stencil_bits_array[0] = 0;
+ depth_bits_array[1] = 16;
+ stencil_bits_array[1] = 0;
+ depth_bits_array[2] = 24;
+ stencil_bits_array[2] = 8;
+ depth_bits_array[3] = 32;
+ stencil_bits_array[3] = 0;
+
+ depth_buffer_factor = 4;
+ back_buffer_factor = 2;
+
+ /* Last 4 is for GLX_TRUE_COLOR & GLX_DIRECT_COLOR, with/without accum */
+ num_modes = depth_buffer_factor * back_buffer_factor * 4;
+
+ if (bpp == 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;
+ }
+
+ 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 */
+
/* Create the device specific screen private data struct.
*/
static sisScreenPtr
@@ -62,8 +132,11 @@ sisCreateScreen( __DRIscreenPrivate *sPriv )
sisScreenPtr sisScreen;
SISDRIPtr sisDRIPriv = (SISDRIPtr)sPriv->pDevPriv;
+#ifndef USE_NEW_INTERFACE
+ /* XXX Should this still be around for the old interface? */
if ( !driCheckDriDdxDrmVersions( sPriv, "SiS", 4, 0, 0, 1, 1, 0 ) )
return NULL;
+#endif
/* Allocate the private area */
sisScreen = (sisScreenPtr)CALLOC( sizeof(*sisScreen) );
@@ -274,12 +347,13 @@ static struct __DriverAPIRec sisAPI = {
* 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)
{
__DRIscreenPrivate *psp;
- psp = __driUtilCreateScreen( dpy, scrn, psc, numConfigs, config, &sisAPI );
+ psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &sisAPI);
return (void *)psp;
}
#else
@@ -288,6 +362,58 @@ void *__driCreateScreen(struct DRIDriverRec *driver,
{
__DRIscreenPrivate *psp;
psp = __driUtilCreateScreen(driver, driverContext, &sisAPI);
- return (void *) psp;
+ return (void *)psp;
}
#endif
+#endif /* !defined(DRI_NEW_INTERFACE_ONLY) */
+
+/**
+ * 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 = {0, 1, 0};
+ static const __DRIversion dri_expected = {4, 0, 0};
+ static const __DRIversion drm_expected = {1, 0, 0};
+
+ if (!driCheckDriDdxDrmVersions2("SiS", 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, &sisAPI);
+ if (psp != NULL) {
+ create_context_modes = (PFNGLXCREATECONTEXTMODES)
+ glXGetProcAddress((const GLubyte *)"__glXCreateContextModes");
+ if (create_context_modes != NULL) {
+ SISDRIPtr dri_priv = (SISDRIPtr)psp->pDevPriv;
+ *driver_modes = sisFillInModes(dri_priv->bytesPerPixel * 8);
+ }
+ }
+
+ return (void *)psp;
+}
+#endif /* USE_NEW_INTERFACE */