GLuint index = (src - GL_COLOR_ATTACHMENT0);
if(index >= MAX_COLOR_ATTACHMENTS)
{
- return error(GL_INVALID_ENUM);
+ return error(GL_INVALID_OPERATION);
}
if(readFramebufferName == 0)
{
}
break;
default:
- error(GL_INVALID_ENUM);
+ return error(GL_INVALID_ENUM);
}
}
}
return error(GL_INVALID_OPERATION, GL_TRUE);
}
+ if(!buffer->isMapped())
+ {
+ // Already unmapped
+ return error(GL_INVALID_OPERATION, GL_TRUE);
+ }
+
return buffer->unmap() ? GL_TRUE : GL_FALSE;
}
TRACE("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = %X)",
target, offset, length, access);
+ if((offset < 0) || (length < 0))
+ {
+ return error(GL_INVALID_VALUE, nullptr);
+ }
+
+ if(!(access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)))
+ {
+ // Must be able to read or write the buffer
+ return error(GL_INVALID_OPERATION, nullptr);
+ }
+ else if((access & GL_MAP_READ_BIT) && (access & (GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT | GL_MAP_UNSYNCHRONIZED_BIT)))
+ {
+ // GL_MAP_INVALIDATE_RANGE_BIT, GL_MAP_INVALIDATE_BUFFER_BIT and GL_MAP_UNSYNCHRONIZED_BIT can't be used with GL_MAP_READ_BIT
+ return error(GL_INVALID_OPERATION, nullptr);
+ }
+ else if((!(access & GL_MAP_WRITE_BIT)) && (access & GL_MAP_FLUSH_EXPLICIT_BIT))
+ {
+ // GL_MAP_FLUSH_EXPLICIT_BIT can't be used without GL_MAP_WRITE_BIT
+ return error(GL_INVALID_OPERATION, nullptr);
+ }
+
es2::Context *context = es2::getContext();
if(context)
}
GLsizeiptr bufferSize = buffer->size();
- if((offset < 0) || (length < 0) || ((offset + length) > bufferSize))
+ if((offset + length) > bufferSize)
{
- error(GL_INVALID_VALUE);
+ return error(GL_INVALID_VALUE, nullptr);
}
if((access & ~(GL_MAP_READ_BIT |
GL_MAP_FLUSH_EXPLICIT_BIT |
GL_MAP_UNSYNCHRONIZED_BIT)) != 0)
{
- error(GL_INVALID_VALUE);
+ return error(GL_INVALID_VALUE, nullptr);
}
return buffer->mapRange(offset, length, access);
TRACE("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)",
target, offset, length);
+ if((offset < 0) || (length < 0))
+ {
+ return error(GL_INVALID_VALUE);
+ }
+
es2::Context *context = es2::getContext();
if(context)
return error(GL_INVALID_OPERATION);
}
- GLsizeiptr bufferSize = buffer->size();
- if((offset < 0) || (length < 0) || ((offset + length) > bufferSize))
+ if(!buffer->isMapped())
+ {
+ // Buffer must be mapped
+ return error(GL_INVALID_OPERATION);
+ }
+
+ GLsizeiptr bufferSize = buffer->length();
+ if((offset + length) > bufferSize)
+ {
+ return error(GL_INVALID_VALUE);
+ }
+
+ if(!(buffer->usage() & GL_MAP_FLUSH_EXPLICIT_BIT))
{
- error(GL_INVALID_VALUE);
+ // Flush must be explicitly allowed
+ return error(GL_INVALID_OPERATION);
}
buffer->flushMappedRange(offset, length);
if((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0)
{
- error(GL_INVALID_VALUE);
+ return error(GL_INVALID_VALUE, GL_FALSE);
}
es2::Context *context = es2::getContext();