forked from xuzhongxing/fuchsia-notes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scenic.txt
131 lines (104 loc) · 5.38 KB
/
scenic.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
service_root通向"/svc/"
CreateStaticServiceRootHandle()
fdio_service_connect("/svc/.", h1.release())
fdio_ns_connect(fdio_root_ns, svcpath, ZX_FS_RIGHT_READABLE | ZX_FS_RIGHT_WRITABLE, h);
__libc_extensions_init里面会把fdio的各种handle设置好。
这样app就可以用fdio_ns_connect来获取channel了
如果root namespace里面没有"/svc/",则这个进程不能访问这个名字
StartupContext::StartupContext(zx::channel service_root, zx::channel directory_request) {
incoming_services_.Bind(std::move(service_root));
directory_ = std::move(directory);
outgoing_.Serve(std::move(directory_request));
vfs_.ServeDirectory(root_dir_, std::move(dir_request))
environment_.NewRequest() // InterfacePtr<Environment>::NewRequest()
zx::channel::create(0, &h1, &h2)
Bind(std::move(h1), async)
impl_->controller.reader().Bind(std::move(channel), async); ????
return InterfaceRequest<Interface>(std::move(h2))
把通道的一头挂在本地事件循环里,Environment服务的客户端。
incoming_services_.ConnectToService(environment_.NewRequest());
incoming_services_.ConnectToService(launcher_.NewRequest());
}
App::App(fuchsia::sys::StartupContext* app_context, fit::closure quit_callback)
: scenic_(std::make_unique<Scenic>(app_context, std::move(quit_callback)))
app_context->outgoing().AddPublicService(scenic_bindings_.GetHandler(this));
scenic_->RegisterSystem<scenic::gfx::GfxSystem>() // SystemT = scenic::gfx::GfxSystem
system = new GfxSystem(SystemContext(app_context_, quit_callback_.share())
display_manager_.WaitForDefaultDisplay(cb1)
display_watcher_.WaitForDisplay(cb2)
device_watcher_ = fsl::DeviceWatcher::Create("/dev/class/display-controller", cb3)
open("/dev/class/display-controller", O_DIRECTORY | O_RDONLY);
这里会触发display controller里面的DdkOpenAt()被调用,会给DisplayManager发送DisplaysChanged rpc
zx_channel_create(0, &wd.channel, &dir_watch_handle)
ioctl_vfs_watch_dir(dir_fd.get(), &wd)
device watcher会触发cb3的调用
如果/dev/class/display-controller存在,调用DeviceWatcher::Handler
DisplayWatcher::HandleDevice
ioctl_display_controller_get_handle(fd.get(), dc_handle.reset_and_get_address())
把ClientProxy的client handle拿到dc_handle里。
调用cb2
display_controller_.Bind(std::move(dc_handle));
让wait开始处理display controller传来的消息:OnAsync()
由于刚才open display-controller的时候触发了display controller发送DisplaysChanged rpc
所以调用
DisplayManager::OnAsync()
DisplayManager::DisplaysChanged()
display_controller_->CreateLayer(&status, &layer_id_);
rpc 调用display controller
Client::HandleCreateLayer
CreateLayer(&resp->layer_id);
创建一个Layer
display_controller_->SetDisplayLayers(display.id, std::move(fidl_layers))
rpc:
Client::HandleSetDisplayLayers
把它放到对应的display的pending layers里
default_display_ = std::make_unique<Display>
创建新的Display
ClientOwnershipChange(owns_display_controller_);
default_display_->ownership_event().signal(
fuchsia::ui::scenic::displayOwnedSignal,
fuchsia::ui::scenic::displayNotOwnedSignal);
给这个event发信号。暂时不知道谁会处理。mark一下。
display_available_cb_(); 调用cb1
GfxSystem::Initialize()
escher::VulkanIsSupported()
首先检查是否有Vulkan支持
CheckIfVulkanIsSupported();
CreateVulkanInstance();
vk::createInstance(&instance_info, nullptr, &instance)
CreateVulkanDevice(instance);
physical_device.createDevice(&device_info, nullptr, &device)
InitializeEscher();
escher::VulkanInstance::New(std::move(instance_params));
vk::createInstance(info);
CreateVulkanMagmaSurface(vulkan_instance_->vk_instance());
vkCreateMagmaSurfaceKHR(instance, &create_info, nullptr, &surface);
定义在third_party/mesa/src/intel/vulkan/anv_wsi_magma.cc
anv_CreateMagmaSurfaceKHR()
surface里面只有一个类型和是否有fb
fb_bind(false, &err) // framebuffer.c
这个会返回false, failed to open display controller
VkIcdSurfaceBase_to_handle(&surface->base);
定义在third_party/mesa/src/vulkan/wsi/wsi_common.h
是个指针或者uint64
escher::VulkanDeviceQueues::New(vulkan_instance_, device_queues_params);
FindSuitablePhysicalDeviceAndQueueFamilies(instance, params);
physical_device.createDevice(device_info);
创建逻辑设备
main queue, transfer queue是同一个。
escher::GlslangInitializeProcess();
glslang::InitializeProcess();
ShInitialize()
InitProcess()
InitializePoolIndex()
InitThread()
Escher::Escher(VulkanDeviceQueuesPtr device)
escher有一堆成员
InitializeEngine();
escher::PaperRenderer::New(escher_)
escher::ShadowMapRenderer::New(escher_, paper_renderer_->model_data(),
paper_renderer_->model_renderer())
std::make_unique<SessionManager>()
InitializeFrameScheduler();
====
scenic_->RegisterSystem<SketchySystem>(scenic);