Commit 0c4e08e9 by Jiawei Shao Committed by Commit Bot

Use ShaderMap in Caps - Part II

This patch is the last one in the series of putting resource limits on each shader stage into ShaderMap. With this patch, all such values are organized in the corresponding ShaderMap. This patch also cleans up all the related code by using this new type of data structure. BUG=angleproject:2169 Change-Id: I440643fe44ab63acf7da0a1611643beed1ba66d1 Reviewed-on: https://chromium-review.googlesource.com/1077748 Commit-Queue: Jiawei Shao <jiawei.shao@intel.com> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 6a455206
......@@ -923,26 +923,24 @@ Caps::Caps()
// Table 20.44
// Table 20.45
// Table 20.43gs (GL_EXT_geometry_shader)
// Table 20.46 (GL_EXT_geometry_shader)
maxShaderUniformBlocks({}),
maxShaderTextureImageUnits({}),
maxShaderStorageBlocks({}),
maxShaderUniformComponents({}),
maxShaderAtomicCounterBuffers({}),
maxShaderAtomicCounters({}),
maxShaderImageUniforms({}),
maxCombinedShaderUniformComponents({}),
// Table 20.43
maxVertexAttributes(0),
maxVertexUniformComponents(0),
maxVertexUniformVectors(0),
maxVertexOutputComponents(0),
maxVertexAtomicCounterBuffers(0),
maxVertexAtomicCounters(0),
maxVertexImageUniforms(0),
// Table 20.44
maxFragmentUniformComponents(0),
maxFragmentUniformVectors(0),
maxFragmentInputComponents(0),
maxFragmentAtomicCounterBuffers(0),
maxFragmentAtomicCounters(0),
maxFragmentImageUniforms(0),
minProgramTextureGatherOffset(0),
maxProgramTextureGatherOffset(0),
minProgramTexelOffset(0),
......@@ -951,19 +949,12 @@ Caps::Caps()
// Table 20.45
maxComputeWorkGroupInvocations(0),
maxComputeSharedMemorySize(0),
maxComputeUniformComponents(0),
maxComputeAtomicCounterBuffers(0),
maxComputeAtomicCounters(0),
maxComputeImageUniforms(0),
maxCombinedComputeUniformComponents(0),
// Table 20.46
maxUniformBufferBindings(0),
maxUniformBlockSize(0),
uniformBufferOffsetAlignment(0),
maxCombinedUniformBlocks(0),
maxCombinedVertexUniformComponents(0),
maxCombinedFragmentUniformComponents(0),
maxVaryingComponents(0),
maxVaryingVectors(0),
maxCombinedTextureImageUnits(0),
......@@ -995,19 +986,12 @@ Caps::Caps()
layerProvokingVertex(0),
// Table 20.43gs (GL_EXT_geometry_shader)
maxGeometryUniformComponents(0),
maxGeometryInputComponents(0),
maxGeometryOutputComponents(0),
maxGeometryOutputVertices(0),
maxGeometryTotalOutputComponents(0),
maxGeometryAtomicCounterBuffers(0),
maxGeometryAtomicCounters(0),
maxGeometryShaderInvocations(0),
// Table 20.46 (GL_EXT_geometry_shader)
maxGeometryImageUniforms(0),
maxCombinedGeometryUniformComponents(0),
// GLES1 emulation: Table 6.20 / 6.22 (ES 1.1 spec)
maxMultitextureUnits(0),
maxClipPlanes(0),
......@@ -1117,14 +1101,14 @@ Caps GenerateMinimumCaps(const Version &clientVersion, const Extensions &extensi
// Table 6.31
caps.maxVertexAttributes = 16;
caps.maxVertexUniformComponents = 1024;
caps.maxShaderUniformComponents[ShaderType::Vertex] = 1024;
caps.maxVertexUniformVectors = 256;
caps.maxShaderUniformBlocks[ShaderType::Vertex] = 12;
caps.maxVertexOutputComponents = 64;
caps.maxShaderTextureImageUnits[ShaderType::Vertex] = 16;
// Table 6.32
caps.maxFragmentUniformComponents = 896;
caps.maxShaderUniformComponents[ShaderType::Fragment] = 896;
caps.maxFragmentUniformVectors = 224;
caps.maxShaderUniformBlocks[ShaderType::Fragment] = 12;
caps.maxFragmentInputComponents = 60;
......@@ -1137,12 +1121,6 @@ Caps GenerateMinimumCaps(const Version &clientVersion, const Extensions &extensi
caps.maxUniformBlockSize = 16384;
caps.uniformBufferOffsetAlignment = 256;
caps.maxCombinedUniformBlocks = 24;
caps.maxCombinedVertexUniformComponents =
caps.maxShaderUniformBlocks[ShaderType::Vertex] * (caps.maxUniformBlockSize / 4) +
caps.maxVertexUniformComponents;
caps.maxCombinedFragmentUniformComponents =
caps.maxShaderUniformBlocks[ShaderType::Fragment] * (caps.maxUniformBlockSize / 4) +
caps.maxFragmentUniformComponents;
caps.maxVaryingComponents = 60;
caps.maxVaryingVectors = 15;
caps.maxCombinedTextureImageUnits = 32;
......@@ -1173,17 +1151,17 @@ Caps GenerateMinimumCaps(const Version &clientVersion, const Extensions &extensi
caps.maxVertexAttribStride = 2048;
// Table 20.43
caps.maxVertexAtomicCounterBuffers = 0;
caps.maxVertexAtomicCounters = 0;
caps.maxVertexImageUniforms = 0;
caps.maxShaderAtomicCounterBuffers[ShaderType::Vertex] = 0;
caps.maxShaderAtomicCounters[ShaderType::Vertex] = 0;
caps.maxShaderImageUniforms[ShaderType::Vertex] = 0;
caps.maxShaderStorageBlocks[ShaderType::Vertex] = 0;
// Table 20.44
caps.maxFragmentUniformComponents = 1024;
caps.maxShaderUniformComponents[ShaderType::Fragment] = 1024;
caps.maxFragmentUniformVectors = 256;
caps.maxFragmentAtomicCounterBuffers = 0;
caps.maxFragmentAtomicCounters = 0;
caps.maxFragmentImageUniforms = 0;
caps.maxShaderAtomicCounterBuffers[ShaderType::Fragment] = 0;
caps.maxShaderAtomicCounters[ShaderType::Fragment] = 0;
caps.maxShaderImageUniforms[ShaderType::Fragment] = 0;
caps.maxShaderStorageBlocks[ShaderType::Fragment] = 0;
caps.minProgramTextureGatherOffset = 0;
caps.maxProgramTextureGatherOffset = 0;
......@@ -1195,21 +1173,14 @@ Caps GenerateMinimumCaps(const Version &clientVersion, const Extensions &extensi
caps.maxShaderUniformBlocks[ShaderType::Compute] = 12;
caps.maxShaderTextureImageUnits[ShaderType::Compute] = 16;
caps.maxComputeSharedMemorySize = 16384;
caps.maxComputeUniformComponents = 1024;
caps.maxComputeAtomicCounterBuffers = 1;
caps.maxComputeAtomicCounters = 8;
caps.maxComputeImageUniforms = 4;
caps.maxCombinedComputeUniformComponents =
caps.maxShaderUniformBlocks[ShaderType::Compute] *
static_cast<GLuint>(caps.maxUniformBlockSize / 4) +
caps.maxComputeUniformComponents;
caps.maxShaderUniformComponents[ShaderType::Compute] = 1024;
caps.maxShaderAtomicCounterBuffers[ShaderType::Compute] = 1;
caps.maxShaderAtomicCounters[ShaderType::Compute] = 8;
caps.maxShaderImageUniforms[ShaderType::Compute] = 4;
caps.maxShaderStorageBlocks[ShaderType::Compute] = 4;
// Table 20.46
caps.maxUniformBufferBindings = 36;
caps.maxCombinedFragmentUniformComponents =
caps.maxShaderUniformBlocks[ShaderType::Fragment] * (caps.maxUniformBlockSize / 4) +
caps.maxFragmentUniformComponents;
caps.maxCombinedTextureImageUnits = 48;
caps.maxCombinedShaderOutputResources = 4;
......@@ -1239,24 +1210,20 @@ Caps GenerateMinimumCaps(const Version &clientVersion, const Extensions &extensi
caps.layerProvokingVertex = GL_LAST_VERTEX_CONVENTION_EXT;
// Table 20.43gs (GL_EXT_geometry_shader)
caps.maxGeometryUniformComponents = 1024;
caps.maxShaderUniformComponents[ShaderType::Geometry] = 1024;
caps.maxShaderUniformBlocks[ShaderType::Geometry] = 12;
caps.maxGeometryInputComponents = 64;
caps.maxGeometryOutputComponents = 64;
caps.maxGeometryOutputVertices = 256;
caps.maxGeometryTotalOutputComponents = 1024;
caps.maxShaderTextureImageUnits[ShaderType::Geometry] = 16;
caps.maxGeometryAtomicCounterBuffers = 0;
caps.maxGeometryAtomicCounters = 0;
caps.maxShaderAtomicCounterBuffers[ShaderType::Geometry] = 0;
caps.maxShaderAtomicCounters[ShaderType::Geometry] = 0;
caps.maxShaderStorageBlocks[ShaderType::Geometry] = 0;
caps.maxGeometryShaderInvocations = 32;
// Table 20.46 (GL_EXT_geometry_shader)
caps.maxGeometryImageUniforms = 0;
caps.maxCombinedGeometryUniformComponents =
caps.maxShaderUniformBlocks[ShaderType::Geometry] *
static_cast<GLuint>(caps.maxUniformBlockSize / 4) +
caps.maxGeometryUniformComponents;
caps.maxShaderImageUniforms[ShaderType::Geometry] = 0;
// Table 20.46 (GL_EXT_geometry_shader)
caps.maxUniformBufferBindings = 48;
......@@ -1264,6 +1231,14 @@ Caps GenerateMinimumCaps(const Version &clientVersion, const Extensions &extensi
caps.maxCombinedTextureImageUnits = 64;
}
for (ShaderType shaderType : AllShaderTypes())
{
caps.maxCombinedShaderUniformComponents[shaderType] =
caps.maxShaderUniformBlocks[shaderType] *
static_cast<GLuint>(caps.maxUniformBlockSize / 4) +
caps.maxShaderUniformComponents[shaderType];
}
return caps;
}
}
......
......@@ -537,26 +537,29 @@ struct Caps
// ES 3.1 (April 29, 2015) Table 20.45: implementation dependent compute shader limits
// GL_EXT_geometry_shader (May 31, 2016) Table 20.43gs: Implementation dependent geometry shader
// limits
// GL_EXT_geometry_shader (May 31, 2016) Table 20.46: Implementation dependent aggregate shader
// limits
ShaderMap<GLuint> maxShaderUniformBlocks;
ShaderMap<GLuint> maxShaderTextureImageUnits;
ShaderMap<GLuint> maxShaderStorageBlocks;
ShaderMap<GLuint> maxShaderUniformComponents;
ShaderMap<GLuint> maxShaderAtomicCounterBuffers;
ShaderMap<GLuint> maxShaderAtomicCounters;
ShaderMap<GLuint> maxShaderImageUniforms;
// Note that we can query MAX_COMPUTE_UNIFORM_COMPONENTS and MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT
// by GetIntegerv, but we can only use GetInteger64v on MAX_VERTEX_UNIFORM_COMPONENTS and
// MAX_FRAGMENT_UNIFORM_COMPONENTS. Currently we use GLuint64 to store all these values so that
// we can put them together into one ShaderMap.
ShaderMap<GLuint64> maxCombinedShaderUniformComponents;
// ES 3.1 (April 29, 2015) Table 20.43: Implementation dependent Vertex shader limits
GLuint maxVertexAttributes;
GLuint maxVertexUniformComponents;
GLuint maxVertexUniformVectors;
GLuint maxVertexOutputComponents;
GLuint maxVertexAtomicCounterBuffers;
GLuint maxVertexAtomicCounters;
GLuint maxVertexImageUniforms;
// ES 3.1 (April 29, 2015) Table 20.44: Implementation dependent Fragment shader limits
GLuint maxFragmentUniformComponents;
GLuint maxFragmentUniformVectors;
GLuint maxFragmentInputComponents;
GLuint maxFragmentAtomicCounterBuffers;
GLuint maxFragmentAtomicCounters;
GLuint maxFragmentImageUniforms;
GLint minProgramTextureGatherOffset;
GLuint maxProgramTextureGatherOffset;
GLint minProgramTexelOffset;
......@@ -567,19 +570,12 @@ struct Caps
std::array<GLuint, 3> maxComputeWorkGroupSize;
GLuint maxComputeWorkGroupInvocations;
GLuint maxComputeSharedMemorySize;
GLuint maxComputeUniformComponents;
GLuint maxComputeAtomicCounterBuffers;
GLuint maxComputeAtomicCounters;
GLuint maxComputeImageUniforms;
GLuint maxCombinedComputeUniformComponents;
// ES 3.1 (April 29, 2015) Table 20.46: implementation dependent aggregate shader limits
GLuint maxUniformBufferBindings;
GLuint64 maxUniformBlockSize;
GLuint uniformBufferOffsetAlignment;
GLuint maxCombinedUniformBlocks;
GLuint64 maxCombinedVertexUniformComponents;
GLuint64 maxCombinedFragmentUniformComponents;
GLuint maxVaryingComponents;
GLuint maxVaryingVectors;
GLuint maxCombinedTextureImageUnits;
......@@ -612,20 +608,12 @@ struct Caps
// GL_EXT_geometry_shader (May 31, 2016) Table 20.43gs: Implementation dependent geometry shader
// limits
GLuint maxGeometryUniformComponents;
GLuint maxGeometryInputComponents;
GLuint maxGeometryOutputComponents;
GLuint maxGeometryOutputVertices;
GLuint maxGeometryTotalOutputComponents;
GLuint maxGeometryAtomicCounterBuffers;
GLuint maxGeometryAtomicCounters;
GLuint maxGeometryShaderInvocations;
// GL_EXT_geometry_shader (May 31, 2016) Table 20.46: Implementation dependent aggregate shader
// limits
GLuint maxGeometryImageUniforms;
GLuint maxCombinedGeometryUniformComponents;
// GLES1 emulation: Caps for ES 1.1. Taken from Table 6.20 / 6.22 in the OpenGL ES 1.1 spec.
GLuint maxMultitextureUnits;
GLuint maxClipPlanes;
......
......@@ -97,9 +97,9 @@ Compiler::Compiler(rx::GLImplFactory *implFactory, const ContextState &state)
mResources.MaxProgramTextureGatherOffset = caps.maxProgramTextureGatherOffset;
mResources.MinProgramTextureGatherOffset = caps.minProgramTextureGatherOffset;
mResources.MaxImageUnits = caps.maxImageUnits;
mResources.MaxVertexImageUniforms = caps.maxVertexImageUniforms;
mResources.MaxFragmentImageUniforms = caps.maxFragmentImageUniforms;
mResources.MaxComputeImageUniforms = caps.maxComputeImageUniforms;
mResources.MaxVertexImageUniforms = caps.maxShaderImageUniforms[ShaderType::Vertex];
mResources.MaxFragmentImageUniforms = caps.maxShaderImageUniforms[ShaderType::Fragment];
mResources.MaxComputeImageUniforms = caps.maxShaderImageUniforms[ShaderType::Compute];
mResources.MaxCombinedImageUniforms = caps.maxCombinedImageUniforms;
mResources.MaxCombinedShaderOutputResources = caps.maxCombinedShaderOutputResources;
mResources.MaxUniformLocations = caps.maxUniformLocations;
......@@ -110,18 +110,21 @@ Compiler::Compiler(rx::GLImplFactory *implFactory, const ContextState &state)
mResources.MaxComputeWorkGroupSize[index] = caps.maxComputeWorkGroupSize[index];
}
mResources.MaxComputeUniformComponents = caps.maxComputeUniformComponents;
mResources.MaxComputeUniformComponents = caps.maxShaderUniformComponents[ShaderType::Compute];
mResources.MaxComputeTextureImageUnits = caps.maxShaderTextureImageUnits[ShaderType::Compute];
mResources.MaxComputeAtomicCounters = caps.maxComputeAtomicCounters;
mResources.MaxComputeAtomicCounterBuffers = caps.maxComputeAtomicCounterBuffers;
mResources.MaxComputeAtomicCounters = caps.maxShaderAtomicCounters[ShaderType::Compute];
mResources.MaxComputeAtomicCounterBuffers =
caps.maxShaderAtomicCounterBuffers[ShaderType::Compute];
mResources.MaxVertexAtomicCounters = caps.maxVertexAtomicCounters;
mResources.MaxFragmentAtomicCounters = caps.maxFragmentAtomicCounters;
mResources.MaxVertexAtomicCounters = caps.maxShaderAtomicCounters[ShaderType::Vertex];
mResources.MaxFragmentAtomicCounters = caps.maxShaderAtomicCounters[ShaderType::Fragment];
mResources.MaxCombinedAtomicCounters = caps.maxCombinedAtomicCounters;
mResources.MaxAtomicCounterBindings = caps.maxAtomicCounterBufferBindings;
mResources.MaxVertexAtomicCounterBuffers = caps.maxVertexAtomicCounterBuffers;
mResources.MaxFragmentAtomicCounterBuffers = caps.maxFragmentAtomicCounterBuffers;
mResources.MaxVertexAtomicCounterBuffers =
caps.maxShaderAtomicCounterBuffers[ShaderType::Vertex];
mResources.MaxFragmentAtomicCounterBuffers =
caps.maxShaderAtomicCounterBuffers[ShaderType::Fragment];
mResources.MaxCombinedAtomicCounterBuffers = caps.maxCombinedAtomicCounterBuffers;
mResources.MaxAtomicCounterBufferSize = caps.maxAtomicCounterBufferSize;
......@@ -138,18 +141,20 @@ Compiler::Compiler(rx::GLImplFactory *implFactory, const ContextState &state)
// Geometry Shader constants
mResources.EXT_geometry_shader = extensions.geometryShader;
mResources.MaxGeometryUniformComponents = caps.maxGeometryUniformComponents;
mResources.MaxGeometryUniformComponents = caps.maxShaderUniformComponents[ShaderType::Geometry];
mResources.MaxGeometryUniformBlocks = caps.maxShaderUniformBlocks[ShaderType::Geometry];
mResources.MaxGeometryInputComponents = caps.maxGeometryInputComponents;
mResources.MaxGeometryOutputComponents = caps.maxGeometryOutputComponents;
mResources.MaxGeometryOutputVertices = caps.maxGeometryOutputVertices;
mResources.MaxGeometryTotalOutputComponents = caps.maxGeometryTotalOutputComponents;
mResources.MaxGeometryTextureImageUnits = caps.maxShaderTextureImageUnits[ShaderType::Geometry];
mResources.MaxGeometryAtomicCounterBuffers = caps.maxGeometryAtomicCounterBuffers;
mResources.MaxGeometryAtomicCounters = caps.maxGeometryAtomicCounters;
mResources.MaxGeometryShaderStorageBlocks = caps.maxShaderStorageBlocks[ShaderType::Geometry];
mResources.MaxGeometryShaderInvocations = caps.maxGeometryShaderInvocations;
mResources.MaxGeometryImageUniforms = caps.maxGeometryImageUniforms;
mResources.MaxGeometryAtomicCounterBuffers =
caps.maxShaderAtomicCounterBuffers[ShaderType::Geometry];
mResources.MaxGeometryAtomicCounters = caps.maxShaderAtomicCounters[ShaderType::Geometry];
mResources.MaxGeometryShaderStorageBlocks = caps.maxShaderStorageBlocks[ShaderType::Geometry];
mResources.MaxGeometryShaderInvocations = caps.maxGeometryShaderInvocations;
mResources.MaxGeometryImageUniforms = caps.maxShaderImageUniforms[ShaderType::Geometry];
}
Compiler::~Compiler()
......
......@@ -1341,7 +1341,7 @@ void Context::getIntegervImpl(GLenum pname, GLint *params)
*params = mCaps.maxVertexUniformVectors;
break;
case GL_MAX_VERTEX_UNIFORM_COMPONENTS:
*params = mCaps.maxVertexUniformComponents;
*params = mCaps.maxShaderUniformComponents[ShaderType::Vertex];
break;
case GL_MAX_VARYING_VECTORS:
*params = mCaps.maxVaryingVectors;
......@@ -1362,7 +1362,7 @@ void Context::getIntegervImpl(GLenum pname, GLint *params)
*params = mCaps.maxFragmentUniformVectors;
break;
case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS:
*params = mCaps.maxFragmentUniformComponents;
*params = mCaps.maxShaderUniformComponents[ShaderType::Fragment];
break;
case GL_MAX_RENDERBUFFER_SIZE:
*params = mCaps.maxRenderbufferSize;
......@@ -1530,25 +1530,25 @@ void Context::getIntegervImpl(GLenum pname, GLint *params)
*params = mCaps.maxVertexAttribStride;
break;
case GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS:
*params = mCaps.maxVertexAtomicCounterBuffers;
*params = mCaps.maxShaderAtomicCounterBuffers[ShaderType::Vertex];
break;
case GL_MAX_VERTEX_ATOMIC_COUNTERS:
*params = mCaps.maxVertexAtomicCounters;
*params = mCaps.maxShaderAtomicCounters[ShaderType::Vertex];
break;
case GL_MAX_VERTEX_IMAGE_UNIFORMS:
*params = mCaps.maxVertexImageUniforms;
*params = mCaps.maxShaderImageUniforms[ShaderType::Vertex];
break;
case GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS:
*params = mCaps.maxShaderStorageBlocks[ShaderType::Vertex];
break;
case GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS:
*params = mCaps.maxFragmentAtomicCounterBuffers;
*params = mCaps.maxShaderAtomicCounterBuffers[ShaderType::Fragment];
break;
case GL_MAX_FRAGMENT_ATOMIC_COUNTERS:
*params = mCaps.maxFragmentAtomicCounters;
*params = mCaps.maxShaderAtomicCounters[ShaderType::Fragment];
break;
case GL_MAX_FRAGMENT_IMAGE_UNIFORMS:
*params = mCaps.maxFragmentImageUniforms;
*params = mCaps.maxShaderImageUniforms[ShaderType::Fragment];
break;
case GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS:
*params = mCaps.maxShaderStorageBlocks[ShaderType::Fragment];
......@@ -1572,19 +1572,20 @@ void Context::getIntegervImpl(GLenum pname, GLint *params)
*params = mCaps.maxComputeSharedMemorySize;
break;
case GL_MAX_COMPUTE_UNIFORM_COMPONENTS:
*params = mCaps.maxComputeUniformComponents;
*params = mCaps.maxShaderUniformComponents[ShaderType::Compute];
break;
case GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS:
*params = mCaps.maxComputeAtomicCounterBuffers;
*params = mCaps.maxShaderAtomicCounterBuffers[ShaderType::Compute];
break;
case GL_MAX_COMPUTE_ATOMIC_COUNTERS:
*params = mCaps.maxComputeAtomicCounters;
*params = mCaps.maxShaderAtomicCounters[ShaderType::Compute];
break;
case GL_MAX_COMPUTE_IMAGE_UNIFORMS:
*params = mCaps.maxComputeImageUniforms;
*params = mCaps.maxShaderImageUniforms[ShaderType::Compute];
break;
case GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS:
*params = mCaps.maxCombinedComputeUniformComponents;
*params =
static_cast<GLint>(mCaps.maxCombinedShaderUniformComponents[ShaderType::Compute]);
break;
case GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS:
*params = mCaps.maxShaderStorageBlocks[ShaderType::Compute];
......@@ -1631,13 +1632,14 @@ void Context::getIntegervImpl(GLenum pname, GLint *params)
*params = mCaps.layerProvokingVertex;
break;
case GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT:
*params = mCaps.maxGeometryUniformComponents;
*params = mCaps.maxShaderUniformComponents[ShaderType::Geometry];
break;
case GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT:
*params = mCaps.maxShaderUniformBlocks[ShaderType::Geometry];
break;
case GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT:
*params = mCaps.maxCombinedGeometryUniformComponents;
*params =
static_cast<GLint>(mCaps.maxCombinedShaderUniformComponents[ShaderType::Geometry]);
break;
case GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT:
*params = mCaps.maxGeometryInputComponents;
......@@ -1658,13 +1660,13 @@ void Context::getIntegervImpl(GLenum pname, GLint *params)
*params = mCaps.maxShaderTextureImageUnits[ShaderType::Geometry];
break;
case GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT:
*params = mCaps.maxGeometryAtomicCounterBuffers;
*params = mCaps.maxShaderAtomicCounterBuffers[ShaderType::Geometry];
break;
case GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT:
*params = mCaps.maxGeometryAtomicCounters;
*params = mCaps.maxShaderAtomicCounters[ShaderType::Geometry];
break;
case GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT:
*params = mCaps.maxGeometryImageUniforms;
*params = mCaps.maxShaderImageUniforms[ShaderType::Geometry];
break;
case GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT:
*params = mCaps.maxShaderStorageBlocks[ShaderType::Geometry];
......@@ -1736,10 +1738,10 @@ void Context::getInteger64vImpl(GLenum pname, GLint64 *params)
*params = mCaps.maxUniformBlockSize;
break;
case GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS:
*params = mCaps.maxCombinedVertexUniformComponents;
*params = mCaps.maxCombinedShaderUniformComponents[ShaderType::Vertex];
break;
case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS:
*params = mCaps.maxCombinedFragmentUniformComponents;
*params = mCaps.maxCombinedShaderUniformComponents[ShaderType::Fragment];
break;
case GL_MAX_SERVER_WAIT_TIMEOUT:
*params = mCaps.maxServerWaitTimeout;
......
......@@ -84,14 +84,7 @@ class UniformLinker final : angle::NonCopyable
bool flattenUniformsAndCheckCapsForShader(const Context *context,
Shader *shader,
GLuint maxUniformComponents,
GLuint maxTextureImageUnits,
GLuint maxImageUnits,
GLuint maxAtomicCounters,
const std::string &componentsErrorMessage,
const std::string &samplerErrorMessage,
const std::string &imageErrorMessage,
const std::string &atomicCounterErrorMessage,
const Caps &caps,
std::vector<LinkedUniform> &samplerUniforms,
std::vector<LinkedUniform> &imageUniforms,
std::vector<LinkedUniform> &atomicCounterUniforms,
......
......@@ -958,8 +958,10 @@ void SetUAVRelatedResourceLimits(D3D_FEATURE_LEVEL featureLevel, gl::Caps *caps)
// Set limits on atomic counter buffers in fragment shaders and compute shaders.
caps->maxCombinedAtomicCounterBuffers = reservedUAVsForAtomicCounterBuffers;
caps->maxComputeAtomicCounterBuffers = reservedUAVsForAtomicCounterBuffers;
caps->maxFragmentAtomicCounterBuffers = reservedUAVsForAtomicCounterBuffers;
caps->maxShaderAtomicCounterBuffers[gl::ShaderType::Compute] =
reservedUAVsForAtomicCounterBuffers;
caps->maxShaderAtomicCounterBuffers[gl::ShaderType::Fragment] =
reservedUAVsForAtomicCounterBuffers;
caps->maxAtomicCounterBufferBindings = reservedUAVsForAtomicCounterBuffers;
// Allocate the remaining slots for images and shader storage blocks.
......@@ -976,19 +978,23 @@ void SetUAVRelatedResourceLimits(D3D_FEATURE_LEVEL featureLevel, gl::Caps *caps)
caps->maxImageUnits = caps->maxCombinedShaderOutputResources;
caps->maxCombinedImageUniforms = caps->maxCombinedShaderOutputResources;
caps->maxComputeImageUniforms = caps->maxCombinedShaderOutputResources;
caps->maxFragmentImageUniforms = caps->maxCombinedShaderOutputResources;
caps->maxShaderImageUniforms[gl::ShaderType::Compute] = caps->maxCombinedShaderOutputResources;
caps->maxShaderImageUniforms[gl::ShaderType::Fragment] = caps->maxCombinedShaderOutputResources;
// On feature level 11_1, UAVs are also available in vertex shaders and geometry shaders.
if (featureLevel == D3D_FEATURE_LEVEL_11_1)
{
caps->maxVertexAtomicCounterBuffers = caps->maxCombinedAtomicCounterBuffers;
caps->maxGeometryAtomicCounterBuffers = caps->maxCombinedAtomicCounterBuffers;
caps->maxShaderAtomicCounterBuffers[gl::ShaderType::Vertex] =
caps->maxCombinedAtomicCounterBuffers;
caps->maxShaderAtomicCounterBuffers[gl::ShaderType::Geometry] =
caps->maxCombinedAtomicCounterBuffers;
caps->maxVertexImageUniforms = caps->maxCombinedShaderOutputResources;
caps->maxShaderImageUniforms[gl::ShaderType::Vertex] =
caps->maxCombinedShaderOutputResources;
caps->maxShaderStorageBlocks[gl::ShaderType::Vertex] =
caps->maxCombinedShaderOutputResources;
caps->maxGeometryImageUniforms = caps->maxCombinedShaderOutputResources;
caps->maxShaderImageUniforms[gl::ShaderType::Geometry] =
caps->maxCombinedShaderOutputResources;
caps->maxShaderStorageBlocks[gl::ShaderType::Geometry] =
caps->maxCombinedShaderOutputResources;
}
......@@ -1392,7 +1398,7 @@ void GenerateCaps(ID3D11Device *device,
{
caps->maxVertexUniformVectors -= 1;
}
caps->maxVertexUniformComponents = caps->maxVertexUniformVectors * 4;
caps->maxShaderUniformComponents[gl::ShaderType::Vertex] = caps->maxVertexUniformVectors * 4;
caps->maxShaderUniformBlocks[gl::ShaderType::Vertex] =
static_cast<GLuint>(GetMaximumVertexUniformBlocks(featureLevel));
caps->maxVertexOutputComponents =
......@@ -1411,7 +1417,8 @@ void GenerateCaps(ID3D11Device *device,
// Fragment shader limits
caps->maxFragmentUniformVectors =
static_cast<GLuint>(GetMaximumPixelUniformVectors(featureLevel));
caps->maxFragmentUniformComponents = caps->maxFragmentUniformVectors * 4;
caps->maxShaderUniformComponents[gl::ShaderType::Fragment] =
caps->maxFragmentUniformVectors * 4;
caps->maxShaderUniformBlocks[gl::ShaderType::Fragment] =
static_cast<GLuint>(GetMaximumPixelUniformBlocks(featureLevel));
caps->maxFragmentInputComponents =
......@@ -1426,7 +1433,7 @@ void GenerateCaps(ID3D11Device *device,
caps->maxComputeWorkGroupSize = GetMaxComputeWorkGroupSize(featureLevel);
caps->maxComputeWorkGroupInvocations =
static_cast<GLuint>(GetMaxComputeWorkGroupInvocations(featureLevel));
caps->maxComputeUniformComponents =
caps->maxShaderUniformComponents[gl::ShaderType::Compute] =
static_cast<GLuint>(GetMaximumComputeUniformVectors(featureLevel)) * 4;
caps->maxShaderUniformBlocks[gl::ShaderType::Compute] =
static_cast<GLuint>(GetMaximumComputeUniformBlocks(featureLevel));
......@@ -1451,17 +1458,15 @@ void GenerateCaps(ID3D11Device *device,
caps->maxCombinedUniformBlocks = caps->maxShaderUniformBlocks[gl::ShaderType::Vertex] +
caps->maxShaderUniformBlocks[gl::ShaderType::Fragment];
caps->maxCombinedVertexUniformComponents =
(static_cast<GLint64>(caps->maxShaderUniformBlocks[gl::ShaderType::Vertex]) *
static_cast<GLint64>(caps->maxUniformBlockSize / 4)) +
static_cast<GLint64>(caps->maxVertexUniformComponents);
caps->maxCombinedFragmentUniformComponents =
(static_cast<GLint64>(caps->maxShaderUniformBlocks[gl::ShaderType::Fragment]) *
static_cast<GLint64>(caps->maxUniformBlockSize / 4)) +
static_cast<GLint64>(caps->maxFragmentUniformComponents);
caps->maxCombinedComputeUniformComponents = static_cast<GLuint>(
caps->maxShaderUniformBlocks[gl::ShaderType::Compute] * (caps->maxUniformBlockSize / 4) +
caps->maxComputeUniformComponents);
for (gl::ShaderType shaderType : gl::AllShaderTypes())
{
caps->maxCombinedShaderUniformComponents[shaderType] =
static_cast<GLint64>(caps->maxShaderUniformBlocks[shaderType]) *
static_cast<GLint64>(caps->maxUniformBlockSize / 4) +
static_cast<GLint64>(caps->maxShaderUniformComponents[shaderType]);
}
caps->maxVaryingComponents =
static_cast<GLuint>(GetMaximumVertexOutputVectors(featureLevel)) * 4;
caps->maxVaryingVectors = static_cast<GLuint>(GetMaximumVertexOutputVectors(featureLevel));
......
......@@ -478,7 +478,7 @@ void GenerateCaps(IDirect3D9 *d3d9,
const size_t MAX_VERTEX_CONSTANT_VECTORS_D3D9 = 256;
caps->maxVertexUniformVectors =
MAX_VERTEX_CONSTANT_VECTORS_D3D9 - GetReservedVertexUniformVectors();
caps->maxVertexUniformComponents = caps->maxVertexUniformVectors * 4;
caps->maxShaderUniformComponents[gl::ShaderType::Vertex] = caps->maxVertexUniformVectors * 4;
caps->maxShaderUniformBlocks[gl::ShaderType::Vertex] = 0;
......@@ -509,7 +509,8 @@ void GenerateCaps(IDirect3D9 *d3d9,
((deviceCaps.PixelShaderVersion >= D3DPS_VERSION(3, 0)) ? MAX_PIXEL_CONSTANT_VECTORS_SM3
: MAX_PIXEL_CONSTANT_VECTORS_SM2) -
GetReservedFragmentUniformVectors();
caps->maxFragmentUniformComponents = caps->maxFragmentUniformVectors * 4;
caps->maxShaderUniformComponents[gl::ShaderType::Fragment] =
caps->maxFragmentUniformVectors * 4;
caps->maxShaderUniformBlocks[gl::ShaderType::Fragment] = 0;
caps->maxFragmentInputComponents = caps->maxVertexOutputComponents;
caps->maxShaderTextureImageUnits[gl::ShaderType::Fragment] = 16;
......@@ -521,8 +522,8 @@ void GenerateCaps(IDirect3D9 *d3d9,
caps->maxUniformBlockSize = 0;
caps->uniformBufferOffsetAlignment = 0;
caps->maxCombinedUniformBlocks = 0;
caps->maxCombinedVertexUniformComponents = 0;
caps->maxCombinedFragmentUniformComponents = 0;
caps->maxCombinedShaderUniformComponents[gl::ShaderType::Vertex] = 0;
caps->maxCombinedShaderUniformComponents[gl::ShaderType::Fragment] = 0;
caps->maxVaryingComponents = 0;
// Aggregate shader limits
......
......@@ -442,7 +442,8 @@ void GenerateCaps(const FunctionsGL *functions,
functions->isAtLeastGLES(gl::Version(2, 0)))
{
caps->maxVertexAttributes = QuerySingleGLInt(functions, GL_MAX_VERTEX_ATTRIBS);
caps->maxVertexUniformComponents = QuerySingleGLInt(functions, GL_MAX_VERTEX_UNIFORM_COMPONENTS);
caps->maxShaderUniformComponents[gl::ShaderType::Vertex] =
QuerySingleGLInt(functions, GL_MAX_VERTEX_UNIFORM_COMPONENTS);
caps->maxShaderTextureImageUnits[gl::ShaderType::Vertex] =
QuerySingleGLInt(functions, GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS);
}
......@@ -462,9 +463,11 @@ void GenerateCaps(const FunctionsGL *functions,
else
{
// Doesn't limit ES version, GL_MAX_VERTEX_UNIFORM_COMPONENTS / 4 is acceptable.
caps->maxVertexUniformVectors = caps->maxVertexUniformComponents / 4;
caps->maxVertexUniformVectors =
caps->maxShaderUniformComponents[gl::ShaderType::Vertex] / 4;
// Doesn't limit ES version, GL_MAX_FRAGMENT_UNIFORM_COMPONENTS / 4 is acceptable.
caps->maxFragmentUniformVectors = caps->maxFragmentUniformComponents / 4;
caps->maxFragmentUniformVectors =
caps->maxShaderUniformComponents[gl::ShaderType::Fragment] / 4;
}
if (functions->isAtLeastGL(gl::Version(3, 2)) ||
......@@ -483,7 +486,8 @@ void GenerateCaps(const FunctionsGL *functions,
if (functions->isAtLeastGL(gl::Version(2, 0)) ||
functions->isAtLeastGLES(gl::Version(2, 0)))
{
caps->maxFragmentUniformComponents = QuerySingleGLInt(functions, GL_MAX_FRAGMENT_UNIFORM_COMPONENTS);
caps->maxShaderUniformComponents[gl::ShaderType::Fragment] =
QuerySingleGLInt(functions, GL_MAX_FRAGMENT_UNIFORM_COMPONENTS);
caps->maxShaderTextureImageUnits[gl::ShaderType::Fragment] =
QuerySingleGLInt(functions, GL_MAX_TEXTURE_IMAGE_UNITS);
}
......@@ -537,8 +541,10 @@ void GenerateCaps(const FunctionsGL *functions,
maxCombinedUniformBlocks, caps->maxShaderUniformBlocks[gl::ShaderType::Vertex] +
caps->maxShaderUniformBlocks[gl::ShaderType::Fragment]);
caps->maxCombinedVertexUniformComponents = QuerySingleGLInt64(functions, GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS);
caps->maxCombinedFragmentUniformComponents = QuerySingleGLInt64(functions, GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS);
caps->maxCombinedShaderUniformComponents[gl::ShaderType::Vertex] =
QuerySingleGLInt64(functions, GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS);
caps->maxCombinedShaderUniformComponents[gl::ShaderType::Fragment] =
QuerySingleGLInt64(functions, GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS);
}
else
{
......@@ -756,14 +762,15 @@ void GenerateCaps(const FunctionsGL *functions,
QuerySingleGLInt(functions, GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS);
caps->maxComputeSharedMemorySize =
QuerySingleGLInt(functions, GL_MAX_COMPUTE_SHARED_MEMORY_SIZE);
caps->maxComputeUniformComponents =
caps->maxShaderUniformComponents[gl::ShaderType::Compute] =
QuerySingleGLInt(functions, GL_MAX_COMPUTE_UNIFORM_COMPONENTS);
caps->maxComputeAtomicCounterBuffers =
caps->maxShaderAtomicCounterBuffers[gl::ShaderType::Compute] =
QuerySingleGLInt(functions, GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS);
caps->maxComputeAtomicCounters =
caps->maxShaderAtomicCounters[gl::ShaderType::Compute] =
QuerySingleGLInt(functions, GL_MAX_COMPUTE_ATOMIC_COUNTERS);
caps->maxComputeImageUniforms = QuerySingleGLInt(functions, GL_MAX_COMPUTE_IMAGE_UNIFORMS);
caps->maxCombinedComputeUniformComponents =
caps->maxShaderImageUniforms[gl::ShaderType::Compute] =
QuerySingleGLInt(functions, GL_MAX_COMPUTE_IMAGE_UNIFORMS);
caps->maxCombinedShaderUniformComponents[gl::ShaderType::Compute] =
QuerySingleGLInt(functions, GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS);
caps->maxShaderStorageBlocks[gl::ShaderType::Compute] =
QuerySingleGLInt(functions, GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS);
......@@ -799,8 +806,9 @@ void GenerateCaps(const FunctionsGL *functions,
if (functions->isAtLeastGL(gl::Version(4, 2)) || functions->isAtLeastGLES(gl::Version(3, 1)) ||
functions->hasGLExtension("GL_ARB_shader_image_load_store"))
{
caps->maxVertexImageUniforms = QuerySingleGLInt(functions, GL_MAX_VERTEX_IMAGE_UNIFORMS);
caps->maxFragmentImageUniforms =
caps->maxShaderImageUniforms[gl::ShaderType::Vertex] =
QuerySingleGLInt(functions, GL_MAX_VERTEX_IMAGE_UNIFORMS);
caps->maxShaderImageUniforms[gl::ShaderType::Fragment] =
QuerySingleGLInt(functions, GL_MAX_FRAGMENT_IMAGE_UNIFORMS);
caps->maxImageUnits = QuerySingleGLInt(functions, GL_MAX_IMAGE_UNITS);
caps->maxCombinedImageUniforms =
......@@ -814,12 +822,13 @@ void GenerateCaps(const FunctionsGL *functions,
if (functions->isAtLeastGL(gl::Version(4, 2)) || functions->isAtLeastGLES(gl::Version(3, 1)) ||
functions->hasGLExtension("GL_ARB_shader_atomic_counters"))
{
caps->maxVertexAtomicCounterBuffers =
caps->maxShaderAtomicCounterBuffers[gl::ShaderType::Vertex] =
QuerySingleGLInt(functions, GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS);
caps->maxVertexAtomicCounters = QuerySingleGLInt(functions, GL_MAX_VERTEX_ATOMIC_COUNTERS);
caps->maxFragmentAtomicCounterBuffers =
caps->maxShaderAtomicCounters[gl::ShaderType::Vertex] =
QuerySingleGLInt(functions, GL_MAX_VERTEX_ATOMIC_COUNTERS);
caps->maxShaderAtomicCounterBuffers[gl::ShaderType::Fragment] =
QuerySingleGLInt(functions, GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS);
caps->maxFragmentAtomicCounters =
caps->maxShaderAtomicCounters[gl::ShaderType::Fragment] =
QuerySingleGLInt(functions, GL_MAX_FRAGMENT_ATOMIC_COUNTERS);
caps->maxAtomicCounterBufferBindings =
QuerySingleGLInt(functions, GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS);
......@@ -839,11 +848,13 @@ void GenerateCaps(const FunctionsGL *functions,
// if the max uniform vectors is too large. Artificially limit the maximum until the test is
// updated.
caps->maxVertexUniformVectors = std::min(1024u, caps->maxVertexUniformVectors);
caps->maxVertexUniformComponents =
std::min(caps->maxVertexUniformVectors * 4, caps->maxVertexUniformComponents);
caps->maxShaderUniformComponents[gl::ShaderType::Vertex] =
std::min(caps->maxVertexUniformVectors * 4,
caps->maxShaderUniformComponents[gl::ShaderType::Vertex]);
caps->maxFragmentUniformVectors = std::min(1024u, caps->maxFragmentUniformVectors);
caps->maxFragmentUniformComponents =
std::min(caps->maxFragmentUniformVectors * 4, caps->maxFragmentUniformComponents);
caps->maxShaderUniformComponents[gl::ShaderType::Fragment] =
std::min(caps->maxFragmentUniformVectors * 4,
caps->maxShaderUniformComponents[gl::ShaderType::Fragment]);
// If it is not possible to support reading buffer data back, a shadow copy of the buffers must
// be held. This disallows writing to buffers indirectly through transform feedback, thus
......@@ -1061,11 +1072,11 @@ void GenerateCaps(const FunctionsGL *functions,
caps->layerProvokingVertex = GL_LAST_VERTEX_CONVENTION_EXT;
}
caps->maxGeometryUniformComponents =
caps->maxShaderUniformComponents[gl::ShaderType::Geometry] =
QuerySingleGLInt(functions, GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT);
caps->maxShaderUniformBlocks[gl::ShaderType::Geometry] =
QuerySingleGLInt(functions, GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT);
caps->maxCombinedGeometryUniformComponents =
caps->maxCombinedShaderUniformComponents[gl::ShaderType::Geometry] =
QuerySingleGLInt(functions, GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT);
caps->maxGeometryInputComponents =
QuerySingleGLInt(functions, GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT);
......@@ -1079,11 +1090,11 @@ void GenerateCaps(const FunctionsGL *functions,
QuerySingleGLInt(functions, GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT);
caps->maxShaderTextureImageUnits[gl::ShaderType::Geometry] =
QuerySingleGLInt(functions, GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT);
caps->maxGeometryAtomicCounterBuffers =
caps->maxShaderAtomicCounterBuffers[gl::ShaderType::Geometry] =
QuerySingleGLInt(functions, GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT);
caps->maxGeometryAtomicCounters =
caps->maxShaderAtomicCounters[gl::ShaderType::Geometry] =
QuerySingleGLInt(functions, GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT);
caps->maxGeometryImageUniforms =
caps->maxShaderImageUniforms[gl::ShaderType::Geometry] =
QuerySingleGLInt(functions, GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT);
caps->maxShaderStorageBlocks[gl::ShaderType::Geometry] =
QuerySingleGLInt(functions, GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT);
......
......@@ -105,9 +105,9 @@ void GenerateCaps(const VkPhysicalDeviceProperties &physicalDeviceProperties,
// Uniforms are implemented using a uniform buffer, so the max number of uniforms we can
// support is the max buffer range divided by the size of a single uniform (4X float).
outCaps->maxVertexUniformVectors = maxUniformVectors;
outCaps->maxVertexUniformComponents = maxUniformComponents;
outCaps->maxShaderUniformComponents[gl::ShaderType::Vertex] = maxUniformComponents;
outCaps->maxFragmentUniformVectors = maxUniformVectors;
outCaps->maxFragmentUniformComponents = maxUniformComponents;
outCaps->maxShaderUniformComponents[gl::ShaderType::Fragment] = maxUniformComponents;
// TODO(jmadill): this is an ES 3.0 property and we can skip implementing it for now.
// This is maxDescriptorSetUniformBuffers minus the number of uniform buffers we
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment