No functional change. Signed-off-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> Reviewed-by: Ryan Neph <ryanneph@google.com>macos/master
parent
c471485538
commit
c15d09acd1
@ -0,0 +1,271 @@ |
|||||||
|
/*
|
||||||
|
* Copyright 2020 Google LLC |
||||||
|
* SPDX-License-Identifier: MIT |
||||||
|
*/ |
||||||
|
|
||||||
|
#include "vkr_image.h" |
||||||
|
|
||||||
|
#include "venus-protocol/vn_protocol_renderer_image.h" |
||||||
|
#include "venus-protocol/vn_protocol_renderer_image_view.h" |
||||||
|
#include "venus-protocol/vn_protocol_renderer_sampler.h" |
||||||
|
#include "venus-protocol/vn_protocol_renderer_sampler_ycbcr_conversion.h" |
||||||
|
|
||||||
|
#include "vkr_context.h" |
||||||
|
#include "vkr_device.h" |
||||||
|
|
||||||
|
static void |
||||||
|
vkr_dispatch_vkCreateImage(struct vn_dispatch_context *dispatch, |
||||||
|
struct vn_command_vkCreateImage *args) |
||||||
|
{ |
||||||
|
struct vkr_context *ctx = dispatch->data; |
||||||
|
|
||||||
|
struct vkr_device *dev = (struct vkr_device *)args->device; |
||||||
|
if (!dev || dev->base.type != VK_OBJECT_TYPE_DEVICE) { |
||||||
|
vkr_cs_decoder_set_fatal(&ctx->decoder); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
#ifdef FORCE_ENABLE_DMABUF |
||||||
|
/* Do not chain VkExternalMemoryImageCreateInfo with optimal tiling, so that
|
||||||
|
* guest Venus can pass memory requirement cts with dedicated allocation. |
||||||
|
*/ |
||||||
|
VkExternalMemoryImageCreateInfo local_external_info; |
||||||
|
if (args->pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL && |
||||||
|
dev->physical_device->EXT_external_memory_dma_buf) { |
||||||
|
VkExternalMemoryImageCreateInfo *external_info = vkr_find_pnext( |
||||||
|
args->pCreateInfo->pNext, VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO); |
||||||
|
if (external_info) { |
||||||
|
external_info->handleTypes |= VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT; |
||||||
|
} else { |
||||||
|
local_external_info = (const VkExternalMemoryImageCreateInfo){ |
||||||
|
.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO, |
||||||
|
.pNext = args->pCreateInfo->pNext, |
||||||
|
.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT, |
||||||
|
}; |
||||||
|
((VkImageCreateInfo *)args->pCreateInfo)->pNext = &local_external_info; |
||||||
|
} |
||||||
|
} |
||||||
|
#endif |
||||||
|
|
||||||
|
CREATE_OBJECT(img, image, IMAGE, vkCreateImage, pImage); |
||||||
|
|
||||||
|
util_hash_table_set_u64(ctx->object_table, img->base.id, img); |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
vkr_dispatch_vkDestroyImage(struct vn_dispatch_context *dispatch, |
||||||
|
struct vn_command_vkDestroyImage *args) |
||||||
|
{ |
||||||
|
struct vkr_context *ctx = dispatch->data; |
||||||
|
|
||||||
|
DESTROY_OBJECT(img, image, IMAGE, vkDestroyImage, image); |
||||||
|
|
||||||
|
util_hash_table_remove_u64(ctx->object_table, img->base.id); |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
vkr_dispatch_vkGetImageMemoryRequirements( |
||||||
|
UNUSED struct vn_dispatch_context *dispatch, |
||||||
|
struct vn_command_vkGetImageMemoryRequirements *args) |
||||||
|
{ |
||||||
|
vn_replace_vkGetImageMemoryRequirements_args_handle(args); |
||||||
|
vkGetImageMemoryRequirements(args->device, args->image, args->pMemoryRequirements); |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
vkr_dispatch_vkGetImageMemoryRequirements2( |
||||||
|
UNUSED struct vn_dispatch_context *dispatch, |
||||||
|
struct vn_command_vkGetImageMemoryRequirements2 *args) |
||||||
|
{ |
||||||
|
vn_replace_vkGetImageMemoryRequirements2_args_handle(args); |
||||||
|
vkGetImageMemoryRequirements2(args->device, args->pInfo, args->pMemoryRequirements); |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
vkr_dispatch_vkGetImageSparseMemoryRequirements( |
||||||
|
UNUSED struct vn_dispatch_context *dispatch, |
||||||
|
struct vn_command_vkGetImageSparseMemoryRequirements *args) |
||||||
|
{ |
||||||
|
vn_replace_vkGetImageSparseMemoryRequirements_args_handle(args); |
||||||
|
vkGetImageSparseMemoryRequirements(args->device, args->image, |
||||||
|
args->pSparseMemoryRequirementCount, |
||||||
|
args->pSparseMemoryRequirements); |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
vkr_dispatch_vkGetImageSparseMemoryRequirements2( |
||||||
|
UNUSED struct vn_dispatch_context *dispatch, |
||||||
|
struct vn_command_vkGetImageSparseMemoryRequirements2 *args) |
||||||
|
{ |
||||||
|
vn_replace_vkGetImageSparseMemoryRequirements2_args_handle(args); |
||||||
|
vkGetImageSparseMemoryRequirements2(args->device, args->pInfo, |
||||||
|
args->pSparseMemoryRequirementCount, |
||||||
|
args->pSparseMemoryRequirements); |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
vkr_dispatch_vkBindImageMemory(UNUSED struct vn_dispatch_context *dispatch, |
||||||
|
struct vn_command_vkBindImageMemory *args) |
||||||
|
{ |
||||||
|
vn_replace_vkBindImageMemory_args_handle(args); |
||||||
|
args->ret = |
||||||
|
vkBindImageMemory(args->device, args->image, args->memory, args->memoryOffset); |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
vkr_dispatch_vkBindImageMemory2(UNUSED struct vn_dispatch_context *dispatch, |
||||||
|
struct vn_command_vkBindImageMemory2 *args) |
||||||
|
{ |
||||||
|
vn_replace_vkBindImageMemory2_args_handle(args); |
||||||
|
args->ret = vkBindImageMemory2(args->device, args->bindInfoCount, args->pBindInfos); |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
vkr_dispatch_vkGetImageSubresourceLayout( |
||||||
|
UNUSED struct vn_dispatch_context *dispatch, |
||||||
|
struct vn_command_vkGetImageSubresourceLayout *args) |
||||||
|
{ |
||||||
|
vn_replace_vkGetImageSubresourceLayout_args_handle(args); |
||||||
|
vkGetImageSubresourceLayout(args->device, args->image, args->pSubresource, |
||||||
|
args->pLayout); |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
vkr_dispatch_vkGetImageDrmFormatModifierPropertiesEXT( |
||||||
|
struct vn_dispatch_context *dispatch, |
||||||
|
struct vn_command_vkGetImageDrmFormatModifierPropertiesEXT *args) |
||||||
|
{ |
||||||
|
struct vkr_context *ctx = dispatch->data; |
||||||
|
struct vkr_device *dev = (struct vkr_device *)args->device; |
||||||
|
if (!dev || dev->base.type != VK_OBJECT_TYPE_DEVICE) { |
||||||
|
vkr_cs_decoder_set_fatal(&ctx->decoder); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
vn_replace_vkGetImageDrmFormatModifierPropertiesEXT_args_handle(args); |
||||||
|
args->ret = dev->get_image_drm_format_modifier_properties(args->device, args->image, |
||||||
|
args->pProperties); |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
vkr_dispatch_vkCreateImageView(struct vn_dispatch_context *dispatch, |
||||||
|
struct vn_command_vkCreateImageView *args) |
||||||
|
{ |
||||||
|
struct vkr_context *ctx = dispatch->data; |
||||||
|
|
||||||
|
CREATE_OBJECT(view, image_view, IMAGE_VIEW, vkCreateImageView, pView); |
||||||
|
|
||||||
|
util_hash_table_set_u64(ctx->object_table, view->base.id, view); |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
vkr_dispatch_vkDestroyImageView(struct vn_dispatch_context *dispatch, |
||||||
|
struct vn_command_vkDestroyImageView *args) |
||||||
|
{ |
||||||
|
struct vkr_context *ctx = dispatch->data; |
||||||
|
|
||||||
|
DESTROY_OBJECT(view, image_view, IMAGE_VIEW, vkDestroyImageView, imageView); |
||||||
|
|
||||||
|
util_hash_table_remove_u64(ctx->object_table, view->base.id); |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
vkr_dispatch_vkCreateSampler(struct vn_dispatch_context *dispatch, |
||||||
|
struct vn_command_vkCreateSampler *args) |
||||||
|
{ |
||||||
|
struct vkr_context *ctx = dispatch->data; |
||||||
|
|
||||||
|
CREATE_OBJECT(sampler, sampler, SAMPLER, vkCreateSampler, pSampler); |
||||||
|
|
||||||
|
util_hash_table_set_u64(ctx->object_table, sampler->base.id, sampler); |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
vkr_dispatch_vkDestroySampler(struct vn_dispatch_context *dispatch, |
||||||
|
struct vn_command_vkDestroySampler *args) |
||||||
|
{ |
||||||
|
struct vkr_context *ctx = dispatch->data; |
||||||
|
|
||||||
|
DESTROY_OBJECT(sampler, sampler, SAMPLER, vkDestroySampler, sampler); |
||||||
|
|
||||||
|
util_hash_table_remove_u64(ctx->object_table, sampler->base.id); |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
vkr_dispatch_vkCreateSamplerYcbcrConversion( |
||||||
|
struct vn_dispatch_context *dispatch, |
||||||
|
struct vn_command_vkCreateSamplerYcbcrConversion *args) |
||||||
|
{ |
||||||
|
struct vkr_context *ctx = dispatch->data; |
||||||
|
|
||||||
|
CREATE_OBJECT(conv, sampler_ycbcr_conversion, SAMPLER_YCBCR_CONVERSION, |
||||||
|
vkCreateSamplerYcbcrConversion, pYcbcrConversion); |
||||||
|
|
||||||
|
util_hash_table_set_u64(ctx->object_table, conv->base.id, conv); |
||||||
|
} |
||||||
|
|
||||||
|
static void |
||||||
|
vkr_dispatch_vkDestroySamplerYcbcrConversion( |
||||||
|
struct vn_dispatch_context *dispatch, |
||||||
|
struct vn_command_vkDestroySamplerYcbcrConversion *args) |
||||||
|
{ |
||||||
|
struct vkr_context *ctx = dispatch->data; |
||||||
|
|
||||||
|
DESTROY_OBJECT(conv, sampler_ycbcr_conversion, SAMPLER_YCBCR_CONVERSION, |
||||||
|
vkDestroySamplerYcbcrConversion, ycbcrConversion); |
||||||
|
|
||||||
|
util_hash_table_remove_u64(ctx->object_table, conv->base.id); |
||||||
|
} |
||||||
|
|
||||||
|
void |
||||||
|
vkr_context_init_image_dispatch(struct vkr_context *ctx) |
||||||
|
{ |
||||||
|
struct vn_dispatch_context *dispatch = &ctx->dispatch; |
||||||
|
|
||||||
|
dispatch->dispatch_vkCreateImage = vkr_dispatch_vkCreateImage; |
||||||
|
dispatch->dispatch_vkDestroyImage = vkr_dispatch_vkDestroyImage; |
||||||
|
dispatch->dispatch_vkGetImageMemoryRequirements = |
||||||
|
vkr_dispatch_vkGetImageMemoryRequirements; |
||||||
|
dispatch->dispatch_vkGetImageMemoryRequirements2 = |
||||||
|
vkr_dispatch_vkGetImageMemoryRequirements2; |
||||||
|
dispatch->dispatch_vkGetImageSparseMemoryRequirements = |
||||||
|
vkr_dispatch_vkGetImageSparseMemoryRequirements; |
||||||
|
dispatch->dispatch_vkGetImageSparseMemoryRequirements2 = |
||||||
|
vkr_dispatch_vkGetImageSparseMemoryRequirements2; |
||||||
|
dispatch->dispatch_vkBindImageMemory = vkr_dispatch_vkBindImageMemory; |
||||||
|
dispatch->dispatch_vkBindImageMemory2 = vkr_dispatch_vkBindImageMemory2; |
||||||
|
dispatch->dispatch_vkGetImageSubresourceLayout = |
||||||
|
vkr_dispatch_vkGetImageSubresourceLayout; |
||||||
|
|
||||||
|
dispatch->dispatch_vkGetImageDrmFormatModifierPropertiesEXT = |
||||||
|
vkr_dispatch_vkGetImageDrmFormatModifierPropertiesEXT; |
||||||
|
} |
||||||
|
|
||||||
|
void |
||||||
|
vkr_context_init_image_view_dispatch(struct vkr_context *ctx) |
||||||
|
{ |
||||||
|
struct vn_dispatch_context *dispatch = &ctx->dispatch; |
||||||
|
|
||||||
|
dispatch->dispatch_vkCreateImageView = vkr_dispatch_vkCreateImageView; |
||||||
|
dispatch->dispatch_vkDestroyImageView = vkr_dispatch_vkDestroyImageView; |
||||||
|
} |
||||||
|
|
||||||
|
void |
||||||
|
vkr_context_init_sampler_dispatch(struct vkr_context *ctx) |
||||||
|
{ |
||||||
|
struct vn_dispatch_context *dispatch = &ctx->dispatch; |
||||||
|
|
||||||
|
dispatch->dispatch_vkCreateSampler = vkr_dispatch_vkCreateSampler; |
||||||
|
dispatch->dispatch_vkDestroySampler = vkr_dispatch_vkDestroySampler; |
||||||
|
} |
||||||
|
|
||||||
|
void |
||||||
|
vkr_context_init_sampler_ycbcr_conversion_dispatch(struct vkr_context *ctx) |
||||||
|
{ |
||||||
|
struct vn_dispatch_context *dispatch = &ctx->dispatch; |
||||||
|
|
||||||
|
dispatch->dispatch_vkCreateSamplerYcbcrConversion = |
||||||
|
vkr_dispatch_vkCreateSamplerYcbcrConversion; |
||||||
|
dispatch->dispatch_vkDestroySamplerYcbcrConversion = |
||||||
|
vkr_dispatch_vkDestroySamplerYcbcrConversion; |
||||||
|
} |
Loading…
Reference in new issue