Commit b47cc50a by Antonio Maiorano Committed by Commit Bot

Enable validation layer custom extensions

With this change, Vulkan-ValidationLayers will allow the specified extensions to pass through, instead of being nulled out: * VK_STRUCTURE_TYPE_SAMPLER_FILTERING_PRECISION_GOOGLE * VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_FEATURES_EXT Bug: b/159027603 Bug: b/154620295 Change-Id: I0ace3acdac06a6c115834ef88b0c883fa2dd4744 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2246304 Commit-Queue: Antonio Maiorano <amaiorano@google.com> Reviewed-by: 's avatarAntonio Maiorano <amaiorano@google.com> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent d8ac1d21
...@@ -20,7 +20,11 @@ config("angle_vulkan_headers_config") { ...@@ -20,7 +20,11 @@ config("angle_vulkan_headers_config") {
} }
angle_source_set("angle_vulkan_headers") { angle_source_set("angle_vulkan_headers") {
sources = [ "vk_headers.h" ] sources = [
"vk_ext_provoking_vertex.h",
"vk_google_filtering_precision.h",
"vk_headers.h",
]
if (angle_shared_libvulkan) { if (angle_shared_libvulkan) {
public_deps = [ "$angle_root/src/third_party/volk:volk" ] public_deps = [ "$angle_root/src/third_party/volk:volk" ]
} else { } else {
......
...@@ -12,7 +12,10 @@ ...@@ -12,7 +12,10 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "common/vulkan/vk_headers.h" #ifndef CUSTOM_VK_EXT_PROVOKING_VERTEX_H_
#define CUSTOM_VK_EXT_PROVOKING_VERTEX_H_
#include "vk_headers.h"
// THIS FILE SHOULD BE DELETED IF VK_EXT_provoking_vertex IS EVER ADDED TO THE VULKAN HEADERS // THIS FILE SHOULD BE DELETED IF VK_EXT_provoking_vertex IS EVER ADDED TO THE VULKAN HEADERS
#ifdef VK_EXT_provoking_vertex #ifdef VK_EXT_provoking_vertex
...@@ -63,3 +66,5 @@ typedef struct VkPipelineRasterizationProvokingVertexStateCreateInfoEXT ...@@ -63,3 +66,5 @@ typedef struct VkPipelineRasterizationProvokingVertexStateCreateInfoEXT
const void *pNext; const void *pNext;
VkProvokingVertexModeEXT provokingVertexMode; VkProvokingVertexModeEXT provokingVertexMode;
} VkPipelineRasterizationProvokingVertexStateCreateInfoEXT; } VkPipelineRasterizationProvokingVertexStateCreateInfoEXT;
#endif // CUSTOM_VK_EXT_PROVOKING_VERTEX_H_
...@@ -12,7 +12,10 @@ ...@@ -12,7 +12,10 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "common/vulkan/vk_headers.h" #ifndef CUSTOM_VK_GOOGLE_SAMPLER_FILTERING_PRECISION_H_
#define CUSTOM_VK_GOOGLE_SAMPLER_FILTERING_PRECISION_H_
#include "vk_headers.h"
// THIS FILE SHOULD BE DELETED IF VK_GOOGLE_sampler_filtering_precision IS EVER ADDED TO THE VULKAN // THIS FILE SHOULD BE DELETED IF VK_GOOGLE_sampler_filtering_precision IS EVER ADDED TO THE VULKAN
// HEADERS // HEADERS
...@@ -24,7 +27,7 @@ ...@@ -24,7 +27,7 @@
static constexpr VkStructureType VK_STRUCTURE_TYPE_SAMPLER_FILTERING_PRECISION_GOOGLE = static constexpr VkStructureType VK_STRUCTURE_TYPE_SAMPLER_FILTERING_PRECISION_GOOGLE =
static_cast<VkStructureType>(1000264000); static_cast<VkStructureType>(1000264000);
#define VK_GOOGLE_sampler_filtering_precisions 1 #define VK_GOOGLE_sampler_filtering_precision 1
#define VK_GOOGLE_SAMPLER_FILTERING_PRECISION_SPEC_VERSION 1 #define VK_GOOGLE_SAMPLER_FILTERING_PRECISION_SPEC_VERSION 1
#define VK_GOOGLE_SAMPLER_FILTERING_PRECISION_EXTENSION_NAME "VK_GOOGLE_sampler_filtering_precision" #define VK_GOOGLE_SAMPLER_FILTERING_PRECISION_EXTENSION_NAME "VK_GOOGLE_sampler_filtering_precision"
...@@ -50,3 +53,5 @@ typedef struct VkSamplerFilteringPrecisionGOOGLE ...@@ -50,3 +53,5 @@ typedef struct VkSamplerFilteringPrecisionGOOGLE
const void *pNext; const void *pNext;
VkSamplerFilteringPrecisionModeGOOGLE samplerFilteringPrecisionMode; VkSamplerFilteringPrecisionModeGOOGLE samplerFilteringPrecisionMode;
} VkSamplerFilteringPrecisionGOOGLE; } VkSamplerFilteringPrecisionGOOGLE;
#endif // CUSTOM_VK_GOOGLE_SAMPLER_FILTERING_PRECISION_H_
...@@ -15,6 +15,29 @@ ...@@ -15,6 +15,29 @@
#include "common/debug.h" #include "common/debug.h"
#include "common/system_utils.h" #include "common/system_utils.h"
#include "common/vulkan/vk_ext_provoking_vertex.h"
#include "common/vulkan/vk_google_filtering_precision.h"
namespace
{
void ResetEnvironmentVar(const char *variableName, const Optional<std::string> &value)
{
if (!value.valid())
{
return;
}
if (value.value().empty())
{
angle::UnsetEnvironmentVar(variableName);
}
else
{
angle::SetEnvironmentVar(variableName, value.value().c_str());
}
}
} // namespace
namespace angle namespace angle
{ {
...@@ -40,8 +63,9 @@ const std::string WrapICDEnvironment(const char *icdEnvironment) ...@@ -40,8 +63,9 @@ const std::string WrapICDEnvironment(const char *icdEnvironment)
constexpr char kLoaderLayersPathEnv[] = "VK_LAYER_PATH"; constexpr char kLoaderLayersPathEnv[] = "VK_LAYER_PATH";
#endif #endif
constexpr char kLoaderICDFilenamesEnv[] = "VK_ICD_FILENAMES"; constexpr char kLoaderICDFilenamesEnv[] = "VK_ICD_FILENAMES";
constexpr char kANGLEPreferredDeviceEnv[] = "ANGLE_PREFERRED_DEVICE"; constexpr char kANGLEPreferredDeviceEnv[] = "ANGLE_PREFERRED_DEVICE";
constexpr char kValidationLayersCustomSTypeListEnv[] = "VK_LAYER_CUSTOM_STYPE_LIST";
constexpr uint32_t kMockVendorID = 0xba5eba11; constexpr uint32_t kMockVendorID = 0xba5eba11;
constexpr uint32_t kMockDeviceID = 0xf005ba11; constexpr uint32_t kMockDeviceID = 0xf005ba11;
...@@ -143,6 +167,12 @@ ScopedVkLoaderEnvironment::ScopedVkLoaderEnvironment(bool enableValidationLayers ...@@ -143,6 +167,12 @@ ScopedVkLoaderEnvironment::ScopedVkLoaderEnvironment(bool enableValidationLayers
ERR() << "Error setting environment for Vulkan layers init."; ERR() << "Error setting environment for Vulkan layers init.";
mEnableValidationLayers = false; mEnableValidationLayers = false;
} }
if (!setCustomExtensionsEnvironment())
{
ERR() << "Error setting custom list for custom extensions for Vulkan layers init.";
mEnableValidationLayers = false;
}
} }
#endif // !defined(ANGLE_PLATFORM_ANDROID) #endif // !defined(ANGLE_PLATFORM_ANDROID)
} }
...@@ -158,15 +188,10 @@ ScopedVkLoaderEnvironment::~ScopedVkLoaderEnvironment() ...@@ -158,15 +188,10 @@ ScopedVkLoaderEnvironment::~ScopedVkLoaderEnvironment()
} }
if (mChangedICDEnv) if (mChangedICDEnv)
{ {
if (mPreviousICDEnv.value().empty()) ResetEnvironmentVar(kLoaderICDFilenamesEnv, mPreviousICDEnv);
{
angle::UnsetEnvironmentVar(kLoaderICDFilenamesEnv);
}
else
{
angle::SetEnvironmentVar(kLoaderICDFilenamesEnv, mPreviousICDEnv.value().c_str());
}
} }
ResetEnvironmentVar(kValidationLayersCustomSTypeListEnv, mPreviousCustomExtensionsEnv);
} }
bool ScopedVkLoaderEnvironment::setICDEnvironment(const char *icd) bool ScopedVkLoaderEnvironment::setICDEnvironment(const char *icd)
...@@ -183,6 +208,40 @@ bool ScopedVkLoaderEnvironment::setICDEnvironment(const char *icd) ...@@ -183,6 +208,40 @@ bool ScopedVkLoaderEnvironment::setICDEnvironment(const char *icd)
return mChangedICDEnv; return mChangedICDEnv;
} }
bool ScopedVkLoaderEnvironment::setCustomExtensionsEnvironment()
{
struct CustomExtension
{
VkStructureType type;
size_t size;
};
CustomExtension customExtensions[] = {
{VK_STRUCTURE_TYPE_SAMPLER_FILTERING_PRECISION_GOOGLE,
sizeof(VkSamplerFilteringPrecisionGOOGLE)},
{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_FEATURES_EXT,
sizeof(VkPhysicalDeviceProvokingVertexFeaturesEXT)},
};
mPreviousCustomExtensionsEnv = angle::GetEnvironmentVar(kValidationLayersCustomSTypeListEnv);
std::stringstream strstr;
for (CustomExtension &extension : customExtensions)
{
if (strstr.tellp() != std::streampos(0))
{
strstr << angle::GetPathSeparatorForEnvironmentVar();
}
strstr << extension.type << angle::GetPathSeparatorForEnvironmentVar() << extension.size;
}
return angle::PrependPathToEnvironmentVar(kValidationLayersCustomSTypeListEnv,
strstr.str().c_str());
}
void ChoosePhysicalDevice(const std::vector<VkPhysicalDevice> &physicalDevices, void ChoosePhysicalDevice(const std::vector<VkPhysicalDevice> &physicalDevices,
vk::ICD preferredICD, vk::ICD preferredICD,
VkPhysicalDevice *physicalDeviceOut, VkPhysicalDevice *physicalDeviceOut,
......
...@@ -38,6 +38,7 @@ class ScopedVkLoaderEnvironment : angle::NonCopyable ...@@ -38,6 +38,7 @@ class ScopedVkLoaderEnvironment : angle::NonCopyable
private: private:
bool setICDEnvironment(const char *icd); bool setICDEnvironment(const char *icd);
bool setCustomExtensionsEnvironment();
bool mEnableValidationLayers; bool mEnableValidationLayers;
vk::ICD mICD; vk::ICD mICD;
...@@ -45,6 +46,7 @@ class ScopedVkLoaderEnvironment : angle::NonCopyable ...@@ -45,6 +46,7 @@ class ScopedVkLoaderEnvironment : angle::NonCopyable
Optional<std::string> mPreviousCWD; Optional<std::string> mPreviousCWD;
bool mChangedICDEnv; bool mChangedICDEnv;
Optional<std::string> mPreviousICDEnv; Optional<std::string> mPreviousICDEnv;
Optional<std::string> mPreviousCustomExtensionsEnv;
}; };
void ChoosePhysicalDevice(const std::vector<VkPhysicalDevice> &physicalDevices, void ChoosePhysicalDevice(const std::vector<VkPhysicalDevice> &physicalDevices,
......
...@@ -85,11 +85,9 @@ _vulkan_backend_sources = [ ...@@ -85,11 +85,9 @@ _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.cpp", "vk_format_utils.cpp",
"vk_format_utils.h", "vk_format_utils.h",
"vk_google_filtering_precision.h",
"vk_helpers.cpp", "vk_helpers.cpp",
"vk_helpers.h", "vk_helpers.h",
"vk_internal_shaders_autogen.cpp", "vk_internal_shaders_autogen.cpp",
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "common/debug.h" #include "common/debug.h"
#include "common/platform.h" #include "common/platform.h"
#include "common/system_utils.h" #include "common/system_utils.h"
#include "common/vulkan/vk_google_filtering_precision.h"
#include "common/vulkan/vulkan_icd.h" #include "common/vulkan/vulkan_icd.h"
#include "gpu_info_util/SystemInfo.h" #include "gpu_info_util/SystemInfo.h"
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
...@@ -32,7 +33,6 @@ ...@@ -32,7 +33,6 @@
#include "libANGLE/renderer/vulkan/VertexArrayVk.h" #include "libANGLE/renderer/vulkan/VertexArrayVk.h"
#include "libANGLE/renderer/vulkan/vk_caps_utils.h" #include "libANGLE/renderer/vulkan/vk_caps_utils.h"
#include "libANGLE/renderer/vulkan/vk_format_utils.h" #include "libANGLE/renderer/vulkan/vk_format_utils.h"
#include "libANGLE/renderer/vulkan/vk_google_filtering_precision.h"
#include "libANGLE/trace.h" #include "libANGLE/trace.h"
#include "platform/PlatformMethods.h" #include "platform/PlatformMethods.h"
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include <queue> #include <queue>
#include <thread> #include <thread>
#include "vk_ext_provoking_vertex.h" #include "common/vulkan/vk_ext_provoking_vertex.h"
#include "common/PackedEnums.h" #include "common/PackedEnums.h"
#include "common/PoolAlloc.h" #include "common/PoolAlloc.h"
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "libANGLE/renderer/vulkan/vk_cache_utils.h" #include "libANGLE/renderer/vulkan/vk_cache_utils.h"
#include "common/aligned_memory.h" #include "common/aligned_memory.h"
#include "common/vulkan/vk_google_filtering_precision.h"
#include "libANGLE/BlobCache.h" #include "libANGLE/BlobCache.h"
#include "libANGLE/VertexAttribute.h" #include "libANGLE/VertexAttribute.h"
#include "libANGLE/renderer/vulkan/FramebufferVk.h" #include "libANGLE/renderer/vulkan/FramebufferVk.h"
...@@ -18,7 +19,6 @@ ...@@ -18,7 +19,6 @@
#include "libANGLE/renderer/vulkan/RendererVk.h" #include "libANGLE/renderer/vulkan/RendererVk.h"
#include "libANGLE/renderer/vulkan/VertexArrayVk.h" #include "libANGLE/renderer/vulkan/VertexArrayVk.h"
#include "libANGLE/renderer/vulkan/vk_format_utils.h" #include "libANGLE/renderer/vulkan/vk_format_utils.h"
#include "libANGLE/renderer/vulkan/vk_google_filtering_precision.h"
#include "libANGLE/renderer/vulkan/vk_helpers.h" #include "libANGLE/renderer/vulkan/vk_helpers.h"
#include <type_traits> #include <type_traits>
......
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