为什么我的 opengl 输出因各种设备而异? [英] Why my opengl output differs for various devices?

查看:22
本文介绍了为什么我的 opengl 输出因各种设备而异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个用于绘制线、圆的 android 应用程序.通过在 OpenGLES 2.0 中使用 GLSurfaceView,就像 Auto cad 应用程序一样.

I have created an android app for drawing of lines,circles.. by using GLSurfaceView in OpenGLES 2.0 like an Auto cad app.

该应用在 Google Nexus 7 上运行良好,从某种意义上说,如果我们画一条线 &然后一个圆圈,该线不会在表面视图中被擦除.但三星 Galaxy Note II 则完全不同.

The app works well with Google Nexus 7, in the sense that if we draw a line & then a circle the line doesn't get erased in surface view. But with Samsung Galaxy Note II, it is entirely different.

在绘制圆之前绘制的线将被删除.即,每次如果我们画一条新的线或圆,前一个就会被删除.我一次只能画一张图像.我需要的是与三星 Galaxy Note II 的 Google Nexus 7 中相同的输出.即我想一次在 GLSurfaceView 中绘制多个图像.

The line previously drawn before a circle being drawn, gets erased. i.e., each time if we draw a new line or circle, the previous one gets erased.I can draw only one image at a time. What I need is the same output which I get in Google Nexus 7 in Samsung Galaxy Note II.i.e.I want to draw more than one image in the GLSurfaceView at a time.

注意:Google Nexus 7 和三星 Galaxy Note II 中的 Android 操作系统都是 Jelly Bean 4.2.但两种设备都是不同的 GPU.Google Nexus 7 GPU 是 ULP GeForce &三星 Galaxy Note II 是 Mali400MP.

Note : Both the Android OS in Google Nexus 7 and Samsung Galaxy Note II are Jelly Bean 4.2. But both devices are different GPU. Google Nexus 7 GPU is ULP GeForce & Samsung Galaxy Note II is Mali400MP.

这会是 Surfaceview 输出渲染的问题吗?

Would this be an issue in the rendering of output of the Surfaceview ?

我们应该在编码时考虑 GPU 吗?

Should we take into account of GPU while Coding ?

谁能告诉我为什么不同设备会出现不同输出的问题?

Can anyone tell me why this problem of different output in different devices ?

推荐答案

我们应该在编码时考虑 GPU 吗?没办法,OpenGL API 是你的应用程序和硬件之间的一层.

Should we take into account of GPU while Coding ? No way, The OpenGL API is a layer between your application and the hardware.

这对于桌面图形来说基本正确,因为所有 GPU 都是即时渲染器,但在移动图形中并非如此.

This is largely correct for desktop graphics as all GPUs are immediate renderers, however, this is NOT the case in mobile graphics.

Mali GPU 使用基于图块的即时模式渲染.对于这种类型的渲染,帧缓冲区被分成大小为 16 x 16 像素的图块.多边形列表生成器 (PLB) 将来自应用程序的输入数据组织到多边形列表中.每个图块都有一个多边形列表.当一个图元覆盖一个图块的一部分时,一个称为多边形列表命令的条目被添加到该图块的多边形列表中.像素处理器获取一个图块的多边形列表,并在开始处理下一个图块之前计算该图块中所有像素的值.由于这种基于切片的方法使用快速的片上切片缓冲区,因此 GPU 仅在每个切片末尾将切片缓冲区内容写入主存储器中的帧缓冲区.基于非平铺的即时模式渲染器通常需要更多的帧缓冲区访问.因此,基于 tile 的方法消耗的内存带宽更少,并且可以有效地支持深度测试、混合和抗锯齿等操作.

The Mali GPUs use tile-based immediate-mode rendering. For this type of rendering, the framebuffer is divided into tiles of size 16 by 16 pixels. The Polygon List Builder (PLB) organizes input data from the application into polygon lists. There is a polygon list for each tile. When a primitive covers part of a tile, an entry, called a polygon list command, is added to the polygon list for the tile. The pixel processor takes the polygon list for one tile and computes values for all pixels in that tile before starting work on the next tile. Because this tile-based approach uses a fast, on-chip tile buffer, the GPU only writes the tile buffer contents to the framebuffer in main memory at the end of each tile. Non-tiled-based, immediate-mode renderers generally require many more framebuffer accesses. The tile-based method therefore consumes less memory bandwidth, and supports operations such as depth testing, blending and anti-aliasing efficiently.

另一个区别是渲染缓冲区的处理.即时渲染器将保存"缓冲区的内容,有效地允许您仅在先前存在的内容之上绘制渲染场景中的差异.但是,此 IS 在 Mali 中可用,但默认情况下未启用,因为如果使用不当可能会导致不良影响.

Another difference is the treatment of rendered buffers. Immediate renderers will "save" the content of your buffer, effectively allowing you to only draw differences in the rendered scene on top of what previously existed. This IS available in Mali, however, is not enabled by default as it can cause undesired effects if used incorrectly.

GLES2 SDK 中有一个关于如何使用EGL Preserve"的 Mali GLES2 SDK 示例这里

There is a Mali GLES2 SDK example on how to use "EGL Preserve" Correctly available in the GLES2 SDK here

基于 Geforce ULP 的 nexus 7 按预期工作的原因是,作为基于即时的渲染器,它默认保留缓冲区,而 Mali 没有.

The reason the Geforce ULP based nexus 7 works as intended is that, as an immediate based renderer, it defaults to preserving the buffers, whereas Mali does not.

来自 Khronos EGL 规范:

From the Khronos EGL specification:

EGL_SWAP_BEHAVIOR

EGL_SWAP_BEHAVIOR

指定使用 eglSwapBuffers 发布表面对颜色缓冲区的影响.EGL_BUFFER_PRESERVED 值表示颜色缓冲区内容不受影响,而 EGL_BUFFER_DESTROYED 值表示颜色缓冲区内容可能会被操作破坏或更改.

Specifies the effect on the color buffer of posting a surface with eglSwapBuffers. A value of EGL_BUFFER_PRESERVED indicates that color buffer contents are unaffected, while EGL_BUFFER_DESTROYED indicates that color buffer contents may be destroyed or changed by the operation.

*EGL_SWAP_BEHAVIOR 的初始值由实现选择.*

Mali 平台上 EGL_SWAP_BEHAVIOUR 的默认值为 EGL_BUFFER_DESTROYED.这是由于在渲染新帧之前必须从内存中获取前一个缓冲区并在最后存储它以及带宽消耗(这对移动设备上的电池寿命也非常不利)相关的性能损失.我无法肯定地评论 Tegra SoC 的默认行为,但对我来说很明显它们的默认行为是 EGL_BUFFER_PRESERVED.

The default value for EGL_SWAP_BEHAVIOUR on the Mali platform is EGL_BUFFER_DESTROYED. This is due to the performance hit associated with having to fetch the previous buffer from memory before rendering the new frame, and storing it at the end as well as the consumption of bandwidth (which is also incredibly bad for battery life on mobile devices). I am unable to comment with certainty as to the default behavior of the Tegra SoCs however, it is apparent to me that their default is EGL_BUFFER_PRESERVED.

澄清 Mali 对 Khronos GLES 规范的立场 - Mali 完全符合要求.

To clarify Mali's position with regards to the Khronos GLES specifications - Mali is fully compliant.

这篇关于为什么我的 opengl 输出因各种设备而异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆