summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2004-10-31 17:56:28 +0000
committerBrian Paul <[email protected]>2004-10-31 17:56:28 +0000
commit66f3231322c8c1c398cc95617813da5b4aa6bddc (patch)
treea5012697f419ddc4d43489c318d985616eb1c8ab
parentbd3b40ad75d50483aaa99ad2d08a3dd8f20cdb42 (diff)
PBO support for glColorTable, glColorSubTable, glGetColorTable, etc.
-rw-r--r--src/mesa/main/colortab.c71
-rw-r--r--src/mesa/swrast/s_imaging.c16
2 files changed, 78 insertions, 9 deletions
diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c
index 382e8cd2770..3fdab6a27db 100644
--- a/src/mesa/main/colortab.c
+++ b/src/mesa/main/colortab.c
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 6.1
+ * Version: 6.3
*
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
@@ -24,7 +24,7 @@
#include "glheader.h"
-#include "imports.h"
+#include "bufferobj.h"
#include "colortab.h"
#include "context.h"
#include "image.h"
@@ -192,6 +192,27 @@ store_colortable_entries(GLcontext *ctx, struct gl_color_table *table,
GLfloat bScale, GLfloat bBias,
GLfloat aScale, GLfloat aBias)
{
+ if (ctx->Unpack.BufferObj->Name) {
+ /* Get/unpack the color table data from a PBO */
+ GLubyte *buf;
+ if (!_mesa_validate_pbo_access(&ctx->Unpack, count, 1, 1,
+ format, type, data)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glColor[Sub]Table(bad PBO access)");
+ return;
+ }
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ GL_READ_ONLY_ARB,
+ ctx->Unpack.BufferObj);
+ if (!buf) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glColor[Sub]Table(PBO mapped)");
+ return;
+ }
+ data = ADD_POINTERS(buf, data);
+ }
+
+
if (table->Type == GL_FLOAT) {
/* convert user-provided data to GLfloat values */
GLfloat tempTab[MAX_COLOR_TABLE_SIZE * 4];
@@ -199,15 +220,18 @@ store_colortable_entries(GLcontext *ctx, struct gl_color_table *table,
GLint i;
_mesa_unpack_color_span_float(ctx,
- count, /* number of pixels */
- table->Format, /* dest format */
- tempTab, /* dest address */
- format, type, data, /* src data */
- &ctx->Unpack,
+ count, /* number of pixels */
+ table->Format, /* dest format */
+ tempTab, /* dest address */
+ format, type, /* src format/type */
+ data, /* src data */
+ &ctx->Unpack,
IMAGE_CLAMP_BIT); /* transfer ops */
+ /* the destination */
tableF = (GLfloat *) table->Table;
+ /* Apply scale & bias & clamp now */
switch (table->Format) {
case GL_INTENSITY:
for (i = 0; i < count; i++) {
@@ -267,6 +291,11 @@ store_colortable_entries(GLcontext *ctx, struct gl_color_table *table,
&ctx->Unpack,
0); /* transfer ops */
}
+
+ if (ctx->Unpack.BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ ctx->Unpack.BufferObj);
+ }
}
@@ -639,7 +668,6 @@ _mesa_ColorSubTable( GLenum target, GLsizei start,
-/* XXX not tested */
void GLAPIENTRY
_mesa_CopyColorTable(GLenum target, GLenum internalformat,
GLint x, GLint y, GLsizei width)
@@ -653,7 +681,6 @@ _mesa_CopyColorTable(GLenum target, GLenum internalformat,
-/* XXX not tested */
void GLAPIENTRY
_mesa_CopyColorSubTable(GLenum target, GLsizei start,
GLint x, GLint y, GLsizei width)
@@ -861,8 +888,34 @@ _mesa_GetColorTable( GLenum target, GLenum format,
return;
}
+ if (ctx->Pack.BufferObj->Name) {
+ /* pack color table into PBO */
+ GLubyte *buf;
+ if (!_mesa_validate_pbo_access(&ctx->Pack, table->Size, 1, 1,
+ format, type, data)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetColorTable(invalid PBO access)");
+ return;
+ }
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ GL_WRITE_ONLY_ARB,
+ ctx->Pack.BufferObj);
+ if (!buf) {
+ /* buffer is already mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetColorTable(PBO is mapped)");
+ return;
+ }
+ data = ADD_POINTERS(buf, data);
+ }
+
_mesa_pack_rgba_span_chan(ctx, table->Size, (const GLchan (*)[4]) rgba,
format, type, data, &ctx->Pack, GL_FALSE);
+
+ if (ctx->Pack.BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ ctx->Pack.BufferObj);
+ }
}
diff --git a/src/mesa/swrast/s_imaging.c b/src/mesa/swrast/s_imaging.c
index a15cc0ba57c..088215d5350 100644
--- a/src/mesa/swrast/s_imaging.c
+++ b/src/mesa/swrast/s_imaging.c
@@ -39,6 +39,7 @@ _swrast_CopyColorTable( GLcontext *ctx,
GLint x, GLint y, GLsizei width)
{
GLchan data[MAX_WIDTH][4];
+ struct gl_buffer_object *bufferSave;
/* Select buffer to read from */
_swrast_use_read_buffer(ctx);
@@ -52,7 +53,14 @@ _swrast_CopyColorTable( GLcontext *ctx,
/* Restore reading from draw buffer (the default) */
_swrast_use_draw_buffer(ctx);
+ /* save PBO binding */
+ bufferSave = ctx->Unpack.BufferObj;
+ ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
+
_mesa_ColorTable(target, internalformat, width, GL_RGBA, CHAN_TYPE, data);
+
+ /* restore PBO binding */
+ ctx->Unpack.BufferObj = bufferSave;
}
@@ -61,6 +69,7 @@ _swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start,
GLint x, GLint y, GLsizei width)
{
GLchan data[MAX_WIDTH][4];
+ struct gl_buffer_object *bufferSave;
/* Select buffer to read from */
_swrast_use_read_buffer(ctx);
@@ -74,7 +83,14 @@ _swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start,
/* Restore reading from draw buffer (the default) */
_swrast_use_draw_buffer(ctx);
+ /* save PBO binding */
+ bufferSave = ctx->Unpack.BufferObj;
+ ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
+
_mesa_ColorSubTable(target, start, width, GL_RGBA, CHAN_TYPE, data);
+
+ /* restore PBO binding */
+ ctx->Unpack.BufferObj = bufferSave;
}