Commit 84c074cf by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Simplify AppendToPNextChain use

The function is turned into a template to avoid the reinterpret_cast at call sites. Additionally, uses Vulkan's own VkBaseOutStructure instead of a bespoke definition. Bug: angleproject:4027 Change-Id: Ib236d44a12c0363e7e89b9bf2ed5ab8166252730 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1924992 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarTobin Ehlis <tobine@google.com>
parent b0a9de95
...@@ -979,12 +979,10 @@ angle::Result RendererVk::initializeDevice(DisplayVk *displayVk, uint32_t queueF ...@@ -979,12 +979,10 @@ angle::Result RendererVk::initializeDevice(DisplayVk *displayVk, uint32_t queueF
// Query line rasterization capabilities // Query line rasterization capabilities
VkPhysicalDeviceFeatures2KHR availableFeatures = {}; VkPhysicalDeviceFeatures2KHR availableFeatures = {};
availableFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; availableFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
AppendToPNextChain(reinterpret_cast<vk::CommonStructHeader *>(&availableFeatures), vk::AppendToPNextChain(&availableFeatures, &mLineRasterizationFeatures);
&mLineRasterizationFeatures);
vkGetPhysicalDeviceFeatures2KHR(mPhysicalDevice, &availableFeatures); vkGetPhysicalDeviceFeatures2KHR(mPhysicalDevice, &availableFeatures);
AppendToPNextChain(reinterpret_cast<vk::CommonStructHeader *>(&createInfo), vk::AppendToPNextChain(&createInfo, &mLineRasterizationFeatures);
&mLineRasterizationFeatures);
} }
mProvokingVertexFeatures = {}; mProvokingVertexFeatures = {};
...@@ -998,12 +996,10 @@ angle::Result RendererVk::initializeDevice(DisplayVk *displayVk, uint32_t queueF ...@@ -998,12 +996,10 @@ angle::Result RendererVk::initializeDevice(DisplayVk *displayVk, uint32_t queueF
// Query line rasterization capabilities // Query line rasterization capabilities
VkPhysicalDeviceFeatures2KHR availableFeatures = {}; VkPhysicalDeviceFeatures2KHR availableFeatures = {};
availableFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; availableFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
AppendToPNextChain(reinterpret_cast<vk::CommonStructHeader *>(&availableFeatures), vk::AppendToPNextChain(&availableFeatures, &mProvokingVertexFeatures);
&mProvokingVertexFeatures);
vkGetPhysicalDeviceFeatures2KHR(mPhysicalDevice, &availableFeatures); vkGetPhysicalDeviceFeatures2KHR(mPhysicalDevice, &availableFeatures);
AppendToPNextChain(reinterpret_cast<vk::CommonStructHeader *>(&createInfo), vk::AppendToPNextChain(&createInfo, &mProvokingVertexFeatures);
&mProvokingVertexFeatures);
} }
if (!displayVk->getState().featuresAllDisabled) if (!displayVk->getState().featuresAllDisabled)
...@@ -1089,8 +1085,7 @@ angle::Result RendererVk::initializeDevice(DisplayVk *displayVk, uint32_t queueF ...@@ -1089,8 +1085,7 @@ angle::Result RendererVk::initializeDevice(DisplayVk *displayVk, uint32_t queueF
{ {
enabledDeviceExtensions.push_back(VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME); enabledDeviceExtensions.push_back(VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME);
divisorFeatures.vertexAttributeInstanceRateDivisor = true; divisorFeatures.vertexAttributeInstanceRateDivisor = true;
AppendToPNextChain(reinterpret_cast<vk::CommonStructHeader *>(&enabledFeatures), vk::AppendToPNextChain(&enabledFeatures, &divisorFeatures);
&divisorFeatures);
VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT divisorProperties = {}; VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT divisorProperties = {};
divisorProperties.sType = divisorProperties.sType =
...@@ -1098,8 +1093,7 @@ angle::Result RendererVk::initializeDevice(DisplayVk *displayVk, uint32_t queueF ...@@ -1098,8 +1093,7 @@ angle::Result RendererVk::initializeDevice(DisplayVk *displayVk, uint32_t queueF
VkPhysicalDeviceProperties2 deviceProperties = {}; VkPhysicalDeviceProperties2 deviceProperties = {};
deviceProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2; deviceProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
AppendToPNextChain(reinterpret_cast<vk::CommonStructHeader *>(&deviceProperties), vk::AppendToPNextChain(&deviceProperties, &divisorProperties);
&divisorProperties);
vkGetPhysicalDeviceProperties2KHR(mPhysicalDevice, &deviceProperties); vkGetPhysicalDeviceProperties2KHR(mPhysicalDevice, &deviceProperties);
// We only store 8 bit divisor in GraphicsPipelineDesc so capping value & we emulate if // We only store 8 bit divisor in GraphicsPipelineDesc so capping value & we emulate if
...@@ -1107,8 +1101,7 @@ angle::Result RendererVk::initializeDevice(DisplayVk *displayVk, uint32_t queueF ...@@ -1107,8 +1101,7 @@ angle::Result RendererVk::initializeDevice(DisplayVk *displayVk, uint32_t queueF
mMaxVertexAttribDivisor = mMaxVertexAttribDivisor =
std::min(divisorProperties.maxVertexAttribDivisor, std::min(divisorProperties.maxVertexAttribDivisor,
static_cast<uint32_t>(std::numeric_limits<uint8_t>::max())); static_cast<uint32_t>(std::numeric_limits<uint8_t>::max()));
AppendToPNextChain(reinterpret_cast<vk::CommonStructHeader *>(&createInfo), vk::AppendToPNextChain(&createInfo, &enabledFeatures);
&enabledFeatures);
} }
else else
{ {
...@@ -1120,8 +1113,7 @@ angle::Result RendererVk::initializeDevice(DisplayVk *displayVk, uint32_t queueF ...@@ -1120,8 +1113,7 @@ angle::Result RendererVk::initializeDevice(DisplayVk *displayVk, uint32_t queueF
{ {
VkPhysicalDeviceProperties2 deviceProperties = {}; VkPhysicalDeviceProperties2 deviceProperties = {};
deviceProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2; deviceProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
AppendToPNextChain(reinterpret_cast<vk::CommonStructHeader *>(&deviceProperties), vk::AppendToPNextChain(&deviceProperties, &mPhysicalDeviceSubgroupProperties);
&mPhysicalDeviceSubgroupProperties);
vkGetPhysicalDeviceProperties2KHR(mPhysicalDevice, &deviceProperties); vkGetPhysicalDeviceProperties2KHR(mPhysicalDevice, &deviceProperties);
} }
......
...@@ -260,16 +260,6 @@ namespace vk ...@@ -260,16 +260,6 @@ namespace vk
const char *gLoaderLayersPathEnv = "VK_LAYER_PATH"; const char *gLoaderLayersPathEnv = "VK_LAYER_PATH";
const char *gLoaderICDFilenamesEnv = "VK_ICD_FILENAMES"; const char *gLoaderICDFilenamesEnv = "VK_ICD_FILENAMES";
void AppendToPNextChain(CommonStructHeader *chainStart, void *ptr)
{
CommonStructHeader *localPtr = chainStart;
while (localPtr->pNext)
{
localPtr = static_cast<CommonStructHeader *>(localPtr->pNext);
}
localPtr->pNext = ptr;
}
VkImageAspectFlags GetDepthStencilAspectFlags(const angle::Format &format) VkImageAspectFlags GetDepthStencilAspectFlags(const angle::Format &format)
{ {
return (format.depthBits > 0 ? VK_IMAGE_ASPECT_DEPTH_BIT : 0) | return (format.depthBits > 0 ? VK_IMAGE_ASPECT_DEPTH_BIT : 0) |
......
...@@ -101,14 +101,17 @@ namespace vk ...@@ -101,14 +101,17 @@ namespace vk
{ {
struct Format; struct Format;
struct CommonStructHeader // Append ptr to end of pNext chain beginning at chainStart
template <typename VulkanStruct1, typename VulkanStruct2>
void AppendToPNextChain(VulkanStruct1 *chainStart, VulkanStruct2 *ptr)
{ {
VkStructureType sType; VkBaseOutStructure *localPtr = reinterpret_cast<VkBaseOutStructure *>(chainStart);
void *pNext; while (localPtr->pNext)
}; {
localPtr = localPtr->pNext;
// Append ptr to end of pNext chain beginning at chainStart->pNext }
void AppendToPNextChain(CommonStructHeader *chainStart, void *ptr); localPtr->pNext = reinterpret_cast<VkBaseOutStructure *>(ptr);
}
extern const char *gLoaderLayersPathEnv; extern const char *gLoaderLayersPathEnv;
extern const char *gLoaderICDFilenamesEnv; extern const char *gLoaderICDFilenamesEnv;
......
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