Home | History | Annotate | Download | only in perftest
      1 // Copyright (C) 2011 The Android Open Source Project
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //      http://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 #pragma version(1)
     16 
     17 #pragma rs java_package_name(com.android.perftest)
     18 
     19 #include "rs_graphics.rsh"
     20 #include "shader_def.rsh"
     21 #include "subtest_def.rsh"
     22 
     23 rs_program_vertex gProgVertex;
     24 rs_program_fragment gProgFragmentTexture;
     25 
     26 rs_program_store gProgStoreBlendNone;
     27 
     28 rs_allocation gTexOpaque;
     29 
     30 rs_mesh g10by10Mesh;
     31 rs_mesh g100by100Mesh;
     32 rs_mesh gWbyHMesh;
     33 
     34 rs_sampler gLinearClamp;
     35 static int gRenderSurfaceW;
     36 static int gRenderSurfaceH;
     37 
     38 static float gDt = 0;
     39 
     40 typedef struct MeshTestData_s {
     41     int meshNum;
     42 } MeshTestData;
     43 MeshTestData *gData;
     44 
     45 void init() {
     46 }
     47 
     48 static void bindProgramVertexOrtho() {
     49     // Default vertex shader
     50     rsgBindProgramVertex(gProgVertex);
     51     // Setup the projection matrix
     52     rs_matrix4x4 proj;
     53     rsMatrixLoadOrtho(&proj, 0, gRenderSurfaceW, gRenderSurfaceH, 0, -500, 500);
     54     rsgProgramVertexLoadProjectionMatrix(&proj);
     55 }
     56 
     57 static void displayMeshSamples(int meshNum) {
     58 
     59     bindProgramVertexOrtho();
     60     rs_matrix4x4 matrix;
     61     rsMatrixLoadTranslate(&matrix, gRenderSurfaceW/2, gRenderSurfaceH/2, 0);
     62     rsgProgramVertexLoadModelMatrix(&matrix);
     63 
     64     // Fragment shader with texture
     65     rsgBindProgramStore(gProgStoreBlendNone);
     66     rsgBindProgramFragment(gProgFragmentTexture);
     67     rsgBindSampler(gProgFragmentTexture, 0, gLinearClamp);
     68 
     69     rsgBindTexture(gProgFragmentTexture, 0, gTexOpaque);
     70 
     71     if (meshNum == 0) {
     72         rsgDrawMesh(g10by10Mesh);
     73     } else if (meshNum == 1) {
     74         rsgDrawMesh(g100by100Mesh);
     75     } else if (meshNum == 2) {
     76         rsgDrawMesh(gWbyHMesh);
     77     }
     78 }
     79 
     80 void root(const void *v_in, void *v_out, const void *usrData, uint32_t x, uint32_t y) {
     81     TestData *testData = (TestData*)usrData;
     82     gRenderSurfaceW = testData->renderSurfaceW;
     83     gRenderSurfaceH = testData->renderSurfaceH;
     84     gDt = testData->dt;
     85 
     86     gData = (MeshTestData*)v_in;
     87 
     88     displayMeshSamples(gData->meshNum);
     89 }
     90