12
返回列表 发新帖
楼主: yinquan8241

CUDA与OpenGL交互问题,求救

[复制链接]
论坛徽章:
18
ITPUB9周年纪念徽章
日期:2010-10-08 09:32:26马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有车
日期:2014-02-19 11:55:14版主2段
日期:2012-05-15 15:24:112012新春纪念徽章
日期:2012-02-13 15:12:252012新春纪念徽章
日期:2012-02-13 15:12:252012新春纪念徽章
日期:2012-02-13 15:12:252012新春纪念徽章
日期:2012-02-13 15:12:25
11#
发表于 2011-5-25 08:01 | 只看该作者
貌似必须进行拷贝,不能直接把RGB数据绑定给一个二维纹理

使用道具 举报

回复
论坛徽章:
0
12#
发表于 2011-5-27 13:47 | 只看该作者
貌似这个问题很普遍啊,同求解答

使用道具 举报

回复
论坛徽章:
1
ITPUB十周年纪念徽章
日期:2011-11-01 16:20:28
13#
发表于 2011-9-20 21:34 | 只看该作者
答案保密?直接贴在后面可否?

使用道具 举报

回复
论坛徽章:
0
14#
发表于 2012-2-20 19:29 | 只看该作者
你如果用的PBO,应该要有一个把数据从PBO拷贝到纹理的一个过程吧。
  1. // "index" is used to copy pixels from a PBO to a texture object
  2. // "nextIndex" is used to update pixels in the other PBO
  3. index = (index + 1) % 2;
  4. if(pboMode == 1)                // with 1 PBO
  5.     nextIndex = index;
  6. else if(pboMode == 2)           // with 2 PBOs
  7.     nextIndex = (index + 1) % 2;

  8. // bind the texture and PBO
  9. glBindTexture(GL_TEXTURE_2D, textureId);
  10. glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pboIds[index]);

  11. // copy pixels from PBO to texture object
  12. // Use offset instead of ponter.
  13. glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, WIDTH, HEIGHT,
  14.                 GL_BGRA, GL_UNSIGNED_BYTE, 0);


  15. // bind PBO to update texture source
  16. glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pboIds[nextIndex]);

  17. // Note that glMapBufferARB() causes sync issue.
  18. // If GPU is working with this buffer, glMapBufferARB() will wait(stall)
  19. // until GPU to finish its job. To avoid waiting (idle), you can call
  20. // first glBufferDataARB() with NULL pointer before glMapBufferARB().
  21. // If you do that, the previous data in PBO will be discarded and
  22. // glMapBufferARB() returns a new allocated pointer immediately
  23. // even if GPU is still working with the previous data.
  24. glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, DATA_SIZE, 0, GL_STREAM_DRAW_ARB);

  25. // map the buffer object into client's memory
  26. GLubyte* ptr = (GLubyte*)glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB,
  27.                                         GL_WRITE_ONLY_ARB);
  28. if(ptr)
  29. {
  30.     // update data directly on the mapped buffer
  31.     updatePixels(ptr, DATA_SIZE);
  32.     glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB); // release the mapped buffer
  33. }

  34. // it is good idea to release PBOs with ID 0 after use.
  35. // Once bound with 0, all pixel operations are back to normal ways.
  36. glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
复制代码

使用道具 举报

回复
论坛徽章:
0
15#
发表于 2012-2-20 19:33 | 只看该作者
我觉得可以尝试一个先把RGB数据拷贝到CUDA的数组:cudaMemcpy2DToArray()
然后把这个数组绑定到一个纹理:cudaBindTextureToArray()
这可能比较方便些。

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表