Only r200 implemented it.
#endif /* GLX_NV_vertex_array_range */
-/*
- * ???. GLX_MESA_allocate_memory
- */
-#ifndef GLX_MESA_allocate_memory
-#define GLX_MESA_allocate_memory 1
-
-extern void *glXAllocateMemoryMESA(Display *dpy, int scrn, size_t size, float readfreq, float writefreq, float priority);
-extern void glXFreeMemoryMESA(Display *dpy, int scrn, void *pointer);
-extern GLuint glXGetMemoryOffsetMESA(Display *dpy, int scrn, const void *pointer);
-typedef void * ( * PFNGLXALLOCATEMEMORYMESAPROC) (Display *dpy, int scrn, size_t size, float readfreq, float writefreq, float priority);
-typedef void ( * PFNGLXFREEMEMORYMESAPROC) (Display *dpy, int scrn, void *pointer);
-typedef GLuint (* PFNGLXGETMEMORYOFFSETMESAPROC) (Display *dpy, int scrn, const void *pointer);
-
-#endif /* GLX_MESA_allocate_memory */
-
-
/*
* ARB ?. GLX_ARB_render_texture
* XXX This was never finalized!
typedef struct __DRIextensionRec __DRIextension;
typedef struct __DRIcopySubBufferExtensionRec __DRIcopySubBufferExtension;
typedef struct __DRIswapControlExtensionRec __DRIswapControlExtension;
-typedef struct __DRIallocateExtensionRec __DRIallocateExtension;
typedef struct __DRIframeTrackingExtensionRec __DRIframeTrackingExtension;
typedef struct __DRImediaStreamCounterExtensionRec __DRImediaStreamCounterExtension;
typedef struct __DRItexOffsetExtensionRec __DRItexOffsetExtension;
unsigned int (*getSwapInterval)(__DRIdrawable *drawable);
};
-/**
- * Used by drivers that implement the GLX_MESA_allocate_memory.
- */
-#define __DRI_ALLOCATE "DRI_Allocate"
-#define __DRI_ALLOCATE_VERSION 1
-struct __DRIallocateExtensionRec {
- __DRIextension base;
-
- void *(*allocateMemory)(__DRIscreen *screen, GLsizei size,
- GLfloat readfreq, GLfloat writefreq,
- GLfloat priority);
-
- void (*freeMemory)(__DRIscreen *screen, GLvoid *pointer);
-
- GLuint (*memoryOffset)(__DRIscreen *screen, const GLvoid *pointer);
-};
-
/**
* Used by drivers that implement the GLX_MESA_swap_frame_usage extension.
*/
glXBindSwapBarrierSGIX glXQueryMaxSwapBarriersSGIX \
glXGetSyncValuesOML glXSwapBuffersMscOML \
glXWaitForMscOML glXWaitForSbcOML \
- glXAllocateMemoryMESA glXFreeMemoryMESA \
- glXGetMemoryOffsetMESA glXReleaseBuffersMESA \
+ glXReleaseBuffersMESA \
glXCreateGLXPixmapMESA glXCopySubBufferMESA \
glXQueryGLXPbufferSGIX glXCreateGLXPbufferSGIX \
glXDestroyGLXPbufferSGIX glXSelectEventSGIX \
}
-/**
- * GLX_MESA_allocate_memory
- */
-/*@{*/
-
-PUBLIC void *
-glXAllocateMemoryMESA(Display * dpy, int scrn,
- size_t size, float readFreq,
- float writeFreq, float priority)
-{
- (void) dpy;
- (void) scrn;
- (void) size;
- (void) readFreq;
- (void) writeFreq;
- (void) priority;
- return NULL;
-}
-
-
-PUBLIC void
-glXFreeMemoryMESA(Display * dpy, int scrn, void *pointer)
-{
-#ifdef __DRI_ALLOCATE
- __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, scrn);
-
- if (psc && psc->allocate)
- (*psc->allocate->freeMemory) (psc->__driScreen, pointer);
-
-#else
- (void) dpy;
- (void) scrn;
- (void) pointer;
-#endif /* __DRI_ALLOCATE */
-}
-
-
-PUBLIC GLuint
-glXGetMemoryOffsetMESA(Display * dpy, int scrn, const void *pointer)
-{
- (void) dpy;
- (void) scrn;
- (void) pointer;
- return ~0L;
-}
-
Bool
glXReleaseBuffersMESA(Display * dpy, GLXDrawable d)
{
}
#endif
-#ifdef __DRI_ALLOCATE
- if (strcmp(extensions[i]->name, __DRI_ALLOCATE) == 0) {
- psc->allocate = (__DRIallocateExtension *) extensions[i];
- __glXEnableDirectExtension(psc, "GLX_MESA_allocate_memory");
- }
-#endif
-
#ifdef __DRI_FRAME_TRACKING
if (strcmp(extensions[i]->name, __DRI_FRAME_TRACKING) == 0) {
psc->frameTracking = (__DRIframeTrackingExtension *) extensions[i];
const __DRIswapControlExtension *swapControl;
#endif
-#ifdef __DRI_ALLOCATE
- const __DRIallocateExtension *allocate;
-#endif
-
#ifdef __DRI_FRAME_TRACKING
const __DRIframeTrackingExtension *frameTracking;
#endif
return False;
}
-
-/**
- * GLX_MESA_allocate_memory
- */
-/*@{*/
-
-PUBLIC void *
-glXAllocateMemoryMESA(Display * dpy, int scrn,
- size_t size, float readFreq,
- float writeFreq, float priority)
-{
-#ifdef __DRI_ALLOCATE
- __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, scrn);
-
- if (psc && psc->allocate)
- return (*psc->allocate->allocateMemory) (psc->__driScreen, size,
- readFreq, writeFreq, priority);
-
-#else
- (void) dpy;
- (void) scrn;
- (void) size;
- (void) readFreq;
- (void) writeFreq;
- (void) priority;
-#endif /* __DRI_ALLOCATE */
-
- return NULL;
-}
-
-
-PUBLIC void
-glXFreeMemoryMESA(Display * dpy, int scrn, void *pointer)
-{
-#ifdef __DRI_ALLOCATE
- __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, scrn);
-
- if (psc && psc->allocate)
- (*psc->allocate->freeMemory) (psc->__driScreen, pointer);
-
-#else
- (void) dpy;
- (void) scrn;
- (void) pointer;
-#endif /* __DRI_ALLOCATE */
-}
-
-
-PUBLIC GLuint
-glXGetMemoryOffsetMESA(Display * dpy, int scrn, const void *pointer)
-{
-#ifdef __DRI_ALLOCATE
- __GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, scrn);
-
- if (psc && psc->allocate)
- return (*psc->allocate->memoryOffset) (psc->__driScreen, pointer);
-
-#else
- (void) dpy;
- (void) scrn;
- (void) pointer;
-#endif /* GLX_DIRECT_RENDERING */
-
- return ~0L;
-}
-
/*@}*/
GLX_FUNCTION2(glXBindSwapBarrierSGIX, __glXBindSwapBarrierSGIX),
GLX_FUNCTION2(glXQueryMaxSwapBarriersSGIX, __glXQueryMaxSwapBarriersSGIX),
- /*** GLX_MESA_allocate_memory ***/
- GLX_FUNCTION(glXAllocateMemoryMESA),
- GLX_FUNCTION(glXFreeMemoryMESA),
- GLX_FUNCTION(glXGetMemoryOffsetMESA),
-
/*** GLX_MESA_copy_sub_buffer ***/
GLX_FUNCTION2(glXCopySubBufferMESA, __glXCopySubBufferMESA),
{ GLX(EXT_visual_rating), VER(0,0), Y, Y, N, N },
#ifdef GLX_USE_APPLEGL
{ GLX(MESA_agp_offset), VER(0,0), N, N, N, N }, /* Deprecated */
- { GLX(MESA_allocate_memory), VER(0,0), N, N, N, N },
{ GLX(MESA_copy_sub_buffer), VER(0,0), N, N, N, N },
#else
{ GLX(MESA_agp_offset), VER(0,0), N, N, N, Y }, /* Deprecated */
- { GLX(MESA_allocate_memory), VER(0,0), Y, N, N, Y },
{ GLX(MESA_copy_sub_buffer), VER(0,0), Y, N, N, N },
#endif
{ GLX(MESA_pixmap_colormap), VER(0,0), N, N, N, N }, /* Deprecated */
EXT_visual_rating_bit,
EXT_import_context_bit,
MESA_agp_offset_bit,
- MESA_allocate_memory_bit, /* Replaces MESA_agp_offset & NV_vertex_array_range */
MESA_copy_sub_buffer_bit,
MESA_depth_float_bit,
MESA_pixmap_colormap_bit,
}
}
-/* This version of AllocateMemoryMESA allocates only GART memory, and
- * only does so after the point at which the driver has been
- * initialized.
- *
- * Theoretically a valid context isn't required. However, in this
- * implementation, it is, as I'm using the hardware lock to protect
- * the kernel data structures, and the current context to get the
- * device fd.
- */
-void *r200AllocateMemoryMESA(__DRIscreen *screen, GLsizei size,
- GLfloat readfreq, GLfloat writefreq,
- GLfloat priority)
-{
- GET_CURRENT_CONTEXT(ctx);
- r200ContextPtr rmesa;
- int region_offset;
- drm_radeon_mem_alloc_t alloc;
- int ret;
-
- if (R200_DEBUG & RADEON_IOCTL)
- fprintf(stderr, "%s sz %d %f/%f/%f\n", __FUNCTION__, size, readfreq,
- writefreq, priority);
-
- if (!ctx || !(rmesa = R200_CONTEXT(ctx)) || !rmesa->radeon.radeonScreen->gartTextures.map)
- return NULL;
-
- if (getenv("R200_NO_ALLOC"))
- return NULL;
-
- alloc.region = RADEON_MEM_REGION_GART;
- alloc.alignment = 0;
- alloc.size = size;
- alloc.region_offset = ®ion_offset;
-
- ret = drmCommandWriteRead( rmesa->radeon.radeonScreen->driScreen->fd,
- DRM_RADEON_ALLOC,
- &alloc, sizeof(alloc));
-
- if (ret) {
- fprintf(stderr, "%s: DRM_RADEON_ALLOC ret %d\n", __FUNCTION__, ret);
- return NULL;
- }
-
- {
- char *region_start = (char *)rmesa->radeon.radeonScreen->gartTextures.map;
- return (void *)(region_start + region_offset);
- }
-}
-
-
-/* Called via glXFreeMemoryMESA() */
-void r200FreeMemoryMESA(__DRIscreen *screen, GLvoid *pointer)
-{
- GET_CURRENT_CONTEXT(ctx);
- r200ContextPtr rmesa;
- ptrdiff_t region_offset;
- drm_radeon_mem_free_t memfree;
- int ret;
-
- if (R200_DEBUG & RADEON_IOCTL)
- fprintf(stderr, "%s %p\n", __FUNCTION__, pointer);
-
- if (!ctx || !(rmesa = R200_CONTEXT(ctx)) || !rmesa->radeon.radeonScreen->gartTextures.map) {
- fprintf(stderr, "%s: no context\n", __FUNCTION__);
- return;
- }
-
- region_offset = (char *)pointer - (char *)rmesa->radeon.radeonScreen->gartTextures.map;
-
- if (region_offset < 0 ||
- region_offset > rmesa->radeon.radeonScreen->gartTextures.size) {
- fprintf(stderr, "offset %d outside range 0..%d\n", region_offset,
- rmesa->radeon.radeonScreen->gartTextures.size);
- return;
- }
-
- memfree.region = RADEON_MEM_REGION_GART;
- memfree.region_offset = region_offset;
-
- ret = drmCommandWrite( rmesa->radeon.radeonScreen->driScreen->fd,
- DRM_RADEON_FREE,
- &memfree, sizeof(memfree));
-
- if (ret)
- fprintf(stderr, "%s: DRM_RADEON_FREE ret %d\n", __FUNCTION__, ret);
-}
-
-/* Called via glXGetMemoryOffsetMESA() */
-GLuint r200GetMemoryOffsetMESA(__DRIscreen *screen, const GLvoid *pointer)
-{
- GET_CURRENT_CONTEXT(ctx);
- r200ContextPtr rmesa;
- GLuint card_offset;
-
- if (!ctx || !(rmesa = R200_CONTEXT(ctx)) ) {
- fprintf(stderr, "%s: no context\n", __FUNCTION__);
- return ~0;
- }
-
- if (!r200IsGartMemory( rmesa, pointer, 0 ))
- return ~0;
-
- card_offset = r200GartOffsetFromVirtual( rmesa, pointer );
-
- return card_offset - rmesa->radeon.radeonScreen->gart_base;
-}
-
GLboolean r200IsGartMemory( r200ContextPtr rmesa, const GLvoid *pointer,
GLint size )
{
extern void r200InitIoctlFuncs( struct dd_function_table *functions );
-extern void *r200AllocateMemoryMESA( __DRIscreen *screen, GLsizei size, GLfloat readfreq,
- GLfloat writefreq, GLfloat priority );
-extern void r200FreeMemoryMESA( __DRIscreen *screen, GLvoid *pointer );
-extern GLuint r200GetMemoryOffsetMESA( __DRIscreen *screen, const GLvoid *pointer );
-
extern GLboolean r200IsGartMemory( r200ContextPtr rmesa, const GLvoid *pointer,
GLint size );
#endif
#if defined(RADEON_R200)
-static const __DRIallocateExtension r200AllocateExtension = {
- { __DRI_ALLOCATE, __DRI_ALLOCATE_VERSION },
- r200AllocateMemoryMESA,
- r200FreeMemoryMESA,
- r200GetMemoryOffsetMESA
-};
static const __DRItexOffsetExtension r200texOffsetExtension = {
{ __DRI_TEX_OFFSET, __DRI_TEX_OFFSET_VERSION },
#endif
#if defined(RADEON_R200)
- if (IS_R200_CLASS(screen))
- screen->extensions[i++] = &r200AllocateExtension.base;
-
screen->extensions[i++] = &r200texOffsetExtension.base;
#endif
#endif
#if defined(RADEON_R200)
- if (IS_R200_CLASS(screen))
- screen->extensions[i++] = &r200AllocateExtension.base;
-
screen->extensions[i++] = &r200TexBufferExtension.base;
#endif
}
-/*** GLX_MESA_allocate_memory */
-
-void PUBLIC *
-glXAllocateMemoryMESA(Display *dpy, int scrn, size_t size,
- float readfreq, float writefreq, float priority)
-{
- /* dummy */
- return NULL;
-}
-
-void PUBLIC
-glXFreeMemoryMESA(Display *dpy, int scrn, void *pointer)
-{
- /* dummy */
-}
-
-
-GLuint PUBLIC
-glXGetMemoryOffsetMESA(Display *dpy, int scrn, const void *pointer)
-{
- /* dummy */
- return 0;
-}
-
-
/*** GLX_EXT_texture_from_pixmap */
void PUBLIC
/*** GLX_MESA_agp_offset ***/
{ "glXGetAGPOffsetMESA", (__GLXextFuncPtr) glXGetAGPOffsetMESA },
- /*** GLX_MESA_allocate_memory ***/
- { "glXAllocateMemoryMESA", (__GLXextFuncPtr) glXAllocateMemoryMESA },
- { "glXFreeMemoryMESA", (__GLXextFuncPtr) glXFreeMemoryMESA },
- { "glXGetMemoryOffsetMESA", (__GLXextFuncPtr) glXGetMemoryOffsetMESA },
-
/*** GLX_EXT_texture_from_pixmap ***/
{ "glXBindTexImageEXT", (__GLXextFuncPtr) glXBindTexImageEXT },
{ "glXReleaseTexImageEXT", (__GLXextFuncPtr) glXReleaseTexImageEXT },