20#if defined(SK_GRAPHITE)
29int VkYcbcrSamplerHelper::GetExpectedY(
int x,
int y,
int width,
int height) {
33std::pair<int, int> VkYcbcrSamplerHelper::GetExpectedUV(
int x,
int y,
int width,
int height) {
34 return { 16 +
x * 224 / (
width - 1), 16 +
y * 224 / (
height - 1) };
41 outImageInfo->
pNext =
nullptr;
42 outImageInfo->
flags = 0;
60 uint32_t* memoryTypeIndex) {
78bool VkYcbcrSamplerHelper::createBackendTexture(uint32_t
width, uint32_t
height) {
81 populate_ycbcr_image_info(&vkImageInfo,
width,
height);
94 VULKAN_CALL(fSharedCtxt->interface(), GetImageMemoryRequirements(fSharedCtxt->device(),
97 uint32_t memoryTypeIndex = 0;
99 fSharedCtxt->vulkanCaps().physicalDeviceMemoryProperties2().memoryProperties;
100 if (!find_memory_type_index(phyDevMemProps, requirements, &memoryTypeIndex)) {
106 allocInfo.
pNext =
nullptr;
138 GetImageSubresourceLayout(fSharedCtxt->device(), fImage, &subresource, &yLayout));
139 uint8_t* bufferData =
reinterpret_cast<uint8_t*
>(mappedBuffer) + yLayout.
offset;
141 for (
size_t x = 0;
x <
width; ++
x) {
149 VULKAN_CALL(fSharedCtxt->interface(), GetImageSubresourceLayout(fSharedCtxt->device(),
153 bufferData =
reinterpret_cast<uint8_t*
>(mappedBuffer) + uvLayout.
offset;
155 for (
size_t x = 0;
x <
width / 2; ++
x) {
157 bufferData[
y * uvLayout.
rowPitch +
x * 2] = u;
158 bufferData[
y * uvLayout.
rowPitch +
x * 2 + 1] = v;
164 flushRange.
pNext =
nullptr;
165 flushRange.
memory = fImageMemory;
174 VULKAN_CALL(fSharedCtxt->interface(), UnmapMemory(fSharedCtxt->device(), fImageMemory));
189 GetPhysicalDeviceFormatProperties(fPhysDev,
198 skgpu::VulkanYcbcrConversionInfo ycbcrInfo = {vkImageInfo.
format,
213 static_cast<uint32_t
>(vkImageInfo.
samples),
233bool VkYcbcrSamplerHelper::createGrBackendTexture(uint32_t
width, uint32_t
height) {
234 GrVkGpu* vkGpu = this->vkGpu();
239 populate_ycbcr_image_info(&vkImageInfo,
width,
height);
252 uint32_t memoryTypeIndex = 0;
256 if (!find_memory_type_index(phyDevMemProps, requirements, &memoryTypeIndex)) {
267 nullptr, &fImageMemory));
274 requirements.
size, 0u, &mappedBuffer));
287 &subresource, &yLayout));
288 uint8_t* bufferData =
reinterpret_cast<uint8_t*
>(mappedBuffer) + yLayout.
offset;
290 for (
size_t x = 0;
x <
width; ++
x) {
299 &subresource, &uvLayout));
300 bufferData =
reinterpret_cast<uint8_t*
>(mappedBuffer) + uvLayout.
offset;
302 for (
size_t x = 0;
x <
width / 2; ++
x) {
304 bufferData[
y * uvLayout.
rowPitch +
x * 2] = u;
305 bufferData[
y * uvLayout.
rowPitch +
x * 2 + 1] = v;
311 flushRange.
pNext =
nullptr;
312 flushRange.
memory = fImageMemory;
339 skgpu::VulkanYcbcrConversionInfo ycbcrInfo = {vkImageInfo.
format,
370GrVkGpu* VkYcbcrSamplerHelper::vkGpu() {
378VkYcbcrSamplerHelper::~VkYcbcrSamplerHelper() {
383 DestroyImage(fSharedCtxt->device(), fImage,
nullptr));
388 FreeMemory(fSharedCtxt->device(), fImageMemory,
nullptr));
394 GrVkGpu* vkGpu = this->vkGpu();
407bool VkYcbcrSamplerHelper::isYCbCrSupported() {
411 if (!fSharedCtxt->vulkanCaps().supportsYcbcrConversion()) {
417 GetPhysicalDeviceFormatProperties(fPhysDev,
423 GrVkGpu* vkGpu = this->vkGpu();
for(const auto glyph :glyphs)
#define GR_VK_CALL(IFACE, X)
#define GR_VK_CALL_RESULT(GPU, RESULT, X)
#define SkASSERT_RELEASE(cond)
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
GrDirectContext * fDContext
#define VULKAN_CALL(IFACE, X)
#define VULKAN_CALL_RESULT(SHARED_CONTEXT, RESULT, X)
SK_API GrBackendApi backend() const
GrDirectContextPriv priv()
bool supportsYcbcrConversion() const
const GrVkCaps & vkCaps() const
const skgpu::VulkanInterface * vkInterface() const
VkPhysicalDevice physicalDevice() const
SK_API GrBackendTexture MakeVk(int width, int height, const GrVkImageInfo &, std::string_view label={})
VkSharingMode sharingMode
VkImageLayout initialLayout
const uint32_t * pQueueFamilyIndices
VkSampleCountFlagBits samples
uint32_t queueFamilyIndexCount
VkImageAspectFlags aspectMask
VkDeviceSize allocationSize
VkMemoryPropertyFlags propertyFlags
VkMemoryType memoryTypes[VK_MAX_MEMORY_TYPES]
@ VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT
@ VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT
@ VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT
@ VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT
@ VK_IMAGE_LAYOUT_UNDEFINED
@ VK_SHARING_MODE_EXCLUSIVE
@ VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
@ VK_IMAGE_CREATE_PROTECTED_BIT
@ VK_IMAGE_ASPECT_PLANE_0_BIT
@ VK_IMAGE_ASPECT_PLANE_1_BIT
@ VK_IMAGE_USAGE_TRANSFER_DST_BIT
@ VK_IMAGE_USAGE_SAMPLED_BIT
@ VK_IMAGE_USAGE_TRANSFER_SRC_BIT
@ VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_709
@ VK_CHROMA_LOCATION_COSITED_EVEN
@ VK_SAMPLER_YCBCR_RANGE_ITU_NARROW
@ VK_FORMAT_G8_B8R8_2PLANE_420_UNORM
#define VK_QUEUE_FAMILY_IGNORED
@ VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO
@ VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO
@ VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE