Commit 99beb97a by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Fix MAX_VERTEX_OUTPUT_COMPONENTS limit

gl_Position is excepted from contributing to MAX_VARYING_VECTORS, which is taken into account when calculating this limit based on Vulkan limits (which don't have such an exception). This exception was mistakenly also being applied to other limits such as MAX_VERTEX_OUTPUT_COMPONENTS. Bug: angleproject:5916 Change-Id: I394761efa02d3093741d2bff21023daf997e5e69 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2869145Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent 9655de62
...@@ -821,34 +821,39 @@ void RendererVk::ensureCapsInitialized() const ...@@ -821,34 +821,39 @@ void RendererVk::ensureCapsInitialized() const
mNativeCaps.maxCombinedShaderOutputResources = mNativeCaps.maxCombinedShaderOutputResources =
LimitToInt(maxPerStageResources - kReservedPerStageBindingCount); LimitToInt(maxPerStageResources - kReservedPerStageBindingCount);
// The max vertex output components should not include gl_Position. // Reserve 1 extra varying for ANGLEPosition when GLLineRasterization is enabled
// The gles2.0 section 2.10 states that "gl_Position is not a varying variable and does constexpr GLint kReservedVaryingComponentsForGLLineRasterization = 4;
// not count against this limit.", but the Vulkan spec has no such mention in its Built-in // Reserve 1 extra varying for transform feedback capture of gl_Position.
// vars section. It is implicit that we need to actually reserve it for Vulkan in that case. constexpr GLint kReservedVaryingComponentsForTransformFeedbackExtension = 4;
GLint reservedVaryingVectorCount = 1;
// Reserve 1 extra for ANGLEPosition when GLLineRasterization is enabled GLint reservedVaryingComponentCount = 0;
constexpr GLint kReservedVaryingForGLLineRasterization = 1;
// Reserve 1 extra for transform feedback capture of gl_Position.
constexpr GLint kReservedVaryingForTransformFeedbackExtension = 1;
if (getFeatures().basicGLLineRasterization.enabled) if (getFeatures().basicGLLineRasterization.enabled)
{ {
reservedVaryingVectorCount += kReservedVaryingForGLLineRasterization; reservedVaryingComponentCount += kReservedVaryingComponentsForGLLineRasterization;
} }
if (getFeatures().supportsTransformFeedbackExtension.enabled) if (getFeatures().supportsTransformFeedbackExtension.enabled)
{ {
reservedVaryingVectorCount += kReservedVaryingForTransformFeedbackExtension; reservedVaryingComponentCount += kReservedVaryingComponentsForTransformFeedbackExtension;
} }
// The max varying vectors should not include gl_Position.
// The gles2.0 section 2.10 states that "gl_Position is not a varying variable and does
// not count against this limit.", but the Vulkan spec has no such mention in its Built-in
// vars section. It is implicit that we need to actually reserve it for Vulkan in that case.
//
// Note that this exception for gl_Position does not apply to MAX_VERTEX_OUTPUT_COMPONENTS and
// similar limits.
const GLint reservedVaryingVectorCount = reservedVaryingComponentCount / 4 + 1;
const GLint maxVaryingCount = const GLint maxVaryingCount =
std::min(limitsVk.maxVertexOutputComponents, limitsVk.maxFragmentInputComponents); std::min(limitsVk.maxVertexOutputComponents, limitsVk.maxFragmentInputComponents);
mNativeCaps.maxVaryingVectors = mNativeCaps.maxVaryingVectors =
LimitToInt((maxVaryingCount / kComponentsPerVector) - reservedVaryingVectorCount); LimitToInt((maxVaryingCount / kComponentsPerVector) - reservedVaryingVectorCount);
mNativeCaps.maxVertexOutputComponents = mNativeCaps.maxVertexOutputComponents =
LimitToInt(limitsVk.maxVertexOutputComponents) - reservedVaryingVectorCount * 4; LimitToInt(limitsVk.maxVertexOutputComponents) - reservedVaryingComponentCount;
mNativeCaps.maxFragmentInputComponents = mNativeCaps.maxFragmentInputComponents =
LimitToInt(limitsVk.maxFragmentInputComponents) - reservedVaryingVectorCount * 4; LimitToInt(limitsVk.maxFragmentInputComponents) - reservedVaryingComponentCount;
mNativeCaps.maxTransformFeedbackInterleavedComponents = mNativeCaps.maxTransformFeedbackInterleavedComponents =
gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS; gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS;
...@@ -934,9 +939,9 @@ void RendererVk::ensureCapsInitialized() const ...@@ -934,9 +939,9 @@ void RendererVk::ensureCapsInitialized() const
: GL_FIRST_VERTEX_CONVENTION_EXT; : GL_FIRST_VERTEX_CONVENTION_EXT;
mNativeCaps.maxGeometryInputComponents = mNativeCaps.maxGeometryInputComponents =
LimitToInt(limitsVk.maxGeometryInputComponents) - reservedVaryingVectorCount * 4; LimitToInt(limitsVk.maxGeometryInputComponents) - reservedVaryingComponentCount;
mNativeCaps.maxGeometryOutputComponents = mNativeCaps.maxGeometryOutputComponents =
LimitToInt(limitsVk.maxGeometryOutputComponents) - reservedVaryingVectorCount * 4; LimitToInt(limitsVk.maxGeometryOutputComponents) - reservedVaryingComponentCount;
mNativeCaps.maxGeometryOutputVertices = LimitToInt(limitsVk.maxGeometryOutputVertices); mNativeCaps.maxGeometryOutputVertices = LimitToInt(limitsVk.maxGeometryOutputVertices);
mNativeCaps.maxGeometryTotalOutputComponents = mNativeCaps.maxGeometryTotalOutputComponents =
LimitToInt(limitsVk.maxGeometryTotalOutputComponents); LimitToInt(limitsVk.maxGeometryTotalOutputComponents);
......
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