From 50416b7af74c98514645c9a7ef5bb507fc3ad9a5 Mon Sep 17 00:00:00 2001 From: redermens <9424949456@qq.com> Date: Tue, 20 May 2025 12:38:36 +0800 Subject: [PATCH] sync dev code Signed-off-by: redermens --- include/gpu/GrDirectContext.h | 3 ++- src/gpu/GrDirectContext.cpp | 9 +++++++++ src/gpu/vk/GrVkGpu.cpp | 20 ++++++++++++++------ src/gpu/vk/vulkan_header_ext_huawei.h | 1 + 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/include/gpu/GrDirectContext.h b/include/gpu/GrDirectContext.h index d7bd8acd64..1c86680279 100644 --- a/include/gpu/GrDirectContext.h +++ b/include/gpu/GrDirectContext.h @@ -902,7 +902,7 @@ public: // OH ISSUE: suppress release window void setGpuCacheSuppressWindowSwitch(bool enabled); void suppressGpuCacheBelowCertainRatio(const std::function& nextFrameHasArrived); - std::function vulkanErrorCallback_; + void processVulkanError(); protected: GrDirectContext(GrBackendApi backend, const GrContextOptions& options); @@ -949,6 +949,7 @@ private: std::unique_ptr fAtlasManager; std::unique_ptr fSmallPathAtlasMgr; + std::function vulkanErrorCallback_; friend class GrDirectContextPriv; diff --git a/src/gpu/GrDirectContext.cpp b/src/gpu/GrDirectContext.cpp index c8a874675e..3fcd3ddc64 100644 --- a/src/gpu/GrDirectContext.cpp +++ b/src/gpu/GrDirectContext.cpp @@ -377,6 +377,15 @@ void GrDirectContext::registerVulkanErrorCallback(const std::function& v vulkanErrorCallback_ = vulkanErrorCallback; } +void GrDirectContext::processVulkanError() +{ + if(vulkanErrorCallback_) { + vulkanErrorCallback_(); + } else { + SK_LOGE("checkVkResult vulkanErrorCallback_ nullptr"); + } +} + void GrDirectContext::purgeCacheBetweenFrames(bool scratchResourcesOnly, const std::set& exitedPidSet, const std::set& protectedPidSet) { diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp index b4fd4ff332..3db088be6e 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp @@ -2714,7 +2714,8 @@ void GrVkGpu::endRenderPass(GrRenderTarget* target, GrSurfaceOrigin origin, } bool GrVkGpu::checkVkResult(VkResult result) { - switch (result) { + int32_t numResult = static_cast(result); + switch (numResult) { case VK_SUCCESS: return true; case VK_ERROR_DEVICE_LOST: @@ -2741,11 +2742,7 @@ bool GrVkGpu::checkVkResult(VkResult result) { { auto context = getContext(); if (context) { - if (context->vulkanErrorCallback_) { - context->vulkanErrorCallback_(); - } else { - SK_LOGE("checkVkResult vulkanErrorCallback_ nullptr"); - } + context->processVulkanError(); } else { SK_LOGE("checkVkResult context nullptr"); } @@ -2755,6 +2752,17 @@ bool GrVkGpu::checkVkResult(VkResult result) { case VK_ERROR_OUT_OF_HOST_MEMORY: this->setOOMed(); return false; + case VK_HUAWEI_GPU_ERROR_RECOVER: + { + SK_LOGE("report VK_HUAWEI_GPU_ERROR_RECOVER"); + auto context = getContext(); + if (context) { + context->processVulkanError(); + } else { + SK_LOGE("checkVkResult context nullptr"); + } + return true; + } default: return false; } diff --git a/src/gpu/vk/vulkan_header_ext_huawei.h b/src/gpu/vk/vulkan_header_ext_huawei.h index 24518e723c..c1f86cb8b4 100644 --- a/src/gpu/vk/vulkan_header_ext_huawei.h +++ b/src/gpu/vk/vulkan_header_ext_huawei.h @@ -27,6 +27,7 @@ typedef struct VkRenderPassDamageRegionBeginInfo { #define VK_HUAWEI_DRAW_BLUR_IMAGE 1 #define VK_HUAWEI_DRAW_BLUR_IMAGE_SPEC_VERSION 10 #define VK_HUAWEI_DRAW_BLUR_IMAGE_EXTENSION_NAME "VK_HUAWEI_draw_blur_image" +#define VK_HUAWEI_GPU_ERROR_RECOVER (-199999999); typedef enum VkBlurOriginTypeHUAWEI { BLUR_ORIGIN_NONE_FLIP_HUAWEI = 0, -- Gitee