Merge branch 'origin' into glsl-compiler-1
[mesa.git] / src / mesa / shader / slang / library / slang_vertex_builtin.gc
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5
4 *
5 * Copyright (C) 2006 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 //
26 // From Shader Spec, ver. 1.10, rev. 59
27 //
28
29 __fixed_output vec4 gl_Position;
30 __fixed_output float gl_PointSize;
31 __fixed_output vec4 gl_ClipVertex;
32
33 attribute vec4 gl_Color;
34 attribute vec4 gl_SecondaryColor;
35 attribute vec3 gl_Normal;
36 attribute vec4 gl_Vertex;
37 attribute vec4 gl_MultiTexCoord0;
38 attribute vec4 gl_MultiTexCoord1;
39 attribute vec4 gl_MultiTexCoord2;
40 attribute vec4 gl_MultiTexCoord3;
41 attribute vec4 gl_MultiTexCoord4;
42 attribute vec4 gl_MultiTexCoord5;
43 attribute vec4 gl_MultiTexCoord6;
44 attribute vec4 gl_MultiTexCoord7;
45 attribute float gl_FogCoord;
46
47 varying vec4 gl_FrontColor;
48 varying vec4 gl_BackColor;
49 varying vec4 gl_FrontSecondaryColor;
50 varying vec4 gl_BackSecondaryColor;
51 varying vec4 gl_TexCoord[gl_MaxTextureCoords];
52 varying float gl_FogFragCoord;
53
54 //
55 // Geometric Functions
56 //
57
58 vec4 ftransform()
59 {
60 __retVal = gl_ModelViewProjectionMatrix * gl_Vertex;
61 }
62
63
64
65 //
66 // 8.7 Texture Lookup Functions
67 // These are pretty much identical to the ones in slang_fragment_builtin.gc
68 // When used in a vertex program, the texture sample instructions should not
69 // be using a LOD term so it's effectively zero. Adding 'lod' to that does
70 // what we want.
71 //
72
73 vec4 texture1DLod(const sampler1D sampler, const float coord, const float lod)
74 {
75 vec4 coord4;
76 coord4.x = coord;
77 coord4.w = lod;
78 __asm vec4_texb1d __retVal, sampler, coord4;
79 }
80
81 vec4 texture1DProjLod(const sampler1D sampler, const vec2 coord, const float lod)
82 {
83 vec4 pcoord;
84 pcoord.x = coord.x / coord.y;
85 pcoord.w = lod;
86 __asm vec4_texb1d __retVal, sampler, pcoord;
87 }
88
89 vec4 texture1DProjLod(const sampler1D sampler, const vec4 coord, const float lod)
90 {
91 vec4 pcoord;
92 pcoord.x = coord.x / coord.z;
93 pcoord.w = lod;
94 __asm vec4_texb1d __retVal, sampler, pcoord;
95 }
96
97
98
99 vec4 texture2DLod(const sampler2D sampler, const vec2 coord, const float lod)
100 {
101 vec4 coord4;
102 coord4.xy = coord.xy;
103 coord4.w = lod;
104 __asm vec4_texb2d __retVal, sampler, coord4;
105 }
106
107 vec4 texture2DProjLod(const sampler2D sampler, const vec3 coord, const float lod)
108 {
109 vec4 pcoord;
110 pcoord.xy = coord.xy / coord.z;
111 pcoord.w = lod;
112 __asm vec4_texb2d __retVal, sampler, pcoord;
113 }
114
115 vec4 texture2DProjLod(const sampler2D sampler, const vec4 coord, const float lod)
116 {
117 vec4 pcoord;
118 pcoord.xy = coord.xy / coord.z;
119 pcoord.w = lod;
120 __asm vec4_texb2d __retVal, sampler, pcoord;
121 }
122
123
124 vec4 texture3DLod(const sampler3D sampler, const vec3 coord, const float lod)
125 {
126 vec4 coord4;
127 coord4.xyz = coord.xyz;
128 coord4.w = lod;
129 __asm vec4_texb3d __retVal, sampler, coord4;
130 }
131
132 vec4 texture3DProjLod(const sampler3D sampler, const vec4 coord, const float lod)
133 {
134 // do projection here (there's no vec4_texbp3d instruction)
135 vec4 pcoord;
136 pcoord.xyz = coord.xyz / coord.w;
137 pcoord.w = lod;
138 __asm vec4_texb3d __retVal, sampler, pcoord;
139 }
140
141
142 vec4 textureCubeLod(const samplerCube sampler, const vec3 coord, const float lod)
143 {
144 vec4 coord4;
145 coord4.xyz = coord;
146 coord4.w = lod;
147 __asm vec4_texcube __retVal, sampler, coord4;
148 }
149
150
151 vec4 shadow1DLod(const sampler1DShadow sampler, const vec3 coord, const float lod)
152 {
153 vec4 coord4;
154 coord4.xyz = coord;
155 coord4.w = lod;
156 __asm vec4_texb1d __retVal, sampler, coord4;
157 }
158
159 vec4 shadow1DProjLod(const sampler1DShadow sampler, const vec4 coord,
160 const float lod)
161 {
162 vec4 pcoord;
163 pcoord.x = coord.x / coord.w;
164 pcoord.z = coord.z;
165 pcoord.w = lod;
166 __asm vec4_texb1d __retVal, sampler, pcoord;
167 }
168
169
170 vec4 shadow2DLod(const sampler2DShadow sampler, const vec3 coord, const float lod)
171 {
172 vec4 coord4;
173 coord4.xyz = coord;
174 coord4.w = lod;
175 __asm vec4_texb2d __retVal, sampler, coord4;
176 }
177
178 vec4 shadow2DProjLod(const sampler2DShadow sampler, const vec4 coord,
179 const float lod)
180 {
181 vec4 pcoord;
182 pcoord.xy = coord.xy / coord.w;
183 pcoord.z = coord.z;
184 pcoord.w = lod;
185 __asm vec4_texb2d __retVal, sampler, pcoord;
186 }
187