Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: client/deps/glbench/src/fillratetest.cc

Issue 2913008: Converted fill rate test to GLES2. (Closed) Base URL: ssh://git@chromiumos-git//autotest.git
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « client/deps/glbench/src/Makefile ('k') | client/deps/glbench/src/main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/logging.h" 5 #include "base/logging.h"
6 #include "main.h" 6 #include "main.h"
7 #include "testbase.h" 7 #include "testbase.h"
8 #include "utils.h" 8 #include "utils.h"
9 9
10 namespace glbench { 10 namespace glbench {
11 11
12 12
13 class FillRateTest : public DrawArraysTestFunc { 13 class FillRateTest : public DrawArraysTestFunc {
14 public: 14 public:
15 FillRateTest() {} 15 FillRateTest() {}
16 virtual ~FillRateTest() {} 16 virtual ~FillRateTest() {}
17 virtual bool Run(); 17 virtual bool Run();
18 virtual const char* Name() const { return "fill_rate"; } 18 virtual const char* Name() const { return "fill_rate"; }
19 19
20 private: 20 private:
21 DISALLOW_COPY_AND_ASSIGN(FillRateTest); 21 DISALLOW_COPY_AND_ASSIGN(FillRateTest);
22 }; 22 };
23 23
24 #if defined(I915_WORKAROUND)
25 #define V1 "gl_TexCoord[0]"
26 #else
27 #define V1 "v1"
28 #endif
29
30 const char* kVertexShader1 =
31 "attribute vec4 position;"
32 "void main() {"
33 " gl_Position = position;"
34 "}";
35
36 const char* kFragmentShader1 =
37 "uniform vec4 color;"
38 "void main() {"
39 " gl_FragColor = color;"
40 "}";
41
42
43 const char* kVertexShader2 =
44 "attribute vec4 position;"
45 "attribute vec4 texcoord;"
46 "uniform float scale;"
47 "varying vec2 v1;"
48 "void main() {"
49 " gl_Position = position * vec4(scale, scale, 1., 1.);"
50 " " V1 " = texcoord;"
51 "}";
52
53 const char* kFragmentShader2 =
54 "uniform sampler2D texture;"
55 "varying vec2 v1;"
56 "void main() {"
57 " gl_FragColor = texture2D(texture, " V1 ".xy);"
58 "}";
24 59
25 bool FillRateTest::Run() { 60 bool FillRateTest::Run() {
26 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); 61 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
27 glDisable(GL_DEPTH_TEST); 62 glDisable(GL_DEPTH_TEST);
28 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 63 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
29 64
30 GLfloat buffer_vertex[8] = { 65 GLfloat buffer_vertex[8] = {
31 -1.f, -1.f, 66 -1.f, -1.f,
32 1.f, -1.f, 67 1.f, -1.f,
33 -1.f, 1.f, 68 -1.f, 1.f,
34 1.f, 1.f, 69 1.f, 1.f,
35 }; 70 };
36 GLfloat buffer_texture[8] = { 71 GLfloat buffer_texture[8] = {
37 0.f, 0.f, 72 0.f, 0.f,
38 1.f, 0.f, 73 1.f, 0.f,
39 0.f, 1.f, 74 0.f, 1.f,
40 1.f, 1.f, 75 1.f, 1.f,
41 }; 76 };
42 glEnableClientState(GL_VERTEX_ARRAY);
43 77
44 GLuint vbo_vertex = SetupVBO(GL_ARRAY_BUFFER, 78 GLuint vbo_vertex = SetupVBO(GL_ARRAY_BUFFER,
45 sizeof(buffer_vertex), buffer_vertex); 79 sizeof(buffer_vertex), buffer_vertex);
46 glVertexPointer(2, GL_FLOAT, 0, 0); 80 GLuint program = InitShaderProgram(kVertexShader1, kFragmentShader1);
81 GLint position_attribute = glGetAttribLocation(program, "position");
82 glVertexAttribPointer(position_attribute, 2, GL_FLOAT, GL_FALSE, 0, NULL);
83 glEnableVertexAttribArray(position_attribute);
84
85 GLint color_uniform = glGetUniformLocation(program, "color");
86 const GLfloat red[4] = {1.f, 0.f, 0.f, 1.f};
87 glUniform4fv(color_uniform, 1, red);
88
89 FillRateTestNormal("fill_solid");
90 FillRateTestBlendDepth("fill_solid");
91
92 glDeleteProgram(program);
93
94 program = InitShaderProgram(kVertexShader2, kFragmentShader2);
95 position_attribute = glGetAttribLocation(program, "position");
96 // Reusing vbo_vertex buffer from the previous test.
97 glVertexAttribPointer(position_attribute, 2, GL_FLOAT, GL_FALSE, 0, NULL);
98 glEnableVertexAttribArray(position_attribute);
47 99
48 GLuint vbo_texture = SetupVBO(GL_ARRAY_BUFFER, 100 GLuint vbo_texture = SetupVBO(GL_ARRAY_BUFFER,
49 sizeof(buffer_texture), buffer_texture); 101 sizeof(buffer_texture), buffer_texture);
50 glTexCoordPointer(2, GL_FLOAT, 0, 0); 102 GLuint texcoord_attribute = glGetAttribLocation(program, "texcoord");
51 103 glVertexAttribPointer(texcoord_attribute, 2, GL_FLOAT, GL_FALSE, 0, NULL);
52 glColor4f(1.f, 0.f, 0.f, 1.f); 104 glEnableVertexAttribArray(texcoord_attribute);
53 FillRateTestNormal("fill_solid");
54 FillRateTestBlendDepth("fill_solid");
55
56 glColor4f(1.f, 1.f, 1.f, 1.f);
57 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
58 glEnable(GL_TEXTURE_2D);
59 105
60 GLuint texture = SetupTexture(9); 106 GLuint texture = SetupTexture(9);
107
108 GLuint texture_uniform = glGetUniformLocation(program, "texture");
109 glUniform1i(texture_uniform, 0);
110
111 GLuint scale_uinform = glGetUniformLocation(program, "scale");
112 glUniform1f(scale_uinform, 1.f);
113
61 FillRateTestNormal("fill_tex_nearest"); 114 FillRateTestNormal("fill_tex_nearest");
62 115
63 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 116 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
64 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 117 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
65 FillRateTestNormal("fill_tex_bilinear"); 118 FillRateTestNormal("fill_tex_bilinear");
66 119
67 // lod = 0.5 120 // lod = 0.5
68 glScalef(0.7071f, 0.7071f, 1.f); 121 glUniform1f(scale_uinform, 0.7071f);
69 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, 122 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
70 GL_LINEAR_MIPMAP_NEAREST); 123 GL_LINEAR_MIPMAP_NEAREST);
71 FillRateTestNormalSubWindow("fill_tex_trilinear_nearest_05", 124 FillRateTestNormalSubWindow("fill_tex_trilinear_nearest_05",
72 0.7071f * g_width, 0.7071f * g_height); 125 0.7071f * g_width, 0.7071f * g_height);
73 126
74 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, 127 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
75 GL_LINEAR_MIPMAP_LINEAR); 128 GL_LINEAR_MIPMAP_LINEAR);
76 FillRateTestNormalSubWindow("fill_tex_trilinear_linear_05", 129 FillRateTestNormalSubWindow("fill_tex_trilinear_linear_05",
77 0.7071f * g_width, 0.7071f * g_height); 130 0.7071f * g_width, 0.7071f * g_height);
78 131
79 // lod = 0.4 132 // lod = 0.4
80 glLoadIdentity(); 133 glUniform1f(scale_uinform, 0.758f);
81 glScalef(0.758f, 0.758f, 1.f);
82 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, 134 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
83 GL_LINEAR_MIPMAP_LINEAR); 135 GL_LINEAR_MIPMAP_LINEAR);
84 FillRateTestNormalSubWindow("fill_tex_trilinear_linear_04", 136 FillRateTestNormalSubWindow("fill_tex_trilinear_linear_04",
85 0.758f * g_width, 0.758f * g_height); 137 0.758f * g_width, 0.758f * g_height);
86 138
87 // lod = 0.1 139 // lod = 0.1
88 glLoadIdentity(); 140 glUniform1f(scale_uinform, 0.933f);
89 glScalef(0.933f, 0.933f, 1.f);
90 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, 141 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
91 GL_LINEAR_MIPMAP_LINEAR); 142 GL_LINEAR_MIPMAP_LINEAR);
92 FillRateTestNormalSubWindow("fill_tex_trilinear_linear_01", 143 FillRateTestNormalSubWindow("fill_tex_trilinear_linear_01",
93 0.933f * g_width, 0.933f * g_height); 144 0.933f * g_width, 0.933f * g_height);
94 145
146 glDeleteProgram(program);
95 glDeleteBuffers(1, &vbo_vertex); 147 glDeleteBuffers(1, &vbo_vertex);
96 glDeleteBuffers(1, &vbo_texture); 148 glDeleteBuffers(1, &vbo_texture);
97 glDeleteTextures(1, &texture); 149 glDeleteTextures(1, &texture);
98 150
99 return true; 151 return true;
100 } 152 }
101 153
102 TestBase* GetFillRateTest() { 154 TestBase* GetFillRateTest() {
103 return new FillRateTest; 155 return new FillRateTest;
104 } 156 }
105 157
106 } // namespace glbench 158 } // namespace glbench
OLDNEW
« no previous file with comments | « client/deps/glbench/src/Makefile ('k') | client/deps/glbench/src/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698