文章目录

  • 1 概述
  • 2 Context
    • 2.1 GLXContext
      • include/GL/glx.h
      • src/gallium/state_trackers/glx/xlib/glx_api.c
    • 2.2 XMesaContext
      • src/gallium/state_trackers/glx/xlib/xm_api.h
    • 2.3 gl_context
      • src/mesa/main/mtypes.h
    • 2.4 st_context
      • src/mesa/state_tracker/st_context.h
      • src/mesa/state_tracker/st_context.c
    • 2.5 pipe_context
      • src/gallium/include/pipe/p_context.h
  • 3 Interface
    • 3.1 Device driver interfaces
      • src/mesa/main/mtypes.h
      • src/mesa/main/dd.h
      • src/mesa/drivers/common/driverfuncs.h
      • src/mesa/drivers/common/driverfuncs.c
      • src/mesa/state_tracker/st_cb_fbo.c

1 概述

Mesa的核心数据结构包含以下几类:

  • Context
  • Interface

2 Context

2.1 GLXContext

include/GL/glx.h

typedef struct __GLXcontextRec *GLXContext;

src/gallium/state_trackers/glx/xlib/glx_api.c

/*** The GLXContext typedef is defined as a pointer to this structure.*/
struct __GLXcontextRec
{Display *currentDpy;GLboolean isDirect;GLXDrawable currentDrawable;GLXDrawable currentReadable;XID xid;XMesaContext xmesaContext;
};

2.2 XMesaContext

src/gallium/state_trackers/glx/xlib/xm_api.h

#include "main/mtypes.h" /* for gl_config */
#include "state_tracker/st_api.h"
#include "os/os_thread.h"#include "state_tracker/xlibsw_api.h"# include <X11/Xlib.h>
# include <X11/Xlibint.h>
# include <X11/Xutil.h>struct hud_context;typedef struct xmesa_display *XMesaDisplay;
typedef struct xmesa_buffer *XMesaBuffer;
typedef struct xmesa_context *XMesaContext;
typedef struct xmesa_visual *XMesaVisual;struct xmesa_display {mtx_t mutex;Display *display;struct pipe_screen *screen;struct st_manager *smapi;struct pipe_context *pipe;
};
// 省略
/*** Context info, derived from st_context.* Basically corresponds to a GLXContext.*/
struct xmesa_context {struct st_context_iface *st;XMesaVisual xm_visual;    /** pixel format info */XMesaBuffer xm_buffer;  /** current drawbuffer */XMesaBuffer xm_read_buffer;  /** current readbuffer */struct hud_context *hud;
};

2.3 gl_context

src/mesa/main/mtypes.h

/*** Mesa rendering context.** This is the central context data structure for Mesa.  Almost all* OpenGL state is contained in this structure.* Think of this as a base class from which device drivers will derive* sub classes.*/
struct gl_context
{/** State possibly shared with other contexts in the address space */struct gl_shared_state *Shared;/** \name API function pointer tables *//*@{*/gl_api API;/*** The current dispatch table for non-displaylist-saving execution, either* BeginEnd or OutsideBeginEnd*/struct _glapi_table *Exec;/*** The normal dispatch table for non-displaylist-saving, non-begin/end*/struct _glapi_table *OutsideBeginEnd;/** The dispatch table used between glNewList() and glEndList() */struct _glapi_table *Save;/*** The dispatch table used between glBegin() and glEnd() (outside of a* display list).  Only valid functions between those two are set, which is* mostly just the set in a GLvertexformat struct.*/struct _glapi_table *BeginEnd;/*** Dispatch table for when a graphics reset has happened.*/struct _glapi_table *ContextLost;/*** Dispatch table used to marshal API calls from the client program to a* separate server thread.  NULL if API calls are not being marshalled to* another thread.*/struct _glapi_table *MarshalExec;/*** Dispatch table currently in use for fielding API calls from the client* program.  If API calls are being marshalled to another thread, this ==* MarshalExec.  Otherwise it == CurrentServerDispatch.*/struct _glapi_table *CurrentClientDispatch;/*** Dispatch table currently in use for performing API calls.  == Save or* Exec.*/struct _glapi_table *CurrentServerDispatch;/*@}*/struct glthread_state *GLThread;struct gl_config Visual;struct gl_framebuffer *DrawBuffer;   /**< buffer for writing */struct gl_framebuffer *ReadBuffer; /**< buffer for reading */struct gl_framebuffer *WinSysDrawBuffer;  /**< set with MakeCurrent */struct gl_framebuffer *WinSysReadBuffer;  /**< set with MakeCurrent *//*** Device driver function pointer table*/struct dd_function_table Driver;/** Core/Driver constants */struct gl_constants Const;/** \name The various 4x4 matrix stacks *//*@{*/struct gl_matrix_stack ModelviewMatrixStack;struct gl_matrix_stack ProjectionMatrixStack;struct gl_matrix_stack TextureMatrixStack[MAX_TEXTURE_UNITS];struct gl_matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES];struct gl_matrix_stack *CurrentStack; /**< Points to one of the above stacks *//*@}*/
// 省略
};

2.4 st_context

src/mesa/state_tracker/st_context.h

struct st_context
{struct st_context_iface iface;struct gl_context *ctx;struct pipe_context *pipe;struct draw_context *draw;  /**< For selection/feedback/rastpos only */struct draw_stage *feedback_stage;  /**< For GL_FEEDBACK rendermode */struct draw_stage *selection_stage;  /**< For GL_SELECT rendermode */struct draw_stage *rastpos_stage;  /**< For glRasterPos */
// 省略
};

src/mesa/state_tracker/st_context.c

static void
st_init_driver_functions(struct pipe_screen *screen,struct dd_function_table *functions)
{_mesa_init_sampler_object_functions(functions);st_init_draw_functions(functions);st_init_blit_functions(functions);st_init_bufferobject_functions(screen, functions);st_init_clear_functions(functions);st_init_bitmap_functions(functions);st_init_copy_image_functions(functions);st_init_drawpixels_functions(functions);st_init_rasterpos_functions(functions);st_init_drawtex_functions(functions);st_init_eglimage_functions(functions);st_init_fbo_functions(functions);
// 省略
}struct st_context *
st_create_context(gl_api api, struct pipe_context *pipe,const struct gl_config *visual,struct st_context *share,const struct st_config_options *options,bool no_error)
{struct gl_context *ctx;struct gl_context *shareCtx = share ? share->ctx : NULL;struct dd_function_table funcs;struct st_context *st;util_cpu_detect();memset(&funcs, 0, sizeof(funcs));st_init_driver_functions(pipe->screen, &funcs);// 省略
}

2.5 pipe_context

src/gallium/include/pipe/p_context.h

/*** Gallium rendering context.  Basically:*  - state setting functions*  - VBO drawing functions*  - surface functions*/
struct pipe_context {struct pipe_screen *screen;void *priv;  /**< context private data (for DRI for example) */void *draw;  /**< private, for draw module (temporary?) *//*** Stream uploaders created by the driver. All drivers, state trackers, and* modules should use them.** Use u_upload_alloc or u_upload_data as many times as you want.* Once you are done, use u_upload_unmap.*/struct u_upload_mgr *stream_uploader; /* everything but shader constants */struct u_upload_mgr *const_uploader;  /* shader constants only */void (*destroy)( struct pipe_context * );

3 Interface

3.1 Device driver interfaces

src/mesa/main/mtypes.h

struct gl_context --> struct dd_function_table Driver

/*** Mesa rendering context.** This is the central context data structure for Mesa.  Almost all* OpenGL state is contained in this structure.* Think of this as a base class from which device drivers will derive* sub classes.*/
struct gl_context
{// 省略struct glthread_state *GLThread;struct gl_config Visual;struct gl_framebuffer *DrawBuffer; /**< buffer for writing */struct gl_framebuffer *ReadBuffer; /**< buffer for reading */struct gl_framebuffer *WinSysDrawBuffer;  /**< set with MakeCurrent */struct gl_framebuffer *WinSysReadBuffer;  /**< set with MakeCurrent *//*** Device driver function pointer table*/struct dd_function_table Driver; // 死亡凝视/** Core/Driver constants */struct gl_constants Const;/** \name The various 4x4 matrix stacks *//*@{*/struct gl_matrix_stack ModelviewMatrixStack;struct gl_matrix_stack ProjectionMatrixStack;struct gl_matrix_stack TextureMatrixStack[MAX_TEXTURE_UNITS];struct gl_matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES];struct gl_matrix_stack *CurrentStack; /**< Points to one of the above stacks */
// 省略
}

src/mesa/main/dd.h

/*** Device driver function table.* Core Mesa uses these function pointers to call into device drivers.* Most of these functions directly correspond to OpenGL state commands.* Core Mesa will call these functions after error checking has been done* so that the drivers don't have to worry about error testing.** Vertex transformation/clipping/lighting is patched into the T&L module.* Rasterization functions are patched into the swrast module.** Note: when new functions are added here, the drivers/common/driverfuncs.c* file should be updated too!!!*/
struct dd_function_table {/*** Return a string as needed by glGetString().* Only the GL_RENDERER query must be implemented.  Otherwise, NULL can be* returned.*/const GLubyte * (*GetString)( struct gl_context *ctx, GLenum name );/*** Notify the driver after Mesa has made some internal state changes.  ** This is in addition to any state change callbacks Mesa may already have* made.*/void (*UpdateState)(struct gl_context *ctx);/*** This is called whenever glFinish() is called.*/void (*Finish)( struct gl_context *ctx );/*** This is called whenever glFlush() is called.*/void (*Flush)( struct gl_context *ctx );/*** Clear the color/depth/stencil/accum buffer(s).* \param buffers  a bitmask of BUFFER_BIT_* flags indicating which*                 renderbuffers need to be cleared.*/void (*Clear)( struct gl_context *ctx, GLbitfield buffers );/*** Execute glRasterPos, updating the ctx->Current.Raster fields*/void (*RasterPos)( struct gl_context *ctx, const GLfloat v[4] );// 省略
}

src/mesa/drivers/common/driverfuncs.h

#ifndef DRIVERFUNCS_H
#define DRIVERFUNCS_H#ifdef __cplusplus
extern "C" {#endifextern void
_mesa_init_driver_functions(struct dd_function_table *driver);extern void
_mesa_init_driver_state(struct gl_context *ctx);#ifdef __cplusplus
} // extern "C"
#endif#endif

src/mesa/drivers/common/driverfuncs.c

/*** Plug in default functions for all pointers in the dd_function_table* structure.* Device drivers should call this function and then plug in any* functions which it wants to override.* Some functions (pointers) MUST be implemented by all drivers (REQUIRED).** \param table the dd_function_table to initialize*/
void
_mesa_init_driver_functions(struct dd_function_table *driver)
{memset(driver, 0, sizeof(*driver));driver->GetString = NULL;  /* REQUIRED! */driver->UpdateState = NULL;  /* REQUIRED! */driver->Finish = NULL;driver->Flush = NULL;
// 省略
}

src/mesa/state_tracker/st_cb_fbo.c

driver->ReadPixels = _mesa_readpixels;
_mesa_readpixels -> read_stencil_pixels -> ctx->Driver.MapRenderbuffer -> st_MapRenderbuffer

void
st_init_fbo_functions(struct dd_function_table *functions)
{functions->NewFramebuffer = _mesa_new_framebuffer;functions->NewRenderbuffer = st_new_renderbuffer;functions->FramebufferRenderbuffer = _mesa_FramebufferRenderbuffer_sw;functions->RenderTexture = st_render_texture;functions->FinishRenderTexture = st_finish_render_texture;functions->ValidateFramebuffer = st_validate_framebuffer;functions->DiscardFramebuffer = st_discard_framebuffer;functions->DrawBufferAllocate = st_DrawBufferAllocate;functions->ReadBuffer = st_ReadBuffer;functions->MapRenderbuffer = st_MapRenderbuffer;functions->UnmapRenderbuffer = st_UnmapRenderbuffer;functions->EvaluateDepthValues = st_EvaluateDepthValues;
}/*** Called via*  ctx->Driver.MapRenderbuffer.*/
static void
st_MapRenderbuffer(struct gl_context *ctx,struct gl_renderbuffer *rb,GLuint x, GLuint y, GLuint w, GLuint h,GLbitfield mode,GLubyte **mapOut, GLint *rowStrideOut,bool flip_y)
{struct st_context *st = st_context(ctx);struct st_renderbuffer *strb = st_renderbuffer(rb);struct pipe_context *pipe = st->pipe;const GLboolean invert = flip_y;GLuint y2;GLubyte *map;// 省略
}

Mesa核心数据结构相关推荐

  1. Nginx源码分析:核心数据结构ngx_cycle_t与内存池概述

    nginx源码分析 nginx-1.11.1 参考书籍<深入理解nginx模块开发与架构解析> 核心数据结构与内存池概述 在Nginx中的核心数据结构就是ngx_cycle_t结构,在初始 ...

  2. tensorflow:图(Graph)的核心数据结构与通用函数(Utility function)

    Tensorflow一些常用基本概念与函数(2) 1. 图(Graph)的核心数据结构 tf.Graph.__init__:建立一个空图: tf.Graph.as_default():一个将某图设置为 ...

  3. 01-Redis核心数据结构和高性能原理

    Redis核心数据结构和高性能原理 Redis安装 核心数据结构以及用法 String结构 字符串常用操作 原子加减 应用场景 Hash结构 Hash常用操作 Hash应用场景 Hash结构优缺点 L ...

  4. redis核心数据结构以及他的应用场景

    文章目录 redis核心数据结构 1.string字符串 1.1应用场景 2.hash哈希 2.1应用场景 2.2优缺点 3.list数组列表 3.1应用场景 4.set集合 4.1应用场景 5.zs ...

  5. OpenCV实战(2)——OpenCV核心数据结构

    OpenCV实战(2)--OpenCV核心数据结构 0. 前言 1. cv::Mat 数据结构 1.1 cv::Mat 简介 1.2 cv::Mat 属性 1.3 完整代码示例 2. 探索 cv::M ...

  6. 输入法核心数据结构及算法的设计

    输入法核心数据结构及算法的设计 突然想到了去年腾讯招实习生时笔试的附加题目,就是让你给出一个输入法的设计方案,要求能够提供智能的输入提示,具体题目要求我不太记得了,简单岂见我们只考虑英文输入法~ 问题 ...

  7. 一文读懂以太坊存储数据核心数据结构:MPT

    作者 | JouyPub 来源 | 简书 出品 | 区块链大本营 MPT (Merkle Patricia Tries) 是以太坊存储数据的核心数据结构,它是由 Merkle Tree 和 Patri ...

  8. 二、HBase的核心数据结构 跳跃表、LSM树、布隆过滤器

    文章目录 HBase的核心数据结构 跳跃表(SkipList) LSM树 布隆过滤器 布隆过滤器算法示例 HBase与布隆过滤器 HBase的核心数据结构 HBase的一个列簇(Column Fami ...

  9. linux文件系统的页高速缓存page cache中的核心数据结构address_space

    address_space对象是文件系统中关于内存中页高速缓存的核心数据结构.这篇博客以address_space对象为切入点,分析文件系统的页高速缓存.(这里大部分都是从原作者那里复制过来的,外加上 ...

  10. Redis核心数据结构List应用场景-商品列表、缓存击穿、PV阅读量、抢红包、推送帖子、普通分布式锁、Redis可重入锁与红锁

    List应用场景 Redis之List 一. Redis list命令实战 二.商品列表 高并发的淘宝聚划算实现技术方案 SpringBoot+Redis实现商品列表功能 二.缓存击穿 什么是缓存击穿 ...

最新文章

  1. 多媒体计算机技术在教学中的应用,【浅谈多媒体计算机技术在中学物理教学中的应用】计算机技术是什么...
  2. Spring Data Redis入门示例:基于RedisTemplate (三)
  3. c/c++里面的变长参数的实现
  4. Python | 字符串isdecimal(),isdigit(),isnumeric()和Methods之间的区别
  5. asp.net简单的投票系统代码 转载牛腩兄弟的
  6. python自动下载图片_python简易爬虫来实现自动图片下载
  7. day08—css布局解决方案之多列布局
  8. Spring3之InternalResourceViewResolver
  9. 连接Excel时出现未指定的错误
  10. 这个世界是怎么了?做商业软件的怎么越来越流氓了?
  11. Vbs脚本编程简明教程
  12. DNS无法解析IP_网站域名解析又出错啦!别着急,让我来帮你
  13. last_load_time和last_active_time的选择
  14. .NET并发编程-数据结构不可变性
  15. Arduino测试一块5路非自锁开关量输入模块ardunio中断编程示例
  16. 论文相关-MATHTYPE字体对应
  17. 【互动媒体】”十二个一“的文艺创作的文本分析与可视化
  18. 2017第八届蓝桥杯决赛(大学B组)java试题 瓷砖样式
  19. 直观打印二叉树的图形
  20. rop检查_他山之石丨详解抗VEGF治疗在ROP诊疗中的应用

热门文章

  1. python笔记:python中 | ^表示什么意思
  2. 用数字ic产生正弦波的仿真尝试。
  3. 【算法学习】蝙蝠算法简介
  4. Elman神经网络原理
  5. 微信撤回软件安卓版_微信强制撤回app
  6. 2021年第十八届五一数学建模竞赛题目 C题 数据驱动的异常检测与预警问题 解题论文完整版
  7. RS485电路原理以及设计
  8. 基于随机森林模型的心脏病患者预测及可视化(pdpbox、eli5、shap、graphviz库)附相关库安装教程
  9. vlfeat工具包的MATLAB安装
  10. C语言找出完数并输出