Commit 1266d20a by Jamie Madill Committed by Commit Bot

Vulkan: Add Features class.

This class will control optional features in the Vulkan back-end. It allows toggling the feature support from a centralized place. This can be useful for performance or correctness testing. Add a placeholder feature for line segment raster. We can also use a feature for enabling backbuffer flipping. Bug: angleproject:2598 Bug: angleproject:2673 Change-Id: I8ddec2dba2181d5b014267be68aee9d2cb015ccf Reviewed-on: https://chromium-review.googlesource.com/1120149Reviewed-by: 's avatarLuc Ferron <lucferron@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 6ef24d78
...@@ -795,4 +795,8 @@ VkColorComponentFlags ContextVk::getClearColorMask() const ...@@ -795,4 +795,8 @@ VkColorComponentFlags ContextVk::getClearColorMask() const
{ {
return mClearColorMask; return mClearColorMask;
} }
const FeaturesVk &ContextVk::getFeatures() const
{
return mRenderer->getFeatures();
}
} // namespace rx } // namespace rx
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
namespace rx namespace rx
{ {
struct FeaturesVk;
class RendererVk; class RendererVk;
class ContextVk : public ContextImpl class ContextVk : public ContextImpl
...@@ -150,7 +151,8 @@ class ContextVk : public ContextImpl ...@@ -150,7 +151,8 @@ class ContextVk : public ContextImpl
gl::Error memoryBarrierByRegion(const gl::Context *context, GLbitfield barriers) override; gl::Error memoryBarrierByRegion(const gl::Context *context, GLbitfield barriers) override;
VkDevice getDevice() const; VkDevice getDevice() const;
RendererVk *getRenderer() { return mRenderer; } RendererVk *getRenderer() const { return mRenderer; }
const FeaturesVk &getFeatures() const;
void invalidateCurrentPipeline(); void invalidateCurrentPipeline();
......
//
// Copyright 2018 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// vk_helpers:
// Optional features for the Vulkan renderer.
#ifndef LIBANGLE_RENDERER_VULKAN_FEATURESVK_H_
#define LIBANGLE_RENDERER_VULKAN_FEATURESVK_H_
namespace rx
{
struct FeaturesVk
{
// Line segment rasterization must follow OpenGL rules. This means using an algorithm similar
// to Bresenham's. Vulkan uses a different algorithm. This feature enables the use of pixel
// shader patching to implement OpenGL basic line rasterization rules. This feature will
// normally always be enabled. Exposing it as an option enables performance testing.
bool basicGLLineRasterization = false;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_VULKAN_FEATURESVK_H_
\ No newline at end of file
...@@ -603,7 +603,7 @@ void RendererVk::ensureCapsInitialized() const ...@@ -603,7 +603,7 @@ void RendererVk::ensureCapsInitialized() const
if (!mCapsInitialized) if (!mCapsInitialized)
{ {
vk::GenerateCaps(mPhysicalDeviceProperties, mNativeTextureCaps, &mNativeCaps, vk::GenerateCaps(mPhysicalDeviceProperties, mNativeTextureCaps, &mNativeCaps,
&mNativeExtensions, &mNativeLimitations); &mNativeExtensions, &mNativeLimitations, &mFeatures);
mCapsInitialized = true; mCapsInitialized = true;
} }
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libANGLE/Caps.h" #include "libANGLE/Caps.h"
#include "libANGLE/renderer/vulkan/CommandGraph.h" #include "libANGLE/renderer/vulkan/CommandGraph.h"
#include "libANGLE/renderer/vulkan/FeaturesVk.h"
#include "libANGLE/renderer/vulkan/vk_format_utils.h" #include "libANGLE/renderer/vulkan/vk_format_utils.h"
#include "libANGLE/renderer/vulkan/vk_internal_shaders.h" #include "libANGLE/renderer/vulkan/vk_internal_shaders.h"
...@@ -138,6 +139,7 @@ class RendererVk : angle::NonCopyable ...@@ -138,6 +139,7 @@ class RendererVk : angle::NonCopyable
Serial issueShaderSerial(); Serial issueShaderSerial();
vk::ShaderLibrary *getShaderLibrary(); vk::ShaderLibrary *getShaderLibrary();
const FeaturesVk &getFeatures() const { return mFeatures; }
private: private:
vk::Error initializeDevice(uint32_t queueFamilyIndex); vk::Error initializeDevice(uint32_t queueFamilyIndex);
...@@ -152,6 +154,7 @@ class RendererVk : angle::NonCopyable ...@@ -152,6 +154,7 @@ class RendererVk : angle::NonCopyable
mutable gl::TextureCapsMap mNativeTextureCaps; mutable gl::TextureCapsMap mNativeTextureCaps;
mutable gl::Extensions mNativeExtensions; mutable gl::Extensions mNativeExtensions;
mutable gl::Limitations mNativeLimitations; mutable gl::Limitations mNativeLimitations;
mutable FeaturesVk mFeatures;
VkInstance mInstance; VkInstance mInstance;
bool mEnableValidationLayers; bool mEnableValidationLayers;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "libANGLE/Caps.h" #include "libANGLE/Caps.h"
#include "libANGLE/formatutils.h" #include "libANGLE/formatutils.h"
#include "libANGLE/renderer/vulkan/DisplayVk.h" #include "libANGLE/renderer/vulkan/DisplayVk.h"
#include "libANGLE/renderer/vulkan/FeaturesVk.h"
#include "vk_format_utils.h" #include "vk_format_utils.h"
namespace namespace
...@@ -30,7 +30,8 @@ void GenerateCaps(const VkPhysicalDeviceProperties &physicalDeviceProperties, ...@@ -30,7 +30,8 @@ void GenerateCaps(const VkPhysicalDeviceProperties &physicalDeviceProperties,
const gl::TextureCapsMap &textureCaps, const gl::TextureCapsMap &textureCaps,
gl::Caps *outCaps, gl::Caps *outCaps,
gl::Extensions *outExtensions, gl::Extensions *outExtensions,
gl::Limitations * /* outLimitations */) gl::Limitations * /* outLimitations */,
FeaturesVk *features)
{ {
outExtensions->setTextureExtensionSupport(textureCaps); outExtensions->setTextureExtensionSupport(textureCaps);
...@@ -141,6 +142,9 @@ void GenerateCaps(const VkPhysicalDeviceProperties &physicalDeviceProperties, ...@@ -141,6 +142,9 @@ void GenerateCaps(const VkPhysicalDeviceProperties &physicalDeviceProperties,
outCaps->maxVaryingVectors = outCaps->maxVaryingVectors =
(physicalDeviceProperties.limits.maxVertexOutputComponents / 4) - kReservedVaryingCount; (physicalDeviceProperties.limits.maxVertexOutputComponents / 4) - kReservedVaryingCount;
outCaps->maxVertexOutputComponents = outCaps->maxVaryingVectors * 4; outCaps->maxVertexOutputComponents = outCaps->maxVaryingVectors * 4;
// Use OpenGL line rasterization rules by default.
features->basicGLLineRasterization = true;
} }
} // namespace vk } // namespace vk
......
...@@ -26,6 +26,7 @@ struct InternalFormat; ...@@ -26,6 +26,7 @@ struct InternalFormat;
namespace rx namespace rx
{ {
struct FeaturesVk;
class DisplayVk; class DisplayVk;
...@@ -35,7 +36,8 @@ void GenerateCaps(const VkPhysicalDeviceProperties &physicalDeviceProperties, ...@@ -35,7 +36,8 @@ void GenerateCaps(const VkPhysicalDeviceProperties &physicalDeviceProperties,
const gl::TextureCapsMap &textureCaps, const gl::TextureCapsMap &textureCaps,
gl::Caps *outCaps, gl::Caps *outCaps,
gl::Extensions *outExtensions, gl::Extensions *outExtensions,
gl::Limitations * /* outLimitations */); gl::Limitations * /* outLimitations */,
FeaturesVk *features);
} // namespace vk } // namespace vk
namespace egl_vk namespace egl_vk
......
...@@ -771,6 +771,7 @@ ...@@ -771,6 +771,7 @@
'libANGLE/renderer/vulkan/DeviceVk.h', 'libANGLE/renderer/vulkan/DeviceVk.h',
'libANGLE/renderer/vulkan/DisplayVk.cpp', 'libANGLE/renderer/vulkan/DisplayVk.cpp',
'libANGLE/renderer/vulkan/DisplayVk.h', 'libANGLE/renderer/vulkan/DisplayVk.h',
'libANGLE/renderer/vulkan/FeaturesVk.h',
'libANGLE/renderer/vulkan/FenceNVVk.cpp', 'libANGLE/renderer/vulkan/FenceNVVk.cpp',
'libANGLE/renderer/vulkan/FenceNVVk.h', 'libANGLE/renderer/vulkan/FenceNVVk.h',
'libANGLE/renderer/vulkan/FramebufferVk.cpp', 'libANGLE/renderer/vulkan/FramebufferVk.cpp',
......
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