opengl 多线程渲染中的问题

Name

eglMakeCurrent — attach an EGL rendering context to EGL surfaces

把EGL的渲染上下文贴到EGL的表面上

C Specification

EGLBoolean eglMakeCurrent( EGLDisplay display,
  EGLSurface draw,
  EGLSurface read,
  EGLContext context);
 

Parameters

display

Specifies the EGL display connection.

draw

Specifies the EGL draw surface.

read

Specifies the EGL read surface.

context

Specifies the EGL rendering context to be attached to the surfaces.

Description

eglMakeCurrent binds context to the current rendering thread and to the draw and read surfaces. draw is used for all GL operations except for any pixel data read back (glReadPixelsglCopyTexImage2D, and glCopyTexSubImage2D), which is taken from the frame buffer values of read.

If the calling thread has already a current rendering context, that context is flushed and marked as no longer current.

The first time that context is made current, the viewport and scissor dimensions are set to the size of the draw surface. The viewport and scissor are not modified whencontext is subsequently made current.

To release the current context without assigning a new one, call eglMakeCurrent with draw and read set to EGL_NO_SURFACE and context set to EGL_NO_CONTEXT.

Use eglGetCurrentContexteglGetCurrentDisplay, and eglGetCurrentSurface to query the current rendering context and associated display connection and surfaces.



首先 第一

在 eglMakeCurrent函数中,有下面这段检查,意思是说,要不然read draw buffer都为空,要不然就都不能为空。

eglapi.c

if (!draw_surf || !read_surf) {
      /* surfaces may be NULL if surfaceless */
      if (!disp->Extensions.KHR_surfaceless_context)
         RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE);

      if ((!draw_surf && draw != EGL_NO_SURFACE) ||
          (!read_surf && read != EGL_NO_SURFACE))
         RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE);
      if (draw_surf || read_surf)
         RETURN_EGL_ERROR(disp, EGL_BAD_MATCH, EGL_FALSE);
   }


然后在eglContext.c中有以下代码

这里ctx表示着当前需要绑定的context,然后draw表示需要读的surface,那么可以看出surface也必须是已经绑定了本个线程的context

里面有一句话。假如draw或者read的surface已经在别的线程被绑定了,那么这里会产生一个错误,那就是EGL_BAD_ACESS

/*
    * The spec says
    *
    * "If ctx is current to some other thread, or if either draw or read are
    * bound to contexts in another thread, an EGL_BAD_ACCESS error is
    * generated."and at most one context may be bound to a particular surface at a given
    * time"
    */

  if (draw && draw->CurrentContext && draw->CurrentContext != ctx) {
      if (draw->CurrentContext->Binding != t ||
          draw->CurrentContext->ClientAPI != ctx->ClientAPI)
         return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent");
   }


  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值