mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-13 10:03:41 +00:00
This CL is part of a chain of CLs that imports dma-bufs as VkImages to support WebGPU on Chrome OS. There are currently two steps for importing external memory into Vulkan: 1. DeviceVk::ImportExternalImage: calls into MemoryServiceOpaqueFD::ImportMemory which in turn calls into vkAllocateMemory and outputs a VkDeviceMemory handle to the imported memory. 2. TextureVk::CreateFromExternal: creates the actual TextureVk object, creates the VkImage, and binds the VkDeviceMemory from ImportExternalImage to the VkImage. For dma-buf support, however, we need to re-order these two steps because importing dma-buf memory requires a handle to the VkImage that will alias it [1]. This CL splits these two steps into three steps to ensure we create the VkImage first so we can use it in vkAllocateMemory: 1. TextureVk::CreateFromExternal: creates the TextureVk and VkImage (no longer concerns itself with vkBindImageMemory). 2. DeviceVk::ImportExternalImage: now takes the VkImage as input but is otherwise unchanged. 3. TextureVk::BindExternalMemory: calls vkBindImageMemory with handles to VkDeviceMemory and VkImage. [1] https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkMemoryDedicatedAllocateInfo.html BUG=chromium:996470 Change-Id: Id2d5951e9b573af79c44ce8c63be5210a279f946 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/13780 Commit-Queue: Brian Ho <hob@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org>
48 lines
1.8 KiB
C++
48 lines
1.8 KiB
C++
// Copyright 2019 The Dawn Authors
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#include "dawn_native/vulkan/DeviceVk.h"
|
|
#include "dawn_native/vulkan/external_memory/MemoryService.h"
|
|
|
|
namespace dawn_native { namespace vulkan { namespace external_memory {
|
|
|
|
Service::Service(Device* device) : mDevice(device) {
|
|
DAWN_UNUSED(mDevice);
|
|
DAWN_UNUSED(mSupported);
|
|
}
|
|
|
|
Service::~Service() = default;
|
|
|
|
bool Service::Supported(VkFormat format,
|
|
VkImageType type,
|
|
VkImageTiling tiling,
|
|
VkImageUsageFlags usage,
|
|
VkImageCreateFlags flags) {
|
|
return false;
|
|
}
|
|
|
|
ResultOrError<MemoryImportParams> Service::GetMemoryImportParams(
|
|
const ExternalImageDescriptor* descriptor,
|
|
VkImage image) {
|
|
return DAWN_UNIMPLEMENTED_ERROR("Using null memory service to interop inside Vulkan");
|
|
}
|
|
|
|
ResultOrError<VkDeviceMemory> Service::ImportMemory(ExternalMemoryHandle handle,
|
|
const MemoryImportParams& importParams,
|
|
VkImage image) {
|
|
return DAWN_UNIMPLEMENTED_ERROR("Using null memory service to interop inside Vulkan");
|
|
}
|
|
|
|
}}} // namespace dawn_native::vulkan::external_memory
|