Thursday, June 20, 2013

GPU Process analysis: hello_triangle_exe (GPU Process on single process and single thread)

GPU Process has demo project for example. There is hello_triangle_exe. I analysis hellow_triangle_exe to understand GPU Process.

How to build

> export GYP_GENERATORS='ninja'
> export GYP_GENERATOR_FLAGS="output_dir=out_gpu"
> export CHROMIUM_GYP_FILE="gpu/demos/demos.gyp"
> ./build/gyp_chromium
> ninja -C out_gpu/Release -j 6 hello_triangle_exe


Overview (seq. diagram)

origin: http://www.diagrammr.com/edit?key=dQ65fKDGRSz

demo does not launch gpu process or thread. However if we create GLES2SmdHelper with CommandBufferProxy instead of CommandBufferService, it would be possible to launch gpu process. How? I don't know yet.

callstack

Final glcall's callstack in above fig.
gfx::GLApiBase::glShaderSourceFn - gl_bindings_autogen_gl.cc, line 3817
gpu::gles2::ProgramManager::ForceCompileShader - program_manager.cc, line 489
gpu::gles2::ProgramManager::DoCompileShader - program_manager.cc, line 461
gpu::gles2::GLES2DecoderImpl::DoCompileShader - gles2_cmd_decoder.cc, line 6258
gpu::gles2::GLES2DecoderImpl::HandleCompileShader - gles2_cmd_decoder_autogen.h, line 330
gpu::gles2::GLES2DecoderImpl::DoCommand - gles2_cmd_decoder.cc, line 3490
gpu::CommandParser::ProcessCommand - cmd_parser.cc, line 72
gpu::GpuScheduler::PutChanged - gpu_scheduler.cc, line 78
base::internal::RunnableAdapter{void (gpu::GpuScheduler::*)()}::Run - bind_internal.h, line 134
base::internal::InvokeHelper{fals - bind_internal.h, line 871
base::internal::Invoker{ - bind_internal.h, line 1169
base::Callback{void ()}::Run() const - callback.h, line 396
gpu::CommandBufferService::FlushSync - command_buffer_service.cc, line 78
gpu::CommandBufferHelper::FlushSync - cmd_buffer_helper.cc, line 109
gpu::CommandBufferHelper::Finish - cmd_buffer_helper.cc, line 136
gpu::gles2::GLES2Implementation::WaitForCmd - gles2_implementation.cc, line 317
gpu::gles2::GLES2Implementation::GetShaderiv - gles2_implementation_impl_autogen.h, line 711
GLES2GetShaderiv - gles2_c_lib_autogen.h, line 254
esLoadShader - esShader.c, line 61
esLoadProgram - esShader.c, line 104
htInit - Hello_Triangle.c, line 47
gpu::demos::gles2_book::Example{HTUserData}::InitGL - example.h, line 54
gpu::demos::Window::Init - window.cc, line 63
main - main_exe.cc, line 34

How to control which call either GLES2Impl or GLApi


use GLES2Impl
It means using GPU Process.

  • #include <GLES2/gl2.h> 
  • #include "gpu/command_buffer/client/gles2_lib.h" and call like ::gles2::GetGLContext()->SwapBuffers() 
use GLApi
It means calling gl directly.
  • #include "ui/gl/gl_gl_api_implementation.h"




No comments:

Post a Comment