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

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

Issue 2106933002: gpu, cmaa: bottom to top is always y-direction. (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 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 outVal.x = D3DX_FLOAT_to_SRGB(val.x); 798 outVal.x = D3DX_FLOAT_to_SRGB(val.x);
799 outVal.y = D3DX_FLOAT_to_SRGB(val.y); 799 outVal.y = D3DX_FLOAT_to_SRGB(val.y);
800 outVal.z = D3DX_FLOAT_to_SRGB(val.z); 800 outVal.z = D3DX_FLOAT_to_SRGB(val.z);
801 return outVal; 801 return outVal;
802 } 802 }
803 /////////////////////////////////////////////////////////////////////// 803 ///////////////////////////////////////////////////////////////////////
804 \n#endif\n // IN_GAMMA_CORRECT_MODE 804 \n#endif\n // IN_GAMMA_CORRECT_MODE
805 805
806 // how .rgba channels from the edge texture maps to pixel edges: 806 // how .rgba channels from the edge texture maps to pixel edges:
807 // 807 //
808 // A - 0x08 808 // A - 0x02
809 // |¯¯¯¯¯¯¯¯¯| 809 // |¯¯¯¯¯¯¯¯¯|
810 // | | 810 // | |
811 // 0x04 - B | pixel | R - 0x01 811 // 0x04 - B | pixel | R - 0x01
812 // | | 812 // | |
813 // |_________| 813 // |_________|
814 // G - 0x02 814 // G - 0x08
815 // 815 //
816 // (A - there's an edge between us and a pixel above us) 816 // (A - there's an edge between us and a pixel at the bottom)
817 // (R - there's an edge between us and a pixel to the right) 817 // (R - there's an edge between us and a pixel to the right)
818 // (G - there's an edge between us and a pixel at the bottom) 818 // (G - there's an edge between us and a pixel above us)
819 // (B - there's an edge between us and a pixel to the left) 819 // (B - there's an edge between us and a pixel to the left)
820 820
821 // Expecting values of 1 and 0 only! 821 // Expecting values of 1 and 0 only!
822 uint PackEdge(uvec4 edges) { 822 uint PackEdge(uvec4 edges) {
823 return (edges.x << 0u) | (edges.y << 1u) | (edges.z << 2u) | 823 return (edges.x << 0u) | (edges.y << 1u) | (edges.z << 2u) |
824 (edges.w << 3u); 824 (edges.w << 3u);
825 } 825 }
826 826
827 uvec4 UnpackEdge(uint value) { 827 uvec4 UnpackEdge(uint value) {
828 uvec4 ret; 828 uvec4 ret;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 const bool horizontal, 909 const bool horizontal,
910 const bool invertedZShape, 910 const bool invertedZShape,
911 const ivec2 stepRight) { 911 const ivec2 stepRight) {
912 // TODO: there must be a cleaner and faster way to get to these - 912 // TODO: there must be a cleaner and faster way to get to these -
913 // a precalculated array indexing maybe? 913 // a precalculated array indexing maybe?
914 uint maskLeft = uint(0); 914 uint maskLeft = uint(0);
915 uint bitsContinueLeft = uint(0); 915 uint bitsContinueLeft = uint(0);
916 uint maskRight = uint(0); 916 uint maskRight = uint(0);
917 uint bitsContinueRight = uint(0); 917 uint bitsContinueRight = uint(0);
918 { 918 {
919 // Horizontal (vertical is the same, just rotated 90º 919 // Horizontal (vertical is the same, just rotated 90º counter-clockwise)
920 // counter-clockwise)
921 // Inverted Z case: // Normal Z case: 920 // Inverted Z case: // Normal Z case:
922 // __ // __ 921 // __ // __
923 // X| // X| 922 // X| // X|
924 // -- // -- 923 // -- // --
925 // 924 //
925 // Vertical
926 // Inverted Z case: // Normal Z case:
927 // | // |
928 // -- // --
929 // X| // |X
926 uint maskTraceLeft = uint(0); 930 uint maskTraceLeft = uint(0);
927 uint maskTraceRight = uint(0); 931 uint maskTraceRight = uint(0);
928 uint maskStopLeft = uint(0); 932 uint maskStopLeft = uint(0);
929 uint maskStopRight = uint(0); 933 uint maskStopRight = uint(0);
930 if (horizontal) { 934 if (horizontal) {
931 if (invertedZShape) { 935 if (invertedZShape) {
932 maskTraceLeft = 0x02u; // tracing bottom edge 936 maskTraceLeft = 0x08u; // tracing bottom edge
933 maskTraceRight = 0x08u; // tracing top edge 937 maskTraceRight = 0x02u; // tracing top edge
934 } else { 938 } else {
935 maskTraceLeft = 0x08u; // tracing top edge 939 maskTraceLeft = 0x02u; // tracing top edge
936 maskTraceRight = 0x02u; // tracing bottom edge 940 maskTraceRight = 0x08u; // tracing bottom edge
937 } 941 }
938 maskStopLeft = 0x01u; // stop on right edge 942 maskStopLeft = 0x01u; // stop on right edge
939 maskStopRight = 0x04u; // stop on left edge 943 maskStopRight = 0x04u; // stop on left edge
940 } else { 944 } else {
941 if (invertedZShape) { 945 if (invertedZShape) {
942 maskTraceLeft = 0x01u; // tracing right edge 946 maskTraceLeft = 0x01u; // tracing right edge
943 maskTraceRight = 0x04u; // tracing left edge 947 maskTraceRight = 0x04u; // tracing left edge
944 } else { 948 } else {
945 maskTraceLeft = 0x04u; // tracing left edge 949 maskTraceLeft = 0x04u; // tracing left edge
946 maskTraceRight = 0x01u; // tracing right edge 950 maskTraceRight = 0x01u; // tracing right edge
947 } 951 }
948 maskStopLeft = 0x08u; // stop on top edge 952 maskStopLeft = 0x02u; // stop on top edge
949 maskStopRight = 0x02u; // stop on bottom edge 953 maskStopRight = 0x08u; // stop on bottom edge
950 } 954 }
951 955
952 maskLeft = maskTraceLeft | maskStopLeft; 956 maskLeft = maskTraceLeft | maskStopLeft;
953 bitsContinueLeft = maskTraceLeft; 957 bitsContinueLeft = maskTraceLeft;
954 maskRight = maskTraceRight | maskStopRight; 958 maskRight = maskTraceRight | maskStopRight;
955 bitsContinueRight = maskTraceRight; 959 bitsContinueRight = maskTraceRight;
956 } 960 }
957 /////////////////////////////////////////////////////////////////////// 961 ///////////////////////////////////////////////////////////////////////
958 962
959 \n#ifdef SETTINGS_ALLOW_SHORT_Zs\n 963 \n#ifdef SETTINGS_ALLOW_SHORT_Zs\n
(...skipping 23 matching lines...) Expand all
983 } 987 }
984 lineLengthLeft = lineLengthRight = i; 988 lineLengthLeft = lineLengthRight = i;
985 return; 989 return;
986 } 990 }
987 991
988 void ProcessDetectedZ(ivec2 screenPos, bool horizontal, 992 void ProcessDetectedZ(ivec2 screenPos, bool horizontal,
989 bool invertedZShape) { 993 bool invertedZShape) {
990 int lineLengthLeft = 0; 994 int lineLengthLeft = 0;
991 int lineLengthRight = 0; 995 int lineLengthRight = 0;
992 996
993 ivec2 stepRight = (horizontal) ? (ivec2(1, 0)) : (ivec2(0, -1)); 997 ivec2 stepRight = (horizontal) ? (ivec2(1, 0)) : (ivec2(0, 1));
994 vec2 blendDir = (horizontal) ? (vec2(0, -1)) : (vec2(-1, 0)); 998 vec2 blendDir = (horizontal) ? (vec2(0, -1)) : (vec2(1, 0));
995 999
996 FindLineLength(lineLengthLeft, lineLengthRight, screenPos, 1000 FindLineLength(lineLengthLeft, lineLengthRight, screenPos,
997 horizontal, invertedZShape, stepRight); 1001 horizontal, invertedZShape, stepRight);
998 1002
999 vec2 pixelSize = g_OneOverScreenSize; 1003 vec2 pixelSize = g_OneOverScreenSize;
1000 1004
1001 float leftOdd = 0.15 * float(lineLengthLeft % 2); 1005 float leftOdd = 0.15 * float(lineLengthLeft % 2);
1002 float rightOdd = 0.15 * float(lineLengthRight % 2); 1006 float rightOdd = 0.15 * float(lineLengthRight % 2);
1003 1007
1004 int loopFrom = -int((lineLengthLeft + 1) / 2) + 1; 1008 int loopFrom = -int((lineLengthLeft + 1) / 2) + 1;
1005 int loopTo = int((lineLengthRight + 1) / 2); 1009 int loopTo = int((lineLengthRight + 1) / 2);
1006 1010
1007 float totalLength = float(loopTo - loopFrom) + 1.0 - leftOdd - 1011 float totalLength = float(loopTo - loopFrom) + 1.0 - leftOdd -
1008 rightOdd; 1012 rightOdd;
1009 1013
1010 for (int i = loopFrom; i <= loopTo; i++) { 1014 for (int i = loopFrom; i <= loopTo; i++) {
1011 highp ivec2 pixelPos = screenPos + stepRight * i; 1015 highp ivec2 pixelPos = screenPos + stepRight * i;
1012 vec2 pixelPosFlt = vec2(float(pixelPos.x) + 0.5, 1016 vec2 pixelPosFlt = vec2(float(pixelPos.x) + 0.5,
1013 float(pixelPos.y) + 0.5); 1017 float(pixelPos.y) + 0.5);
1014 1018
1015 \n#ifdef DEBUG_OUTPUT_AAINFO\n 1019 \n#ifdef DEBUG_OUTPUT_AAINFO\n
1016 imageStore(g_resultTextureSlot2, pixelPos, 1020 imageStore(g_resultTextureSlot2, pixelPos,
1017 PackBlurAAInfo(pixelPos, 1u)); 1021 PackBlurAAInfo(pixelPos, 1u));
1018 \n#endif\n 1022 \n#endif\n
1019 1023
1020 float m = (float(i) + 0.5 - leftOdd - float(loopFrom)) / 1024 float m = (float(i) + 0.5 - leftOdd - float(loopFrom)) /
1021 totalLength; 1025 totalLength;
1022 m = saturate(m); 1026 m = saturate(m);
1023 float k = m - ((i > 0) ? 1.0 : 0.0); 1027 float k = m - ((i > 0) ? 1.0 : 0.0);
1024 k = (invertedZShape) ? (-k) : (k); 1028 k = (invertedZShape) ? (k) : (-k);
1025 1029
1026 vec4 color = textureLod(g_screenTexture, 1030 vec4 color = textureLod(g_screenTexture,
1027 (pixelPosFlt + blendDir * k) * pixelSize, 1031 (pixelPosFlt + blendDir * k) * pixelSize,
1028 0.0); 1032 0.0);
1029 1033
1030 \n#ifdef IN_GAMMA_CORRECT_MODE\n 1034 \n#ifdef IN_GAMMA_CORRECT_MODE\n
1031 color.rgb = D3DX_FLOAT3_to_SRGB(color.rgb); 1035 color.rgb = D3DX_FLOAT3_to_SRGB(color.rgb);
1032 \n#endif\n 1036 \n#endif\n
1033 imageStore(g_resultTextureFlt4Slot1, pixelPos, color); 1037 imageStore(g_resultTextureFlt4Slot1, pixelPos, color);
1034 } 1038 }
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 uint packedEdgesC = packedEdgesArray[(1 + _x) * 4 + (1 + _y)]; 1479 uint packedEdgesC = packedEdgesArray[(1 + _x) * 4 + (1 + _y)];
1476 1480
1477 uvec4 edges = UnpackEdge(packedEdgesC); 1481 uvec4 edges = UnpackEdge(packedEdgesC);
1478 vec4 edgesFlt = vec4(edges); 1482 vec4 edgesFlt = vec4(edges);
1479 1483
1480 float numberOfEdges = dot(edgesFlt, vec4(1, 1, 1, 1)); 1484 float numberOfEdges = dot(edgesFlt, vec4(1, 1, 1, 1));
1481 if (numberOfEdges < 2.0) 1485 if (numberOfEdges < 2.0)
1482 continue; 1486 continue;
1483 1487
1484 float fromRight = edgesFlt.r; 1488 float fromRight = edgesFlt.r;
1485 float fromBelow = edgesFlt.g; 1489 float fromAbove = edgesFlt.g;
1486 float fromLeft = edgesFlt.b; 1490 float fromLeft = edgesFlt.b;
1487 float fromAbove = edgesFlt.a; 1491 float fromBelow = edgesFlt.a;
1488 1492
1489 vec4 xFroms = vec4(fromBelow, fromAbove, fromRight, fromLeft); 1493 vec4 xFroms = vec4(fromBelow, fromAbove, fromRight, fromLeft);
1490 1494
1491 float blurCoeff = 0.0; 1495 float blurCoeff = 0.0;
1492 1496
1493 // These are additional blurs that complement the main line-based 1497 // These are additional blurs that complement the main line-based
1494 // blurring; Unlike line-based, these do not necessarily preserve 1498 // blurring; Unlike line-based, these do not necessarily preserve
1495 // the total amount of screen colour as they will take 1499 // the total amount of screen colour as they will take
1496 // neighbouring pixel colours and apply them to the one currently 1500 // neighbouring pixel colours and apply them to the one currently
1497 // processed. 1501 // processed.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1560 float allWeightSum = centerWeight + fourWeightSum; 1564 float allWeightSum = centerWeight + fourWeightSum;
1561 1565
1562 vec4 color = vec4(0, 0, 0, 0); 1566 vec4 color = vec4(0, 0, 0, 0);
1563 if (fromLeftWeight > 0.0) { 1567 if (fromLeftWeight > 0.0) {
1564 vec3 pixelL = texelFetchOffset(g_screenTexture, screenPosI.xy, 0, 1568 vec3 pixelL = texelFetchOffset(g_screenTexture, screenPosI.xy, 0,
1565 ivec2(-1, 0)).rgb; 1569 ivec2(-1, 0)).rgb;
1566 color.rgb += fromLeftWeight * pixelL; 1570 color.rgb += fromLeftWeight * pixelL;
1567 } 1571 }
1568 if (fromAboveWeight > 0.0) { 1572 if (fromAboveWeight > 0.0) {
1569 vec3 pixelT = texelFetchOffset(g_screenTexture, screenPosI.xy, 0, 1573 vec3 pixelT = texelFetchOffset(g_screenTexture, screenPosI.xy, 0,
1570 ivec2(0, -1)).rgb; 1574 ivec2(0, 1)).rgb;
1571 color.rgb += fromAboveWeight * pixelT; 1575 color.rgb += fromAboveWeight * pixelT;
1572 } 1576 }
1573 if (fromRightWeight > 0.0) { 1577 if (fromRightWeight > 0.0) {
1574 vec3 pixelR = texelFetchOffset(g_screenTexture, screenPosI.xy, 0, 1578 vec3 pixelR = texelFetchOffset(g_screenTexture, screenPosI.xy, 0,
1575 ivec2(1, 0)).rgb; 1579 ivec2(1, 0)).rgb;
1576 color.rgb += fromRightWeight * pixelR; 1580 color.rgb += fromRightWeight * pixelR;
1577 } 1581 }
1578 if (fromBelowWeight > 0.0) { 1582 if (fromBelowWeight > 0.0) {
1579 vec3 pixelB = texelFetchOffset(g_screenTexture, screenPosI.xy, 0, 1583 vec3 pixelB = texelFetchOffset(g_screenTexture, screenPosI.xy, 0,
1580 ivec2(0, 1)).rgb; 1584 ivec2(0, -1)).rgb;
1581 color.rgb += fromBelowWeight * pixelB; 1585 color.rgb += fromBelowWeight * pixelB;
1582 } 1586 }
1583 1587
1584 color /= fourWeightSum + 0.0001; 1588 color /= fourWeightSum + 0.0001;
1585 color.a = 1.0 - centerWeight / allWeightSum; 1589 color.a = 1.0 - centerWeight / allWeightSum;
1586 1590
1587 color.rgb = mix(pixelC.rgb, color.rgb, color.a).rgb; 1591 color.rgb = mix(pixelC.rgb, color.rgb, color.a).rgb;
1588 \n#ifdef IN_GAMMA_CORRECT_MODE\n 1592 \n#ifdef IN_GAMMA_CORRECT_MODE\n
1589 color.rgb = D3DX_FLOAT3_to_SRGB(color.rgb); 1593 color.rgb = D3DX_FLOAT3_to_SRGB(color.rgb);
1590 \n#endif\n 1594 \n#endif\n
1591 1595
1592 \n#ifdef DEBUG_OUTPUT_AAINFO\n 1596 \n#ifdef DEBUG_OUTPUT_AAINFO\n
1593 imageStore(g_resultTextureSlot2, screenPosI.xy, 1597 imageStore(g_resultTextureSlot2, screenPosI.xy,
1594 PackBlurAAInfo(screenPosI.xy, uint(numberOfEdges))); 1598 PackBlurAAInfo(screenPosI.xy, uint(numberOfEdges)));
1595 \n#endif\n 1599 \n#endif\n
1596 imageStore(g_resultTextureFlt4Slot1, screenPosI.xy, 1600 imageStore(g_resultTextureFlt4Slot1, screenPosI.xy,
1597 vec4(color.rgb, pixelC.a)); 1601 vec4(color.rgb, pixelC.a));
1598 1602
1599 if (numberOfEdges == 2.0) { 1603 if (numberOfEdges == 2.0) {
1600 uint packedEdgesL = packedEdgesArray[(0 + _x) * 4 + (1 + _y)]; 1604 uint packedEdgesL = packedEdgesArray[(0 + _x) * 4 + (1 + _y)];
1601 uint packedEdgesT = packedEdgesArray[(1 + _x) * 4 + (0 + _y)]; 1605 uint packedEdgesB = packedEdgesArray[(1 + _x) * 4 + (0 + _y)];
1602 uint packedEdgesR = packedEdgesArray[(2 + _x) * 4 + (1 + _y)]; 1606 uint packedEdgesR = packedEdgesArray[(2 + _x) * 4 + (1 + _y)];
1603 uint packedEdgesB = packedEdgesArray[(1 + _x) * 4 + (2 + _y)]; 1607 uint packedEdgesT = packedEdgesArray[(1 + _x) * 4 + (2 + _y)];
1604 1608
1605 bool isHorizontalA = ((packedEdgesC) == (0x01u | 0x02u)) && 1609 bool isHorizontalA = ((packedEdgesC) == (0x01u | 0x02u)) &&
1606 ((packedEdgesR & (0x01u | 0x08u)) == (0x08u)); 1610 ((packedEdgesR & 0x08u) == 0x08u);
1607 bool isHorizontalB = ((packedEdgesC) == (0x01u | 0x08u)) && 1611 bool isHorizontalB = ((packedEdgesC) == (0x01u | 0x08u)) &&
1608 ((packedEdgesR & (0x01u | 0x02u)) == (0x02u)); 1612 ((packedEdgesR & 0x02u) == 0x02u);
1609 1613
1610 bool isHCandidate = isHorizontalA || isHorizontalB; 1614 bool isHCandidate = isHorizontalA || isHorizontalB;
1611 1615
1612 bool isVerticalA = ((packedEdgesC) == (0x08u | 0x01u)) && 1616 bool isVerticalA = ((packedEdgesC) == (0x02u | 0x04u)) &&
1613 ((packedEdgesT & (0x08u | 0x04u)) == (0x04u)); 1617 ((packedEdgesT & 0x01u) == 0x01u);
1614 bool isVerticalB = ((packedEdgesC) == (0x08u | 0x04u)) && 1618 bool isVerticalB = ((packedEdgesC) == (0x01u | 0x02u)) &&
1615 ((packedEdgesT & (0x08u | 0x01u)) == (0x01u)); 1619 ((packedEdgesT & 0x04u) == 0x04u);
1616 bool isVCandidate = isVerticalA || isVerticalB; 1620 bool isVCandidate = isVerticalA || isVerticalB;
1617 1621
1618 bool isCandidate = isHCandidate || isVCandidate; 1622 bool isCandidate = isHCandidate || isVCandidate;
1619 1623
1620 if (!isCandidate) 1624 if (!isCandidate)
1621 continue; 1625 continue;
1622 1626
1623 bool horizontal = isHCandidate; 1627 bool horizontal = isHCandidate;
1624 1628
1625 // what if both are candidates? do additional pruning (still not 1629 // what if both are candidates? do additional pruning (still not
1626 // 100% but gets rid of worst case errors) 1630 // 100% but gets rid of worst case errors)
1627 if (isHCandidate && isVCandidate) 1631 if (isHCandidate && isVCandidate)
1628 horizontal = 1632 horizontal =
1629 (isHorizontalA && ((packedEdgesL & 0x02u) == 0x02u)) || 1633 (isHorizontalA && ((packedEdgesL & 0x02u) == 0x02u)) ||
1630 (isHorizontalB && ((packedEdgesL & 0x08u) == 0x08u)); 1634 (isHorizontalB && ((packedEdgesL & 0x08u) == 0x08u));
1631 1635
1632 ivec2 offsetC; 1636 ivec2 offsetC;
1633 uint packedEdgesM1P0; 1637 uint packedEdgesM1P0;
1634 uint packedEdgesP1P0; 1638 uint packedEdgesP1P0;
1635 if (horizontal) { 1639 if (horizontal) {
1636 packedEdgesM1P0 = packedEdgesL; 1640 packedEdgesM1P0 = packedEdgesL;
1637 packedEdgesP1P0 = packedEdgesR; 1641 packedEdgesP1P0 = packedEdgesR;
1638 offsetC = ivec2(2, 0); 1642 offsetC = ivec2(2, 0);
1639 } else { 1643 } else {
1640 packedEdgesM1P0 = packedEdgesB; 1644 packedEdgesM1P0 = packedEdgesB;
1641 packedEdgesP1P0 = packedEdgesT; 1645 packedEdgesP1P0 = packedEdgesT;
1642 offsetC = ivec2(0, -2); 1646 offsetC = ivec2(0, 2);
1643 } 1647 }
1644 1648
1645 uvec4 edgesM1P0 = UnpackEdge(packedEdgesM1P0); 1649 uvec4 edgesM1P0 = UnpackEdge(packedEdgesM1P0);
1646 uvec4 edgesP1P0 = UnpackEdge(packedEdgesP1P0); 1650 uvec4 edgesP1P0 = UnpackEdge(packedEdgesP1P0);
1647 uvec4 edgesP2P0 = UnpackEdge(uint(texelFetch( 1651 uvec4 edgesP2P0 = UnpackEdge(uint(texelFetch(
1648 g_src0TextureFlt, screenPosI.xy + offsetC, 0).r * 255.5)); 1652 g_src0TextureFlt, screenPosI.xy + offsetC, 0).r * 255.5));
1649 1653
1650 uvec4 arg0; 1654 uvec4 arg0;
1651 uvec4 arg1; 1655 uvec4 arg1;
1652 uvec4 arg2; 1656 uvec4 arg2;
1653 uvec4 arg3; 1657 uvec4 arg3;
1654 bool arg4; 1658 bool arg4;
1655 1659
1656 if (horizontal) { 1660 if (horizontal) {
1657 arg0 = uvec4(edges); 1661 arg0 = uvec4(edges);
1658 arg1 = edgesM1P0; 1662 arg1 = edgesM1P0;
1659 arg2 = edgesP1P0; 1663 arg2 = edgesP1P0;
1660 arg3 = edgesP2P0; 1664 arg3 = edgesP2P0;
1661 arg4 = true; 1665 arg4 = true;
1662 } else { 1666 } else {
1663 // Reuse the same code for vertical (used for horizontal above) 1667 // Reuse the same code for vertical (used for horizontal above)
1664 // but rotate input data 90º counter-clockwise, so that: 1668 // but rotate input data 90º counter-clockwise. See FindLineLength()
1665 // left becomes bottom 1669 // e.g. arg0.r (new top) must be mapped to edges.g (old top)
1666 // top becomes left 1670 arg0 = uvec4(edges.gbar);
1667 // right becomes top 1671 arg1 = edgesM1P0.gbar;
1668 // bottom becomes right 1672 arg2 = edgesP1P0.gbar;
1669 1673 arg3 = edgesP2P0.gbar;
1670 // we also have to rotate edges, thus .argb
1671 arg0 = uvec4(edges.argb);
1672 arg1 = edgesM1P0.argb;
1673 arg2 = edgesP1P0.argb;
1674 arg3 = edgesP2P0.argb;
1675 arg4 = false; 1674 arg4 = false;
1676 } 1675 }
1677 1676
1678 { 1677 {
1679 ivec2 screenPos = screenPosI.xy; 1678 ivec2 screenPos = screenPosI.xy;
1680 uvec4 _edges = arg0; 1679 uvec4 _edges = arg0;
1681 uvec4 _edgesM1P0 = arg1; 1680 uvec4 _edgesM1P0 = arg1;
1682 uvec4 _edgesP1P0 = arg2; 1681 uvec4 _edgesP1P0 = arg2;
1683 uvec4 _edgesP2P0 = arg3; 1682 uvec4 _edgesP2P0 = arg3;
1684 bool horizontal = arg4; 1683 bool horizontal = arg4;
1685 // Inverted Z case: 1684
1686 // __ 1685 // Normal Z case:
1686 // __
1687 // X| 1687 // X|
1688 // ¯¯ 1688 // ¯¯
1689 bool isInvertedZ = false; 1689 bool isInvertedZ = false;
1690 bool isNormalZ = false; 1690 bool isNormalZ = false;
1691 { 1691 {
1692 \n#ifndef SETTINGS_ALLOW_SHORT_Zs\n 1692 \n#ifndef SETTINGS_ALLOW_SHORT_Zs\n
1693 // (1u-_edges.a) constraint can be removed; it was added for 1693 // (1u-_edges.a) constraint can be removed; it was added for
1694 // some rare cases 1694 // some rare cases
1695 uint isZShape = _edges.r * _edges.g * _edgesM1P0.g * 1695 uint isZShape = _edges.r * _edges.g * _edgesM1P0.g *
1696 _edgesP1P0.a *_edgesP2P0.a * (1u - _edges.b) * 1696 _edgesP1P0.a *_edgesP2P0.a * (1u - _edges.b) *
1697 (1u - _edgesP1P0.r) * (1u - _edges.a) * 1697 (1u - _edgesP1P0.r) * (1u - _edges.a) *
1698 (1u - _edgesP1P0.g); 1698 (1u - _edgesP1P0.g);
1699 \n#else\n 1699 \n#else\n
1700 uint isZShape = _edges.r * _edges.g * _edgesP1P0.a * 1700 uint isZShape = _edges.r * _edges.g * _edgesP1P0.a *
1701 (1u - _edges.b) * (1u - _edgesP1P0.r) * (1u - _edges.a) * 1701 (1u - _edges.b) * (1u - _edgesP1P0.r) * (1u - _edges.a) *
1702 (1u - _edgesP1P0.g); 1702 (1u - _edgesP1P0.g);
1703 isZShape *= (_edgesM1P0.g + _edgesP2P0.a); 1703 isZShape *= (_edgesM1P0.g + _edgesP2P0.a);
1704 // and at least one of these need to be there 1704 // and at least one of these need to be there
1705 \n#endif\n 1705 \n#endif\n
1706 if (isZShape > 0u) { 1706 if (isZShape > 0u) {
1707 isInvertedZ = true; 1707 isNormalZ = true;
1708 } 1708 }
1709 } 1709 }
1710 1710
1711 // Normal Z case: 1711 // Inverted Z case:
1712 // __ 1712 // __
1713 // X| 1713 // X|
1714 // ¯¯ 1714 // ¯¯
1715 { 1715 {
1716 \n#ifndef SETTINGS_ALLOW_SHORT_Zs\n 1716 \n#ifndef SETTINGS_ALLOW_SHORT_Zs\n
1717 uint isZShape = _edges.r * _edges.a * _edgesM1P0.a * 1717 uint isZShape = _edges.r * _edges.a * _edgesM1P0.a *
1718 _edgesP1P0.g * _edgesP2P0.g * (1u - _edges.b) * 1718 _edgesP1P0.g * _edgesP2P0.g * (1u - _edges.b) *
1719 (1u - _edgesP1P0.r) * (1u - _edges.g) * 1719 (1u - _edgesP1P0.r) * (1u - _edges.g) *
1720 (1u - _edgesP1P0.a); 1720 (1u - _edgesP1P0.a);
1721 \n#else\n 1721 \n#else\n
1722 uint isZShape = _edges.r * _edges.a * _edgesP1P0.g * 1722 uint isZShape = _edges.r * _edges.a * _edgesP1P0.g *
1723 (1u - _edges.b) * (1u - _edgesP1P0.r) * (1u - _edges.g) * 1723 (1u - _edges.b) * (1u - _edgesP1P0.r) * (1u - _edges.g) *
1724 (1u - _edgesP1P0.a); 1724 (1u - _edgesP1P0.a);
1725 isZShape *= 1725 isZShape *=
1726 (_edgesM1P0.a + _edgesP2P0.g); 1726 (_edgesM1P0.a + _edgesP2P0.g);
1727 // and at least one of these need to be there 1727 // and at least one of these need to be there
1728 \n#endif\n 1728 \n#endif\n
1729 1729
1730 if (isZShape > 0u) { 1730 if (isZShape > 0u) {
1731 isNormalZ = true; 1731 isInvertedZ = true;
1732 } 1732 }
1733 } 1733 }
1734 1734
1735 bool isZ = isInvertedZ || isNormalZ; 1735 bool isZ = isInvertedZ || isNormalZ;
1736 if (isZ) { 1736 if (isZ) {
1737 forFollowUpCoords[forFollowUpCount++] = 1737 forFollowUpCoords[forFollowUpCount++] =
1738 ivec4(screenPosI.xy, horizontal, isInvertedZ); 1738 ivec4(screenPosI.xy, horizontal, isInvertedZ);
1739 } 1739 }
1740 } 1740 }
1741 } 1741 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1828 \n#ifdef OUT_FBO\n 1828 \n#ifdef OUT_FBO\n
1829 outColor = pixel; 1829 outColor = pixel;
1830 \n#else\n 1830 \n#else\n
1831 imageStore(outTexture, screenPosI, pixel); 1831 imageStore(outTexture, screenPosI, pixel);
1832 \n#endif\n 1832 \n#endif\n
1833 } 1833 }
1834 ); 1834 );
1835 /* clang-format on */ 1835 /* clang-format on */
1836 1836
1837 } // namespace gpu 1837 } // 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