Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit b07147b

Browse files
committed
Provoking vertex fixes
A few things were buggy in the last provoking vertex cl: - There were 2 separate loops for rasterizationState extensions. Correctly combined them into a single loop. - There was a missing break statement in vkCreateDevice - There was a missing case in vkGetPhysicalDeviceFeatures2 Bug: angleproject:3677, angleproject:3430 Change-Id: Id4a16168933fc8c440b7339851a39e8cc4683491 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/37688 Presubmit-Ready: Alexis Hétu <sugoi@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: Alexis Hétu <sugoi@google.com>
1 parent f8f6103 commit b07147b

File tree

2 files changed

+23
-27
lines changed

2 files changed

+23
-27
lines changed

src/Vulkan/VkPipeline.cpp

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -390,31 +390,6 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
390390
UNIMPLEMENTED("pCreateInfo->pRasterizationState settings");
391391
}
392392

393-
if(rasterizationState->pNext)
394-
{
395-
const VkBaseInStructure* extensionCreateInfo = reinterpret_cast<const VkBaseInStructure*>(rasterizationState->pNext);
396-
while(extensionCreateInfo)
397-
{
398-
// Casting to a long since some structures, such as
399-
// VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_FEATURES_EXT
400-
// are not enumerated in the official Vulkan header
401-
switch((long)(extensionCreateInfo->sType))
402-
{
403-
case VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_PROVOKING_VERTEX_STATE_CREATE_INFO_EXT:
404-
{
405-
const VkPipelineRasterizationProvokingVertexStateCreateInfoEXT* provokingVertexModeCreateInfo =
406-
reinterpret_cast<const VkPipelineRasterizationProvokingVertexStateCreateInfoEXT*>(extensionCreateInfo);
407-
context.provokingVertexMode = provokingVertexModeCreateInfo->provokingVertexMode;
408-
}
409-
break;
410-
default:
411-
UNIMPLEMENTED("extensionCreateInfo->pNext");
412-
}
413-
414-
extensionCreateInfo = extensionCreateInfo->pNext;
415-
}
416-
}
417-
418393
context.rasterizerDiscard = (rasterizationState->rasterizerDiscardEnable == VK_TRUE);
419394
context.cullMode = rasterizationState->cullMode;
420395
context.frontFace = rasterizationState->frontFace;
@@ -425,14 +400,24 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
425400
const VkBaseInStructure* extensionCreateInfo = reinterpret_cast<const VkBaseInStructure*>(rasterizationState->pNext);
426401
while(extensionCreateInfo)
427402
{
428-
switch(extensionCreateInfo->sType)
403+
// Casting to a long since some structures, such as
404+
// VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_FEATURES_EXT
405+
// are not enumerated in the official Vulkan header
406+
switch((long)(extensionCreateInfo->sType))
429407
{
430408
case VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_LINE_STATE_CREATE_INFO_EXT:
431409
{
432410
const VkPipelineRasterizationLineStateCreateInfoEXT* lineStateCreateInfo = reinterpret_cast<const VkPipelineRasterizationLineStateCreateInfoEXT*>(extensionCreateInfo);
433411
context.lineRasterizationMode = lineStateCreateInfo->lineRasterizationMode;
434412
}
435413
break;
414+
case VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_PROVOKING_VERTEX_STATE_CREATE_INFO_EXT:
415+
{
416+
const VkPipelineRasterizationProvokingVertexStateCreateInfoEXT* provokingVertexModeCreateInfo =
417+
reinterpret_cast<const VkPipelineRasterizationProvokingVertexStateCreateInfoEXT*>(extensionCreateInfo);
418+
context.provokingVertexMode = provokingVertexModeCreateInfo->provokingVertexMode;
419+
}
420+
break;
436421
default:
437422
UNIMPLEMENTED("extensionCreateInfo->sType");
438423
break;

src/Vulkan/libVulkan.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, c
611611
// that the provokingVertexLast feature is enabled before using the provoking vertex convention.
612612
(void)provokingVertexFeatures->provokingVertexLast;
613613
}
614+
break;
614615
default:
615616
// "the [driver] must skip over, without processing (other than reading the sType and pNext members) any structures in the chain with sType values not defined by [supported extenions]"
616617
UNIMPLEMENTED("extensionCreateInfo->sType %d", int(extensionCreateInfo->sType)); // TODO(b/119321052): UNIMPLEMENTED() should be used only for features that must still be implemented. Use a more informational macro here.
@@ -2371,7 +2372,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures2(VkPhysicalDevice physica
23712372
VkBaseOutStructure* extensionFeatures = reinterpret_cast<VkBaseOutStructure*>(pFeatures->pNext);
23722373
while(extensionFeatures)
23732374
{
2374-
switch(extensionFeatures->sType)
2375+
switch((long)(extensionFeatures->sType))
23752376
{
23762377
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES:
23772378
{
@@ -2421,6 +2422,16 @@ VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures2(VkPhysicalDevice physica
24212422
vk::Cast(physicalDevice)->getFeatures(&features);
24222423
}
24232424
break;
2425+
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_FEATURES_EXT:
2426+
{
2427+
const VkPhysicalDeviceProvokingVertexFeaturesEXT* provokingVertexFeatures = reinterpret_cast<const VkPhysicalDeviceProvokingVertexFeaturesEXT*>(extensionFeatures);
2428+
2429+
// Provoking vertex is supported.
2430+
// provokingVertexFeatures->provokingVertexLast can be VK_TRUE or VK_FALSE.
2431+
// No action needs to be taken on our end in either case; it's the apps responsibility to check
2432+
// that the provokingVertexLast feature is enabled before using the provoking vertex convention.
2433+
(void)provokingVertexFeatures->provokingVertexLast;
2434+
}
24242435
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONDITIONAL_RENDERING_FEATURES_EXT:
24252436
ASSERT(!HasExtensionProperty(VK_EXT_CONDITIONAL_RENDERING_EXTENSION_NAME, deviceExtensionProperties,
24262437
sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));

0 commit comments

Comments
 (0)