-
Notifications
You must be signed in to change notification settings - Fork 102
/
shadertoy.txt
121 lines (93 loc) · 5.84 KB
/
shadertoy.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
main
rpc:
ViewProviderService::CreateView
CreateScenicSessionPtrAndListenerRequest(scenic_)
scenic->CreateSession(session.NewRequest(), listener_handle.Bind());
CreateSession(::fidl::InterfaceRequest<Session> session, ::fidl::InterfaceHandle<SessionListener> listener)
view_factory_(std::move(args));
shadertoy_client::NewView(args)
scenic::BaseView(args.startup_context,
std::move(args.session_and_listener_request), // 通向scenic session
std::move(args.view_token), debug_name),
ViewImpl::ViewImpl()
image pipe的客户端是shadertoy, 服务端是scenic
shadertoy_factory_->NewImagePipeShadertoy(shadertoy_.NewRequest(), std::move(image_pipe_handle));
====> shadertoy service:
添加binding
image_pipe bind, 另一头在shadertoy client里通过session()->Enqueue(scenic::NewCreateImagePipeCmd交给Scenic了。
shadertoy_->SetResolution
====> shadertoy service:
ShadertoyState::SetResolution
ShadertoyStateForImagePipe::OnSetResolution
ClearFramebuffers();
创建image, 分配内存,尺寸是小的
Framebuffer::Framebuffer
info.pAttachments = image_views_.data();
device.createFramebuffer(info)
把image绑定到framebuffer上了
后面render就会画到这个image上
image_pipe_->AddImage(fb.image_pipe_id, std::move(image_info), std::move(vmo),fuchsia::images::MemoryType::VK_DEVICE_MEMORY, image->memory_offset());
====> scenic:
images_.AddResource(image_id, image)
添加的是GpuImage
RequestFrame(0);
DrawFrame(presentation_time=0, stopwatch_.GetElapsedSeconds()=0);
renderer()->DrawFrame
escher()->NewFrame("Shadertoy Renderer", ++frame_number_);
最后submit command buffer
image_pipe_->PresentImage
====> scenic:
ImagePipe::PresentImage
====> async wait
weak->session()->ScheduleImagePipeUpdate(presentation_time,ImagePipePtr(weak.get()));
Session::ScheduleImagePipeUpdate
scheduled_image_pipe_updates_.push({presentation_time, std::move(image_pipe)});
engine_->session_manager()->ScheduleUpdateForSession(engine_, presentation_time, SessionPtr(this));
SessionManager::ScheduleUpdateForSession
updatable_sessions_.insert({presentation_time, std::move(session)});
update_scheduler->ScheduleUpdate(presentation_time);
Engine::ScheduleUpdate
frame_scheduler_->RequestFrame(presentation_time);
转root_presenter.txt
====> shadertoy service async loop
callback:
self->OnFramePresented(std::move(info));
ShadertoyState::OnFramePresented
RequestFrame(info.presentation_time + info.presentation_interval);
建立了request循环
shadertoy_->SetShaderCode
====> shadertoy service:
ShadertoyState::SetShaderCode
compile callback:
compiler_->Compile
compiler_->Compile // 生成pipeline
glsl编译好了就开始render
weak->RequestFrame(0);
DrawFrame(presentation_time, stopwatch_.GetElapsedSeconds());
renderer()->DrawFrame(fb.framebuffer, pipeline(), params, channel0(),
channel1(), channel2(), channel3(),
fb.release_semaphore, fb.acquire_semaphore);
escher()->NewFrame("Shadertoy Renderer", ++frame_number_); // 这个是本地的escher
frame_manager_->NewFrame
frame->BeginFrame();
CommandBuffer::NewForGraphics(escher());
GetUpdatedDescriptorSet(frame, channel0, channel1, channel2, channel3);
command_buffer->BeginRenderPass(
command_buffer_.beginRenderPass
command_buffer->EndRenderPass();
frame->EndFrame
command_buffer_->Submit
image_pipe_->PresentImage
====>
在scenic进程:
image_pipe_->PresentImage
shadertoy_->SetPaused(false);
====> shadertoy service
RequestFrame(0);
// Create a rounded-rect shape to display the Shadertoy image on.
把image pipe接入一个material, 然后放入一个RoundedRectangle,放入root node.
InvalidateScene();
PresentScene(last_presentation_time_);
session()->Present
====> scenic
触发scenic端的命令执行