comparison libvo/gl_common.c @ 30840:e159f9aa13a2

Add newlines to generated fragment program to make both fragment program dump with -v more readable and compiler error message more understandable.
author reimar
date Fri, 12 Mar 2010 17:21:05 +0000
parents 6eb012e46b63
children 55917a674d7d
comparison
equal deleted inserted replaced
30839:d50e20b4e441 30840:e159f9aa13a2
853 ActiveTexture(GL_TEXTURE0); 853 ActiveTexture(GL_TEXTURE0);
854 free(tex); 854 free(tex);
855 } 855 }
856 856
857 static const char *bilin_filt_template = 857 static const char *bilin_filt_template =
858 "TEX yuv.%c, fragment.texcoord[%c], texture[%c], %s;"; 858 "TEX yuv.%c, fragment.texcoord[%c], texture[%c], %s;\n";
859 859
860 #define BICUB_FILT_MAIN(textype) \ 860 #define BICUB_FILT_MAIN(textype) \
861 /* first y-interpolation */ \ 861 /* first y-interpolation */ \
862 "ADD coord, fragment.texcoord[%c].xyxy, cdelta.xyxw;" \ 862 "ADD coord, fragment.texcoord[%c].xyxy, cdelta.xyxw;\n" \
863 "ADD coord2, fragment.texcoord[%c].xyxy, cdelta.zyzw;" \ 863 "ADD coord2, fragment.texcoord[%c].xyxy, cdelta.zyzw;\n" \
864 "TEX a.r, coord.xyxy, texture[%c], "textype";" \ 864 "TEX a.r, coord.xyxy, texture[%c], "textype";\n" \
865 "TEX a.g, coord.zwzw, texture[%c], "textype";" \ 865 "TEX a.g, coord.zwzw, texture[%c], "textype";\n" \
866 /* second y-interpolation */ \ 866 /* second y-interpolation */ \
867 "TEX b.r, coord2.xyxy, texture[%c], "textype";" \ 867 "TEX b.r, coord2.xyxy, texture[%c], "textype";\n" \
868 "TEX b.g, coord2.zwzw, texture[%c], "textype";" \ 868 "TEX b.g, coord2.zwzw, texture[%c], "textype";\n" \
869 "LRP a.b, parmy.b, a.rrrr, a.gggg;" \ 869 "LRP a.b, parmy.b, a.rrrr, a.gggg;\n" \
870 "LRP a.a, parmy.b, b.rrrr, b.gggg;" \ 870 "LRP a.a, parmy.b, b.rrrr, b.gggg;\n" \
871 /* x-interpolation */ \ 871 /* x-interpolation */ \
872 "LRP yuv.%c, parmx.b, a.bbbb, a.aaaa;" 872 "LRP yuv.%c, parmx.b, a.bbbb, a.aaaa;\n"
873 873
874 static const char *bicub_filt_template_2D = 874 static const char *bicub_filt_template_2D =
875 "MAD coord.xy, fragment.texcoord[%c], {%e, %e}, {0.5, 0.5};" 875 "MAD coord.xy, fragment.texcoord[%c], {%e, %e}, {0.5, 0.5};\n"
876 "TEX parmx, coord.x, texture[%c], 1D;" 876 "TEX parmx, coord.x, texture[%c], 1D;\n"
877 "MUL cdelta.xz, parmx.rrgg, {-%e, 0, %e, 0};" 877 "MUL cdelta.xz, parmx.rrgg, {-%e, 0, %e, 0};\n"
878 "TEX parmy, coord.y, texture[%c], 1D;" 878 "TEX parmy, coord.y, texture[%c], 1D;\n"
879 "MUL cdelta.yw, parmy.rrgg, {0, -%e, 0, %e};" 879 "MUL cdelta.yw, parmy.rrgg, {0, -%e, 0, %e};\n"
880 BICUB_FILT_MAIN("2D"); 880 BICUB_FILT_MAIN("2D");
881 881
882 static const char *bicub_filt_template_RECT = 882 static const char *bicub_filt_template_RECT =
883 "ADD coord, fragment.texcoord[%c], {0.5, 0.5};" 883 "ADD coord, fragment.texcoord[%c], {0.5, 0.5};\n"
884 "TEX parmx, coord.x, texture[%c], 1D;" 884 "TEX parmx, coord.x, texture[%c], 1D;\n"
885 "MUL cdelta.xz, parmx.rrgg, {-1, 0, 1, 0};" 885 "MUL cdelta.xz, parmx.rrgg, {-1, 0, 1, 0};\n"
886 "TEX parmy, coord.y, texture[%c], 1D;" 886 "TEX parmy, coord.y, texture[%c], 1D;\n"
887 "MUL cdelta.yw, parmy.rrgg, {0, -1, 0, 1};" 887 "MUL cdelta.yw, parmy.rrgg, {0, -1, 0, 1};\n"
888 BICUB_FILT_MAIN("RECT"); 888 BICUB_FILT_MAIN("RECT");
889 889
890 #define CALCWEIGHTS(t, s) \ 890 #define CALCWEIGHTS(t, s) \
891 "MAD "t", {-0.5, 0.1666, 0.3333, -0.3333}, "s", {1, 0, -0.5, 0.5};" \ 891 "MAD "t", {-0.5, 0.1666, 0.3333, -0.3333}, "s", {1, 0, -0.5, 0.5};\n" \
892 "MAD "t", "t", "s", {0, 0, -0.5, 0.5};" \ 892 "MAD "t", "t", "s", {0, 0, -0.5, 0.5};\n" \
893 "MAD "t", "t", "s", {-0.6666, 0, 0.8333, 0.1666};" \ 893 "MAD "t", "t", "s", {-0.6666, 0, 0.8333, 0.1666};\n" \
894 "RCP a.x, "t".z;" \ 894 "RCP a.x, "t".z;\n" \
895 "RCP a.y, "t".w;" \ 895 "RCP a.y, "t".w;\n" \
896 "MAD "t".xy, "t".xyxy, a.xyxy, {1, 1, 0, 0};" \ 896 "MAD "t".xy, "t".xyxy, a.xyxy, {1, 1, 0, 0};\n" \
897 "ADD "t".x, "t".xxxx, "s";" \ 897 "ADD "t".x, "t".xxxx, "s";\n" \
898 "SUB "t".y, "t".yyyy, "s";" 898 "SUB "t".y, "t".yyyy, "s";\n"
899 899
900 static const char *bicub_notex_filt_template_2D = 900 static const char *bicub_notex_filt_template_2D =
901 "MAD coord.xy, fragment.texcoord[%c], {%e, %e}, {0.5, 0.5};" 901 "MAD coord.xy, fragment.texcoord[%c], {%e, %e}, {0.5, 0.5};\n"
902 "FRC coord.xy, coord.xyxy;" 902 "FRC coord.xy, coord.xyxy;\n"
903 CALCWEIGHTS("parmx", "coord.xxxx") 903 CALCWEIGHTS("parmx", "coord.xxxx")
904 "MUL cdelta.xz, parmx.rrgg, {-%e, 0, %e, 0};" 904 "MUL cdelta.xz, parmx.rrgg, {-%e, 0, %e, 0};\n"
905 CALCWEIGHTS("parmy", "coord.yyyy") 905 CALCWEIGHTS("parmy", "coord.yyyy")
906 "MUL cdelta.yw, parmy.rrgg, {0, -%e, 0, %e};" 906 "MUL cdelta.yw, parmy.rrgg, {0, -%e, 0, %e};\n"
907 BICUB_FILT_MAIN("2D"); 907 BICUB_FILT_MAIN("2D");
908 908
909 static const char *bicub_notex_filt_template_RECT = 909 static const char *bicub_notex_filt_template_RECT =
910 "ADD coord, fragment.texcoord[%c], {0.5, 0.5};" 910 "ADD coord, fragment.texcoord[%c], {0.5, 0.5};\n"
911 "FRC coord.xy, coord.xyxy;" 911 "FRC coord.xy, coord.xyxy;\n"
912 CALCWEIGHTS("parmx", "coord.xxxx") 912 CALCWEIGHTS("parmx", "coord.xxxx")
913 "MUL cdelta.xz, parmx.rrgg, {-1, 0, 1, 0};" 913 "MUL cdelta.xz, parmx.rrgg, {-1, 0, 1, 0};\n"
914 CALCWEIGHTS("parmy", "coord.yyyy") 914 CALCWEIGHTS("parmy", "coord.yyyy")
915 "MUL cdelta.yw, parmy.rrgg, {0, -1, 0, 1};" 915 "MUL cdelta.yw, parmy.rrgg, {0, -1, 0, 1};\n"
916 BICUB_FILT_MAIN("RECT"); 916 BICUB_FILT_MAIN("RECT");
917 917
918 #define BICUB_X_FILT_MAIN(textype) \ 918 #define BICUB_X_FILT_MAIN(textype) \
919 "ADD coord.xy, fragment.texcoord[%c].xyxy, cdelta.xyxy;" \ 919 "ADD coord.xy, fragment.texcoord[%c].xyxy, cdelta.xyxy;\n" \
920 "ADD coord2.xy, fragment.texcoord[%c].xyxy, cdelta.zyzy;" \ 920 "ADD coord2.xy, fragment.texcoord[%c].xyxy, cdelta.zyzy;\n" \
921 "TEX a.r, coord, texture[%c], "textype";" \ 921 "TEX a.r, coord, texture[%c], "textype";\n" \
922 "TEX b.r, coord2, texture[%c], "textype";" \ 922 "TEX b.r, coord2, texture[%c], "textype";\n" \
923 /* x-interpolation */ \ 923 /* x-interpolation */ \
924 "LRP yuv.%c, parmx.b, a.rrrr, b.rrrr;" 924 "LRP yuv.%c, parmx.b, a.rrrr, b.rrrr;\n"
925 925
926 static const char *bicub_x_filt_template_2D = 926 static const char *bicub_x_filt_template_2D =
927 "MAD coord.x, fragment.texcoord[%c], {%e}, {0.5};" 927 "MAD coord.x, fragment.texcoord[%c], {%e}, {0.5};\n"
928 "TEX parmx, coord, texture[%c], 1D;" 928 "TEX parmx, coord, texture[%c], 1D;\n"
929 "MUL cdelta.xyz, parmx.rrgg, {-%e, 0, %e};" 929 "MUL cdelta.xyz, parmx.rrgg, {-%e, 0, %e};\n"
930 BICUB_X_FILT_MAIN("2D"); 930 BICUB_X_FILT_MAIN("2D");
931 931
932 static const char *bicub_x_filt_template_RECT = 932 static const char *bicub_x_filt_template_RECT =
933 "ADD coord.x, fragment.texcoord[%c], {0.5};" 933 "ADD coord.x, fragment.texcoord[%c], {0.5};\n"
934 "TEX parmx, coord, texture[%c], 1D;" 934 "TEX parmx, coord, texture[%c], 1D;\n"
935 "MUL cdelta.xyz, parmx.rrgg, {-1, 0, 1};" 935 "MUL cdelta.xyz, parmx.rrgg, {-1, 0, 1};\n"
936 BICUB_X_FILT_MAIN("RECT"); 936 BICUB_X_FILT_MAIN("RECT");
937 937
938 static const char *unsharp_filt_template = 938 static const char *unsharp_filt_template =
939 "PARAM dcoord%c = {%e, %e, %e, %e};" 939 "PARAM dcoord%c = {%e, %e, %e, %e};\n"
940 "ADD coord, fragment.texcoord[%c].xyxy, dcoord%c;" 940 "ADD coord, fragment.texcoord[%c].xyxy, dcoord%c;\n"
941 "SUB coord2, fragment.texcoord[%c].xyxy, dcoord%c;" 941 "SUB coord2, fragment.texcoord[%c].xyxy, dcoord%c;\n"
942 "TEX a.r, fragment.texcoord[%c], texture[%c], %s;" 942 "TEX a.r, fragment.texcoord[%c], texture[%c], %s;\n"
943 "TEX b.r, coord.xyxy, texture[%c], %s;" 943 "TEX b.r, coord.xyxy, texture[%c], %s;\n"
944 "TEX b.g, coord.zwzw, texture[%c], %s;" 944 "TEX b.g, coord.zwzw, texture[%c], %s;\n"
945 "ADD b.r, b.r, b.g;" 945 "ADD b.r, b.r, b.g;\n"
946 "TEX b.b, coord2.xyxy, texture[%c], %s;" 946 "TEX b.b, coord2.xyxy, texture[%c], %s;\n"
947 "TEX b.g, coord2.zwzw, texture[%c], %s;" 947 "TEX b.g, coord2.zwzw, texture[%c], %s;\n"
948 "DP3 b, b, {0.25, 0.25, 0.25};" 948 "DP3 b, b, {0.25, 0.25, 0.25};\n"
949 "SUB b.r, a.r, b.r;" 949 "SUB b.r, a.r, b.r;\n"
950 "MAD yuv.%c, b.r, {%e}, a.r;"; 950 "MAD yuv.%c, b.r, {%e}, a.r;\n";
951 951
952 static const char *unsharp_filt_template2 = 952 static const char *unsharp_filt_template2 =
953 "PARAM dcoord%c = {%e, %e, %e, %e};" 953 "PARAM dcoord%c = {%e, %e, %e, %e};\n"
954 "PARAM dcoord2%c = {%e, 0, 0, %e};" 954 "PARAM dcoord2%c = {%e, 0, 0, %e};\n"
955 "ADD coord, fragment.texcoord[%c].xyxy, dcoord%c;" 955 "ADD coord, fragment.texcoord[%c].xyxy, dcoord%c;\n"
956 "SUB coord2, fragment.texcoord[%c].xyxy, dcoord%c;" 956 "SUB coord2, fragment.texcoord[%c].xyxy, dcoord%c;\n"
957 "TEX a.r, fragment.texcoord[%c], texture[%c], %s;" 957 "TEX a.r, fragment.texcoord[%c], texture[%c], %s;\n"
958 "TEX b.r, coord.xyxy, texture[%c], %s;" 958 "TEX b.r, coord.xyxy, texture[%c], %s;\n"
959 "TEX b.g, coord.zwzw, texture[%c], %s;" 959 "TEX b.g, coord.zwzw, texture[%c], %s;\n"
960 "ADD b.r, b.r, b.g;" 960 "ADD b.r, b.r, b.g;\n"
961 "TEX b.b, coord2.xyxy, texture[%c], %s;" 961 "TEX b.b, coord2.xyxy, texture[%c], %s;\n"
962 "TEX b.g, coord2.zwzw, texture[%c], %s;" 962 "TEX b.g, coord2.zwzw, texture[%c], %s;\n"
963 "ADD b.r, b.r, b.b;" 963 "ADD b.r, b.r, b.b;\n"
964 "ADD b.a, b.r, b.g;" 964 "ADD b.a, b.r, b.g;\n"
965 "ADD coord, fragment.texcoord[%c].xyxy, dcoord2%c;" 965 "ADD coord, fragment.texcoord[%c].xyxy, dcoord2%c;\n"
966 "SUB coord2, fragment.texcoord[%c].xyxy, dcoord2%c;" 966 "SUB coord2, fragment.texcoord[%c].xyxy, dcoord2%c;\n"
967 "TEX b.r, coord.xyxy, texture[%c], %s;" 967 "TEX b.r, coord.xyxy, texture[%c], %s;\n"
968 "TEX b.g, coord.zwzw, texture[%c], %s;" 968 "TEX b.g, coord.zwzw, texture[%c], %s;\n"
969 "ADD b.r, b.r, b.g;" 969 "ADD b.r, b.r, b.g;\n"
970 "TEX b.b, coord2.xyxy, texture[%c], %s;" 970 "TEX b.b, coord2.xyxy, texture[%c], %s;\n"
971 "TEX b.g, coord2.zwzw, texture[%c], %s;" 971 "TEX b.g, coord2.zwzw, texture[%c], %s;\n"
972 "DP4 b.r, b, {-0.1171875, -0.1171875, -0.1171875, -0.09765625};" 972 "DP4 b.r, b, {-0.1171875, -0.1171875, -0.1171875, -0.09765625};\n"
973 "MAD b.r, a.r, {0.859375}, b.r;" 973 "MAD b.r, a.r, {0.859375}, b.r;\n"
974 "MAD yuv.%c, b.r, {%e}, a.r;"; 974 "MAD yuv.%c, b.r, {%e}, a.r;\n";
975 975
976 static const char *yuv_prog_template = 976 static const char *yuv_prog_template =
977 "PARAM ycoef = {%e, %e, %e};" 977 "PARAM ycoef = {%e, %e, %e};\n"
978 "PARAM ucoef = {%e, %e, %e};" 978 "PARAM ucoef = {%e, %e, %e};\n"
979 "PARAM vcoef = {%e, %e, %e};" 979 "PARAM vcoef = {%e, %e, %e};\n"
980 "PARAM offsets = {%e, %e, %e};" 980 "PARAM offsets = {%e, %e, %e};\n"
981 "TEMP res;" 981 "TEMP res;\n"
982 "MAD res.rgb, yuv.rrrr, ycoef, offsets;" 982 "MAD res.rgb, yuv.rrrr, ycoef, offsets;\n"
983 "MAD res.rgb, yuv.gggg, ucoef, res;" 983 "MAD res.rgb, yuv.gggg, ucoef, res;\n"
984 "MAD result.color.rgb, yuv.bbbb, vcoef, res;" 984 "MAD result.color.rgb, yuv.bbbb, vcoef, res;\n"
985 "END"; 985 "END";
986 986
987 static const char *yuv_pow_prog_template = 987 static const char *yuv_pow_prog_template =
988 "PARAM ycoef = {%e, %e, %e};" 988 "PARAM ycoef = {%e, %e, %e};\n"
989 "PARAM ucoef = {%e, %e, %e};" 989 "PARAM ucoef = {%e, %e, %e};\n"
990 "PARAM vcoef = {%e, %e, %e};" 990 "PARAM vcoef = {%e, %e, %e};\n"
991 "PARAM offsets = {%e, %e, %e};" 991 "PARAM offsets = {%e, %e, %e};\n"
992 "PARAM gamma = {%e, %e, %e};" 992 "PARAM gamma = {%e, %e, %e};\n"
993 "TEMP res;" 993 "TEMP res;\n"
994 "MAD res.rgb, yuv.rrrr, ycoef, offsets;" 994 "MAD res.rgb, yuv.rrrr, ycoef, offsets;\n"
995 "MAD res.rgb, yuv.gggg, ucoef, res;" 995 "MAD res.rgb, yuv.gggg, ucoef, res;\n"
996 "MAD_SAT res.rgb, yuv.bbbb, vcoef, res;" 996 "MAD_SAT res.rgb, yuv.bbbb, vcoef, res;\n"
997 "POW result.color.r, res.r, gamma.r;" 997 "POW result.color.r, res.r, gamma.r;\n"
998 "POW result.color.g, res.g, gamma.g;" 998 "POW result.color.g, res.g, gamma.g;\n"
999 "POW result.color.b, res.b, gamma.b;" 999 "POW result.color.b, res.b, gamma.b;\n"
1000 "END"; 1000 "END";
1001 1001
1002 static const char *yuv_lookup_prog_template = 1002 static const char *yuv_lookup_prog_template =
1003 "PARAM ycoef = {%e, %e, %e, 0};" 1003 "PARAM ycoef = {%e, %e, %e, 0};\n"
1004 "PARAM ucoef = {%e, %e, %e, 0};" 1004 "PARAM ucoef = {%e, %e, %e, 0};\n"
1005 "PARAM vcoef = {%e, %e, %e, 0};" 1005 "PARAM vcoef = {%e, %e, %e, 0};\n"
1006 "PARAM offsets = {%e, %e, %e, 0.125};" 1006 "PARAM offsets = {%e, %e, %e, 0.125};\n"
1007 "TEMP res;" 1007 "TEMP res;\n"
1008 "MAD res, yuv.rrrr, ycoef, offsets;" 1008 "MAD res, yuv.rrrr, ycoef, offsets;\n"
1009 "MAD res.rgb, yuv.gggg, ucoef, res;" 1009 "MAD res.rgb, yuv.gggg, ucoef, res;\n"
1010 "MAD res.rgb, yuv.bbbb, vcoef, res;" 1010 "MAD res.rgb, yuv.bbbb, vcoef, res;\n"
1011 "TEX result.color.r, res.raaa, texture[%c], 2D;" 1011 "TEX result.color.r, res.raaa, texture[%c], 2D;\n"
1012 "ADD res.a, res.a, 0.25;" 1012 "ADD res.a, res.a, 0.25;\n"
1013 "TEX result.color.g, res.gaaa, texture[%c], 2D;" 1013 "TEX result.color.g, res.gaaa, texture[%c], 2D;\n"
1014 "ADD res.a, res.a, 0.25;" 1014 "ADD res.a, res.a, 0.25;\n"
1015 "TEX result.color.b, res.baaa, texture[%c], 2D;" 1015 "TEX result.color.b, res.baaa, texture[%c], 2D;\n"
1016 "END"; 1016 "END";
1017 1017
1018 static const char *yuv_lookup3d_prog_template = 1018 static const char *yuv_lookup3d_prog_template =
1019 "TEX result.color, yuv, texture[%c], 3D;" 1019 "TEX result.color, yuv, texture[%c], 3D;\n"
1020 "END"; 1020 "END";
1021 1021
1022 /** 1022 /**
1023 * \brief creates and initializes helper textures needed for scaling texture read 1023 * \brief creates and initializes helper textures needed for scaling texture read
1024 * \param scaler scaler type to create texture for 1024 * \param scaler scaler type to create texture for
1252 int texw = params->texw; 1252 int texw = params->texw;
1253 int texh = params->texh; 1253 int texh = params->texh;
1254 int rect = params->target == GL_TEXTURE_RECTANGLE; 1254 int rect = params->target == GL_TEXTURE_RECTANGLE;
1255 static const char prog_hdr[] = 1255 static const char prog_hdr[] =
1256 "!!ARBfp1.0\n" 1256 "!!ARBfp1.0\n"
1257 "OPTION ARB_precision_hint_fastest;" 1257 "OPTION ARB_precision_hint_fastest;\n"
1258 // all scaler variables must go here so they aren't defined 1258 // all scaler variables must go here so they aren't defined
1259 // multiple times when the same scaler is used more than once 1259 // multiple times when the same scaler is used more than once
1260 "TEMP coord, coord2, cdelta, parmx, parmy, a, b, yuv;"; 1260 "TEMP coord, coord2, cdelta, parmx, parmy, a, b, yuv;\n";
1261 int prog_remain; 1261 int prog_remain;
1262 char *yuv_prog, *prog_pos; 1262 char *yuv_prog, *prog_pos;
1263 int cur_texu = 3; 1263 int cur_texu = 3;
1264 char lum_scale_texs[1]; 1264 char lum_scale_texs[1];
1265 char chrom_scale_texs[1]; 1265 char chrom_scale_texs[1];