Revert "[fuchsia] Use scenic allocator service (#25385)" (flutter/engine#25655)
This reverts commit f0cf6ac1a8.
This commit is contained in:
@@ -134,7 +134,6 @@ template("runner_sources") {
|
||||
"$fuchsia_sdk_root/fidl:fuchsia.images",
|
||||
"$fuchsia_sdk_root/fidl:fuchsia.intl",
|
||||
"$fuchsia_sdk_root/fidl:fuchsia.io",
|
||||
"$fuchsia_sdk_root/fidl:fuchsia.scenic.allocation",
|
||||
"$fuchsia_sdk_root/fidl:fuchsia.sys",
|
||||
"$fuchsia_sdk_root/fidl:fuchsia.ui.app",
|
||||
"$fuchsia_sdk_root/fidl:fuchsia.ui.scenic",
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
"fuchsia.logger.LogSink",
|
||||
"fuchsia.net.NameLookup",
|
||||
"fuchsia.posix.socket.Provider",
|
||||
"fuchsia.scenic.allocation.Allocator",
|
||||
"fuchsia.sysmem.Allocator",
|
||||
"fuchsia.timezone.Timezone",
|
||||
"fuchsia.tracing.provider.Registry",
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
"fuchsia.logger.LogSink",
|
||||
"fuchsia.net.NameLookup",
|
||||
"fuchsia.posix.socket.Provider",
|
||||
"fuchsia.scenic.allocation.Allocator",
|
||||
"fuchsia.sysmem.Allocator",
|
||||
"fuchsia.timezone.Timezone",
|
||||
"fuchsia.tracing.provider.Registry",
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
"fuchsia.logger.LogSink",
|
||||
"fuchsia.net.NameLookup",
|
||||
"fuchsia.posix.socket.Provider",
|
||||
"fuchsia.scenic.allocation.Allocator",
|
||||
"fuchsia.sysmem.Allocator",
|
||||
"fuchsia.timezone.Timezone",
|
||||
"fuchsia.tracing.provider.Registry",
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
"fuchsia.logger.LogSink",
|
||||
"fuchsia.net.NameLookup",
|
||||
"fuchsia.posix.socket.Provider",
|
||||
"fuchsia.scenic.allocation.Allocator",
|
||||
"fuchsia.sysmem.Allocator",
|
||||
"fuchsia.timezone.Timezone",
|
||||
"fuchsia.tracing.provider.Registry",
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
"services": [
|
||||
"fuchsia.logger.LogSink",
|
||||
"fuchsia.sys.Environment",
|
||||
"fuchsia.scenic.allocation.Allocator",
|
||||
"fuchsia.sysmem.Allocator",
|
||||
"fuchsia.tracing.provider.Registry",
|
||||
"fuchsia.ui.input.ImeService",
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
"facets": {
|
||||
"fuchsia.test": {
|
||||
"system-services": [
|
||||
"fuchsia.scenic.allocation.Allocator",
|
||||
"fuchsia.sysmem.Allocator",
|
||||
"fuchsia.ui.scenic.Scenic",
|
||||
"fuchsia.vulkan.loader.Loader"
|
||||
@@ -28,7 +27,6 @@
|
||||
"fuchsia.process.Launcher",
|
||||
"fuchsia.vulkan.loader.Loader",
|
||||
"fuchsia.logger.LogSink",
|
||||
"fuchsia.scenic.allocation.Allocator",
|
||||
"fuchsia.sysmem.Allocator",
|
||||
"fuchsia.ui.scenic.Scenic"
|
||||
]
|
||||
|
||||
@@ -103,24 +103,15 @@ bool VulkanSurface::CreateVulkanImage(vulkan::VulkanProvider& vulkan_provider,
|
||||
VulkanSurface::VulkanSurface(
|
||||
vulkan::VulkanProvider& vulkan_provider,
|
||||
fuchsia::sysmem::AllocatorSyncPtr& sysmem_allocator,
|
||||
fuchsia::scenic::allocation::AllocatorPtr& scenic_allocator,
|
||||
sk_sp<GrDirectContext> context,
|
||||
scenic::Session* session,
|
||||
const SkISize& size)
|
||||
const SkISize& size,
|
||||
uint32_t buffer_id)
|
||||
: vulkan_provider_(vulkan_provider), session_(session), wait_(this) {
|
||||
FML_DCHECK(session_);
|
||||
|
||||
fuchsia::scenic::allocation::BufferCollectionExportToken export_token;
|
||||
fuchsia::scenic::allocation::BufferCollectionImportToken import_token;
|
||||
if (zx::eventpair::create(0, &export_token.value, &import_token.value) !=
|
||||
ZX_OK) {
|
||||
FML_DLOG(INFO) << "Failed to create event pair";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AllocateDeviceMemory(sysmem_allocator, scenic_allocator,
|
||||
std::move(export_token), std::move(context),
|
||||
size)) {
|
||||
if (!AllocateDeviceMemory(sysmem_allocator, std::move(context), size,
|
||||
buffer_id)) {
|
||||
FML_DLOG(INFO) << "Could not allocate device memory.";
|
||||
return;
|
||||
}
|
||||
@@ -130,7 +121,7 @@ VulkanSurface::VulkanSurface(
|
||||
return;
|
||||
}
|
||||
|
||||
PushSessionImageSetupOps(session, std::move(import_token));
|
||||
PushSessionImageSetupOps(session);
|
||||
|
||||
std::fill(size_history_.begin(), size_history_.end(), SkISize::MakeEmpty());
|
||||
|
||||
@@ -145,6 +136,9 @@ VulkanSurface::~VulkanSurface() {
|
||||
if (image_id_) {
|
||||
session_->Enqueue(scenic::NewReleaseResourceCmd(image_id_));
|
||||
}
|
||||
if (buffer_id_) {
|
||||
session_->DeregisterBufferCollection(buffer_id_);
|
||||
}
|
||||
wait_.Cancel();
|
||||
wait_.set_object(ZX_HANDLE_INVALID);
|
||||
}
|
||||
@@ -230,10 +224,9 @@ bool VulkanSurface::CreateFences() {
|
||||
|
||||
bool VulkanSurface::AllocateDeviceMemory(
|
||||
fuchsia::sysmem::AllocatorSyncPtr& sysmem_allocator,
|
||||
fuchsia::scenic::allocation::AllocatorPtr& scenic_allocator,
|
||||
fuchsia::scenic::allocation::BufferCollectionExportToken export_token,
|
||||
sk_sp<GrDirectContext> context,
|
||||
const SkISize& size) {
|
||||
const SkISize& size,
|
||||
uint32_t buffer_id) {
|
||||
if (size.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
@@ -249,14 +242,8 @@ bool VulkanSurface::AllocateDeviceMemory(
|
||||
status = vulkan_token->Sync();
|
||||
LOG_AND_RETURN(status != ZX_OK, "Failed to sync token");
|
||||
|
||||
scenic_allocator->RegisterBufferCollection(
|
||||
std::move(export_token), std::move(scenic_token),
|
||||
[](fuchsia::scenic::allocation::Allocator_RegisterBufferCollection_Result
|
||||
result) {
|
||||
if (result.is_err()) {
|
||||
FML_DLOG(ERROR) << "RegisterBufferCollection failed";
|
||||
}
|
||||
});
|
||||
session_->RegisterBufferCollection(buffer_id, std::move(scenic_token));
|
||||
buffer_id_ = buffer_id;
|
||||
|
||||
VkBufferCollectionCreateInfoFUCHSIA import_info;
|
||||
import_info.collectionToken = vulkan_token.Unbind().TakeChannel().release();
|
||||
@@ -383,14 +370,11 @@ bool VulkanSurface::SetupSkiaSurface(sk_sp<GrDirectContext> context,
|
||||
return true;
|
||||
}
|
||||
|
||||
void VulkanSurface::PushSessionImageSetupOps(
|
||||
scenic::Session* session,
|
||||
fuchsia::scenic::allocation::BufferCollectionImportToken import_token) {
|
||||
void VulkanSurface::PushSessionImageSetupOps(scenic::Session* session) {
|
||||
if (image_id_ == 0)
|
||||
image_id_ = session->AllocResourceId();
|
||||
session->Enqueue(scenic::NewCreateImage3Cmd(image_id_, sk_surface_->width(),
|
||||
sk_surface_->height(),
|
||||
std::move(import_token), 0));
|
||||
session->Enqueue(scenic::NewCreateImage2Cmd(
|
||||
image_id_, sk_surface_->width(), sk_surface_->height(), buffer_id_, 0));
|
||||
}
|
||||
|
||||
uint32_t VulkanSurface::GetImageId() {
|
||||
|
||||
@@ -71,10 +71,10 @@ class VulkanSurface final : public SurfaceProducerSurface {
|
||||
public:
|
||||
VulkanSurface(vulkan::VulkanProvider& vulkan_provider,
|
||||
fuchsia::sysmem::AllocatorSyncPtr& sysmem_allocator,
|
||||
fuchsia::scenic::allocation::AllocatorPtr& scenic_allocator,
|
||||
sk_sp<GrDirectContext> context,
|
||||
scenic::Session* session,
|
||||
const SkISize& size);
|
||||
const SkISize& size,
|
||||
uint32_t buffer_id);
|
||||
|
||||
~VulkanSurface() override;
|
||||
|
||||
@@ -144,12 +144,10 @@ class VulkanSurface final : public SurfaceProducerSurface {
|
||||
zx_status_t status,
|
||||
const zx_packet_signal_t* signal);
|
||||
|
||||
bool AllocateDeviceMemory(
|
||||
fuchsia::sysmem::AllocatorSyncPtr& sysmem_allocator,
|
||||
fuchsia::scenic::allocation::AllocatorPtr& scenic_allocator,
|
||||
fuchsia::scenic::allocation::BufferCollectionExportToken export_token,
|
||||
sk_sp<GrDirectContext> context,
|
||||
const SkISize& size);
|
||||
bool AllocateDeviceMemory(fuchsia::sysmem::AllocatorSyncPtr& sysmem_allocator,
|
||||
sk_sp<GrDirectContext> context,
|
||||
const SkISize& size,
|
||||
uint32_t buffer_id);
|
||||
|
||||
bool CreateVulkanImage(vulkan::VulkanProvider& vulkan_provider,
|
||||
const SkISize& size,
|
||||
@@ -163,9 +161,7 @@ class VulkanSurface final : public SurfaceProducerSurface {
|
||||
|
||||
bool CreateFences();
|
||||
|
||||
void PushSessionImageSetupOps(
|
||||
scenic::Session* session,
|
||||
fuchsia::scenic::allocation::BufferCollectionImportToken import_token);
|
||||
void PushSessionImageSetupOps(scenic::Session* session);
|
||||
|
||||
void Reset();
|
||||
|
||||
@@ -179,6 +175,7 @@ class VulkanSurface final : public SurfaceProducerSurface {
|
||||
VkMemoryAllocateInfo vk_memory_info_;
|
||||
vulkan::VulkanHandle<VkFence> command_buffer_fence_;
|
||||
sk_sp<SkSurface> sk_surface_;
|
||||
uint32_t buffer_id_ = 0;
|
||||
uint32_t image_id_ = 0;
|
||||
vulkan::VulkanHandle<VkBufferCollectionFUCHSIA> collection_;
|
||||
zx::event acquire_event_;
|
||||
|
||||
@@ -41,10 +41,6 @@ VulkanSurfacePool::VulkanSurfacePool(vulkan::VulkanProvider& vulkan_provider,
|
||||
sysmem_allocator_->SetDebugClientInfo(GetCurrentProcessName(),
|
||||
GetCurrentProcessId());
|
||||
FML_DCHECK(status != ZX_OK);
|
||||
status = fdio_service_connect(
|
||||
"/svc/fuchsia.scenic.allocation.Allocator",
|
||||
scenic_allocator_.NewRequest().TakeChannel().release());
|
||||
FML_DCHECK(status != ZX_OK);
|
||||
}
|
||||
|
||||
VulkanSurfacePool::~VulkanSurfacePool() {}
|
||||
@@ -118,8 +114,8 @@ std::unique_ptr<VulkanSurface> VulkanSurfacePool::CreateSurface(
|
||||
TRACE_EVENT2("flutter", "VulkanSurfacePool::CreateSurface", "width",
|
||||
size.width(), "height", size.height());
|
||||
auto surface = std::make_unique<VulkanSurface>(
|
||||
vulkan_provider_, sysmem_allocator_, scenic_allocator_, context_,
|
||||
scenic_session_, size);
|
||||
vulkan_provider_, sysmem_allocator_, context_, scenic_session_, size,
|
||||
buffer_id_++);
|
||||
if (!surface->IsValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -42,10 +42,10 @@ class VulkanSurfacePool final {
|
||||
sk_sp<GrDirectContext> context_;
|
||||
scenic::Session* scenic_session_;
|
||||
fuchsia::sysmem::AllocatorSyncPtr sysmem_allocator_;
|
||||
fuchsia::scenic::allocation::AllocatorPtr scenic_allocator_;
|
||||
std::vector<std::unique_ptr<VulkanSurface>> available_surfaces_;
|
||||
std::unordered_map<uintptr_t, std::unique_ptr<VulkanSurface>>
|
||||
pending_surfaces_;
|
||||
uint32_t buffer_id_ = 1;
|
||||
|
||||
size_t trace_surfaces_created_ = 0;
|
||||
size_t trace_surfaces_reused_ = 0;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
"facets": {
|
||||
"fuchsia.test": {
|
||||
"system-services": [
|
||||
"fuchsia.scenic.allocation.Allocator",
|
||||
"fuchsia.sysmem.Allocator",
|
||||
"fuchsia.vulkan.loader.Loader"
|
||||
]
|
||||
@@ -26,7 +25,6 @@
|
||||
"fuchsia.logger.LogSink",
|
||||
"fuchsia.process.Launcher",
|
||||
"fuchsia.settings.Intl",
|
||||
"fuchsia.scenic.allocation.Allocator",
|
||||
"fuchsia.sysmem.Allocator",
|
||||
"fuchsia.tracing.provider.Registry",
|
||||
"fuchsia.ui.input3.Keyboard",
|
||||
|
||||
Reference in New Issue
Block a user