版本:22.0.5
硬件:swrast
入口:_mesa_DrawArrays
和i965的区别:
从 _mesa_draw_arrays 开始 Driver 重命名
ctx->Driver.DrawGallium(ctx, &info, 0, &draw, 1);
DrawGallium的加载
经过三层,从API到gallium、gllium到state tracker、再从state tracker到真正的driver。
进入state_tracker/st_draw.c
st_init_draw_functions(struct pipe_screen *screen,
struct dd_function_table *functions)
{
functions->DrawGallium = st_draw_gallium;
functions->DrawGalliumMultiMode = st_draw_gallium_multimode;
if (screen->get_param(screen, PIPE_CAP_DRAW_VERTEX_STATE)) {
functions->DrawGalliumVertexState = st_draw_gallium_vertex_state;
functions->CreateGalliumVertexState = st_create_gallium_vertex_state;
}
}
- st_init_draw_functions被调用的过程,draw函数的加载过程:
从 eglCreateContext 中调用的
context = disp->Driver->CreateContext(disp, conf, share, attrib_list);
const struct __DriverAPIRec galliumdrm_driver_api = {
.InitScreen = dri2_init_screen,
.DestroyScreen = dri_destroy_screen,
.CreateContext = dri_create_context,
.DestroyContext = dri_destroy_context,
.CreateBuffer = dri2_create_buffer,
.DestroyBuffer = dri_destroy_buffer,
.MakeCurrent = dri_make_current,
.UnbindContext = dri_unbind_context,
.AllocateBuffer = dri2_allocate_buffer,
.ReleaseBuffer = dri2_release_buffer,
};
-> 到gallium/frontends/dri/dri_context.c: dri_create_context
ctx->st = stapi->create_context(stapi, &screen->base, &attribs, &ctx_err,
st_share);
static const struct st_api st_gl_api = {
.name = "Mesa " PACKAGE_VERSION,
.api = ST_API_OPENGL,
.profile_mask = ST_PROFILE_DEFAULT_MASK |
ST_PROFILE_OPENGL_CORE_MASK |
ST_PROFILE_OPENGL_ES1_MASK |
ST_PROFILE_OPENGL_ES2_MASK |
0,
.feature_mask = ST_API_FEATURE_MS_VISUALS_MASK,
.destroy = st_api_destroy,
.query_versions = st_api_query_versions,
.create_context = st_api_create_context,
.make_current = st_api_make_current,
.get_current = st_api_get_current,
.destroy_drawable = st_api_destroy_drawable,
};
-> state_tracker/st_manager.c:st_api_create_context
st = st_create_context(api, pipe, mode_ptr, shared_ctx,
&attribs->options, no_error,
!!smapi->validate_egl_image);
-> state_tracker/st_context.c:st_create_context
st_init_driver_functions(pipe->screen, &funcs, has_egl_image_validate);
-> state_tracker/st_context.c:st_init_driver_functions
st_gl_api 的加载
state_tracker/st_manager.c:st_gl_api_create
struct st_api *
st_gl_api_create(void)
{
return (struct st_api *) &st_gl_api;
}
-> gallium/frontends/dri/dri_screen.c: dri_init_screen_helper
screen->st_api = st_gl_api_create();
-> gallium/frontends/dri/dri2.c: dri2_init_screen
configs = dri_init_screen_helper(screen, pscreen);
dri2_init_screen接上面的gallium driver api: .InitScreen = dri2_init_screen,
-> gallium/frontends/dri/dri_util/c: driCreateNewScreen2
*driver_configs = psp->driver->InitScreen(psp);
-> gallium/frontends/dri/dri_util/c: dri2CreateNewScreen
static __DRIscreen *
dri2CreateNewScreen(int scrn, int fd,
const __DRIextension **extensions,
const __DRIconfig ***driver_configs, void *data)
{
return driCreateNewScreen2(scrn, fd, extensions, NULL,
driver_configs, data);
}
const __DRIdri2Extension driDRI2Extension = {
.base = { __DRI_DRI2, 4 },
.createNewScreen = dri2CreateNewScreen,
.createNewDrawable = driCreateNewDrawable,
.createNewContext = driCreateNewContext,
.getAPIMask = driGetAPIMask,
.createNewContextForAPI = driCreateNewContextForAPI,
.allocateBuffer = dri2AllocateBuffer,
.releaseBuffer = dri2ReleaseBuffer,
.createContextAttribs = driCreateContextAttribs,
.createNewScreen2 = driCreateNewScreen2,
};
这里就和egl的API接上了,最终是到eglInitialize上了