1 /*
2 * Copyright 2023 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7 #include "src/gpu/ganesh/vk/GrVkContextThreadSafeProxy.h"
8
9 #include "include/core/SkRefCnt.h"
10 #include "include/gpu/GpuTypes.h"
11 #include "include/gpu/ganesh/GrTypes.h"
12 #include "src/gpu/ganesh/vk/GrVkCaps.h"
13
14 class GrCaps;
15 struct GrContextOptions;
16
GrVkContextThreadSafeProxy(const GrContextOptions & opts)17 GrVkContextThreadSafeProxy::GrVkContextThreadSafeProxy(const GrContextOptions& opts)
18 : GrContextThreadSafeProxy(GrBackendApi::kVulkan, opts) {}
19
isValidCharacterizationForVulkan(sk_sp<const GrCaps> caps,bool isTextureable,skgpu::Mipmapped isMipmapped,skgpu::Protected isProtected,bool vkRTSupportsInputAttachment,bool forVulkanSecondaryCommandBuffer)20 bool GrVkContextThreadSafeProxy::isValidCharacterizationForVulkan(
21 sk_sp<const GrCaps> caps,
22 bool isTextureable,
23 skgpu::Mipmapped isMipmapped,
24 skgpu::Protected isProtected,
25 bool vkRTSupportsInputAttachment,
26 bool forVulkanSecondaryCommandBuffer) {
27 if (forVulkanSecondaryCommandBuffer &&
28 (isTextureable || isMipmapped == skgpu::Mipmapped::kYes || vkRTSupportsInputAttachment)) {
29 return false;
30 }
31
32 const GrVkCaps* vkCaps = (const GrVkCaps*)caps.get();
33
34 // The protection status of the characterization and the context need to match
35 return isProtected == GrProtected(vkCaps->supportsProtectedContent());
36 }
37