/*
* Mesa 3-D graphics library
- * Version: 6.1
+ * Version: 6.3
*
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
#include "glheader.h"
+#include "bufferobj.h"
#include "colormac.h"
#include "context.h"
#include "image.h"
format != GL_ABGR_EXT &&
format != GL_LUMINANCE &&
format != GL_LUMINANCE_ALPHA) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetHistogram(format)");
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetMinMax(format)");
}
if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
return;
}
- if (!values)
+ if (ctx->Pack.BufferObj->Name) {
+ /* pack min/max values into a PBO */
+ GLubyte *buf;
+ if (!_mesa_validate_pbo_access(&ctx->Pack, 2, 1, 1,
+ format, type, values)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetMinMax(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,"glGetMinMax(PBO is mapped)");
+ return;
+ }
+ values = ADD_POINTERS(buf, values);
+ }
+ else if (!values) {
+ /* not an error */
return;
+ }
{
GLfloat minmax[2][4];
format, type, values, &ctx->Pack, 0);
}
+ if (ctx->Pack.BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ ctx->Pack.BufferObj);
+ }
+
if (reset) {
_mesa_ResetMinmax(GL_MINMAX);
}
return;
}
- if (!values)
+ if (ctx->Pack.BufferObj->Name) {
+ /* pack min/max values into a PBO */
+ GLubyte *buf;
+ if (!_mesa_validate_pbo_access(&ctx->Pack, ctx->Histogram.Width, 1, 1,
+ format, type, values)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetHistogram(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,"glGetHistogram(PBO is mapped)");
+ return;
+ }
+ values = ADD_POINTERS(buf, values);
+ }
+ else if (!values) {
+ /* not an error */
return;
+ }
pack_histogram(ctx, ctx->Histogram.Width,
(CONST GLuint (*)[4]) ctx->Histogram.Count,
format, type, values, &ctx->Pack);
+ if (ctx->Pack.BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ ctx->Pack.BufferObj);
+ }
+
if (reset) {
GLuint i;
for (i = 0; i < HISTOGRAM_TABLE_SIZE; i++) {