Monday, May 27, 2019
Wednesday, May 22, 2019
Sunday, May 19, 2019
Inline Function
http://blogs.microsoft.co.il/sasha/2012/01/20/aggressive-inlining-in-the-clr-45-jit/
public static int SmallMethod(int i, int j)
{
if (i > j)
return i + j;
else
return i + 2 * j – 1;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int LargeMethod(int i, int j)
{
if (i + 14 > j)
{
return i + j;
}
else if (j * 12 < i)
{
return 42 + i – j * 7;
}
else
{
return i % 14 – j;
}
}
{
if (i > j)
return i + j;
else
return i + 2 * j – 1;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int LargeMethod(int i, int j)
{
if (i + 14 > j)
{
return i + j;
}
else if (j * 12 < i)
{
return 42 + i – j * 7;
}
else
{
return i % 14 – j;
}
}
The code size for these methods is 16 and 34, respectively. Without the AggressiveInlining attribute, the first method is inlined and the second is not inlined. With the AggressiveInlining attribute, the second method is inlined as well.
However, methods that couldn’t be inlined previously because of other criteria are still not inlined. I checked the following, and neither of these methods was inlined:
- Recursive method
- Virtual method (even if the static type of the receiver variable is sealed)
- Method with exception handling (representing a “complicated flowgraph”)
Friday, May 17, 2019
GET MEMORY HEAP SIZE ON MOBILE
ANDROID
https://stackoverflow.com/questions/2630158/detect-application-heap-size-in-android/2634738#2634738
IOS
https://developer.apple.com/library/archive/documentation/Performance/Conceptual/ManagingMemory/Articles/AboutMemory.html
STACK SIZE IN C#
https://stackoverflow.com/questions/2630158/detect-application-heap-size-in-android/2634738#2634738
IOS
https://developer.apple.com/library/archive/documentation/Performance/Conceptual/ManagingMemory/Articles/AboutMemory.html
STACK SIZE IN C#
Today's PCs have a large amount of physical RAM but still, the stack size of C# is only 1 MB for 32-bit processes and 4 MB for 64-bit processes (Stack capacity in C#).
Wednesday, May 15, 2019
Support for Android App Bundle (AAB) in Unity 2018.3 beta
Larger apps and games convert fewer Google Play store visits into installs. This is because users are conscious of using up storage on their device, using up their data plans, and waiting around for downloads to complete on slow connections. Android App Bundle is a new Android app publishing format which makes games smaller on people’s device.
https://blogs.unity3d.com/2018/10/03/support-for-android-app-bundle-aab-in-unity-2018-3-beta/?fbclid=IwAR1t9h8l5CmiZvKshNHOk8HmJYnvC2ADkGa036bbyQiRtgKWd36I-yK45Dc
Thursday, May 9, 2019
Monday, May 6, 2019
Sunday, May 5, 2019
Draw call, batch and setpass call
- The phrase often used to describe rendering is the rendering pipeline, and this is a useful image to bear in mind; efficient rendering is all about keeping information flowing.For every frame that is rendered, the CPU does the following work:
- The CPU checks every object in the scene to determine whether it should be rendered. An object is only rendered if it meets certain criteria; for example, some part of its bounding box must be within a camera’s view frustum. Objects that will not be rendered are said to be culled. For more information on the frustum and frustum culling please see this page.
- The CPU gathers information about every object that will be rendered and sorts this data into commands known as draw calls. A draw call contains data about a single mesh and how that mesh should be rendered; for example, which textures should be used. Under certain circumstances, objects that share settings may be combined into the same draw call. Combining data for different objects into the same draw call is known as batching.
- The CPU creates a packet of data called a batch for each draw call. Batches may sometimes contain data other than draw calls, but these situations are unlikely to contribute to common performance issues and we therefore won’t consider these in this article.
For every batch that contains a draw call, the CPU now must do the following:- The CPU may send a command to the GPU to change a number of variables known collectively as the render state. This command is known as a SetPass call. A SetPass call tells the GPU which settings to use to render the next mesh. A SetPass call is sent only if the next mesh to be rendered requires a change in render state from the previous mesh.
- The CPU sends the draw call to the GPU. The draw call instructs the GPU to render the specified mesh using the settings defined in the most recent SetPass call.
- Under certain circumstances, more than one pass may be required for the batch. A pass is a section of shader code and a new pass requires a change to the render state. For each pass in the batch, the CPU must send a new SetPass call and then must send the draw call again.
Meanwhile, the GPU does the following work:- The GPU handles tasks from the CPU in the order that they were sent.
- If the current task is a SetPass call, the GPU updates the render state.
- If the current task is a draw call, the GPU renders the mesh. This happens in stages, defined by separate sections of shader code. This part of rendering is complex and we won’t cover it in great detail, but it’s useful for us to understand that a section of code called the vertex shader tells the GPU how to process the mesh’s vertices and then a section of code called the fragment shader tells the GPU how to draw the individual pixels.
- This process repeats until all tasks sent from the CPU have been processed by the GPU.
Now that we understand what’s happening when Unity renders a frame, let’s consider the sort of problems that can occur when rendering.
Friday, May 3, 2019
Rendering a Large Number of Animated Characters
https://github.com/chenjd/Render-Crowd-Of-Animated-Characters?fbclid=IwAR1P1UaPuuudes4RReHP1995t-jl2ox7ViBnmTQ_1xEdcu8RSn0oQ-NUhoQ
https://blogs.unity3d.com/2018/04/16/animation-instancing-instancing-for-skinnedmeshrenderer/
https://www.hindawi.com/journals/ijcgt/2019/1792304/
https://www.youtube.com/watch?v=rXqKu9uC0f4
https://blogs.unity3d.com/2018/04/16/animation-instancing-instancing-for-skinnedmeshrenderer/
https://www.hindawi.com/journals/ijcgt/2019/1792304/
https://www.youtube.com/watch?v=rXqKu9uC0f4
Subscribe to:
Posts (Atom)