updated for PBOs
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
* Version: 6.1
|
* Version: 6.3
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
|
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
|
||||||
*
|
*
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "glheader.h"
|
#include "glheader.h"
|
||||||
|
#include "bufferobj.h"
|
||||||
#include "colormac.h"
|
#include "colormac.h"
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
@@ -705,7 +706,7 @@ _mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvo
|
|||||||
format != GL_ABGR_EXT &&
|
format != GL_ABGR_EXT &&
|
||||||
format != GL_LUMINANCE &&
|
format != GL_LUMINANCE &&
|
||||||
format != GL_LUMINANCE_ALPHA) {
|
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)) {
|
if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
|
||||||
@@ -713,8 +714,29 @@ _mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvo
|
|||||||
return;
|
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;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
GLfloat minmax[2][4];
|
GLfloat minmax[2][4];
|
||||||
@@ -730,6 +752,11 @@ _mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvo
|
|||||||
format, type, values, &ctx->Pack, 0);
|
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) {
|
if (reset) {
|
||||||
_mesa_ResetMinmax(GL_MINMAX);
|
_mesa_ResetMinmax(GL_MINMAX);
|
||||||
}
|
}
|
||||||
@@ -771,13 +798,39 @@ _mesa_GetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, G
|
|||||||
return;
|
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;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
pack_histogram(ctx, ctx->Histogram.Width,
|
pack_histogram(ctx, ctx->Histogram.Width,
|
||||||
(CONST GLuint (*)[4]) ctx->Histogram.Count,
|
(CONST GLuint (*)[4]) ctx->Histogram.Count,
|
||||||
format, type, values, &ctx->Pack);
|
format, type, values, &ctx->Pack);
|
||||||
|
|
||||||
|
if (ctx->Pack.BufferObj->Name) {
|
||||||
|
ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
|
||||||
|
ctx->Pack.BufferObj);
|
||||||
|
}
|
||||||
|
|
||||||
if (reset) {
|
if (reset) {
|
||||||
GLuint i;
|
GLuint i;
|
||||||
for (i = 0; i < HISTOGRAM_TABLE_SIZE; i++) {
|
for (i = 0; i < HISTOGRAM_TABLE_SIZE; i++) {
|
||||||
|
Reference in New Issue
Block a user