~ubuntu-branches/ubuntu/precise/mesa/precise-updates

« back to all changes in this revision

Viewing changes to src/mesa/vbo/vbo_attrib_tmp.h

  • Committer: Package Import Robot
  • Author(s): Robert Hooker
  • Date: 2012-02-02 12:05:48 UTC
  • mfrom: (1.7.1) (3.3.27 sid)
  • Revision ID: package-import@ubuntu.com-20120202120548-nvkma85jq0h4coix
Tags: 8.0~rc2-0ubuntu4
Drop drisearchdir handling, it is no longer needed with multiarch
and dri-alternates being removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**************************************************************************
2
2
 
3
3
Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.
4
 
 
 
4
Copyright 2011 Dave Airlie (ARB_vertex_type_2_10_10_10_rev support)
5
5
All Rights Reserved.
6
6
 
7
7
Permission is hereby granted, free of charge, to any person obtaining a
59
59
 
60
60
#define MAT_ATTR( A, N, V ) ATTR( A, N, (V)[0], (V)[1], (V)[2], (V)[3] )
61
61
 
62
 
 
 
62
static inline float conv_ui10_to_norm_float(unsigned ui10)
 
63
{
 
64
   return (float)(ui10) / 1023.0;
 
65
}
 
66
 
 
67
static inline float conv_ui2_to_norm_float(unsigned ui2)
 
68
{
 
69
   return (float)(ui2) / 3.0;
 
70
}
 
71
 
 
72
#define ATTRUI10_1( A, UI ) ATTR( A, 1, (UI) & 0x3ff, 0, 0, 1 )
 
73
#define ATTRUI10_2( A, UI ) ATTR( A, 2, (UI) & 0x3ff, ((UI) >> 10) & 0x3ff, 0, 1 )
 
74
#define ATTRUI10_3( A, UI ) ATTR( A, 3, (UI) & 0x3ff, ((UI) >> 10) & 0x3ff, ((UI) >> 20) & 0x3ff, 1 )
 
75
#define ATTRUI10_4( A, UI ) ATTR( A, 4, (UI) & 0x3ff, ((UI) >> 10) & 0x3ff, ((UI) >> 20) & 0x3ff, ((UI) >> 30) & 0x3 )
 
76
 
 
77
#define ATTRUI10N_1( A, UI ) ATTR( A, 1, conv_ui10_to_norm_float((UI) & 0x3ff), 0, 0, 1 )
 
78
#define ATTRUI10N_2( A, UI ) ATTR( A, 2, \
 
79
                                   conv_ui10_to_norm_float((UI) & 0x3ff), \
 
80
                                   conv_ui10_to_norm_float(((UI) >> 10) & 0x3ff), 0, 1 )
 
81
#define ATTRUI10N_3( A, UI ) ATTR( A, 3, \
 
82
                                   conv_ui10_to_norm_float((UI) & 0x3ff), \
 
83
                                   conv_ui10_to_norm_float(((UI) >> 10) & 0x3ff), \
 
84
                                   conv_ui10_to_norm_float(((UI) >> 20) & 0x3ff), 1 )
 
85
#define ATTRUI10N_4( A, UI ) ATTR( A, 4, \
 
86
                                   conv_ui10_to_norm_float((UI) & 0x3ff), \
 
87
                                   conv_ui10_to_norm_float(((UI) >> 10) & 0x3ff), \
 
88
                                   conv_ui10_to_norm_float(((UI) >> 20) & 0x3ff), \
 
89
                                   conv_ui2_to_norm_float(((UI) >> 30) & 0x3) )
 
90
 
 
91
struct attr_bits_10 {signed int x:10;};
 
92
struct attr_bits_2 {signed int x:2;};
 
93
 
 
94
static inline float conv_i10_to_i(int i10)
 
95
{
 
96
   struct attr_bits_10 val;
 
97
   val.x = i10;
 
98
   return (float)val.x;
 
99
}
 
100
 
 
101
static inline float conv_i2_to_i(int i2)
 
102
{
 
103
   struct attr_bits_2 val;
 
104
   val.x = i2;
 
105
   return (float)val.x;
 
106
}
 
107
 
 
108
static inline float conv_i10_to_norm_float(int i10)
 
109
{
 
110
   struct attr_bits_10 val;
 
111
   val.x = i10;
 
112
   return (2.0F * (float)val.x + 1.0F) * (1.0F  / 511.0F);
 
113
}
 
114
 
 
115
static inline float conv_i2_to_norm_float(int i2)
 
116
{
 
117
   struct attr_bits_2 val;
 
118
   val.x = i2;
 
119
   return (float)val.x;
 
120
}
 
121
 
 
122
#define ATTRI10_1( A, I10 ) ATTR( A, 1, conv_i10_to_i((I10) & 0x3ff), 0, 0, 1 )
 
123
#define ATTRI10_2( A, I10 ) ATTR( A, 2, \
 
124
                                conv_i10_to_i((I10) & 0x3ff),           \
 
125
                                conv_i10_to_i(((I10) >> 10) & 0x3ff), 0, 1 )
 
126
#define ATTRI10_3( A, I10 ) ATTR( A, 3, \
 
127
                                conv_i10_to_i((I10) & 0x3ff),       \
 
128
                                conv_i10_to_i(((I10) >> 10) & 0x3ff), \
 
129
                                conv_i10_to_i(((I10) >> 20) & 0x3ff), 1 )
 
130
#define ATTRI10_4( A, I10 ) ATTR( A, 4, \
 
131
                                conv_i10_to_i((I10) & 0x3ff),           \
 
132
                                conv_i10_to_i(((I10) >> 10) & 0x3ff), \
 
133
                                conv_i10_to_i(((I10) >> 20) & 0x3ff), \
 
134
                                conv_i2_to_i(((I10) >> 30) & 0x3))
 
135
 
 
136
 
 
137
#define ATTRI10N_1( A, I10 ) ATTR( A, 1, conv_i10_to_norm_float((I10) & 0x3ff), 0, 0, 1 )
 
138
#define ATTRI10N_2( A, I10 ) ATTR( A, 2, \
 
139
                                conv_i10_to_norm_float((I10) & 0x3ff),          \
 
140
                                conv_i10_to_norm_float(((I10) >> 10) & 0x3ff), 0, 1 )
 
141
#define ATTRI10N_3( A, I10 ) ATTR( A, 3, \
 
142
                                conv_i10_to_norm_float((I10) & 0x3ff),      \
 
143
                                conv_i10_to_norm_float(((I10) >> 10) & 0x3ff), \
 
144
                                conv_i10_to_norm_float(((I10) >> 20) & 0x3ff), 1 )
 
145
#define ATTRI10N_4( A, I10 ) ATTR( A, 4, \
 
146
                                conv_i10_to_norm_float((I10) & 0x3ff),          \
 
147
                                conv_i10_to_norm_float(((I10) >> 10) & 0x3ff), \
 
148
                                conv_i10_to_norm_float(((I10) >> 20) & 0x3ff), \
 
149
                                conv_i2_to_norm_float(((I10) >> 30) & 0x3))
 
150
 
 
151
#define ATTR_UI(val, type, normalized, attr, arg) do {          \
 
152
   if ((type) == GL_UNSIGNED_INT_2_10_10_10_REV) {              \
 
153
      if (normalized) {                                         \
 
154
         ATTRUI10N_##val((attr), (arg));                        \
 
155
      } else {                                                  \
 
156
         ATTRUI10_##val((attr), (arg));                         \
 
157
      }                                                         \
 
158
   }   else if ((type) == GL_INT_2_10_10_10_REV) {              \
 
159
      if (normalized) {                                         \
 
160
         ATTRI10N_##val((attr), (arg));                         \
 
161
      } else {                                                  \
 
162
         ATTRI10_##val((attr), (arg));                          \
 
163
      }                                                         \
 
164
   } else                                                       \
 
165
      ERROR(GL_INVALID_VALUE);                                  \
 
166
   } while(0)
 
167
 
 
168
#define ATTR_UI_INDEX(val, type, normalized, index, arg) do {   \
 
169
      if ((index) == 0) {                                       \
 
170
         ATTR_UI(val, (type), normalized, 0, (arg));                    \
 
171
      } else if ((index) < MAX_VERTEX_GENERIC_ATTRIBS) {                \
 
172
         ATTR_UI(val, (type), normalized, VBO_ATTRIB_GENERIC0 + (index), (arg)); \
 
173
      } else                                                            \
 
174
         ERROR(GL_INVALID_VALUE);                                       \
 
175
   } while(0)
63
176
 
64
177
static void GLAPIENTRY
65
178
TAG(Vertex2f)(GLfloat x, GLfloat y)
696
809
                 const GLfloat * params)
697
810
{
698
811
   GET_CURRENT_CONTEXT(ctx);
 
812
 
 
813
   if (face != GL_FRONT && face != GL_BACK && face != GL_FRONT_AND_BACK) {
 
814
      _mesa_error(ctx, GL_INVALID_ENUM, "glMaterial(invalid face)");
 
815
      return;
 
816
   }
 
817
 
699
818
   switch (pname) {
700
819
   case GL_EMISSION:
701
820
      MAT(VBO_ATTRIB_MAT_FRONT_EMISSION, 4, face, params);
710
829
      MAT(VBO_ATTRIB_MAT_FRONT_SPECULAR, 4, face, params);
711
830
      break;
712
831
   case GL_SHININESS:
713
 
      MAT(VBO_ATTRIB_MAT_FRONT_SHININESS, 1, face, params);
 
832
      if (*params < 0 || *params > ctx->Const.MaxShininess)
 
833
         _mesa_error(ctx, GL_INVALID_VALUE,
 
834
                     "glMaterial(invalid shininess: %f out range [0, %f])",
 
835
                     *params, ctx->Const.MaxShininess);
 
836
      else
 
837
         MAT(VBO_ATTRIB_MAT_FRONT_SHININESS, 1, face, params);
714
838
      break;
715
839
   case GL_COLOR_INDEXES:
716
840
      MAT(VBO_ATTRIB_MAT_FRONT_INDEXES, 3, face, params);
725
849
   }
726
850
}
727
851
 
 
852
static void GLAPIENTRY
 
853
TAG(VertexP2ui)(GLenum type, GLuint value)
 
854
{
 
855
   GET_CURRENT_CONTEXT(ctx);
 
856
   ATTR_UI(2, type, 0, VBO_ATTRIB_POS, value);
 
857
}
 
858
 
 
859
static void GLAPIENTRY
 
860
TAG(VertexP2uiv)(GLenum type, const GLuint *value)
 
861
{
 
862
   GET_CURRENT_CONTEXT(ctx);
 
863
   ATTR_UI(2, type, 0, VBO_ATTRIB_POS, value[0]);
 
864
}
 
865
 
 
866
static void GLAPIENTRY
 
867
TAG(VertexP3ui)(GLenum type, GLuint value)
 
868
{
 
869
   GET_CURRENT_CONTEXT(ctx);
 
870
   ATTR_UI(3, type, 0, VBO_ATTRIB_POS, value);
 
871
}
 
872
 
 
873
static void GLAPIENTRY
 
874
TAG(VertexP3uiv)(GLenum type, const GLuint *value)
 
875
{
 
876
   GET_CURRENT_CONTEXT(ctx);
 
877
   ATTR_UI(3, type, 0, VBO_ATTRIB_POS, value[0]);
 
878
}
 
879
 
 
880
static void GLAPIENTRY
 
881
TAG(VertexP4ui)(GLenum type, GLuint value)
 
882
{
 
883
   GET_CURRENT_CONTEXT(ctx);
 
884
   ATTR_UI(4, type, 0, VBO_ATTRIB_POS, value);
 
885
}
 
886
 
 
887
static void GLAPIENTRY
 
888
TAG(VertexP4uiv)(GLenum type, const GLuint *value)
 
889
{
 
890
   GET_CURRENT_CONTEXT(ctx);
 
891
   ATTR_UI(4, type, 0, VBO_ATTRIB_POS, value[0]);
 
892
}
 
893
 
 
894
static void GLAPIENTRY
 
895
TAG(TexCoordP1ui)(GLenum type, GLuint coords)
 
896
{
 
897
   GET_CURRENT_CONTEXT(ctx);
 
898
   ATTR_UI(1, type, 0, VBO_ATTRIB_TEX0, coords);
 
899
}
 
900
 
 
901
static void GLAPIENTRY
 
902
TAG(TexCoordP1uiv)(GLenum type, const GLuint *coords)
 
903
{
 
904
   GET_CURRENT_CONTEXT(ctx);
 
905
   ATTR_UI(1, type, 0, VBO_ATTRIB_TEX0, coords[0]);
 
906
}
 
907
 
 
908
static void GLAPIENTRY
 
909
TAG(TexCoordP2ui)(GLenum type, GLuint coords)
 
910
{
 
911
   GET_CURRENT_CONTEXT(ctx);
 
912
   ATTR_UI(2, type, 0, VBO_ATTRIB_TEX0, coords);
 
913
}
 
914
 
 
915
static void GLAPIENTRY
 
916
TAG(TexCoordP2uiv)(GLenum type, const GLuint *coords)
 
917
{
 
918
   GET_CURRENT_CONTEXT(ctx);
 
919
   ATTR_UI(2, type, 0, VBO_ATTRIB_TEX0, coords[0]);
 
920
}
 
921
 
 
922
static void GLAPIENTRY
 
923
TAG(TexCoordP3ui)(GLenum type, GLuint coords)
 
924
{
 
925
   GET_CURRENT_CONTEXT(ctx);
 
926
   ATTR_UI(3, type, 0, VBO_ATTRIB_TEX0, coords);
 
927
}
 
928
 
 
929
static void GLAPIENTRY
 
930
TAG(TexCoordP3uiv)(GLenum type, const GLuint *coords)
 
931
{
 
932
   GET_CURRENT_CONTEXT(ctx);
 
933
   ATTR_UI(3, type, 0, VBO_ATTRIB_TEX0, coords[0]);
 
934
}
 
935
 
 
936
static void GLAPIENTRY
 
937
TAG(TexCoordP4ui)(GLenum type, GLuint coords)
 
938
{
 
939
   GET_CURRENT_CONTEXT(ctx);
 
940
   ATTR_UI(4, type, 0, VBO_ATTRIB_TEX0, coords);
 
941
}
 
942
 
 
943
static void GLAPIENTRY
 
944
TAG(TexCoordP4uiv)(GLenum type, const GLuint *coords)
 
945
{
 
946
   GET_CURRENT_CONTEXT(ctx);
 
947
   ATTR_UI(4, type, 0, VBO_ATTRIB_TEX0, coords[0]);
 
948
}
 
949
 
 
950
static void GLAPIENTRY
 
951
TAG(MultiTexCoordP1ui)(GLenum target, GLenum type, GLuint coords)
 
952
{
 
953
   GET_CURRENT_CONTEXT(ctx);
 
954
   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
 
955
   ATTR_UI(1, type, 0, attr, coords);
 
956
}
 
957
 
 
958
static void GLAPIENTRY
 
959
TAG(MultiTexCoordP1uiv)(GLenum target, GLenum type, const GLuint *coords)
 
960
{
 
961
   GET_CURRENT_CONTEXT(ctx);
 
962
   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
 
963
   ATTR_UI(1, type, 0, attr, coords[0]);
 
964
}
 
965
 
 
966
static void GLAPIENTRY
 
967
TAG(MultiTexCoordP2ui)(GLenum target, GLenum type, GLuint coords)
 
968
{
 
969
   GET_CURRENT_CONTEXT(ctx);
 
970
   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
 
971
   ATTR_UI(2, type, 0, attr, coords);
 
972
}
 
973
 
 
974
static void GLAPIENTRY
 
975
TAG(MultiTexCoordP2uiv)(GLenum target, GLenum type, const GLuint *coords)
 
976
{
 
977
   GET_CURRENT_CONTEXT(ctx);
 
978
   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
 
979
   ATTR_UI(2, type, 0, attr, coords[0]);
 
980
}
 
981
 
 
982
static void GLAPIENTRY
 
983
TAG(MultiTexCoordP3ui)(GLenum target, GLenum type, GLuint coords)
 
984
{
 
985
   GET_CURRENT_CONTEXT(ctx);
 
986
   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
 
987
   ATTR_UI(3, type, 0, attr, coords);
 
988
}
 
989
 
 
990
static void GLAPIENTRY
 
991
TAG(MultiTexCoordP3uiv)(GLenum target, GLenum type, const GLuint *coords)
 
992
{
 
993
   GET_CURRENT_CONTEXT(ctx);
 
994
   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
 
995
   ATTR_UI(3, type, 0, attr, coords[0]);
 
996
}
 
997
 
 
998
static void GLAPIENTRY
 
999
TAG(MultiTexCoordP4ui)(GLenum target, GLenum type, GLuint coords)
 
1000
{
 
1001
   GET_CURRENT_CONTEXT(ctx);
 
1002
   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
 
1003
   ATTR_UI(4, type, 0, attr, coords);
 
1004
}
 
1005
 
 
1006
static void GLAPIENTRY
 
1007
TAG(MultiTexCoordP4uiv)(GLenum target, GLenum type, const GLuint *coords)
 
1008
{
 
1009
   GET_CURRENT_CONTEXT(ctx);
 
1010
   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
 
1011
   ATTR_UI(4, type, 0, attr, coords[0]);
 
1012
}
 
1013
 
 
1014
static void GLAPIENTRY
 
1015
TAG(NormalP3ui)(GLenum type, GLuint coords)
 
1016
{
 
1017
   GET_CURRENT_CONTEXT(ctx);
 
1018
   ATTR_UI(3, type, 1, VBO_ATTRIB_NORMAL, coords);
 
1019
}
 
1020
 
 
1021
static void GLAPIENTRY
 
1022
TAG(NormalP3uiv)(GLenum type, const GLuint *coords)
 
1023
{
 
1024
   GET_CURRENT_CONTEXT(ctx);
 
1025
   ATTR_UI(3, type, 1, VBO_ATTRIB_NORMAL, coords[0]);
 
1026
}
 
1027
 
 
1028
static void GLAPIENTRY
 
1029
TAG(ColorP3ui)(GLenum type, GLuint color)
 
1030
{
 
1031
   GET_CURRENT_CONTEXT(ctx);
 
1032
   ATTR_UI(3, type, 1, VBO_ATTRIB_COLOR0, color);
 
1033
}
 
1034
 
 
1035
static void GLAPIENTRY
 
1036
TAG(ColorP3uiv)(GLenum type, const GLuint *color)
 
1037
{
 
1038
   GET_CURRENT_CONTEXT(ctx);
 
1039
   ATTR_UI(3, type, 1, VBO_ATTRIB_COLOR0, color[0]);
 
1040
}
 
1041
 
 
1042
static void GLAPIENTRY
 
1043
TAG(ColorP4ui)(GLenum type, GLuint color)
 
1044
{
 
1045
   GET_CURRENT_CONTEXT(ctx);
 
1046
   ATTR_UI(4, type, 1, VBO_ATTRIB_COLOR0, color);
 
1047
}
 
1048
 
 
1049
static void GLAPIENTRY
 
1050
TAG(ColorP4uiv)(GLenum type, const GLuint *color)
 
1051
{
 
1052
   GET_CURRENT_CONTEXT(ctx);
 
1053
   ATTR_UI(4, type, 1, VBO_ATTRIB_COLOR0, color[0]);
 
1054
}
 
1055
 
 
1056
static void GLAPIENTRY
 
1057
TAG(SecondaryColorP3ui)(GLenum type, GLuint color)
 
1058
{
 
1059
   GET_CURRENT_CONTEXT(ctx);
 
1060
   ATTR_UI(3, type, 1, VBO_ATTRIB_COLOR1, color);
 
1061
}
 
1062
 
 
1063
static void GLAPIENTRY
 
1064
TAG(SecondaryColorP3uiv)(GLenum type, const GLuint *color)
 
1065
{
 
1066
   GET_CURRENT_CONTEXT(ctx);
 
1067
   ATTR_UI(3, type, 1, VBO_ATTRIB_COLOR1, color[0]);
 
1068
}
 
1069
 
 
1070
static void GLAPIENTRY
 
1071
TAG(VertexAttribP1ui)(GLuint index, GLenum type, GLboolean normalized,
 
1072
                      GLuint value)
 
1073
{
 
1074
   GET_CURRENT_CONTEXT(ctx);
 
1075
   ATTR_UI_INDEX(1, type, normalized, index, value);
 
1076
}
 
1077
 
 
1078
static void GLAPIENTRY
 
1079
TAG(VertexAttribP2ui)(GLuint index, GLenum type, GLboolean normalized,
 
1080
                      GLuint value)
 
1081
{
 
1082
   GET_CURRENT_CONTEXT(ctx);
 
1083
   ATTR_UI_INDEX(2, type, normalized, index, value);
 
1084
}
 
1085
 
 
1086
static void GLAPIENTRY
 
1087
TAG(VertexAttribP3ui)(GLuint index, GLenum type, GLboolean normalized,
 
1088
                      GLuint value)
 
1089
{
 
1090
   GET_CURRENT_CONTEXT(ctx);
 
1091
   ATTR_UI_INDEX(3, type, normalized, index, value);
 
1092
}
 
1093
 
 
1094
static void GLAPIENTRY
 
1095
TAG(VertexAttribP4ui)(GLuint index, GLenum type, GLboolean normalized,
 
1096
                      GLuint value)
 
1097
{
 
1098
   GET_CURRENT_CONTEXT(ctx);
 
1099
   ATTR_UI_INDEX(4, type, normalized, index, value);
 
1100
}
 
1101
 
 
1102
static void GLAPIENTRY
 
1103
TAG(VertexAttribP1uiv)(GLuint index, GLenum type, GLboolean normalized,
 
1104
                       const GLuint *value)
 
1105
{
 
1106
   GET_CURRENT_CONTEXT(ctx);
 
1107
   ATTR_UI_INDEX(1, type, normalized, index, *value);
 
1108
}
 
1109
 
 
1110
static void GLAPIENTRY
 
1111
TAG(VertexAttribP2uiv)(GLuint index, GLenum type, GLboolean normalized,
 
1112
                       const GLuint *value)
 
1113
{
 
1114
   GET_CURRENT_CONTEXT(ctx);
 
1115
   ATTR_UI_INDEX(2, type, normalized, index, *value);
 
1116
}
 
1117
 
 
1118
static void GLAPIENTRY
 
1119
TAG(VertexAttribP3uiv)(GLuint index, GLenum type, GLboolean normalized,
 
1120
                       const GLuint *value)
 
1121
{
 
1122
   GET_CURRENT_CONTEXT(ctx);
 
1123
   ATTR_UI_INDEX(3, type, normalized, index, *value);
 
1124
}
 
1125
 
 
1126
static void GLAPIENTRY
 
1127
TAG(VertexAttribP4uiv)(GLuint index, GLenum type, GLboolean normalized,
 
1128
                      const GLuint *value)
 
1129
{
 
1130
   GET_CURRENT_CONTEXT(ctx);
 
1131
   ATTR_UI_INDEX(4, type, normalized, index, *value);
 
1132
}
 
1133
 
728
1134
 
729
1135
#undef ATTR1FV
730
1136
#undef ATTR2FV
736
1142
#undef ATTR3F
737
1143
#undef ATTR4F
738
1144
 
 
1145
#undef ATTR_UI
 
1146
 
739
1147
#undef MAT
740
1148
#undef MAT_ATTR