Commit d37992d1 by Tim Van Patten Committed by Commit Bot

Vulkan: Prevent Creating ES 3.0 Context if Min. Caps. Not Met

ANGLE should not allow creating an ES 3.0 context if the device's maxPerStageDescriptorUniformBuffers or maxVertexOutputComponents values are too low to support the necessary minimums for GLES 3.0. Bug: angleproject:3938 Test: CQ Change-Id: I4fce841d1f364c1aef1a883fa5edb64a4b93f08e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1841971Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Tim Van Patten <timvp@google.com>
parent 8896e18e
...@@ -1049,14 +1049,14 @@ Caps GenerateMinimumCaps(const Version &clientVersion, const Extensions &extensi ...@@ -1049,14 +1049,14 @@ Caps GenerateMinimumCaps(const Version &clientVersion, const Extensions &extensi
caps.maxVertexAttributes = 16; caps.maxVertexAttributes = 16;
caps.maxShaderUniformComponents[ShaderType::Vertex] = 1024; caps.maxShaderUniformComponents[ShaderType::Vertex] = 1024;
caps.maxVertexUniformVectors = 256; caps.maxVertexUniformVectors = 256;
caps.maxShaderUniformBlocks[ShaderType::Vertex] = 12; caps.maxShaderUniformBlocks[ShaderType::Vertex] = limits::kMinimumShaderUniformBlocks;
caps.maxVertexOutputComponents = 64; caps.maxVertexOutputComponents = limits::kMinimumVertexOutputComponents;
caps.maxShaderTextureImageUnits[ShaderType::Vertex] = 16; caps.maxShaderTextureImageUnits[ShaderType::Vertex] = 16;
// Table 6.32 // Table 6.32
caps.maxShaderUniformComponents[ShaderType::Fragment] = 896; caps.maxShaderUniformComponents[ShaderType::Fragment] = 896;
caps.maxFragmentUniformVectors = 224; caps.maxFragmentUniformVectors = 224;
caps.maxShaderUniformBlocks[ShaderType::Fragment] = 12; caps.maxShaderUniformBlocks[ShaderType::Fragment] = limits::kMinimumShaderUniformBlocks;
caps.maxFragmentInputComponents = 60; caps.maxFragmentInputComponents = 60;
caps.maxShaderTextureImageUnits[ShaderType::Fragment] = 16; caps.maxShaderTextureImageUnits[ShaderType::Fragment] = 16;
caps.minProgramTexelOffset = -8; caps.minProgramTexelOffset = -8;
...@@ -1113,7 +1113,7 @@ Caps GenerateMinimumCaps(const Version &clientVersion, const Extensions &extensi ...@@ -1113,7 +1113,7 @@ Caps GenerateMinimumCaps(const Version &clientVersion, const Extensions &extensi
caps.maxComputeWorkGroupCount = {{65535, 65535, 65535}}; caps.maxComputeWorkGroupCount = {{65535, 65535, 65535}};
caps.maxComputeWorkGroupSize = {{128, 128, 64}}; caps.maxComputeWorkGroupSize = {{128, 128, 64}};
caps.maxComputeWorkGroupInvocations = 12; caps.maxComputeWorkGroupInvocations = 12;
caps.maxShaderUniformBlocks[ShaderType::Compute] = 12; caps.maxShaderUniformBlocks[ShaderType::Compute] = limits::kMinimumShaderUniformBlocks;
caps.maxShaderTextureImageUnits[ShaderType::Compute] = 16; caps.maxShaderTextureImageUnits[ShaderType::Compute] = 16;
caps.maxComputeSharedMemorySize = 16384; caps.maxComputeSharedMemorySize = 16384;
caps.maxShaderUniformComponents[ShaderType::Compute] = 1024; caps.maxShaderUniformComponents[ShaderType::Compute] = 1024;
...@@ -1154,7 +1154,7 @@ Caps GenerateMinimumCaps(const Version &clientVersion, const Extensions &extensi ...@@ -1154,7 +1154,7 @@ Caps GenerateMinimumCaps(const Version &clientVersion, const Extensions &extensi
// Table 20.43gs (GL_EXT_geometry_shader) // Table 20.43gs (GL_EXT_geometry_shader)
caps.maxShaderUniformComponents[ShaderType::Geometry] = 1024; caps.maxShaderUniformComponents[ShaderType::Geometry] = 1024;
caps.maxShaderUniformBlocks[ShaderType::Geometry] = 12; caps.maxShaderUniformBlocks[ShaderType::Geometry] = limits::kMinimumShaderUniformBlocks;
caps.maxGeometryInputComponents = 64; caps.maxGeometryInputComponents = 64;
caps.maxGeometryOutputComponents = 64; caps.maxGeometryOutputComponents = 64;
caps.maxGeometryOutputVertices = 256; caps.maxGeometryOutputVertices = 256;
......
...@@ -72,7 +72,7 @@ enum ...@@ -72,7 +72,7 @@ enum
IMPLEMENTATION_MAX_ATOMIC_COUNTER_BUFFERS = 8, IMPLEMENTATION_MAX_ATOMIC_COUNTER_BUFFERS = 8,
// Implementation upper limits, real maximums depend on the hardware. // Implementation upper limits, real maximums depend on the hardware.
IMPLEMENTATION_MAX_SHADER_STORAGE_BUFFER_BINDINGS = 64 IMPLEMENTATION_MAX_SHADER_STORAGE_BUFFER_BINDINGS = 64,
}; };
namespace limits namespace limits
...@@ -80,6 +80,13 @@ namespace limits ...@@ -80,6 +80,13 @@ namespace limits
// Some of the minimums required by GL, used to detect if the backend meets the minimum requirement. // Some of the minimums required by GL, used to detect if the backend meets the minimum requirement.
// Currently, there's no need to separate these values per spec version. // Currently, there's no need to separate these values per spec version.
constexpr uint32_t kMinimumComputeStorageBuffers = 4; constexpr uint32_t kMinimumComputeStorageBuffers = 4;
// OpenGL ES 3.0+ Minimum Values
// Table 6.31 MAX_VERTEX_UNIFORM_BLOCKS minimum value = 12
// Table 6.32 MAX_FRAGMENT_UNIFORM_BLOCKS minimum value = 12
constexpr uint32_t kMinimumShaderUniformBlocks = 12;
// Table 6.31 MAX_VERTEX_OUTPUT_COMPONENTS minimum value = 64
constexpr uint32_t kMinimumVertexOutputComponents = 64;
} // namespace limits } // namespace limits
} // namespace gl } // namespace gl
......
...@@ -1227,6 +1227,7 @@ gl::Version RendererVk::getMaxSupportedESVersion() const ...@@ -1227,6 +1227,7 @@ gl::Version RendererVk::getMaxSupportedESVersion() const
} }
// Limit to ES2.0 if there are any blockers for 3.0. // Limit to ES2.0 if there are any blockers for 3.0.
// TODO: http://anglebug.com/3972 Limit to GLES 2.0 if flat shading can't be emulated
// If the command buffer doesn't support queries, we can't support ES3. // If the command buffer doesn't support queries, we can't support ES3.
if (!vk::CommandBuffer::SupportsQueries(mPhysicalDeviceFeatures)) if (!vk::CommandBuffer::SupportsQueries(mPhysicalDeviceFeatures))
...@@ -1250,6 +1251,29 @@ gl::Version RendererVk::getMaxSupportedESVersion() const ...@@ -1250,6 +1251,29 @@ gl::Version RendererVk::getMaxSupportedESVersion() const
maxVersion = std::max(maxVersion, gl::Version(2, 0)); maxVersion = std::max(maxVersion, gl::Version(2, 0));
} }
// Limit to GLES 2.0 if maxPerStageDescriptorUniformBuffers is too low.
// Table 6.31 MAX_VERTEX_UNIFORM_BLOCKS minimum value = 12
// Table 6.32 MAX_FRAGMENT_UNIFORM_BLOCKS minimum value = 12
// NOTE: We reserve some uniform buffers for emulation, so use the mNativeCaps which takes this
// into account, rather than the physical device maxPerStageDescriptorUniformBuffers limits.
for (gl::ShaderType shaderType : gl::AllShaderTypes())
{
if (mNativeCaps.maxShaderUniformBlocks[shaderType] <
gl::limits::kMinimumShaderUniformBlocks)
{
maxVersion = std::max(maxVersion, gl::Version(2, 0));
}
}
// Limit to GLES 2.0 if maxVertexOutputComponents is too low.
// Table 6.31 MAX VERTEX OUTPUT COMPONENTS minimum value = 64
// NOTE: We reserve some vertex output components for emulation, so use the mNativeCaps which
// takes this into account, rather than the physical device maxVertexOutputComponents limits.
if (mNativeCaps.maxVertexOutputComponents < gl::limits::kMinimumVertexOutputComponents)
{
maxVersion = std::max(maxVersion, gl::Version(2, 0));
}
return maxVersion; return maxVersion;
} }
......
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