前言

由于原文链接在国内经常链接不上,这里特意转到CSDN。原文链接:http://android-developers.blogspot.it/2013/09/using-hardware-scaler-for-performance.html


26 September 2013

Posted by Hak Matsuda and Dirk Dougherty, Android Developer Relations team

If you develop a performance-intensive 3D game, you’re always looking for ways to give users richer graphics, higher frame rates, and better responsiveness. You also want to conserve the user’s battery and keep the device from getting too warm during play. To help you optimize in all of these areas, consider taking advantage of the hardware scaler that’s available on almost all Android devices in the market today.

How it works and why you should use it

Virtually all modern Android devices use a CPU/GPU chipset that includes a hardware video scaler. Android provides the higher-level integration and makes the scaler available to apps through standard Android APIs, from Java or native (C++) code. To take advantage of the hardware scaler, all you have to do is render to a fixed-size graphics buffer, rather than using the system-provided default buffers, which are sized to the device’s full screen resolution.

When you render to a fixed-size buffer, the device hardware does the work of scaling your scene up (or down) to match the device’s screen resolution, including making any adjustments to aspect ratio. Typically, you would create a fixed-size buffer that’s smaller than the device’s full screen resolution, which lets you render more efficiently — especially on today’s high-resolution screens.

Using the hardware scaler is more efficient for several reasons. First, hardware scalers are extremely fast and can produce great visual results through multi-tap and other algorithms that reduce artifacts. Second, because your app is rendering to a smaller buffer, the computation load on the GPU is reduced and performance improves. Third, with less computation work to do, the GPU runs cooler and uses less battery. And finally, you can choose what size rendering buffer you want to use, and that buffer can be the same on all devices, regardless of the actual screen resolution.

Optimizing the fill rate

In a mobile GPU, the pixel fill rate is one of the major sources of performance bottlenecks for performance game applications. With newer phones and tablets offering higher and higher screen resolutions, rendering your 2D or 3D graphics on those those devices can significantly reduce your frame rate. The GPU hits its maximum fill rate, and with so many pixels to fill, your frame rate drops.


Power consumed in the GPU at different rendering resolutions, across several popular chipsets in use on Android devices. (Data provided by Qualcomm).

To avoid these bottlenecks, you need to reduce the number of pixels that your game is drawing in each frame. There are several techniques for achieving that, such as using depth-prepass optimizations and others, but a really simple and effective way is making use of the hardware scaler.

Instead of rendering to a full-size buffer that could be as large as 2560x1600, your game can instead render to a smaller buffer — for example 1280x720 or 1920x1080 — and let the hardware scaler expand your scene without any additional cost and minimal loss in visual quality.

Reducing power consumption and thermal effects

A performance-intensive game can tend to consume too much battery and generate too much heat. The game’s power consumption and thermal conditions are important to users, and they are important considerations to developers as well.

As shown in the diagram, the power consumed in the device GPU increases significantly as rendering resolution rises. In most cases, any heavy use of power in GPU will end up reducing battery life in the device.

In addition, as CPU/GPU rendering load increases, heat is generated that can make the device uncomfortable to hold. The heat can even trigger CPU/GPU speed adjustments designed to cool the CPU/GPU, and these in turn can throttle the processing power that’s available to your game.

For both minimizing power consumption and thermal effects, using the hardware scaler can be very useful. Because you are rendering to a smaller buffer, the GPU spends less energy rendering and generates less heat.

Accessing the hardware scaler from Android APIs

Android gives you easy access to the hardware scaler through standard APIs, available from your Java code or from your native (C++) code through the Android NDK.

All you need to do is use the APIs to create a fixed-size buffer and render into it. You don’t need to consider the actual size of the device screen, however in cases where you want to preserve the original aspect ratio, you can either match the aspect ratio of the buffer to that of the screen, or you can adjust your rendering into the buffer.

From your Java code, you access the scaler through SurfaceView, introduced in API level 1. Here’s how you would create a fixed-size buffer at 1280x720 resolution:

surfaceView = new GLSurfaceView(this);
surfaceView.getHolder().setFixedSize(1280, 720);

If you want to use the scaler from native code, you can do so through the NativeActivityclass, introduced in Android 2.3 (API level 9). Here’s how you would create a fixed-size buffer at 1280x720 resolution using NativeActivity:

int32_t ret = ANativeWindow_setBuffersGeometry(window, 1280, 720, 0);

By specifying a size for the buffer, the hardware scaler is enabled and you benefit in your rendering to the specified window.

Choosing a size for your graphics buffer

If you will use a fixed-size graphics buffer, it’s important to choose a size that balances visual quality across targeted devices with performance and efficiency gains.

For most performance 3D games that use the hardware scaler, the recommended size for rendering is 1080p. As illustrated in the diagram, 1080p is a sweet spot that balances a visual quality, frame rate, and power consumption. If you are satisfied with 720p, of course you can use that size for even more efficient operations.

More information

If you’d like to take advantage of the hardware scaler in your app, take a look at the class documentation for SurfaceView or NativeActivity, depending on whether you are rendering through the Android framework or native APIs.

Watch for sample code on using the hardware scaler coming soon!

Using the Hardware Scaler for Performance and Efficiency相关推荐

  1. Linux perf 1.4、hardware events

    可以通过perf list命令来查看系统中的hardware event: # simpleperf list hw List of hardware events:cpu-cyclesinstruc ...

  2. Android Graphics - Architecture

    说在前面的话 这篇文章翻译自Google 的Graphic Architecture. https://source.android.com/devices/graphics/architecture ...

  3. 开启报名 | AI芯片体系架构和软件专题报告会2020

    近年来,专用的人工智能芯片为人工智能应用提供了强大的算力.面对日新月异的人工智能应用,人工智能芯片的体系架构,系统软件,安全成为计算机体系结构和系统软件的热点研究问题.为了推进国内在该领域的发展,由北 ...

  4. CUDA系列学习(三)GPU设计与结构QA coding练习

    啥?你把CUDA系列学习(一),(二)都看完了还不知道為什麼要用GPU提速? 是啊..经微博上的反馈我默默感觉到提出这样问题的小伙伴不在少数,但是更多小伙伴应该是看了(一)就感觉离自己太远所以赶紧撤粉 ...

  5. 2021年图灵奖公布!72岁的美国科学家 Jack Dongarra 获奖

    刚刚,2021年计算机领域的最高奖项--图灵奖公布!美国计算机科学家 Jack J. Dongarra 获奖,以表彰他在高性能计算领域的卓越成就. >>>> 根据 ACM 的介 ...

  6. [ARM]【编译】【实践】 - 浮点编译选项NEON引发的Skia的库Illegal instruction运行错误和解决办法

    前言,ARM编译器选项除了优化系统代码性能外,往往还具备其他一些设定,例如警告级别,和指令集的扩展 本文论述工作中遇到的一个编译开源浏览器chromine遇到的问题,由编译选项引发的可执行文件的Ill ...

  7. A Brief Overview Of Vulkan API

    转一篇关于Vulkan的介绍性文章. Vulkan据说标准快要出来了:根据目前笔者了解,其实很多很AMD mantle很像.等正式发布后,笔者准备再写一系列文章研究新标准.毕竟这个才是未来的方向! 另 ...

  8. Facebook的体系结构分析---外文转载

    Facebook的体系结构分析---外文转载 From various readings and conversations I had, my understanding of Facebook's ...

  9. perf Examples

    为什么80%的码农都做不了架构师?>>>    These are some examples of using the perf Linux profiler, which has ...

  10. (转) Exploring How Cache Coherency Accelerates Heterogeneous Compute

    Long Time No See! 转载自:https://community.arm.com/developer/ip-products/processors/b/processors-ip-blo ...

最新文章

  1. 这是入门生信,学习生信分析思路和数据可视化的首选?
  2. vue 嵌套表格组件_vue+element中表格嵌套怎么做?
  3. CTFshow php特性 web125
  4. C# 效率也不是很差嘛
  5. 初识Mysql(part13)--我需要知道的7条Mysql语句之更新和删除数据
  6. “中国好创意” CCF全国青年大数据创新大赛启动仪式 暨大数据大师论坛议程...
  7. leetcode - 1024. 视频拼接
  8. matlab期中考试卷,matlab期末考试试卷及答案.doc
  9. 瑞元双玻组件助力浙江多座分布式电站高效运行
  10. 不同版本的Python,如何pip
  11. 【图像处理】基于matlab GUI图像直方图+滤波处理【含Matlab源码 839期】
  12. 内网渗透技术之超越LLMNR/NBNS欺骗的ADIDNS欺骗攻击
  13. RNA甲基化修饰m6A检测热门技术—MeRIP-seq
  14. 铁路cj继电器_铁路信号继电器简介
  15. MAXTENT模型地理维度不一致的解决办法
  16. Android 手机开机密码破解锁定
  17. IJCAI 2022奖项公布:3篇杰出论文,南加大、耶拿大学等机构在列
  18. Java语言Switch语句详解(一)
  19. Mqtt ----心跳机制 长链接 ping
  20. Mysql服务端(三)--- 索引及设计建议

热门文章

  1. 【Unity3D进阶4-15】Lua热更新
  2. macOS Sierra,Xcode 8配置openCV3
  3. 电商企业如何利用CRM突出重围?
  4. 独立院校转设,高考新生何去何从|转设对新生有哪些影响
  5. angular 万年历_jQuery实现的简单日历组件定义与用法示例
  6. Callnovo全球联络中心云通讯CRM平台系列(一)
  7. 【无标题】智慧校园管理系统-毕设项目(包含数据库)
  8. mysql normsinv,在MySQL中实现NORMSINV函数
  9. CHD6.3.1部署文档
  10. I - Circles (SDUT 2018 Autumn Individual Contest - I)