#ifndef LIBANGLE_CAPS_H_
#define LIBANGLE_CAPS_H_
#include "angle_gl.h"
#include "libANGLE/Version.h"
#include "libANGLE/angletypes.h"
#include "libANGLE/gles_extensions_autogen.h"
#include "libANGLE/renderer/Format.h"
#include <array>
#include <map>
#include <set>
#include <string>
#include <vector>
namespace gl
{
struct TextureCaps
{
TextureCaps();
TextureCaps(const TextureCaps &other);
TextureCaps &operator=(const TextureCaps &other);
~TextureCaps();
bool texturable = false;
bool filterable = false;
bool textureAttachment = false;
bool renderbuffer = false;
bool blendable = false;
SupportedSampleSet sampleCounts;
};
TextureCaps GenerateMinimumTextureCaps(GLenum internalFormat,
const Version &clientVersion,
const Extensions &extensions);
class TextureCapsMap final : angle::NonCopyable
{
public:
TextureCapsMap();
~TextureCapsMap();
void insert(GLenum internalFormat, const TextureCaps &caps);
const TextureCaps &get(GLenum internalFormat) const;
void clear();
const TextureCaps &get(angle::FormatID formatID) const;
void set(angle::FormatID formatID, const TextureCaps &caps);
private:
TextureCaps &get(angle::FormatID formatID);
angle::FormatMap<TextureCaps> mFormatData;
};
void InitMinimumTextureCapsMap(const Version &clientVersion,
const Extensions &extensions,
TextureCapsMap *capsMap);
bool DetermineCompressedTextureETCSupport(const TextureCapsMap &textureCaps);
bool DetermineRenderSnormSupport(const TextureCapsMap &textureCaps, bool textureNorm16EXT);
using ExtensionBool = bool Extensions::*;
struct ExtensionInfo
{
bool Requestable = false;
bool Disablable = false;
ExtensionBool ExtensionsMember = nullptr;
};
using ExtensionInfoMap = std::map<std::string, ExtensionInfo>;
const ExtensionInfoMap &GetExtensionInfoMap();
struct Limitations
{
Limitations();
Limitations(const Limitations &other);
Limitations &operator=(const Limitations &other);
bool noFrontFacingSupport = false;
bool noSampleAlphaToCoverageSupport = false;
bool attributeZeroRequiresZeroDivisorInEXT = false;
bool noSeparateStencilRefsAndMasks = false;
bool noSimultaneousConstantColorAndAlphaBlendFunc = false;
bool noUnclampedBlendColor = false;
bool noFlexibleVaryingPacking = false;
bool noDoubleBoundTransformFeedbackBuffers = false;
bool noVertexAttributeAliasing = false;
bool noShadowSamplerCompareModeNone = false;
bool squarePvrtc1 = false;
bool emulatedEtc1 = false;
bool emulatedAstc = false;
bool noCompressedTexture3D = false;
bool compressedBaseMipLevelMultipleOfFour = false;
GLint webGLTextureSizeLimit = 0;
bool multidrawEmulated = true;
bool baseInstanceBaseVertexEmulated = true;
};
struct TypePrecision
{
TypePrecision();
TypePrecision(const TypePrecision &other);
TypePrecision &operator=(const TypePrecision &other);
void setIEEEFloat();
void setIEEEHalfFloat();
void setTwosComplementInt(unsigned int bits);
void setSimulatedFloat(unsigned int range, unsigned int precision);
void setSimulatedInt(unsigned int range);
void get(GLint *returnRange, GLint *returnPrecision) const;
std::array<GLint, 2> range = {0, 0};
GLint precision = 0;
};
struct FragmentShadingRateProperties
{
GLuint minFragmentShadingRateAttachmentTexelWidth;
GLuint minFragmentShadingRateAttachmentTexelHeight;
GLuint maxFragmentShadingRateAttachmentTexelWidth;
GLuint maxFragmentShadingRateAttachmentTexelHeight;
GLuint maxFragmentShadingRateAttachmentTexelAspectRatio;
GLuint maxFragmentShadingRateAttachmentLayers;
bool layeredShadingRateAttachments;
bool fragmentShadingRateNonTrivialCombinersSupport;
bool fragmentShadingRateWithShaderDepthStencilWritesSupport;
bool fragmentShadingRateWithSampleMaskSupport;
};
struct Caps
{
Caps();
Caps(const Caps &other);
Caps &operator=(const Caps &other);
~Caps();
GLfloat minInterpolationOffset = 0;
GLfloat maxInterpolationOffset = 0;
GLint subPixelInterpolationOffsetBits = 0;
GLint64 maxElementIndex = 0;
GLint max3DTextureSize = 0;
GLint max2DTextureSize = 0;
GLint maxRectangleTextureSize = 0;
GLint maxArrayTextureLayers = 0;
GLfloat maxLODBias = 0.0f;
GLint maxCubeMapTextureSize = 0;
GLint maxRenderbufferSize = 0;
GLfloat minAliasedPointSize = 1.0f;
GLfloat maxAliasedPointSize = 1.0f;
GLfloat minAliasedLineWidth = 0.0f;
GLfloat maxAliasedLineWidth = 0.0f;
GLint maxDrawBuffers = 0;
GLint maxFramebufferWidth = 0;
GLint maxFramebufferHeight = 0;
GLint maxFramebufferSamples = 0;
GLint maxColorAttachments = 0;
GLint maxViewportWidth = 0;
GLint maxViewportHeight = 0;
GLint maxSampleMaskWords = 0;
GLint maxColorTextureSamples = 0;
GLint maxDepthTextureSamples = 0;
GLint maxIntegerSamples = 0;
GLint64 maxServerWaitTimeout = 0;
GLint maxVertexAttribRelativeOffset = 0;
GLint maxVertexAttribBindings = 0;
GLint maxVertexAttribStride = 0;
GLint maxElementsIndices = 0;
GLint maxElementsVertices = 0;
std::vector<GLenum> compressedTextureFormats;
std::vector<GLenum> programBinaryFormats;
std::vector<GLenum> shaderBinaryFormats;
TypePrecision vertexHighpFloat;
TypePrecision vertexMediumpFloat;
TypePrecision vertexLowpFloat;
TypePrecision vertexHighpInt;
TypePrecision vertexMediumpInt;
TypePrecision vertexLowpInt;
TypePrecision fragmentHighpFloat;
TypePrecision fragmentMediumpFloat;
TypePrecision fragmentLowpFloat;
TypePrecision fragmentHighpInt;
TypePrecision fragmentMediumpInt;
TypePrecision fragmentLowpInt;
ShaderMap<GLint> maxShaderUniformBlocks = {};
ShaderMap<GLint> maxShaderTextureImageUnits = {};
ShaderMap<GLint> maxShaderStorageBlocks = {};
ShaderMap<GLint> maxShaderUniformComponents = {};
ShaderMap<GLint> maxShaderAtomicCounterBuffers = {};
ShaderMap<GLint> maxShaderAtomicCounters = {};
ShaderMap<GLint> maxShaderImageUniforms = {};
ShaderMap<GLint64> maxCombinedShaderUniformComponents = {};
GLint maxVertexAttributes = 0;
GLint maxVertexUniformVectors = 0;
GLint maxVertexOutputComponents = 0;
GLint maxFragmentUniformVectors = 0;
GLint maxFragmentInputComponents = 0;
GLint minProgramTextureGatherOffset = 0;
GLint maxProgramTextureGatherOffset = 0;
GLint minProgramTexelOffset = 0;
GLint maxProgramTexelOffset = 0;
std::array<GLint, 3> maxComputeWorkGroupCount = {0, 0, 0};
std::array<GLint, 3> maxComputeWorkGroupSize = {0, 0, 0};
GLint maxComputeWorkGroupInvocations = 0;
GLint maxComputeSharedMemorySize = 0;
GLint maxUniformBufferBindings = 0;
GLint64 maxUniformBlockSize = 0;
GLint uniformBufferOffsetAlignment = 0;
GLint maxCombinedUniformBlocks = 0;
GLint maxVaryingComponents = 0;
GLint maxVaryingVectors = 0;
GLint maxCombinedTextureImageUnits = 0;
GLint maxCombinedShaderOutputResources = 0;
GLint maxUniformLocations = 0;
GLint maxAtomicCounterBufferBindings = 0;
GLint maxAtomicCounterBufferSize = 0;
GLint maxCombinedAtomicCounterBuffers = 0;
GLint maxCombinedAtomicCounters = 0;
GLint maxImageUnits = 0;
GLint maxCombinedImageUniforms = 0;
GLint maxShaderStorageBufferBindings = 0;
GLint64 maxShaderStorageBlockSize = 0;
GLint maxCombinedShaderStorageBlocks = 0;
GLint shaderStorageBufferOffsetAlignment = 0;
GLint maxTransformFeedbackInterleavedComponents = 0;
GLint maxTransformFeedbackSeparateAttributes = 0;
GLint maxTransformFeedbackSeparateComponents = 0;
GLint maxSamples = 0;
GLint maxFramebufferLayers = 0;
GLint layerProvokingVertex = 0;
GLint maxGeometryInputComponents = 0;
GLint maxGeometryOutputComponents = 0;
GLint maxGeometryOutputVertices = 0;
GLint maxGeometryTotalOutputComponents = 0;
GLint maxGeometryShaderInvocations = 0;
GLint maxTessControlInputComponents = 0;
GLint maxTessControlOutputComponents = 0;
GLint maxTessControlTotalOutputComponents = 0;
GLint maxTessPatchComponents = 0;
GLint maxPatchVertices = 0;
GLint maxTessGenLevel = 0;
GLint maxTessEvaluationInputComponents = 0;
GLint maxTessEvaluationOutputComponents = 0;
bool primitiveRestartForPatchesSupported = false;
GLuint subPixelBits = 4;
GLuint maxDualSourceDrawBuffers = 0;
GLfloat maxTextureAnisotropy = 0.0f;
GLuint queryCounterBitsTimeElapsed = 0;
GLuint queryCounterBitsTimestamp = 0;
GLuint maxViews = 1;
GLuint maxDebugMessageLength = 0;
GLuint maxDebugLoggedMessages = 0;
GLuint maxDebugGroupStackDepth = 0;
GLuint maxLabelLength = 0;
GLuint maxClipDistances = 0;
GLuint maxCullDistances = 0;
GLuint maxCombinedClipAndCullDistances = 0;
GLuint maxPixelLocalStoragePlanes = 0;
GLuint maxCombinedDrawBuffersAndPixelLocalStoragePlanes = 0;
GLuint maxShaderPixelLocalStorageFastSizeEXT = 0;
GLuint maxMultitextureUnits = 0;
GLuint maxClipPlanes = 0;
GLuint maxLights = 0;
static constexpr int GlobalMatrixStackDepth = 16;
GLuint maxModelviewMatrixStackDepth = 0;
GLuint maxProjectionMatrixStackDepth = 0;
GLuint maxTextureMatrixStackDepth = 0;
GLfloat minSmoothPointSize = 0.0f;
GLfloat maxSmoothPointSize = 0.0f;
GLfloat minSmoothLineWidth = 0.0f;
GLfloat maxSmoothLineWidth = 0.0f;
GLfloat lineWidthGranularity = 0.0f;
GLfloat minMultisampleLineWidth = 0.0f;
GLfloat maxMultisampleLineWidth = 0.0f;
GLint maxTextureBufferSize = 0;
GLint textureBufferOffsetAlignment = 0;
bool fragmentShaderFramebufferFetchMRT = false;
FragmentShadingRateProperties fragmentShadingRateProperties = {};
};
Caps GenerateMinimumCaps(const Version &clientVersion, const Extensions &extensions);
}
namespace egl
{
struct Caps
{
Caps();
bool textureNPOT = false;
bool stencil8 = false;
};
struct DisplayExtensions
{
DisplayExtensions();
std::vector<std::string> getStrings() const;
bool createContextRobustness = false;
bool d3dShareHandleClientBuffer = false;
bool d3dTextureClientBuffer = false;
bool surfaceD3DTexture2DShareHandle = false;
bool querySurfacePointer = false;
bool windowFixedSize = false;
bool keyedMutex = false;
bool surfaceOrientation = false;
bool postSubBuffer = false;
bool createContext = false;
bool image = false;
bool imageBase = false;
bool imagePixmap = false;
bool glTexture2DImage = false;
bool glTextureCubemapImage = false;
bool glTexture3DImage = false;
bool glRenderbufferImage = false;
bool getAllProcAddresses = false;
bool directComposition = false;
bool windowsUIComposition = false;
bool createContextNoError = false;
bool stream = false;
bool streamConsumerGLTexture = false;
bool streamConsumerGLTextureYUV = false;
bool streamProducerD3DTexture = false;
bool fenceSync = false;
bool waitSync = false;
bool createContextWebGLCompatibility = false;
bool createContextBindGeneratesResource = false;
bool syncControlCHROMIUM = false;
bool syncControlRateANGLE = false;
bool swapBuffersWithDamage = false;
bool pixelFormatFloat = false;
bool surfacelessContext = false;
bool displayTextureShareGroup = false;
bool displaySemaphoreShareGroup = false;
bool createContextClientArrays = false;
bool programCacheControlANGLE = false;
bool robustResourceInitializationANGLE = false;
bool iosurfaceClientBuffer = false;
bool mtlTextureClientBuffer = false;
bool createContextExtensionsEnabled = false;
bool presentationTime = false;
bool blobCache = false;
bool imageNativeBuffer = false;
bool getFrameTimestamps = false;
bool frontBufferAutoRefreshANDROID = false;
bool timestampSurfaceAttributeANGLE = false;
bool recordable = false;
bool powerPreference = false;
bool waitUntilWorkScheduled = false;
bool imageD3D11Texture = false;
bool getNativeClientBufferANDROID = false;
bool createNativeClientBufferANDROID = false;
bool nativeFenceSyncANDROID = false;
bool createContextBackwardsCompatible = false;
bool noConfigContext = false;
bool contextPriority = false;
bool glColorspace = false;
bool glColorspaceDisplayP3Linear = false;
bool glColorspaceDisplayP3 = false;
bool glColorspaceScrgb = false;
bool glColorspaceScrgbLinear = false;
bool glColorspaceDisplayP3Passthrough = false;
bool eglColorspaceAttributePassthroughANGLE = false;
bool glColorspaceBt2020Linear = false;
bool glColorspaceBt2020Pq = false;
bool glColorspaceBt2020Hlg = false;
bool framebufferTargetANDROID = false;
bool imageGlColorspace = false;
bool imageDmaBufImportEXT = false;
bool imageDmaBufImportModifiersEXT = false;
bool textureFromPixmapNOK = false;
bool robustnessVideoMemoryPurgeNV = false;
bool reusableSyncKHR = false;
bool externalContextAndSurface = false;
bool bufferAgeEXT = false;
bool mutableRenderBufferKHR = false;
bool protectedContentEXT = false;
bool createSurfaceSwapIntervalANGLE = false;
bool contextVirtualizationANGLE = false;
bool lockSurface3KHR = false;
bool vulkanImageANGLE = false;
bool metalCreateContextOwnershipIdentityANGLE = false;
bool partialUpdateKHR = false;
bool mtlSyncSharedEventANGLE = false;
bool mtlSyncCommandsScheduledANGLE = false;
bool globalFenceSyncANGLE = false;
bool memoryUsageReportANGLE = false;
bool surfaceCompressionEXT = false;
bool webgpuTextureClientBuffer = false;
bool createContextPassthroughShadersANGLE = false;
bool contextPriorityRealtimeNV = false;
};
struct DeviceExtensions
{
DeviceExtensions();
std::vector<std::string> getStrings() const;
bool deviceD3D = false;
bool deviceD3D9 = false;
bool deviceD3D11 = false;
bool deviceCGL = false;
bool deviceMetal = false;
bool deviceVulkan = false;
bool deviceDrmEXT = false;
bool deviceDrmRenderNodeEXT = false;
bool deviceWebGPU = false;
};
struct ClientExtensions
{
ClientExtensions();
ClientExtensions(const ClientExtensions &other);
std::vector<std::string> getStrings() const;
bool clientExtensions = false;
bool platformBase = false;
bool platformDevice = false;
bool platformGbmKHR = false;
bool platformWaylandEXT = false;
bool platformSurfacelessMESA = false;
bool platformANGLE = false;
bool platformANGLED3D = false;
bool platformANGLED3D11ON12 = false;
bool platformANGLED3DLUID = false;
bool platformANGLEOpenGL = false;
bool platformANGLENULL = false;
bool platformANGLEWebgpu = false;
bool platformANGLEVulkan = false;
bool platformANGLEVulkanDeviceUUID = false;
bool platformANGLEMetal = false;
bool platformANGLEDeviceContextVolatileCgl = false;
bool platformANGLEDeviceId = false;
bool deviceCreation = false;
bool deviceCreationD3D11 = false;
bool x11Visual = false;
bool experimentalPresentPath = false;
bool clientGetAllProcAddresses = false;
bool debug = false;
bool featureControlANGLE = false;
bool platformANGLEDeviceTypeSwiftShader = false;
bool platformANGLEDeviceTypeEGLANGLE = false;
bool deviceQueryEXT = false;
bool displayPowerPreferenceANGLE = false;
bool noErrorANGLE = false;
};
}
#endif