Commit 9b843ea8 by Ben Clayton

VkPipeline: Fix unsigned integer underflows in computePrimitiveCount()

Tests: dEQP-VK.draw.basic_draw.* Change-Id: I609e22601c4aae1bdebaca6d42d33754cfaa57bb Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/31840 Presubmit-Ready: Ben Clayton <bclayton@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent c367b22b
......@@ -485,13 +485,13 @@ uint32_t GraphicsPipeline::computePrimitiveCount(uint32_t vertexCount) const
case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
return vertexCount / 2;
case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
return vertexCount - 1;
return std::max<uint32_t>(vertexCount, 1) - 1;
case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
return vertexCount / 3;
case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
return vertexCount - 2;
return std::max<uint32_t>(vertexCount, 2) - 2;
case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
return vertexCount - 2;
return std::max<uint32_t>(vertexCount, 2) - 2;
default:
UNIMPLEMENTED("context.topology %d", int(context.topology));
}
......
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