+#include "errors.h"
#include "glheader.h"
#include "bufferobj.h"
#include "glformats.h"
#include "image.h"
-#include "imports.h"
#include "mtypes.h"
+#include "macros.h"
#include "pbo.h"
If a PBO is bound, 'ptr' is an offset into the bound PBO.
In that case 'clientMemSize' is ignored: we just use the PBO's size.
*/
- if (!_mesa_is_bufferobj(pack->BufferObj)) {
+ if (!pack->BufferObj) {
offset = 0;
size = (clientMemSize == INT_MAX) ? UINTPTR_MAX : clientMemSize;
} else {
/* no buffer! */
return GL_FALSE;
+ /* If the size of the image is zero then no pixels are accessed so we
+ * don't need to check anything else.
+ */
+ if (width == 0 || height == 0 || depth == 0)
+ return GL_TRUE;
+
/* get the offset to the first pixel we'll read/write */
start = _mesa_image_offset(dimensions, pack, width, height,
format, type, 0, 0, 0);
{
const GLubyte *buf;
- if (_mesa_is_bufferobj(unpack->BufferObj)) {
+ if (unpack->BufferObj) {
/* unpack from PBO */
buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0,
unpack->BufferObj->Size,
if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth,
format, type, clientMemSize, ptr)) {
- if (_mesa_is_bufferobj(unpack->BufferObj)) {
+ if (unpack->BufferObj) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(out of bounds PBO access)",
where);
return false;
}
- if (!_mesa_is_bufferobj(unpack->BufferObj)) {
+ if (!unpack->BufferObj) {
/* non-PBO access: no further validation to be done */
return true;
}
GLsizei imageSize, const GLvoid *pixels,
const char *where)
{
- if (!_mesa_is_bufferobj(unpack->BufferObj)) {
+ if (!unpack->BufferObj) {
/* not using a PBO */
return true;
}
const struct gl_pixelstore_attrib *unpack)
{
assert(unpack != &ctx->Pack); /* catch pack/unpack mismatch */
- if (_mesa_is_bufferobj(unpack->BufferObj)) {
+ if (unpack->BufferObj) {
ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj, MAP_INTERNAL);
}
}
{
void *buf;
- if (_mesa_is_bufferobj(pack->BufferObj)) {
+ if (pack->BufferObj) {
/* pack into PBO */
buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0,
pack->BufferObj->Size,
if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth,
format, type, clientMemSize, ptr)) {
- if (_mesa_is_bufferobj(unpack->BufferObj)) {
+ if (unpack->BufferObj) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(out of bounds PBO access)", where);
} else {
return NULL;
}
- if (!_mesa_is_bufferobj(unpack->BufferObj)) {
+ if (!unpack->BufferObj) {
/* non-PBO access: no further validation to be done */
return ptr;
}
const struct gl_pixelstore_attrib *pack)
{
assert(pack != &ctx->Unpack); /* catch pack/unpack mismatch */
- if (_mesa_is_bufferobj(pack->BufferObj)) {
+ if (pack->BufferObj) {
ctx->Driver.UnmapBuffer(ctx, pack->BufferObj, MAP_INTERNAL);
}
}
{
GLubyte *buf;
- if (!_mesa_is_bufferobj(unpack->BufferObj)) {
+ if (!unpack->BufferObj) {
/* no PBO */
return pixels;
}
return NULL;
}
- if (!_mesa_is_bufferobj(packing->BufferObj)) {
+ if (!packing->BufferObj) {
/* not using a PBO - return pointer unchanged */
return pixels;
}
_mesa_unmap_teximage_pbo(struct gl_context *ctx,
const struct gl_pixelstore_attrib *unpack)
{
- if (_mesa_is_bufferobj(unpack->BufferObj)) {
+ if (unpack->BufferObj) {
ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj, MAP_INTERNAL);
}
}