The old MESA_PBUFFER_ALLOC() function allocated memory on 512-byte boundaries.

Restore that behavior with new _mesa_alloc_texmemory() function.
Should fix via_sse_memcpy() problem in found with flightgear.
This commit is contained in:
Brian Paul 2005-07-05 14:13:42 +00:00
parent 78be0b5dad
commit 4cf6718725
3 changed files with 44 additions and 12 deletions

View File

@ -51,6 +51,29 @@
#include "mtypes.h"
/**
* We allocate texture memory on 512-byte boundaries so we can use MMX/SSE
* elsewhere.
*/
void *
_mesa_alloc_texmemory(GLsizei bytes)
{
return _mesa_align_malloc(bytes, 512);
}
/**
* Free texture memory allocated with _mesa_alloc_texmemory()
*/
void
_mesa_free_texmemory(void *m)
{
_mesa_align_free(m);
}
#if 0
static void PrintTexture(GLcontext *ctx, const struct gl_texture_image *img)
{
@ -572,17 +595,19 @@ _mesa_new_texture_image( GLcontext *ctx )
/**
* Free texture image data.
* This function is a fallback called via ctx->Driver.FreeTexImageData().
*
* \param teximage texture image.
*
* Free the texture image data if it's not marked as client data.
*/
void
_mesa_free_texture_image_data( GLcontext *ctx, struct gl_texture_image *texImage )
_mesa_free_texture_image_data(GLcontext *ctx,
struct gl_texture_image *texImage)
{
if (texImage->Data && !texImage->IsClientData) {
/* free the old texture data */
_mesa_free(texImage->Data);
_mesa_free_texmemory(texImage->Data);
}
texImage->Data = NULL;

View File

@ -5,9 +5,9 @@
/*
* Mesa 3-D graphics library
* Version: 6.1
* Version: 6.3
*
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
* 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"),
@ -35,6 +35,13 @@
#include "mtypes.h"
extern void *
_mesa_alloc_texmemory(GLsizei bytes);
extern void
_mesa_free_texmemory(void *m);
/** \name Internal functions */
/*@{*/

View File

@ -2207,7 +2207,7 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
sizeInBytes = texImage->CompressedSize;
else
sizeInBytes = postConvWidth * texImage->TexFormat->TexelBytes;
texImage->Data = _mesa_malloc(sizeInBytes);
texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
if (!texImage->Data) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
return;
@ -2295,7 +2295,7 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
sizeInBytes = texImage->CompressedSize;
else
sizeInBytes = postConvWidth * postConvHeight * texelBytes;
texImage->Data = _mesa_malloc(sizeInBytes);
texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
if (!texImage->Data) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
return;
@ -2375,7 +2375,7 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
sizeInBytes = texImage->CompressedSize;
else
sizeInBytes = width * height * depth * texelBytes;
texImage->Data = _mesa_malloc(sizeInBytes);
texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
if (!texImage->Data) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
return;
@ -2633,7 +2633,7 @@ _mesa_store_compressed_teximage2d(GLcontext *ctx, GLenum target, GLint level,
texImage->FetchTexelf = texImage->TexFormat->FetchTexel2Df;
/* allocate storage */
texImage->Data = _mesa_malloc(imageSize);
texImage->Data = _mesa_alloc_texmemory(imageSize);
if (!texImage->Data) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB");
return;
@ -3674,7 +3674,7 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
/* Free old image data */
if (dstImage->Data)
_mesa_free(dstImage->Data);
ctx->Driver.FreeTexImageData(ctx, dstImage);
/* initialize new image */
_mesa_init_teximage_fields(ctx, target, dstImage, dstWidth, dstHeight,
@ -3692,7 +3692,7 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
*/
if (dstImage->IsCompressed) {
ASSERT(dstImage->CompressedSize > 0); /* set by init_teximage_fields*/
dstImage->Data = _mesa_malloc(dstImage->CompressedSize);
dstImage->Data = _mesa_alloc_texmemory(dstImage->CompressedSize);
if (!dstImage->Data) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps");
return;
@ -3704,8 +3704,8 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
else {
bytesPerTexel = srcImage->TexFormat->TexelBytes;
ASSERT(dstWidth * dstHeight * dstDepth * bytesPerTexel > 0);
dstImage->Data = _mesa_malloc(dstWidth * dstHeight * dstDepth
* bytesPerTexel);
dstImage->Data = _mesa_alloc_texmemory(dstWidth * dstHeight
* dstDepth * bytesPerTexel);
if (!dstImage->Data) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps");
return;