// // Copyright 2016 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. //
// validationEGL.cpp: Validation functions for generic EGL entry point parameters
int maxDimension = 0; switch (type)
{ case gl::TextureType::_2D: case gl::TextureType::_2DArray: case gl::TextureType::_2DMultisample:
maxDimension = caps.max2DTextureSize; break; case gl::TextureType::Rectangle:
maxDimension = caps.maxRectangleTextureSize; break; case gl::TextureType::CubeMap:
maxDimension = caps.maxCubeMapTextureSize; break; case gl::TextureType::_3D:
maxDimension = caps.max3DTextureSize; break;
default:
UNREACHABLE();
}
return gl::log2(maxDimension);
}
bool TextureHasNonZeroMipLevelsSpecified(const gl::Context *context, const gl::Texture *texture)
{
size_t maxMip = GetMaximumMipLevel(context, texture->getType()); for (size_t level = 1; level < maxMip; level++)
{ if (texture->getType() == gl::TextureType::CubeMap)
{ for (gl::TextureTarget face : gl::AllCubeFaceTextureTargets())
{ if (texture->getFormat(face, level).valid())
{ returntrue;
}
}
} else
{ if (texture->getFormat(gl::NonCubeTextureTypeToTarget(texture->getType()), level)
.valid())
{ returntrue;
}
}
}
returnfalse;
}
bool CubeTextureHasUnspecifiedLevel0Face(const gl::Texture *texture)
{
ASSERT(texture->getType() == gl::TextureType::CubeMap); for (gl::TextureTarget face : gl::AllCubeFaceTextureTargets())
{ if (!texture->getFormat(face, 0).valid())
{ returntrue;
}
}
returnfalse;
}
bool ValidateStreamAttribute(const ValidationContext *val, const EGLAttrib attribute, const EGLAttrib value, const DisplayExtensions &extensions)
{ switch (attribute)
{ case EGL_STREAM_STATE_KHR: case EGL_PRODUCER_FRAME_KHR: case EGL_CONSUMER_FRAME_KHR:
val->setError(EGL_BAD_ACCESS, "Attempt to initialize readonly parameter"); returnfalse; case EGL_CONSUMER_LATENCY_USEC_KHR: // Technically not in spec but a latency < 0 makes no sense so we check it if (value < 0)
{
val->setError(EGL_BAD_PARAMETER, "Latency must be positive"); returnfalse;
} break; case EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR: if (!extensions.streamConsumerGLTexture)
{
val->setError(EGL_BAD_ATTRIBUTE, "Consumer GL extension not enabled"); returnfalse;
} // Again not in spec but it should be positive anyways if (value < 0)
{
val->setError(EGL_BAD_PARAMETER, "Timeout must be positive"); returnfalse;
} break; default:
val->setError(EGL_BAD_ATTRIBUTE, "Invalid stream attribute"); returnfalse;
} returntrue;
}
bool ValidateCreateImageMipLevelCommon(const ValidationContext *val, const gl::Context *context, const gl::Texture *texture,
EGLAttrib level)
{ // Note that the spec EGL_create_image spec does not explicitly specify an error // when the level is outside the base/max level range, but it does mention that the // level "must be a part of the complete texture object <buffer>". It can be argued // that out-of-range levels are not a part of the complete texture. const GLuint effectiveBaseLevel = texture->getTextureState().getEffectiveBaseLevel(); if (level > 0 &&
(!texture->isMipmapComplete() || static_cast<GLuint>(level) < effectiveBaseLevel || static_cast<GLuint>(level) > texture->getTextureState().getMipmapMaxLevel()))
{
val->setError(EGL_BAD_PARAMETER, "texture must be complete if level is non-zero."); returnfalse;
}
if (level == 0 && !texture->isMipmapComplete() &&
TextureHasNonZeroMipLevelsSpecified(context, texture))
{
val->setError(EGL_BAD_PARAMETER, "if level is zero and the texture is incomplete, it must " "have no mip levels specified except zero."); returnfalse;
}
returntrue;
}
bool ValidateConfigAttribute(const ValidationContext *val, const Display *display,
EGLAttrib attribute)
{ switch (attribute)
{ case EGL_BUFFER_SIZE: case EGL_ALPHA_SIZE: case EGL_BLUE_SIZE: case EGL_GREEN_SIZE: case EGL_RED_SIZE: case EGL_DEPTH_SIZE: case EGL_STENCIL_SIZE: case EGL_CONFIG_CAVEAT: case EGL_CONFIG_ID: case EGL_LEVEL: case EGL_NATIVE_RENDERABLE: case EGL_NATIVE_VISUAL_ID: case EGL_NATIVE_VISUAL_TYPE: case EGL_SAMPLES: case EGL_SAMPLE_BUFFERS: case EGL_SURFACE_TYPE: case EGL_TRANSPARENT_TYPE: case EGL_TRANSPARENT_BLUE_VALUE: case EGL_TRANSPARENT_GREEN_VALUE: case EGL_TRANSPARENT_RED_VALUE: case EGL_BIND_TO_TEXTURE_RGB: case EGL_BIND_TO_TEXTURE_RGBA: case EGL_MIN_SWAP_INTERVAL: case EGL_MAX_SWAP_INTERVAL: case EGL_LUMINANCE_SIZE: case EGL_ALPHA_MASK_SIZE: case EGL_COLOR_BUFFER_TYPE: case EGL_RENDERABLE_TYPE: case EGL_MATCH_NATIVE_PIXMAP: case EGL_CONFORMANT: case EGL_MAX_PBUFFER_WIDTH: case EGL_MAX_PBUFFER_HEIGHT: case EGL_MAX_PBUFFER_PIXELS: break;
case EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE: if (!display->getExtensions().surfaceOrientation)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_ANGLE_surface_orientation is not enabled."); returnfalse;
} break;
case EGL_COLOR_COMPONENT_TYPE_EXT: if (!display->getExtensions().pixelFormatFloat)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_EXT_pixel_format_float is not enabled."); returnfalse;
} break;
case EGL_RECORDABLE_ANDROID: if (!display->getExtensions().recordable)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_ANDROID_recordable is not enabled."); returnfalse;
} break;
case EGL_FRAMEBUFFER_TARGET_ANDROID: if (!display->getExtensions().framebufferTargetANDROID)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_ANDROID_framebuffer_target is not enabled."); returnfalse;
} break;
case EGL_BIND_TO_TEXTURE_TARGET_ANGLE: if (!display->getExtensions().iosurfaceClientBuffer)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_ANGLE_iosurface_client_buffer is not enabled."); returnfalse;
} break;
case EGL_Y_INVERTED_NOK: if (!display->getExtensions().textureFromPixmapNOK)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_NOK_texture_from_pixmap is not enabled."); returnfalse;
} break;
case EGL_MATCH_FORMAT_KHR: if (!display->getExtensions().lockSurface3KHR)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_KHR_lock_surface3 is not enabled."); returnfalse;
} break;
case EGL_BIND_TO_TEXTURE_RGB: case EGL_BIND_TO_TEXTURE_RGBA: switch (value)
{ case EGL_DONT_CARE: case EGL_TRUE: case EGL_FALSE: break; default:
val->setError(EGL_BAD_ATTRIBUTE, "EGL_bind_to_texture invalid attribute: 0x%X", static_cast<uint32_t>(value)); returnfalse;
} break;
case EGL_COLOR_BUFFER_TYPE: switch (value)
{ case EGL_RGB_BUFFER: case EGL_LUMINANCE_BUFFER: // EGL_DONT_CARE doesn't match the spec, but does match dEQP usage case EGL_DONT_CARE: break; default:
val->setError(EGL_BAD_ATTRIBUTE, "EGL_color_buffer_type invalid attribute: 0x%X", static_cast<uint32_t>(value)); returnfalse;
} break;
case EGL_NATIVE_RENDERABLE: switch (value)
{ case EGL_DONT_CARE: case EGL_TRUE: case EGL_FALSE: break; default:
val->setError(EGL_BAD_ATTRIBUTE, "EGL_native_renderable invalid attribute: 0x%X", static_cast<uint32_t>(value)); returnfalse;
} break;
case EGL_TRANSPARENT_TYPE: switch (value)
{ case EGL_NONE: case EGL_TRANSPARENT_RGB: // EGL_DONT_CARE doesn't match the spec, but does match dEQP usage case EGL_DONT_CARE: break; default:
val->setError(EGL_BAD_ATTRIBUTE, "EGL_transparent_type invalid attribute: 0x%X", static_cast<uint32_t>(value)); returnfalse;
} break;
case EGL_RECORDABLE_ANDROID: switch (value)
{ case EGL_TRUE: case EGL_FALSE: case EGL_DONT_CARE: break; default:
val->setError(EGL_BAD_ATTRIBUTE, "EGL_RECORDABLE_ANDROID invalid attribute: 0x%X", static_cast<uint32_t>(value)); returnfalse;
} break;
case EGL_COLOR_COMPONENT_TYPE_EXT: switch (value)
{ case EGL_COLOR_COMPONENT_TYPE_FIXED_EXT: case EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT: case EGL_DONT_CARE: break; default:
val->setError(EGL_BAD_ATTRIBUTE, "EGL_COLOR_COMPONENT_TYPE_EXT invalid attribute: 0x%X", static_cast<uint32_t>(value)); returnfalse;
} break;
case EGL_MATCH_FORMAT_KHR: switch (value)
{ case EGL_FORMAT_RGB_565_KHR: case EGL_FORMAT_RGBA_8888_KHR: case EGL_FORMAT_RGB_565_EXACT_KHR: case EGL_FORMAT_RGBA_8888_EXACT_KHR: break; default:
val->setError(EGL_BAD_ATTRIBUTE, "EGL_KHR_lock_surface3 invalid attribute: 0x%X", static_cast<uint32_t>(value)); returnfalse;
} break;
for (constauto &attrib : attributes)
{
EGLAttrib pname = attrib.first;
EGLAttrib value = attrib.second;
ANGLE_VALIDATION_TRY(ValidateConfigAttributeValue(val, display, pname, value));
}
returntrue;
}
bool ValidateColorspaceAttribute(const ValidationContext *val, const DisplayExtensions &displayExtensions,
EGLAttrib colorSpace)
{ switch (colorSpace)
{ case EGL_GL_COLORSPACE_SRGB: break; case EGL_GL_COLORSPACE_LINEAR: break; case EGL_GL_COLORSPACE_DISPLAY_P3_LINEAR_EXT: if (!displayExtensions.glColorspaceDisplayP3Linear &&
!displayExtensions.eglColorspaceAttributePassthroughANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EXT_gl_colorspace_display_p3_linear is not available."); returnfalse;
} break; case EGL_GL_COLORSPACE_DISPLAY_P3_EXT: if (!displayExtensions.glColorspaceDisplayP3 &&
!displayExtensions.eglColorspaceAttributePassthroughANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EXT_gl_colorspace_display_p3 is not available."); returnfalse;
} break; case EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT: if (!displayExtensions.glColorspaceDisplayP3Passthrough &&
!displayExtensions.eglColorspaceAttributePassthroughANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_EXT_gl_colorspace_display_p3_passthrough is not available."); returnfalse;
} break; case EGL_GL_COLORSPACE_SCRGB_EXT: if (!displayExtensions.glColorspaceScrgb &&
!displayExtensions.eglColorspaceAttributePassthroughANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EXT_gl_colorspace_scrgb is not available."); returnfalse;
} break; case EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT: if (!displayExtensions.glColorspaceScrgbLinear &&
!displayExtensions.eglColorspaceAttributePassthroughANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EXT_gl_colorspace_scrgb_linear is not available."); returnfalse;
} break; default:
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} returntrue;
} bool ValidatePlatformType(const ValidationContext *val, const ClientExtensions &clientExtensions,
EGLAttrib platformType)
{ switch (platformType)
{ case EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE: break;
case EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE: case EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE: if (!clientExtensions.platformANGLED3D)
{
val->setError(EGL_BAD_ATTRIBUTE, "Direct3D platform is unsupported."); returnfalse;
} break;
case EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE: case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE: if (!clientExtensions.platformANGLEOpenGL)
{
val->setError(EGL_BAD_ATTRIBUTE, "OpenGL platform is unsupported."); returnfalse;
} break;
case EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE: if (!clientExtensions.platformANGLENULL)
{
val->setError(EGL_BAD_ATTRIBUTE, "Display type EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE " "requires EGL_ANGLE_platform_angle_null."); returnfalse;
} break;
case EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE: if (!clientExtensions.platformANGLEVulkan)
{
val->setError(EGL_BAD_ATTRIBUTE, "Vulkan platform is unsupported."); returnfalse;
} break;
case EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE: if (!clientExtensions.platformANGLEMetal)
{
val->setError(EGL_BAD_ATTRIBUTE, "Metal platform is unsupported."); returnfalse;
} break;
switch (platform)
{ case EGL_PLATFORM_ANGLE_ANGLE: if (!clientExtensions.platformANGLE)
{
val->setError(EGL_BAD_PARAMETER, "Platform ANGLE extension is not active"); returnfalse;
} break; case EGL_PLATFORM_DEVICE_EXT: if (!clientExtensions.platformDevice)
{
val->setError(EGL_BAD_PARAMETER, "Platform Device extension is not active"); returnfalse;
} break; case EGL_PLATFORM_GBM_KHR: if (!clientExtensions.platformGbmKHR)
{
val->setError(EGL_BAD_PARAMETER, "Platform GBM extension is not active"); returnfalse;
} break; case EGL_PLATFORM_WAYLAND_EXT: if (!clientExtensions.platformWaylandEXT)
{
val->setError(EGL_BAD_PARAMETER, "Platform Wayland extension is not active"); returnfalse;
} break; default:
val->setError(EGL_BAD_CONFIG, "Bad platform type."); returnfalse;
}
case EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE: if (value != EGL_DONT_CARE)
{
majorVersion = value;
} break;
case EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE: if (value != EGL_DONT_CARE)
{
minorVersion = value;
} break;
case EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE: switch (value)
{ case EGL_TRUE: case EGL_FALSE: break; default:
val->setError(EGL_BAD_ATTRIBUTE, "Invalid automatic trim attribute"); returnfalse;
}
enableAutoTrimSpecified = true; break;
case EGL_PLATFORM_ANGLE_D3D11ON12_ANGLE: if (!clientExtensions.platformANGLED3D ||
!clientExtensions.platformANGLED3D11ON12)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_PLATFORM_ANGLE_D3D11ON12_ANGLE extension not active."); returnfalse;
}
switch (value)
{ case EGL_TRUE: case EGL_FALSE: break; default:
val->setError(EGL_BAD_ATTRIBUTE, "Invalid D3D11on12 attribute"); returnfalse;
}
enableD3D11on12 = true; break;
case EGL_EXPERIMENTAL_PRESENT_PATH_ANGLE: if (!clientExtensions.experimentalPresentPath)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_ANGLE_experimental_present_path extension not active"); returnfalse;
}
switch (value)
{ case EGL_EXPERIMENTAL_PRESENT_PATH_FAST_ANGLE: case EGL_EXPERIMENTAL_PRESENT_PATH_COPY_ANGLE: break; default:
val->setError(EGL_BAD_ATTRIBUTE, "Invalid value for EGL_EXPERIMENTAL_PRESENT_PATH_ANGLE"); returnfalse;
}
presentPathSpecified = true; break;
case EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE: switch (value)
{ case EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE: case EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE: break;
case EGL_PLATFORM_ANGLE_DEVICE_TYPE_D3D_WARP_ANGLE: case EGL_PLATFORM_ANGLE_DEVICE_TYPE_D3D_REFERENCE_ANGLE: if (!clientExtensions.platformANGLED3D)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_ANGLE_platform_angle_d3d is not supported"); returnfalse;
} break;
case EGL_PLATFORM_ANGLE_DEVICE_TYPE_EGL_ANGLE: if (!clientExtensions.platformANGLEDeviceTypeEGLANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_ANGLE_platform_angle_device_type_" "egl_angle is not supported"); returnfalse;
} break;
case EGL_PLATFORM_ANGLE_DEVICE_TYPE_SWIFTSHADER_ANGLE: if (!clientExtensions.platformANGLEDeviceTypeSwiftShader)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_ANGLE_platform_angle_device_type_" "swiftshader is not supported"); returnfalse;
} break;
default:
val->setError(EGL_BAD_ATTRIBUTE, "Invalid value for " "EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE " "attrib"); returnfalse;
}
deviceType = value; break;
case EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED_ANGLE: if (!clientExtensions.platformANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_ANGLE_platform_angle extension not active"); returnfalse;
} if (value != EGL_TRUE && value != EGL_FALSE && value != EGL_DONT_CARE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED_ANGLE " "must be EGL_TRUE, EGL_FALSE, or " "EGL_DONT_CARE."); returnfalse;
} break;
case EGL_PLATFORM_ANGLE_EGL_HANDLE_ANGLE: if (value != EGL_DONT_CARE)
{
eglHandle = value;
} break;
case EGL_PLATFORM_ANGLE_D3D_LUID_HIGH_ANGLE: case EGL_PLATFORM_ANGLE_D3D_LUID_LOW_ANGLE:
luidSpecified = true; break; case EGL_PLATFORM_ANGLE_DEVICE_CONTEXT_VOLATILE_EAGL_ANGLE: // The property does not have an effect if it's not active, so do not check // for non-support. switch (value)
{ case EGL_FALSE: case EGL_TRUE: break; default:
val->setError(EGL_BAD_ATTRIBUTE, "Invalid value for " "EGL_PLATFORM_ANGLE_DEVICE_CONTEXT_VOLATILE_" "EAGL_ANGLE attrib"); returnfalse;
} break; case EGL_PLATFORM_ANGLE_DEVICE_CONTEXT_VOLATILE_CGL_ANGLE: // The property does not have an effect if it's not active, so do not check // for non-support. switch (value)
{ case EGL_FALSE: case EGL_TRUE: break; default:
val->setError(EGL_BAD_ATTRIBUTE, "Invalid value for " "EGL_PLATFORM_ANGLE_DEVICE_CONTEXT_VOLATILE_" "CGL_ANGLE attrib"); returnfalse;
} break; case EGL_PLATFORM_ANGLE_DEVICE_ID_HIGH_ANGLE: case EGL_PLATFORM_ANGLE_DEVICE_ID_LOW_ANGLE: if (!clientExtensions.platformANGLEDeviceId)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_ANGLE_platform_angle_device_id is not supported"); returnfalse;
}
deviceIdSpecified = true; break; default: break;
}
}
if (!majorVersion.valid() && minorVersion.valid())
{
val->setError(EGL_BAD_ATTRIBUTE, "Must specify major version if you specify a minor version."); returnfalse;
}
if (deviceType == EGL_PLATFORM_ANGLE_DEVICE_TYPE_D3D_WARP_ANGLE &&
platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE requires a " "device type of EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE."); returnfalse;
}
if (enableAutoTrimSpecified && platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE " "requires a device type of " "EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE."); returnfalse;
}
if (enableD3D11on12)
{ if (platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_PLATFORM_ANGLE_D3D11ON12_ANGLE " "requires a platform type of " "EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE."); returnfalse;
}
if (deviceType.valid() && deviceType != EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE &&
deviceType != EGL_PLATFORM_ANGLE_DEVICE_TYPE_D3D_WARP_ANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_PLATFORM_ANGLE_D3D11ON12_ANGLE requires a device " "type of EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE " "or EGL_PLATFORM_ANGLE_DEVICE_TYPE_D3D_WARP_ANGLE"); returnfalse;
}
}
if (presentPathSpecified && platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_EXPERIMENTAL_PRESENT_PATH_ANGLE requires a " "device type of EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE."); returnfalse;
}
if (luidSpecified)
{ if (platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_PLATFORM_ANGLE_D3D_LUID_HIGH_ANGLE and " "EGL_PLATFORM_ANGLE_D3D_LUID_LOW_ANGLE " "require a platform type of " "EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE."); returnfalse;
}
if (attribMap.get(EGL_PLATFORM_ANGLE_D3D_LUID_HIGH_ANGLE, 0) == 0 &&
attribMap.get(EGL_PLATFORM_ANGLE_D3D_LUID_LOW_ANGLE, 0) == 0)
{
val->setError(EGL_BAD_ATTRIBUTE, "If either EGL_PLATFORM_ANGLE_D3D_LUID_HIGH_ANGLE " "and/or EGL_PLATFORM_ANGLE_D3D_LUID_LOW_ANGLE are " "specified, at least one must non-zero."); returnfalse;
}
}
if (deviceIdSpecified)
{ if (attribMap.get(EGL_PLATFORM_ANGLE_DEVICE_ID_HIGH_ANGLE, 0) == 0 &&
attribMap.get(EGL_PLATFORM_ANGLE_DEVICE_ID_LOW_ANGLE, 0) == 0)
{
val->setError(EGL_BAD_ATTRIBUTE, "If either EGL_PLATFORM_ANGLE_DEVICE_ID_HIGH_ANGLE " "and/or EGL_PLATFORM_ANGLE_DEVICE_ID_LOW_ANGLE are " "specified, at least one must non-zero."); returnfalse;
}
}
if (deviceType.valid())
{ switch (deviceType.value())
{ case EGL_PLATFORM_ANGLE_DEVICE_TYPE_D3D_REFERENCE_ANGLE: case EGL_PLATFORM_ANGLE_DEVICE_TYPE_D3D_WARP_ANGLE: if (platformType != EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE &&
platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "This device type requires a " "platform type of EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE or " "EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE."); returnfalse;
} break;
case EGL_PLATFORM_ANGLE_DEVICE_TYPE_SWIFTSHADER_ANGLE: if (platformType != EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "This device type requires a " "platform type of EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE."); returnfalse;
} break;
default: break;
}
}
if (platformType == EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE)
{ if ((majorVersion.valid() && majorVersion.value() != 1) ||
(minorVersion.valid() && minorVersion.value() != 0))
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE currently " "only supports Vulkan 1.0."); returnfalse;
}
}
if (eglHandle.valid() && platformType != EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE &&
platformType != EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_PLATFORM_ANGLE_EGL_HANDLE_ANGLE requires a " "device type of EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE."); returnfalse;
}
} else
{ const Device *eglDevice = static_cast<const Device *>(native_display); if (eglDevice == nullptr || !Device::IsValidDevice(eglDevice))
{
val->setError(EGL_BAD_ATTRIBUTE, "native_display should be a valid EGL device if " "platform equals EGL_PLATFORM_DEVICE_EXT"); returnfalse;
}
}
if (attribMap.contains(EGL_POWER_PREFERENCE_ANGLE))
{ if (!clientExtensions.displayPowerPreferenceANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute EGL_POWER_PREFERENCE_ANGLE " "requires EGL_ANGLE_display_power_preference."); returnfalse;
}
EGLAttrib value = attribMap.get(EGL_POWER_PREFERENCE_ANGLE, 0); if (value != EGL_LOW_POWER_ANGLE && value != EGL_HIGH_POWER_ANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_POWER_PREFERENCE_ANGLE must be " "either EGL_LOW_POWER_ANGLE or EGL_HIGH_POWER_ANGLE."); returnfalse;
}
}
if (attribMap.contains(EGL_FEATURE_OVERRIDES_ENABLED_ANGLE))
{ if (!clientExtensions.featureControlANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_ANGLE_feature_control is not supported"); returnfalse;
} elseif (attribMap.get(EGL_FEATURE_OVERRIDES_ENABLED_ANGLE, 0) == 0)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_FEATURE_OVERRIDES_ENABLED_ANGLE must be a valid pointer"); returnfalse;
}
} if (attribMap.contains(EGL_FEATURE_OVERRIDES_DISABLED_ANGLE))
{ if (!clientExtensions.featureControlANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_ANGLE_feature_control is not supported"); returnfalse;
} elseif (attribMap.get(EGL_FEATURE_OVERRIDES_DISABLED_ANGLE, 0) == 0)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_FEATURE_OVERRIDES_DISABLED_ANGLE must be a valid pointer"); returnfalse;
}
}
case ObjectType::Display:
{
ANGLE_VALIDATION_TRY(ValidateDisplay(val, display)); if (display != object)
{ if (val)
{
val->setError(EGL_BAD_PARAMETER, "when object type is EGL_OBJECT_DISPLAY_KHR, the " "object must be the same as the display.");
} returnfalse;
}
// This is a common sub-check of Display status that's shared by multiple functions bool ValidateDisplayPointer(const ValidationContext *val, const Display *display)
{ if (display == EGL_NO_DISPLAY)
{ if (val)
{
val->setError(EGL_BAD_DISPLAY, "display is EGL_NO_DISPLAY.");
} returnfalse;
}
if (!Display::isValidDisplay(display))
{ if (val)
{
val->setError(EGL_BAD_DISPLAY, "display is not a valid display: 0x%p", display);
} returnfalse;
}
returntrue;
}
bool ValidCompositorTimingName(CompositorTiming name)
{ switch (name)
{ case CompositorTiming::CompositeDeadline: case CompositorTiming::CompositInterval: case CompositorTiming::CompositToPresentLatency: returntrue;
default: returnfalse;
}
}
bool ValidTimestampType(Timestamp timestamp)
{ switch (timestamp)
{ case Timestamp::RequestedPresentTime: case Timestamp::RenderingCompleteTime: case Timestamp::CompositionLatchTime: case Timestamp::FirstCompositionStartTime: case Timestamp::LastCompositionStartTime: case Timestamp::FirstCompositionGPUFinishedTime: case Timestamp::DisplayPresentTime: case Timestamp::DequeueReadyTime: case Timestamp::ReadsDoneTime: returntrue;
if (context->getClientType() != EGL_OPENGL_API)
{ // Surface compatible with client API - only OPENGL_ES supported switch (context->getClientMajorVersion())
{ case 1: if (!(surfaceConfig->renderableType & EGL_OPENGL_ES_BIT))
{
val->setError(EGL_BAD_MATCH, "Surface not compatible with OpenGL ES 1.x."); returnfalse;
} break; case 2: if (!(surfaceConfig->renderableType & EGL_OPENGL_ES2_BIT))
{
val->setError(EGL_BAD_MATCH, "Surface not compatible with OpenGL ES 2.x."); returnfalse;
} break; case 3: if (!(surfaceConfig->renderableType & (EGL_OPENGL_ES2_BIT | EGL_OPENGL_ES3_BIT)))
{
val->setError(EGL_BAD_MATCH, "Surface not compatible with OpenGL ES 3.x."); returnfalse;
} break; default:
val->setError(EGL_BAD_MATCH, "Surface not compatible with Context API."); returnfalse;
}
} else
{ if (!(surfaceConfig->renderableType & EGL_OPENGL_BIT))
{
val->setError(EGL_BAD_MATCH, "Surface not compatible with OpenGL Desktop."); returnfalse;
}
}
// EGL KHR no config context if (context->getConfig() == EGL_NO_CONFIG_KHR)
{ const DisplayExtensions &displayExtensions = display->getExtensions(); if (displayExtensions.noConfigContext)
{ returntrue;
}
val->setError(EGL_BAD_MATCH, "Context with no config is not supported."); returnfalse;
}
// Config compatibility is defined in section 2.2 of the EGL 1.5 spec
bool colorBufferCompat = surfaceConfig->colorBufferType == contextConfig->colorBufferType; if (!colorBufferCompat)
{
val->setError(EGL_BAD_MATCH, "Color buffer types are not compatible."); returnfalse;
}
bool componentTypeCompat =
surfaceConfig->colorComponentType == contextConfig->colorComponentType; if (!componentTypeCompat)
{
val->setError(EGL_BAD_MATCH, "Color buffer component types are not compatible."); returnfalse;
}
bool dsCompat = surfaceConfig->depthSize == contextConfig->depthSize &&
surfaceConfig->stencilSize == contextConfig->stencilSize; if (!dsCompat)
{
val->setError(EGL_BAD_MATCH, "Depth-stencil buffer types are not compatible."); returnfalse;
}
bool surfaceTypeCompat = (surfaceConfig->surfaceType & contextConfig->surfaceType) != 0; if (!surfaceTypeCompat)
{
val->setError(EGL_BAD_MATCH, "Surface type is not compatible."); returnfalse;
}
if (!currentContext->getExtensions().EGLSyncOES)
{
val->setError(EGL_BAD_MATCH, "EGL_SYNC_FENCE_KHR cannot be used without " "GL_OES_EGL_sync support."); returnfalse;
} break;
case EGL_SYNC_NATIVE_FENCE_ANDROID: if (!display->getExtensions().fenceSync)
{
val->setError(EGL_BAD_MATCH, "EGL_KHR_fence_sync extension is not available"); returnfalse;
}
if (!display->getExtensions().nativeFenceSyncANDROID)
{
val->setError(EGL_BAD_DISPLAY, "EGL_ANDROID_native_fence_sync extension is not available."); returnfalse;
}
if (display != currentDisplay)
{
val->setError(EGL_BAD_MATCH, "CreateSync can only be called on the current display"); returnfalse;
}
if (!currentContext->getExtensions().EGLSyncOES)
{
val->setError(EGL_BAD_MATCH, "EGL_SYNC_FENCE_KHR cannot be used without " "GL_OES_EGL_sync support."); returnfalse;
}
for (constauto &attributeIter : attribs)
{
EGLAttrib attribute = attributeIter.first;
switch (attribute)
{ case EGL_SYNC_NATIVE_FENCE_FD_ANDROID: break;
case EGL_SYNC_REUSABLE_KHR: if (!attribs.isEmpty())
{
val->setError(EGL_BAD_ATTRIBUTE, "Invalid attribute"); returnfalse;
}
if (!display->getExtensions().reusableSyncKHR)
{
val->setError(EGL_BAD_MATCH, "EGL_KHR_reusable_sync extension is not available."); returnfalse;
} break;
case EGL_SYNC_METAL_SHARED_EVENT_ANGLE: if (!display->getExtensions().fenceSync)
{
val->setError(EGL_BAD_MATCH, "EGL_KHR_fence_sync extension is not available"); returnfalse;
}
if (!display->getExtensions().mtlSyncSharedEventANGLE)
{
val->setError(EGL_BAD_DISPLAY, "EGL_ANGLE_metal_shared_event_sync is not available"); returnfalse;
}
if (display != currentDisplay)
{
val->setError(EGL_BAD_MATCH, "CreateSync can only be called on the current display"); returnfalse;
}
switch (attribute)
{ case EGL_SYNC_CONDITION_KHR: switch (sync->getType())
{ case EGL_SYNC_FENCE_KHR: case EGL_SYNC_NATIVE_FENCE_ANDROID: case EGL_SYNC_METAL_SHARED_EVENT_ANGLE: break;
default:
val->setError(EGL_BAD_ATTRIBUTE, "EGL_SYNC_CONDITION_KHR is not valid for this sync type."); returnfalse;
} break;
// The following attributes are accepted by all types case EGL_SYNC_TYPE_KHR: case EGL_SYNC_STATUS_KHR: break;
switch (attribute)
{ case EGL_DEVICE_EXT: if (!Display::GetClientExtensions().deviceQueryEXT)
{
val->setError(EGL_BAD_DISPLAY, "EGL_EXT_device_query extension is not available."); returnfalse;
} break;
case EGL_FEATURE_COUNT_ANGLE: if (!Display::GetClientExtensions().featureControlANGLE)
{
val->setError(EGL_BAD_DISPLAY, "EGL_ANGLE_feature_control extension is not available."); returnfalse;
} break;
default:
val->setError(EGL_BAD_ATTRIBUTE, "attribute is not valid."); returnfalse;
}
returntrue;
}
bool ValidateCreateContextAttribute(const ValidationContext *val, const Display *display,
EGLAttrib attribute)
{ switch (attribute)
{ case EGL_CONTEXT_CLIENT_VERSION: case EGL_CONTEXT_MINOR_VERSION: case EGL_CONTEXT_FLAGS_KHR: case EGL_CONTEXT_OPENGL_DEBUG: break;
case EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR: if (val->eglThread->getAPI() != EGL_OPENGL_API)
{ // Only valid for OpenGL (non-ES) contexts
val->setError(EGL_BAD_ATTRIBUTE, "OpenGL profile mask requires an OpenGL context."); returnfalse;
} break;
case EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT: if (!display->getExtensions().createContextRobustness)
{
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} break;
case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT: if (!display->getExtensions().createContextRobustness)
{
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} break;
case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY:
{ // We either need to have - // 1. EGL 1.5 which added support for this as part of core spec // 2. EGL_KHR_create_context extension which requires EGL 1.4
constexpr EGLint kRequiredMajorVersion = 1;
constexpr EGLint kRequiredMinorVersion = 5; if ((kEglMajorVersion < kRequiredMajorVersion ||
kEglMinorVersion < kRequiredMinorVersion) &&
!display->getExtensions().createContext)
{
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} break;
}
case EGL_CONTEXT_OPENGL_NO_ERROR_KHR: if (!display->getExtensions().createContextNoError)
{
val->setError(EGL_BAD_ATTRIBUTE, "Invalid Context attribute."); returnfalse;
} break;
case EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE: if (!display->getExtensions().createContextWebGLCompatibility)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute " "EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE requires " "EGL_ANGLE_create_context_webgl_compatibility."); returnfalse;
} break;
case EGL_CONTEXT_BIND_GENERATES_RESOURCE_CHROMIUM: if (!display->getExtensions().createContextBindGeneratesResource)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute EGL_CONTEXT_BIND_GENERATES_RESOURCE_CHROMIUM requires " "EGL_CHROMIUM_create_context_bind_generates_resource."); returnfalse;
} break;
case EGL_DISPLAY_TEXTURE_SHARE_GROUP_ANGLE: if (!display->getExtensions().displayTextureShareGroup)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute " "EGL_DISPLAY_TEXTURE_SHARE_GROUP_ANGLE requires " "EGL_ANGLE_display_texture_share_group."); returnfalse;
} break;
case EGL_DISPLAY_SEMAPHORE_SHARE_GROUP_ANGLE: if (!display->getExtensions().displayTextureShareGroup)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute " "EGL_DISPLAY_SEMAPHORE_SHARE_GROUP_ANGLE requires " "EGL_ANGLE_display_semaphore_share_group."); returnfalse;
} break;
case EGL_CONTEXT_CLIENT_ARRAYS_ENABLED_ANGLE: if (!display->getExtensions().createContextClientArrays)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute EGL_CONTEXT_CLIENT_ARRAYS_ENABLED_ANGLE requires " "EGL_ANGLE_create_context_client_arrays."); returnfalse;
} break;
case EGL_CONTEXT_PROGRAM_BINARY_CACHE_ENABLED_ANGLE: if (!display->getExtensions().programCacheControlANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute EGL_CONTEXT_PROGRAM_BINARY_CACHE_ENABLED_ANGLE " "requires EGL_ANGLE_program_cache_control."); returnfalse;
} break;
case EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE: if (!display->getExtensions().robustResourceInitializationANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE " "requires EGL_ANGLE_robust_resource_initialization."); returnfalse;
} break;
case EGL_EXTENSIONS_ENABLED_ANGLE: if (!display->getExtensions().createContextExtensionsEnabled)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute EGL_EXTENSIONS_ENABLED_ANGLE " "requires EGL_ANGLE_create_context_extensions_enabled."); returnfalse;
} break;
case EGL_POWER_PREFERENCE_ANGLE: if (!display->getExtensions().powerPreference)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute EGL_POWER_PREFERENCE_ANGLE " "requires EGL_ANGLE_power_preference."); returnfalse;
} break;
case EGL_CONTEXT_OPENGL_BACKWARDS_COMPATIBLE_ANGLE: if (!display->getExtensions().createContextBackwardsCompatible)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute EGL_CONTEXT_OPENGL_BACKWARDS_COMPATIBLE_ANGLE " "requires EGL_ANGLE_create_context_backwards_compatible."); returnfalse;
} break;
case EGL_CONTEXT_PRIORITY_LEVEL_IMG: if (!display->getExtensions().contextPriority)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute EGL_CONTEXT_PRIORITY_LEVEL_IMG requires " "extension EGL_IMG_context_priority."); returnfalse;
} break;
case EGL_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV: if (!display->getExtensions().robustnessVideoMemoryPurgeNV)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute EGL_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV requires " "extension EGL_NV_robustness_video_memory_purge."); returnfalse;
} break;
case EGL_EXTERNAL_CONTEXT_ANGLE: if (!display->getExtensions().externalContextAndSurface)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute " "EGL_EXTERNAL_CONTEXT_ANGLE requires " "EGL_ANGLE_external_context_and_surface."); returnfalse;
} break; case EGL_EXTERNAL_CONTEXT_SAVE_STATE_ANGLE: if (!display->getExtensions().externalContextAndSurface)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute " "EGL_EXTERNAL_CONTEXT_SAVE_STATE_ANGLE requires " "EGL_ANGLE_external_context_and_surface."); returnfalse;
} break;
case EGL_PROTECTED_CONTENT_EXT: if (!display->getExtensions().protectedContentEXT)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute EGL_PROTECTED_CONTEXT_EXT requires " "extension EGL_EXT_protected_content."); returnfalse;
} break;
case EGL_CONTEXT_VIRTUALIZATION_GROUP_ANGLE: if (!display->getExtensions().contextVirtualizationANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute EGL_CONTEXT_VIRTUALIZATION_GROUP_ANGLE requires " "extension EGL_ANGLE_context_virtualization."); returnfalse;
} break;
case EGL_CONTEXT_METAL_OWNERSHIP_IDENTITY_ANGLE: if (!display->getExtensions().metalCreateContextOwnershipIdentityANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute EGL_CONTEXT_METAL_OWNERSHIP_IDENTITY_ANGLE requires " "EGL_ANGLE_metal_create_context_ownership_identity.");
} break;
case EGL_CONTEXT_FLAGS_KHR:
{ // Note: EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR does not apply to ES
constexpr EGLint kValidContextFlags =
(EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR | EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR); if ((value & ~kValidContextFlags) != 0)
{
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} break;
}
case EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT: if (value != EGL_TRUE && value != EGL_FALSE)
{
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} break;
case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT: case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY: if (value != EGL_LOSE_CONTEXT_ON_RESET_EXT && value != EGL_NO_RESET_NOTIFICATION_EXT)
{
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
}
case EGL_CONTEXT_OPENGL_NO_ERROR_KHR: if (value != EGL_TRUE && value != EGL_FALSE)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute must be EGL_TRUE or EGL_FALSE."); returnfalse;
} break;
case EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE: if (value != EGL_TRUE && value != EGL_FALSE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE must be " "EGL_TRUE or EGL_FALSE."); returnfalse;
} break;
case EGL_CONTEXT_BIND_GENERATES_RESOURCE_CHROMIUM: if (value != EGL_TRUE && value != EGL_FALSE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_CONTEXT_BIND_GENERATES_RESOURCE_CHROMIUM " "must be EGL_TRUE or EGL_FALSE."); returnfalse;
} break;
case EGL_DISPLAY_TEXTURE_SHARE_GROUP_ANGLE: if (value != EGL_TRUE && value != EGL_FALSE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_DISPLAY_TEXTURE_SHARE_GROUP_ANGLE must be " "EGL_TRUE or EGL_FALSE."); returnfalse;
} if (shareContext &&
shareContext->usingDisplayTextureShareGroup() != (value == EGL_TRUE))
{
val->setError(EGL_BAD_ATTRIBUTE, "All contexts within a share group must be " "created with the same value of " "EGL_DISPLAY_TEXTURE_SHARE_GROUP_ANGLE."); returnfalse;
} break;
case EGL_DISPLAY_SEMAPHORE_SHARE_GROUP_ANGLE: if (value != EGL_TRUE && value != EGL_FALSE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_DISPLAY_SEMAPHORE_SHARE_GROUP_ANGLE must be " "EGL_TRUE or EGL_FALSE."); returnfalse;
} if (shareContext &&
shareContext->usingDisplaySemaphoreShareGroup() != (value == EGL_TRUE))
{
val->setError(EGL_BAD_ATTRIBUTE, "All contexts within a share group must be " "created with the same value of " "EGL_DISPLAY_SEMAPHORE_SHARE_GROUP_ANGLE."); returnfalse;
} break;
case EGL_CONTEXT_CLIENT_ARRAYS_ENABLED_ANGLE: if (value != EGL_TRUE && value != EGL_FALSE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_CONTEXT_CLIENT_ARRAYS_ENABLED_ANGLE must " "be EGL_TRUE or EGL_FALSE."); returnfalse;
} break;
case EGL_CONTEXT_PROGRAM_BINARY_CACHE_ENABLED_ANGLE: if (value != EGL_TRUE && value != EGL_FALSE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_CONTEXT_PROGRAM_BINARY_CACHE_ENABLED_ANGLE must " "be EGL_TRUE or EGL_FALSE."); returnfalse;
} break;
case EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE: if (value != EGL_TRUE && value != EGL_FALSE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE must be " "either EGL_TRUE or EGL_FALSE."); returnfalse;
} break;
case EGL_EXTENSIONS_ENABLED_ANGLE: if (value != EGL_TRUE && value != EGL_FALSE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_EXTENSIONS_ENABLED_ANGLE must be " "either EGL_TRUE or EGL_FALSE."); returnfalse;
} break;
case EGL_POWER_PREFERENCE_ANGLE: if (value != EGL_LOW_POWER_ANGLE && value != EGL_HIGH_POWER_ANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_POWER_PREFERENCE_ANGLE must be " "either EGL_LOW_POWER_ANGLE or EGL_HIGH_POWER_ANGLE."); returnfalse;
} break;
case EGL_CONTEXT_OPENGL_BACKWARDS_COMPATIBLE_ANGLE: if (value != EGL_TRUE && value != EGL_FALSE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_CONTEXT_OPENGL_BACKWARDS_COMPATIBLE_ANGLE must be " "either EGL_TRUE or EGL_FALSE."); returnfalse;
} break;
case EGL_CONTEXT_PRIORITY_LEVEL_IMG: switch (value)
{ case EGL_CONTEXT_PRIORITY_LOW_IMG: case EGL_CONTEXT_PRIORITY_MEDIUM_IMG: case EGL_CONTEXT_PRIORITY_HIGH_IMG: break; default:
val->setError(EGL_BAD_ATTRIBUTE, "Attribute EGL_CONTEXT_PRIORITY_LEVEL_IMG " "must be one of: EGL_CONTEXT_PRIORITY_LOW_IMG, " "EGL_CONTEXT_PRIORITY_MEDIUM_IMG, or " "EGL_CONTEXT_PRIORITY_HIGH_IMG."); returnfalse;
} break;
case EGL_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV: if (value != EGL_TRUE && value != EGL_FALSE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV must " "be either EGL_TRUE or EGL_FALSE."); returnfalse;
} break;
case EGL_EXTERNAL_CONTEXT_ANGLE: if (value != EGL_TRUE && value != EGL_FALSE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_EXTERNAL_CONTEXT_ANGLE must " "be either EGL_TRUE or EGL_FALSE."); returnfalse;
} if (shareContext && (value == EGL_TRUE))
{
val->setError(
EGL_BAD_ATTRIBUTE, "EGL_EXTERNAL_CONTEXT_ANGLE doesn't allow creating with sharedContext."); returnfalse;
} break; case EGL_EXTERNAL_CONTEXT_SAVE_STATE_ANGLE: if (value != EGL_TRUE && value != EGL_FALSE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_EXTERNAL_CONTEXT_SAVE_STATE_ANGLE must " "be either EGL_TRUE or EGL_FALSE."); returnfalse;
} break;
case EGL_PROTECTED_CONTENT_EXT: if (value != EGL_TRUE && value != EGL_FALSE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_PROTECTED_CONTENT_EXT must " "be either EGL_TRUE or EGL_FALSE."); returnfalse;
} break;
case EGL_CONTEXT_METAL_OWNERSHIP_IDENTITY_ANGLE: if (value == 0)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_CONTEXT_METAL_OWNERSHIP_IDENTITY_ANGLE must" "be non-zero."); returnfalse;
} break;
switch (attribute)
{ case EGL_WIDTH: case EGL_HEIGHT: case EGL_LARGEST_PBUFFER: case EGL_TEXTURE_FORMAT: case EGL_TEXTURE_TARGET: case EGL_MIPMAP_TEXTURE: case EGL_VG_COLORSPACE: case EGL_GL_COLORSPACE: case EGL_VG_ALPHA_FORMAT: break;
case EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE: if (!displayExtensions.robustResourceInitializationANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE " "requires EGL_ANGLE_robust_resource_initialization."); returnfalse;
} break;
case EGL_PROTECTED_CONTENT_EXT: if (!displayExtensions.protectedContentEXT)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute EGL_PROTECTED_CONTEXT_EXT requires " "extension EGL_EXT_protected_content."); returnfalse;
} break;
switch (attribute)
{ case EGL_WIDTH: case EGL_HEIGHT: if (value < 0)
{
val->setError(EGL_BAD_PARAMETER); returnfalse;
} break;
case EGL_LARGEST_PBUFFER: break;
case EGL_TEXTURE_FORMAT: switch (value)
{ case EGL_NO_TEXTURE: case EGL_TEXTURE_RGB: case EGL_TEXTURE_RGBA: break; default:
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} break;
case EGL_TEXTURE_TARGET: switch (value)
{ case EGL_NO_TEXTURE: case EGL_TEXTURE_2D: break; default:
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} break;
case EGL_MIPMAP_TEXTURE: break;
case EGL_VG_COLORSPACE: break;
case EGL_GL_COLORSPACE:
ANGLE_VALIDATION_TRY(ValidateColorspaceAttribute(val, displayExtensions, value)); break;
case EGL_VG_ALPHA_FORMAT: break;
case EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE:
ASSERT(displayExtensions.robustResourceInitializationANGLE); if (value != EGL_TRUE && value != EGL_FALSE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE must be " "either EGL_TRUE or EGL_FALSE."); returnfalse;
} break;
case EGL_PROTECTED_CONTENT_EXT:
ASSERT(displayExtensions.protectedContentEXT); if (value != EGL_TRUE && value != EGL_FALSE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_PROTECTED_CONTENT_EXT must " "be either EGL_TRUE or EGL_FALSE."); returnfalse;
} break;
// Get the requested client version (default is 1) and check it is 2 or 3.
EGLAttrib clientMajorVersion = attributes.get(EGL_CONTEXT_CLIENT_VERSION, 1);
EGLAttrib clientMinorVersion = attributes.get(EGL_CONTEXT_MINOR_VERSION, 0);
EGLenum api = val->eglThread->getAPI();
switch (api)
{ case EGL_OPENGL_ES_API: switch (clientMajorVersion)
{ case 1: if (clientMinorVersion != 0 && clientMinorVersion != 1)
{
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} if (configuration == EGL_NO_CONFIG_KHR)
{
val->setError(EGL_BAD_MATCH); returnfalse;
} if ((configuration != EGL_NO_CONFIG_KHR) &&
!(configuration->renderableType & EGL_OPENGL_ES_BIT))
{
val->setError(EGL_BAD_MATCH); returnfalse;
} break;
case 2: if (clientMinorVersion != 0)
{
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} if ((configuration != EGL_NO_CONFIG_KHR) &&
!(configuration->renderableType & EGL_OPENGL_ES2_BIT))
{
val->setError(EGL_BAD_MATCH); returnfalse;
} break; case 3: if (clientMinorVersion < 0 || clientMinorVersion > 2)
{
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} if ((configuration != EGL_NO_CONFIG_KHR) &&
!(configuration->renderableType & EGL_OPENGL_ES3_BIT))
{
val->setError(EGL_BAD_MATCH); returnfalse;
} if (display->getMaxSupportedESVersion() <
gl::Version(static_cast<GLuint>(clientMajorVersion), static_cast<GLuint>(clientMinorVersion)))
{
gl::Version max = display->getMaxSupportedESVersion();
val->setError(EGL_BAD_ATTRIBUTE, "Requested GLES version (%" PRIxPTR ".%" PRIxPTR ") is greater than " "max supported (%d, %d).",
clientMajorVersion, clientMinorVersion, max.major, max.minor); returnfalse;
} if ((attributes.get(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE, EGL_FALSE) ==
EGL_TRUE) &&
(clientMinorVersion > 1))
{
val->setError(EGL_BAD_ATTRIBUTE, "Requested GLES version (%" PRIxPTR ".%" PRIxPTR ") is greater than " "max supported 3.1 for WebGL.",
clientMajorVersion, clientMinorVersion); returnfalse;
} break; default:
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} break;
case EGL_OPENGL_API: // The requested configuration must use EGL_OPENGL_BIT if EGL_OPENGL_BIT is the // currently bound API. if ((configuration != EGL_NO_CONFIG_KHR) &&
!(configuration->renderableType & EGL_OPENGL_BIT))
{
val->setError(EGL_BAD_CONFIG); returnfalse;
} // TODO(http://anglebug.com/7533): validate desktop OpenGL versions and profile mask break;
if (shareContext)
{ // Shared context is invalid or is owned by another display if (!display->isValidContext(shareContext))
{
val->setError(EGL_BAD_MATCH); returnfalse;
}
}
for (constauto &attributeIter : attributes)
{
EGLAttrib attribute = attributeIter.first;
EGLAttrib value = attributeIter.second;
switch (attribute)
{ case EGL_RENDER_BUFFER: switch (value)
{ case EGL_BACK_BUFFER: break; case EGL_SINGLE_BUFFER: break; default:
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} break;
case EGL_POST_SUB_BUFFER_SUPPORTED_NV: if (!displayExtensions.postSubBuffer)
{
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} break;
case EGL_WIDTH: case EGL_HEIGHT: if (!displayExtensions.windowFixedSize)
{
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} if (value < 0)
{
val->setError(EGL_BAD_PARAMETER); returnfalse;
} break;
case EGL_FIXED_SIZE_ANGLE: if (!displayExtensions.windowFixedSize)
{
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} break;
case EGL_SURFACE_ORIENTATION_ANGLE: if (!displayExtensions.surfaceOrientation)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_ANGLE_surface_orientation is not enabled."); returnfalse;
} break;
case EGL_VG_COLORSPACE: if (value != EGL_VG_COLORSPACE_sRGB)
{
val->setError(EGL_BAD_MATCH); returnfalse;
} break;
case EGL_GL_COLORSPACE:
ANGLE_VALIDATION_TRY(ValidateColorspaceAttribute(val, displayExtensions, value)); break;
case EGL_VG_ALPHA_FORMAT:
val->setError(EGL_BAD_MATCH); returnfalse;
case EGL_DIRECT_COMPOSITION_ANGLE: if (!displayExtensions.directComposition)
{
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} break;
case EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE: if (!display->getExtensions().robustResourceInitializationANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE " "requires EGL_ANGLE_robust_resource_initialization."); returnfalse;
} if (value != EGL_TRUE && value != EGL_FALSE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE must be " "either EGL_TRUE or EGL_FALSE."); returnfalse;
} break;
case EGL_GGP_STREAM_DESCRIPTOR_ANGLE: if (!display->getExtensions().ggpStreamDescriptor)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_GGP_STREAM_DESCRIPTOR_ANGLE requires " "EGL_ANGLE_ggp_stream_descriptor."); returnfalse;
} break;
case EGL_PROTECTED_CONTENT_EXT: if (!displayExtensions.protectedContentEXT)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute EGL_PROTECTED_CONTEXT_EXT requires " "extension EGL_EXT_protected_content."); returnfalse;
} if (value != EGL_TRUE && value != EGL_FALSE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_PROTECTED_CONTENT_EXT must " "be either EGL_TRUE or EGL_FALSE."); returnfalse;
} break;
case EGL_SWAP_INTERVAL_ANGLE: if (!displayExtensions.createSurfaceSwapIntervalANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute EGL_SWAP_INTERVAL_ANGLE requires " "extension EGL_ANGLE_create_surface_swap_interval."); returnfalse;
} if (value < config->minSwapInterval || value > config->maxSwapInterval)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_SWAP_INTERVAL_ANGLE must " "be within the EGLConfig min and max swap intervals."); returnfalse;
} break;
switch (buftype)
{ case EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE: if (!displayExtensions.d3dShareHandleClientBuffer)
{
val->setError(EGL_BAD_PARAMETER); returnfalse;
} if (buffer == nullptr)
{
val->setError(EGL_BAD_PARAMETER); returnfalse;
} break;
case EGL_D3D_TEXTURE_ANGLE: if (!displayExtensions.d3dTextureClientBuffer)
{
val->setError(EGL_BAD_PARAMETER); returnfalse;
} if (buffer == nullptr)
{
val->setError(EGL_BAD_PARAMETER); returnfalse;
} break;
case EGL_IOSURFACE_ANGLE: if (!displayExtensions.iosurfaceClientBuffer)
{
val->setError(EGL_BAD_PARAMETER, "<buftype> EGL_IOSURFACE_ANGLE requires the " "EGL_ANGLE_iosurface_client_buffer extension."); returnfalse;
} if (buffer == nullptr)
{
val->setError(EGL_BAD_PARAMETER, "<buffer> must be non null"); returnfalse;
} break; case EGL_EXTERNAL_SURFACE_ANGLE: if (!display->getExtensions().externalContextAndSurface)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute " "EGL_EXTERNAL_SURFACE_ANGLE requires " "EGL_ANGLE_external_context_and_surface."); returnfalse;
} if (buffer != nullptr)
{
val->setError(EGL_BAD_PARAMETER, "<buffer> must be null"); returnfalse;
} break;
for (AttributeMap::const_iterator attributeIter = attributes.begin();
attributeIter != attributes.end(); attributeIter++)
{
EGLAttrib attribute = attributeIter->first;
EGLAttrib value = attributeIter->second;
switch (attribute)
{ case EGL_WIDTH: case EGL_HEIGHT: if (buftype != EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE &&
buftype != EGL_D3D_TEXTURE_ANGLE && buftype != EGL_IOSURFACE_ANGLE &&
buftype != EGL_EXTERNAL_SURFACE_ANGLE)
{
val->setError(EGL_BAD_PARAMETER, "Width and Height are not supported for this <buftype>"); returnfalse;
} if (value < 0)
{
val->setError(EGL_BAD_PARAMETER, "Width and Height must be positive"); returnfalse;
} break;
case EGL_TEXTURE_FORMAT: switch (value)
{ case EGL_NO_TEXTURE: case EGL_TEXTURE_RGB: case EGL_TEXTURE_RGBA: break; default:
val->setError(EGL_BAD_ATTRIBUTE, "Invalid value for EGL_TEXTURE_FORMAT"); returnfalse;
} break;
case EGL_TEXTURE_TARGET: switch (value)
{ case EGL_NO_TEXTURE: case EGL_TEXTURE_2D: break; case EGL_TEXTURE_RECTANGLE_ANGLE: if (buftype != EGL_IOSURFACE_ANGLE)
{
val->setError(EGL_BAD_PARAMETER, "<buftype> doesn't support rectangle texture targets"); returnfalse;
} break;
default:
val->setError(EGL_BAD_ATTRIBUTE, "Invalid value for EGL_TEXTURE_TARGET"); returnfalse;
} break;
case EGL_MIPMAP_TEXTURE: break;
case EGL_IOSURFACE_PLANE_ANGLE: if (buftype != EGL_IOSURFACE_ANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "<buftype> doesn't support iosurface plane"); returnfalse;
} break;
case EGL_TEXTURE_TYPE_ANGLE: if (buftype != EGL_IOSURFACE_ANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "<buftype> doesn't support texture type"); returnfalse;
} break;
case EGL_TEXTURE_INTERNAL_FORMAT_ANGLE: if (buftype != EGL_IOSURFACE_ANGLE && buftype != EGL_D3D_TEXTURE_ANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "<buftype> doesn't support texture internal format"); returnfalse;
} break;
case EGL_GL_COLORSPACE: if (buftype != EGL_D3D_TEXTURE_ANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "<buftype> doesn't support setting GL colorspace"); returnfalse;
} break;
case EGL_IOSURFACE_USAGE_HINT_ANGLE: if (value & ~(EGL_IOSURFACE_READ_HINT_ANGLE | EGL_IOSURFACE_WRITE_HINT_ANGLE))
{
val->setError(EGL_BAD_ATTRIBUTE, "IOSurface usage hint must only contain READ or WRITE"); returnfalse;
} break;
case EGL_TEXTURE_OFFSET_X_ANGLE: case EGL_TEXTURE_OFFSET_Y_ANGLE: if (buftype != EGL_D3D_TEXTURE_ANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "<buftype> doesn't support setting texture offset"); returnfalse;
} break;
case EGL_PROTECTED_CONTENT_EXT: if (!displayExtensions.protectedContentEXT)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute EGL_PROTECTED_CONTEXT_EXT requires " "extension EGL_EXT_protected_content."); returnfalse;
} if (value != EGL_TRUE && value != EGL_FALSE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_PROTECTED_CONTENT_EXT must " "be either EGL_TRUE or EGL_FALSE."); returnfalse;
} break;
if (!(config->surfaceType & EGL_PBUFFER_BIT))
{
val->setError(EGL_BAD_MATCH); returnfalse;
}
EGLAttrib textureFormat = attributes.get(EGL_TEXTURE_FORMAT, EGL_NO_TEXTURE);
EGLAttrib textureTarget = attributes.get(EGL_TEXTURE_TARGET, EGL_NO_TEXTURE); if ((textureFormat != EGL_NO_TEXTURE && textureTarget == EGL_NO_TEXTURE) ||
(textureFormat == EGL_NO_TEXTURE && textureTarget != EGL_NO_TEXTURE))
{
val->setError(EGL_BAD_MATCH); returnfalse;
} if ((textureFormat == EGL_TEXTURE_RGB && config->bindToTextureRGB != EGL_TRUE) ||
(textureFormat == EGL_TEXTURE_RGBA && config->bindToTextureRGBA != EGL_TRUE))
{ // TODO(cwallez@chromium.org): For IOSurface pbuffers we require that EGL_TEXTURE_RGBA is // set so that eglBindTexImage works. Normally this is only allowed if the config exposes // the bindToTextureRGB/RGBA flag. This issue is that enabling this flags means that // eglBindTexImage should also work for regular pbuffers which isn't implemented on macOS. // Instead of adding the flag we special case the check here to be ignored for IOSurfaces. // The TODO is to find a proper solution for this, maybe by implementing eglBindTexImage on // OSX? if (buftype != EGL_IOSURFACE_ANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
}
}
if (buftype == EGL_IOSURFACE_ANGLE)
{ if (static_cast<EGLenum>(textureTarget) != config->bindToTextureTarget)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_IOSURFACE requires the texture target to match the config"); returnfalse;
} if (textureFormat != EGL_TEXTURE_RGBA)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_IOSURFACE requires the EGL_TEXTURE_RGBA format"); returnfalse;
}
for (constauto &attributePair : attributes)
{
EGLAttrib attribute = attributePair.first;
EGLAttrib value = attributePair.second;
switch (attribute)
{ case EGL_GL_COLORSPACE:
ANGLE_VALIDATION_TRY(ValidateColorspaceAttribute(val, displayExtensions, value)); break;
case EGL_VG_COLORSPACE: break; case EGL_VG_ALPHA_FORMAT: break;
case EGL_TEXTURE_FORMAT: if (!displayExtensions.textureFromPixmapNOK)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_NOK_texture_from_pixmap is not enabled."); returnfalse;
} switch (value)
{ case EGL_NO_TEXTURE: case EGL_TEXTURE_RGB: case EGL_TEXTURE_RGBA: break; default:
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} break;
case EGL_TEXTURE_TARGET: if (!displayExtensions.textureFromPixmapNOK)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_NOK_texture_from_pixmap is not enabled."); returnfalse;
} switch (value)
{ case EGL_NO_TEXTURE: case EGL_TEXTURE_2D: break; default:
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} break;
case EGL_MIPMAP_TEXTURE: if (!displayExtensions.textureFromPixmapNOK)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_NOK_texture_from_pixmap is not enabled."); returnfalse;
} break;
case EGL_PROTECTED_CONTENT_EXT: if (!displayExtensions.protectedContentEXT)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute EGL_PROTECTED_CONTEXT_EXT requires " "extension EGL_EXT_protected_content."); returnfalse;
} if (value != EGL_TRUE && value != EGL_FALSE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_PROTECTED_CONTENT_EXT must " "be either EGL_TRUE or EGL_FALSE."); returnfalse;
} break;
// If ctx is EGL_NO_CONTEXT and either draw or read are not EGL_NO_SURFACE, an EGL_BAD_MATCH // error is generated. EGL_KHR_surfaceless_context allows both surfaces to be EGL_NO_SURFACE. if (context != EGL_NO_CONTEXT && (draw == EGL_NO_SURFACE || read == EGL_NO_SURFACE))
{ if (display->getExtensions().surfacelessContext)
{ if ((draw == EGL_NO_SURFACE) != (read == EGL_NO_SURFACE))
{
val->setError(EGL_BAD_MATCH, "If ctx is not EGL_NOT_CONTEXT, draw or read must " "both be EGL_NO_SURFACE, or both not"); returnfalse;
}
} else
{
val->setError(EGL_BAD_MATCH, "If ctx is not EGL_NO_CONTEXT, surfaces must not be EGL_NO_SURFACE"); returnfalse;
}
}
// If either of draw or read is a valid surface and the other is EGL_NO_SURFACE, an // EGL_BAD_MATCH error is generated. if ((read == EGL_NO_SURFACE) != (draw == EGL_NO_SURFACE))
{
val->setError(EGL_BAD_MATCH, "read and draw must both be valid surfaces, or both be EGL_NO_SURFACE"); returnfalse;
}
if (display == EGL_NO_DISPLAY || !Display::isValidDisplay(display))
{
val->setError(EGL_BAD_DISPLAY, "'dpy' not a valid EGLDisplay handle"); returnfalse;
}
// EGL 1.5 spec: dpy can be uninitialized if all other parameters are null if (!display->isInitialized() &&
(context != EGL_NO_CONTEXT || draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE))
{
val->setError(EGL_NOT_INITIALIZED, "'dpy' not initialized"); returnfalse;
}
if (context != EGL_NO_CONTEXT)
{
ANGLE_VALIDATION_TRY(ValidateContext(val, display, context));
}
if (display->isInitialized() && display->isDeviceLost())
{
val->setError(EGL_CONTEXT_LOST); returnfalse;
}
if (draw != EGL_NO_SURFACE)
{
ANGLE_VALIDATION_TRY(ValidateSurface(val, display, draw));
}
// TODO(geofflang): Complete validation from EGL_KHR_image_base: // If the resource specified by <dpy>, <ctx>, <target>, <buffer> and <attrib_list> is itself an // EGLImage sibling, the error EGL_BAD_ACCESS is generated.
for (AttributeMap::const_iterator attributeIter = attributes.begin();
attributeIter != attributes.end(); attributeIter++)
{
EGLAttrib attribute = attributeIter->first;
EGLAttrib value = attributeIter->second;
switch (attribute)
{ case EGL_IMAGE_PRESERVED: switch (value)
{ case EGL_TRUE: case EGL_FALSE: break;
default:
val->setError(EGL_BAD_PARAMETER, "EGL_IMAGE_PRESERVED must be EGL_TRUE or EGL_FALSE."); returnfalse;
} break;
case EGL_GL_TEXTURE_LEVEL: if (!displayExtensions.glTexture2DImage &&
!displayExtensions.glTextureCubemapImage && !displayExtensions.glTexture3DImage)
{
val->setError(EGL_BAD_PARAMETER, "EGL_GL_TEXTURE_LEVEL cannot be used " "without KHR_gl_texture_*_image support."); returnfalse;
}
if (value < 0)
{
val->setError(EGL_BAD_PARAMETER, "EGL_GL_TEXTURE_LEVEL cannot be negative."); returnfalse;
} break;
case EGL_GL_TEXTURE_ZOFFSET: if (!displayExtensions.glTexture3DImage)
{
val->setError(EGL_BAD_PARAMETER, "EGL_GL_TEXTURE_ZOFFSET cannot be used " "without KHR_gl_texture_3D_image support."); returnfalse;
} break;
case EGL_GL_COLORSPACE: if (!displayExtensions.glColorspace)
{
val->setError(EGL_BAD_PARAMETER, "EGL_GL_COLORSPACE cannot be used " "without EGL_KHR_gl_colorspace support."); returnfalse;
} switch (value)
{ case EGL_GL_COLORSPACE_DEFAULT_EXT: break; default:
ANGLE_VALIDATION_TRY(
ValidateColorspaceAttribute(val, displayExtensions, value)); break;
} break;
case EGL_TEXTURE_INTERNAL_FORMAT_ANGLE: if (!displayExtensions.imageD3D11Texture && !displayExtensions.vulkanImageANGLE)
{
val->setError(
EGL_BAD_PARAMETER, "EGL_TEXTURE_INTERNAL_FORMAT_ANGLE cannot be used without " "EGL_ANGLE_image_d3d11_texture or EGL_ANGLE_vulkan_image support."); returnfalse;
} break;
case EGL_D3D11_TEXTURE_PLANE_ANGLE: if (!displayExtensions.imageD3D11Texture)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_D3D11_TEXTURE_PLANE_ANGLE cannot be used without " "EGL_ANGLE_image_d3d11_texture support."); returnfalse;
} break;
case EGL_D3D11_TEXTURE_ARRAY_SLICE_ANGLE: if (!displayExtensions.imageD3D11Texture)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_D3D11_TEXTURE_ARRAY_SLICE_ANGLE cannot be used without " "EGL_ANGLE_image_d3d11_texture support."); returnfalse;
} break;
case EGL_WIDTH: case EGL_HEIGHT: if (target != EGL_LINUX_DMA_BUF_EXT)
{
val->setError(
EGL_BAD_PARAMETER, "Parameter cannot be used if target is not EGL_LINUX_DMA_BUF_EXT"); returnfalse;
} break;
case EGL_LINUX_DRM_FOURCC_EXT: case EGL_DMA_BUF_PLANE0_FD_EXT: case EGL_DMA_BUF_PLANE0_OFFSET_EXT: case EGL_DMA_BUF_PLANE0_PITCH_EXT: case EGL_DMA_BUF_PLANE1_FD_EXT: case EGL_DMA_BUF_PLANE1_OFFSET_EXT: case EGL_DMA_BUF_PLANE1_PITCH_EXT: case EGL_DMA_BUF_PLANE2_FD_EXT: case EGL_DMA_BUF_PLANE2_OFFSET_EXT: case EGL_DMA_BUF_PLANE2_PITCH_EXT: if (!displayExtensions.imageDmaBufImportEXT)
{
val->setError(EGL_BAD_PARAMETER, "Parameter cannot be used without " "EGL_EXT_image_dma_buf_import support."); returnfalse;
} break;
case EGL_YUV_COLOR_SPACE_HINT_EXT: if (!displayExtensions.imageDmaBufImportEXT)
{
val->setError(EGL_BAD_PARAMETER, "Parameter cannot be used without " "EGL_EXT_image_dma_buf_import support."); returnfalse;
}
switch (value)
{ case EGL_ITU_REC601_EXT: case EGL_ITU_REC709_EXT: case EGL_ITU_REC2020_EXT: break;
default:
val->setError(EGL_BAD_PARAMETER, "Invalid value for EGL_YUV_COLOR_SPACE_HINT_EXT."); returnfalse;
} break;
case EGL_SAMPLE_RANGE_HINT_EXT: if (!displayExtensions.imageDmaBufImportEXT)
{
val->setError(EGL_BAD_PARAMETER, "Parameter cannot be used without " "EGL_EXT_image_dma_buf_import support."); returnfalse;
}
switch (value)
{ case EGL_YUV_FULL_RANGE_EXT: case EGL_YUV_NARROW_RANGE_EXT: break;
default:
val->setError(EGL_BAD_PARAMETER, "Invalid value for EGL_SAMPLE_RANGE_HINT_EXT."); returnfalse;
} break;
case EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT: case EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT: if (!displayExtensions.imageDmaBufImportEXT)
{
val->setError(EGL_BAD_PARAMETER, "Parameter cannot be used without " "EGL_EXT_image_dma_buf_import support."); returnfalse;
}
switch (value)
{ case EGL_YUV_CHROMA_SITING_0_EXT: case EGL_YUV_CHROMA_SITING_0_5_EXT: break;
default:
val->setError(
EGL_BAD_PARAMETER, "Invalid value for EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT or " "EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT."); returnfalse;
} break;
case EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT: case EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT: case EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT: case EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT: case EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT: case EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT: case EGL_DMA_BUF_PLANE3_FD_EXT: case EGL_DMA_BUF_PLANE3_OFFSET_EXT: case EGL_DMA_BUF_PLANE3_PITCH_EXT: case EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT: case EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT: if (!displayExtensions.imageDmaBufImportModifiersEXT)
{
val->setError(EGL_BAD_PARAMETER, "Parameter cannot be used without " "EGL_EXT_image_dma_buf_import_modifiers support."); returnfalse;
} break;
case EGL_PROTECTED_CONTENT_EXT: if (!displayExtensions.protectedContentEXT)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute EGL_PROTECTED_CONTEXT_EXT requires " "extension EGL_EXT_protected_content."); returnfalse;
} if (value != EGL_TRUE && value != EGL_FALSE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_PROTECTED_CONTENT_EXT must " "be either EGL_TRUE or EGL_FALSE."); returnfalse;
} break;
case EGL_VULKAN_IMAGE_CREATE_INFO_HI_ANGLE: case EGL_VULKAN_IMAGE_CREATE_INFO_LO_ANGLE: if (!displayExtensions.vulkanImageANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute EGL_VULKAN_IMAGE_CREATE_INFO_{HI,LO}_ANGLE require " "extension EGL_ANGLE_vulkan_image."); returnfalse;
} break;
switch (target)
{ case EGL_GL_TEXTURE_2D:
{ if (!displayExtensions.glTexture2DImage)
{
val->setError(EGL_BAD_PARAMETER, "KHR_gl_texture_2D_image not supported."); returnfalse;
}
if (buffer == 0)
{
val->setError(EGL_BAD_PARAMETER, "buffer cannot reference a 2D texture with the name 0."); returnfalse;
}
ANGLE_VALIDATION_TRY(ValidateContext(val, display, context)); const gl::Texture *texture =
context->getTexture({egl_gl::EGLClientBufferToGLObjectHandle(buffer)}); if (texture == nullptr || texture->getType() != gl::TextureType::_2D)
{
val->setError(EGL_BAD_PARAMETER, "target is not a 2D texture."); returnfalse;
}
if (texture->getBoundSurface() != nullptr)
{
val->setError(EGL_BAD_ACCESS, "texture has a surface bound to it."); returnfalse;
}
EGLAttrib level = attributes.get(EGL_GL_TEXTURE_LEVEL, 0); if (texture->getWidth(gl::TextureTarget::_2D, static_cast<size_t>(level)) == 0 ||
texture->getHeight(gl::TextureTarget::_2D, static_cast<size_t>(level)) == 0)
{
val->setError(EGL_BAD_PARAMETER, "target 2D texture does not have a valid size at specified level."); returnfalse;
}
bool protectedContentAttrib =
(attributes.getAsInt(EGL_PROTECTED_CONTENT_EXT, EGL_FALSE) != EGL_FALSE); if (protectedContentAttrib != texture->hasProtectedContent())
{
val->setError(EGL_BAD_PARAMETER, "EGL_PROTECTED_CONTENT_EXT attribute does not match protected state " "of target."); returnfalse;
}
case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X: case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X: case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y: case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z: case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
{ if (!displayExtensions.glTextureCubemapImage)
{
val->setError(EGL_BAD_PARAMETER, "KHR_gl_texture_cubemap_image not supported."); returnfalse;
}
if (buffer == 0)
{
val->setError(EGL_BAD_PARAMETER, "buffer cannot reference a cubemap texture with the name 0."); returnfalse;
}
ANGLE_VALIDATION_TRY(ValidateContext(val, display, context)); const gl::Texture *texture =
context->getTexture({egl_gl::EGLClientBufferToGLObjectHandle(buffer)}); if (texture == nullptr || texture->getType() != gl::TextureType::CubeMap)
{
val->setError(EGL_BAD_PARAMETER, "target is not a cubemap texture."); returnfalse;
}
if (texture->getBoundSurface() != nullptr)
{
val->setError(EGL_BAD_ACCESS, "texture has a surface bound to it."); returnfalse;
}
EGLAttrib level = attributes.get(EGL_GL_TEXTURE_LEVEL, 0);
gl::TextureTarget cubeMapFace = egl_gl::EGLCubeMapTargetToCubeMapTarget(target); if (texture->getWidth(cubeMapFace, static_cast<size_t>(level)) == 0 ||
texture->getHeight(cubeMapFace, static_cast<size_t>(level)) == 0)
{
val->setError(EGL_BAD_PARAMETER, "target cubemap texture does not have a valid " "size at specified level and face."); returnfalse;
}
if (level == 0 && !texture->isMipmapComplete() &&
CubeTextureHasUnspecifiedLevel0Face(texture))
{
val->setError(EGL_BAD_PARAMETER, "if level is zero and the texture is incomplete, " "it must have all of its faces specified at level " "zero."); returnfalse;
}
bool protectedContentAttrib =
(attributes.getAsInt(EGL_PROTECTED_CONTENT_EXT, EGL_FALSE) != EGL_FALSE); if (protectedContentAttrib != texture->hasProtectedContent())
{
val->setError(EGL_BAD_PARAMETER, "EGL_PROTECTED_CONTENT_EXT attribute does not match protected state " "of target."); returnfalse;
}
} break;
case EGL_GL_TEXTURE_3D:
{ if (!displayExtensions.glTexture3DImage)
{
val->setError(EGL_BAD_PARAMETER, "KHR_gl_texture_3D_image not supported."); returnfalse;
}
if (buffer == 0)
{
val->setError(EGL_BAD_PARAMETER, "buffer cannot reference a 3D texture with the name 0."); returnfalse;
}
ANGLE_VALIDATION_TRY(ValidateContext(val, display, context)); const gl::Texture *texture =
context->getTexture({egl_gl::EGLClientBufferToGLObjectHandle(buffer)}); if (texture == nullptr || texture->getType() != gl::TextureType::_3D)
{
val->setError(EGL_BAD_PARAMETER, "target is not a 3D texture."); returnfalse;
}
if (texture->getBoundSurface() != nullptr)
{
val->setError(EGL_BAD_ACCESS, "texture has a surface bound to it."); returnfalse;
}
EGLAttrib level = attributes.get(EGL_GL_TEXTURE_LEVEL, 0);
EGLAttrib zOffset = attributes.get(EGL_GL_TEXTURE_ZOFFSET, 0); if (texture->getWidth(gl::TextureTarget::_3D, static_cast<size_t>(level)) == 0 ||
texture->getHeight(gl::TextureTarget::_3D, static_cast<size_t>(level)) == 0 ||
texture->getDepth(gl::TextureTarget::_3D, static_cast<size_t>(level)) == 0)
{
val->setError(EGL_BAD_PARAMETER, "target 3D texture does not have a valid size at specified level."); returnfalse;
}
if (static_cast<size_t>(zOffset) >=
texture->getDepth(gl::TextureTarget::_3D, static_cast<size_t>(level)))
{
val->setError(EGL_BAD_PARAMETER, "target 3D texture does not have enough layers " "for the specified Z offset at the specified " "level."); returnfalse;
}
bool protectedContentAttrib =
(attributes.getAsInt(EGL_PROTECTED_CONTENT_EXT, EGL_FALSE) != EGL_FALSE); if (protectedContentAttrib != texture->hasProtectedContent())
{
val->setError(EGL_BAD_PARAMETER, "EGL_PROTECTED_CONTENT_EXT attribute does not match protected state " "of target."); returnfalse;
}
case EGL_GL_RENDERBUFFER:
{ if (!displayExtensions.glRenderbufferImage)
{
val->setError(EGL_BAD_PARAMETER, "KHR_gl_renderbuffer_image not supported."); returnfalse;
}
if (attributes.contains(EGL_GL_TEXTURE_LEVEL))
{
val->setError(EGL_BAD_PARAMETER, "EGL_GL_TEXTURE_LEVEL cannot be used in " "conjunction with a renderbuffer target."); returnfalse;
}
if (buffer == 0)
{
val->setError(EGL_BAD_PARAMETER, "buffer cannot reference a renderbuffer with the name 0."); returnfalse;
}
ANGLE_VALIDATION_TRY(ValidateContext(val, display, context)); const gl::Renderbuffer *renderbuffer =
context->getRenderbuffer({egl_gl::EGLClientBufferToGLObjectHandle(buffer)}); if (renderbuffer == nullptr)
{
val->setError(EGL_BAD_PARAMETER, "target is not a renderbuffer."); returnfalse;
}
if (renderbuffer->getSamples() > 0)
{
val->setError(EGL_BAD_PARAMETER, "target renderbuffer cannot be multisampled."); returnfalse;
}
bool protectedContentAttrib =
(attributes.getAsInt(EGL_PROTECTED_CONTENT_EXT, EGL_FALSE) != EGL_FALSE); if (protectedContentAttrib != renderbuffer->hasProtectedContent())
{
val->setError(EGL_BAD_ACCESS, "EGL_PROTECTED_CONTENT_EXT attribute does not match protected state " "of target."); returnfalse;
}
} break;
case EGL_NATIVE_BUFFER_ANDROID:
{ if (!displayExtensions.imageNativeBuffer)
{
val->setError(EGL_BAD_PARAMETER, "EGL_ANDROID_image_native_buffer not supported."); returnfalse;
}
if (context != nullptr)
{
val->setError(EGL_BAD_CONTEXT, "ctx must be EGL_NO_CONTEXT."); returnfalse;
}
case EGL_D3D11_TEXTURE_ANGLE: if (!displayExtensions.imageD3D11Texture)
{
val->setError(EGL_BAD_PARAMETER, "EGL_ANGLE_image_d3d11_texture not supported."); returnfalse;
}
if (context != nullptr)
{
val->setError(EGL_BAD_CONTEXT, "ctx must be EGL_NO_CONTEXT."); returnfalse;
}
case EGL_LINUX_DMA_BUF_EXT: if (!displayExtensions.imageDmaBufImportEXT)
{
val->setError(EGL_BAD_PARAMETER, "EGL_EXT_image_dma_buf_import not supported."); returnfalse;
}
if (context != nullptr)
{
val->setError(EGL_BAD_CONTEXT, "ctx must be EGL_NO_CONTEXT."); returnfalse;
}
if (buffer != nullptr)
{
val->setError(EGL_BAD_PARAMETER, "buffer must be NULL."); returnfalse;
}
case EGL_METAL_TEXTURE_ANGLE: if (!displayExtensions.mtlTextureClientBuffer)
{
val->setError(EGL_BAD_PARAMETER, "EGL_ANGLE_metal_texture_client_buffer not supported."); returnfalse;
}
if (context != nullptr)
{
val->setError(EGL_BAD_CONTEXT, "ctx must be EGL_NO_CONTEXT."); returnfalse;
}
ANGLE_EGL_TRY_RETURN(
val->eglThread,
display->validateImageClientBuffer(context, target, buffer, attributes),
val->entryPoint, val->labeledObject, false); break; case EGL_VULKAN_IMAGE_ANGLE: if (!displayExtensions.vulkanImageANGLE)
{
val->setError(EGL_BAD_PARAMETER, "EGL_ANGLE_vulkan_image not supported."); returnfalse;
}
if (context != nullptr)
{
val->setError(EGL_BAD_CONTEXT, "ctx must be EGL_NO_CONTEXT."); returnfalse;
}
if (attributes.contains(EGL_GL_TEXTURE_ZOFFSET) && target != EGL_GL_TEXTURE_3D)
{
val->setError(EGL_BAD_PARAMETER, "EGL_GL_TEXTURE_ZOFFSET must be used with a 3D texture target."); returnfalse;
}
if (!display->getExtensions().imageBase && !display->getExtensions().image)
{ // It is out of spec what happens when calling an extension function when the extension is // not available. // EGL_BAD_DISPLAY seems like a reasonable error.
val->setError(EGL_BAD_DISPLAY, "EGL_KHR_image not supported."); returnfalse;
}
if (!display->getExtensions().imageBase && !display->getExtensions().image)
{ // It is out of spec what happens when calling an extension function when the extension is // not available. // EGL_BAD_DISPLAY seems like a reasonable error.
val->setError(EGL_BAD_DISPLAY); returnfalse;
}
Display *owningDisplay = device->getOwningDisplay(); if (owningDisplay != nullptr)
{
val->setError(EGL_BAD_DEVICE_EXT, "Device must have been created using eglCreateDevice"); returnfalse;
}
gl::Context *context = val->eglThread->getContext(); if (context == nullptr)
{
val->setError(EGL_BAD_MATCH, "No context is current."); returnfalse;
}
if (!context->getExtensions().EGLSyncOES)
{
val->setError(EGL_BAD_MATCH, "Server-side waits cannot be performed without " "GL_OES_EGL_sync support."); returnfalse;
}
if (flags != 0)
{
val->setError(EGL_BAD_PARAMETER, "flags must be zero"); returnfalse;
}
// Lookup the texture and ensure it is correct
gl::Texture *texture = context->getState().getTargetTexture(gl::TextureType::External); if (texture == nullptr || texture->id().value == 0)
{
val->setError(EGL_BAD_ACCESS, "No external texture bound"); returnfalse;
}
gl::Context *context = val->eglThread->getContext(); if (!context)
{
val->setError(EGL_BAD_ACCESS, "No GL context current to calling thread."); returnfalse;
}
if (!stream->isConsumerBoundToContext(context))
{
val->setError(EGL_BAD_ACCESS, "Current GL context not associated with stream consumer"); returnfalse;
}
// Note: technically EGL_STREAM_STATE_EMPTY_KHR is a valid state when the timeout is non-zero. // However, the timeout is effectively ignored since it has no useful functionality with the // current producers that are implemented, so we don't allow that state if (stream->getState() != EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR &&
stream->getState() != EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR)
{
val->setError(EGL_BAD_STATE_KHR, "Invalid stream state"); returnfalse;
}
gl::Context *context = val->eglThread->getContext(); if (!context)
{
val->setError(EGL_BAD_ACCESS, "No GL context current to calling thread."); returnfalse;
}
if (!stream->isConsumerBoundToContext(context))
{
val->setError(EGL_BAD_ACCESS, "Current GL context not associated with stream consumer"); returnfalse;
}
// Although technically not a requirement in spec, the context needs to be checked for support // for external textures or future logic will cause assertations. This extension is also // effectively useless without external textures. if (!context->getExtensions().EGLStreamConsumerExternalNV)
{
val->setError(EGL_BAD_ACCESS, "EGL stream consumer external GL extension not enabled"); returnfalse;
}
EGLAttrib colorBufferType = EGL_RGB_BUFFER;
EGLAttrib planeCount = -1;
EGLAttrib plane[3]; for (int i = 0; i < 3; i++)
{
plane[i] = -1;
}
attribs.initializeWithoutValidation();
for (constauto &attributeIter : attribs)
{
EGLAttrib attribute = attributeIter.first;
EGLAttrib value = attributeIter.second;
switch (attribute)
{ case EGL_COLOR_BUFFER_TYPE: if (value != EGL_RGB_BUFFER && value != EGL_YUV_BUFFER_EXT)
{
val->setError(EGL_BAD_PARAMETER, "Invalid color buffer type"); returnfalse;
}
colorBufferType = value; break; case EGL_YUV_NUMBER_OF_PLANES_EXT: // planeCount = -1 is a tag for the default plane count so the value must be checked // to be positive here to ensure future logic doesn't break on invalid negative // inputs if (value < 0)
{
val->setError(EGL_BAD_MATCH, "Invalid plane count"); returnfalse;
}
planeCount = value; break; default: if (attribute >= EGL_YUV_PLANE0_TEXTURE_UNIT_NV &&
attribute <= EGL_YUV_PLANE2_TEXTURE_UNIT_NV)
{ if ((value < 0 ||
value >= static_cast<EGLAttrib>(glCaps.maxCombinedTextureImageUnits)) &&
value != EGL_NONE)
{
val->setError(EGL_BAD_ACCESS, "Invalid texture unit"); returnfalse;
}
plane[attribute - EGL_YUV_PLANE0_TEXTURE_UNIT_NV] = value;
} else
{
val->setError(EGL_BAD_ATTRIBUTE, "Invalid attribute"); returnfalse;
}
}
}
if (colorBufferType == EGL_RGB_BUFFER)
{ if (planeCount > 0)
{
val->setError(EGL_BAD_MATCH, "Plane count must be 0 for RGB buffer"); returnfalse;
} for (int i = 0; i < 3; i++)
{ if (plane[i] != -1)
{
val->setError(EGL_BAD_MATCH, "Planes cannot be specified"); returnfalse;
}
}
// Lookup the texture and ensure it is correct
gl::Texture *texture = context->getState().getTargetTexture(gl::TextureType::External); if (texture == nullptr || texture->id().value == 0)
{
val->setError(EGL_BAD_ACCESS, "No external texture bound"); returnfalse;
}
} else
{ if (planeCount == -1)
{
planeCount = 2;
} if (planeCount < 1 || planeCount > 3)
{
val->setError(EGL_BAD_MATCH, "Invalid YUV plane count"); returnfalse;
} for (EGLAttrib i = planeCount; i < 3; i++)
{ if (plane[i] != -1)
{
val->setError(EGL_BAD_MATCH, "Invalid plane specified"); returnfalse;
}
}
// Set to ensure no texture is referenced more than once
std::set<gl::Texture *> textureSet; for (EGLAttrib i = 0; i < planeCount; i++)
{ if (plane[i] == -1)
{
val->setError(EGL_BAD_MATCH, "Not all planes specified"); returnfalse;
} if (plane[i] != EGL_NONE)
{
gl::Texture *texture = context->getState().getSamplerTexture( static_cast<unsignedint>(plane[i]), gl::TextureType::External); if (texture == nullptr || texture->id().value == 0)
{
val->setError(
EGL_BAD_ACCESS, "No external texture bound at one or more specified texture units"); returnfalse;
} if (textureSet.find(texture) != textureSet.end())
{
val->setError(EGL_BAD_ACCESS, "Multiple planes bound to same texture object"); returnfalse;
}
textureSet.insert(texture);
}
}
}
if (!display->getExtensions().swapBuffersWithDamage)
{ // It is out of spec what happens when calling an extension function when the extension is // not available. EGL_BAD_DISPLAY seems like a reasonable error.
val->setError(EGL_BAD_DISPLAY, "EGL_KHR_swap_buffers_with_damage is not available."); returnfalse;
}
if (surface == EGL_NO_SURFACE)
{
val->setError(EGL_BAD_SURFACE, "Swap surface cannot be EGL_NO_SURFACE."); returnfalse;
}
if (n_rects < 0)
{
val->setError(EGL_BAD_PARAMETER, "n_rects cannot be negative."); returnfalse;
}
if (n_rects > 0 && rects == nullptr)
{
val->setError(EGL_BAD_PARAMETER, "n_rects cannot be greater than zero when rects is NULL."); returnfalse;
}
if (surface->isLocked())
{
val->setError(EGL_BAD_ACCESS); returnfalse;
}
// TODO(jmadill): Validate Surface is bound to the thread.
returntrue;
}
bool ValidateWaitNative(const ValidationContext *val, const EGLint engine)
{ if (val->eglThread->getDisplay() == nullptr)
{ // EGL spec says this about eglWaitNative - // eglWaitNative is ignored if there is no current EGL rendering context. returntrue;
}
bool ValidateBindAPI(const ValidationContext *val, const EGLenum api)
{ switch (api)
{ case EGL_OPENGL_ES_API: case EGL_OPENGL_API: break; case EGL_OPENVG_API:
val->setError(EGL_BAD_PARAMETER); returnfalse; // Not supported by this implementation default:
val->setError(EGL_BAD_PARAMETER); returnfalse;
}
if (!display->getExtensions().presentationTime)
{ // It is out of spec what happens when calling an extension function when the extension is // not available. EGL_BAD_DISPLAY seems like a reasonable error.
val->setError(EGL_BAD_DISPLAY, "EGL_ANDROID_presentation_time is not available."); returnfalse;
}
if (display->areBlobCacheFuncsSet())
{
val->setError(EGL_BAD_PARAMETER, "Blob cache functions can only be set once in the lifetime of a Display"); returnfalse;
}
if (set == nullptr || get == nullptr)
{
val->setError(EGL_BAD_PARAMETER, "Blob cache callbacks cannot be null."); returnfalse;
}
if (!display->getExtensions().programCacheControlANGLE)
{
val->setError(EGL_BAD_ACCESS, "Extension not supported"); returnfalse;
}
if (index < 0 || index >= display->programCacheGetAttrib(EGL_PROGRAM_CACHE_SIZE_ANGLE))
{
val->setError(EGL_BAD_PARAMETER, "Program index out of range."); returnfalse;
}
if (keysize == nullptr || binarysize == nullptr)
{
val->setError(EGL_BAD_PARAMETER, "keysize and binarysize must always be valid pointers."); returnfalse;
}
if (binary && *keysize != static_cast<EGLint>(egl::BlobCache::kKeyLength))
{
val->setError(EGL_BAD_PARAMETER, "Invalid program key size."); returnfalse;
}
if ((key == nullptr) != (binary == nullptr))
{
val->setError(EGL_BAD_PARAMETER, "key and binary must both be null or both non-null."); returnfalse;
}
if (!display->getExtensions().programCacheControlANGLE)
{
val->setError(EGL_BAD_ACCESS, "Extension not supported"); returnfalse;
}
if (keysize != static_cast<EGLint>(egl::BlobCache::kKeyLength))
{
val->setError(EGL_BAD_PARAMETER, "Invalid program key size."); returnfalse;
}
if (key == nullptr || binary == nullptr)
{
val->setError(EGL_BAD_PARAMETER, "null pointer in arguments."); returnfalse;
}
// Upper bound for binarysize is arbitrary. if (binarysize <= 0 || binarysize > egl::kProgramCacheSizeAbsoluteMax)
{
val->setError(EGL_BAD_PARAMETER, "binarysize out of valid range."); returnfalse;
}
if (surface == EGL_NO_SURFACE)
{
val->setError(EGL_BAD_SURFACE, "Surface cannot be EGL_NO_SURFACE."); returnfalse;
}
switch (attribute)
{ case EGL_MIPMAP_LEVEL: break;
case EGL_MULTISAMPLE_RESOLVE: switch (value)
{ case EGL_MULTISAMPLE_RESOLVE_DEFAULT: break;
case EGL_MULTISAMPLE_RESOLVE_BOX: if ((surface->getConfig()->surfaceType & EGL_MULTISAMPLE_RESOLVE_BOX_BIT) == 0)
{
val->setError(EGL_BAD_MATCH, "Surface does not support EGL_MULTISAMPLE_RESOLVE_BOX."); returnfalse;
} break;
case EGL_SWAP_BEHAVIOR: switch (value)
{ case EGL_BUFFER_PRESERVED: if ((surface->getConfig()->surfaceType & EGL_SWAP_BEHAVIOR_PRESERVED_BIT) == 0)
{
val->setError(EGL_BAD_MATCH, "Surface does not support EGL_SWAP_BEHAVIOR_PRESERVED."); returnfalse;
} break;
case EGL_WIDTH: case EGL_HEIGHT: if (!display->getExtensions().windowFixedSize)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_WIDTH or EGL_HEIGHT cannot be set without " "EGL_ANGLE_window_fixed_size support."); returnfalse;
} if (!surface->isFixedSize())
{
val->setError(EGL_BAD_MATCH, "EGL_WIDTH or EGL_HEIGHT cannot be set without " "EGL_FIXED_SIZE_ANGLE being enabled on the surface."); returnfalse;
} break;
case EGL_TIMESTAMPS_ANDROID: if (!display->getExtensions().getFrameTimestamps &&
!display->getExtensions().timestampSurfaceAttributeANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_TIMESTAMPS_ANDROID cannot be used without " "EGL_ANDROID_get_frame_timestamps support."); returnfalse;
} switch (value)
{ case EGL_TRUE: case EGL_FALSE: break;
case EGL_FRONT_BUFFER_AUTO_REFRESH_ANDROID:
ASSERT(value == EGL_TRUE || value == EGL_FALSE); break;
case EGL_RENDER_BUFFER: if (value != EGL_BACK_BUFFER && value != EGL_SINGLE_BUFFER)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_RENDER_BUFFER must be EGL_BACK_BUFFER or EGL_SINGLE_BUFFER."); returnfalse;
}
if (value == EGL_SINGLE_BUFFER)
{ if (!display->getExtensions().mutableRenderBufferKHR)
{
val->setError(
EGL_BAD_ATTRIBUTE, "Attribute EGL_RENDER_BUFFER requires EGL_KHR_mutable_render_buffer."); returnfalse;
}
if ((surface->getConfig()->surfaceType & EGL_MUTABLE_RENDER_BUFFER_BIT_KHR) == 0)
{
val->setError(EGL_BAD_MATCH, "EGL_RENDER_BUFFER requires the surface type bit " "EGL_MUTABLE_RENDER_BUFFER_BIT_KHR."); returnfalse;
}
} break;
if (surface == EGL_NO_SURFACE)
{
val->setError(EGL_BAD_SURFACE, "Surface cannot be EGL_NO_SURFACE."); returnfalse;
}
switch (attribute)
{ case EGL_GL_COLORSPACE: case EGL_VG_ALPHA_FORMAT: case EGL_VG_COLORSPACE: case EGL_CONFIG_ID: case EGL_HEIGHT: case EGL_HORIZONTAL_RESOLUTION: case EGL_LARGEST_PBUFFER: case EGL_MIPMAP_TEXTURE: case EGL_MIPMAP_LEVEL: case EGL_MULTISAMPLE_RESOLVE: case EGL_PIXEL_ASPECT_RATIO: case EGL_RENDER_BUFFER: case EGL_SWAP_BEHAVIOR: case EGL_TEXTURE_FORMAT: case EGL_TEXTURE_TARGET: case EGL_VERTICAL_RESOLUTION: case EGL_WIDTH: break;
case EGL_POST_SUB_BUFFER_SUPPORTED_NV: if (!display->getExtensions().postSubBuffer)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_POST_SUB_BUFFER_SUPPORTED_NV cannot be used " "without EGL_ANGLE_surface_orientation support."); returnfalse;
} break;
case EGL_FIXED_SIZE_ANGLE: if (!display->getExtensions().windowFixedSize)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_FIXED_SIZE_ANGLE cannot be used without " "EGL_ANGLE_window_fixed_size support."); returnfalse;
} break;
case EGL_SURFACE_ORIENTATION_ANGLE: if (!display->getExtensions().surfaceOrientation)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_SURFACE_ORIENTATION_ANGLE cannot be " "queried without " "EGL_ANGLE_surface_orientation support."); returnfalse;
} break;
case EGL_DIRECT_COMPOSITION_ANGLE: if (!display->getExtensions().directComposition)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_DIRECT_COMPOSITION_ANGLE cannot be " "used without " "EGL_ANGLE_direct_composition support."); returnfalse;
} break;
case EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE: if (!display->getExtensions().robustResourceInitializationANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE cannot be " "used without EGL_ANGLE_robust_resource_initialization " "support."); returnfalse;
} break;
case EGL_TIMESTAMPS_ANDROID: if (!display->getExtensions().getFrameTimestamps &&
!display->getExtensions().timestampSurfaceAttributeANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_TIMESTAMPS_ANDROID cannot be used without " "EGL_ANDROID_get_frame_timestamps support."); returnfalse;
} break;
case EGL_BUFFER_AGE_EXT:
{ if (!display->getExtensions().bufferAgeEXT)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_BUFFER_AGE_EXT cannot be used without " "EGL_EXT_buffer_age support."); returnfalse;
}
gl::Context *context = val->eglThread->getContext(); if ((context == nullptr) || (context->getCurrentDrawSurface() != surface))
{
val->setError(EGL_BAD_SURFACE, "The surface must be current to the current context " "in order to query buffer age per extension " "EGL_EXT_buffer_age."); returnfalse;
}
} break;
case EGL_BITMAP_PITCH_KHR: case EGL_BITMAP_ORIGIN_KHR: case EGL_BITMAP_PIXEL_RED_OFFSET_KHR: case EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR: case EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR: case EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR: case EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR: case EGL_BITMAP_PIXEL_SIZE_KHR: if (!display->getExtensions().lockSurface3KHR)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_KHR_lock_surface3 is not supported."); returnfalse;
} break;
case EGL_PROTECTED_CONTENT_EXT: if (!display->getExtensions().protectedContentEXT)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_EXT_protected_content not supported"); returnfalse;
} break;
switch (attribute)
{ case EGL_CONFIG_ID: case EGL_CONTEXT_CLIENT_TYPE: case EGL_CONTEXT_CLIENT_VERSION: case EGL_RENDER_BUFFER: break;
case EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE: if (!display->getExtensions().robustResourceInitializationANGLE)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE cannot be " "used without EGL_ANGLE_robust_resource_initialization " "support."); returnfalse;
} break;
case EGL_CONTEXT_PRIORITY_LEVEL_IMG: if (!display->getExtensions().contextPriority)
{
val->setError(EGL_BAD_ATTRIBUTE, "Attribute EGL_CONTEXT_PRIORITY_LEVEL_IMG requires " "extension EGL_IMG_context_priority."); returnfalse;
} break;
case EGL_PROTECTED_CONTENT_EXT: if (!display->getExtensions().protectedContentEXT)
{
val->setError(EGL_BAD_ATTRIBUTE, "EGL_EXT_protected_content not supported"); returnfalse;
} break;
bool ValidateDebugMessageControlKHR(const ValidationContext *val,
EGLDEBUGPROCKHR callback, const AttributeMap &attribs)
{ const ClientExtensions &clientExtensions = Display::GetClientExtensions(); if (!clientExtensions.debug)
{
val->setError(EGL_BAD_ACCESS, "EGL_KHR_debug extension is not available."); returnfalse;
}
attribs.initializeWithoutValidation();
for (constauto &attrib : attribs)
{ switch (attrib.first)
{ case EGL_DEBUG_MSG_CRITICAL_KHR: case EGL_DEBUG_MSG_ERROR_KHR: case EGL_DEBUG_MSG_WARN_KHR: case EGL_DEBUG_MSG_INFO_KHR: if (attrib.second != EGL_TRUE && attrib.second != EGL_FALSE)
{
val->setError(EGL_BAD_ATTRIBUTE, "message controls must be EGL_TRUE or EGL_FALSE."); returnfalse;
} break;
}
}
returntrue;
}
bool ValidateQueryDebugKHR(const ValidationContext *val, EGLint attribute, const EGLAttrib *value)
{ const ClientExtensions &clientExtensions = Display::GetClientExtensions(); if (!clientExtensions.debug)
{
val->setError(EGL_BAD_ACCESS, "EGL_KHR_debug extension is not available."); returnfalse;
}
switch (attribute)
{ case EGL_DEBUG_MSG_CRITICAL_KHR: case EGL_DEBUG_MSG_ERROR_KHR: case EGL_DEBUG_MSG_WARN_KHR: case EGL_DEBUG_MSG_INFO_KHR: case EGL_DEBUG_CALLBACK_KHR: break;
if (!display->getExtensions().getFrameTimestamps)
{
val->setError(EGL_BAD_DISPLAY, "EGL_ANDROID_get_frame_timestamps extension is not available."); returnfalse;
}
if (!display->getExtensions().getFrameTimestamps)
{
val->setError(EGL_BAD_DISPLAY, "EGL_ANDROID_get_frame_timestamps extension is not available."); returnfalse;
}
if (names == nullptr && numTimestamps > 0)
{
val->setError(EGL_BAD_PARAMETER, "names is NULL."); returnfalse;
}
if (values == nullptr && numTimestamps > 0)
{
val->setError(EGL_BAD_PARAMETER, "values is NULL."); returnfalse;
}
if (numTimestamps < 0)
{
val->setError(EGL_BAD_PARAMETER, "numTimestamps must be at least 0."); returnfalse;
}
for (EGLint i = 0; i < numTimestamps; i++)
{
CompositorTiming name = FromEGLenum<CompositorTiming>(names[i]);
if (!ValidCompositorTimingName(name))
{
val->setError(EGL_BAD_PARAMETER, "invalid compositor timing."); returnfalse;
}
if (!surface->getSupportedCompositorTimings().test(name))
{
val->setError(EGL_BAD_PARAMETER, "compositor timing not supported by surface."); returnfalse;
}
}
if (!display->getExtensions().getFrameTimestamps)
{
val->setError(EGL_BAD_DISPLAY, "EGL_ANDROID_get_frame_timestamps extension is not available."); returnfalse;
}
if (!display->getExtensions().getFrameTimestamps)
{
val->setError(EGL_BAD_DISPLAY, "EGL_ANDROID_get_frame_timestamps extension is not available."); returnfalse;
}
if (!display->getExtensions().getFrameTimestamps)
{
val->setError(EGL_BAD_DISPLAY, "EGL_ANDROID_get_frame_timestamps extension is not available."); returnfalse;
}
if (!Display::GetClientExtensions().featureControlANGLE)
{
val->setError(EGL_BAD_DISPLAY, "EGL_ANGLE_feature_control extension is not available."); returnfalse;
}
if (index < 0)
{
val->setError(EGL_BAD_PARAMETER, "index is negative."); returnfalse;
}
switch (name)
{ case EGL_FEATURE_NAME_ANGLE: case EGL_FEATURE_CATEGORY_ANGLE: case EGL_FEATURE_DESCRIPTION_ANGLE: case EGL_FEATURE_BUG_ANGLE: case EGL_FEATURE_STATUS_ANGLE: case EGL_FEATURE_CONDITION_ANGLE: break; default:
val->setError(EGL_BAD_PARAMETER, "name is not valid."); returnfalse;
}
if (static_cast<size_t>(index) >= display->getFeatures().size())
{
val->setError(EGL_BAD_PARAMETER, "index is too big."); returnfalse;
}
bool ValidateGetNativeClientBufferANDROID(const ValidationContext *val, const AHardwareBuffer *buffer)
{ // No extension check is done because no display is passed to eglGetNativeClientBufferANDROID // despite it being a display extension. No display is needed for the implementation though. if (buffer == nullptr)
{
val->setError(EGL_BAD_PARAMETER, "NULL buffer."); returnfalse;
}
int width = attribMap.getAsInt(EGL_WIDTH, 0); int height = attribMap.getAsInt(EGL_HEIGHT, 0); int redSize = attribMap.getAsInt(EGL_RED_SIZE, 0); int greenSize = attribMap.getAsInt(EGL_GREEN_SIZE, 0); int blueSize = attribMap.getAsInt(EGL_BLUE_SIZE, 0); int alphaSize = attribMap.getAsInt(EGL_ALPHA_SIZE, 0); int usage = attribMap.getAsInt(EGL_NATIVE_BUFFER_USAGE_ANDROID, 0);
for (AttributeMap::const_iterator attributeIter = attribMap.begin();
attributeIter != attribMap.end(); attributeIter++)
{
EGLAttrib attribute = attributeIter->first; switch (attribute)
{ case EGL_WIDTH: case EGL_HEIGHT: // Validation done after the switch statement break; case EGL_RED_SIZE: case EGL_GREEN_SIZE: case EGL_BLUE_SIZE: case EGL_ALPHA_SIZE: if (redSize < 0 || greenSize < 0 || blueSize < 0 || alphaSize < 0)
{
val->setError(EGL_BAD_PARAMETER, "incorrect channel size requested"); returnfalse;
} break; case EGL_NATIVE_BUFFER_USAGE_ANDROID: // The buffer must be used for either a texture or a renderbuffer. if ((usage & ~(EGL_NATIVE_BUFFER_USAGE_PROTECTED_BIT_ANDROID |
EGL_NATIVE_BUFFER_USAGE_RENDERBUFFER_BIT_ANDROID |
EGL_NATIVE_BUFFER_USAGE_TEXTURE_BIT_ANDROID)) != 0)
{
val->setError(EGL_BAD_PARAMETER, "invalid usage flag"); returnfalse;
} break; case EGL_NONE: break; default:
val->setError(EGL_BAD_ATTRIBUTE, "invalid attribute"); returnfalse;
}
}
// Validate EGL_WIDTH and EGL_HEIGHT values passed in. Done here to account // for the case where EGL_WIDTH and EGL_HEIGHT were not part of the attribute list. if (width <= 0 || height <= 0)
{
val->setError(EGL_BAD_PARAMETER, "incorrect buffer dimensions requested"); returnfalse;
}
if (!display->getExtensions().mtlSyncSharedEventANGLE)
{
val->setError(EGL_BAD_DISPLAY, "EGL_ANGLE_metal_shared_event_sync is not available."); returnfalse;
}
if (!display->getExtensions().nativeFenceSyncANDROID)
{
val->setError(EGL_BAD_DISPLAY, "EGL_ANDROID_native_fence_sync extension is not available."); returnfalse;
}
if (!display->getExtensions().swapWithFrameToken)
{
val->setError(EGL_BAD_DISPLAY, "EGL_ANGLE_swap_buffers_with_frame_token is not available."); returnfalse;
}
if (sync->getType() == EGL_SYNC_REUSABLE_KHR)
{ if (!display->getExtensions().reusableSyncKHR)
{
val->setError(EGL_BAD_MATCH, "EGL_KHR_reusable_sync extension is not available."); returnfalse;
}
if (!Display::GetClientExtensions().deviceQueryEXT)
{
val->setError(EGL_BAD_ACCESS, "EGL_EXT_device_query not supported."); returnfalse;
}
// validate the attribute parameter switch (attribute)
{ case EGL_D3D11_DEVICE_ANGLE: case EGL_D3D9_DEVICE_ANGLE: if (!device->getExtensions().deviceD3D || device->getType() != attribute)
{
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} break; case EGL_EAGL_CONTEXT_ANGLE: if (!device->getExtensions().deviceEAGL)
{
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} break; case EGL_METAL_DEVICE_ANGLE: if (!device->getExtensions().deviceMetal)
{
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} break; case EGL_VULKAN_VERSION_ANGLE: case EGL_VULKAN_INSTANCE_ANGLE: case EGL_VULKAN_INSTANCE_EXTENSIONS_ANGLE: case EGL_VULKAN_PHYSICAL_DEVICE_ANGLE: case EGL_VULKAN_DEVICE_ANGLE: case EGL_VULKAN_DEVICE_EXTENSIONS_ANGLE: case EGL_VULKAN_FEATURES_ANGLE: case EGL_VULKAN_QUEUE_ANGLE: case EGL_VULKAN_QUEUE_FAMILIY_INDEX_ANGLE: case EGL_VULKAN_GET_INSTANCE_PROC_ADDR: if (!device->getExtensions().deviceVulkan)
{
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} break; case EGL_CGL_CONTEXT_ANGLE: case EGL_CGL_PIXEL_FORMAT_ANGLE: if (!device->getExtensions().deviceCGL)
{
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} break; default:
val->setError(EGL_BAD_ATTRIBUTE); returnfalse;
} returntrue;
}
bool ValidateQueryString(const ValidationContext *val, const Display *dpyPacked, EGLint name)
{ // The only situation where EGL_NO_DISPLAY is allowed is when querying // EGL_EXTENSIONS or EGL_VERSION. constbool canQueryWithoutDisplay = (name == EGL_VERSION || name == EGL_EXTENSIONS);
if (dpyPacked != nullptr || !canQueryWithoutDisplay)
{
ANGLE_VALIDATION_TRY(ValidateDisplay(val, dpyPacked));
}
switch (name)
{ case EGL_CLIENT_APIS: case EGL_EXTENSIONS: case EGL_VENDOR: case EGL_VERSION: break; default:
val->setError(EGL_BAD_PARAMETER); returnfalse;
} returntrue;
}
bool ValidateWaitGL(const ValidationContext *val)
{ if (val->eglThread->getDisplay() == nullptr)
{ // EGL spec says this about eglWaitGL - // eglWaitGL is ignored if there is no current EGL rendering context for OpenGL ES. returntrue;
}
bool ValidateWaitClient(const ValidationContext *val)
{ if (val->eglThread->getDisplay() == nullptr)
{ // EGL spec says this about eglWaitClient - // If there is no current context for the current rendering API, // the function has no effect but still returns EGL_TRUE. returntrue;
}
if (!dpy->getExtensions().lockSurface3KHR)
{
val->setError(EGL_BAD_ACCESS); returnfalse;
}
if (surface->isLocked())
{
val->setError(EGL_BAD_ACCESS); returnfalse;
}
if ((surface->getConfig()->surfaceType & EGL_LOCK_SURFACE_BIT_KHR) == false)
{
val->setError(EGL_BAD_ACCESS, "Config does not support EGL_LOCK_SURFACE_BIT"); returnfalse;
}
if (surface->isCurrentOnAnyContext())
{
val->setError(EGL_BAD_ACCESS, "Surface cannot be current to a context for eglLockSurface()"); returnfalse;
}
if (surface->hasProtectedContent())
{
val->setError(EGL_BAD_ACCESS, "Surface cannot be protected content for eglLockSurface()"); returnfalse;
}
attributes.initializeWithoutValidation();
for (constauto &attributeIter : attributes)
{
EGLAttrib attribute = attributeIter.first;
EGLAttrib value = attributeIter.second;
if (!dpy->getExtensions().lockSurface3KHR)
{
val->setError(EGL_BAD_ACCESS); returnfalse;
}
switch (attribute)
{ case EGL_BITMAP_PITCH_KHR: case EGL_BITMAP_ORIGIN_KHR: case EGL_BITMAP_PIXEL_RED_OFFSET_KHR: case EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR: case EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR: case EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR: case EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR: case EGL_BITMAP_PIXEL_SIZE_KHR: case EGL_BITMAP_POINTER_KHR: break; default:
val->setError(EGL_BAD_ATTRIBUTE, "Invalid eglQuerySurface64 attribute"); returnfalse;
}
if (value == nullptr)
{
val->setError(EGL_BAD_PARAMETER, "value is NULL."); returnfalse;
}
if (!surface->isLocked())
{
val->setError(EGL_BAD_ACCESS, "Surface is not locked"); returnfalse;
}
if (!(surface->getType() & EGL_WINDOW_BIT))
{
val->setError(EGL_BAD_MATCH, "surface is not a postable surface"); returnfalse;
}
if (surface != val->eglThread->getCurrentDrawSurface())
{
val->setError(EGL_BAD_MATCH, "surface is not the current draw surface for the calling thread"); returnfalse;
}
if (surface->getSwapBehavior() != EGL_BUFFER_DESTROYED)
{
val->setError(EGL_BAD_MATCH, "surface's swap behavior is not EGL_BUFFER_DESTROYED"); returnfalse;
}
if (surface->isDamageRegionSet())
{
val->setError(
EGL_BAD_ACCESS, "damage region has already been set on surface since the most recent frame boundary"); returnfalse;
}
if (!surface->bufferAgeQueriedSinceLastSwap())
{
val->setError(EGL_BAD_ACCESS, "EGL_BUFFER_AGE_KHR attribute of surface has not been queried since the most " "recent frame boundary"); returnfalse;
}
if (!dpy->getExtensions().imageDmaBufImportModifiersEXT)
{
val->setError(EGL_BAD_ACCESS, "EGL_EXT_dma_buf_import_modfier not supported"); returnfalse;
}
if (max_formats < 0)
{
val->setError(EGL_BAD_PARAMETER, "max_formats should not be negative"); returnfalse;
}
if (max_formats > 0 && formats == nullptr)
{
val->setError(EGL_BAD_PARAMETER, "if max_formats is positive, formats should not be NULL"); returnfalse;
}
if (!dpy->getExtensions().imageDmaBufImportModifiersEXT)
{
val->setError(EGL_BAD_ACCESS, "EGL_EXT_dma_buf_import_modfier not supported"); returnfalse;
}
if (max_modifiers < 0)
{
val->setError(EGL_BAD_PARAMETER, "max_modifiers should not be negative"); returnfalse;
}
if (max_modifiers > 0 && modifiers == nullptr)
{
val->setError(EGL_BAD_PARAMETER, "if max_modifiers is positive, modifiers should not be NULL"); returnfalse;
}
if (!dpy->supportsDmaBufFormat(format))
{
val->setError(EGL_BAD_PARAMETER, "format should be one of the formats advertised by QueryDmaBufFormatsEXT"); returnfalse;
} returntrue;
}
} // namespace egl
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.226Bemerkung:
(vorverarbeitet am 2026-04-27)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.