Hardware Scaler for performance and efficiency

Source: Internet
Author: User

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 the optimize of these areas, consider taking advantage of the hardware scaler that's available on almost AL L Android devices in the market today.


How does it works and why do 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 J Ava or Native (c + +) code. To take advantage of the hardware scaler, all of which are the render to a fixed-size graphics buffer, rather than using The system-provided default buffers, which is sized to the device's full screen resolution.

When you render to a fixed-size buffer, the device hardware does the "work of the Scaling your scene" 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 re NDEr more efficiently-especially on today ' s high-resolution screens.

Using the hardware scaler is more efficient for several reasons. First, hardware scalers is extremely fast and can produce great visual results through Multi-tap and other algorithms tha t reduce artifacts. Second, because your app is rendering to a smaller buffer, the computation load on the GPU is reduced and performance impr Oves. Third, with less computation, the GPU runs cooler and uses less battery. And finally, can choose what size rendering buffer you want to use, and that buffer can is the same on all devices, re Gardless 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 Applicati Ons. With newer phones and tablets offering higher and higher screens resolutions, rendering your 2D or 3D graphics on those tho SE 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 @ different rendering resolutions, across several popular chipsets in use on Android device S. (Data provided by Qualcomm).

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

Instead of rendering to a full-size buffer that could is 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 is important to users, and they is important considerations to Devel Opers as well.

As shown in the diagram, the power consumed in the device GPU increases significantly as rendering resolution rises. In more cases, any heavy with the power in GPU would end up reducing battery life in the device.

In addition, as CPU/GPU rendering load increases, heat is generated so 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 Proce Ssing 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 is rendering to a smaller buffer, the GPU spends less energy rendering and generates less heat.

Accessing the hardware scaler from Android APIs

Android gives access to the hardware scaler through standard APIs, available from your Java code or from your NAT Ive (c + +) code through the Android NDK.

All your need to does is with 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 the "the screen" or you can adjust your rendering into the buffer.

From your Java code, your access the Scaler through Surfaceview, introduced in API Level 1. Here's how to would create a fixed-size buffer at 1280x720 resolution:

surfaceview  =  Span style= "color: #000000;" >  new      ( this  );  Surfaceview   getholder   ().  setfixedsize   ( 1280  ,    );  

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

=anativewindow_setbuffersgeometry(window,1280  ,720,0);

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

Choosing a size for your graphics buffer

If you'll 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, the hardware scaler and the recommended size for rendering are 1080p. As illustrated in the diagram, 1080p are a sweet spot that balances a visual quality, frame rate, and power consumption. If you is satisfied with 720p, the course you can use this size for even more efficient operations.

More information

If you're a 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 is rendering through the Android framework or native APIs.

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

Hardware Scaler for performance and efficiency

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.