Debian Codegraph @

src/gpu/graphite/vk/VulkanTextureInfo.cpp

raw
1 /*
2 * Copyright 2024 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 "include/core/SkString.h"
8 #include "include/gpu/graphite/vk/VulkanGraphiteTypes.h"
9 #include "include/gpu/vk/VulkanMutableTextureState.h"
10 #include "src/gpu/graphite/TextureInfoPriv.h"
11 #include "src/gpu/graphite/vk/VulkanGraphiteUtils.h"
12 #include "src/gpu/vk/VulkanUtilsPriv.h"
13
14 #include <cstdint>
15
16 namespace skgpu::graphite {
17
18 SkString VulkanTextureInfo::toBackendString() const {
19 return SkStringPrintf(
20 "flags=0x%08X,imageTiling=%d,imageUsageFlags=0x%08X,sharingMode=%d,"
21 "aspectMask=%u",
22 fFlags,
23 fImageTiling,
24 fImageUsageFlags,
25 fSharingMode,
26 fAspectMask);
27 }
28
29 TextureFormat VulkanTextureInfo::viewFormat() const {
30 if (fYcbcrConversionInfo.isValid()) {
31 return fYcbcrConversionInfo.format() == VK_FORMAT_UNDEFINED
32 ? TextureFormat::kExternal
33 : VkFormatToTextureFormat(fYcbcrConversionInfo.format());
34 }
35
36 return VkFormatToTextureFormat(fFormat);
37 }
38
39 bool VulkanTextureInfo::isCompatible(const TextureInfo& that, bool requireExact) const {
40 const auto& vt = TextureInfoPriv::Get<VulkanTextureInfo>(that);
41
42 // The usages may match or the usage passed in may be a superset of the usage stored within.
43 const auto usageMask = requireExact ? vt.fImageUsageFlags : fImageUsageFlags;
44 return fFlags == vt.fFlags &&
45 fFormat == vt.fFormat &&
46 fImageTiling == vt.fImageTiling &&
47 fSharingMode == vt.fSharingMode &&
48 fAspectMask == vt.fAspectMask &&
49 (usageMask & vt.fImageUsageFlags) == fImageUsageFlags &&
50 fYcbcrConversionInfo == vt.fYcbcrConversionInfo;
51 }
52
53 namespace TextureInfos {
54
55 TextureInfo MakeVulkan(const VulkanTextureInfo& vkInfo) {
56 return TextureInfoPriv::Make(vkInfo);
57 }
58
59 bool GetVulkanTextureInfo(const TextureInfo& info, VulkanTextureInfo* out) {
60 return TextureInfoPriv::Copy(info, out);
61 }
62
63 } // namespace TextureInfos
64
65 } // namespace skgpu::graphite