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

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

Issue 2122020: Fixes for GLES systems. (Closed) Base URL: ssh://git@chromiumos-git//autotest.git
Patch Set: ...and removed bogus #-I from Makefile Created 10 years, 7 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
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 "main.h" 5 #include "main.h"
6 #include "testbase.h" 6 #include "testbase.h"
7 #include "utils.h" 7 #include "utils.h"
8 8
9 9
10 namespace glbench { 10 namespace glbench {
11 11
12 12
13 class VaryingsAndDdxyShaderTest : public DrawElementsTestFunc { 13 class VaryingsAndDdxyShaderTest : public DrawElementsTestFunc {
14 public: 14 public:
15 VaryingsAndDdxyShaderTest() {} 15 VaryingsAndDdxyShaderTest() {}
16 virtual ~VaryingsAndDdxyShaderTest() {} 16 virtual ~VaryingsAndDdxyShaderTest() {}
17 virtual bool Run(); 17 virtual bool Run();
18 18
19 private: 19 private:
20 DISALLOW_COPY_AND_ASSIGN(VaryingsAndDdxyShaderTest); 20 DISALLOW_COPY_AND_ASSIGN(VaryingsAndDdxyShaderTest);
21 }; 21 };
22 22
23 #if I915_WORKAROUND 23 #if defined(I915_WORKAROUND)
24 #define V1 "gl_TexCoord[0]" 24 #define V1 "gl_TexCoord[0]"
25 #define V2 "gl_TexCoord[1]" 25 #define V2 "gl_TexCoord[1]"
26 #define V3 "gl_TexCoord[2]" 26 #define V3 "gl_TexCoord[2]"
27 #define V4 "gl_TexCoord[3]" 27 #define V4 "gl_TexCoord[3]"
28 #define V5 "gl_TexCoord[4]" 28 #define V5 "gl_TexCoord[4]"
29 #define V6 "gl_TexCoord[5]" 29 #define V6 "gl_TexCoord[5]"
30 #define V7 "gl_TexCoord[6]" 30 #define V7 "gl_TexCoord[6]"
31 #define V8 "gl_TexCoord[7]" 31 #define V8 "gl_TexCoord[7]"
32 #define DDX "dFdx"
33 #define DDY "dFdy"
34 #else 32 #else
35 #define V1 "v1" 33 #define V1 "v1"
36 #define V2 "v2" 34 #define V2 "v2"
37 #define V3 "v3" 35 #define V3 "v3"
38 #define V4 "v4" 36 #define V4 "v4"
39 #define V5 "v5" 37 #define V5 "v5"
40 #define V6 "v6" 38 #define V6 "v6"
41 #define V7 "v7" 39 #define V7 "v7"
42 #define V8 "v8" 40 #define V8 "v8"
43 #define DDX "ddx"
44 #define DDY "ddy"
45 #endif 41 #endif
46 42
47 43
48 const char *vertex_shader_1_varying = 44 const char *vertex_shader_1_varying =
49 "attribute vec4 c;" 45 "attribute vec4 c;"
50 "varying vec4 v1;" 46 "varying vec4 v1;"
51 "void main() {" 47 "void main() {"
52 " gl_Position = c;" 48 " gl_Position = c;"
53 V1 "= c;" 49 V1 "= c;"
54 "}"; 50 "}";
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 int attribute_index = glGetAttribLocation(program, "c"); 147 int attribute_index = glGetAttribLocation(program, "c");
152 glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer); 148 glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
153 glVertexAttribPointer(attribute_index, 2, GL_FLOAT, GL_FALSE, 0, NULL); 149 glVertexAttribPointer(attribute_index, 2, GL_FLOAT, GL_FALSE, 0, NULL);
154 glEnableVertexAttribArray(attribute_index); 150 glEnableVertexAttribArray(attribute_index);
155 151
156 return program; 152 return program;
157 } 153 }
158 154
159 155
160 const char *fragment_shader_ddx = 156 const char *fragment_shader_ddx =
157 "#extension GL_OES_standard_derivatives : enable\n"
161 "varying vec4 v1;" 158 "varying vec4 v1;"
162 "void main() {" 159 "void main() {"
163 " gl_FragColor = vec4(" DDX "(" V1 ".x), 0., 0., 1.);" 160 " gl_FragColor = vec4(dFdx(" V1 ".x), 0., 0., 1.);"
164 "}"; 161 "}";
165 162
166 const char *fragment_shader_ddy = 163 const char *fragment_shader_ddy =
164 "#extension GL_OES_standard_derivatives : enable\n"
167 "varying vec4 v1;" 165 "varying vec4 v1;"
168 "void main() {" 166 "void main() {"
169 " gl_FragColor = vec4(" DDY "(" V1 ".y), 0., 0., 1.);" 167 " gl_FragColor = vec4(dFdy(" V1 ".y), 0., 0., 1.);"
170 "}"; 168 "}";
171 169
172 GLuint DdxDdyShaderProgram(bool ddx, GLuint vertex_buffer) { 170 GLuint DdxDdyShaderProgram(bool ddx, GLuint vertex_buffer) {
173 GLuint program = 171 GLuint program =
174 InitShaderProgram(vertex_shader_1_varying, 172 InitShaderProgram(vertex_shader_1_varying,
175 ddx ? fragment_shader_ddx : fragment_shader_ddy); 173 ddx ? fragment_shader_ddx : fragment_shader_ddy);
176 174
177 int attribute_index = glGetAttribLocation(program, "c"); 175 int attribute_index = glGetAttribLocation(program, "c");
178 glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer); 176 glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
179 glVertexAttribPointer(attribute_index, 2, GL_FLOAT, GL_FALSE, 0, NULL); 177 glVertexAttribPointer(attribute_index, 2, GL_FLOAT, GL_FALSE, 0, NULL);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 return true; 238 return true;
241 } 239 }
242 240
243 241
244 TestBase* GetVaryingsAndDdxyShaderTest() { 242 TestBase* GetVaryingsAndDdxyShaderTest() {
245 return new VaryingsAndDdxyShaderTest; 243 return new VaryingsAndDdxyShaderTest;
246 } 244 }
247 245
248 246
249 } // namespace glbench 247 } // namespace glbench
OLDNEW
« no previous file with comments | « client/deps/glbench/src/utils.h ('k') | client/deps/glbench/src/windowmanagercompositingtest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698