* 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.
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
*/
/*
* The back-buffer is allocated by the driver and is private.
*/
+#include <stdio.h>
+#include "main/api_exec.h"
#include "main/context.h"
#include "main/extensions.h"
#include "main/formats.h"
#include "main/framebuffer.h"
#include "main/imports.h"
#include "main/renderbuffer.h"
+#include "main/version.h"
+#include "main/vtxfmt.h"
#include "swrast/swrast.h"
+#include "swrast/s_renderbuffer.h"
#include "swrast_setup/swrast_setup.h"
#include "tnl/tnl.h"
#include "tnl/t_context.h"
#include "utils.h"
#include "main/teximage.h"
-#include "main/texfetch.h"
#include "main/texformat.h"
+#include "main/texobj.h"
#include "main/texstate.h"
#include "swrast_priv.h"
+#include "swrast/s_context.h"
+#include <sys/types.h>
+#ifdef HAVE_SYS_SYSCTL_H
+# include <sys/sysctl.h>
+#endif
+
+const __DRIextension **__driDriverGetExtensions_swrast(void);
+
+const char * const swrast_vendor_string = "Mesa Project";
+const char * const swrast_renderer_string = "Software Rasterizer";
/**
* Screen and config-related functions
struct dri_context *dri_ctx;
int x, y, w, h;
__DRIscreen *sPriv = dPriv->driScreenPriv;
- struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
+ struct swrast_texture_image *swImage;
uint32_t internalFormat;
+ mesa_format texFormat;
dri_ctx = pDRICtx->driverPrivate;
internalFormat = (texture_format == __DRI_TEXTURE_FORMAT_RGB ? 3 : 4);
- texUnit = _mesa_get_current_tex_unit(&dri_ctx->Base);
- texObj = _mesa_select_tex_object(&dri_ctx->Base, texUnit, target);
+ texObj = _mesa_get_current_tex_object(&dri_ctx->Base, target);
texImage = _mesa_get_tex_image(&dri_ctx->Base, texObj, target, 0);
+ swImage = swrast_texture_image(texImage);
_mesa_lock_texture(&dri_ctx->Base, texObj);
sPriv->swrast_loader->getDrawableInfo(dPriv, &x, &y, &w, &h, dPriv->loaderPrivate);
- _mesa_init_teximage_fields(&dri_ctx->Base, target, texImage,
- w, h, 1, 0, internalFormat);
-
if (texture_format == __DRI_TEXTURE_FORMAT_RGB)
- texImage->TexFormat = MESA_FORMAT_XRGB8888;
+ texFormat = MESA_FORMAT_B8G8R8X8_UNORM;
else
- texImage->TexFormat = MESA_FORMAT_ARGB8888;
+ texFormat = MESA_FORMAT_B8G8R8A8_UNORM;
- _mesa_set_fetch_functions(texImage, 2);
+ _mesa_init_teximage_fields(&dri_ctx->Base, texImage,
+ w, h, 1, 0, internalFormat, texFormat);
- sPriv->swrast_loader->getImage(dPriv, x, y, w, h, (char *)texImage->Data,
+ sPriv->swrast_loader->getImage(dPriv, x, y, w, h, (char *)swImage->Buffer,
dPriv->loaderPrivate);
_mesa_unlock_texture(&dri_ctx->Base, texObj);
}
static const __DRItexBufferExtension swrastTexBufferExtension = {
- { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION },
- swrastSetTexBuffer,
- swrastSetTexBuffer2,
+ .base = { __DRI_TEX_BUFFER, 3 },
+
+ .setTexBuffer = swrastSetTexBuffer,
+ .setTexBuffer2 = swrastSetTexBuffer2,
+ .releaseTexBuffer = NULL,
+};
+
+
+static int
+swrast_query_renderer_integer(__DRIscreen *psp, int param,
+ unsigned int *value)
+{
+ switch (param) {
+ case __DRI2_RENDERER_VENDOR_ID:
+ case __DRI2_RENDERER_DEVICE_ID:
+ /* Return 0xffffffff for both vendor and device id */
+ value[0] = 0xffffffff;
+ return 0;
+ case __DRI2_RENDERER_ACCELERATED:
+ value[0] = 0;
+ return 0;
+ case __DRI2_RENDERER_VIDEO_MEMORY: {
+ /* This should probably share code with os_get_total_physical_memory()
+ * from src/gallium/auxiliary/os/os_misc.c
+ */
+#if defined(CTL_HW) && defined(HW_MEMSIZE)
+ int mib[2] = { CTL_HW, HW_MEMSIZE };
+ unsigned long system_memory_bytes;
+ size_t len = sizeof(system_memory_bytes);
+ if (sysctl(mib, 2, &system_memory_bytes, &len, NULL, 0) != 0)
+ return -1;
+#elif defined(_SC_PHYS_PAGES) && defined(_SC_PAGE_SIZE)
+ /* XXX: Do we want to return the full amount of system memory ? */
+ const long system_memory_pages = sysconf(_SC_PHYS_PAGES);
+ const long system_page_size = sysconf(_SC_PAGE_SIZE);
+
+ if (system_memory_pages <= 0 || system_page_size <= 0)
+ return -1;
+
+ const uint64_t system_memory_bytes = (uint64_t) system_memory_pages
+ * (uint64_t) system_page_size;
+#else
+#error "Unsupported platform"
+#endif
+
+ const unsigned system_memory_megabytes =
+ (unsigned) (system_memory_bytes / (1024 * 1024));
+
+ value[0] = system_memory_megabytes;
+ return 0;
+ }
+ case __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE:
+ /**
+ * XXX: Perhaps we should return 1 ?
+ * See issue #7 from the spec, currently UNRESOLVED.
+ */
+ value[0] = 0;
+ return 0;
+ default:
+ return driQueryRendererIntegerCommon(psp, param, value);
+ }
+}
+
+static int
+swrast_query_renderer_string(__DRIscreen *psp, int param, const char **value)
+{
+ switch (param) {
+ case __DRI2_RENDERER_VENDOR_ID:
+ value[0] = swrast_vendor_string;
+ return 0;
+ case __DRI2_RENDERER_DEVICE_ID:
+ value[0] = swrast_renderer_string;
+ return 0;
+ default:
+ return -1;
+ }
+}
+
+static const __DRI2rendererQueryExtension swrast_query_renderer_extension = {
+ .base = { __DRI2_RENDERER_QUERY, 1 },
+
+ .queryInteger = swrast_query_renderer_integer,
+ .queryString = swrast_query_renderer_string
};
static const __DRIextension *dri_screen_extensions[] = {
&swrastTexBufferExtension.base,
+ &swrast_query_renderer_extension.base,
NULL
};
__DRIconfig **configs;
unsigned depth_buffer_factor;
unsigned back_buffer_factor;
- GLenum fb_format;
- GLenum fb_type;
+ mesa_format format;
/* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
* support pageflipping at all.
uint8_t stencil_bits_array[4];
uint8_t msaa_samples_array[1];
+ (void) psp;
+ (void) have_back_buffer;
+
depth_bits_array[0] = 0;
depth_bits_array[1] = 0;
depth_bits_array[2] = depth_bits;
back_buffer_factor = 2;
switch (pixel_bits) {
- case 8:
- fb_format = GL_RGB;
- fb_type = GL_UNSIGNED_BYTE_2_3_3_REV;
- break;
case 16:
- fb_format = GL_RGB;
- fb_type = GL_UNSIGNED_SHORT_5_6_5;
+ format = MESA_FORMAT_B5G6R5_UNORM;
break;
case 24:
- fb_format = GL_BGR;
- fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+ format = MESA_FORMAT_B8G8R8X8_UNORM;
break;
case 32:
- fb_format = GL_BGRA;
- fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+ format = MESA_FORMAT_B8G8R8A8_UNORM;
break;
default:
fprintf(stderr, "[%s:%u] bad depth %d\n", __func__, __LINE__,
return NULL;
}
- configs = driCreateConfigs(fb_format, fb_type,
+ configs = driCreateConfigs(format,
depth_bits_array, stencil_bits_array,
depth_buffer_factor, back_buffer_modes,
back_buffer_factor, msaa_samples_array, 1,
- GL_TRUE);
+ GL_TRUE, GL_FALSE);
if (configs == NULL) {
fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
__LINE__);
static const __DRIconfig **
dri_init_screen(__DRIscreen * psp)
{
- __DRIconfig **configs8, **configs16, **configs24, **configs32;
+ __DRIconfig **configs16, **configs24, **configs32;
TRACE;
+ psp->max_gl_compat_version = 21;
+ psp->max_gl_es1_version = 11;
+ psp->max_gl_es2_version = 20;
+
psp->extensions = dri_screen_extensions;
- configs8 = swrastFillInModes(psp, 8, 8, 0, 1);
configs16 = swrastFillInModes(psp, 16, 16, 0, 1);
configs24 = swrastFillInModes(psp, 24, 24, 8, 1);
configs32 = swrastFillInModes(psp, 32, 24, 8, 1);
- configs16 = driConcatConfigs(configs8, configs16);
configs24 = driConcatConfigs(configs16, configs24);
configs32 = driConcatConfigs(configs24, configs32);
dri_destroy_screen(__DRIscreen * sPriv)
{
TRACE;
+ (void) sPriv;
}
&& v->blueMask == 0xc0)
return PF_R3G3B2;
- _mesa_problem( NULL, "unexpected format in %s", __FUNCTION__ );
+ _mesa_problem( NULL, "unexpected format in %s", __func__ );
return 0;
}
static void
-swrast_delete_renderbuffer(struct gl_renderbuffer *rb)
+swrast_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
{
+ struct dri_swrast_renderbuffer *xrb = dri_swrast_renderbuffer(rb);
+
TRACE;
- free(rb->Data);
- free(rb);
+ free(xrb->Base.Buffer);
+ _mesa_delete_renderbuffer(ctx, rb);
}
/* see bytes_per_line in libGL */
-static INLINE int
+static inline int
bytes_per_line(unsigned pitch_bits, unsigned mul)
{
unsigned mask = mul - 1;
swrast_alloc_front_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
GLenum internalFormat, GLuint width, GLuint height)
{
- struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
+ struct dri_swrast_renderbuffer *xrb = dri_swrast_renderbuffer(rb);
TRACE;
- rb->Data = NULL;
+ (void) ctx;
+ (void) internalFormat;
+
+ xrb->Base.Buffer = NULL;
rb->Width = width;
rb->Height = height;
-
xrb->pitch = bytes_per_line(width * xrb->bpp, 32);
return GL_TRUE;
swrast_alloc_back_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
GLenum internalFormat, GLuint width, GLuint height)
{
- struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
+ struct dri_swrast_renderbuffer *xrb = dri_swrast_renderbuffer(rb);
TRACE;
- free(rb->Data);
+ free(xrb->Base.Buffer);
swrast_alloc_front_storage(ctx, rb, internalFormat, width, height);
- rb->Data = malloc(height * xrb->pitch);
+ xrb->Base.Buffer = malloc(height * xrb->pitch);
return GL_TRUE;
}
-static struct swrast_renderbuffer *
-swrast_new_renderbuffer(const struct gl_config *visual, GLboolean front)
+static struct dri_swrast_renderbuffer *
+swrast_new_renderbuffer(const struct gl_config *visual, __DRIdrawable *dPriv,
+ GLboolean front)
{
- struct swrast_renderbuffer *xrb = calloc(1, sizeof *xrb);
+ struct dri_swrast_renderbuffer *xrb = calloc(1, sizeof *xrb);
+ struct gl_renderbuffer *rb;
GLuint pixel_format;
TRACE;
if (!xrb)
return NULL;
- _mesa_init_renderbuffer(&xrb->Base, 0);
+ rb = &xrb->Base.Base;
+
+ _mesa_init_renderbuffer(rb, 0);
pixel_format = choose_pixel_format(visual);
- xrb->Base.Delete = swrast_delete_renderbuffer;
+ xrb->dPriv = dPriv;
+ xrb->Base.Base.Delete = swrast_delete_renderbuffer;
if (front) {
- xrb->Base.AllocStorage = swrast_alloc_front_storage;
- swrast_set_span_funcs_front(xrb, pixel_format);
+ rb->AllocStorage = swrast_alloc_front_storage;
}
else {
- xrb->Base.AllocStorage = swrast_alloc_back_storage;
- swrast_set_span_funcs_back(xrb, pixel_format);
+ rb->AllocStorage = swrast_alloc_back_storage;
}
switch (pixel_format) {
case PF_A8R8G8B8:
- xrb->Base.Format = MESA_FORMAT_ARGB8888;
- xrb->Base.InternalFormat = GL_RGBA;
- xrb->Base._BaseFormat = GL_RGBA;
- xrb->Base.DataType = GL_UNSIGNED_BYTE;
+ rb->Format = MESA_FORMAT_B8G8R8A8_UNORM;
+ rb->InternalFormat = GL_RGBA;
+ rb->_BaseFormat = GL_RGBA;
xrb->bpp = 32;
break;
case PF_X8R8G8B8:
- xrb->Base.Format = MESA_FORMAT_ARGB8888; /* XXX */
- xrb->Base.InternalFormat = GL_RGB;
- xrb->Base._BaseFormat = GL_RGB;
- xrb->Base.DataType = GL_UNSIGNED_BYTE;
+ rb->Format = MESA_FORMAT_B8G8R8A8_UNORM; /* XXX */
+ rb->InternalFormat = GL_RGB;
+ rb->_BaseFormat = GL_RGB;
xrb->bpp = 32;
break;
case PF_R5G6B5:
- xrb->Base.Format = MESA_FORMAT_RGB565;
- xrb->Base.InternalFormat = GL_RGB;
- xrb->Base._BaseFormat = GL_RGB;
- xrb->Base.DataType = GL_UNSIGNED_BYTE;
+ rb->Format = MESA_FORMAT_B5G6R5_UNORM;
+ rb->InternalFormat = GL_RGB;
+ rb->_BaseFormat = GL_RGB;
xrb->bpp = 16;
break;
case PF_R3G3B2:
- xrb->Base.Format = MESA_FORMAT_RGB332;
- xrb->Base.InternalFormat = GL_RGB;
- xrb->Base._BaseFormat = GL_RGB;
- xrb->Base.DataType = GL_UNSIGNED_BYTE;
+ rb->Format = MESA_FORMAT_B2G3R3_UNORM;
+ rb->InternalFormat = GL_RGB;
+ rb->_BaseFormat = GL_RGB;
xrb->bpp = 8;
break;
default:
+ free(xrb);
return NULL;
}
return xrb;
}
+static void
+swrast_map_renderbuffer(struct gl_context *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint x, GLuint y, GLuint w, GLuint h,
+ GLbitfield mode,
+ GLubyte **out_map,
+ GLint *out_stride)
+{
+ struct dri_swrast_renderbuffer *xrb = dri_swrast_renderbuffer(rb);
+ GLubyte *map = xrb->Base.Buffer;
+ int cpp = _mesa_get_format_bytes(rb->Format);
+ int stride = rb->Width * cpp;
+
+ if (rb->AllocStorage == swrast_alloc_front_storage) {
+ __DRIdrawable *dPriv = xrb->dPriv;
+ __DRIscreen *sPriv = dPriv->driScreenPriv;
+
+ xrb->map_mode = mode;
+ xrb->map_x = x;
+ xrb->map_y = rb->Height - y - h;
+ xrb->map_w = w;
+ xrb->map_h = h;
+
+ stride = w * cpp;
+ xrb->Base.Buffer = malloc(h * stride);
+
+ sPriv->swrast_loader->getImage(dPriv, x, xrb->map_y, w, h,
+ (char *) xrb->Base.Buffer,
+ dPriv->loaderPrivate);
+
+ *out_map = xrb->Base.Buffer + (h - 1) * stride;
+ *out_stride = -stride;
+ return;
+ }
+
+ assert(xrb->Base.Buffer);
+
+ if (rb->AllocStorage == swrast_alloc_back_storage) {
+ map += (rb->Height - 1) * stride;
+ stride = -stride;
+ }
+
+ map += (GLsizei)y * stride;
+ map += (GLsizei)x * cpp;
+
+ *out_map = map;
+ *out_stride = stride;
+}
+
+static void
+swrast_unmap_renderbuffer(struct gl_context *ctx,
+ struct gl_renderbuffer *rb)
+{
+ struct dri_swrast_renderbuffer *xrb = dri_swrast_renderbuffer(rb);
+
+ if (rb->AllocStorage == swrast_alloc_front_storage) {
+ __DRIdrawable *dPriv = xrb->dPriv;
+ __DRIscreen *sPriv = dPriv->driScreenPriv;
+
+ if (xrb->map_mode & GL_MAP_WRITE_BIT) {
+ sPriv->swrast_loader->putImage(dPriv, __DRI_SWRAST_IMAGE_OP_DRAW,
+ xrb->map_x, xrb->map_y,
+ xrb->map_w, xrb->map_h,
+ (char *) xrb->Base.Buffer,
+ dPriv->loaderPrivate);
+ }
+
+ free(xrb->Base.Buffer);
+ xrb->Base.Buffer = NULL;
+ }
+}
+
static GLboolean
dri_create_buffer(__DRIscreen * sPriv,
__DRIdrawable * dPriv,
{
struct dri_drawable *drawable = NULL;
struct gl_framebuffer *fb;
- struct swrast_renderbuffer *frontrb, *backrb;
+ struct dri_swrast_renderbuffer *frontrb, *backrb;
TRACE;
+ (void) sPriv;
+ (void) isPixmap;
+
drawable = CALLOC_STRUCT(dri_drawable);
if (drawable == NULL)
goto drawable_fail;
dPriv->driverPrivate = drawable;
drawable->dPriv = dPriv;
- drawable->row = malloc(MAX_WIDTH * 4);
+ drawable->row = malloc(SWRAST_MAX_WIDTH * 4);
if (drawable->row == NULL)
goto drawable_fail;
_mesa_initialize_window_framebuffer(fb, visual);
/* add front renderbuffer */
- frontrb = swrast_new_renderbuffer(visual, GL_TRUE);
- _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontrb->Base);
+ frontrb = swrast_new_renderbuffer(visual, dPriv, GL_TRUE);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontrb->Base.Base);
/* add back renderbuffer */
if (visual->doubleBufferMode) {
- backrb = swrast_new_renderbuffer(visual, GL_FALSE);
- _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backrb->Base);
+ backrb = swrast_new_renderbuffer(visual, dPriv, GL_FALSE);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backrb->Base.Base);
}
/* add software renderbuffers */
- _mesa_add_soft_renderbuffers(fb,
- GL_FALSE, /* color */
- visual->haveDepthBuffer,
- visual->haveStencilBuffer,
- visual->haveAccumBuffer,
- GL_FALSE, /* alpha */
- GL_FALSE /* aux bufs */);
+ _swrast_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ visual->haveDepthBuffer,
+ visual->haveStencilBuffer,
+ visual->haveAccumBuffer,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux bufs */);
return GL_TRUE;
if (drawable)
free(drawable->row);
- FREE(drawable);
+ free(drawable);
return GL_FALSE;
}
struct dri_drawable *drawable = dri_drawable(dPriv);
struct gl_framebuffer *fb;
- struct swrast_renderbuffer *frontrb, *backrb;
+ struct dri_swrast_renderbuffer *frontrb, *backrb;
TRACE;
fb = &drawable->Base;
frontrb =
- swrast_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
+ dri_swrast_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
backrb =
- swrast_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer);
+ dri_swrast_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer);
/* check for signle-buffered */
if (backrb == NULL)
sPriv->swrast_loader->putImage(dPriv, __DRI_SWRAST_IMAGE_OP_SWAP,
0, 0,
- frontrb->Base.Width,
- frontrb->Base.Height,
- backrb->Base.Data,
+ frontrb->Base.Base.Width,
+ frontrb->Base.Base.Height,
+ (char *) backrb->Base.Buffer,
dPriv->loaderPrivate);
}
(void) ctx;
switch (pname) {
case GL_VENDOR:
- return (const GLubyte *) "Mesa Project";
+ return (const GLubyte *) swrast_vendor_string;
case GL_RENDERER:
- return (const GLubyte *) "Software Rasterizer";
+ return (const GLubyte *) swrast_renderer_string;
default:
return NULL;
}
}
static void
-viewport(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+viewport(struct gl_context *ctx)
{
struct gl_framebuffer *draw = ctx->WinSysDrawBuffer;
struct gl_framebuffer *read = ctx->WinSysReadBuffer;
swrast_check_and_update_window_size(ctx, read);
}
-static gl_format swrastChooseTextureFormat(struct gl_context * ctx,
+static mesa_format swrastChooseTextureFormat(struct gl_context * ctx,
+ GLenum target,
GLint internalFormat,
GLenum format,
GLenum type)
{
if (internalFormat == GL_RGB)
- return MESA_FORMAT_XRGB8888;
- return _mesa_choose_tex_format(ctx, internalFormat, format, type);
+ return MESA_FORMAT_B8G8R8X8_UNORM;
+ return _mesa_choose_tex_format(ctx, target, internalFormat, format, type);
}
static void
{
driver->GetString = get_string;
driver->UpdateState = update_state;
- driver->GetBufferSize = NULL;
driver->Viewport = viewport;
driver->ChooseTextureFormat = swrastChooseTextureFormat;
+ driver->MapRenderbuffer = swrast_map_renderbuffer;
+ driver->UnmapRenderbuffer = swrast_unmap_renderbuffer;
}
-
/**
* Context-related functions.
*/
static GLboolean
dri_create_context(gl_api api,
const struct gl_config * visual,
- __DRIcontext * cPriv, void *sharedContextPrivate)
+ __DRIcontext * cPriv,
+ unsigned major_version,
+ unsigned minor_version,
+ uint32_t flags,
+ bool notify_reset,
+ unsigned *error,
+ void *sharedContextPrivate)
{
struct dri_context *ctx = NULL;
struct dri_context *share = (struct dri_context *)sharedContextPrivate;
TRACE;
+ /* Flag filtering is handled in dri2CreateContextAttribs.
+ */
+ (void) flags;
+
ctx = CALLOC_STRUCT(dri_context);
- if (ctx == NULL)
+ if (ctx == NULL) {
+ *error = __DRI_CTX_ERROR_NO_MEMORY;
goto context_fail;
+ }
cPriv->driverPrivate = ctx;
ctx->cPriv = cPriv;
mesaCtx = &ctx->Base;
/* basic context setup */
- if (!_mesa_initialize_context(mesaCtx, visual, sharedCtx, &functions, (void *) cPriv)) {
+ if (!_mesa_initialize_context(mesaCtx, api, visual, sharedCtx, &functions)) {
+ *error = __DRI_CTX_ERROR_NO_MEMORY;
goto context_fail;
}
- /* do bounds checking to prevent segfaults and server crashes! */
- mesaCtx->Const.CheckArrayBounds = GL_TRUE;
+ driContextSetFlags(mesaCtx, flags);
/* create module contexts */
_swrast_CreateContext( mesaCtx );
tnl->Driver.RunPipeline = _tnl_run_pipeline;
}
+ _mesa_meta_init(mesaCtx);
_mesa_enable_sw_extensions(mesaCtx);
- _mesa_enable_1_3_extensions(mesaCtx);
- _mesa_enable_1_4_extensions(mesaCtx);
- _mesa_enable_1_5_extensions(mesaCtx);
- _mesa_enable_2_0_extensions(mesaCtx);
- _mesa_enable_2_1_extensions(mesaCtx);
- _mesa_meta_init(mesaCtx);
+ _mesa_compute_version(mesaCtx);
- driInitExtensions( mesaCtx, NULL, GL_FALSE );
+ _mesa_initialize_dispatch_tables(mesaCtx);
+ _mesa_initialize_vbo_vtxfmt(mesaCtx);
+ *error = __DRI_CTX_ERROR_SUCCESS;
return GL_TRUE;
context_fail:
- FREE(ctx);
+ free(ctx);
return GL_FALSE;
}
return GL_TRUE;
}
+static void
+dri_copy_sub_buffer(__DRIdrawable *dPriv, int x, int y,
+ int w, int h)
+{
+ __DRIscreen *sPriv = dPriv->driScreenPriv;
+ void *data;
+ int iy;
+ struct dri_drawable *drawable = dri_drawable(dPriv);
+ struct gl_framebuffer *fb;
+ struct dri_swrast_renderbuffer *frontrb, *backrb;
+
+ TRACE;
+
+ fb = &drawable->Base;
+
+ frontrb =
+ dri_swrast_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
+ backrb =
+ dri_swrast_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer);
+
+ /* check for signle-buffered */
+ if (backrb == NULL)
+ return;
+
+ iy = frontrb->Base.Base.Height - y - h;
+ data = (char *)backrb->Base.Buffer + (iy * backrb->pitch) + (x * ((backrb->bpp + 7) / 8));
+ sPriv->swrast_loader->putImage2(dPriv, __DRI_SWRAST_IMAGE_OP_SWAP,
+ x, iy, w, h,
+ frontrb->pitch,
+ data,
+ dPriv->loaderPrivate);
+}
+
-const struct __DriverAPIRec driDriverAPI = {
+static const struct __DriverAPIRec swrast_driver_api = {
.InitScreen = dri_init_screen,
.DestroyScreen = dri_destroy_screen,
.CreateContext = dri_create_context,
.SwapBuffers = dri_swap_buffers,
.MakeCurrent = dri_make_current,
.UnbindContext = dri_unbind_context,
+ .CopySubBuffer = dri_copy_sub_buffer,
+};
+
+static const struct __DRIDriverVtableExtensionRec swrast_vtable = {
+ .base = { __DRI_DRIVER_VTABLE, 1 },
+ .vtable = &swrast_driver_api,
};
-/* This is the table of extensions that the loader will dlsym() for. */
-PUBLIC const __DRIextension *__driDriverExtensions[] = {
+static const __DRIextension *swrast_driver_extensions[] = {
&driCoreExtension.base,
&driSWRastExtension.base,
+ &driCopySubBufferExtension.base,
+ &dri2ConfigQueryExtension.base,
+ &swrast_vtable.base,
NULL
};
+
+PUBLIC const __DRIextension **__driDriverGetExtensions_swrast(void)
+{
+ globalDriverAPI = &swrast_driver_api;
+
+ return swrast_driver_extensions;
+}