summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/libANGLE/validationES2.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-07-11 23:29:50 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-07-11 23:31:02 +0200
commit70dd5e7c66b1fe3f82e5b4db2406050baba15f05 (patch)
tree3f012200ef3c934f33db1a4ef2b790fae3141860 /gfx/angle/src/libANGLE/validationES2.cpp
parent3b7ffb477eec078c7036c92c6a51bb5de6de4f28 (diff)
parent8481fa25d246f1968d0a254ee3c6cdd82c60781a (diff)
downloadUXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar
UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar.gz
UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar.lz
UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar.xz
UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.zip
Merge branch 'ANGLE-rollback'
This resolves #624 Note: Cherry-picked some fixes on top of the ANGLE version that we want to keep.
Diffstat (limited to 'gfx/angle/src/libANGLE/validationES2.cpp')
-rwxr-xr-xgfx/angle/src/libANGLE/validationES2.cpp686
1 files changed, 78 insertions, 608 deletions
diff --git a/gfx/angle/src/libANGLE/validationES2.cpp b/gfx/angle/src/libANGLE/validationES2.cpp
index 3133102f3..f68958cba 100755
--- a/gfx/angle/src/libANGLE/validationES2.cpp
+++ b/gfx/angle/src/libANGLE/validationES2.cpp
@@ -10,19 +10,19 @@
#include <cstdint>
-#include "common/mathutil.h"
-#include "common/string_utils.h"
-#include "common/utilities.h"
+#include "libANGLE/validationES.h"
+#include "libANGLE/validationES3.h"
#include "libANGLE/Context.h"
#include "libANGLE/Texture.h"
#include "libANGLE/Framebuffer.h"
-#include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/Renderbuffer.h"
-#include "libANGLE/Shader.h"
-#include "libANGLE/Uniform.h"
#include "libANGLE/formatutils.h"
-#include "libANGLE/validationES.h"
-#include "libANGLE/validationES3.h"
+#include "libANGLE/FramebufferAttachment.h"
+#include "libANGLE/Uniform.h"
+
+#include "common/mathutil.h"
+#include "common/string_utils.h"
+#include "common/utilities.h"
namespace gl
{
@@ -285,21 +285,9 @@ bool IsValidCopyTextureSourceTarget(Context *context, GLenum target)
} // anonymous namespace
-bool ValidateES2TexImageParameters(Context *context,
- GLenum target,
- GLint level,
- GLenum internalformat,
- bool isCompressed,
- bool isSubImage,
- GLint xoffset,
- GLint yoffset,
- GLsizei width,
- GLsizei height,
- GLint border,
- GLenum format,
- GLenum type,
- GLsizei imageSize,
- const GLvoid *pixels)
+bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, GLenum internalformat, bool isCompressed, bool isSubImage,
+ GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
+ GLint border, GLenum format, GLenum type, const GLvoid *pixels)
{
if (!ValidTexture2DDestinationTarget(context, target))
{
@@ -368,16 +356,10 @@ bool ValidateES2TexImageParameters(Context *context,
if (isSubImage)
{
- GLenum textureFormat = texture->getFormat(target, level).asSized();
- if (textureFormat == GL_NONE)
- {
- context->handleError(Error(GL_INVALID_OPERATION, "Texture level does not exist."));
- return false;
- }
-
if (format != GL_NONE)
{
- if (gl::GetSizedInternalFormat(format, type) != textureFormat)
+ if (gl::GetSizedInternalFormat(format, type) !=
+ texture->getFormat(target, level).asSized())
{
context->handleError(Error(GL_INVALID_OPERATION));
return false;
@@ -710,12 +692,6 @@ bool ValidateES2TexImageParameters(Context *context,
}
}
- if (!ValidImageDataSize(context, target, width, height, 1, internalformat, type, pixels,
- imageSize))
- {
- return false;
- }
-
return true;
}
@@ -1217,6 +1193,52 @@ bool ValidateES2TexStorageParameters(Context *context, GLenum target, GLsizei le
return true;
}
+// check for combinations of format and type that are valid for ReadPixels
+bool ValidES2ReadFormatType(ValidationContext *context, GLenum format, GLenum type)
+{
+ switch (format)
+ {
+ case GL_RGBA:
+ switch (type)
+ {
+ case GL_UNSIGNED_BYTE:
+ break;
+ default:
+ return false;
+ }
+ break;
+ case GL_BGRA_EXT:
+ switch (type)
+ {
+ case GL_UNSIGNED_BYTE:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
+ break;
+ default:
+ return false;
+ }
+ break;
+ case GL_RG_EXT:
+ case GL_RED_EXT:
+ if (!context->getExtensions().textureRG)
+ {
+ return false;
+ }
+ switch (type)
+ {
+ case GL_UNSIGNED_BYTE:
+ break;
+ default:
+ return false;
+ }
+ break;
+
+ default:
+ return false;
+ }
+ return true;
+}
+
bool ValidateDiscardFramebufferEXT(Context *context, GLenum target, GLsizei numAttachments,
const GLenum *attachments)
{
@@ -1992,43 +2014,12 @@ bool ValidateTexImage2D(Context *context,
if (context->getClientMajorVersion() < 3)
{
return ValidateES2TexImageParameters(context, target, level, internalformat, false, false,
- 0, 0, width, height, border, format, type, -1, pixels);
+ 0, 0, width, height, border, format, type, pixels);
}
ASSERT(context->getClientMajorVersion() >= 3);
return ValidateES3TexImage2DParameters(context, target, level, internalformat, false, false, 0,
- 0, 0, width, height, 1, border, format, type, -1,
- pixels);
-}
-
-bool ValidateTexImage2DRobust(Context *context,
- GLenum target,
- GLint level,
- GLint internalformat,
- GLsizei width,
- GLsizei height,
- GLint border,
- GLenum format,
- GLenum type,
- GLsizei bufSize,
- const GLvoid *pixels)
-{
- if (!ValidateRobustEntryPoint(context, bufSize))
- {
- return false;
- }
-
- if (context->getClientMajorVersion() < 3)
- {
- return ValidateES2TexImageParameters(context, target, level, internalformat, false, false,
- 0, 0, width, height, border, format, type, bufSize,
- pixels);
- }
-
- ASSERT(context->getClientMajorVersion() >= 3);
- return ValidateES3TexImage2DParameters(context, target, level, internalformat, false, false, 0,
- 0, 0, width, height, 1, border, format, type, bufSize,
- pixels);
+ 0, 0, width, height, 1, border, format, type, pixels);
}
bool ValidateTexSubImage2D(Context *context,
@@ -2046,43 +2037,12 @@ bool ValidateTexSubImage2D(Context *context,
if (context->getClientMajorVersion() < 3)
{
return ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true, xoffset,
- yoffset, width, height, 0, format, type, -1, pixels);
+ yoffset, width, height, 0, format, type, pixels);
}
ASSERT(context->getClientMajorVersion() >= 3);
return ValidateES3TexImage2DParameters(context, target, level, GL_NONE, false, true, xoffset,
- yoffset, 0, width, height, 1, 0, format, type, -1,
- pixels);
-}
-
-bool ValidateTexSubImage2DRobustANGLE(Context *context,
- GLenum target,
- GLint level,
- GLint xoffset,
- GLint yoffset,
- GLsizei width,
- GLsizei height,
- GLenum format,
- GLenum type,
- GLsizei bufSize,
- const GLvoid *pixels)
-{
- if (!ValidateRobustEntryPoint(context, bufSize))
- {
- return false;
- }
-
- if (context->getClientMajorVersion() < 3)
- {
- return ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true, xoffset,
- yoffset, width, height, 0, format, type, bufSize,
- pixels);
- }
-
- ASSERT(context->getClientMajorVersion() >= 3);
- return ValidateES3TexImage2DParameters(context, target, level, GL_NONE, false, true, xoffset,
- yoffset, 0, width, height, 1, 0, format, type, bufSize,
- pixels);
+ yoffset, 0, width, height, 1, 0, format, type, pixels);
}
bool ValidateCompressedTexImage2D(Context *context,
@@ -2098,7 +2058,7 @@ bool ValidateCompressedTexImage2D(Context *context,
if (context->getClientMajorVersion() < 3)
{
if (!ValidateES2TexImageParameters(context, target, level, internalformat, true, false, 0,
- 0, width, height, border, GL_NONE, GL_NONE, -1, data))
+ 0, width, height, border, GL_NONE, GL_NONE, data))
{
return false;
}
@@ -2107,7 +2067,7 @@ bool ValidateCompressedTexImage2D(Context *context,
{
ASSERT(context->getClientMajorVersion() >= 3);
if (!ValidateES3TexImage2DParameters(context, target, level, internalformat, true, false, 0,
- 0, 0, width, height, 1, border, GL_NONE, GL_NONE, -1,
+ 0, 0, width, height, 1, border, GL_NONE, GL_NONE,
data))
{
return false;
@@ -2116,7 +2076,7 @@ bool ValidateCompressedTexImage2D(Context *context,
const InternalFormat &formatInfo = GetInternalFormatInfo(internalformat);
auto blockSizeOrErr =
- formatInfo.computeCompressedImageSize(gl::Extents(width, height, 1));
+ formatInfo.computeCompressedImageSize(GL_UNSIGNED_BYTE, gl::Extents(width, height, 1));
if (blockSizeOrErr.isError())
{
context->handleError(blockSizeOrErr.getError());
@@ -2146,7 +2106,7 @@ bool ValidateCompressedTexSubImage2D(Context *context,
if (context->getClientMajorVersion() < 3)
{
if (!ValidateES2TexImageParameters(context, target, level, GL_NONE, true, true, xoffset,
- yoffset, width, height, 0, GL_NONE, GL_NONE, -1, data))
+ yoffset, width, height, 0, GL_NONE, GL_NONE, data))
{
return false;
}
@@ -2155,7 +2115,7 @@ bool ValidateCompressedTexSubImage2D(Context *context,
{
ASSERT(context->getClientMajorVersion() >= 3);
if (!ValidateES3TexImage2DParameters(context, target, level, GL_NONE, true, true, xoffset,
- yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE, -1,
+ yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE,
data))
{
return false;
@@ -2164,7 +2124,7 @@ bool ValidateCompressedTexSubImage2D(Context *context,
const InternalFormat &formatInfo = GetInternalFormatInfo(format);
auto blockSizeOrErr =
- formatInfo.computeCompressedImageSize(gl::Extents(width, height, 1));
+ formatInfo.computeCompressedImageSize(GL_UNSIGNED_BYTE, gl::Extents(width, height, 1));
if (blockSizeOrErr.isError())
{
context->handleError(blockSizeOrErr.getError());
@@ -2182,7 +2142,13 @@ bool ValidateCompressedTexSubImage2D(Context *context,
bool ValidateGetBufferPointervOES(Context *context, GLenum target, GLenum pname, void **params)
{
- return ValidateGetBufferPointervBase(context, target, pname, nullptr, params);
+ if (!context->getExtensions().mapBuffer)
+ {
+ context->handleError(Error(GL_INVALID_OPERATION, "Map buffer extension not available."));
+ return false;
+ }
+
+ return ValidateGetBufferPointervBase(context, target, pname, params);
}
bool ValidateMapBufferOES(Context *context, GLenum target, GLenum access)
@@ -2273,13 +2239,6 @@ bool ValidateBindTexture(Context *context, GLenum target, GLuint texture)
return false;
}
- if (!context->getGLState().isBindGeneratesResourceEnabled() &&
- !context->isTextureGenerated(texture))
- {
- context->handleError(Error(GL_INVALID_OPERATION, "Texture was not generated"));
- return false;
- }
-
switch (target)
{
case GL_TEXTURE_2D:
@@ -3356,68 +3315,6 @@ bool ValidateCopySubTextureCHROMIUM(Context *context,
return true;
}
-bool ValidateCompressedCopyTextureCHROMIUM(Context *context, GLuint sourceId, GLuint destId)
-{
- if (!context->getExtensions().copyCompressedTexture)
- {
- context->handleError(Error(GL_INVALID_OPERATION,
- "GL_CHROMIUM_copy_compressed_texture extension not available."));
- return false;
- }
-
- const gl::Texture *source = context->getTexture(sourceId);
- if (source == nullptr)
- {
- context->handleError(
- Error(GL_INVALID_VALUE, "Source texture is not a valid texture object."));
- return false;
- }
-
- if (source->getTarget() != GL_TEXTURE_2D)
- {
- context->handleError(
- Error(GL_INVALID_VALUE, "Source texture must be of type GL_TEXTURE_2D."));
- return false;
- }
-
- if (source->getWidth(GL_TEXTURE_2D, 0) == 0 || source->getHeight(GL_TEXTURE_2D, 0) == 0)
- {
- context->handleError(Error(GL_INVALID_VALUE, "Source texture must level 0 defined."));
- return false;
- }
-
- const gl::Format &sourceFormat = source->getFormat(GL_TEXTURE_2D, 0);
- if (!sourceFormat.info->compressed)
- {
- context->handleError(
- Error(GL_INVALID_OPERATION, "Source texture must have a compressed internal format."));
- return false;
- }
-
- const gl::Texture *dest = context->getTexture(destId);
- if (dest == nullptr)
- {
- context->handleError(
- Error(GL_INVALID_VALUE, "Destination texture is not a valid texture object."));
- return false;
- }
-
- if (dest->getTarget() != GL_TEXTURE_2D)
- {
- context->handleError(
- Error(GL_INVALID_VALUE, "Destination texture must be of type GL_TEXTURE_2D."));
- return false;
- }
-
- if (dest->getImmutableFormat())
- {
- context->handleError(Error(GL_INVALID_OPERATION, "Destination cannot be immutable."));
- return false;
- }
-
- return true;
-}
-
bool ValidateCreateShader(Context *context, GLenum type)
{
switch (type)
@@ -3425,442 +3322,15 @@ bool ValidateCreateShader(Context *context, GLenum type)
case GL_VERTEX_SHADER:
case GL_FRAGMENT_SHADER:
break;
-
case GL_COMPUTE_SHADER:
- if (context->getClientVersion() < Version(3, 1))
- {
- context->handleError(
- Error(GL_INVALID_ENUM, "GL_COMPUTE_SHADER requires OpenGL ES 3.1."));
- return false;
- }
- break;
-
- default:
- context->handleError(Error(GL_INVALID_ENUM, "Unknown shader type."));
- return false;
- }
-
- return true;
-}
-
-bool ValidateBufferData(ValidationContext *context,
- GLenum target,
- GLsizeiptr size,
- const GLvoid *data,
- GLenum usage)
-{
- if (size < 0)
- {
- context->handleError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- switch (usage)
- {
- case GL_STREAM_DRAW:
- case GL_STATIC_DRAW:
- case GL_DYNAMIC_DRAW:
- break;
-
- case GL_STREAM_READ:
- case GL_STREAM_COPY:
- case GL_STATIC_READ:
- case GL_STATIC_COPY:
- case GL_DYNAMIC_READ:
- case GL_DYNAMIC_COPY:
- if (context->getClientMajorVersion() < 3)
+ if (context->getGLVersion().isES31())
{
- context->handleError(Error(GL_INVALID_ENUM));
- return false;
+ break;
}
- break;
-
default:
context->handleError(Error(GL_INVALID_ENUM));
return false;
}
-
- if (!ValidBufferTarget(context, target))
- {
- context->handleError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- Buffer *buffer = context->getGLState().getTargetBuffer(target);
-
- if (!buffer)
- {
- context->handleError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- return true;
-}
-
-bool ValidateBufferSubData(ValidationContext *context,
- GLenum target,
- GLintptr offset,
- GLsizeiptr size,
- const GLvoid *data)
-{
- if (size < 0 || offset < 0)
- {
- context->handleError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- if (!ValidBufferTarget(context, target))
- {
- context->handleError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- Buffer *buffer = context->getGLState().getTargetBuffer(target);
-
- if (!buffer)
- {
- context->handleError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- if (buffer->isMapped())
- {
- context->handleError(Error(GL_INVALID_OPERATION));
- return false;
- }
-
- // Check for possible overflow of size + offset
- angle::CheckedNumeric<size_t> checkedSize(size);
- checkedSize += offset;
- if (!checkedSize.IsValid())
- {
- context->handleError(Error(GL_OUT_OF_MEMORY));
- return false;
- }
-
- if (size + offset > buffer->getSize())
- {
- context->handleError(Error(GL_INVALID_VALUE));
- return false;
- }
-
- return true;
-}
-
-bool ValidateEnableExtensionANGLE(ValidationContext *context, const GLchar *name)
-{
- if (!context->getExtensions().webglCompatibility)
- {
- context->handleError(
- Error(GL_INVALID_OPERATION, "GL_ANGLE_webgl_compatibility is not available."));
- return false;
- }
-
- const ExtensionInfoMap &extensionInfos = GetExtensionInfoMap();
- auto extension = extensionInfos.find(name);
- if (extension == extensionInfos.end() || !extension->second.Enableable)
- {
- context->handleError(Error(GL_INVALID_OPERATION, "Extension %s is not enableable.", name));
- return false;
- }
-
- return true;
-}
-
-bool ValidateActiveTexture(ValidationContext *context, GLenum texture)
-{
- if (texture < GL_TEXTURE0 ||
- texture > GL_TEXTURE0 + context->getCaps().maxCombinedTextureImageUnits - 1)
- {
- context->handleError(Error(GL_INVALID_ENUM));
- return false;
- }
-
- return true;
-}
-
-bool ValidateAttachShader(ValidationContext *context, GLuint program, GLuint shader)
-{
- Program *programObject = GetValidProgram(context, program);
- if (!programObject)
- {
- return false;
- }
-
- Shader *shaderObject = GetValidShader(context, shader);
- if (!shaderObject)
- {
- return false;
- }
-
- switch (shaderObject->getType())
- {
- case GL_VERTEX_SHADER:
- {
- if (programObject->getAttachedVertexShader())
- {
- context->handleError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- }
- case GL_FRAGMENT_SHADER:
- {
- if (programObject->getAttachedFragmentShader())
- {
- context->handleError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- }
- case GL_COMPUTE_SHADER:
- {
- if (programObject->getAttachedComputeShader())
- {
- context->handleError(Error(GL_INVALID_OPERATION));
- return false;
- }
- break;
- }
- default:
- UNREACHABLE();
- break;
- }
-
- return true;
-}
-
-bool ValidateBindAttribLocation(ValidationContext *context,
- GLuint program,
- GLuint index,
- const GLchar *name)
-{
- if (index >= MAX_VERTEX_ATTRIBS)
- {
- context->handleError(Error(GL_INVALID_VALUE, "Index exceeds MAX_VERTEX_ATTRIBS"));
- return false;
- }
-
- if (strncmp(name, "gl_", 3) == 0)
- {
- context->handleError(Error(GL_INVALID_OPERATION, "Cannot Bind built-in attributes"));
- return false;
- }
-
- return GetValidProgram(context, program) != nullptr;
-}
-
-bool ValidateBindBuffer(ValidationContext *context, GLenum target, GLuint buffer)
-{
- if (!ValidBufferTarget(context, target))
- {
- context->handleError(Error(GL_INVALID_ENUM, "Invalid Buffer target"));
- return false;
- }
-
- if (!context->getGLState().isBindGeneratesResourceEnabled() &&
- !context->isBufferGenerated(buffer))
- {
- context->handleError(Error(GL_INVALID_OPERATION, "Buffer was not generated"));
- return false;
- }
-
- return true;
-}
-
-bool ValidateBindFramebuffer(ValidationContext *context, GLenum target, GLuint framebuffer)
-{
- if (!ValidFramebufferTarget(target))
- {
- context->handleError(Error(GL_INVALID_ENUM, "Invalid Framebuffer target"));
- return false;
- }
-
- if (!context->getGLState().isBindGeneratesResourceEnabled() &&
- !context->isFramebufferGenerated(framebuffer))
- {
- context->handleError(Error(GL_INVALID_OPERATION, "Framebuffer was not generated"));
- return false;
- }
-
- return true;
-}
-
-bool ValidateBindRenderbuffer(ValidationContext *context, GLenum target, GLuint renderbuffer)
-{
- if (target != GL_RENDERBUFFER)
- {
- context->handleError(Error(GL_INVALID_ENUM, "Invalid Renderbuffer target"));
- return false;
- }
-
- if (!context->getGLState().isBindGeneratesResourceEnabled() &&
- !context->isRenderbufferGenerated(renderbuffer))
- {
- context->handleError(Error(GL_INVALID_OPERATION, "Renderbuffer was not generated"));
- return false;
- }
-
- return true;
-}
-
-static bool ValidBlendEquationMode(GLenum mode)
-{
- switch (mode)
- {
- case GL_FUNC_ADD:
- case GL_FUNC_SUBTRACT:
- case GL_FUNC_REVERSE_SUBTRACT:
- case GL_MIN:
- case GL_MAX:
- return true;
-
- default:
- return false;
- }
-}
-
-bool ValidateBlendEquation(ValidationContext *context, GLenum mode)
-{
- if (!ValidBlendEquationMode(mode))
- {
- context->handleError(Error(GL_INVALID_ENUM, "Invalid blend equation"));
- return false;
- }
-
- return true;
-}
-
-bool ValidateBlendEquationSeparate(ValidationContext *context, GLenum modeRGB, GLenum modeAlpha)
-{
- if (!ValidBlendEquationMode(modeRGB))
- {
- context->handleError(Error(GL_INVALID_ENUM, "Invalid RGB blend equation"));
- return false;
- }
-
- if (!ValidBlendEquationMode(modeAlpha))
- {
- context->handleError(Error(GL_INVALID_ENUM, "Invalid alpha blend equation"));
- return false;
- }
-
- return true;
-}
-
-bool ValidateBlendFunc(ValidationContext *context, GLenum sfactor, GLenum dfactor)
-{
- return ValidateBlendFuncSeparate(context, sfactor, dfactor, sfactor, dfactor);
-}
-
-static bool ValidSrcBlendFunc(GLenum srcBlend)
-{
- switch (srcBlend)
- {
- case GL_ZERO:
- case GL_ONE:
- case GL_SRC_COLOR:
- case GL_ONE_MINUS_SRC_COLOR:
- case GL_DST_COLOR:
- case GL_ONE_MINUS_DST_COLOR:
- case GL_SRC_ALPHA:
- case GL_ONE_MINUS_SRC_ALPHA:
- case GL_DST_ALPHA:
- case GL_ONE_MINUS_DST_ALPHA:
- case GL_CONSTANT_COLOR:
- case GL_ONE_MINUS_CONSTANT_COLOR:
- case GL_CONSTANT_ALPHA:
- case GL_ONE_MINUS_CONSTANT_ALPHA:
- case GL_SRC_ALPHA_SATURATE:
- return true;
-
- default:
- return false;
- }
-}
-
-static bool ValidDstBlendFunc(GLenum dstBlend, GLint contextMajorVersion)
-{
- switch (dstBlend)
- {
- case GL_ZERO:
- case GL_ONE:
- case GL_SRC_COLOR:
- case GL_ONE_MINUS_SRC_COLOR:
- case GL_DST_COLOR:
- case GL_ONE_MINUS_DST_COLOR:
- case GL_SRC_ALPHA:
- case GL_ONE_MINUS_SRC_ALPHA:
- case GL_DST_ALPHA:
- case GL_ONE_MINUS_DST_ALPHA:
- case GL_CONSTANT_COLOR:
- case GL_ONE_MINUS_CONSTANT_COLOR:
- case GL_CONSTANT_ALPHA:
- case GL_ONE_MINUS_CONSTANT_ALPHA:
- return true;
-
- case GL_SRC_ALPHA_SATURATE:
- return (contextMajorVersion >= 3);
-
- default:
- return false;
- }
-}
-
-bool ValidateBlendFuncSeparate(ValidationContext *context,
- GLenum srcRGB,
- GLenum dstRGB,
- GLenum srcAlpha,
- GLenum dstAlpha)
-{
- if (!ValidSrcBlendFunc(srcRGB))
- {
- context->handleError(Error(GL_INVALID_ENUM, "Invalid blend function"));
- return false;
- }
-
- if (!ValidDstBlendFunc(dstRGB, context->getClientMajorVersion()))
- {
- context->handleError(Error(GL_INVALID_ENUM, "Invalid blend function"));
- return false;
- }
-
- if (!ValidSrcBlendFunc(srcAlpha))
- {
- context->handleError(Error(GL_INVALID_ENUM, "Invalid blend function"));
- return false;
- }
-
- if (!ValidDstBlendFunc(dstAlpha, context->getClientMajorVersion()))
- {
- context->handleError(Error(GL_INVALID_ENUM, "Invalid blend function"));
- return false;
- }
-
- if (context->getLimitations().noSimultaneousConstantColorAndAlphaBlendFunc)
- {
- bool constantColorUsed =
- (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR ||
- dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR);
-
- bool constantAlphaUsed =
- (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA ||
- dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA);
-
- if (constantColorUsed && constantAlphaUsed)
- {
- ERR("Simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and "
- "GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR not supported by this "
- "implementation.");
- context->handleError(Error(GL_INVALID_OPERATION,
- "Simultaneous use of "
- "GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and "
- "GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR not "
- "supported by this implementation."));
- return false;
- }
- }
-
return true;
}