OLD | NEW |
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 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1431 // any(greaterThan(numberOfEdges4, uvec4(1))) ? 1.0 : 0.0; | 1431 // any(greaterThan(numberOfEdges4, uvec4(1))) ? 1.0 : 0.0; |
1432 | 1432 |
1433 gl_FragDepth = | 1433 gl_FragDepth = |
1434 any(greaterThan(outEdge4, uvec4(1))) ? 1.0 : 0.0; | 1434 any(greaterThan(outEdge4, uvec4(1))) ? 1.0 : 0.0; |
1435 } | 1435 } |
1436 \n#endif\n // COMBINE_EDGES | 1436 \n#endif\n // COMBINE_EDGES |
1437 | 1437 |
1438 \n#ifdef BLUR_EDGES\n | 1438 \n#ifdef BLUR_EDGES\n |
1439 layout(early_fragment_tests) in; | 1439 layout(early_fragment_tests) in; |
1440 void BlurEdges() { | 1440 void BlurEdges() { |
1441 int _i; | 1441 // Each |gl_FragCoord| updates 4 texels of the original texture, which are |
1442 | 1442 // 2x|gl_FragCoord| + (-1 or 0, -1 or 0) in the unnormalized texture |
| 1443 // coordinate, which is the coordinate used by texelFetch(). |
| 1444 // e.g. when gl_FragCoord == (3.5, 3.5), this fragment shader covers |
| 1445 // (6,6) (6,7) (7,6) (7,7) texels. |
| 1446 // Note: gl_FragCoord == (0.5, 0.5) (i.e. left-bottom-most fragment) |
| 1447 // covers (0,0) (0,1) (1,0) (1,1) texels |
| 1448 // gl_FragCoord == ((w/2)-0.5, (h/2)-0.5) (i.e. right-top-most fragment) |
| 1449 // covers (w-2,h-2) (w-2,h-1) (w-1,h-2) (w-1,h-1) |
1443 ivec3 screenPosIBase = ivec3(ivec2(gl_FragCoord.xy) * 2, 0); | 1450 ivec3 screenPosIBase = ivec3(ivec2(gl_FragCoord.xy) * 2, 0); |
1444 vec3 screenPosBase = vec3(screenPosIBase); | 1451 vec3 screenPosBase = vec3(screenPosIBase); |
| 1452 |
| 1453 // When gl_FragCoord == (0.5, 0.5) (i.e. left-bottom-most fragment), |
| 1454 // |sampA| textureGatherOffset() looks up (-1,-1), (-1,0), (0,-1), (0,0). |
| 1455 // (-1,-1), (-1,0), (0,-1) must be handled. |
| 1456 // Note: textureGatherOffset() on out of range gives an undefined value. |
| 1457 uvec2 notBottomLeft = uvec2(notEqual(screenPosIBase.xy, ivec2(0, 0))); |
| 1458 // When gl_FragCoord == ((w/2)-0.5, (h/2)-0.5) (i.e. right-top-most |
| 1459 // fragment), |sampD| looks up (w-1, h-1), (w-1, h), (w, h-1), (w, h). |
| 1460 // (w-1, h), (w, h-1), (w, h) must be handled. |
| 1461 uvec2 notTopRight = uvec2( |
| 1462 notEqual((screenPosIBase.xy + 2), textureSize(g_src0TextureFlt, 0))); |
| 1463 |
1445 uint forFollowUpCount = 0u; | 1464 uint forFollowUpCount = 0u; |
1446 ivec4 forFollowUpCoords[4]; | 1465 ivec4 forFollowUpCoords[4]; |
1447 | 1466 |
1448 uint packedEdgesArray[4 * 4]; | 1467 uint packedEdgesArray[4 * 4]; |
1449 | 1468 |
1450 uvec4 sampA = uvec4( | 1469 uvec4 sampA = uvec4( |
1451 textureGatherOffset(g_src0TextureFlt, | 1470 textureGatherOffset(g_src0TextureFlt, |
1452 screenPosBase.xy * g_OneOverScreenSize, | 1471 screenPosBase.xy * g_OneOverScreenSize, |
1453 ivec2(0, 0)) *255.5); | 1472 ivec2(0, 0)) *255.5); |
1454 uvec4 sampB = uvec4( | 1473 uvec4 sampB = uvec4( |
1455 textureGatherOffset(g_src0TextureFlt, | 1474 textureGatherOffset(g_src0TextureFlt, |
1456 screenPosBase.xy * g_OneOverScreenSize, | 1475 screenPosBase.xy * g_OneOverScreenSize, |
1457 ivec2(2, 0)) *255.5); | 1476 ivec2(2, 0)) *255.5); |
1458 uvec4 sampC = uvec4( | 1477 uvec4 sampC = uvec4( |
1459 textureGatherOffset(g_src0TextureFlt, | 1478 textureGatherOffset(g_src0TextureFlt, |
1460 screenPosBase.xy * g_OneOverScreenSize, | 1479 screenPosBase.xy * g_OneOverScreenSize, |
1461 ivec2(0, 2)) *255.5); | 1480 ivec2(0, 2)) *255.5); |
1462 uvec4 sampD = uvec4( | 1481 uvec4 sampD = uvec4( |
1463 textureGatherOffset(g_src0TextureFlt, | 1482 textureGatherOffset(g_src0TextureFlt, |
1464 screenPosBase.xy * g_OneOverScreenSize, | 1483 screenPosBase.xy * g_OneOverScreenSize, |
1465 ivec2(2, 2)) *255.5); | 1484 ivec2(2, 2)) *255.5); |
1466 | 1485 |
1467 packedEdgesArray[(0) * 4 + (0)] = sampA.w; | 1486 packedEdgesArray[(0) * 4 + (0)] = |
1468 packedEdgesArray[(1) * 4 + (0)] = sampA.z; | 1487 sampA.w * notBottomLeft.x * notBottomLeft.y; |
1469 packedEdgesArray[(0) * 4 + (1)] = sampA.x; | 1488 packedEdgesArray[(1) * 4 + (0)] = sampA.z * notBottomLeft.y; |
| 1489 packedEdgesArray[(0) * 4 + (1)] = sampA.x * notBottomLeft.x; |
1470 packedEdgesArray[(1) * 4 + (1)] = sampA.y; | 1490 packedEdgesArray[(1) * 4 + (1)] = sampA.y; |
1471 packedEdgesArray[(2) * 4 + (0)] = sampB.w; | 1491 packedEdgesArray[(2) * 4 + (0)] = sampB.w * notBottomLeft.y; |
1472 packedEdgesArray[(3) * 4 + (0)] = sampB.z; | 1492 packedEdgesArray[(3) * 4 + (0)] = |
| 1493 sampB.z * notBottomLeft.y * notTopRight.x; |
1473 packedEdgesArray[(2) * 4 + (1)] = sampB.x; | 1494 packedEdgesArray[(2) * 4 + (1)] = sampB.x; |
1474 packedEdgesArray[(3) * 4 + (1)] = sampB.y; | 1495 packedEdgesArray[(3) * 4 + (1)] = sampB.y * notTopRight.x; |
1475 packedEdgesArray[(0) * 4 + (2)] = sampC.w; | 1496 packedEdgesArray[(0) * 4 + (2)] = sampC.w * notBottomLeft.x; |
1476 packedEdgesArray[(1) * 4 + (2)] = sampC.z; | 1497 packedEdgesArray[(1) * 4 + (2)] = sampC.z; |
1477 packedEdgesArray[(0) * 4 + (3)] = sampC.x; | 1498 packedEdgesArray[(0) * 4 + (3)] = |
1478 packedEdgesArray[(1) * 4 + (3)] = sampC.y; | 1499 sampC.x * notBottomLeft.x * notTopRight.y; |
| 1500 packedEdgesArray[(1) * 4 + (3)] = sampC.y * notTopRight.y; |
1479 packedEdgesArray[(2) * 4 + (2)] = sampD.w; | 1501 packedEdgesArray[(2) * 4 + (2)] = sampD.w; |
1480 packedEdgesArray[(3) * 4 + (2)] = sampD.z; | 1502 packedEdgesArray[(3) * 4 + (2)] = sampD.z * notTopRight.x; |
1481 packedEdgesArray[(2) * 4 + (3)] = sampD.x; | 1503 packedEdgesArray[(2) * 4 + (3)] = sampD.x * notTopRight.y; |
1482 packedEdgesArray[(3) * 4 + (3)] = sampD.y; | 1504 packedEdgesArray[(3) * 4 + (3)] = sampD.y * notTopRight.x * notTopRight.y; |
1483 | 1505 |
1484 for (_i = 0; _i < 4; _i++) { | 1506 for (int _i = 0; _i < 4; _i++) { |
1485 int _x = _i % 2; | 1507 int _x = _i % 2; |
1486 int _y = _i / 2; | 1508 int _y = _i / 2; |
1487 | 1509 |
1488 ivec3 screenPosI = screenPosIBase + ivec3(_x, _y, 0); | 1510 ivec3 screenPosI = screenPosIBase + ivec3(_x, _y, 0); |
1489 | 1511 |
1490 uint packedEdgesC = packedEdgesArray[(1 + _x) * 4 + (1 + _y)]; | 1512 uint packedEdgesC = packedEdgesArray[(1 + _x) * 4 + (1 + _y)]; |
1491 | 1513 |
1492 uvec4 edges = UnpackEdge(packedEdgesC); | 1514 uvec4 edges = UnpackEdge(packedEdgesC); |
1493 vec4 edgesFlt = vec4(edges); | 1515 vec4 edgesFlt = vec4(edges); |
1494 | 1516 |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1861 \n#ifdef OUT_FBO\n | 1883 \n#ifdef OUT_FBO\n |
1862 outColor = pixel; | 1884 outColor = pixel; |
1863 \n#else\n | 1885 \n#else\n |
1864 imageStore(outTexture, screenPosI, pixel); | 1886 imageStore(outTexture, screenPosI, pixel); |
1865 \n#endif\n | 1887 \n#endif\n |
1866 } | 1888 } |
1867 ); | 1889 ); |
1868 /* clang-format on */ | 1890 /* clang-format on */ |
1869 | 1891 |
1870 } // namespace gpu | 1892 } // namespace gpu |
OLD | NEW |