Provoking vertex feature support enabled

Added support in ANGLE for the provoking vertex feature,
which allows to choose the provoking vertex convention
(first or last) for flat shading.

Just copying the vk_ext_provoking_vertex.h file into ANGLE src tree for now.
When the extension lands in the vulkan header we'll migrate to that and remove this
file from ANGLE.

With this, all these tests pass with SwANGLE:
dEQP-GLES3.functional.fragment_out.* (fixes 526 failures)
dEQP-GLES3.functional.rasterization.flatshading.* (fixes 6 failures)
dEQP-GLES3.functional.shaders.linkage.varying.* (already passing before, still passing)

Bug: angleproject:3430
Bug: angleproject:3677
Bug: angleproject:4063
Change-Id: Icc361f567072c12472398e37a94a61d7f95007ad
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1855681
Commit-Queue: Alexis Hétu <sugoi@chromium.org>
Reviewed-by: Alexis Hétu <sugoi@chromium.org>
This commit is contained in:
Alexis Hetu 2019-10-11 11:29:22 -04:00 коммит произвёл Commit Bot
Родитель 133be10311
Коммит 5e6be1d627
6 изменённых файлов: 116 добавлений и 1 удалений

Просмотреть файл

@ -35,6 +35,12 @@ struct FeaturesVk : FeatureSetBase
"bresenham_line_rasterization", FeatureCategory::VulkanFeatures, "bresenham_line_rasterization", FeatureCategory::VulkanFeatures,
"Enable Bresenham line rasterization via VK_EXT_line_rasterization extension", &members}; "Enable Bresenham line rasterization via VK_EXT_line_rasterization extension", &members};
// If the VK_EXT_provoking_vertex extension is available, we'll use it to set
// the provoking vertex mode
Feature provokingVertex = {"provoking_vertex", FeatureCategory::VulkanFeatures,
"Enable provoking vertex mode via VK_EXT_provoking_vertex extension",
&members};
// Flips the viewport to render upside-down. This has the effect to render the same way as // Flips the viewport to render upside-down. This has the effect to render the same way as
// OpenGL. If this feature gets enabled, we enable the KHR_MAINTENANCE_1 extension to allow // OpenGL. If this feature gets enabled, we enable the KHR_MAINTENANCE_1 extension to allow
// negative viewports. We inverse rendering to the backbuffer by reversing the height of the // negative viewports. We inverse rendering to the backbuffer by reversing the height of the

Просмотреть файл

@ -85,6 +85,7 @@ _vulkan_backend_sources = [
"vk_cache_utils.h", "vk_cache_utils.h",
"vk_caps_utils.cpp", "vk_caps_utils.cpp",
"vk_caps_utils.h", "vk_caps_utils.h",
"vk_ext_provoking_vertex.h",
"vk_format_table_autogen.cpp", "vk_format_table_autogen.cpp",
"vk_format_utils.h", "vk_format_utils.h",
"vk_format_utils.cpp", "vk_format_utils.cpp",

Просмотреть файл

@ -981,6 +981,26 @@ angle::Result RendererVk::initializeDevice(DisplayVk *displayVk, uint32_t queueF
AppendToPNextChain(reinterpret_cast<vk::CommonStructHeader *>(&createInfo), AppendToPNextChain(reinterpret_cast<vk::CommonStructHeader *>(&createInfo),
&mLineRasterizationFeatures); &mLineRasterizationFeatures);
} }
mProvokingVertexFeatures = {};
mProvokingVertexFeatures.sType =
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_FEATURES_EXT;
ASSERT(mProvokingVertexFeatures.provokingVertexLast == VK_FALSE);
if (vkGetPhysicalDeviceFeatures2KHR &&
ExtensionFound(VK_EXT_PROVOKING_VERTEX_EXTENSION_NAME, deviceExtensionNames))
{
enabledDeviceExtensions.push_back(VK_EXT_PROVOKING_VERTEX_EXTENSION_NAME);
// Query line rasterization capabilities
VkPhysicalDeviceFeatures2KHR availableFeatures = {};
availableFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
AppendToPNextChain(reinterpret_cast<vk::CommonStructHeader *>(&availableFeatures),
&mProvokingVertexFeatures);
vkGetPhysicalDeviceFeatures2KHR(mPhysicalDevice, &availableFeatures);
AppendToPNextChain(reinterpret_cast<vk::CommonStructHeader *>(&createInfo),
&mProvokingVertexFeatures);
}
initFeatures(deviceExtensionNames); initFeatures(deviceExtensionNames);
OverrideFeaturesWithDisplayState(&mFeatures, displayVk->getState()); OverrideFeaturesWithDisplayState(&mFeatures, displayVk->getState());
mFeaturesInitialized = true; mFeaturesInitialized = true;
@ -1304,6 +1324,13 @@ void RendererVk::initFeatures(const ExtensionNameList &deviceExtensionNames)
ANGLE_FEATURE_CONDITION((&mFeatures), basicGLLineRasterization, !IsAndroid()); ANGLE_FEATURE_CONDITION((&mFeatures), basicGLLineRasterization, !IsAndroid());
} }
if (mProvokingVertexFeatures.provokingVertexLast == VK_TRUE)
{
ASSERT(mProvokingVertexFeatures.sType ==
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_FEATURES_EXT);
ANGLE_FEATURE_CONDITION((&mFeatures), provokingVertex, true);
}
// TODO(lucferron): Currently disabled on Intel only since many tests are failing and need // TODO(lucferron): Currently disabled on Intel only since many tests are failing and need
// investigation. http://anglebug.com/2728 // investigation. http://anglebug.com/2728
ANGLE_FEATURE_CONDITION( ANGLE_FEATURE_CONDITION(

Просмотреть файл

@ -13,6 +13,7 @@
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include <memory> #include <memory>
#include <mutex> #include <mutex>
#include "vk_ext_provoking_vertex.h"
#include "common/PoolAlloc.h" #include "common/PoolAlloc.h"
#include "common/angleutils.h" #include "common/angleutils.h"
@ -247,6 +248,7 @@ class RendererVk : angle::NonCopyable
VkPhysicalDeviceSubgroupProperties mPhysicalDeviceSubgroupProperties; VkPhysicalDeviceSubgroupProperties mPhysicalDeviceSubgroupProperties;
VkPhysicalDeviceFeatures mPhysicalDeviceFeatures; VkPhysicalDeviceFeatures mPhysicalDeviceFeatures;
VkPhysicalDeviceLineRasterizationFeaturesEXT mLineRasterizationFeatures; VkPhysicalDeviceLineRasterizationFeaturesEXT mLineRasterizationFeatures;
VkPhysicalDeviceProvokingVertexFeaturesEXT mProvokingVertexFeatures;
std::vector<VkQueueFamilyProperties> mQueueFamilyProperties; std::vector<VkQueueFamilyProperties> mQueueFamilyProperties;
std::mutex mQueueMutex; std::mutex mQueueMutex;
VkQueue mQueue; VkQueue mQueue;

Просмотреть файл

@ -790,13 +790,27 @@ angle::Result GraphicsPipelineDesc::initializePipeline(
rasterState.depthBiasClamp = rasterAndMS.depthBiasClamp; rasterState.depthBiasClamp = rasterAndMS.depthBiasClamp;
rasterState.depthBiasSlopeFactor = rasterAndMS.depthBiasSlopeFactor; rasterState.depthBiasSlopeFactor = rasterAndMS.depthBiasSlopeFactor;
rasterState.lineWidth = rasterAndMS.lineWidth; rasterState.lineWidth = rasterAndMS.lineWidth;
const void **pNextPtr = &rasterState.pNext;
VkPipelineRasterizationLineStateCreateInfoEXT rasterLineState = {}; VkPipelineRasterizationLineStateCreateInfoEXT rasterLineState = {};
rasterLineState.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_LINE_STATE_CREATE_INFO_EXT; rasterLineState.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_LINE_STATE_CREATE_INFO_EXT;
// Always enable Bresenham line rasterization if available. // Always enable Bresenham line rasterization if available.
if (contextVk->getFeatures().bresenhamLineRasterization.enabled) if (contextVk->getFeatures().bresenhamLineRasterization.enabled)
{ {
rasterLineState.lineRasterizationMode = VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT; rasterLineState.lineRasterizationMode = VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT;
rasterState.pNext = &rasterLineState; *pNextPtr = &rasterLineState;
pNextPtr = &rasterLineState.pNext;
}
VkPipelineRasterizationProvokingVertexStateCreateInfoEXT provokingVertexState = {};
provokingVertexState.sType =
VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_PROVOKING_VERTEX_STATE_CREATE_INFO_EXT;
// Always set provoking vertex mode to last if available.
if (contextVk->getFeatures().provokingVertex.enabled)
{
provokingVertexState.provokingVertexMode = VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT;
*pNextPtr = &provokingVertexState;
pNextPtr = &provokingVertexState.pNext;
} }
// Multisample state. // Multisample state.

Просмотреть файл

@ -0,0 +1,65 @@
// Copyright 2019 The SwiftShader Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <vulkan/vulkan.h>
// THIS FILE SHOULD BE DELETED IF VK_EXT_provoking_vertex IS EVER ADDED TO THE VULKAN HEADERS
#ifdef VK_EXT_provoking_vertex
# error \
"VK_EXT_provoking_vertex is already defined in the Vulkan headers, you can delete this file"
#endif
static constexpr VkStructureType VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_FEATURES_EXT =
static_cast<VkStructureType>(1000254000);
static constexpr VkStructureType
VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_PROVOKING_VERTEX_STATE_CREATE_INFO_EXT =
static_cast<VkStructureType>(1000254001);
static constexpr VkStructureType VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_PROPERTIES_EXT =
static_cast<VkStructureType>(1000254002);
#define VK_EXT_provoking_vertex 1
#define VK_EXT_PROVOKING_VERTEX_SPEC_VERSION 1
#define VK_EXT_PROVOKING_VERTEX_EXTENSION_NAME "VK_EXT_provoking_vertex"
typedef enum VkProvokingVertexModeEXT
{
VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT = 0,
VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT = 1,
VK_PROVOKING_VERTEX_MODE_BEGIN_RANGE_EXT = VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT,
VK_PROVOKING_VERTEX_MODE_END_RANGE_EXT = VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT,
VK_PROVOKING_VERTEX_MODE_RANGE_SIZE_EXT =
(VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT - VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT + 1),
VK_PROVOKING_VERTEX_MODE_MAX_ENUM_EXT = 0x7FFFFFFF
} VkProvokingVertexModeEXT;
typedef struct VkPhysicalDeviceProvokingVertexFeaturesEXT
{
VkStructureType sType;
void *pNext;
VkBool32 provokingVertexLast;
} VkPhysicalDeviceProvokingVertexFeaturesEXT;
typedef struct VkPhysicalDeviceProvokingVertexPropertiesEXT
{
VkStructureType sType;
void *pNext;
VkBool32 provokingVertexModePerPipeline;
} VkPhysicalDeviceProvokingVertexPropertiesEXT;
typedef struct VkPipelineRasterizationProvokingVertexStateCreateInfoEXT
{
VkStructureType sType;
const void *pNext;
VkProvokingVertexModeEXT provokingVertexMode;
} VkPipelineRasterizationProvokingVertexStateCreateInfoEXT;