Posts

Post not yet marked as solved
0 Replies
381 Views
Hi friends, I am porting my iPad game to Metal 2.0, the original one is written with OpenGL ES 2.0 with draw instanced extension. After one month's hard work, all OpenGL ES APIs have been written with Metal APIs, and all the functions work as same as in the OpenGL ES 2.0 version. But only one thing make me not happy, I use quad slices to simulate volumetric clouds among the mountains. The game runs at 60 fps, in the OpenGL ES 2.0 version, when the camera enter into the clouds, it can run at 30 fps when rendering the slices, but it dropped to only 5 fps in the Metal 2.0 version ! I have traced the app within the 'Instruments' tool, it shows that it is lagged by the fragment shader when entering into the clouds. In the fragment shader, there are only two lines, return the cloud color multiplied by the cloud mask stored in a small texture with only one channel. fragment half4 fshaderterraincloud( TerrainCloudColorInOut in[[stagein]], texture2d < half >     stexture5[[texture(1)]]) {     constexpr sampler colorSampler(magfilter::nearest,                                    minfilter::nearest);     half cloudmask = stexture5.sample(colorSampler, in.vtexCoord).r;     return half4(in.vcolor.rgb, in.vcolor.a * cloudmask); } So I believe that it must exist huge optimization space, for the two versions run on the same hardware - iPad mini 2, why the performances are so different ? Here is the draw call: [publicrenderpass drawPrimitives:MTLPrimitiveTypeTriangle                            vertexStart:0                            vertexCount:(int)cloudshapevertices.size()                          instanceCount:(int)cloudvertices.size()]; Has any body encountered such issue ? I'm appreciate your help. Thank you.
Posted
by artgolf.
Last updated
.