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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa_intel.cc

Issue 2110543002: gpu, cmaa: don't blend the rightmost and topmost edges. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | « 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa _intel.h" 5 #include "gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa _intel.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "gpu/command_buffer/service/framebuffer_manager.h" 8 #include "gpu/command_buffer/service/framebuffer_manager.h"
9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
10 #include "ui/gl/gl_context.h" 10 #include "ui/gl/gl_context.h"
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 pixel12); 1192 pixel12);
1193 } 1193 }
1194 outEdges = STORE_UVEC4(outputEdges); 1194 outEdges = STORE_UVEC4(outputEdges);
1195 } 1195 }
1196 \n#endif\n // DETECT_EDGES1 1196 \n#endif\n // DETECT_EDGES1
1197 1197
1198 vec2 UnpackThresholds(uint val) { 1198 vec2 UnpackThresholds(uint val) {
1199 return vec2(val & 0x0Fu, val >> 4u) / 15.0f; 1199 return vec2(val & 0x0Fu, val >> 4u) / 15.0f;
1200 } 1200 }
1201 1201
1202 uint PruneNonDominantEdges(vec4 edges[3]) { 1202 uvec4 PruneNonDominantEdges(vec4 edges[3]) {
1203 vec4 maxE4 = vec4(0.0, 0.0, 0.0, 0.0); 1203 vec4 maxE4 = vec4(0.0, 0.0, 0.0, 0.0);
1204 1204
1205 float avg = 0.0; 1205 float avg = 0.0;
1206 1206
1207 for (int i = 0; i < 3; i++) { 1207 for (int i = 0; i < 3; i++) {
1208 maxE4 = max(maxE4, edges[i]); 1208 maxE4 = max(maxE4, edges[i]);
1209 1209
1210 avg = dot(edges[i], vec4(1, 1, 1, 1) / (3.0 * 4.0)); 1210 avg = dot(edges[i], vec4(1, 1, 1, 1) / (3.0 * 4.0));
1211 } 1211 }
1212 1212
1213 vec2 maxE2 = max(maxE4.xy, maxE4.zw); 1213 vec2 maxE2 = max(maxE4.xy, maxE4.zw);
1214 float maxE = max(maxE2.x, maxE2.y); 1214 float maxE = max(maxE2.x, maxE2.y);
1215 1215
1216 float threshold = avg * 0.65 + maxE * 0.35; 1216 float threshold = avg * 0.65 + maxE * 0.35;
1217 1217
1218 // threshold = 0.0001; // this disables non-dominant edge pruning! 1218 // threshold = 0.0001; // this disables non-dominant edge pruning!
1219 1219
1220 uint cx = edges[0].x >= threshold ? 1u : 0u; 1220 uint cx = edges[0].x >= threshold ? 1u : 0u;
1221 uint cy = edges[0].y >= threshold ? 1u : 0u; 1221 uint cy = edges[0].y >= threshold ? 1u : 0u;
1222 return PackEdge(uvec4(cx, cy, 0, 0)); 1222 return uvec4(cx, cy, 0, 0);
1223 } 1223 }
1224 1224
1225 void CollectEdges(int offX, 1225 void CollectEdges(int offX,
1226 int offY, 1226 int offY,
1227 out vec4 edges[3], 1227 out vec4 edges[3],
1228 const uint packedVals[6 * 6]) { 1228 const uint packedVals[6 * 6]) {
1229 vec2 pixelP0P0 = UnpackThresholds(packedVals[(offX)*6+(offY)]); 1229 vec2 pixelP0P0 = UnpackThresholds(packedVals[(offX)*6+(offY)]);
1230 vec2 pixelP1P0 = UnpackThresholds(packedVals[(offX+1)*6+(offY)]); 1230 vec2 pixelP1P0 = UnpackThresholds(packedVals[(offX+1)*6+(offY)]);
1231 vec2 pixelP0P1 = UnpackThresholds(packedVals[(offX)*6+(offY+1)]); 1231 vec2 pixelP0P1 = UnpackThresholds(packedVals[(offX)*6+(offY+1)]);
1232 vec2 pixelM1P0 = UnpackThresholds(packedVals[(offX-1)*6 +(offY)]); 1232 vec2 pixelM1P0 = UnpackThresholds(packedVals[(offX-1)*6 +(offY)]);
(...skipping 15 matching lines...) Expand all
1248 edges[2].w = pixelM1P1.x; 1248 edges[2].w = pixelM1P1.x;
1249 } 1249 }
1250 ); 1250 );
1251 1251
1252 const char ApplyFramebufferAttachmentCMAAINTELResourceManager::cmaa_frag_s2_[] = 1252 const char ApplyFramebufferAttachmentCMAAINTELResourceManager::cmaa_frag_s2_[] =
1253 SHADER( 1253 SHADER(
1254 \n#ifdef DETECT_EDGES2\n 1254 \n#ifdef DETECT_EDGES2\n
1255 layout(early_fragment_tests) in; 1255 layout(early_fragment_tests) in;
1256 void DetectEdges2() { 1256 void DetectEdges2() {
1257 ivec2 screenPosI = ivec2(gl_FragCoord.xy); 1257 ivec2 screenPosI = ivec2(gl_FragCoord.xy);
1258 ivec2 notTopRight =
1259 ivec2((screenPosI + 1) != textureSize(g_src0Texture4Uint, 0));
piman 2016/06/28 21:09:38 Actually, going back from the next CL, I think I h
dshwang 2016/06/29 10:41:54 I explain this code is introduced to avoid "if sta
dshwang 2016/06/29 13:53:01 oh my bad. I actually want "notEqual((screenPosI +
1258 1260
1259 // source : edge differences from previous pass 1261 // source : edge differences from previous pass
1260 uint packedVals[6 * 6]; 1262 uint packedVals[6 * 6];
1261 1263
1262 // center pixel (our output) 1264 // center pixel (our output)
1263 UVEC4 packedQ4 = texelFetch(g_src0Texture4Uint, screenPosI.xy, 0); 1265 UVEC4 packedQ4 = texelFetch(g_src0Texture4Uint, screenPosI.xy, 0);
1264 packedVals[(2) * 6 + (2)] = LOAD_UINT(packedQ4.x); 1266 packedVals[(2) * 6 + (2)] = LOAD_UINT(packedQ4.x);
1265 packedVals[(3) * 6 + (2)] = LOAD_UINT(packedQ4.y); 1267 packedVals[(3) * 6 + (2)] = LOAD_UINT(packedQ4.y);
1266 packedVals[(2) * 6 + (3)] = LOAD_UINT(packedQ4.z); 1268 packedVals[(2) * 6 + (3)] = LOAD_UINT(packedQ4.z);
1267 packedVals[(3) * 6 + (3)] = LOAD_UINT(packedQ4.w); 1269 packedVals[(3) * 6 + (3)] = LOAD_UINT(packedQ4.w);
(...skipping 14 matching lines...) Expand all
1282 UVEC4 packedQ3 = texelFetchOffset(g_src0Texture4Uint, 1284 UVEC4 packedQ3 = texelFetchOffset(g_src0Texture4Uint,
1283 screenPosI.xy, 0, ivec2(-1, 0)); 1285 screenPosI.xy, 0, ivec2(-1, 0));
1284 packedVals[(0) * 6 + (2)] = LOAD_UINT(packedQ3.x); 1286 packedVals[(0) * 6 + (2)] = LOAD_UINT(packedQ3.x);
1285 packedVals[(1) * 6 + (2)] = LOAD_UINT(packedQ3.y); 1287 packedVals[(1) * 6 + (2)] = LOAD_UINT(packedQ3.y);
1286 packedVals[(0) * 6 + (3)] = LOAD_UINT(packedQ3.z); 1288 packedVals[(0) * 6 + (3)] = LOAD_UINT(packedQ3.z);
1287 packedVals[(1) * 6 + (3)] = LOAD_UINT(packedQ3.w); 1289 packedVals[(1) * 6 + (3)] = LOAD_UINT(packedQ3.w);
1288 } 1290 }
1289 1291
1290 if (bool(packedVals[(2) * 6 + (2)])) { 1292 if (bool(packedVals[(2) * 6 + (2)])) {
1291 CollectEdges(2, 2, edges, packedVals); 1293 CollectEdges(2, 2, edges, packedVals);
1292 uint pe = PruneNonDominantEdges(edges); 1294 uint pe = PackEdge(PruneNonDominantEdges(edges));
1293 if (pe != 0u) { 1295 if (pe != 0u) {
1294 imageStore(g_resultTexture, 2 * screenPosI.xy + ivec2(0, 0), 1296 imageStore(g_resultTexture, 2 * screenPosI.xy + ivec2(0, 0),
1295 vec4(float(0x80u | pe) / 255.0, 0, 0, 0)); 1297 vec4(float(0x80u | pe) / 255.0, 0, 0, 0));
1296 } 1298 }
1297 } 1299 }
1298 1300
1299 if (bool(packedVals[(3) * 6 + (2)]) || 1301 if (bool(packedVals[(3) * 6 + (2)]) ||
1300 bool(packedVals[(3) * 6 + (3)])) { 1302 bool(packedVals[(3) * 6 + (3)])) {
1301 UVEC4 packedQ5 = texelFetchOffset(g_src0Texture4Uint, 1303 UVEC4 packedQ5 = texelFetchOffset(g_src0Texture4Uint,
1302 screenPosI.xy, 0, ivec2(1, 0)); 1304 screenPosI.xy, 0, ivec2(1, 0));
1303 packedVals[(4) * 6 + (2)] = LOAD_UINT(packedQ5.x); 1305 packedVals[(4) * 6 + (2)] = LOAD_UINT(packedQ5.x);
1304 packedVals[(5) * 6 + (2)] = LOAD_UINT(packedQ5.y); 1306 packedVals[(5) * 6 + (2)] = LOAD_UINT(packedQ5.y);
1305 packedVals[(4) * 6 + (3)] = LOAD_UINT(packedQ5.z); 1307 packedVals[(4) * 6 + (3)] = LOAD_UINT(packedQ5.z);
1306 packedVals[(5) * 6 + (3)] = LOAD_UINT(packedQ5.w); 1308 packedVals[(5) * 6 + (3)] = LOAD_UINT(packedQ5.w);
1307 } 1309 }
1308 1310
1309 if (bool(packedVals[(3) * 6 + (2)])) { 1311 if (bool(packedVals[(3) * 6 + (2)])) {
1310 UVEC4 packedQ2 = texelFetchOffset(g_src0Texture4Uint, 1312 UVEC4 packedQ2 = texelFetchOffset(g_src0Texture4Uint,
1311 screenPosI.xy, 0, ivec2(1, -1)); 1313 screenPosI.xy, 0, ivec2(1, -1));
1312 packedVals[(4) * 6 + (0)] = LOAD_UINT(packedQ2.x); 1314 packedVals[(4) * 6 + (0)] = LOAD_UINT(packedQ2.x);
1313 packedVals[(5) * 6 + (0)] = LOAD_UINT(packedQ2.y); 1315 packedVals[(5) * 6 + (0)] = LOAD_UINT(packedQ2.y);
1314 packedVals[(4) * 6 + (1)] = LOAD_UINT(packedQ2.z); 1316 packedVals[(4) * 6 + (1)] = LOAD_UINT(packedQ2.z);
1315 packedVals[(5) * 6 + (1)] = LOAD_UINT(packedQ2.w); 1317 packedVals[(5) * 6 + (1)] = LOAD_UINT(packedQ2.w);
1316 1318
1317 CollectEdges(3, 2, edges, packedVals); 1319 CollectEdges(3, 2, edges, packedVals);
1318 uint pe = PruneNonDominantEdges(edges); 1320 uvec4 dominant_edges = PruneNonDominantEdges(edges);
1321 // The rightmost edge of the texture is not edge.
1322 // Note: texelFetch() on out of range gives an undefined value.
1323 uint pe = PackEdge(dominant_edges * uvec4(notTopRight.x, 1, 1, 1));
1319 if (pe != 0u) { 1324 if (pe != 0u) {
1320 imageStore(g_resultTexture, 2 * screenPosI.xy + ivec2(1, 0), 1325 imageStore(g_resultTexture, 2 * screenPosI.xy + ivec2(1, 0),
1321 vec4(float(0x80u | pe) / 255.0, 0, 0, 0)); 1326 vec4(float(0x80u | pe) / 255.0, 0, 0, 0));
1322 } 1327 }
1323 } 1328 }
1324 1329
1325 if (bool(packedVals[(2) * 6 + (3)]) || 1330 if (bool(packedVals[(2) * 6 + (3)]) ||
1326 bool(packedVals[(3) * 6 + (3)])) { 1331 bool(packedVals[(3) * 6 + (3)])) {
1327 UVEC4 packedQ7 = texelFetchOffset(g_src0Texture4Uint, 1332 UVEC4 packedQ7 = texelFetchOffset(g_src0Texture4Uint,
1328 screenPosI.xy, 0, ivec2(0, 1)); 1333 screenPosI.xy, 0, ivec2(0, 1));
1329 packedVals[(2) * 6 + (4)] = LOAD_UINT(packedQ7.x); 1334 packedVals[(2) * 6 + (4)] = LOAD_UINT(packedQ7.x);
1330 packedVals[(3) * 6 + (4)] = LOAD_UINT(packedQ7.y); 1335 packedVals[(3) * 6 + (4)] = LOAD_UINT(packedQ7.y);
1331 packedVals[(2) * 6 + (5)] = LOAD_UINT(packedQ7.z); 1336 packedVals[(2) * 6 + (5)] = LOAD_UINT(packedQ7.z);
1332 packedVals[(3) * 6 + (5)] = LOAD_UINT(packedQ7.w); 1337 packedVals[(3) * 6 + (5)] = LOAD_UINT(packedQ7.w);
1333 } 1338 }
1334 1339
1335 if (bool(packedVals[(2) * 6 + (3)])) { 1340 if (bool(packedVals[(2) * 6 + (3)])) {
1336 UVEC4 packedQ6 = texelFetchOffset(g_src0Texture4Uint, 1341 UVEC4 packedQ6 = texelFetchOffset(g_src0Texture4Uint,
1337 screenPosI.xy, 0, ivec2(-1, -1)); 1342 screenPosI.xy, 0, ivec2(-1, -1));
1338 packedVals[(0) * 6 + (4)] = LOAD_UINT(packedQ6.x); 1343 packedVals[(0) * 6 + (4)] = LOAD_UINT(packedQ6.x);
1339 packedVals[(1) * 6 + (4)] = LOAD_UINT(packedQ6.y); 1344 packedVals[(1) * 6 + (4)] = LOAD_UINT(packedQ6.y);
1340 packedVals[(0) * 6 + (5)] = LOAD_UINT(packedQ6.z); 1345 packedVals[(0) * 6 + (5)] = LOAD_UINT(packedQ6.z);
1341 packedVals[(1) * 6 + (5)] = LOAD_UINT(packedQ6.w); 1346 packedVals[(1) * 6 + (5)] = LOAD_UINT(packedQ6.w);
1342 1347
1343 CollectEdges(2, 3, edges, packedVals); 1348 CollectEdges(2, 3, edges, packedVals);
1344 uint pe = PruneNonDominantEdges(edges); 1349 uvec4 dominant_edges = PruneNonDominantEdges(edges);
1350 uint pe = PackEdge(dominant_edges * uvec4(1, notTopRight.y, 1, 1));
1345 if (pe != 0u) { 1351 if (pe != 0u) {
1346 imageStore(g_resultTexture, 2 * screenPosI.xy + ivec2(0, 1), 1352 imageStore(g_resultTexture, 2 * screenPosI.xy + ivec2(0, 1),
1347 vec4(float(0x80u | pe) / 255.0, 0, 0, 0)); 1353 vec4(float(0x80u | pe) / 255.0, 0, 0, 0));
1348 } 1354 }
1349 } 1355 }
1350 1356
1351 if (bool(packedVals[(3) * 6 + (3)])) { 1357 if (bool(packedVals[(3) * 6 + (3)])) {
1352 CollectEdges(3, 3, edges, packedVals); 1358 CollectEdges(3, 3, edges, packedVals);
1353 uint pe = PruneNonDominantEdges(edges); 1359 uvec4 dominant_edges = PruneNonDominantEdges(edges);
1360 uint pe = PackEdge(dominant_edges * uvec4(notTopRight, 1, 1));
1354 if (pe != 0u) { 1361 if (pe != 0u) {
1355 imageStore(g_resultTexture, 2 * screenPosI.xy + ivec2(1, 1), 1362 imageStore(g_resultTexture, 2 * screenPosI.xy + ivec2(1, 1),
1356 vec4(float(0x80u | pe) / 255.0, 0, 0, 0)); 1363 vec4(float(0x80u | pe) / 255.0, 0, 0, 0));
1357 } 1364 }
1358 } 1365 }
1359 } 1366 }
1360 \n#endif\n // DETECT_EDGES2 1367 \n#endif\n // DETECT_EDGES2
1361 1368
1362 \n#ifdef COMBINE_EDGES\n 1369 \n#ifdef COMBINE_EDGES\n
1363 void CombineEdges() { 1370 void CombineEdges() {
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1828 \n#ifdef OUT_FBO\n 1835 \n#ifdef OUT_FBO\n
1829 outColor = pixel; 1836 outColor = pixel;
1830 \n#else\n 1837 \n#else\n
1831 imageStore(outTexture, screenPosI, pixel); 1838 imageStore(outTexture, screenPosI, pixel);
1832 \n#endif\n 1839 \n#endif\n
1833 } 1840 }
1834 ); 1841 );
1835 /* clang-format on */ 1842 /* clang-format on */
1836 1843
1837 } // namespace gpu 1844 } // namespace gpu
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