Hardware dependency

We have discussed earlier that hardware configuration plays a major role in the FPS system. If the hardware is not capable of running a certain set of instructions with a certain frequency, then it is not possible for any developer to run a game on the target FPS.

Let's list the tasks that take most of the processing time for a game:

  • Display or rendering
  • Memory load/unload operations
  • Logical operations

Display or rendering

Display processing depends mostly on the graphics processor and what all needs to be displayed. When it comes to interaction with the hardware, the process becomes slow. Rendering each and every pixel with shader manipulation and mapping takes time.

There were times when running a game with a frame rate of 12 was difficult. However, in the modern world, a superb display quality game needs to be run on a frame rate of 60. It is only a matter of hardware quality.

A large display requires a good amount of cache memory. So, for example, hardware with a large and dense display and with low cache memory is incapable of maintaining a good display quality.

Memory load/unload operations

Memory is a hardware component of a system. Again, it takes more time to interact with the memory component. From a developer's perspective, it takes time when we allocate memory, deallocate memory, and read or write an operation.

From the game development perspective, four types of memory are the most important:

  • Heap memory
  • Stack memory
  • Register memory
  • ROM

Heap memory

Heap memory is user-defined manually managed memory. This memory has to be allocated manually and freed manually as well. In the case of Android, the garbage collector is responsible for freeing memory, which is flagged as non-referenced. This memory location is the slowest in the random access memory category.

Stack memory

This segment of memory is used for elements that are declared inside a method. Allocation and deallocation of this memory segment is automatically done by the program interpreter. This memory segment works only for local members.

Register memory

Register memory is the fastest of all. Register memory is used to store data for the current process and frequently used data. Game developers can achieve a higher frame rate in the case of devices where the register memory is better and faster.

ROM

Read-only memory (ROM) is permanent memory. Especially in game development, a huge chunk of assets is stored in the ROM. It takes maximum time during the load/unload operation of those assets. A program needs to load the necessary data onto the RAM from the ROM. So, having faster ROM helps achieve better FPS during the load/unload operation.

Logical operations

Developers should define the instructions in such a way that they can use hardware in the most efficient way. In technical terms, each and every instruction goes in stacks in a binary instruction form. The processor executes one instruction in one clock cycle.

For example, let's have a look at a badly constructed logical instruction:

char[] name = "my name is android";
for(int i = 0; i < name.length; i ++)
{
  //some operation
}

Calling length and using a post increment operator every time increases the instructions to the processor, which eventually increases the execution time. Now, look at this code:

char[] name = "my name is android";
int length = name.length;
for(int i = 0; i < length; ++ i)
{
  //some operation
}

This code executed the same task; however, the processing overhead is reduced a lot in this approach. The only compromise this code made is blocking memory for one integer variable and saving a lot of nested tasks related to length.

Processors with a better clock speed can execute the task faster, which directly implies better FPS. However, managing the task amount depends on the developer, as is shown in the previous example.

Every processor has a mathematical processing unit. The power of the processor varies from one processor to another. So, developers always need to check the mathematical expression to know whether it can be simplified or not.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.3.175