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

Side by Side Diff: cc/output/shader.cc

Issue 14705008: cc: Cache highp_threshold in TexCoordPrecisionRequired (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium 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 "cc/output/shader.h" 5 #include "cc/output/shader.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // we are unlikely to be vertex shader bound when drawing large quads. 74 // we are unlikely to be vertex shader bound when drawing large quads.
75 // Also, some vertex shaders mutate the texture coordinate in such a 75 // Also, some vertex shaders mutate the texture coordinate in such a
76 // way that the effective precision might be lower than expected. 76 // way that the effective precision might be lower than expected.
77 return "#define TexCoordPrecision highp\n" + 77 return "#define TexCoordPrecision highp\n" +
78 std::string(shader_string); 78 std::string(shader_string);
79 } 79 }
80 80
81 TexCoordPrecision TexCoordPrecisionRequired(WebGraphicsContext3D* context, 81 TexCoordPrecision TexCoordPrecisionRequired(WebGraphicsContext3D* context,
82 int highp_threshold_min, 82 int highp_threshold_min,
83 int x, int y) { 83 int x, int y) {
84 // Initialize range and precision with minimum spec values for when 84 static int s_highp_threshold = 0;
85 // GetShaderPrecisionFormat is a test stub. 85 static WebGraphicsContext3D* s_cached_context = NULL;
86 // TODO(brianderson): Implement better stubs of GetShaderPrecisionFormat 86
87 // everywhere. 87 if (!s_cached_context) {
88 GLint range[2] = { 14, 14 }; 88 // Initialize range and precision with minimum spec values for when
89 GLint precision = 10; 89 // GetShaderPrecisionFormat is a test stub.
90 GLC(context, context->getShaderPrecisionFormat(GL_FRAGMENT_SHADER, 90 // TODO(brianderson): Implement better stubs of GetShaderPrecisionFormat
91 GL_MEDIUM_FLOAT, 91 // everywhere.
92 range, &precision)); 92 static GLint range[2] = { 14, 14 };
93 int highp_threshold = std::max(1 << precision, highp_threshold_min); 93 static GLint precision = 10;
94 if (x > highp_threshold || y > highp_threshold) 94 GLC(context, context->getShaderPrecisionFormat(GL_FRAGMENT_SHADER,
95 GL_MEDIUM_FLOAT,
96 range, &precision));
97 s_highp_threshold = std::max(1 << precision, highp_threshold_min);
98 s_cached_context = context;
99 }
100
101 // If we are using multiple contexts, we need smarter caching logic.
102 DCHECK_EQ(s_cached_context, context);
vangelis 2013/05/03 19:13:27 It's not uncommon for one renderer to have multipl
103
104 if (x > s_highp_threshold || y > s_highp_threshold)
95 return TexCoordPrecisionHigh; 105 return TexCoordPrecisionHigh;
96 return TexCoordPrecisionMedium; 106 return TexCoordPrecisionMedium;
97 } 107 }
98 108
99 } // namespace 109 } // namespace
100 110
101 TexCoordPrecision TexCoordPrecisionRequired(WebGraphicsContext3D* context, 111 TexCoordPrecision TexCoordPrecisionRequired(WebGraphicsContext3D* context,
102 int highp_threshold_min, 112 int highp_threshold_min,
103 gfx::Point max_coordinate) { 113 gfx::Point max_coordinate) {
104 return TexCoordPrecisionRequired(context, highp_threshold_min, 114 return TexCoordPrecisionRequired(context, highp_threshold_min,
(...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1429 vec2 texCoord = 1439 vec2 texCoord =
1430 clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texTransform.xy; 1440 clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texTransform.xy;
1431 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0); 1441 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0);
1432 float picker = abs(coord.x - coord.y); 1442 float picker = abs(coord.x - coord.y);
1433 gl_FragColor = mix(color1, color2, picker) * alpha; 1443 gl_FragColor = mix(color1, color2, picker) * alpha;
1434 } 1444 }
1435 ); // NOLINT(whitespace/parens) 1445 ); // NOLINT(whitespace/parens)
1436 } 1446 }
1437 1447
1438 } // namespace cc 1448 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698