1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package android.gameperformance; 17 18 import java.util.ArrayList; 19 import java.util.List; 20 21 import android.annotation.NonNull; 22 23 /** 24 * Test that measures maximum amount of triangles can be rasterized keeping FPS close to the device 25 * refresh rate. It is has very few devices call and each call contains big amount of triangles. 26 * Total filling area is around one screen. 27 */ 28 public class TriangleCountOpenGLTest extends RenderPatchOpenGLTest { 29 // Based on index buffer of short values. 30 private final static int MAX_TRIANGLES_IN_PATCH = 32000; 31 TriangleCountOpenGLTest(@onNull GamePerformanceActivity activity)32 public TriangleCountOpenGLTest(@NonNull GamePerformanceActivity activity) { 33 super(activity); 34 } 35 36 @Override getName()37 public String getName() { 38 return "triangle_count"; 39 } 40 41 @Override getUnitName()42 public String getUnitName() { 43 return "ktriangles"; 44 } 45 46 @Override getUnitScale()47 public double getUnitScale() { 48 return 2.0; 49 } 50 51 @Override initUnits(double trianlgeCountD)52 public void initUnits(double trianlgeCountD) { 53 final int triangleCount = (int)Math.round(trianlgeCountD * 1000.0); 54 final List<RenderPatchAnimation> renderPatches = new ArrayList<>(); 55 final int patchCount = 56 (triangleCount + MAX_TRIANGLES_IN_PATCH - 1) / MAX_TRIANGLES_IN_PATCH; 57 final int patchTriangleCount = triangleCount / patchCount; 58 for (int i = 0; i < patchCount; ++i) { 59 final RenderPatch renderPatch = new RenderPatch(patchTriangleCount, 60 0.5f /* dimension */, 61 RenderPatch.TESSELLATION_TO_CENTER); 62 renderPatches.add(new RenderPatchAnimation(renderPatch, getView().getRenderRatio())); 63 } 64 setRenderPatches(renderPatches); 65 } 66 }