vboxdri_drv.c revision ad27e1d5e48ca41245120c331cc88b50464813ce
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* Minimal swrast-based dri loadable driver.
*
* Todo:
* -- Use malloced (rather than framebuffer) memory for backbuffer
* -- 32bpp is hardwired -- fix
*
* NOTES:
* -- No mechanism for cliprects or resize notification --
* assumes this is a fullscreen device.
* -- No locking -- assumes this is the only driver accessing this
* device.
* -- Doesn't (yet) make use of any acceleration or other interfaces
* provided by fb. Would be entirely happy working against any
* fullscreen interface.
* -- HOWEVER: only a small number of pixelformats are supported, and
* the mechanism for choosing between them makes some assumptions
* that may not be valid everywhere.
*/
#include "driver.h"
#include "drm.h"
#include "utils.h"
#include "drirenderbuffer.h"
#include "buffers.h"
#include "extensions.h"
#include "framebuffer.h"
#include "renderbuffer.h"
#include "swrast_setup/swrast_setup.h"
#include "tnl/t_context.h"
#include "tnl/t_pipeline.h"
#include "drivers/common/driverfuncs.h"
#define need_GL_VERSION_1_3
#define need_GL_VERSION_1_4
#define need_GL_VERSION_1_5
#define need_GL_VERSION_2_0
#define need_GL_VERSION_2_1
/* sw extensions for imaging */
#define need_GL_EXT_blend_color
#define need_GL_EXT_blend_minmax
#define need_GL_EXT_convolution
#define need_GL_EXT_histogram
#define need_GL_SGI_color_table
/* sw extensions not associated with some GL version */
#define need_GL_ARB_shader_objects
#define need_GL_ARB_vertex_program
#define need_GL_ATI_fragment_shader
#define need_GL_EXT_depth_bounds_test
#define need_GL_EXT_framebuffer_object
#define need_GL_EXT_framebuffer_blit
#define need_GL_EXT_paletted_texture
#define need_GL_MESA_resize_buffers
#define need_GL_NV_vertex_program
#define need_GL_NV_fragment_program
#include "extension_helper.h"
const struct dri_extension card_extensions[] =
{
{ "GL_VERSION_1_3", GL_VERSION_1_3_functions },
{ "GL_VERSION_1_4", GL_VERSION_1_4_functions },
{ "GL_VERSION_1_5", GL_VERSION_1_5_functions },
{ "GL_VERSION_2_0", GL_VERSION_2_0_functions },
{ "GL_VERSION_2_1", GL_VERSION_2_1_functions },
{ "GL_EXT_blend_color", GL_EXT_blend_color_functions },
{ "GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions },
{ "GL_EXT_convolution", GL_EXT_convolution_functions },
{ "GL_EXT_histogram", GL_EXT_histogram_functions },
{ "GL_SGI_color_table", GL_SGI_color_table_functions },
{ "GL_ARB_shader_objects", GL_ARB_shader_objects_functions },
{ "GL_ARB_vertex_program", GL_ARB_vertex_program_functions },
{ "GL_APPLE_vertex_array_object", GL_APPLE_vertex_array_object_functions },
{ "GL_ATI_fragment_shader", GL_ATI_fragment_shader_functions },
{ "GL_EXT_depth_bounds_test", GL_EXT_depth_bounds_test_functions },
{ "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions },
{ "GL_EXT_framebuffer_blit", GL_EXT_framebuffer_blit_functions },
{ "GL_EXT_gpu_program_parameters", GL_EXT_gpu_program_parameters_functions },
{ "GL_EXT_paletted_texture", GL_EXT_paletted_texture_functions },
{ "GL_IBM_multimode_draw_arrays", GL_IBM_multimode_draw_arrays_functions },
{ "GL_MESA_resize_buffers", GL_MESA_resize_buffers_functions },
{ "GL_NV_vertex_program", GL_NV_vertex_program_functions },
{ "GL_NV_fragment_program", GL_NV_fragment_program_functions },
};
typedef struct {
struct {
} dri;
} fbContext, *fbContextPtr;
static const GLubyte *
{
(void) ctx;
switch (pname) {
case GL_RENDERER:
return (const GLubyte *) "Mesa dumb framebuffer";
default:
return NULL;
}
}
static void
{
/* not much to do here - pass it on */
}
/**
* Called by ctx->Driver.GetBufferSize from in core Mesa to query the
* current framebuffer size.
*/
static void
{
}
static void
{
}
}
static void
{
/* XXX this should be called after we acquire the DRI lock, not here */
}
static void
{
}
/*
* Generate code for span functions.
*/
/* 24-bit BGR */
#define SPAN_VARS \
#define INIT_PIXEL_PTR(P, X, Y) \
#define INC_PIXEL_PTR(P) P += 3
#include "swrast/s_spantemp.h"
/* 32-bit BGRA */
#define SPAN_VARS \
#define INIT_PIXEL_PTR(P, X, Y) \
#define INC_PIXEL_PTR(P) P += 4
#include "swrast/s_spantemp.h"
/* 16-bit BGR (XXX implement dithering someday) */
#define SPAN_VARS \
#define INIT_PIXEL_PTR(P, X, Y) \
#define INC_PIXEL_PTR(P) P += 1
DST[0] = ( (((VALUE[RCOMP]) & 0xf8) << 8) | (((VALUE[GCOMP]) & 0xfc) << 3) | ((VALUE[BCOMP]) >> 3) )
#include "swrast/s_spantemp.h"
/* 15-bit BGR (XXX implement dithering someday) */
#define SPAN_VARS \
#define INIT_PIXEL_PTR(P, X, Y) \
#define INC_PIXEL_PTR(P) P += 1
DST[0] = ( (((VALUE[RCOMP]) & 0xf8) << 7) | (((VALUE[GCOMP]) & 0xf8) << 2) | ((VALUE[BCOMP]) >> 3) )
#include "swrast/s_spantemp.h"
/* 8-bit color index */
#define CI_MODE
#define SPAN_VARS \
#define INIT_PIXEL_PTR(P, X, Y) \
#define INC_PIXEL_PTR(P) P += 1
#include "swrast/s_spantemp.h"
void
{
}
}
}
}
}
}
else {
}
}
static void
{
}
unsigned depth_bits,
unsigned stencil_bits,
{
/* 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.
*/
if(deep) {
depth_bits_array[0] = 0;
stencil_bits_array[0] = 0;
} else {
depth_bits_array[0] = depth_bits;
depth_bits_array[1] = 0;
depth_bits_array[3] = 0;
stencil_bits_array[0] = 0;
stencil_bits_array[1] = 0;
}
return driCreateConfigs(
db_modes, 2);
}
/**
* This is the driver specific part of the createNewScreen entry point.
* Called when using legacy DRI.
*
* return the __GLcontextModes supported by this driver
*/
{
if ( ! driCheckDriDdxDrmVersions2( "vboxvideo",
return NULL;
}
1);
}
/* Create the device specific context.
*/
static GLboolean
void *sharedContextPrivate)
{
struct dd_function_table functions;
/* Allocate the Fb context */
if ( !fbmesa )
return GL_FALSE;
/* Init default driver functions then plug in our FBdev-specific functions
*/
/* Allocate the Mesa context */
if (sharedContextPrivate)
else
return GL_FALSE;
}
/* Create module contexts */
_swsetup_Wakeup( ctx );
/* use default TCL pipeline */
{
}
return GL_TRUE;
}
static void
{
/* check if we're deleting the currently bound context */
}
/* Free fb context resources */
if ( fbmesa ) {
/* free the Mesa context */
_mesa_free( fbmesa );
}
}
/* Create and initialize the Mesa and driver specific pixmap buffer
* data.
*/
static GLboolean
const __GLcontextModes *mesaVis,
{
struct gl_framebuffer *mesa_framebuffer;
if (isPixmap) {
return GL_FALSE; /* not implemented */
}
else {
if (!mesa_framebuffer)
return 0;
/* XXX double-check these parameters (bpp vs cpp, etc) */
{
}
if (mesaVis->doubleBufferMode) {
* driScrnPriv->fbHeight);
}
GL_FALSE, /* color */
swAlpha, /* or always zero? */
GL_FALSE /* aux */);
return 1;
}
}
static void
{
}
/* If the backbuffer is on a videocard, this is extraordinarily slow!
*/
static void
{
struct gl_renderbuffer * front_renderbuffer = mesa_framebuffer->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
int i;
int offset = 0;
for (i = 0; i < dPriv->h; i++) {
offset += currentPitch;
}
}
}
else {
/* XXX this shouldn't be an error but we can't handle it for now */
}
}
/* Force the context `c' to be the current context and associate with it
* buffer `b'.
*/
static GLboolean
{
if ( driContextPriv ) {
} else {
}
return GL_TRUE;
}
/* Force the context `c' to be unbound from its buffer.
*/
static GLboolean
{
return GL_TRUE;
}
const struct __DriverAPIRec driDriverAPI = {
};