Vulkan: Don't enable primitiveRestart on "list" topologies

This conforms to the Vulkan usage validation rules and is otherwise a
noop because primitive restart would do nothing for "list" topologies.

BUG=dawn:162

Change-Id: Icda96b15e2f931a0abd3fba794c2aff56dccb714
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7660
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Corentin Wallez 2019-06-03 22:53:29 +00:00 committed by Commit Bot service account
parent c2750abd0c
commit b632bc58ed
1 changed files with 17 additions and 2 deletions

View File

@ -121,6 +121,22 @@ namespace dawn_native { namespace vulkan {
} }
} }
bool ShouldEnablePrimitiveRestart(dawn::PrimitiveTopology topology) {
// Primitive restart is always enabled in WebGPU but Vulkan validation rules ask that
// primitive restart be only enabled on primitive topologies that support restarting.
switch (topology) {
case dawn::PrimitiveTopology::PointList:
case dawn::PrimitiveTopology::LineList:
case dawn::PrimitiveTopology::TriangleList:
return false;
case dawn::PrimitiveTopology::LineStrip:
case dawn::PrimitiveTopology::TriangleStrip:
return true;
default:
UNREACHABLE();
}
}
VkBlendFactor VulkanBlendFactor(dawn::BlendFactor factor) { VkBlendFactor VulkanBlendFactor(dawn::BlendFactor factor) {
switch (factor) { switch (factor) {
case dawn::BlendFactor::Zero: case dawn::BlendFactor::Zero:
@ -307,8 +323,7 @@ namespace dawn_native { namespace vulkan {
inputAssembly.pNext = nullptr; inputAssembly.pNext = nullptr;
inputAssembly.flags = 0; inputAssembly.flags = 0;
inputAssembly.topology = VulkanPrimitiveTopology(GetPrimitiveTopology()); inputAssembly.topology = VulkanPrimitiveTopology(GetPrimitiveTopology());
// Primitive restart is always enabled in Dawn (because of Metal) inputAssembly.primitiveRestartEnable = ShouldEnablePrimitiveRestart(GetPrimitiveTopology());
inputAssembly.primitiveRestartEnable = VK_TRUE;
// A dummy viewport/scissor info. The validation layers force use to provide at least one // A dummy viewport/scissor info. The validation layers force use to provide at least one
// scissor and one viewport here, even if we choose to make them dynamic. // scissor and one viewport here, even if we choose to make them dynamic.