About CPUS and Gpus

CPU(central Processing Unit):

The metadata core and control center of the whole system of modern computer is the final execution unit of information processing and program operation. Copy the codeCopy the code

GPU(Graphics Processing Unit):

Display core, vision processor, display chip, is a specialized in personal computers, workstations, game consoles and some mobile devices (such as tablet computers, smart phones, etc.) to do the image and graphics related operations on the microprocessor. Copy the codeCopy the code

The design goals of CPU and GPU are different, and they are respectively targeted at two different application scenarios. CPU is the core of operation and control, need to have strong operation universality, compatible with various data types, but also need to be able to deal with a large number of different jump, interrupt and other instructions, so the internal structure of THE CPU is more complex. On the other hand, Gpus are faced with more simple operations with uniform types, and do not need to process complex instructions, but also shoulder larger computing tasks.

Therefore, CPU and GPU architectures are different. The situation is more complicated for the CPU. As you can see from the figure above, the CPU has more Cache space and more complex control units. Computing power is not the main demand of the CPU. CPU is designed for low latency, and more caching also means faster access to data; At the same time, the complex control unit can process logic branches more quickly, which is more suitable for serial computing.

However, GPU has more Arithmetic Logic units, which has stronger computing ability and more control units. Gpus are designed for high throughput, and each part of the cache is connected to a stream processor, which is more suitable for large-scale parallel computing.

Shader rendering process

The shader rendering process can be roughly divided into the following steps: Vertex shaders and slice shaders are essential in openGL

Render frame in iOS

CoreAnimation rendering

CoreAnimation rendering pipeline

Render Server operation analysis

Off-screen rendering issues

Under normal circumstances, the computer only needs to process the image in the frame cache and show it directly on the screen after the processing is completed. IOS uses the dual-cache technology and has the off-screen rendering area. Under what circumstances do we need to use the off-screen rendering area? In simple terms: for multiple layers, the finished layer cannot be displayed directly. There are other steps that need to be processed. After all layers are processed, the final blended layer needs to be displayed

Oil painter algorithm

First let’s think about how the computer draws when it has multiple layers on it.

As shown in the figure, we have three patterns with different colors. The computer does not draw successfully at one time when displaying. It starts from far and near, first drawing the blue layer -> red layer -> yellow layer, which is also the principle of the painter’s algorithm

We can also think about frosted glass and rounded corners in iOS. How does setting masks and rasters trigger off-screen rendering?

Here’s what we did by setting rounded corners. We created five Spaces. 1.2.3 is all UIButton and 4.5 is UIImageView

Enable off-screen rendering

We can see that there is no off-screen rendering in 2 and 5,2 just sets the background color, and 5 just sets the UIImage , in fact is essentially OC underlying whether do you have multiple layers to hybrid rendering needs to use to render off-screen buffer, need happens happens off-screen rendering, it is worth noting that the off-screen rendering area using the timeliness, as the picture is more than 2.5 times the current screen, or join 300 ms after the off-screen render cache untreated, will be abandoned

Citation: Original address