/lib_angle/src/libGLESv2/entry_points_gles_3_0.cpp
C++ | 3377 lines | 2818 code | 525 blank | 34 comment | 503 complexity | d2001ff41eb41ce33f10fab375a2b261 MD5 | raw file
Possible License(s): Zlib, BSD-3-Clause, CC0-1.0, GPL-3.0, GPL-2.0, CPL-1.0, MPL-2.0-no-copyleft-exception, LGPL-2.0, LGPL-2.1, LGPL-3.0, 0BSD, Cube
Large files files are truncated, but you can click here to view the full file
- //
- // Copyright(c) 2014 The ANGLE Project Authors. All rights reserved.
- // Use of this source code is governed by a BSD-style license that can be
- // found in the LICENSE file.
- //
- // entry_points_gles_3_0.cpp : Implements the GLES 3.0 entry points.
- #include "libGLESv2/entry_points_gles_3_0.h"
- #include "libGLESv2/entry_points_gles_2_0_ext.h"
- #include "libGLESv2/global_state.h"
- #include "libANGLE/formatutils.h"
- #include "libANGLE/Buffer.h"
- #include "libANGLE/Context.h"
- #include "libANGLE/Error.h"
- #include "libANGLE/Fence.h"
- #include "libANGLE/Framebuffer.h"
- #include "libANGLE/Query.h"
- #include "libANGLE/VertexArray.h"
- #include "libANGLE/validationES.h"
- #include "libANGLE/validationES3.h"
- #include "libANGLE/queryconversions.h"
- #include "common/debug.h"
- namespace gl
- {
- void GL_APIENTRY ReadBuffer(GLenum mode)
- {
- EVENT("(GLenum mode = 0x%X)", mode);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- // glReadBuffer
- UNIMPLEMENTED();
- }
- }
- void GL_APIENTRY DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
- {
- EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, "
- "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- // glDrawRangeElements
- UNIMPLEMENTED();
- }
- }
- void GL_APIENTRY TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
- {
- EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
- "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, "
- "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
- target, level, internalformat, width, height, depth, border, format, type, pixels);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- // validateES3TexImageFormat sets the error code if there is an error
- if (!ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
- 0, 0, 0, width, height, depth, border, format, type, pixels))
- {
- return;
- }
- Extents size(width, height, depth);
- Texture *texture = context->getTargetTexture(target);
- Error error = texture->setImage(target, level, internalformat, size, format, type, context->getState().getUnpackState(),
- reinterpret_cast<const uint8_t *>(pixels));
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- }
- void GL_APIENTRY TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels)
- {
- EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
- "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
- "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
- target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- // validateES3TexImageFormat sets the error code if there is an error
- if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
- xoffset, yoffset, zoffset, width, height, depth, 0,
- format, type, pixels))
- {
- return;
- }
- // Zero sized uploads are valid but no-ops
- if (width == 0 || height == 0 || depth == 0)
- {
- return;
- }
- Box area(xoffset, yoffset, zoffset, width, height, depth);
- Texture *texture = context->getTargetTexture(target);
- Error error = texture->setSubImage(target, level, area, format, type, context->getState().getUnpackState(),
- reinterpret_cast<const uint8_t *>(pixels));
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- }
- void GL_APIENTRY CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
- {
- EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
- "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
- target, level, xoffset, yoffset, zoffset, x, y, width, height);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- if (!ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true, xoffset, yoffset, zoffset,
- x, y, width, height, 0))
- {
- return;
- }
- Offset destOffset(xoffset, yoffset, zoffset);
- Rectangle sourceArea(x, y, width, height);
- const Framebuffer *framebuffer = context->getState().getReadFramebuffer();
- Texture *texture = context->getTargetTexture(target);
- Error error = texture->copySubImage(target, level, destOffset, sourceArea, framebuffer);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- }
- void GL_APIENTRY CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
- {
- EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
- "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, "
- "const GLvoid* data = 0x%0.8p)",
- target, level, internalformat, width, height, depth, border, imageSize, data);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- const InternalFormat &formatInfo = GetInternalFormatInfo(internalformat);
- if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- // validateES3TexImageFormat sets the error code if there is an error
- if (!ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
- 0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE, data))
- {
- return;
- }
- Extents size(width, height, depth);
- Texture *texture = context->getTargetTexture(target);
- Error error = texture->setCompressedImage(target, level, internalformat, size, context->getState().getUnpackState(),
- reinterpret_cast<const uint8_t *>(data));
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- }
- void GL_APIENTRY CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data)
- {
- EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
- "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
- "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
- target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- const InternalFormat &formatInfo = GetInternalFormatInfo(format);
- if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- if (!data)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- // validateES3TexImageFormat sets the error code if there is an error
- if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
- 0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE, data))
- {
- return;
- }
- // Zero sized uploads are valid but no-ops
- if (width == 0 || height == 0)
- {
- return;
- }
- Box area(xoffset, yoffset, zoffset, width, height, depth);
- Texture *texture = context->getTargetTexture(target);
- Error error = texture->setCompressedSubImage(target, level, area, format, context->getState().getUnpackState(),
- reinterpret_cast<const uint8_t *>(data));
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- }
- void GL_APIENTRY GenQueries(GLsizei n, GLuint* ids)
- {
- EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- if (n < 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- for (GLsizei i = 0; i < n; i++)
- {
- ids[i] = context->createQuery();
- }
- }
- }
- void GL_APIENTRY DeleteQueries(GLsizei n, const GLuint* ids)
- {
- EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- if (n < 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- for (GLsizei i = 0; i < n; i++)
- {
- context->deleteQuery(ids[i]);
- }
- }
- }
- GLboolean GL_APIENTRY IsQuery(GLuint id)
- {
- EVENT("(GLuint id = %u)", id);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return GL_FALSE;
- }
- return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
- }
- return GL_FALSE;
- }
- void GL_APIENTRY BeginQuery(GLenum target, GLuint id)
- {
- EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- if (!ValidateBeginQuery(context, target, id))
- {
- return;
- }
- Error error = context->beginQuery(target, id);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- }
- void GL_APIENTRY EndQuery(GLenum target)
- {
- EVENT("(GLenum target = 0x%X)", target);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- if (!ValidateEndQuery(context, target))
- {
- return;
- }
- Error error = context->endQuery(target);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- }
- void GL_APIENTRY GetQueryiv(GLenum target, GLenum pname, GLint* params)
- {
- EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- if (!ValidQueryType(context, target))
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return;
- }
- switch (pname)
- {
- case GL_CURRENT_QUERY:
- params[0] = static_cast<GLint>(context->getState().getActiveQueryId(target));
- break;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return;
- }
- }
- }
- void GL_APIENTRY GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
- {
- EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- Query *queryObject = context->getQuery(id, false, GL_NONE);
- if (!queryObject)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- if (context->getState().getActiveQueryId(queryObject->getType()) == id)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- switch(pname)
- {
- case GL_QUERY_RESULT_EXT:
- {
- Error error = queryObject->getResult(params);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
- case GL_QUERY_RESULT_AVAILABLE_EXT:
- {
- Error error = queryObject->isResultAvailable(params);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- break;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return;
- }
- }
- }
- GLboolean GL_APIENTRY UnmapBuffer(GLenum target)
- {
- EVENT("(GLenum target = 0x%X)", target);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return GL_FALSE;
- }
- return UnmapBufferOES(target);
- }
- return GL_FALSE;
- }
- void GL_APIENTRY GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
- {
- EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- GetBufferPointervOES(target, pname, params);
- }
- }
- void GL_APIENTRY DrawBuffers(GLsizei n, const GLenum* bufs)
- {
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- DrawBuffersEXT(n, bufs);
- }
- }
- void GL_APIENTRY UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
- {
- EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
- location, count, transpose, value);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x3, location, count, transpose))
- {
- return;
- }
- Program *program = context->getState().getProgram();
- program->setUniformMatrix2x3fv(location, count, transpose, value);
- }
- }
- void GL_APIENTRY UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
- {
- EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
- location, count, transpose, value);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x2, location, count, transpose))
- {
- return;
- }
- Program *program = context->getState().getProgram();
- program->setUniformMatrix3x2fv(location, count, transpose, value);
- }
- }
- void GL_APIENTRY UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
- {
- EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
- location, count, transpose, value);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x4, location, count, transpose))
- {
- return;
- }
- Program *program = context->getState().getProgram();
- program->setUniformMatrix2x4fv(location, count, transpose, value);
- }
- }
- void GL_APIENTRY UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
- {
- EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
- location, count, transpose, value);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x2, location, count, transpose))
- {
- return;
- }
- Program *program = context->getState().getProgram();
- program->setUniformMatrix4x2fv(location, count, transpose, value);
- }
- }
- void GL_APIENTRY UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
- {
- EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
- location, count, transpose, value);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x4, location, count, transpose))
- {
- return;
- }
- Program *program = context->getState().getProgram();
- program->setUniformMatrix3x4fv(location, count, transpose, value);
- }
- }
- void GL_APIENTRY UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
- {
- EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
- location, count, transpose, value);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x3, location, count, transpose))
- {
- return;
- }
- Program *program = context->getState().getProgram();
- program->setUniformMatrix4x3fv(location, count, transpose, value);
- }
- }
- void GL_APIENTRY BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
- {
- EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, "
- "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
- srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
- dstX0, dstY0, dstX1, dstY1, mask, filter,
- false))
- {
- return;
- }
- Framebuffer *readFramebuffer = context->getState().getReadFramebuffer();
- ASSERT(readFramebuffer);
- Framebuffer *drawFramebuffer = context->getState().getDrawFramebuffer();
- ASSERT(drawFramebuffer);
- Rectangle srcArea(srcX0, srcY0, srcX1 - srcX0, srcY1 - srcY0);
- Rectangle dstArea(dstX0, dstY0, dstX1 - dstX0, dstY1 - dstY0);
- Error error = drawFramebuffer->blit(context->getState(), srcArea, dstArea, mask, filter, readFramebuffer);
- if (error.isError())
- {
- context->recordError(error);
- return;
- }
- }
- }
- void GL_APIENTRY RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
- {
- EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
- target, samples, internalformat, width, height);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- if (!ValidateES3RenderbufferStorageParameters(context, target, samples, internalformat, width, height))
- {
- return;
- }
- Renderbuffer *renderbuffer = context->getState().getCurrentRenderbuffer();
- renderbuffer->setStorage(width, height, internalformat, samples);
- }
- }
- void GL_APIENTRY FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
- {
- EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)",
- target, attachment, texture, level, layer);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (!ValidateFramebufferTextureLayer(context, target, attachment, texture,
- level, layer))
- {
- return;
- }
- Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
- ASSERT(framebuffer);
- if (texture != 0)
- {
- Texture *textureObject = context->getTexture(texture);
- ImageIndex index = ImageIndex::MakeInvalid();
- if (textureObject->getTarget() == GL_TEXTURE_3D)
- {
- index = ImageIndex::Make3D(level, layer);
- }
- else
- {
- ASSERT(textureObject->getTarget() == GL_TEXTURE_2D_ARRAY);
- index = ImageIndex::Make2DArray(level, layer);
- }
- framebuffer->setTextureAttachment(attachment, textureObject, index);
- }
- else
- {
- framebuffer->setNULLAttachment(attachment);
- }
- }
- }
- GLvoid *GL_APIENTRY MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
- {
- EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
- target, offset, length, access);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return NULL;
- }
- return MapBufferRangeEXT(target, offset, length, access);
- }
- return NULL;
- }
- void GL_APIENTRY FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
- {
- EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- FlushMappedBufferRangeEXT(target, offset, length);
- }
- }
- void GL_APIENTRY BindVertexArray(GLuint array)
- {
- EVENT("(GLuint array = %u)", array);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- VertexArray *vao = context->getVertexArray(array);
- if (!vao)
- {
- // The default VAO should always exist
- ASSERT(array != 0);
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- context->bindVertexArray(array);
- }
- }
- void GL_APIENTRY DeleteVertexArrays(GLsizei n, const GLuint* arrays)
- {
- EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- if (n < 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
- {
- if (arrays[arrayIndex] != 0)
- {
- context->deleteVertexArray(arrays[arrayIndex]);
- }
- }
- }
- }
- void GL_APIENTRY GenVertexArrays(GLsizei n, GLuint* arrays)
- {
- EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- if (n < 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
- {
- arrays[arrayIndex] = context->createVertexArray();
- }
- }
- }
- GLboolean GL_APIENTRY IsVertexArray(GLuint array)
- {
- EVENT("(GLuint array = %u)", array);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return GL_FALSE;
- }
- if (array == 0)
- {
- return GL_FALSE;
- }
- VertexArray *vao = context->getVertexArray(array);
- return (vao != NULL ? GL_TRUE : GL_FALSE);
- }
- return GL_FALSE;
- }
- void GL_APIENTRY GetIntegeri_v(GLenum target, GLuint index, GLint* data)
- {
- EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)",
- target, index, data);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- const Caps &caps = context->getCaps();
- switch (target)
- {
- case GL_TRANSFORM_FEEDBACK_BUFFER_START:
- case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
- case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
- if (index >= caps.maxTransformFeedbackSeparateAttributes)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- break;
- case GL_UNIFORM_BUFFER_START:
- case GL_UNIFORM_BUFFER_SIZE:
- case GL_UNIFORM_BUFFER_BINDING:
- if (index >= caps.maxCombinedUniformBlocks)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- break;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return;
- }
- if (!(context->getIndexedIntegerv(target, index, data)))
- {
- GLenum nativeType;
- unsigned int numParams = 0;
- if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
- {
- context->recordError(Error(GL_INVALID_ENUM));
- return;
- }
- if (numParams == 0)
- {
- return; // it is known that pname is valid, but there are no parameters to return
- }
- if (nativeType == GL_INT_64_ANGLEX)
- {
- GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<int>::min());
- GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<int>::max());
- GLint64 *int64Params = new GLint64[numParams];
- context->getIndexedInteger64v(target, index, int64Params);
- for (unsigned int i = 0; i < numParams; ++i)
- {
- GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue);
- data[i] = static_cast<GLint>(clampedValue);
- }
- delete [] int64Params;
- }
- else
- {
- UNREACHABLE();
- }
- }
- }
- }
- void GL_APIENTRY BeginTransformFeedback(GLenum primitiveMode)
- {
- EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- switch (primitiveMode)
- {
- case GL_TRIANGLES:
- case GL_LINES:
- case GL_POINTS:
- break;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return;
- }
- TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
- ASSERT(transformFeedback != NULL);
- if (transformFeedback->isStarted())
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- if (transformFeedback->isPaused())
- {
- transformFeedback->resume();
- }
- else
- {
- transformFeedback->start(primitiveMode);
- }
- }
- }
- void GL_APIENTRY EndTransformFeedback(void)
- {
- EVENT("(void)");
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
- ASSERT(transformFeedback != NULL);
- if (!transformFeedback->isStarted())
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- transformFeedback->stop();
- }
- }
- void GL_APIENTRY BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
- {
- EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)",
- target, index, buffer, offset, size);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- const Caps &caps = context->getCaps();
- switch (target)
- {
- case GL_TRANSFORM_FEEDBACK_BUFFER:
- if (index >= caps.maxTransformFeedbackSeparateAttributes)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- break;
- case GL_UNIFORM_BUFFER:
- if (index >= caps.maxUniformBufferBindings)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- break;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return;
- }
- if (buffer != 0 && size <= 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- switch (target)
- {
- case GL_TRANSFORM_FEEDBACK_BUFFER:
- {
- // size and offset must be a multiple of 4
- if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0))
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- // Cannot bind a transform feedback buffer if the current transform feedback is active (3.0.4 pg 91 section 2.15.2)
- TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
- if (curTransformFeedback && curTransformFeedback->isStarted())
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size);
- context->bindGenericTransformFeedbackBuffer(buffer);
- break;
- }
- case GL_UNIFORM_BUFFER:
- // it is an error to bind an offset not a multiple of the alignment
- if (buffer != 0 && (offset % caps.uniformBufferOffsetAlignment) != 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- context->bindIndexedUniformBuffer(buffer, index, offset, size);
- context->bindGenericUniformBuffer(buffer);
- break;
- default:
- UNREACHABLE();
- }
- }
- }
- void GL_APIENTRY BindBufferBase(GLenum target, GLuint index, GLuint buffer)
- {
- EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)",
- target, index, buffer);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- const Caps &caps = context->getCaps();
- switch (target)
- {
- case GL_TRANSFORM_FEEDBACK_BUFFER:
- if (index >= caps.maxTransformFeedbackSeparateAttributes)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- break;
- case GL_UNIFORM_BUFFER:
- if (index >= caps.maxUniformBufferBindings)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- break;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return;
- }
- switch (target)
- {
- case GL_TRANSFORM_FEEDBACK_BUFFER:
- {
- // Cannot bind a transform feedback buffer if the current transform feedback is active (3.0.4 pg 91 section 2.15.2)
- TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
- if (curTransformFeedback && curTransformFeedback->isStarted())
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0);
- context->bindGenericTransformFeedbackBuffer(buffer);
- break;
- }
- case GL_UNIFORM_BUFFER:
- context->bindIndexedUniformBuffer(buffer, index, 0, 0);
- context->bindGenericUniformBuffer(buffer);
- break;
- default:
- UNREACHABLE();
- }
- }
- }
- void GL_APIENTRY TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
- {
- EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)",
- program, count, varyings, bufferMode);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- if (count < 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- const Caps &caps = context->getCaps();
- switch (bufferMode)
- {
- case GL_INTERLEAVED_ATTRIBS:
- break;
- case GL_SEPARATE_ATTRIBS:
- if (static_cast<GLuint>(count) > caps.maxTransformFeedbackSeparateAttributes)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- break;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return;
- }
- if (!ValidProgram(context, program))
- {
- return;
- }
- Program *programObject = context->getProgram(program);
- ASSERT(programObject);
- programObject->setTransformFeedbackVaryings(count, varyings, bufferMode);
- }
- }
- void GL_APIENTRY GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
- {
- EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, "
- "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
- program, index, bufSize, length, size, type, name);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- if (bufSize < 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- if (!ValidProgram(context, program))
- {
- return;
- }
- Program *programObject = context->getProgram(program);
- ASSERT(programObject);
- if (index >= static_cast<GLuint>(programObject->getTransformFeedbackVaryingCount()))
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name);
- }
- }
- void GL_APIENTRY VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
- {
- EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)",
- index, size, type, stride, pointer);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- if (index >= MAX_VERTEX_ATTRIBS)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- if (size < 1 || size > 4)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- switch (type)
- {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_INT_2_10_10_10_REV:
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- break;
- default:
- context->recordError(Error(GL_INVALID_ENUM));
- return;
- }
- if (stride < 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- // [OpenGL ES 3.0.2] Section 2.8 page 24:
- // An INVALID_OPERATION error is generated when a non-zero vertex array object
- // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
- // and the pointer argument is not NULL.
- if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && pointer != NULL)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type, false, true,
- stride, pointer);
- }
- }
- void GL_APIENTRY GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
- {
- EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
- index, pname, params);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- if (index >= MAX_VERTEX_ATTRIBS)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- const VertexAttribute &attribState = context->getState().getVertexAttribState(index);
- if (!ValidateGetVertexAttribParameters(context, pname))
- {
- return;
- }
- if (pname == GL_CURRENT_VERTEX_ATTRIB)
- {
- const VertexAttribCurrentValueData ¤tValueData = context->getState().getVertexAttribCurrentValue(index);
- for (int i = 0; i < 4; ++i)
- {
- params[i] = currentValueData.IntValues[i];
- }
- }
- else
- {
- *params = QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
- }
- }
- }
- void GL_APIENTRY GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
- {
- EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)",
- index, pname, params);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- if (index >= MAX_VERTEX_ATTRIBS)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- const VertexAttribute &attribState = context->getState().getVertexAttribState(index);
- if (!ValidateGetVertexAttribParameters(context, pname))
- {
- return;
- }
- if (pname == GL_CURRENT_VERTEX_ATTRIB)
- {
- const VertexAttribCurrentValueData ¤tValueData = context->getState().getVertexAttribCurrentValue(index);
- for (int i = 0; i < 4; ++i)
- {
- params[i] = currentValueData.UnsignedIntValues[i];
- }
- }
- else
- {
- *params = QuerySingleVertexAttributeParameter<GLuint>(attribState, pname);
- }
- }
- }
- void GL_APIENTRY VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
- {
- EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)",
- index, x, y, z, w);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- if (index >= MAX_VERTEX_ATTRIBS)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- GLint vals[4] = { x, y, z, w };
- context->getState().setVertexAttribi(index, vals);
- }
- }
- void GL_APIENTRY VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
- {
- EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)",
- index, x, y, z, w);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- if (index >= MAX_VERTEX_ATTRIBS)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- GLuint vals[4] = { x, y, z, w };
- context->getState().setVertexAttribu(index, vals);
- }
- }
- void GL_APIENTRY VertexAttribI4iv(GLuint index, const GLint* v)
- {
- EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- if (index >= MAX_VERTEX_ATTRIBS)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- context->getState().setVertexAttribi(index, v);
- }
- }
- void GL_APIENTRY VertexAttribI4uiv(GLuint index, const GLuint* v)
- {
- EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return;
- }
- if (index >= MAX_VERTEX_ATTRIBS)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return;
- }
- context->getState().setVertexAttribu(index, v);
- }
- }
- void GL_APIENTRY GetUniformuiv(GLuint program, GLint location, GLuint* params)
- {
- EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)",
- program, location, params);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (!ValidateGetUniformuiv(context, program, location, params))
- {
- return;
- }
- Program *programObject = context->getProgram(program);
- ASSERT(programObject);
- programObject->getUniformuiv(location, params);
- }
- }
- GLint GL_APIENTRY GetFragDataLocation(GLuint program, const GLchar *name)
- {
- EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)",
- program, name);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (context->getClientVersion() < 3)
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return -1;
- }
- if (program == 0)
- {
- context->recordError(Error(GL_INVALID_VALUE));
- return -1;
- }
- Program *programObject = context->getProgram(program);
- if (!programObject || !programObject->isLinked())
- {
- context->recordError(Error(GL_INVALID_OPERATION));
- return -1;
- }
- return programObject->getFragDataLocation(name);
- }
- return 0;
- }
- void GL_APIENTRY Uniform1ui(GLint location, GLuint v0)
- {
- Uniform1uiv(location, 1, &v0);
- }
- void GL_APIENTRY Uniform2ui(GLint location, GLuint v0, GLuint v1)
- {
- const GLuint xy[] = { v0, v1 };
- Uniform2uiv(location, 1, xy);
- }
- void GL_APIENTRY Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
- {
- const GLuint xyz[] = { v0, v1, v2 };
- Uniform3uiv(location, 1, xyz);
- }
- void GL_APIENTRY Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
- {
- const GLuint xyzw[] = { v0, v1, v2, v3 };
- Uniform4uiv(location, 1, xyzw);
- }
- void GL_APIENTRY Uniform1uiv(GLint location, GLsizei count, const GLuint* value)
- {
- EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
- location, count, value);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (!ValidateUniform(context, GL_UNSIGNED_INT, location, count))
- {
- return;
- }
- Program *program = context->getState().getProgram();
- program->setUniform1uiv(location, count, value);
- }
- }
- void GL_APIENTRY Uniform2uiv(GLint location, GLsizei count, const GLuint* value)
- {
- EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
- location, count, value);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC2, location, count))
- {
- return;
- }
- Program *program = context->getState().getProgram();
- program->setUniform2uiv(location, count, value);
- }
- }
- void GL_APIENTRY Uniform3uiv(GLint location, GLsizei count, const GLuint* value)
- {
- EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)",
- location, count, value);
- Context *context = GetValidGlobalContext();
- if (context)
- {
- if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC3, location, count))
- {…
Large files files are truncated, but you can click here to view the full file