| 1 |
/* |
| 2 |
* Copyright 2023 Google Inc. |
| 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 |
|
| 8 |
#ifndef skgpu_graphite_VulkanYcbcrConversion_DEFINED |
| 9 |
#define skgpu_graphite_VulkanYcbcrConversion_DEFINED |
| 10 |
|
| 11 |
#include "src/gpu/graphite/Resource.h" |
| 12 |
|
| 13 |
#include "include/private/gpu/vk/SkiaVulkan.h" |
| 14 |
#include "src/core/SkChecksum.h" |
| 15 |
|
| 16 |
#include <cinttypes> |
| 17 |
#include <optional> |
| 18 |
|
| 19 |
namespace skgpu { |
| 20 |
struct VulkanYcbcrConversionInfo; |
| 21 |
} |
| 22 |
|
| 23 |
namespace skgpu::graphite { |
| 24 |
|
| 25 |
class VulkanSharedContext; |
| 26 |
|
| 27 |
class VulkanYcbcrConversion : public Resource { |
| 28 |
public: |
| 29 |
static sk_sp<VulkanYcbcrConversion> Make(const VulkanSharedContext*, |
| 30 |
const VulkanYcbcrConversionInfo&); |
| 31 |
|
| 32 |
const VkSamplerYcbcrConversion& ycbcrConversion() const { return fYcbcrConversion; } |
| 33 |
|
| 34 |
// If the format does not support |
| 35 |
// VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT, |
| 36 |
// sampler's minFilter and magFilter must match the conversion's chromaFilter, which can be |
| 37 |
// found in fRequiredFilter. If not set, minFilter and magFilter can be independently set. |
| 38 |
std::optional<VkFilter> requiredFilter() const { return fRequiredFilter; } |
| 39 |
|
| 40 |
const char* getResourceType() const override { return "Vulkan YCbCr Conversion"; } |
| 41 |
|
| 42 |
// Static utilities for working with VulkanYcbcrConversionInfo and ImmutableSamplerInfo, both of |
| 43 |
// which pack the necessary information to create a VulkanYcbcrConversion resource. These are |
| 44 |
// not on VulkanYcbcrConversionInfo because that is a public type for use with |
| 45 |
// VulkanTextureInfo. |
| 46 |
static ImmutableSamplerInfo ToImmutableSamplerInfo(const VulkanYcbcrConversionInfo&); |
| 47 |
static VulkanYcbcrConversionInfo FromImmutableSamplerInfo(ImmutableSamplerInfo); |
| 48 |
|
| 49 |
private: |
| 50 |
VulkanYcbcrConversion(const VulkanSharedContext*, |
| 51 |
VkSamplerYcbcrConversion, |
| 52 |
std::optional<VkFilter>); |
| 53 |
|
| 54 |
void freeGpuData() override; |
| 55 |
|
| 56 |
VkSamplerYcbcrConversion fYcbcrConversion; |
| 57 |
std::optional<VkFilter> fRequiredFilter; |
| 58 |
}; |
| 59 |
} // namespace skgpu::graphite |
| 60 |
|
| 61 |
#endif // skgpu_graphite_VulkanYcbcrConversion_DEFINED |