Commit 3c13b505 authored by Peng Huang's avatar Peng Huang Committed by Commit Bot

Fix a SkiaRenderer + Vulkan crash on crbug.com page

Bug: 959800
Change-Id: I990dd544fe1d3b1a4ceacc5eda5c98e9f5c5ce22
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1599856
Commit-Queue: Peng Huang <penghuang@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#657552}
parent cae35cf1
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
#include "gpu/command_buffer/service/shared_image_representation.h" #include "gpu/command_buffer/service/shared_image_representation.h"
#include "gpu/command_buffer/service/skia_utils.h" #include "gpu/command_buffer/service/skia_utils.h"
#include "gpu/command_buffer/service/wrapped_sk_image.h" #include "gpu/command_buffer/service/wrapped_sk_image.h"
#include "gpu/vulkan/buildflags.h"
#include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkDeferredDisplayListRecorder.h" #include "third_party/skia/include/core/SkDeferredDisplayListRecorder.h"
#include "third_party/skia/include/core/SkSurface.h" #include "third_party/skia/include/core/SkSurface.h"
...@@ -73,6 +74,11 @@ ...@@ -73,6 +74,11 @@
#include "ui/gl/gl_surface.h" #include "ui/gl/gl_surface.h"
#include "ui/gl/gl_version_info.h" #include "ui/gl/gl_version_info.h"
#if BUILDFLAG(ENABLE_VULKAN)
#include "components/viz/common/gpu/vulkan_context_provider.h"
#include "gpu/vulkan/vulkan_device_queue.h"
#endif
// Local versions of the SET_GL_ERROR macros // Local versions of the SET_GL_ERROR macros
#define LOCAL_SET_GL_ERROR(error, function_name, msg) \ #define LOCAL_SET_GL_ERROR(error, function_name, msg) \
ERRORSTATE_SET_GL_ERROR(error_state_.get(), error, function_name, msg) ERRORSTATE_SET_GL_ERROR(error_state_.get(), error, function_name, msg)
...@@ -866,7 +872,22 @@ Capabilities RasterDecoderImpl::GetCapabilities() { ...@@ -866,7 +872,22 @@ Capabilities RasterDecoderImpl::GetCapabilities() {
caps.texture_storage_image = caps.texture_storage_image =
feature_info()->feature_flags().chromium_texture_storage_image; feature_info()->feature_flags().chromium_texture_storage_image;
caps.texture_storage = feature_info()->feature_flags().ext_texture_storage; caps.texture_storage = feature_info()->feature_flags().ext_texture_storage;
api()->glGetIntegervFn(GL_MAX_TEXTURE_SIZE, &caps.max_texture_size); // TODO(piman): have a consistent limit in shared image backings.
// https://crbug.com/960588
if (shared_context_state_->GrContextIsGL()) {
api()->glGetIntegervFn(GL_MAX_TEXTURE_SIZE, &caps.max_texture_size);
} else if (shared_context_state_->GrContextIsVulkan()) {
#if BUILDFLAG(ENABLE_VULKAN)
caps.max_texture_size = shared_context_state_->vk_context_provider()
->GetDeviceQueue()
->vk_physical_device_properties()
.limits.maxImageDimension2D;
#else
NOTREACHED();
#endif
} else {
NOTIMPLEMENTED();
}
if (feature_info()->workarounds().max_texture_size) { if (feature_info()->workarounds().max_texture_size) {
caps.max_texture_size = std::min( caps.max_texture_size = std::min(
caps.max_texture_size, feature_info()->workarounds().max_texture_size); caps.max_texture_size, feature_info()->workarounds().max_texture_size);
......
...@@ -32,6 +32,7 @@ VULKAN_PHYSICAL_DEVICE_FUNCTIONS = [ ...@@ -32,6 +32,7 @@ VULKAN_PHYSICAL_DEVICE_FUNCTIONS = [
{ 'name': 'vkCreateDevice' }, { 'name': 'vkCreateDevice' },
{ 'name': 'vkEnumerateDeviceLayerProperties' }, { 'name': 'vkEnumerateDeviceLayerProperties' },
{ 'name': 'vkGetPhysicalDeviceQueueFamilyProperties' }, { 'name': 'vkGetPhysicalDeviceQueueFamilyProperties' },
{ 'name': 'vkGetPhysicalDeviceProperties' },
# The following functions belong here but are handled specially: # The following functions belong here but are handled specially:
# vkGetPhysicalDeviceSurfaceCapabilitiesKHR # vkGetPhysicalDeviceSurfaceCapabilitiesKHR
# vkGetPhysicalDeviceSurfaceFormatsKHR # vkGetPhysicalDeviceSurfaceFormatsKHR
......
...@@ -88,6 +88,9 @@ bool VulkanDeviceQueue::Initialize( ...@@ -88,6 +88,9 @@ bool VulkanDeviceQueue::Initialize(
return false; return false;
vk_physical_device_ = devices[device_index]; vk_physical_device_ = devices[device_index];
vkGetPhysicalDeviceProperties(vk_physical_device_,
&vk_physical_device_properties_);
vk_queue_index_ = queue_index; vk_queue_index_ = queue_index;
float queue_priority = 0.0f; float queue_priority = 0.0f;
......
...@@ -57,6 +57,10 @@ class VULKAN_EXPORT VulkanDeviceQueue { ...@@ -57,6 +57,10 @@ class VULKAN_EXPORT VulkanDeviceQueue {
return vk_physical_device_; return vk_physical_device_;
} }
const VkPhysicalDeviceProperties& vk_physical_device_properties() const {
return vk_physical_device_properties_;
}
VkDevice GetVulkanDevice() const { VkDevice GetVulkanDevice() const {
DCHECK_NE(static_cast<VkDevice>(VK_NULL_HANDLE), vk_device_); DCHECK_NE(static_cast<VkDevice>(VK_NULL_HANDLE), vk_device_);
return vk_device_; return vk_device_;
...@@ -78,6 +82,7 @@ class VULKAN_EXPORT VulkanDeviceQueue { ...@@ -78,6 +82,7 @@ class VULKAN_EXPORT VulkanDeviceQueue {
private: private:
gfx::ExtensionSet enabled_extensions_; gfx::ExtensionSet enabled_extensions_;
VkPhysicalDevice vk_physical_device_ = VK_NULL_HANDLE; VkPhysicalDevice vk_physical_device_ = VK_NULL_HANDLE;
VkPhysicalDeviceProperties vk_physical_device_properties_;
VkDevice owned_vk_device_ = VK_NULL_HANDLE; VkDevice owned_vk_device_ = VK_NULL_HANDLE;
VkDevice vk_device_ = VK_NULL_HANDLE; VkDevice vk_device_ = VK_NULL_HANDLE;
VkQueue vk_queue_ = VK_NULL_HANDLE; VkQueue vk_queue_ = VK_NULL_HANDLE;
......
...@@ -101,6 +101,13 @@ bool VulkanFunctionPointers::BindPhysicalDeviceFunctionPointers( ...@@ -101,6 +101,13 @@ bool VulkanFunctionPointers::BindPhysicalDeviceFunctionPointers(
if (!vkGetPhysicalDeviceQueueFamilyPropertiesFn) if (!vkGetPhysicalDeviceQueueFamilyPropertiesFn)
return false; return false;
vkGetPhysicalDevicePropertiesFn =
reinterpret_cast<PFN_vkGetPhysicalDeviceProperties>(
vkGetInstanceProcAddrFn(vk_instance,
"vkGetPhysicalDeviceProperties"));
if (!vkGetPhysicalDevicePropertiesFn)
return false;
return true; return true;
} }
......
...@@ -75,6 +75,7 @@ struct VulkanFunctionPointers { ...@@ -75,6 +75,7 @@ struct VulkanFunctionPointers {
nullptr; nullptr;
PFN_vkGetPhysicalDeviceQueueFamilyProperties PFN_vkGetPhysicalDeviceQueueFamilyProperties
vkGetPhysicalDeviceQueueFamilyPropertiesFn = nullptr; vkGetPhysicalDeviceQueueFamilyPropertiesFn = nullptr;
PFN_vkGetPhysicalDeviceProperties vkGetPhysicalDevicePropertiesFn = nullptr;
PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR
vkGetPhysicalDeviceSurfaceCapabilitiesKHRFn = nullptr; vkGetPhysicalDeviceSurfaceCapabilitiesKHRFn = nullptr;
PFN_vkGetPhysicalDeviceSurfaceFormatsKHR PFN_vkGetPhysicalDeviceSurfaceFormatsKHR
...@@ -209,6 +210,8 @@ struct VulkanFunctionPointers { ...@@ -209,6 +210,8 @@ struct VulkanFunctionPointers {
gpu::GetVulkanFunctionPointers()->vkEnumerateDeviceLayerPropertiesFn gpu::GetVulkanFunctionPointers()->vkEnumerateDeviceLayerPropertiesFn
#define vkGetPhysicalDeviceQueueFamilyProperties \ #define vkGetPhysicalDeviceQueueFamilyProperties \
gpu::GetVulkanFunctionPointers()->vkGetPhysicalDeviceQueueFamilyPropertiesFn gpu::GetVulkanFunctionPointers()->vkGetPhysicalDeviceQueueFamilyPropertiesFn
#define vkGetPhysicalDeviceProperties \
gpu::GetVulkanFunctionPointers()->vkGetPhysicalDevicePropertiesFn
#define vkGetPhysicalDeviceSurfaceCapabilitiesKHR \ #define vkGetPhysicalDeviceSurfaceCapabilitiesKHR \
gpu::GetVulkanFunctionPointers()->vkGetPhysicalDeviceSurfaceCapabilitiesKHRFn gpu::GetVulkanFunctionPointers()->vkGetPhysicalDeviceSurfaceCapabilitiesKHRFn
#define vkGetPhysicalDeviceSurfaceFormatsKHR \ #define vkGetPhysicalDeviceSurfaceFormatsKHR \
......
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