mesa: import latest GLSL code from gallium-0.1 branch

This commit is contained in:
Brian Paul 2008-08-16 09:30:14 -06:00
parent 1b39b92e6d
commit 1f4997c2aa
40 changed files with 3640 additions and 3155 deletions

View file

@ -31,8 +31,8 @@
*/
#include "glheader.h"
#include "context.h"
#include "main/glheader.h"
#include "main/context.h"
#include "prog_parameter.h"
#include "prog_statevars.h"
#include "program.h"
@ -368,9 +368,9 @@ _mesa_count_texture_instructions(struct gl_program *prog)
/**
* Scan/rewrite program to remove reads of custom (output) registers.
* The passed type has to be either PROGRAM_VARYING or PROGRAM_OUTPUT.
* In GLSL vertex shaders, varying vars can be read and written.
* Normally, vertex varying vars are implemented as output registers.
* The passed type has to be either PROGRAM_OUTPUT or PROGRAM_VARYING
* (for vertex shaders).
* In GLSL shaders, varying vars can be read and written.
* On some hardware, trying to read an output register causes trouble.
* So, rewrite the program to use a temporary register in this case.
*/
@ -381,8 +381,8 @@ _mesa_remove_output_reads(struct gl_program *prog, enum register_file type)
GLint outputMap[VERT_RESULT_MAX];
GLuint numVaryingReads = 0;
assert(prog->Target == GL_VERTEX_PROGRAM_ARB);
assert(type == PROGRAM_VARYING || type == PROGRAM_OUTPUT);
assert(prog->Target == GL_VERTEX_PROGRAM_ARB || type != PROGRAM_VARYING);
for (i = 0; i < VERT_RESULT_MAX; i++)
outputMap[i] = -1;

File diff suppressed because it is too large Load diff

View file

@ -2,103 +2,103 @@
/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE FOLLOWING FILE: */
/* slang_builtin_120_common.gc */
3,1,0,26,0,109,97,116,114,105,120,67,111,109,112,77,117,108,116,0,1,0,0,26,109,0,0,1,0,0,26,110,0,
0,0,1,8,58,109,97,116,50,120,51,0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,48,0,18,109,0,16,10,
49,0,57,18,110,0,16,10,49,0,57,48,0,0,0,0,1,0,28,0,109,97,116,114,105,120,67,111,109,112,77,117,
108,116,0,1,0,0,28,109,0,0,1,0,0,28,110,0,0,0,1,8,58,109,97,116,50,120,52,0,18,109,0,16,8,48,0,57,
18,110,0,16,8,48,0,57,48,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,48,0,0,0,0,1,0,27,0,109,
97,116,114,105,120,67,111,109,112,77,117,108,116,0,1,0,0,27,109,0,0,1,0,0,27,110,0,0,0,1,8,58,109,
97,116,51,120,50,0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,48,0,18,109,0,16,10,49,0,57,18,110,
0,16,10,49,0,57,48,0,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,48,0,0,0,0,1,0,30,0,109,97,116,
114,105,120,67,111,109,112,77,117,108,116,0,1,0,0,30,109,0,0,1,0,0,30,110,0,0,0,1,8,58,109,97,116,
51,120,52,0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,48,0,18,109,0,16,10,49,0,57,18,110,0,16,10,
49,0,57,48,0,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,48,0,0,0,0,1,0,29,0,109,97,116,114,105,
120,67,111,109,112,77,117,108,116,0,1,0,0,29,109,0,0,1,0,0,29,110,0,0,0,1,8,58,109,97,116,52,120,
50,0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,48,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,
57,48,0,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,48,0,18,109,0,16,10,51,0,57,18,110,0,16,10,
51,0,57,48,0,0,0,0,1,0,31,0,109,97,116,114,105,120,67,111,109,112,77,117,108,116,0,1,0,0,31,109,0,
0,1,0,0,31,110,0,0,0,1,8,58,109,97,116,52,120,51,0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,48,
0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,48,0,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,
48,0,18,109,0,16,10,51,0,57,18,110,0,16,10,51,0,57,48,0,0,0,0,1,0,13,0,111,117,116,101,114,80,114,
111,100,117,99,116,0,1,0,0,10,99,0,0,1,0,0,10,114,0,0,0,1,8,58,109,97,116,50,0,18,99,0,59,120,0,18,
114,0,59,120,0,48,0,18,99,0,59,121,0,18,114,0,59,120,0,48,0,18,99,0,59,120,0,18,114,0,59,121,0,48,
0,18,99,0,59,121,0,18,114,0,59,121,0,48,0,0,0,0,1,0,14,0,111,117,116,101,114,80,114,111,100,117,99,
116,0,1,0,0,11,99,0,0,1,0,0,11,114,0,0,0,1,8,58,109,97,116,51,0,18,99,0,59,120,0,18,114,0,59,120,0,
4,1,0,0,26,0,109,97,116,114,105,120,67,111,109,112,77,117,108,116,0,1,0,0,26,109,0,0,1,0,0,26,110,
0,0,0,1,8,58,109,97,116,50,120,51,0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,48,0,18,109,0,16,
10,49,0,57,18,110,0,16,10,49,0,57,48,0,0,0,0,1,0,0,28,0,109,97,116,114,105,120,67,111,109,112,77,
117,108,116,0,1,0,0,28,109,0,0,1,0,0,28,110,0,0,0,1,8,58,109,97,116,50,120,52,0,18,109,0,16,8,48,0,
57,18,110,0,16,8,48,0,57,48,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,48,0,0,0,0,1,0,0,27,0,
109,97,116,114,105,120,67,111,109,112,77,117,108,116,0,1,0,0,27,109,0,0,1,0,0,27,110,0,0,0,1,8,58,
109,97,116,51,120,50,0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,48,0,18,109,0,16,10,49,0,57,18,
110,0,16,10,49,0,57,48,0,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,48,0,0,0,0,1,0,0,30,0,109,
97,116,114,105,120,67,111,109,112,77,117,108,116,0,1,0,0,30,109,0,0,1,0,0,30,110,0,0,0,1,8,58,109,
97,116,51,120,52,0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,48,0,18,109,0,16,10,49,0,57,18,110,
0,16,10,49,0,57,48,0,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,48,0,0,0,0,1,0,0,29,0,109,97,
116,114,105,120,67,111,109,112,77,117,108,116,0,1,0,0,29,109,0,0,1,0,0,29,110,0,0,0,1,8,58,109,97,
116,52,120,50,0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,48,0,18,109,0,16,10,49,0,57,18,110,0,
16,10,49,0,57,48,0,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,48,0,18,109,0,16,10,51,0,57,18,
110,0,16,10,51,0,57,48,0,0,0,0,1,0,0,31,0,109,97,116,114,105,120,67,111,109,112,77,117,108,116,0,1,
0,0,31,109,0,0,1,0,0,31,110,0,0,0,1,8,58,109,97,116,52,120,51,0,18,109,0,16,8,48,0,57,18,110,0,16,
8,48,0,57,48,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,48,0,18,109,0,16,10,50,0,57,18,110,0,
16,10,50,0,57,48,0,18,109,0,16,10,51,0,57,18,110,0,16,10,51,0,57,48,0,0,0,0,1,0,0,13,0,111,117,116,
101,114,80,114,111,100,117,99,116,0,1,0,0,10,99,0,0,1,0,0,10,114,0,0,0,1,8,58,109,97,116,50,0,18,
99,0,59,120,0,18,114,0,59,120,0,48,0,18,99,0,59,121,0,18,114,0,59,120,0,48,0,18,99,0,59,120,0,18,
114,0,59,121,0,48,0,18,99,0,59,121,0,18,114,0,59,121,0,48,0,0,0,0,1,0,0,14,0,111,117,116,101,114,
80,114,111,100,117,99,116,0,1,0,0,11,99,0,0,1,0,0,11,114,0,0,0,1,8,58,109,97,116,51,0,18,99,0,59,
120,0,18,114,0,59,120,0,48,0,18,99,0,59,121,0,18,114,0,59,120,0,48,0,18,99,0,59,122,0,18,114,0,59,
120,0,48,0,18,99,0,59,120,0,18,114,0,59,121,0,48,0,18,99,0,59,121,0,18,114,0,59,121,0,48,0,18,99,0,
59,122,0,18,114,0,59,121,0,48,0,18,99,0,59,120,0,18,114,0,59,122,0,48,0,18,99,0,59,121,0,18,114,0,
59,122,0,48,0,18,99,0,59,122,0,18,114,0,59,122,0,48,0,0,0,0,1,0,0,15,0,111,117,116,101,114,80,114,
111,100,117,99,116,0,1,0,0,12,99,0,0,1,0,0,12,114,0,0,0,1,8,58,109,97,116,52,0,18,99,0,59,120,0,18,
114,0,59,120,0,48,0,18,99,0,59,121,0,18,114,0,59,120,0,48,0,18,99,0,59,122,0,18,114,0,59,120,0,48,
0,18,99,0,59,119,0,18,114,0,59,120,0,48,0,18,99,0,59,120,0,18,114,0,59,121,0,48,0,18,99,0,59,121,0,
18,114,0,59,121,0,48,0,18,99,0,59,122,0,18,114,0,59,121,0,48,0,18,99,0,59,119,0,18,114,0,59,121,0,
48,0,18,99,0,59,120,0,18,114,0,59,122,0,48,0,18,99,0,59,121,0,18,114,0,59,122,0,48,0,18,99,0,59,
122,0,18,114,0,59,122,0,48,0,18,99,0,59,119,0,18,114,0,59,122,0,48,0,18,99,0,59,120,0,18,114,0,59,
119,0,48,0,18,99,0,59,121,0,18,114,0,59,119,0,48,0,18,99,0,59,122,0,18,114,0,59,119,0,48,0,18,99,0,
59,119,0,18,114,0,59,119,0,48,0,0,0,0,1,0,0,26,0,111,117,116,101,114,80,114,111,100,117,99,116,0,1,
0,0,11,99,0,0,1,0,0,10,114,0,0,0,1,8,58,109,97,116,50,120,51,0,18,99,0,59,120,0,18,114,0,59,120,0,
48,0,18,99,0,59,121,0,18,114,0,59,120,0,48,0,18,99,0,59,122,0,18,114,0,59,120,0,48,0,18,99,0,59,
120,0,18,114,0,59,121,0,48,0,18,99,0,59,121,0,18,114,0,59,121,0,48,0,18,99,0,59,122,0,18,114,0,59,
121,0,48,0,18,99,0,59,120,0,18,114,0,59,122,0,48,0,18,99,0,59,121,0,18,114,0,59,122,0,48,0,18,99,0,
59,122,0,18,114,0,59,122,0,48,0,0,0,0,1,0,15,0,111,117,116,101,114,80,114,111,100,117,99,116,0,1,0,
0,12,99,0,0,1,0,0,12,114,0,0,0,1,8,58,109,97,116,52,0,18,99,0,59,120,0,18,114,0,59,120,0,48,0,18,
99,0,59,121,0,18,114,0,59,120,0,48,0,18,99,0,59,122,0,18,114,0,59,120,0,48,0,18,99,0,59,119,0,18,
114,0,59,120,0,48,0,18,99,0,59,120,0,18,114,0,59,121,0,48,0,18,99,0,59,121,0,18,114,0,59,121,0,48,
0,18,99,0,59,122,0,18,114,0,59,121,0,48,0,18,99,0,59,119,0,18,114,0,59,121,0,48,0,18,99,0,59,120,0,
18,114,0,59,122,0,48,0,18,99,0,59,121,0,18,114,0,59,122,0,48,0,18,99,0,59,122,0,18,114,0,59,122,0,
48,0,18,99,0,59,119,0,18,114,0,59,122,0,48,0,18,99,0,59,120,0,18,114,0,59,119,0,48,0,18,99,0,59,
121,0,18,114,0,59,119,0,48,0,18,99,0,59,122,0,18,114,0,59,119,0,48,0,18,99,0,59,119,0,18,114,0,59,
119,0,48,0,0,0,0,1,0,26,0,111,117,116,101,114,80,114,111,100,117,99,116,0,1,0,0,11,99,0,0,1,0,0,10,
114,0,0,0,1,8,58,109,97,116,50,120,51,0,18,99,0,59,120,0,18,114,0,59,120,0,48,0,18,99,0,59,121,0,
18,114,0,59,120,0,48,0,18,99,0,59,122,0,18,114,0,59,120,0,48,0,18,99,0,59,120,0,18,114,0,59,121,0,
48,0,18,99,0,59,121,0,18,114,0,59,121,0,48,0,18,99,0,59,122,0,18,114,0,59,121,0,48,0,0,0,0,1,0,27,
0,111,117,116,101,114,80,114,111,100,117,99,116,0,1,0,0,10,99,0,0,1,0,0,11,114,0,0,0,1,8,58,109,97,
116,51,120,50,0,18,99,0,59,120,0,18,114,0,59,120,0,48,0,18,99,0,59,121,0,18,114,0,59,120,0,48,0,18,
99,0,59,120,0,18,114,0,59,121,0,48,0,18,99,0,59,121,0,18,114,0,59,121,0,48,0,18,99,0,59,120,0,18,
114,0,59,122,0,48,0,18,99,0,59,121,0,18,114,0,59,122,0,48,0,0,0,0,1,0,28,0,111,117,116,101,114,80,
114,111,100,117,99,116,0,1,0,0,12,99,0,0,1,0,0,10,114,0,0,0,1,8,58,109,97,116,50,120,52,0,18,99,0,
59,120,0,18,114,0,59,120,0,48,0,18,99,0,59,121,0,18,114,0,59,120,0,48,0,18,99,0,59,122,0,18,114,0,
59,120,0,48,0,18,99,0,59,119,0,18,114,0,59,120,0,48,0,18,99,0,59,120,0,18,114,0,59,121,0,48,0,18,
99,0,59,121,0,18,114,0,59,121,0,48,0,18,99,0,59,122,0,18,114,0,59,121,0,48,0,18,99,0,59,119,0,18,
114,0,59,121,0,48,0,0,0,0,1,0,29,0,111,117,116,101,114,80,114,111,100,117,99,116,0,1,0,0,10,99,0,0,
1,0,0,12,114,0,0,0,1,8,58,109,97,116,52,120,50,0,18,99,0,59,120,0,18,114,0,59,120,0,48,0,18,99,0,
59,121,0,18,114,0,59,120,0,48,0,18,99,0,59,120,0,18,114,0,59,121,0,48,0,18,99,0,59,121,0,18,114,0,
59,121,0,48,0,18,99,0,59,120,0,18,114,0,59,122,0,48,0,18,99,0,59,121,0,18,114,0,59,122,0,48,0,18,
99,0,59,120,0,18,114,0,59,119,0,48,0,18,99,0,59,121,0,18,114,0,59,119,0,48,0,0,0,0,1,0,30,0,111,
117,116,101,114,80,114,111,100,117,99,116,0,1,0,0,12,99,0,0,1,0,0,11,114,0,0,0,1,8,58,109,97,116,
51,120,52,0,18,99,0,59,120,0,18,114,0,59,120,0,48,0,18,99,0,59,121,0,18,114,0,59,120,0,48,0,18,99,
0,59,122,0,18,114,0,59,120,0,48,0,18,99,0,59,119,0,18,114,0,59,120,0,48,0,18,99,0,59,120,0,18,114,
0,59,121,0,48,0,18,99,0,59,121,0,18,114,0,59,121,0,48,0,18,99,0,59,122,0,18,114,0,59,121,0,48,0,18,
99,0,59,119,0,18,114,0,59,121,0,48,0,18,99,0,59,120,0,18,114,0,59,122,0,48,0,18,99,0,59,121,0,18,
114,0,59,122,0,48,0,18,99,0,59,122,0,18,114,0,59,122,0,48,0,18,99,0,59,119,0,18,114,0,59,122,0,48,
0,0,0,0,1,0,31,0,111,117,116,101,114,80,114,111,100,117,99,116,0,1,0,0,11,99,0,0,1,0,0,12,114,0,0,
0,1,8,58,109,97,116,52,120,51,0,18,99,0,59,120,0,18,114,0,59,120,0,48,0,18,99,0,59,121,0,18,114,0,
59,120,0,48,0,18,99,0,59,122,0,18,114,0,59,120,0,48,0,18,99,0,59,120,0,18,114,0,59,121,0,48,0,18,
99,0,59,121,0,18,114,0,59,121,0,48,0,18,99,0,59,122,0,18,114,0,59,121,0,48,0,18,99,0,59,120,0,18,
114,0,59,122,0,48,0,18,99,0,59,121,0,18,114,0,59,122,0,48,0,18,99,0,59,122,0,18,114,0,59,122,0,48,
0,18,99,0,59,120,0,18,114,0,59,119,0,48,0,18,99,0,59,121,0,18,114,0,59,119,0,48,0,18,99,0,59,122,0,
18,114,0,59,119,0,48,0,0,0,0,1,0,13,0,116,114,97,110,115,112,111,115,101,0,1,0,0,13,109,0,0,0,1,8,
58,109,97,116,50,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,120,0,0,18,109,0,16,
8,48,0,57,59,121,0,0,18,109,0,16,10,49,0,57,59,121,0,0,0,0,0,1,0,14,0,116,114,97,110,115,112,111,
115,101,0,1,0,0,14,109,0,0,0,1,8,58,109,97,116,51,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,
10,49,0,57,59,120,0,0,18,109,0,16,10,50,0,57,59,120,0,0,18,109,0,16,8,48,0,57,59,121,0,0,18,109,0,
16,10,49,0,57,59,121,0,0,18,109,0,16,10,50,0,57,59,121,0,0,18,109,0,16,8,48,0,57,59,122,0,0,18,109,
0,16,10,49,0,57,59,122,0,0,18,109,0,16,10,50,0,57,59,122,0,0,0,0,0,1,0,15,0,116,114,97,110,115,112,
111,115,101,0,1,0,0,15,109,0,0,0,1,8,58,109,97,116,52,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,
16,10,49,0,57,59,120,0,0,18,109,0,16,10,50,0,57,59,120,0,0,18,109,0,16,10,51,0,57,59,120,0,0,18,
109,0,16,8,48,0,57,59,121,0,0,18,109,0,16,10,49,0,57,59,121,0,0,18,109,0,16,10,50,0,57,59,121,0,0,
18,109,0,16,10,51,0,57,59,121,0,0,18,109,0,16,8,48,0,57,59,122,0,0,18,109,0,16,10,49,0,57,59,122,0,
0,18,109,0,16,10,50,0,57,59,122,0,0,18,109,0,16,10,51,0,57,59,122,0,0,18,109,0,16,8,48,0,57,59,119,
0,0,18,109,0,16,10,49,0,57,59,119,0,0,18,109,0,16,10,50,0,57,59,119,0,0,18,109,0,16,10,51,0,57,59,
119,0,0,0,0,0,1,0,26,0,116,114,97,110,115,112,111,115,101,0,1,0,0,27,109,0,0,0,1,8,58,109,97,116,
50,120,51,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,120,0,0,18,109,0,16,10,50,0,
57,59,120,0,0,18,109,0,16,8,48,0,57,59,121,0,0,18,109,0,16,10,49,0,57,59,121,0,0,18,109,0,16,10,50,
0,57,59,121,0,0,0,0,0,1,0,27,0,116,114,97,110,115,112,111,115,101,0,1,0,0,26,109,0,0,0,1,8,58,109,
97,116,51,120,50,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,120,0,0,18,109,0,16,
8,48,0,57,59,121,0,0,18,109,0,16,10,49,0,57,59,121,0,0,18,109,0,16,8,48,0,57,59,122,0,0,18,109,0,
16,10,49,0,57,59,122,0,0,0,0,0,1,0,28,0,116,114,97,110,115,112,111,115,101,0,1,0,0,29,109,0,0,0,1,
8,58,109,97,116,50,120,52,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,120,0,0,18,
109,0,16,10,50,0,57,59,120,0,0,18,109,0,16,10,51,0,57,59,120,0,0,18,109,0,16,8,48,0,57,59,121,0,0,
18,109,0,16,10,49,0,57,59,121,0,0,18,109,0,16,10,50,0,57,59,121,0,0,18,109,0,16,10,51,0,57,59,121,
0,0,0,0,0,1,0,29,0,116,114,97,110,115,112,111,115,101,0,1,0,0,28,109,0,0,0,1,8,58,109,97,116,52,
120,50,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,120,0,0,18,109,0,16,8,48,0,57,
59,121,0,0,18,109,0,16,10,49,0,57,59,121,0,0,18,109,0,16,8,48,0,57,59,122,0,0,18,109,0,16,10,49,0,
57,59,122,0,0,18,109,0,16,8,48,0,57,59,119,0,0,18,109,0,16,10,49,0,57,59,119,0,0,0,0,0,1,0,30,0,
116,114,97,110,115,112,111,115,101,0,1,0,0,31,109,0,0,0,1,8,58,109,97,116,51,120,52,0,18,109,0,16,
121,0,48,0,0,0,0,1,0,0,27,0,111,117,116,101,114,80,114,111,100,117,99,116,0,1,0,0,10,99,0,0,1,0,0,
11,114,0,0,0,1,8,58,109,97,116,51,120,50,0,18,99,0,59,120,0,18,114,0,59,120,0,48,0,18,99,0,59,121,
0,18,114,0,59,120,0,48,0,18,99,0,59,120,0,18,114,0,59,121,0,48,0,18,99,0,59,121,0,18,114,0,59,121,
0,48,0,18,99,0,59,120,0,18,114,0,59,122,0,48,0,18,99,0,59,121,0,18,114,0,59,122,0,48,0,0,0,0,1,0,0,
28,0,111,117,116,101,114,80,114,111,100,117,99,116,0,1,0,0,12,99,0,0,1,0,0,10,114,0,0,0,1,8,58,109,
97,116,50,120,52,0,18,99,0,59,120,0,18,114,0,59,120,0,48,0,18,99,0,59,121,0,18,114,0,59,120,0,48,0,
18,99,0,59,122,0,18,114,0,59,120,0,48,0,18,99,0,59,119,0,18,114,0,59,120,0,48,0,18,99,0,59,120,0,
18,114,0,59,121,0,48,0,18,99,0,59,121,0,18,114,0,59,121,0,48,0,18,99,0,59,122,0,18,114,0,59,121,0,
48,0,18,99,0,59,119,0,18,114,0,59,121,0,48,0,0,0,0,1,0,0,29,0,111,117,116,101,114,80,114,111,100,
117,99,116,0,1,0,0,10,99,0,0,1,0,0,12,114,0,0,0,1,8,58,109,97,116,52,120,50,0,18,99,0,59,120,0,18,
114,0,59,120,0,48,0,18,99,0,59,121,0,18,114,0,59,120,0,48,0,18,99,0,59,120,0,18,114,0,59,121,0,48,
0,18,99,0,59,121,0,18,114,0,59,121,0,48,0,18,99,0,59,120,0,18,114,0,59,122,0,48,0,18,99,0,59,121,0,
18,114,0,59,122,0,48,0,18,99,0,59,120,0,18,114,0,59,119,0,48,0,18,99,0,59,121,0,18,114,0,59,119,0,
48,0,0,0,0,1,0,0,30,0,111,117,116,101,114,80,114,111,100,117,99,116,0,1,0,0,12,99,0,0,1,0,0,11,114,
0,0,0,1,8,58,109,97,116,51,120,52,0,18,99,0,59,120,0,18,114,0,59,120,0,48,0,18,99,0,59,121,0,18,
114,0,59,120,0,48,0,18,99,0,59,122,0,18,114,0,59,120,0,48,0,18,99,0,59,119,0,18,114,0,59,120,0,48,
0,18,99,0,59,120,0,18,114,0,59,121,0,48,0,18,99,0,59,121,0,18,114,0,59,121,0,48,0,18,99,0,59,122,0,
18,114,0,59,121,0,48,0,18,99,0,59,119,0,18,114,0,59,121,0,48,0,18,99,0,59,120,0,18,114,0,59,122,0,
48,0,18,99,0,59,121,0,18,114,0,59,122,0,48,0,18,99,0,59,122,0,18,114,0,59,122,0,48,0,18,99,0,59,
119,0,18,114,0,59,122,0,48,0,0,0,0,1,0,0,31,0,111,117,116,101,114,80,114,111,100,117,99,116,0,1,0,
0,11,99,0,0,1,0,0,12,114,0,0,0,1,8,58,109,97,116,52,120,51,0,18,99,0,59,120,0,18,114,0,59,120,0,48,
0,18,99,0,59,121,0,18,114,0,59,120,0,48,0,18,99,0,59,122,0,18,114,0,59,120,0,48,0,18,99,0,59,120,0,
18,114,0,59,121,0,48,0,18,99,0,59,121,0,18,114,0,59,121,0,48,0,18,99,0,59,122,0,18,114,0,59,121,0,
48,0,18,99,0,59,120,0,18,114,0,59,122,0,48,0,18,99,0,59,121,0,18,114,0,59,122,0,48,0,18,99,0,59,
122,0,18,114,0,59,122,0,48,0,18,99,0,59,120,0,18,114,0,59,119,0,48,0,18,99,0,59,121,0,18,114,0,59,
119,0,48,0,18,99,0,59,122,0,18,114,0,59,119,0,48,0,0,0,0,1,0,0,13,0,116,114,97,110,115,112,111,115,
101,0,1,0,0,13,109,0,0,0,1,8,58,109,97,116,50,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,10,49,
0,57,59,120,0,0,18,109,0,16,8,48,0,57,59,121,0,0,18,109,0,16,10,49,0,57,59,121,0,0,0,0,0,1,0,0,14,
0,116,114,97,110,115,112,111,115,101,0,1,0,0,14,109,0,0,0,1,8,58,109,97,116,51,0,18,109,0,16,8,48,
0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,120,0,0,18,109,0,16,10,50,0,57,59,120,0,0,18,109,0,16,8,
48,0,57,59,121,0,0,18,109,0,16,10,49,0,57,59,121,0,0,18,109,0,16,10,50,0,57,59,121,0,0,18,109,0,16,
8,48,0,57,59,122,0,0,18,109,0,16,10,49,0,57,59,122,0,0,18,109,0,16,10,50,0,57,59,122,0,0,0,0,0,1,0,
0,15,0,116,114,97,110,115,112,111,115,101,0,1,0,0,15,109,0,0,0,1,8,58,109,97,116,52,0,18,109,0,16,
8,48,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,120,0,0,18,109,0,16,10,50,0,57,59,120,0,0,18,109,0,
16,10,51,0,57,59,120,0,0,18,109,0,16,8,48,0,57,59,121,0,0,18,109,0,16,10,49,0,57,59,121,0,0,18,109,
0,16,10,50,0,57,59,121,0,0,18,109,0,16,10,51,0,57,59,121,0,0,18,109,0,16,8,48,0,57,59,122,0,0,18,
109,0,16,10,49,0,57,59,122,0,0,18,109,0,16,10,50,0,57,59,122,0,0,18,109,0,16,10,51,0,57,59,122,0,0,
0,0,0,1,0,31,0,116,114,97,110,115,112,111,115,101,0,1,0,0,30,109,0,0,0,1,8,58,109,97,116,52,120,51,
0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,120,0,0,18,109,0,16,10,50,0,57,59,120,
0,0,18,109,0,16,8,48,0,57,59,121,0,0,18,109,0,16,10,49,0,57,59,121,0,0,18,109,0,16,10,50,0,57,59,
121,0,0,18,109,0,16,8,48,0,57,59,122,0,0,18,109,0,16,10,49,0,57,59,122,0,0,18,109,0,16,10,50,0,57,
59,122,0,0,18,109,0,16,8,48,0,57,59,119,0,0,18,109,0,16,10,49,0,57,59,119,0,0,18,109,0,16,10,50,0,
57,59,119,0,0,0,0,0,0
18,109,0,16,8,48,0,57,59,119,0,0,18,109,0,16,10,49,0,57,59,119,0,0,18,109,0,16,10,50,0,57,59,119,0,
0,18,109,0,16,10,51,0,57,59,119,0,0,0,0,0,1,0,0,26,0,116,114,97,110,115,112,111,115,101,0,1,0,0,27,
109,0,0,0,1,8,58,109,97,116,50,120,51,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,
120,0,0,18,109,0,16,10,50,0,57,59,120,0,0,18,109,0,16,8,48,0,57,59,121,0,0,18,109,0,16,10,49,0,57,
59,121,0,0,18,109,0,16,10,50,0,57,59,121,0,0,0,0,0,1,0,0,27,0,116,114,97,110,115,112,111,115,101,0,
1,0,0,26,109,0,0,0,1,8,58,109,97,116,51,120,50,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,10,
49,0,57,59,120,0,0,18,109,0,16,8,48,0,57,59,121,0,0,18,109,0,16,10,49,0,57,59,121,0,0,18,109,0,16,
8,48,0,57,59,122,0,0,18,109,0,16,10,49,0,57,59,122,0,0,0,0,0,1,0,0,28,0,116,114,97,110,115,112,111,
115,101,0,1,0,0,29,109,0,0,0,1,8,58,109,97,116,50,120,52,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,
0,16,10,49,0,57,59,120,0,0,18,109,0,16,10,50,0,57,59,120,0,0,18,109,0,16,10,51,0,57,59,120,0,0,18,
109,0,16,8,48,0,57,59,121,0,0,18,109,0,16,10,49,0,57,59,121,0,0,18,109,0,16,10,50,0,57,59,121,0,0,
18,109,0,16,10,51,0,57,59,121,0,0,0,0,0,1,0,0,29,0,116,114,97,110,115,112,111,115,101,0,1,0,0,28,
109,0,0,0,1,8,58,109,97,116,52,120,50,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,
120,0,0,18,109,0,16,8,48,0,57,59,121,0,0,18,109,0,16,10,49,0,57,59,121,0,0,18,109,0,16,8,48,0,57,
59,122,0,0,18,109,0,16,10,49,0,57,59,122,0,0,18,109,0,16,8,48,0,57,59,119,0,0,18,109,0,16,10,49,0,
57,59,119,0,0,0,0,0,1,0,0,30,0,116,114,97,110,115,112,111,115,101,0,1,0,0,31,109,0,0,0,1,8,58,109,
97,116,51,120,52,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,120,0,0,18,109,0,16,
10,50,0,57,59,120,0,0,18,109,0,16,10,51,0,57,59,120,0,0,18,109,0,16,8,48,0,57,59,121,0,0,18,109,0,
16,10,49,0,57,59,121,0,0,18,109,0,16,10,50,0,57,59,121,0,0,18,109,0,16,10,51,0,57,59,121,0,0,18,
109,0,16,8,48,0,57,59,122,0,0,18,109,0,16,10,49,0,57,59,122,0,0,18,109,0,16,10,50,0,57,59,122,0,0,
18,109,0,16,10,51,0,57,59,122,0,0,0,0,0,1,0,0,31,0,116,114,97,110,115,112,111,115,101,0,1,0,0,30,
109,0,0,0,1,8,58,109,97,116,52,120,51,0,18,109,0,16,8,48,0,57,59,120,0,0,18,109,0,16,10,49,0,57,59,
120,0,0,18,109,0,16,10,50,0,57,59,120,0,0,18,109,0,16,8,48,0,57,59,121,0,0,18,109,0,16,10,49,0,57,
59,121,0,0,18,109,0,16,10,50,0,57,59,121,0,0,18,109,0,16,8,48,0,57,59,122,0,0,18,109,0,16,10,49,0,
57,59,122,0,0,18,109,0,16,10,50,0,57,59,122,0,0,18,109,0,16,8,48,0,57,59,119,0,0,18,109,0,16,10,49,
0,57,59,119,0,0,18,109,0,16,10,50,0,57,59,119,0,0,0,0,0,0

View file

@ -2,4 +2,4 @@
/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE FOLLOWING FILE: */
/* slang_builtin_120_fragment.gc */
3,2,2,3,10,1,103,108,95,80,111,105,110,116,67,111,111,114,100,0,0,0,0
4,2,2,3,0,10,1,103,108,95,80,111,105,110,116,67,111,111,114,100,0,0,0,0

View file

@ -171,7 +171,7 @@ uniform gl_FogParameters gl_Fog;
float radians(const float deg)
{
const float c = 3.1415926 / 180.0;
__asm vec4_multiply __retVal.x, deg, c;
__asm vec4_multiply __retVal, deg, c;
}
vec2 radians(const vec2 deg)
@ -198,7 +198,7 @@ vec4 radians(const vec4 deg)
float degrees(const float rad)
{
const float c = 180.0 / 3.1415926;
__asm vec4_multiply __retVal.x, rad, c;
__asm vec4_multiply __retVal, rad, c;
}
vec2 degrees(const vec2 rad)
@ -224,7 +224,7 @@ vec4 degrees(const vec4 rad)
float sin(const float radians)
{
__asm float_sine __retVal.x, radians;
__asm float_sine __retVal, radians;
}
vec2 sin(const vec2 radians)
@ -253,7 +253,7 @@ vec4 sin(const vec4 radians)
float cos(const float radians)
{
__asm float_cosine __retVal.x, radians;
__asm float_cosine __retVal, radians;
}
vec2 cos(const vec2 radians)
@ -444,7 +444,7 @@ vec4 atan(const vec4 u, const vec4 v)
float pow(const float a, const float b)
{
__asm float_power __retVal.x, a, b;
__asm float_power __retVal, a, b;
}
vec2 pow(const vec2 a, const vec2 b)
@ -507,7 +507,7 @@ vec4 exp(const vec4 a)
float log2(const float x)
{
__asm float_log2 __retVal.x, x;
__asm float_log2 __retVal, x;
}
vec2 log2(const vec2 v)
@ -566,7 +566,7 @@ vec4 log(const vec4 v)
float exp2(const float a)
{
__asm float_exp2 __retVal.x, a;
__asm float_exp2 __retVal, a;
}
vec2 exp2(const vec2 a)
@ -597,7 +597,7 @@ float sqrt(const float x)
{
float r;
__asm float_rsq r, x;
__asm float_rcp __retVal.x, r;
__asm float_rcp __retVal, r;
}
vec2 sqrt(const vec2 v)
@ -667,13 +667,13 @@ vec4 inversesqrt(const vec4 v)
float normalize(const float x)
{
__retVal.x = 1.0;
__retVal = 1.0;
}
vec2 normalize(const vec2 v)
{
const float s = inversesqrt(dot(v, v));
__asm vec4_multiply __retVal.xy, v, s.xx;
__asm vec4_multiply __retVal.xy, v, s;
}
vec3 normalize(const vec3 v)
@ -686,7 +686,7 @@ vec3 normalize(const vec3 v)
float tmp;
__asm vec3_dot tmp, v, v;
__asm float_rsq tmp, tmp;
__asm vec4_multiply __retVal.xyz, v, tmp.xxx;
__asm vec4_multiply __retVal.xyz, v, tmp;
}
vec4 normalize(const vec4 v)
@ -694,7 +694,7 @@ vec4 normalize(const vec4 v)
float tmp;
__asm vec4_dot tmp, v, v;
__asm float_rsq tmp, tmp;
__asm vec4_multiply __retVal.xyz, v, tmp.xxx;
__asm vec4_multiply __retVal.xyz, v, tmp;
}
@ -708,7 +708,7 @@ vec4 normalize(const vec4 v)
float abs(const float a)
{
__asm vec4_abs __retVal.x, a;
__asm vec4_abs __retVal, a;
}
vec2 abs(const vec2 a)
@ -732,9 +732,9 @@ vec4 abs(const vec4 a)
float sign(const float x)
{
float p, n;
__asm vec4_sgt p.x, x, 0.0; // p = (x > 0)
__asm vec4_sgt n.x, 0.0, x; // n = (x < 0)
__asm vec4_subtract __retVal.x, p, n; // sign = p - n
__asm vec4_sgt p, x, 0.0; // p = (x > 0)
__asm vec4_sgt n, 0.0, x; // n = (x < 0)
__asm vec4_subtract __retVal, p, n; // sign = p - n
}
vec2 sign(const vec2 v)
@ -766,7 +766,7 @@ vec4 sign(const vec4 v)
float floor(const float a)
{
__asm vec4_floor __retVal.x, a;
__asm vec4_floor __retVal, a;
}
vec2 floor(const vec2 a)
@ -792,7 +792,7 @@ float ceil(const float a)
// XXX this could be improved
float b = -a;
__asm vec4_floor b, b;
__retVal.x = -b;
__retVal = -b;
}
vec2 ceil(const vec2 a)
@ -821,7 +821,7 @@ vec4 ceil(const vec4 a)
float fract(const float a)
{
__asm vec4_frac __retVal.x, a;
__asm vec4_frac __retVal, a;
}
vec2 fract(const vec2 a)
@ -846,7 +846,7 @@ float mod(const float a, const float b)
{
float oneOverB;
__asm float_rcp oneOverB, b;
__retVal.x = a - b * floor(a * oneOverB);
__retVal = a - b * floor(a * oneOverB);
}
vec2 mod(const vec2 a, const float b)
@ -872,35 +872,29 @@ vec4 mod(const vec4 a, const float b)
vec2 mod(const vec2 a, const vec2 b)
{
float oneOverBx, oneOverBy;
__asm float_rcp oneOverBx, b.x;
__asm float_rcp oneOverBy, b.y;
__retVal.x = a.x - b.x * floor(a.x * oneOverBx);
__retVal.y = a.y - b.y * floor(a.y * oneOverBy);
vec2 oneOverB;
__asm float_rcp oneOverB.x, b.x;
__asm float_rcp oneOverB.y, b.y;
__retVal = a - b * floor(a * oneOverB);
}
vec3 mod(const vec3 a, const vec3 b)
{
float oneOverBx, oneOverBy, oneOverBz;
__asm float_rcp oneOverBx, b.x;
__asm float_rcp oneOverBy, b.y;
__asm float_rcp oneOverBz, b.z;
__retVal.x = a.x - b.x * floor(a.x * oneOverBx);
__retVal.y = a.y - b.y * floor(a.y * oneOverBy);
__retVal.z = a.z - b.z * floor(a.z * oneOverBz);
vec3 oneOverB;
__asm float_rcp oneOverB.x, b.x;
__asm float_rcp oneOverB.y, b.y;
__asm float_rcp oneOverB.z, b.z;
__retVal = a - b * floor(a * oneOverB);
}
vec4 mod(const vec4 a, const vec4 b)
{
float oneOverBx, oneOverBy, oneOverBz, oneOverBw;
__asm float_rcp oneOverBx, b.x;
__asm float_rcp oneOverBy, b.y;
__asm float_rcp oneOverBz, b.z;
__asm float_rcp oneOverBw, b.w;
__retVal.x = a.x - b.x * floor(a.x * oneOverBx);
__retVal.y = a.y - b.y * floor(a.y * oneOverBy);
__retVal.z = a.z - b.z * floor(a.z * oneOverBz);
__retVal.w = a.w - b.w * floor(a.w * oneOverBw);
vec4 oneOverB;
__asm float_rcp oneOverB.x, b.x;
__asm float_rcp oneOverB.y, b.y;
__asm float_rcp oneOverB.z, b.z;
__asm float_rcp oneOverB.w, b.w;
__retVal = a - b * floor(a * oneOverB);
}
@ -908,7 +902,7 @@ vec4 mod(const vec4 a, const vec4 b)
float min(const float a, const float b)
{
__asm vec4_min __retVal.x, a.x, b.x;
__asm vec4_min __retVal, a, b;
}
vec2 min(const vec2 a, const vec2 b)
@ -928,17 +922,17 @@ vec4 min(const vec4 a, const vec4 b)
vec2 min(const vec2 a, const float b)
{
__asm vec4_min __retVal, a.xy, b.xx;
__asm vec4_min __retVal, a.xy, b;
}
vec3 min(const vec3 a, const float b)
{
__asm vec4_min __retVal, a.xyz, b.xxx;
__asm vec4_min __retVal, a.xyz, b;
}
vec4 min(const vec4 a, const float b)
{
__asm vec4_min __retVal, a, b.xxxx;
__asm vec4_min __retVal, a, b;
}
@ -946,7 +940,7 @@ vec4 min(const vec4 a, const float b)
float max(const float a, const float b)
{
__asm vec4_max __retVal.x, a.x, b.x;
__asm vec4_max __retVal, a, b;
}
vec2 max(const vec2 a, const vec2 b)
@ -966,17 +960,17 @@ vec4 max(const vec4 a, const vec4 b)
vec2 max(const vec2 a, const float b)
{
__asm vec4_max __retVal, a.xy, b.xx;
__asm vec4_max __retVal, a.xy, b;
}
vec3 max(const vec3 a, const float b)
{
__asm vec4_max __retVal, a.xyz, b.xxx;
__asm vec4_max __retVal, a.xyz, b;
}
vec4 max(const vec4 a, const float b)
{
__asm vec4_max __retVal, a, b.xxxx;
__asm vec4_max __retVal, a, b;
}
@ -1056,45 +1050,45 @@ vec4 mix(const vec4 x, const vec4 y, const vec4 a)
}
//// step (untested)
//// step
float step(const float edge, const float x)
{
__asm vec4_sgt __retVal.x, x, edge;
__asm vec4_sge __retVal, x, edge;
}
vec2 step(const vec2 edge, const vec2 x)
{
__asm vec4_sgt __retVal.xy, x, edge;
__asm vec4_sge __retVal.xy, x, edge;
}
vec3 step(const vec3 edge, const vec3 x)
{
__asm vec4_sgt __retVal.xyz, x, edge;
__asm vec4_sge __retVal.xyz, x, edge;
}
vec4 step(const vec4 edge, const vec4 x)
{
__asm vec4_sgt __retVal, x, edge;
__asm vec4_sge __retVal, x, edge;
}
vec2 step(const float edge, const vec2 v)
{
__asm vec4_sgt __retVal.xy, v, edge.xx;
__asm vec4_sge __retVal.xy, v, edge;
}
vec3 step(const float edge, const vec3 v)
{
__asm vec4_sgt __retVal.xyz, v, edge.xxx;
__asm vec4_sge __retVal.xyz, v, edge;
}
vec4 step(const float edge, const vec4 v)
{
__asm vec4_sgt __retVal, v, edge.xxxx;
__asm vec4_sge __retVal, v, edge;
}
//// smoothstep (untested)
//// smoothstep
float smoothstep(const float edge0, const float edge1, const float x)
{
@ -1165,7 +1159,7 @@ float length(const vec3 v)
float r;
const float p = dot(v, v); // p = v.x * v.x + v.y * v.y + v.z * v.z
__asm float_rsq r, p; // r = 1 / sqrt(p)
__asm float_rcp __retVal.x, r; // retVal = 1 / r
__asm float_rcp __retVal, r; // retVal = 1 / r
}
float length(const vec4 v)
@ -1173,7 +1167,7 @@ float length(const vec4 v)
float r;
const float p = dot(v, v); // p = v.x * v.x + v.y * v.y + ...
__asm float_rsq r, p; // r = 1 / sqrt(p)
__asm float_rcp __retVal.x, r; // retVal = 1 / r
__asm float_rcp __retVal, r; // retVal = 1 / r
}
@ -1219,7 +1213,7 @@ float faceforward(const float N, const float I, const float Nref)
// this could probably be done better
const float d = dot(Nref, I);
float s;
__asm vec4_sgt s.x, 0.0, d; // s = (0.0 > d) ? 1 : 0
__asm vec4_sgt s, 0.0, d; // s = (0.0 > d) ? 1 : 0
return mix(-N, N, s);
}
@ -1228,7 +1222,7 @@ vec2 faceforward(const vec2 N, const vec2 I, const vec2 Nref)
// this could probably be done better
const float d = dot(Nref, I);
float s;
__asm vec4_sgt s.x, 0.0, d; // s = (0.0 > d) ? 1 : 0
__asm vec4_sgt s, 0.0, d; // s = (0.0 > d) ? 1 : 0
return mix(-N, N, s);
}
@ -1237,7 +1231,7 @@ vec3 faceforward(const vec3 N, const vec3 I, const vec3 Nref)
// this could probably be done better
const float d = dot(Nref, I);
float s;
__asm vec4_sgt s.x, 0.0, d; // s = (0.0 > d) ? 1 : 0
__asm vec4_sgt s, 0.0, d; // s = (0.0 > d) ? 1 : 0
return mix(-N, N, s);
}
@ -1246,7 +1240,7 @@ vec4 faceforward(const vec4 N, const vec4 I, const vec4 Nref)
// this could probably be done better
const float d = dot(Nref, I);
float s;
__asm vec4_sgt s.x, 0.0, d; // s = (0.0 > d) ? 1 : 0
__asm vec4_sgt s, 0.0, d; // s = (0.0 > d) ? 1 : 0
return mix(-N, N, s);
}
@ -1277,34 +1271,50 @@ vec4 reflect(const vec4 I, const vec4 N)
float refract(const float I, const float N, const float eta)
{
float k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I));
float n_dot_i = dot(N, I);
float k = 1.0 - eta * eta * (1.0 - n_dot_i * n_dot_i);
float retval;
if (k < 0.0)
return 0.0;
return eta * I - (eta * dot(N, I) + sqrt(k)) * N;
retval = 0.0;
else
retval = eta * I - (eta * n_dot_i + sqrt(k)) * N;
return retval;
}
vec2 refract(const vec2 I, const vec2 N, const float eta)
{
float k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I));
float n_dot_i = dot(N, I);
float k = 1.0 - eta * eta * (1.0 - n_dot_i * n_dot_i);
vec2 retval;
if (k < 0.0)
return 0.0;
return eta * I - (eta * dot(N, I) + sqrt(k)) * N;
retval = vec2(0.0);
else
retval = eta * I - (eta * n_dot_i + sqrt(k)) * N;
return retval;
}
vec3 refract(const vec3 I, const vec3 N, const float eta)
{
float k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I));
float n_dot_i = dot(N, I);
float k = 1.0 - eta * eta * (1.0 - n_dot_i * n_dot_i);
vec3 retval;
if (k < 0.0)
return 0.0;
return eta * I - (eta * dot(N, I) + sqrt(k)) * N;
retval = vec3(0.0);
else
retval = eta * I - (eta * n_dot_i + sqrt(k)) * N;
return retval;
}
vec4 refract(const vec4 I, const vec4 N, const float eta)
{
float k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I));
float n_dot_i = dot(N, I);
float k = 1.0 - eta * eta * (1.0 - n_dot_i * n_dot_i);
vec4 retval;
if (k < 0.0)
return 0.0;
return eta * I - (eta * dot(N, I) + sqrt(k)) * N;
retval = vec4(0.0);
else
retval = eta * I - (eta * n_dot_i + sqrt(k)) * N;
return retval;
}
@ -1418,7 +1428,7 @@ bvec4 greaterThan(const vec4 u, const vec4 v)
bvec2 greaterThan(const ivec2 u, const ivec2 v)
{
__asm vec4_sgt __retVal.xy, u, v;
__asm vec4_sgt __retVal.xy, u.xy, v.xy;
}
bvec3 greaterThan(const ivec3 u, const ivec3 v)
@ -1596,26 +1606,25 @@ bool any(const bvec4 v)
bool all (const bvec2 v)
{
float prod;
__asm vec4_multiply prod.x, v.x, v.y;
__asm vec4_sne __retVal.x, prod.x, 0.0;
return v.x && v.y;
__asm vec4_multiply prod, v.x, v.y;
__asm vec4_sne __retVal, prod, 0.0;
}
bool all (const bvec3 v)
{
float prod;
__asm vec4_multiply prod.x, v.x, v.y;
__asm vec4_multiply prod.x, prod.x, v.z;
__asm vec4_sne __retVal.x, prod.x, 0.0;
__asm vec4_multiply prod, v.x, v.y;
__asm vec4_multiply prod, prod, v.z;
__asm vec4_sne __retVal, prod, 0.0;
}
bool all (const bvec4 v)
{
float prod;
__asm vec4_multiply prod.x, v.x, v.y;
__asm vec4_multiply prod.x, prod.x, v.z;
__asm vec4_multiply prod.x, prod.x, v.w;
__asm vec4_sne __retVal.x, prod.x, 0.0;
__asm vec4_multiply prod, v.x, v.y;
__asm vec4_multiply prod, prod, v.z;
__asm vec4_multiply prod, prod, v.w;
__asm vec4_sne __retVal, prod, 0.0;
}

File diff suppressed because it is too large Load diff

View file

@ -107,7 +107,7 @@
int __constructor(const float f)
{
__asm float_to_int __retVal, f;
__asm vec4_to_ivec4 __retVal, f;
}
int __constructor(const bool b)
@ -122,14 +122,12 @@ int __constructor(const int i)
bool __constructor(const int i)
{
const float zero = 0.0;
__asm vec4_sne __retVal, i, zero;
__asm vec4_sne __retVal, i, 0.0;
}
bool __constructor(const float f)
{
const float zero = 0.0;
__asm vec4_sne __retVal, f, zero;
__asm vec4_sne __retVal, f, 0.0;
}
bool __constructor(const bool b)
@ -139,12 +137,12 @@ bool __constructor(const bool b)
float __constructor(const int i)
{
__asm int_to_float __retVal, i;
__asm ivec4_to_vec4 __retVal, i;
}
float __constructor(const bool b)
{
__retVal = b;
__asm ivec4_to_vec4 __retVal, b;
}
float __constructor(const float f)
@ -163,32 +161,33 @@ vec2 __constructor(const float x, const float y)
vec2 __constructor(const float f)
{
__retVal.xy = f.xx;
__asm vec4_move __retVal.xy, f;
}
vec2 __constructor(const int i)
{
__retVal.xy = i.xx;
__asm ivec4_to_vec4 __retVal.xy, i;
}
vec2 __constructor(const bool b)
{
__retVal.xy = b.xx;
__asm ivec4_to_vec4 __retVal.xy, b;
}
vec2 __constructor(const bvec2 b)
{
__retVal = b;
// __retVal = b;
__asm ivec4_to_vec4 __retVal.xy, b;
}
vec2 __constructor(const vec3 v)
{
__retVal.xy = v.xy;
__asm vec4_move __retVal.xy, v.xy;
}
vec2 __constructor(const vec4 v)
{
__retVal.st = v.xy;
__asm vec4_move __retVal.xy, v.xy;
}
@ -203,27 +202,28 @@ vec3 __constructor(const float x, const float y, const float z)
vec3 __constructor(const float f)
{
__retVal.xyz = f.xxx;
// Note: this could be "__retVal.xyz = f" but that's an illegal assignment
__asm vec4_move __retVal.xyz, f;
}
vec3 __constructor(const int i)
{
__asm int_to_float __retVal.xyz, i.xxx;
__asm ivec4_to_vec4 __retVal.xyz, i;
}
vec3 __constructor(const bool b)
{
__retVal.xyz = b.xxx;
__asm ivec4_to_vec4 __retVal.xyz, b;
}
vec3 __constructor(const bvec3 b)
{
__retVal = b;
__asm ivec4_to_vec4 __retVal.xyz, b;
}
vec3 __constructor(const vec4 v)
{
__retVal.xyz = v.xyz;
__asm vec4_move __retVal.xyz, v;
}
@ -239,22 +239,28 @@ vec4 __constructor(const float x, const float y, const float z, const float w)
vec4 __constructor(const float f)
{
__retVal = f.xxxx;
// Note: this could be "__retVal = f" but that's an illegal assignment
__asm vec4_move __retVal, f;
}
vec4 __constructor(const int i)
{
__retVal = i.xxxx;
__asm ivec4_to_vec4 __retVal, i;
}
vec4 __constructor(const bool b)
{
__retVal = b.xxxx;
__asm ivec4_to_vec4 __retVal, b;
}
vec4 __constructor(const bvec4 b)
{
__retVal = b;
__asm ivec4_to_vec4 __retVal, b;
}
vec4 __constructor(const ivec4 i)
{
__asm ivec4_to_vec4 __retVal, i;
}
vec4 __constructor(const vec3 v3, const float f)
@ -283,17 +289,17 @@ ivec2 __constructor(const int i, const int j)
ivec2 __constructor(const int i)
{
__retVal.xy = i.xx;
__asm vec4_move __retVal.xy, i;
}
ivec2 __constructor(const float f)
{
__asm float_to_int __retVal.xy, f.xx;
__asm vec4_to_ivec4 __retVal.xy, f;
}
ivec2 __constructor(const bool b)
{
__asm float_to_int __retVal.xy, b.xx;
__asm vec4_to_ivec4 __retVal.xy, b;
}
@ -308,17 +314,17 @@ ivec3 __constructor(const int i, const int j, const int k)
ivec3 __constructor(const int i)
{
__retVal.xyz = i.xxx;
__asm vec4_move __retVal.xyz, i;
}
ivec3 __constructor(const float f)
{
__retVal.xyz = f.xxx;
__asm vec4_to_ivec4 __retVal.xyz, f;
}
ivec3 __constructor(const bool b)
{
__retVal.xyz = b.xxx;
__asm vec4_move __retVal.xyz, b;
}
@ -334,17 +340,17 @@ ivec4 __constructor(const int x, const int y, const int z, const int w)
ivec4 __constructor(const int i)
{
__retVal = i.xxxx;
__asm vec4_move __retVal, i;
}
ivec4 __constructor(const float f)
{
__asm float_to_int __retVal, f.xxxx;
__asm vec4_to_ivec4 __retVal, f;
}
ivec4 __constructor(const bool b)
{
__retVal = b.xxxx;
__asm vec4_to_ivec4 __retVal, b;
}
@ -356,21 +362,26 @@ bvec2 __constructor(const bool b1, const bool b2)
__retVal.y = b2;
}
bvec2 __constructor(const int i1, const int i2)
{
__asm vec4_sne __retVal.x, i1, 0.0;
__asm vec4_sne __retVal.y, i2, 0.0;
}
bvec2 __constructor(const bool b)
{
__retVal.xy = b.xx;
__asm vec4_move __retVal.xy, b;
}
bvec2 __constructor(const float f)
{
const vec2 zero = vec2(0.0, 0.0);
__asm vec4_sne __retVal.xy, f.xx, zero;
__asm vec4_sne __retVal.xy, f, 0.0;
}
bvec2 __constructor(const int i)
{
const ivec2 zero = ivec2(0, 0);
__asm vec4_sne __retVal.xy, i.xx, zero;
__asm vec4_sne __retVal.xy, i, 0.0;
}
bvec2 __constructor(const vec2 v)
@ -380,8 +391,7 @@ bvec2 __constructor(const vec2 v)
bvec2 __constructor(const ivec2 v)
{
const ivec2 zero = ivec2(0, 0);
__asm vec4_sne __retVal.xy, v, zero;
__asm vec4_sne __retVal.xy, v, 0.0;
}
@ -395,33 +405,36 @@ bvec3 __constructor(const bool b1, const bool b2, const bool b3)
__retVal.z = b3;
}
bvec3 __constructor(const float f1, const float f2, const float f3)
{
__asm vec4_sne __retVal.x, f1, 0.0;
__asm vec4_sne __retVal.y, f2, 0.0;
__asm vec4_sne __retVal.z, f3, 0.0;
}
bvec3 __constructor(const bool b)
{
__retVal.xyz = b.xxx;
__asm vec4_move __retVal.xyz, b;
}
bvec3 __constructor(const float f)
{
const vec3 zero = vec3(0.0, 0.0, 0.0);
__asm vec4_sne __retVal.xyz, f.xxx, zero;
__asm vec4_sne __retVal.xyz, f, 0.0;
}
bvec3 __constructor(const int i)
{
const ivec3 zero = ivec3(0, 0, 0);
__asm vec4_sne __retVal.xyz, i.xxx, zero;
__asm vec4_sne __retVal.xyz, i, 0.0;
}
bvec3 __constructor(const vec3 v)
{
const vec3 zero = vec3(0.0, 0.0, 0.0);
__asm vec4_sne __retVal.xyz, v, zero;
__asm vec4_sne __retVal.xyz, v, 0.0;
}
bvec3 __constructor(const ivec3 v)
{
const ivec3 zero = ivec3(0, 0, 0);
__asm vec4_sne __retVal.xyz, v, zero;
__asm vec4_sne __retVal.xyz, v, 0.0;
}
@ -436,33 +449,38 @@ bvec4 __constructor(const bool b1, const bool b2, const bool b3, const bool b4)
__retVal.w = b4;
}
bvec4 __constructor(const float f1, const float f2, const float f3, const float f4)
{
const float zero = 0.0;
__asm vec4_sne __retVal.x, f1, zero;
__asm vec4_sne __retVal.y, f2, zero;
__asm vec4_sne __retVal.z, f3, zero;
__asm vec4_sne __retVal.w, f4, zero;
}
bvec4 __constructor(const bool b)
{
__retVal.xyzw = b.xxxx;
__asm vec4_move __retVal.xyzw, b;
}
bvec4 __constructor(const float f)
{
const vec4 zero = vec4(0.0, 0.0, 0.0, 0.0);
__asm vec4_sne __retVal, f.xxxx, zero;
__asm vec4_sne __retVal.xyzw, f, 0.0;
}
bvec4 __constructor(const int i)
{
const ivec4 zero = ivec4(0, 0, 0, 0);
__asm vec4_sne __retVal, i.xxxx, zero;
__asm vec4_sne __retVal.xyzw, i, 0.0;
}
bvec4 __constructor(const vec4 v)
{
const vec4 zero = vec4(0.0, 0.0, 0.0, 0.0);
__asm vec4_sne __retVal, v, zero;
__asm vec4_sne __retVal.xyzw, v, 0.0;
}
bvec4 __constructor(const ivec4 v)
{
const ivec4 zero = ivec4(0, 0, 0, 0);
__asm vec4_sne __retVal, v, zero;
__asm vec4_sne __retVal.xyzw, v, 0.0;
}
@ -605,30 +623,17 @@ mat4 __constructor(const vec4 c0, const vec4 c1, const vec4 c2, const vec4 c3)
int __operator + (const int a, const int b)
{
// XXX If we ever have int registers, we'll do something like this:
// XXX For now, mostly treat ints as floats.
// float x, y;
// __asm int_to_float x, a;
// __asm int_to_float y, b;
// __asm vec4_add x.x, x.x, y.x;
// __asm float_to_int __retVal, x;
float x;
__asm vec4_add x, a, b;
__asm float_to_int __retVal, x;
__asm vec4_add __retVal, a, b;
}
int __operator - (const int a, const int b)
{
float x;
__asm vec4_subtract x, a, b;
__asm float_to_int __retVal, x;
__asm vec4_subtract __retVal, a, b;
}
int __operator * (const int a, const int b)
{
float x;
__asm vec4_multiply x, a, b;
__asm float_to_int __retVal, x;
__asm vec4_multiply __retVal, a, b;
}
int __operator / (const int a, const int b)
@ -636,7 +641,7 @@ int __operator / (const int a, const int b)
float bInv, x;
__asm float_rcp bInv, b;
__asm vec4_multiply x, a, bInv;
__asm float_to_int __retVal, x;
__asm vec4_to_ivec4 __retVal, x;
}
@ -644,23 +649,17 @@ int __operator / (const int a, const int b)
ivec2 __operator + (const ivec2 a, const ivec2 b)
{
vec2 x;
__asm vec4_add x, a, b;
__asm float_to_int __retVal, x;
__asm vec4_add __retVal, a, b;
}
ivec2 __operator - (const ivec2 a, const ivec2 b)
{
vec2 x;
__asm vec4_subtract x, a, b;
__asm float_to_int __retVal, x;
__asm vec4_subtract __retVal, a, b;
}
ivec2 __operator * (const ivec2 a, const ivec2 b)
{
vec2 x;
__asm vec4_multiply x, a, b;
__asm float_to_int __retVal, x;
__asm vec4_multiply __retVal, a, b;
}
ivec2 __operator / (const ivec2 a, const ivec2 b)
@ -669,7 +668,7 @@ ivec2 __operator / (const ivec2 a, const ivec2 b)
__asm float_rcp bInv.x, b.x;
__asm float_rcp bInv.y, b.y;
__asm vec4_multiply x, a, bInv;
__asm float_to_int __retVal, x;
__asm vec4_to_ivec4 __retVal, x;
}
@ -677,23 +676,17 @@ ivec2 __operator / (const ivec2 a, const ivec2 b)
ivec3 __operator + (const ivec3 a, const ivec3 b)
{
vec3 x;
__asm vec4_add x, a, b;
__asm float_to_int __retVal, x;
__asm vec4_add __retVal, a, b;
}
ivec3 __operator - (const ivec3 a, const ivec3 b)
{
vec3 x;
__asm vec4_subtract x, a, b;
__asm float_to_int __retVal, x;
__asm vec4_subtract __retVal, a, b;
}
ivec3 __operator * (const ivec3 a, const ivec3 b)
{
vec3 x;
__asm vec4_multiply x, a, b;
__asm float_to_int __retVal, x;
__asm vec4_multiply __retVal, a, b;
}
ivec3 __operator / (const ivec3 a, const ivec3 b)
@ -703,7 +696,7 @@ ivec3 __operator / (const ivec3 a, const ivec3 b)
__asm float_rcp bInv.y, b.y;
__asm float_rcp bInv.z, b.z;
__asm vec4_multiply x, a, bInv;
__asm float_to_int __retVal, x;
__asm vec4_to_ivec4 __retVal, x;
}
@ -711,23 +704,17 @@ ivec3 __operator / (const ivec3 a, const ivec3 b)
ivec4 __operator + (const ivec4 a, const ivec4 b)
{
vec3 x;
__asm vec4_add x, a, b;
__asm float_to_int __retVal, x;
__asm vec4_add __retVal, a, b;
}
ivec4 __operator - (const ivec4 a, const ivec4 b)
{
vec4 x;
__asm vec4_subtract x, a, b;
__asm float_to_int __retVal, x;
__asm vec4_subtract __retVal, a, b;
}
ivec4 __operator * (const ivec4 a, const ivec4 b)
{
vec4 x;
__asm vec4_multiply x, a, b;
__asm float_to_int __retVal, x;
__asm vec4_multiply __retVal, a, b;
}
ivec4 __operator / (const ivec4 a, const ivec4 b)
@ -738,7 +725,7 @@ ivec4 __operator / (const ivec4 a, const ivec4 b)
__asm float_rcp bInv.z, b.z;
__asm float_rcp bInv.w, b.w;
__asm vec4_multiply x, a, bInv;
__asm float_to_int __retVal, x;
__asm vec4_to_ivec4 __retVal, x;
}
@ -746,24 +733,24 @@ ivec4 __operator / (const ivec4 a, const ivec4 b)
float __operator + (const float a, const float b)
{
__asm vec4_add __retVal.x, a, b;
__asm vec4_add __retVal, a, b;
}
float __operator - (const float a, const float b)
{
__asm vec4_subtract __retVal.x, a, b;
__asm vec4_subtract __retVal, a, b;
}
float __operator * (const float a, const float b)
{
__asm vec4_multiply __retVal.x, a, b;
__asm vec4_multiply __retVal, a, b;
}
float __operator / (const float a, const float b)
{
float bInv;
__asm float_rcp bInv.x, b.x;
__asm vec4_multiply __retVal.x, a, bInv;
__asm float_rcp bInv.x, b;
__asm vec4_multiply __retVal, a, bInv;
}
@ -854,32 +841,32 @@ vec4 __operator / (const vec4 v, const vec4 u)
vec2 __operator + (const float a, const vec2 u)
{
__asm vec4_add __retVal.xy, a.xx, u.xy;
__asm vec4_add __retVal.xy, a, u.xy;
}
vec2 __operator + (const vec2 v, const float b)
{
__asm vec4_add __retVal.xy, v.xy, b.xx;
__asm vec4_add __retVal.xy, v.xy, b;
}
vec2 __operator - (const float a, const vec2 u)
{
__asm vec4_subtract __retVal.xy, a.xx, u.xy;
__asm vec4_subtract __retVal.xy, a, u.xy;
}
vec2 __operator - (const vec2 v, const float b)
{
__asm vec4_subtract __retVal.xy, v.xy, b.xx;
__asm vec4_subtract __retVal.xy, v.xy, b;
}
vec2 __operator * (const float a, const vec2 u)
{
__asm vec4_multiply __retVal.xy, a.xx, u.xy;
__asm vec4_multiply __retVal.xy, a, u.xy;
}
vec2 __operator * (const vec2 v, const float b)
{
__asm vec4_multiply __retVal.xy, v.xy, b.xx;
__asm vec4_multiply __retVal.xy, v.xy, b;
}
vec2 __operator / (const float a, const vec2 u)
@ -887,14 +874,14 @@ vec2 __operator / (const float a, const vec2 u)
vec2 invU;
__asm float_rcp invU.x, u.x;
__asm float_rcp invU.y, u.y;
__asm vec4_multiply __retVal.xy, a.xx, invU.xy;
__asm vec4_multiply __retVal.xy, a, invU.xy;
}
vec2 __operator / (const vec2 v, const float b)
{
float invB;
__asm float_rcp invB, b;
__asm vec4_multiply __retVal.xy, v.xy, invB.xx;
__asm vec4_multiply __retVal.xy, v.xy, invB;
}
@ -902,32 +889,32 @@ vec2 __operator / (const vec2 v, const float b)
vec3 __operator + (const float a, const vec3 u)
{
__asm vec4_add __retVal.xyz, a.xxx, u.xyz;
__asm vec4_add __retVal.xyz, a, u.xyz;
}
vec3 __operator + (const vec3 v, const float b)
{
__asm vec4_add __retVal.xyz, v.xyz, b.xxx;
__asm vec4_add __retVal.xyz, v.xyz, b;
}
vec3 __operator - (const float a, const vec3 u)
{
__asm vec4_subtract __retVal.xyz, a.xxx, u.xyz;
__asm vec4_subtract __retVal.xyz, a, u.xyz;
}
vec3 __operator - (const vec3 v, const float b)
{
__asm vec4_subtract __retVal.xyz, v.xyz, b.xxx;
__asm vec4_subtract __retVal.xyz, v.xyz, b;
}
vec3 __operator * (const float a, const vec3 u)
{
__asm vec4_multiply __retVal.xyz, a.xxx, u.xyz;
__asm vec4_multiply __retVal.xyz, a, u.xyz;
}
vec3 __operator * (const vec3 v, const float b)
{
__asm vec4_multiply __retVal.xyz, v.xyz, b.xxx;
__asm vec4_multiply __retVal.xyz, v.xyz, b;
}
vec3 __operator / (const float a, const vec3 u)
@ -936,14 +923,14 @@ vec3 __operator / (const float a, const vec3 u)
__asm float_rcp invU.x, u.x;
__asm float_rcp invU.y, u.y;
__asm float_rcp invU.z, u.z;
__asm vec4_multiply __retVal.xyz, a.xxx, invU.xyz;
__asm vec4_multiply __retVal.xyz, a, invU.xyz;
}
vec3 __operator / (const vec3 v, const float b)
{
float invB;
__asm float_rcp invB, b;
__asm vec4_multiply __retVal.xyz, v.xyz, invB.xxx;
__asm vec4_multiply __retVal.xyz, v.xyz, invB;
}
@ -951,32 +938,32 @@ vec3 __operator / (const vec3 v, const float b)
vec4 __operator + (const float a, const vec4 u)
{
__asm vec4_add __retVal, a.xxxx, u;
__asm vec4_add __retVal, a, u;
}
vec4 __operator + (const vec4 v, const float b)
{
__asm vec4_add __retVal, v, b.xxxx;
__asm vec4_add __retVal, v, b;
}
vec4 __operator - (const float a, const vec4 u)
{
__asm vec4_subtract __retVal, a.xxxx, u;
__asm vec4_subtract __retVal, a, u;
}
vec4 __operator - (const vec4 v, const float b)
{
__asm vec4_subtract __retVal, v, b.xxxx;
__asm vec4_subtract __retVal, v, b;
}
vec4 __operator * (const float a, const vec4 u)
{
__asm vec4_multiply __retVal, a.xxxx, u;
__asm vec4_multiply __retVal, a, u;
}
vec4 __operator * (const vec4 v, const float b)
{
__asm vec4_multiply __retVal, v, b.xxxx;
__asm vec4_multiply __retVal, v, b;
}
vec4 __operator / (const float a, const vec4 u)
@ -986,14 +973,14 @@ vec4 __operator / (const float a, const vec4 u)
__asm float_rcp invU.y, u.y;
__asm float_rcp invU.z, u.z;
__asm float_rcp invU.w, u.w;
__asm vec4_multiply __retVal, a.xxxx, invU;
__asm vec4_multiply __retVal, a, invU;
}
vec4 __operator / (const vec4 v, const float b)
{
float invB;
__asm float_rcp invB, b;
__asm vec4_multiply __retVal, v, invB.xxxx;
__asm vec4_multiply __retVal, v, invB;
}
@ -1240,7 +1227,7 @@ void __operator /= (inout int a, const int b)
float invB;
__asm float_rcp invB, b;
__asm vec4_multiply a, a, invB;
__asm float_to_int a, a;
__asm vec4_to_ivec4 a, a;
}
@ -1267,7 +1254,7 @@ void __operator /= (inout ivec2 v, const ivec2 u)
__asm float_rcp inv.x, u.x;
__asm float_rcp inv.y, u.y;
__asm vec4_multiply z, v, inv;
__asm float_to_int v, z;
__asm vec4_to_ivec4 v, z;
}
@ -1294,7 +1281,7 @@ void __operator /= (inout ivec3 v, const ivec3 u)
__asm float_rcp inv.x, u.x;
__asm float_rcp inv.y, u.y;
__asm vec4_multiply z, v, inv;
__asm float_to_int v, z;
__asm vec4_to_ivec4 v, z;
}
@ -1321,7 +1308,7 @@ void __operator /= (inout ivec4 v, const ivec4 u)
__asm float_rcp inv.x, u.x;
__asm float_rcp inv.y, u.y;
__asm vec4_multiply z, v, inv;
__asm float_to_int v, z;
__asm vec4_to_ivec4 v, z;
}
@ -1436,17 +1423,17 @@ void __operator /= (inout vec4 v, const vec4 u)
void __operator += (inout ivec2 v, const int a)
{
__asm vec4_add v.xy, v.xy, a.xx;
__asm vec4_add v.xy, v.xy, a;
}
void __operator -= (inout ivec2 v, const int a)
{
__asm vec4_subtract v.xy, v.xy, a.xx;
__asm vec4_subtract v.xy, v.xy, a;
}
void __operator *= (inout ivec2 v, const int a)
{
__asm vec4_multiply v.xy, v.xy, a.xx;
__asm vec4_multiply v.xy, v.xy, a;
v.x *= a;
v.y *= a;
}
@ -1463,17 +1450,17 @@ void __operator /= (inout ivec2 v, const int a)
void __operator += (inout ivec3 v, const int a)
{
__asm vec4_add v.xyz, v.xyz, a.xxx;
__asm vec4_add v.xyz, v.xyz, a;
}
void __operator -= (inout ivec3 v, const int a)
{
__asm vec4_subtract v.xyz, v.xyz, a.xxx;
__asm vec4_subtract v.xyz, v.xyz, a;
}
void __operator *= (inout ivec3 v, const int a)
{
__asm vec4_multiply v.xyz, v.xyz, a.xxx;
__asm vec4_multiply v.xyz, v.xyz, a;
}
void __operator /= (inout ivec3 v, const int a)
@ -1489,17 +1476,17 @@ void __operator /= (inout ivec3 v, const int a)
void __operator += (inout ivec4 v, const int a)
{
__asm vec4_add v, v, a.xxxx;
__asm vec4_add v, v, a;
}
void __operator -= (inout ivec4 v, const int a)
{
__asm vec4_subtract v, v, a.xxxx;
__asm vec4_subtract v, v, a;
}
void __operator *= (inout ivec4 v, const int a)
{
__asm vec4_multiply v, v, a.xxxx;
__asm vec4_multiply v, v, a;
}
void __operator /= (inout ivec4 v, const int a)
@ -1516,24 +1503,24 @@ void __operator /= (inout ivec4 v, const int a)
void __operator += (inout vec2 v, const float a)
{
__asm vec4_add v.xy, v, a.xx;
__asm vec4_add v.xy, v, a;
}
void __operator -= (inout vec2 v, const float a)
{
__asm vec4_subtract v.xy, v, a.xx;
__asm vec4_subtract v.xy, v, a;
}
void __operator *= (inout vec2 v, const float a)
{
__asm vec4_multiply v.xy, v, a.xx;
__asm vec4_multiply v.xy, v, a;
}
void __operator /= (inout vec2 v, const float a)
{
float invA;
__asm float_rcp invA, a;
__asm vec4_multiply v.xy, v.xy, invA.xx;
__asm vec4_multiply v.xy, v.xy, invA;
}
@ -1541,24 +1528,24 @@ void __operator /= (inout vec2 v, const float a)
void __operator += (inout vec3 v, const float a)
{
__asm vec4_add v.xyz, v, a.xxx;
__asm vec4_add v.xyz, v, a;
}
void __operator -= (inout vec3 v, const float a)
{
__asm vec4_subtract v.xyz, v, a.xxx;
__asm vec4_subtract v.xyz, v, a;
}
void __operator *= (inout vec3 v, const float a)
{
__asm vec4_multiply v.xyz, v, a.xxx;
__asm vec4_multiply v.xyz, v, a;
}
void __operator /= (inout vec3 v, const float a)
{
float invA;
__asm float_rcp invA, a;
__asm vec4_multiply v.xyz, v.xyz, invA.xxx;
__asm vec4_multiply v.xyz, v.xyz, invA;
}
@ -1566,24 +1553,24 @@ void __operator /= (inout vec3 v, const float a)
void __operator += (inout vec4 v, const float a)
{
__asm vec4_add v, v, a.xxxx;
__asm vec4_add v, v, a;
}
void __operator -= (inout vec4 v, const float a)
{
__asm vec4_subtract v, v, a.xxxx;
__asm vec4_subtract v, v, a;
}
void __operator *= (inout vec4 v, const float a)
{
__asm vec4_multiply v, v, a.xxxx;
__asm vec4_multiply v, v, a;
}
void __operator /= (inout vec4 v, const float a)
{
float invA;
__asm float_rcp invA, a;
__asm vec4_multiply v, v, invA.xxxx;
__asm vec4_multiply v, v, invA;
}

File diff suppressed because it is too large Load diff

View file

@ -2,98 +2,100 @@
/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE FOLLOWING FILE: */
/* slang_fragment_builtin.gc */
3,2,2,6,12,1,103,108,95,70,114,97,103,67,111,111,114,100,0,0,0,2,2,6,1,1,103,108,95,70,114,111,110,
116,70,97,99,105,110,103,0,0,0,2,2,5,12,1,103,108,95,70,114,97,103,67,111,108,111,114,0,0,0,2,2,5,
12,1,103,108,95,70,114,97,103,68,97,116,97,0,3,18,103,108,95,77,97,120,68,114,97,119,66,117,102,
102,101,114,115,0,0,0,2,2,5,9,1,103,108,95,70,114,97,103,68,101,112,116,104,0,0,0,2,2,3,12,1,103,
108,95,67,111,108,111,114,0,0,0,2,2,3,12,1,103,108,95,83,101,99,111,110,100,97,114,121,67,111,108,
111,114,0,0,0,2,2,3,12,1,103,108,95,84,101,120,67,111,111,114,100,0,3,18,103,108,95,77,97,120,84,
101,120,116,117,114,101,67,111,111,114,100,115,0,0,0,2,2,3,9,1,103,108,95,70,111,103,70,114,97,103,
67,111,111,114,100,0,0,0,1,0,12,0,116,101,120,116,117,114,101,49,68,0,1,1,0,16,115,97,109,112,108,
101,114,0,0,1,1,0,9,99,111,111,114,100,0,0,1,1,0,9,98,105,97,115,0,0,0,1,3,2,0,12,1,99,111,111,114,
100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,0,18,99,111,111,114,100,0,20,0,9,18,99,111,111,
114,100,52,0,59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,95,116,101,120,98,49,100,0,18,95,95,
114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,0,
12,0,116,101,120,116,117,114,101,49,68,80,114,111,106,0,1,1,0,16,115,97,109,112,108,101,114,0,0,1,
1,0,10,99,111,111,114,100,0,0,1,1,0,9,98,105,97,115,0,0,0,1,3,2,0,12,1,112,99,111,111,114,100,0,0,
0,9,18,112,99,111,111,114,100,0,59,120,0,18,99,111,111,114,100,0,59,120,0,18,99,111,111,114,100,0,
59,121,0,49,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,95,
4,2,2,6,0,12,1,103,108,95,70,114,97,103,67,111,111,114,100,0,0,0,2,2,6,0,1,1,103,108,95,70,114,111,
110,116,70,97,99,105,110,103,0,0,0,2,2,5,0,12,1,103,108,95,70,114,97,103,67,111,108,111,114,0,0,0,
2,2,5,0,12,1,103,108,95,70,114,97,103,68,97,116,97,0,3,18,103,108,95,77,97,120,68,114,97,119,66,
117,102,102,101,114,115,0,0,0,2,2,5,0,9,1,103,108,95,70,114,97,103,68,101,112,116,104,0,0,0,2,2,3,
0,12,1,103,108,95,67,111,108,111,114,0,0,0,2,2,3,0,12,1,103,108,95,83,101,99,111,110,100,97,114,
121,67,111,108,111,114,0,0,0,2,2,3,0,12,1,103,108,95,84,101,120,67,111,111,114,100,0,3,18,103,108,
95,77,97,120,84,101,120,116,117,114,101,67,111,111,114,100,115,0,0,0,2,2,3,0,9,1,103,108,95,70,111,
103,70,114,97,103,67,111,111,114,100,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,49,68,0,1,1,0,16,
115,97,109,112,108,101,114,0,0,1,1,0,9,99,111,111,114,100,0,0,1,1,0,9,98,105,97,115,0,0,0,1,3,2,0,
0,12,1,99,111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,0,18,99,111,111,114,100,0,
20,0,9,18,99,111,111,114,100,52,0,59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,95,116,101,120,
98,49,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,
100,52,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,49,68,80,114,111,106,0,1,1,0,16,115,97,109,
112,108,101,114,0,0,1,1,0,10,99,111,111,114,100,0,0,1,1,0,9,98,105,97,115,0,0,0,1,3,2,0,0,12,1,112,
99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,0,18,99,111,111,114,100,0,59,120,0,
18,99,111,111,114,100,0,59,121,0,49,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,98,105,97,115,0,
20,0,4,118,101,99,52,95,116,101,120,98,49,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,
112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,49,68,
80,114,111,106,0,1,1,0,16,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,1,1,0,9,
98,105,97,115,0,0,0,1,3,2,0,0,12,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,
120,0,18,99,111,111,114,100,0,59,120,0,18,99,111,111,114,100,0,59,122,0,49,20,0,9,18,112,99,111,
111,114,100,0,59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,95,116,101,120,98,49,100,0,18,95,95,
114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,
0,12,0,116,101,120,116,117,114,101,50,68,0,1,1,0,17,115,97,109,112,108,101,114,0,0,1,1,0,10,99,111,
111,114,100,0,0,1,1,0,9,98,105,97,115,0,0,0,1,3,2,0,0,12,1,99,111,111,114,100,52,0,0,0,9,18,99,111,
111,114,100,52,0,59,120,121,0,18,99,111,111,114,100,0,59,120,121,0,20,0,9,18,99,111,111,114,100,52,
0,59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,95,116,101,120,98,50,100,0,18,95,95,114,101,116,
86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,0,0,12,0,116,
101,120,116,117,114,101,50,68,80,114,111,106,0,1,1,0,17,115,97,109,112,108,101,114,0,0,1,1,0,11,99,
111,111,114,100,0,0,1,1,0,9,98,105,97,115,0,0,0,1,3,2,0,0,12,1,112,99,111,111,114,100,0,0,0,9,18,
112,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,
59,122,0,49,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,95,
116,101,120,98,50,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,
112,99,111,111,114,100,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,50,68,80,114,111,106,0,1,1,0,
17,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,1,1,0,9,98,105,97,115,0,0,0,1,3,
2,0,0,12,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,121,0,18,99,111,111,
114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,119,0,49,20,0,9,18,112,99,111,111,114,100,0,59,
119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,95,116,101,120,98,50,100,0,18,95,95,114,101,116,86,
97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,0,12,0,116,101,
120,116,117,114,101,51,68,0,1,1,0,18,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,111,114,100,0,
0,1,1,0,9,98,105,97,115,0,0,0,1,3,2,0,0,12,1,99,111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,
52,0,59,120,121,122,0,18,99,111,111,114,100,0,59,120,121,122,0,20,0,9,18,99,111,111,114,100,52,0,
59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,95,116,101,120,98,51,100,0,18,95,95,114,101,116,
86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,0,0,12,0,116,
101,120,116,117,114,101,51,68,80,114,111,106,0,1,1,0,18,115,97,109,112,108,101,114,0,0,1,1,0,12,99,
111,111,114,100,0,0,1,1,0,9,98,105,97,115,0,0,0,1,3,2,0,0,12,1,112,99,111,111,114,100,0,0,0,9,18,
112,99,111,111,114,100,0,59,120,121,122,0,18,99,111,111,114,100,0,59,120,121,122,0,18,99,111,111,
114,100,0,59,119,0,49,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,98,105,97,115,0,20,0,4,118,
101,99,52,95,116,101,120,98,51,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,
114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,67,117,98,101,0,1,
1,0,19,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,111,114,100,0,0,1,1,0,9,98,105,97,115,0,0,0,
1,3,2,0,0,12,1,99,111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,121,122,0,18,99,111,
111,114,100,0,20,0,9,18,99,111,111,114,100,52,0,59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,
95,116,101,120,99,117,98,101,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,
0,18,99,111,111,114,100,52,0,0,0,0,1,0,0,12,0,115,104,97,100,111,119,49,68,0,1,1,0,20,115,97,109,
112,108,101,114,0,0,1,1,0,11,99,111,111,114,100,0,0,1,1,0,9,98,105,97,115,0,0,0,1,3,2,0,0,12,1,99,
111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,121,122,0,18,99,111,111,114,100,0,20,
0,9,18,99,111,111,114,100,52,0,59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,95,116,101,120,98,
49,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,
100,52,0,0,0,0,1,0,0,12,0,115,104,97,100,111,119,49,68,80,114,111,106,0,1,1,0,20,115,97,109,112,
108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,1,1,0,9,98,105,97,115,0,0,0,1,3,2,0,0,12,1,112,99,
111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,0,18,99,111,111,114,100,0,59,120,0,18,
99,111,111,114,100,0,59,119,0,49,20,0,9,18,112,99,111,111,114,100,0,59,122,0,18,99,111,111,114,100,
0,59,122,0,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,95,
116,101,120,98,49,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,
112,99,111,111,114,100,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,49,68,80,114,111,106,0,1,1,0,
16,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,1,1,0,9,98,105,97,115,0,0,0,1,3,
2,0,12,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,0,18,99,111,111,114,100,
0,59,120,0,18,99,111,111,114,100,0,59,122,0,49,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,98,
105,97,115,0,20,0,4,118,101,99,52,95,116,101,120,98,49,100,0,18,95,95,114,101,116,86,97,108,0,0,18,
115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,12,0,116,101,120,116,117,114,
101,50,68,0,1,1,0,17,115,97,109,112,108,101,114,0,0,1,1,0,10,99,111,111,114,100,0,0,1,1,0,9,98,105,
97,115,0,0,0,1,3,2,0,12,1,99,111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,121,0,18,
99,111,111,114,100,0,59,120,121,0,20,0,9,18,99,111,111,114,100,52,0,59,119,0,18,98,105,97,115,0,20,
0,4,118,101,99,52,95,116,101,120,98,50,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,
108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,50,68,80,114,
111,106,0,1,1,0,17,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,111,114,100,0,0,1,1,0,9,98,105,
97,115,0,0,0,1,3,2,0,12,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,121,0,
18,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,122,0,49,20,0,9,18,112,99,111,111,
114,100,0,59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,95,116,101,120,98,50,100,0,18,95,95,114,
101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,12,0,
116,101,120,116,117,114,101,50,68,80,114,111,106,0,1,1,0,17,115,97,109,112,108,101,114,0,0,1,1,0,
12,99,111,111,114,100,0,0,1,1,0,9,98,105,97,115,0,0,0,1,3,2,0,12,1,112,99,111,111,114,100,0,0,0,9,
18,112,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,
100,0,59,119,0,49,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,
52,95,116,101,120,98,50,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,
18,112,99,111,111,114,100,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,51,68,0,1,1,0,18,115,97,109,
112,108,101,114,0,0,1,1,0,11,99,111,111,114,100,0,0,1,1,0,9,98,105,97,115,0,0,0,1,3,2,0,12,1,99,
111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,121,122,0,18,99,111,111,114,100,0,59,
120,121,122,0,20,0,9,18,99,111,111,114,100,52,0,59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,
95,116,101,120,98,51,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,
99,111,111,114,100,52,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,51,68,80,114,111,106,0,1,1,0,18,
115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,1,1,0,9,98,105,97,115,0,0,0,1,3,2,0,
12,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,121,122,0,18,99,111,111,114,
100,0,59,120,121,122,0,18,99,111,111,114,100,0,59,119,0,49,20,0,9,18,112,99,111,111,114,100,0,59,
119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,95,116,101,120,98,51,100,0,18,95,95,114,101,116,86,
97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,12,0,116,101,
120,116,117,114,101,67,117,98,101,0,1,1,0,19,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,111,
114,100,0,0,1,1,0,9,98,105,97,115,0,0,0,1,3,2,0,12,1,99,111,111,114,100,52,0,0,0,9,18,99,111,111,
114,100,52,0,59,120,121,122,0,18,99,111,111,114,100,0,20,0,9,18,99,111,111,114,100,52,0,59,119,0,
18,98,105,97,115,0,20,0,4,118,101,99,52,95,116,101,120,99,117,98,101,0,18,95,95,114,101,116,86,97,
108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,0,12,0,115,104,97,100,
111,119,49,68,0,1,1,0,20,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,111,114,100,0,0,1,1,0,9,98,
105,97,115,0,0,0,1,3,2,0,12,1,99,111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,121,
122,0,18,99,111,111,114,100,0,20,0,9,18,99,111,111,114,100,52,0,59,119,0,18,98,105,97,115,0,20,0,4,
118,101,99,52,95,116,101,120,98,49,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,
101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,0,12,0,115,104,97,100,111,119,49,68,80,114,111,106,
0,1,1,0,20,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,1,1,0,9,98,105,97,115,0,
0,0,1,3,2,0,12,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,0,18,99,111,111,
114,100,0,59,120,0,18,99,111,111,114,100,0,59,119,0,49,20,0,9,18,112,99,111,111,114,100,0,59,122,0,
18,99,111,111,114,100,0,59,122,0,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,98,105,97,115,0,20,
0,4,118,101,99,52,95,116,101,120,98,49,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,
108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,12,0,115,104,97,100,111,119,50,68,0,1,1,0,21,
115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,111,114,100,0,0,1,1,0,9,98,105,97,115,0,0,0,1,3,2,0,
12,1,99,111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,121,122,0,18,99,111,111,114,
100,0,20,0,9,18,99,111,111,114,100,52,0,59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,95,116,
101,120,98,50,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,
111,114,100,52,0,0,0,0,1,0,12,0,115,104,97,100,111,119,50,68,80,114,111,106,0,1,1,0,21,115,97,109,
112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,1,1,0,9,98,105,97,115,0,0,0,1,3,2,0,12,1,112,
99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,120,
121,0,18,99,111,111,114,100,0,59,119,0,49,20,0,9,18,112,99,111,111,114,100,0,59,122,0,18,99,111,
111,114,100,0,59,122,0,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,98,105,97,115,0,20,0,4,118,
101,99,52,95,116,101,120,98,50,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,
114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,9,0,100,70,100,120,0,1,1,0,9,112,0,0,0,1,4,118,101,
99,52,95,100,100,120,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,112,0,59,120,120,120,120,0,0,
0,0,1,0,10,0,100,70,100,120,0,1,1,0,10,112,0,0,0,1,4,118,101,99,52,95,100,100,120,0,18,95,95,114,
101,116,86,97,108,0,59,120,121,0,0,18,112,0,59,120,121,121,121,0,0,0,0,1,0,11,0,100,70,100,120,0,1,
1,0,11,112,0,0,0,1,4,118,101,99,52,95,100,100,120,0,18,95,95,114,101,116,86,97,108,0,59,120,121,
122,0,0,18,112,0,59,120,121,122,122,0,0,0,0,1,0,12,0,100,70,100,120,0,1,1,0,12,112,0,0,0,1,4,118,
101,99,52,95,100,100,120,0,18,95,95,114,101,116,86,97,108,0,0,18,112,0,0,0,0,1,0,9,0,100,70,100,
121,0,1,1,0,9,112,0,0,0,1,4,118,101,99,52,95,100,100,121,0,18,95,95,114,101,116,86,97,108,0,59,120,
0,0,18,112,0,59,120,120,120,120,0,0,0,0,1,0,10,0,100,70,100,121,0,1,1,0,10,112,0,0,0,1,4,118,101,
99,52,95,100,100,121,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,112,0,59,120,121,121,121,
0,0,0,0,1,0,11,0,100,70,100,121,0,1,1,0,11,112,0,0,0,1,4,118,101,99,52,95,100,100,121,0,18,95,95,
114,101,116,86,97,108,0,59,120,121,122,0,0,18,112,0,59,120,121,122,122,0,0,0,0,1,0,12,0,100,70,100,
121,0,1,1,0,12,112,0,0,0,1,4,118,101,99,52,95,100,100,121,0,18,95,95,114,101,116,86,97,108,0,0,18,
112,0,0,0,0,1,0,9,0,102,119,105,100,116,104,0,1,1,0,9,112,0,0,0,1,8,58,97,98,115,0,58,100,70,100,
120,0,18,112,0,0,0,0,0,58,97,98,115,0,58,100,70,100,121,0,18,112,0,0,0,0,0,46,0,0,1,0,10,0,102,119,
105,100,116,104,0,1,1,0,10,112,0,0,0,1,8,58,97,98,115,0,58,100,70,100,120,0,18,112,0,0,0,0,0,58,97,
98,115,0,58,100,70,100,121,0,18,112,0,0,0,0,0,46,0,0,1,0,11,0,102,119,105,100,116,104,0,1,1,0,11,
112,0,0,0,1,8,58,97,98,115,0,58,100,70,100,120,0,18,112,0,0,0,0,0,58,97,98,115,0,58,100,70,100,121,
0,18,112,0,0,0,0,0,46,0,0,1,0,12,0,102,119,105,100,116,104,0,1,1,0,12,112,0,0,0,1,8,58,97,98,115,0,
58,100,70,100,120,0,18,112,0,0,0,0,0,58,97,98,115,0,58,100,70,100,121,0,18,112,0,0,0,0,0,46,0,0,0
112,99,111,111,114,100,0,0,0,0,1,0,0,12,0,115,104,97,100,111,119,50,68,0,1,1,0,21,115,97,109,112,
108,101,114,0,0,1,1,0,11,99,111,111,114,100,0,0,1,1,0,9,98,105,97,115,0,0,0,1,3,2,0,0,12,1,99,111,
111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,121,122,0,18,99,111,111,114,100,0,20,0,9,
18,99,111,111,114,100,52,0,59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,95,116,101,120,98,50,
100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,
52,0,0,0,0,1,0,0,12,0,115,104,97,100,111,119,50,68,80,114,111,106,0,1,1,0,21,115,97,109,112,108,
101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,1,1,0,9,98,105,97,115,0,0,0,1,3,2,0,0,12,1,112,99,111,
111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,120,121,0,
18,99,111,111,114,100,0,59,119,0,49,20,0,9,18,112,99,111,111,114,100,0,59,122,0,18,99,111,111,114,
100,0,59,122,0,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,98,105,97,115,0,20,0,4,118,101,99,52,
95,116,101,120,98,50,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,
112,99,111,111,114,100,0,0,0,0,1,0,0,9,0,100,70,100,120,0,1,1,0,9,112,0,0,0,1,4,118,101,99,52,95,
100,100,120,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18,112,0,59,120,120,120,120,0,0,0,0,1,0,
0,10,0,100,70,100,120,0,1,1,0,10,112,0,0,0,1,4,118,101,99,52,95,100,100,120,0,18,95,95,114,101,116,
86,97,108,0,59,120,121,0,0,18,112,0,59,120,121,121,121,0,0,0,0,1,0,0,11,0,100,70,100,120,0,1,1,0,
11,112,0,0,0,1,4,118,101,99,52,95,100,100,120,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,
0,18,112,0,59,120,121,122,122,0,0,0,0,1,0,0,12,0,100,70,100,120,0,1,1,0,12,112,0,0,0,1,4,118,101,
99,52,95,100,100,120,0,18,95,95,114,101,116,86,97,108,0,0,18,112,0,0,0,0,1,0,0,9,0,100,70,100,121,
0,1,1,0,9,112,0,0,0,1,4,118,101,99,52,95,100,100,121,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,
18,112,0,59,120,120,120,120,0,0,0,0,1,0,0,10,0,100,70,100,121,0,1,1,0,10,112,0,0,0,1,4,118,101,99,
52,95,100,100,121,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,112,0,59,120,121,121,121,0,
0,0,0,1,0,0,11,0,100,70,100,121,0,1,1,0,11,112,0,0,0,1,4,118,101,99,52,95,100,100,121,0,18,95,95,
114,101,116,86,97,108,0,59,120,121,122,0,0,18,112,0,59,120,121,122,122,0,0,0,0,1,0,0,12,0,100,70,
100,121,0,1,1,0,12,112,0,0,0,1,4,118,101,99,52,95,100,100,121,0,18,95,95,114,101,116,86,97,108,0,0,
18,112,0,0,0,0,1,0,0,9,0,102,119,105,100,116,104,0,1,1,0,9,112,0,0,0,1,8,58,97,98,115,0,58,100,70,
100,120,0,18,112,0,0,0,0,0,58,97,98,115,0,58,100,70,100,121,0,18,112,0,0,0,0,0,46,0,0,1,0,0,10,0,
102,119,105,100,116,104,0,1,1,0,10,112,0,0,0,1,8,58,97,98,115,0,58,100,70,100,120,0,18,112,0,0,0,0,
0,58,97,98,115,0,58,100,70,100,121,0,18,112,0,0,0,0,0,46,0,0,1,0,0,11,0,102,119,105,100,116,104,0,
1,1,0,11,112,0,0,0,1,8,58,97,98,115,0,58,100,70,100,120,0,18,112,0,0,0,0,0,58,97,98,115,0,58,100,
70,100,121,0,18,112,0,0,0,0,0,46,0,0,1,0,0,12,0,102,119,105,100,116,104,0,1,1,0,12,112,0,0,0,1,8,
58,97,98,115,0,58,100,70,100,120,0,18,112,0,0,0,0,0,58,97,98,115,0,58,100,70,100,121,0,18,112,0,0,
0,0,0,46,0,0,0

View file

@ -31,11 +31,9 @@
.syntax version_directive;
version_directive
version_directive_1 .and .loop version_directive_2;
version_directive_1;
version_directive_1
prior_optional_spaces .and optional_version_directive .and .true .emit $;
version_directive_2
prior_optional_spaces .and version_directive_body .and .true .emit $;
optional_version_directive
version_directive_body .or .true .emit 10 .emit 1;
@ -45,13 +43,16 @@ version_directive_body
new_line;
version_number
version_number_110 .or version_number_120;
version_number_100 .or version_number_110 .or version_number_120;
version_number_100
leading_zeroes .and "100" .emit 0 .emit 1;
version_number_110
leading_zeroes .and "110" .emit 10 .emit 1;
version_number_120
leading_zeroes .and "120" .emit 20 .emit 1;
leading_zeroes .and "120" .emit 20 .emit 1;
leading_zeroes
.loop zero;

View file

@ -3,22 +3,22 @@
".syntax version_directive;\n"
"version_directive\n"
" version_directive_1 .and .loop version_directive_2;\n"
" version_directive_1;\n"
"version_directive_1\n"
" prior_optional_spaces .and optional_version_directive .and .true .emit $;\n"
"version_directive_2\n"
" prior_optional_spaces .and version_directive_body .and .true .emit $;\n"
"optional_version_directive\n"
" version_directive_body .or .true .emit 10 .emit 1;\n"
"version_directive_body\n"
" '#' .and optional_space .and \"version\" .and space .and version_number .and optional_space .and\n"
" new_line;\n"
"version_number\n"
" version_number_110 .or version_number_120;\n"
" version_number_100 .or version_number_110 .or version_number_120;\n"
"version_number_100\n"
" leading_zeroes .and \"100\" .emit 0 .emit 1;\n"
"version_number_110\n"
" leading_zeroes .and \"110\" .emit 10 .emit 1;\n"
"version_number_120\n"
" leading_zeroes .and \"120\" .emit 20 .emit 1;\n"
" leading_zeroes .and \"120\" .emit 20 .emit 1;\n"
"leading_zeroes\n"
" .loop zero;\n"
"zero\n"

View file

@ -49,7 +49,7 @@
.syntax translation_unit;
/* revision number - increment after each change affecting emitted output */
.emtcode REVISION 3
.emtcode REVISION 4
/* external declaration (or precision or invariant stmt) */
.emtcode EXTERNAL_NULL 0
@ -59,9 +59,10 @@
.emtcode INVARIANT_STMT 4
/* precision */
.emtcode PRECISION_LOW 0
.emtcode PRECISION_MEDIUM 1
.emtcode PRECISION_HIGH 2
.emtcode PRECISION_DEFAULT 0
.emtcode PRECISION_LOW 1
.emtcode PRECISION_MEDIUM 2
.emtcode PRECISION_HIGH 3
/* declaration */
.emtcode DECLARATION_FUNCTION_PROTOTYPE 1
@ -242,7 +243,9 @@
.emtcode PARAMETER_ARRAY_NOT_PRESENT 0
.emtcode PARAMETER_ARRAY_PRESENT 1
.errtext INVALID_EXTERNAL_DECLARATION "2001: Invalid external declaration."
/* INVALID_EXTERNAL_DECLARATION seems to be reported when there's */
/* any syntax errors... */
.errtext INVALID_EXTERNAL_DECLARATION "2001: Syntax error."
.errtext INVALID_OPERATOR_OVERRIDE "2002: Invalid operator override."
.errtext LBRACE_EXPECTED "2003: '{' expected but '$err_token$' found."
.errtext LPAREN_EXPECTED "2004: '(' expected but '$err_token$' found."
@ -853,15 +856,21 @@ single_declaration_6
/*
<fully_specified_type> ::= <type_specifier>
| <type_qualifier> <type_specifier>
| <precision> <type_specifier>
| <type_qualifier> <precision> <type_specifier>
*/
fully_specified_type_space
fully_specified_type_1 .and type_specifier_space;
fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_space;
fully_specified_type_nospace
fully_specified_type_1 .and type_specifier_nospace;
fully_specified_type_1
fully_specified_type_2 .or .true .emit TYPE_QUALIFIER_NONE;
fully_specified_type_2
fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_nospace;
fully_specified_type_optqual
fully_specified_type_qual .or .true .emit TYPE_QUALIFIER_NONE;
fully_specified_type_qual
type_qualifier .and space;
fully_specified_type_optprec
fully_specified_type_prec .or .true .emit PRECISION_DEFAULT;
fully_specified_type_prec
precision .and space;
/*
<type_qualifier> ::= "const"

View file

@ -2,15 +2,16 @@
/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE .syn FILE */
".syntax translation_unit;\n"
".emtcode REVISION 3\n"
".emtcode REVISION 4\n"
".emtcode EXTERNAL_NULL 0\n"
".emtcode EXTERNAL_FUNCTION_DEFINITION 1\n"
".emtcode EXTERNAL_DECLARATION 2\n"
".emtcode DEFAULT_PRECISION 3\n"
".emtcode INVARIANT_STMT 4\n"
".emtcode PRECISION_LOW 0\n"
".emtcode PRECISION_MEDIUM 1\n"
".emtcode PRECISION_HIGH 2\n"
".emtcode PRECISION_DEFAULT 0\n"
".emtcode PRECISION_LOW 1\n"
".emtcode PRECISION_MEDIUM 2\n"
".emtcode PRECISION_HIGH 3\n"
".emtcode DECLARATION_FUNCTION_PROTOTYPE 1\n"
".emtcode DECLARATION_INIT_DECLARATOR_LIST 2\n"
".emtcode FUNCTION_ORDINARY 0\n"
@ -46,7 +47,6 @@
".emtcode TYPE_QUALIFIER_UNIFORM 4\n"
".emtcode TYPE_QUALIFIER_FIXEDOUTPUT 5\n"
".emtcode TYPE_QUALIFIER_FIXEDINPUT 6\n"
".emtcode TYPE_QUALIFIER_INVARIANT_VARYING 7\n"
".emtcode TYPE_SPECIFIER_VOID 0\n"
".emtcode TYPE_SPECIFIER_BOOL 1\n"
".emtcode TYPE_SPECIFIER_BVEC2 2\n"
@ -138,7 +138,7 @@
".emtcode PARAMETER_NEXT 1\n"
".emtcode PARAMETER_ARRAY_NOT_PRESENT 0\n"
".emtcode PARAMETER_ARRAY_PRESENT 1\n"
".errtext INVALID_EXTERNAL_DECLARATION \"2001: Invalid external declaration.\"\n"
".errtext INVALID_EXTERNAL_DECLARATION \"2001: Syntax error.\"\n"
".errtext INVALID_OPERATOR_OVERRIDE \"2002: Invalid operator override.\"\n"
".errtext LBRACE_EXPECTED \"2003: '{' expected but '$err_token$' found.\"\n"
".errtext LPAREN_EXPECTED \"2004: '(' expected but '$err_token$' found.\"\n"
@ -414,13 +414,17 @@
"single_declaration_6\n"
" constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN;\n"
"fully_specified_type_space\n"
" fully_specified_type_1 .and type_specifier_space;\n"
" fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_space;\n"
"fully_specified_type_nospace\n"
" fully_specified_type_1 .and type_specifier_nospace;\n"
"fully_specified_type_1\n"
" fully_specified_type_2 .or .true .emit TYPE_QUALIFIER_NONE;\n"
"fully_specified_type_2\n"
" fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_nospace;\n"
"fully_specified_type_optqual\n"
" fully_specified_type_qual .or .true .emit TYPE_QUALIFIER_NONE;\n"
"fully_specified_type_qual\n"
" type_qualifier .and space;\n"
"fully_specified_type_optprec\n"
" fully_specified_type_prec .or .true .emit PRECISION_DEFAULT;\n"
"fully_specified_type_prec\n"
" precision .and space;\n"
"type_qualifier\n"
" \"const\" .emit TYPE_QUALIFIER_CONST .or\n"
" .if (shader_type == 2) \"attribute\" .emit TYPE_QUALIFIER_ATTRIBUTE .or\n"

View file

@ -2,92 +2,93 @@
/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED FROM THE FOLLOWING FILE: */
/* slang_vertex_builtin.gc */
3,2,2,5,12,1,103,108,95,80,111,115,105,116,105,111,110,0,0,0,2,2,5,9,1,103,108,95,80,111,105,110,
116,83,105,122,101,0,0,0,2,2,5,12,1,103,108,95,67,108,105,112,86,101,114,116,101,120,0,0,0,2,2,2,
12,1,103,108,95,67,111,108,111,114,0,0,0,2,2,2,12,1,103,108,95,83,101,99,111,110,100,97,114,121,67,
111,108,111,114,0,0,0,2,2,2,11,1,103,108,95,78,111,114,109,97,108,0,0,0,2,2,2,12,1,103,108,95,86,
101,114,116,101,120,0,0,0,2,2,2,12,1,103,108,95,77,117,108,116,105,84,101,120,67,111,111,114,100,
48,0,0,0,2,2,2,12,1,103,108,95,77,117,108,116,105,84,101,120,67,111,111,114,100,49,0,0,0,2,2,2,12,
1,103,108,95,77,117,108,116,105,84,101,120,67,111,111,114,100,50,0,0,0,2,2,2,12,1,103,108,95,77,
117,108,116,105,84,101,120,67,111,111,114,100,51,0,0,0,2,2,2,12,1,103,108,95,77,117,108,116,105,84,
101,120,67,111,111,114,100,52,0,0,0,2,2,2,12,1,103,108,95,77,117,108,116,105,84,101,120,67,111,111,
114,100,53,0,0,0,2,2,2,12,1,103,108,95,77,117,108,116,105,84,101,120,67,111,111,114,100,54,0,0,0,2,
2,2,12,1,103,108,95,77,117,108,116,105,84,101,120,67,111,111,114,100,55,0,0,0,2,2,2,9,1,103,108,95,
70,111,103,67,111,111,114,100,0,0,0,2,2,3,12,1,103,108,95,70,114,111,110,116,67,111,108,111,114,0,
0,0,2,2,3,12,1,103,108,95,66,97,99,107,67,111,108,111,114,0,0,0,2,2,3,12,1,103,108,95,70,114,111,
110,116,83,101,99,111,110,100,97,114,121,67,111,108,111,114,0,0,0,2,2,3,12,1,103,108,95,66,97,99,
107,83,101,99,111,110,100,97,114,121,67,111,108,111,114,0,0,0,2,2,3,12,1,103,108,95,84,101,120,67,
111,111,114,100,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,67,111,111,114,100,115,0,0,
0,2,2,3,9,1,103,108,95,70,111,103,70,114,97,103,67,111,111,114,100,0,0,0,1,0,12,0,102,116,114,97,
110,115,102,111,114,109,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,103,108,95,86,101,114,116,101,
120,0,18,103,108,95,77,111,100,101,108,86,105,101,119,80,114,111,106,101,99,116,105,111,110,77,97,
116,114,105,120,84,114,97,110,115,112,111,115,101,0,48,20,0,0,1,0,12,0,116,101,120,116,117,114,101,
49,68,76,111,100,0,1,1,0,16,115,97,109,112,108,101,114,0,0,1,1,0,9,99,111,111,114,100,0,0,1,1,0,9,
108,111,100,0,0,0,1,3,2,0,12,1,99,111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,0,
18,99,111,111,114,100,0,20,0,9,18,99,111,111,114,100,52,0,59,119,0,18,108,111,100,0,20,0,4,118,101,
99,52,95,116,101,120,98,49,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,
0,0,18,99,111,111,114,100,52,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,49,68,80,114,111,106,76,
111,100,0,1,1,0,16,115,97,109,112,108,101,114,0,0,1,1,0,10,99,111,111,114,100,0,0,1,1,0,9,108,111,
100,0,0,0,1,3,2,0,12,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,0,18,99,
111,111,114,100,0,59,120,0,18,99,111,111,114,100,0,59,121,0,49,20,0,9,18,112,99,111,111,114,100,0,
59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,49,100,0,18,95,95,114,101,116,86,
97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,12,0,116,101,
120,116,117,114,101,49,68,80,114,111,106,76,111,100,0,1,1,0,16,115,97,109,112,108,101,114,0,0,1,1,
0,12,99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,12,1,112,99,111,111,114,100,0,0,0,9,
18,112,99,111,111,114,100,0,59,120,0,18,99,111,111,114,100,0,59,120,0,18,99,111,111,114,100,0,59,
122,0,49,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,
101,120,98,49,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,
111,111,114,100,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,50,68,76,111,100,0,1,1,0,17,115,97,
109,112,108,101,114,0,0,1,1,0,10,99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,12,1,99,
111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,121,0,18,99,111,111,114,100,0,59,120,
121,0,20,0,9,18,99,111,111,114,100,52,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,
120,98,50,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,
114,100,52,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,50,68,80,114,111,106,76,111,100,0,1,1,0,17,
115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,
12,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,
0,59,120,121,0,18,99,111,111,114,100,0,59,122,0,49,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,
108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,50,100,0,18,95,95,114,101,116,86,97,108,0,0,
18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,12,0,116,101,120,116,117,
114,101,50,68,80,114,111,106,76,111,100,0,1,1,0,17,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,
111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,12,1,112,99,111,111,114,100,0,0,0,9,18,112,99,
111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,122,
0,49,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,
120,98,50,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,
111,114,100,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,51,68,76,111,100,0,1,1,0,18,115,97,109,
112,108,101,114,0,0,1,1,0,11,99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,12,1,99,111,
111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,121,122,0,18,99,111,111,114,100,0,59,120,
121,122,0,20,0,9,18,99,111,111,114,100,52,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,
101,120,98,51,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,
111,114,100,52,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,51,68,80,114,111,106,76,111,100,0,1,1,
0,18,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,
2,0,12,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,121,122,0,18,99,111,111,
114,100,0,59,120,121,122,0,18,99,111,111,114,100,0,59,119,0,49,20,0,9,18,112,99,111,111,114,100,0,
59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,51,100,0,18,95,95,114,101,116,86,
97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,12,0,116,101,
120,116,117,114,101,67,117,98,101,76,111,100,0,1,1,0,19,115,97,109,112,108,101,114,0,0,1,1,0,11,99,
111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,12,1,99,111,111,114,100,52,0,0,0,9,18,99,111,
4,2,2,5,0,12,1,103,108,95,80,111,115,105,116,105,111,110,0,0,0,2,2,5,0,9,1,103,108,95,80,111,105,
110,116,83,105,122,101,0,0,0,2,2,5,0,12,1,103,108,95,67,108,105,112,86,101,114,116,101,120,0,0,0,2,
2,2,0,12,1,103,108,95,67,111,108,111,114,0,0,0,2,2,2,0,12,1,103,108,95,83,101,99,111,110,100,97,
114,121,67,111,108,111,114,0,0,0,2,2,2,0,11,1,103,108,95,78,111,114,109,97,108,0,0,0,2,2,2,0,12,1,
103,108,95,86,101,114,116,101,120,0,0,0,2,2,2,0,12,1,103,108,95,77,117,108,116,105,84,101,120,67,
111,111,114,100,48,0,0,0,2,2,2,0,12,1,103,108,95,77,117,108,116,105,84,101,120,67,111,111,114,100,
49,0,0,0,2,2,2,0,12,1,103,108,95,77,117,108,116,105,84,101,120,67,111,111,114,100,50,0,0,0,2,2,2,0,
12,1,103,108,95,77,117,108,116,105,84,101,120,67,111,111,114,100,51,0,0,0,2,2,2,0,12,1,103,108,95,
77,117,108,116,105,84,101,120,67,111,111,114,100,52,0,0,0,2,2,2,0,12,1,103,108,95,77,117,108,116,
105,84,101,120,67,111,111,114,100,53,0,0,0,2,2,2,0,12,1,103,108,95,77,117,108,116,105,84,101,120,
67,111,111,114,100,54,0,0,0,2,2,2,0,12,1,103,108,95,77,117,108,116,105,84,101,120,67,111,111,114,
100,55,0,0,0,2,2,2,0,9,1,103,108,95,70,111,103,67,111,111,114,100,0,0,0,2,2,3,0,12,1,103,108,95,70,
114,111,110,116,67,111,108,111,114,0,0,0,2,2,3,0,12,1,103,108,95,66,97,99,107,67,111,108,111,114,0,
0,0,2,2,3,0,12,1,103,108,95,70,114,111,110,116,83,101,99,111,110,100,97,114,121,67,111,108,111,114,
0,0,0,2,2,3,0,12,1,103,108,95,66,97,99,107,83,101,99,111,110,100,97,114,121,67,111,108,111,114,0,0,
0,2,2,3,0,12,1,103,108,95,84,101,120,67,111,111,114,100,0,3,18,103,108,95,77,97,120,84,101,120,116,
117,114,101,67,111,111,114,100,115,0,0,0,2,2,3,0,9,1,103,108,95,70,111,103,70,114,97,103,67,111,
111,114,100,0,0,0,1,0,0,12,0,102,116,114,97,110,115,102,111,114,109,0,0,1,9,18,95,95,114,101,116,
86,97,108,0,18,103,108,95,86,101,114,116,101,120,0,18,103,108,95,77,111,100,101,108,86,105,101,119,
80,114,111,106,101,99,116,105,111,110,77,97,116,114,105,120,84,114,97,110,115,112,111,115,101,0,48,
20,0,0,1,0,0,12,0,116,101,120,116,117,114,101,49,68,76,111,100,0,1,1,0,16,115,97,109,112,108,101,
114,0,0,1,1,0,9,99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,99,111,111,114,100,
52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,0,18,99,111,111,114,100,0,20,0,9,18,99,111,111,114,
100,52,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,49,100,0,18,95,95,114,
101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,0,0,12,
0,116,101,120,116,117,114,101,49,68,80,114,111,106,76,111,100,0,1,1,0,16,115,97,109,112,108,101,
114,0,0,1,1,0,10,99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,112,99,111,111,
114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,0,18,99,111,111,114,100,0,59,120,0,18,99,111,
111,114,100,0,59,121,0,49,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,108,111,100,0,20,0,4,118,
101,99,52,95,116,101,120,98,49,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,
114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,49,68,80,114,111,
106,76,111,100,0,1,1,0,16,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,1,1,0,9,
108,111,100,0,0,0,1,3,2,0,0,12,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,
0,18,99,111,111,114,100,0,59,120,0,18,99,111,111,114,100,0,59,122,0,49,20,0,9,18,112,99,111,111,
114,100,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,49,100,0,18,95,95,114,
101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,0,12,
0,116,101,120,116,117,114,101,50,68,76,111,100,0,1,1,0,17,115,97,109,112,108,101,114,0,0,1,1,0,10,
99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,99,111,111,114,100,52,0,0,0,9,18,
99,111,111,114,100,52,0,59,120,121,0,18,99,111,111,114,100,0,59,120,121,0,20,0,9,18,99,111,111,114,
100,52,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,50,100,0,18,95,95,114,
101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,0,0,12,
0,116,101,120,116,117,114,101,50,68,80,114,111,106,76,111,100,0,1,1,0,17,115,97,109,112,108,101,
114,0,0,1,1,0,11,99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,112,99,111,111,
114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,120,121,0,18,
99,111,111,114,100,0,59,122,0,49,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,108,111,100,0,20,0,
4,118,101,99,52,95,116,101,120,98,50,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,
108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,50,68,80,
114,111,106,76,111,100,0,1,1,0,17,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,1,
1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,
59,120,121,0,18,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,122,0,49,20,0,9,18,
112,99,111,111,114,100,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,50,100,0,
18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,
0,0,1,0,0,12,0,116,101,120,116,117,114,101,51,68,76,111,100,0,1,1,0,18,115,97,109,112,108,101,114,
0,0,1,1,0,11,99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,99,111,111,114,100,52,
0,0,0,9,18,99,111,111,114,100,52,0,59,120,121,122,0,18,99,111,111,114,100,0,59,120,121,122,0,20,0,
9,18,99,111,111,114,100,52,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,51,
100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,
52,0,0,0,0,1,0,0,12,0,116,101,120,116,117,114,101,51,68,80,114,111,106,76,111,100,0,1,1,0,18,115,
97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,
1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,121,122,0,18,99,111,111,114,
100,0,59,120,121,122,0,18,99,111,111,114,100,0,59,119,0,49,20,0,9,18,112,99,111,111,114,100,0,59,
119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,51,100,0,18,95,95,114,101,116,86,97,
108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,0,12,0,116,101,120,
116,117,114,101,67,117,98,101,76,111,100,0,1,1,0,19,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,
111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,99,111,111,114,100,52,0,0,0,9,18,99,111,
111,114,100,52,0,59,120,121,122,0,18,99,111,111,114,100,0,20,0,9,18,99,111,111,114,100,52,0,59,119,
0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,99,117,98,101,0,18,95,95,114,101,116,86,97,
108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,0,12,0,115,104,97,100,
111,119,49,68,76,111,100,0,1,1,0,20,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,111,114,100,0,0,
1,1,0,9,108,111,100,0,0,0,1,3,2,0,12,1,99,111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,
120,121,122,0,18,99,111,111,114,100,0,20,0,9,18,99,111,111,114,100,52,0,59,119,0,18,108,111,100,0,
20,0,4,118,101,99,52,95,116,101,120,98,49,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,
112,108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,0,12,0,115,104,97,100,111,119,49,68,80,114,
111,106,76,111,100,0,1,1,0,20,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,1,1,0,
9,108,111,100,0,0,0,1,3,2,0,12,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,
0,18,99,111,111,114,100,0,59,120,0,18,99,111,111,114,100,0,59,119,0,49,20,0,9,18,112,99,111,111,
114,100,0,59,122,0,18,99,111,111,114,100,0,59,122,0,20,0,9,18,112,99,111,111,114,100,0,59,119,0,18,
108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,49,100,0,18,95,95,114,101,116,86,97,108,0,0,
18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,12,0,115,104,97,100,111,
119,50,68,76,111,100,0,1,1,0,21,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,111,114,100,0,0,1,1,
0,9,108,111,100,0,0,0,1,3,2,0,12,1,99,111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,52,0,59,120,
121,122,0,18,99,111,111,114,100,0,20,0,9,18,99,111,111,114,100,52,0,59,119,0,18,108,111,100,0,20,0,
4,118,101,99,52,95,116,101,120,98,50,100,0,18,95,95,114,101,116,86,97,108,0,0,18,115,97,109,112,
108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,0,12,0,115,104,97,100,111,119,50,68,80,114,111,
106,76,111,100,0,1,1,0,21,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,100,0,0,1,1,0,9,
108,111,100,0,0,0,1,3,2,0,12,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,114,100,0,59,120,
121,0,18,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,119,0,49,20,0,9,18,112,99,
111,111,114,100,0,59,122,0,18,99,111,111,114,100,0,59,122,0,20,0,9,18,112,99,111,111,114,100,0,59,
119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,50,100,0,18,95,95,114,101,116,86,97,
108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,0
108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,0,0,12,0,115,104,97,
100,111,119,49,68,76,111,100,0,1,1,0,20,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,111,114,100,
0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,99,111,111,114,100,52,0,0,0,9,18,99,111,111,114,100,
52,0,59,120,121,122,0,18,99,111,111,114,100,0,20,0,9,18,99,111,111,114,100,52,0,59,119,0,18,108,
111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,49,100,0,18,95,95,114,101,116,86,97,108,0,0,18,
115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,0,0,12,0,115,104,97,100,111,119,
49,68,80,114,111,106,76,111,100,0,1,1,0,20,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,111,114,
100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,112,99,111,111,114,100,0,0,0,9,18,112,99,111,111,
114,100,0,59,120,0,18,99,111,111,114,100,0,59,120,0,18,99,111,111,114,100,0,59,119,0,49,20,0,9,18,
112,99,111,111,114,100,0,59,122,0,18,99,111,111,114,100,0,59,122,0,20,0,9,18,112,99,111,111,114,
100,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,49,100,0,18,95,95,114,101,
116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,1,0,0,12,0,
115,104,97,100,111,119,50,68,76,111,100,0,1,1,0,21,115,97,109,112,108,101,114,0,0,1,1,0,11,99,111,
111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,99,111,111,114,100,52,0,0,0,9,18,99,111,
111,114,100,52,0,59,120,121,122,0,18,99,111,111,114,100,0,20,0,9,18,99,111,111,114,100,52,0,59,119,
0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,50,100,0,18,95,95,114,101,116,86,97,108,
0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,52,0,0,0,0,1,0,0,12,0,115,104,97,100,
111,119,50,68,80,114,111,106,76,111,100,0,1,1,0,21,115,97,109,112,108,101,114,0,0,1,1,0,12,99,111,
111,114,100,0,0,1,1,0,9,108,111,100,0,0,0,1,3,2,0,0,12,1,112,99,111,111,114,100,0,0,0,9,18,112,99,
111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,120,121,0,18,99,111,111,114,100,0,59,119,
0,49,20,0,9,18,112,99,111,111,114,100,0,59,122,0,18,99,111,111,114,100,0,59,122,0,20,0,9,18,112,99,
111,111,114,100,0,59,119,0,18,108,111,100,0,20,0,4,118,101,99,52,95,116,101,120,98,50,100,0,18,95,
95,114,101,116,86,97,108,0,0,18,115,97,109,112,108,101,114,0,0,18,112,99,111,111,114,100,0,0,0,0,0

View file

@ -425,6 +425,7 @@ static slang_asm_info AsmInfo[] = {
{ "vec4_sle", IR_SLE, 1, 2 },
{ "vec4_slt", IR_SLT, 1, 2 },
/* vec4 unary */
{ "vec4_move", IR_MOVE, 1, 1 },
{ "vec4_floor", IR_FLOOR, 1, 1 },
{ "vec4_frac", IR_FRAC, 1, 1 },
{ "vec4_abs", IR_ABS, 1, 1 },
@ -448,8 +449,8 @@ static slang_asm_info AsmInfo[] = {
{ "vec4_texp_rect", IR_TEX, 1, 2 },/* rectangle w/ projection */
/* unary op */
{ "int_to_float", IR_I_TO_F, 1, 1 },
{ "float_to_int", IR_F_TO_I, 1, 1 },
{ "ivec4_to_vec4", IR_I_TO_F, 1, 1 }, /* int[4] to float[4] */
{ "vec4_to_ivec4", IR_F_TO_I, 1, 1 }, /* float[4] to int[4] */
{ "float_exp", IR_EXP, 1, 1 },
{ "float_exp2", IR_EXP2, 1, 1 },
{ "float_log2", IR_LOG2, 1, 1 },
@ -1674,11 +1675,9 @@ _slang_gen_asm(slang_assemble_ctx *A, slang_operation *oper,
return NULL;
assert(!n->Store);
n->Store = get_store(n0);
n->Writemask = writemask;
n->Store = n0->Store;
assert(n->Store->File != PROGRAM_UNDEFINED ||
n->Store->Parent);
assert(n->Store->File != PROGRAM_UNDEFINED || n->Store->Parent);
_slang_free(n0);
}
@ -1957,6 +1956,7 @@ _slang_gen_function_call_name(slang_assemble_ctx *A, const char *name,
slang_atom atom;
slang_function *fun;
GLboolean error;
slang_ir_node *n;
atom = slang_atom_pool_atom(A->atoms, name);
if (atom == SLANG_ATOM_NULL)
@ -2008,7 +2008,17 @@ _slang_gen_function_call_name(slang_assemble_ctx *A, const char *name,
assert(fun);
}
return _slang_gen_function_call(A, fun, oper, dest);
n = _slang_gen_function_call(A, fun, oper, dest);
if (n && !n->Store && !dest
&& fun->header.type.specifier.type != SLANG_SPEC_VOID) {
/* setup n->Store for the result of the function call */
GLint size = _slang_sizeof_type_specifier(&fun->header.type.specifier);
n->Store = _slang_new_ir_storage(PROGRAM_TEMPORARY, -1, size);
/*printf("Alloc storage for function result, size %d \n", size);*/
}
return n;
}
@ -2049,6 +2059,23 @@ _slang_is_scalar_or_boolean(slang_assemble_ctx *A, slang_operation *oper)
}
/**
* Test if an operation is boolean.
*/
static GLboolean
_slang_is_boolean(slang_assemble_ctx *A, slang_operation *oper)
{
slang_typeinfo type;
GLboolean isBool;
slang_typeinfo_construct(&type);
_slang_typeof_operation(A, oper, &type);
isBool = (type.spec.type == SLANG_SPEC_BOOL);
slang_typeinfo_destruct(&type);
return isBool;
}
/**
* Generate loop code using high-level IR_LOOP instruction
*/
@ -2064,7 +2091,7 @@ _slang_gen_while(slang_assemble_ctx * A, const slang_operation *oper)
GLboolean isConst, constTrue;
/* type-check expression */
if (!_slang_is_scalar_or_boolean(A, &oper->children[0])) {
if (!_slang_is_boolean(A, &oper->children[0])) {
slang_info_log_error(A->log, "scalar/boolean expression expected for 'while'");
return NULL;
}
@ -2127,7 +2154,7 @@ _slang_gen_do(slang_assemble_ctx * A, const slang_operation *oper)
GLboolean isConst, constTrue;
/* type-check expression */
if (!_slang_is_scalar_or_boolean(A, &oper->children[1])) {
if (!_slang_is_boolean(A, &oper->children[1])) {
slang_info_log_error(A->log, "scalar/boolean expression expected for 'do/while'");
return NULL;
}
@ -2256,6 +2283,11 @@ _slang_gen_if(slang_assemble_ctx * A, const slang_operation *oper)
GLboolean isConst, constTrue;
/* type-check expression */
if (!_slang_is_boolean(A, &oper->children[0])) {
slang_info_log_error(A->log, "boolean expression expected for 'while'");
return NULL;
}
if (!_slang_is_scalar_or_boolean(A, &oper->children[0])) {
slang_info_log_error(A->log, "scalar/boolean expression expected for 'if'");
return NULL;
@ -2408,11 +2440,19 @@ _slang_gen_var_decl(slang_assemble_ctx *A, slang_variable *var)
if (var->array_len > 0) {
/* this is an array */
/* round up element size to mult of 4 */
GLint sz = (n->Store->Size + 3) & ~3;
/* mult by array size */
sz *= var->array_len;
n->Store->Size = sz;
/* cannot be const-qualified */
if (var->type.qualifier == SLANG_QUAL_CONST) {
slang_info_log_error(A->log, "array '%s' cannot be const",
(char*) var->a_name);
return NULL;
}
else {
/* round up element size to mult of 4 */
GLint sz = (n->Store->Size + 3) & ~3;
/* mult by array size */
sz *= var->array_len;
n->Store->Size = sz;
}
}
assert(n->Store->Size > 0);
@ -2449,16 +2489,36 @@ _slang_gen_select(slang_assemble_ctx *A, slang_operation *oper)
{
slang_ir_node *cond, *ifNode, *trueExpr, *falseExpr, *trueNode, *falseNode;
slang_ir_node *tmpDecl, *tmpVar, *tree;
slang_typeinfo type;
int size;
slang_typeinfo type0, type1, type2;
int size, isBool, isEqual;
assert(oper->type == SLANG_OPER_SELECT);
assert(oper->num_children == 3);
/* type of children[0] must be boolean */
slang_typeinfo_construct(&type0);
_slang_typeof_operation(A, &oper->children[0], &type0);
isBool = (type0.spec.type == SLANG_SPEC_BOOL);
slang_typeinfo_destruct(&type0);
if (!isBool) {
slang_info_log_error(A->log, "selector type is not boolean");
return NULL;
}
slang_typeinfo_construct(&type1);
slang_typeinfo_construct(&type2);
_slang_typeof_operation(A, &oper->children[1], &type1);
_slang_typeof_operation(A, &oper->children[2], &type2);
isEqual = slang_type_specifier_equal(&type1.spec, &type2.spec);
slang_typeinfo_destruct(&type1);
slang_typeinfo_destruct(&type2);
if (!isEqual) {
slang_info_log_error(A->log, "incompatible types for ?: operator");
return NULL;
}
/* size of x or y's type */
slang_typeinfo_construct(&type);
_slang_typeof_operation(A, &oper->children[1], &type);
size = _slang_sizeof_type_specifier(&type.spec);
size = _slang_sizeof_type_specifier(&type1.spec);
assert(size > 0);
/* temporary var */
@ -2472,13 +2532,13 @@ _slang_gen_select(slang_assemble_ctx *A, slang_operation *oper)
tmpVar = new_node0(IR_VAR);
tmpVar->Store = tmpDecl->Store;
trueExpr = _slang_gen_operation(A, &oper->children[1]);
trueNode = new_node2(IR_MOVE, tmpVar, trueExpr);
trueNode = new_node2(IR_COPY, tmpVar, trueExpr);
/* if-false body (child 2) */
tmpVar = new_node0(IR_VAR);
tmpVar->Store = tmpDecl->Store;
falseExpr = _slang_gen_operation(A, &oper->children[2]);
falseNode = new_node2(IR_MOVE, tmpVar, falseExpr);
falseNode = new_node2(IR_COPY, tmpVar, falseExpr);
ifNode = new_if(cond, trueNode, falseNode);
@ -2619,6 +2679,88 @@ _slang_gen_return(slang_assemble_ctx * A, slang_operation *oper)
}
/**
* Determine if the given operation/expression is const-valued.
*/
static GLboolean
_slang_is_constant_expr(const slang_operation *oper)
{
slang_variable *var;
GLuint i;
switch (oper->type) {
case SLANG_OPER_IDENTIFIER:
var = _slang_locate_variable(oper->locals, oper->a_id, GL_TRUE);
if (var && var->type.qualifier == SLANG_QUAL_CONST)
return GL_TRUE;
return GL_FALSE;
default:
for (i = 0; i < oper->num_children; i++) {
if (!_slang_is_constant_expr(&oper->children[i]))
return GL_FALSE;
}
return GL_TRUE;
}
}
/**
* Check if an assignment of type t1 to t0 is legal.
* XXX more cases needed.
*/
static GLboolean
_slang_assignment_compatible(slang_assemble_ctx *A,
slang_operation *op0,
slang_operation *op1)
{
slang_typeinfo t0, t1;
GLuint sz0, sz1;
slang_typeinfo_construct(&t0);
_slang_typeof_operation(A, op0, &t0);
slang_typeinfo_construct(&t1);
_slang_typeof_operation(A, op1, &t1);
sz0 = _slang_sizeof_type_specifier(&t0.spec);
sz1 = _slang_sizeof_type_specifier(&t1.spec);
#if 1
if (sz0 != sz1) {
/*printf("assignment size mismatch %u vs %u\n", sz0, sz1);*/
return GL_FALSE;
}
#endif
if (t0.spec.type == SLANG_SPEC_STRUCT &&
t1.spec.type == SLANG_SPEC_STRUCT &&
t0.spec._struct->a_name != t1.spec._struct->a_name)
return GL_FALSE;
if (t0.spec.type == SLANG_SPEC_FLOAT &&
t1.spec.type == SLANG_SPEC_BOOL)
return GL_FALSE;
#if 0 /* not used just yet - causes problems elsewhere */
if (t0.spec.type == SLANG_SPEC_INT &&
t1.spec.type == SLANG_SPEC_FLOAT)
return GL_FALSE;
#endif
if (t0.spec.type == SLANG_SPEC_BOOL &&
t1.spec.type == SLANG_SPEC_FLOAT)
return GL_FALSE;
if (t0.spec.type == SLANG_SPEC_BOOL &&
t1.spec.type == SLANG_SPEC_INT)
return GL_FALSE;
return GL_TRUE;
}
/**
* Generate IR tree for a variable declaration.
*/
@ -2629,12 +2771,24 @@ _slang_gen_declaration(slang_assemble_ctx *A, slang_operation *oper)
slang_ir_node *varDecl;
slang_variable *v;
const char *varName = (char *) oper->a_id;
slang_operation *initializer;
assert(oper->num_children == 0 || oper->num_children == 1);
assert(oper->type == SLANG_OPER_VARIABLE_DECL);
assert(oper->num_children <= 1);
v = _slang_locate_variable(oper->locals, oper->a_id, GL_TRUE);
/*printf("Declare %s at %p\n", varName, v);*/
assert(v);
if (!v)
return NULL; /* "shouldn't happen" */
if (v->type.qualifier == SLANG_QUAL_ATTRIBUTE ||
v->type.qualifier == SLANG_QUAL_VARYING ||
v->type.qualifier == SLANG_QUAL_UNIFORM) {
/* can't declare attribute/uniform vars inside functions */
slang_info_log_error(A->log,
"local variable '%s' cannot be an attribute/uniform/varying",
varName);
return NULL;
}
#if 0
if (v->declared) {
@ -2644,57 +2798,78 @@ _slang_gen_declaration(slang_assemble_ctx *A, slang_operation *oper)
#endif
varDecl = _slang_gen_var_decl(A, v);
if (!varDecl)
return NULL;
/* check if the var has an initializer */
if (oper->num_children > 0) {
/* child is initializer */
slang_ir_node *var, *init, *rhs;
assert(oper->num_children == 1);
var = new_var(A, oper, oper->a_id);
if (!var) {
slang_info_log_error(A->log, "undefined variable '%s'", varName);
return NULL;
}
/* XXX make copy of this initializer? */
rhs = _slang_gen_operation(A, &oper->children[0]);
if (!rhs)
return NULL; /* must have found an error */
init = new_node2(IR_MOVE, var, rhs);
/*assert(rhs->Opcode != IR_SEQ);*/
n = new_seq(varDecl, init);
initializer = &oper->children[0];
}
else if (v->initializer) {
slang_ir_node *var, *init, *rhs;
initializer = v->initializer;
}
else {
initializer = NULL;
}
if (v->type.qualifier == SLANG_QUAL_CONST && !initializer) {
slang_info_log_error(A->log,
"const-qualified variable '%s' requires initializer",
varName);
return NULL;
}
if (initializer) {
slang_ir_node *var, *init;
/* type check/compare var and initializer */
if (!_slang_assignment_compatible(A, oper, initializer)) {
slang_info_log_error(A->log, "incompatible types in assignment");
return NULL;
}
var = new_var(A, oper, oper->a_id);
if (!var) {
slang_info_log_error(A->log, "undefined variable '%s'", varName);
return NULL;
}
if (v->type.qualifier == SLANG_QUAL_CONST) {
/* if the variable is const, the initializer must be a const
* expression as well.
*/
#if 0
/* XXX make copy of this initializer? */
{
slang_operation dup;
slang_operation_construct(&dup);
slang_operation_copy(&dup, v->initializer);
_slang_simplify(&dup, &A->space, A->atoms);
rhs = _slang_gen_operation(A, &dup);
}
#else
_slang_simplify(v->initializer, &A->space, A->atoms);
rhs = _slang_gen_operation(A, v->initializer);
if (!_slang_is_constant_expr(initializer)) {
slang_info_log_error(A->log,
"initializer for %s not constant", varName);
return NULL;
}
#endif
if (!rhs)
}
_slang_simplify(initializer, &A->space, A->atoms);
init = _slang_gen_operation(A, initializer);
if (!init)
return NULL;
assert(rhs);
init = new_node2(IR_MOVE, var, rhs);
/*
assert(rhs->Opcode != IR_SEQ);
*/
n = new_seq(varDecl, init);
/*assert(init->Store);*/
/* XXX remove this when type checking is added above */
if (init->Store && var->Store->Size != init->Store->Size) {
slang_info_log_error(A->log, "invalid assignment (wrong types)");
return NULL;
}
n = new_node2(IR_COPY, var, init);
n = new_seq(varDecl, n);
}
else {
n = varDecl;
}
return n;
}
@ -2751,6 +2926,24 @@ _slang_gen_swizzle(slang_ir_node *child, GLuint swizzle)
}
static GLboolean
is_store_writable(const slang_assemble_ctx *A, const slang_ir_storage *store)
{
while (store->Parent)
store = store->Parent;
if (!(store->File == PROGRAM_OUTPUT ||
store->File == PROGRAM_TEMPORARY ||
(store->File == PROGRAM_VARYING &&
A->program->Target == GL_VERTEX_PROGRAM_ARB))) {
return GL_FALSE;
}
else {
return GL_TRUE;
}
}
/**
* Generate IR tree for an assignment (=).
*/
@ -2796,23 +2989,31 @@ _slang_gen_assignment(slang_assemble_ctx * A, slang_operation *oper)
}
else {
slang_ir_node *n, *lhs, *rhs;
lhs = _slang_gen_operation(A, &oper->children[0]);
if (lhs) {
if (!lhs->Store) {
slang_info_log_error(A->log,
"invalid left hand side for assignment");
return NULL;
}
if (!(lhs->Store->File == PROGRAM_OUTPUT ||
lhs->Store->File == PROGRAM_TEMPORARY ||
(lhs->Store->File == PROGRAM_VARYING &&
A->program->Target == GL_VERTEX_PROGRAM_ARB) ||
lhs->Store->File == PROGRAM_UNDEFINED)) {
slang_info_log_error(A->log,
"illegal assignment to read-only l-value");
return NULL;
}
/* lhs and rhs type checking */
if (!_slang_assignment_compatible(A,
&oper->children[0],
&oper->children[1])) {
slang_info_log_error(A->log, "incompatible types in assignment");
return NULL;
}
lhs = _slang_gen_operation(A, &oper->children[0]);
if (!lhs) {
return NULL;
}
if (!lhs->Store) {
slang_info_log_error(A->log,
"invalid left hand side for assignment");
return NULL;
}
/* check that lhs is writable */
if (!is_store_writable(A, lhs->Store)) {
slang_info_log_error(A->log,
"illegal assignment to read-only l-value");
return NULL;
}
rhs = _slang_gen_operation(A, &oper->children[1]);
@ -2826,7 +3027,7 @@ _slang_gen_assignment(slang_assemble_ctx * A, slang_operation *oper)
*/
rhs = _slang_gen_swizzle(rhs, newSwizzle);
}
n = new_node2(IR_MOVE, lhs, rhs);
n = new_node2(IR_COPY, lhs, rhs);
n->Writemask = writemask;
return n;
}
@ -3055,6 +3256,48 @@ _slang_gen_array_element(slang_assemble_ctx * A, slang_operation *oper)
}
static slang_ir_node *
_slang_gen_compare(slang_assemble_ctx *A, slang_operation *oper,
slang_ir_opcode opcode)
{
slang_typeinfo t0, t1;
slang_ir_node *n;
slang_typeinfo_construct(&t0);
_slang_typeof_operation(A, &oper->children[0], &t0);
slang_typeinfo_construct(&t1);
_slang_typeof_operation(A, &oper->children[0], &t1);
if (t0.spec.type == SLANG_SPEC_ARRAY ||
t1.spec.type == SLANG_SPEC_ARRAY) {
slang_info_log_error(A->log, "Illegal array comparison");
return NULL;
}
if (oper->type != SLANG_OPER_EQUAL &&
oper->type != SLANG_OPER_NOTEQUAL) {
/* <, <=, >, >= can only be used with scalars */
if ((t0.spec.type != SLANG_SPEC_INT &&
t0.spec.type != SLANG_SPEC_FLOAT) ||
(t1.spec.type != SLANG_SPEC_INT &&
t1.spec.type != SLANG_SPEC_FLOAT)) {
slang_info_log_error(A->log, "Incompatible type(s) for inequality operator");
return NULL;
}
}
n = new_node2(opcode,
_slang_gen_operation(A, &oper->children[0]),
_slang_gen_operation(A, &oper->children[1]));
/* result is a bool (size 1) */
n->Store = _slang_new_ir_storage(PROGRAM_TEMPORARY, -1, 1);
return n;
}
#if 0
static void
print_vars(slang_variable_scope *s)
@ -3163,29 +3406,17 @@ _slang_gen_operation(slang_assemble_ctx * A, slang_operation *oper)
return new_node0(IR_KILL);
case SLANG_OPER_EQUAL:
return new_node2(IR_EQUAL,
_slang_gen_operation(A, &oper->children[0]),
_slang_gen_operation(A, &oper->children[1]));
return _slang_gen_compare(A, oper, IR_EQUAL);
case SLANG_OPER_NOTEQUAL:
return new_node2(IR_NOTEQUAL,
_slang_gen_operation(A, &oper->children[0]),
_slang_gen_operation(A, &oper->children[1]));
return _slang_gen_compare(A, oper, IR_NOTEQUAL);
case SLANG_OPER_GREATER:
return new_node2(IR_SGT,
_slang_gen_operation(A, &oper->children[0]),
_slang_gen_operation(A, &oper->children[1]));
return _slang_gen_compare(A, oper, IR_SGT);
case SLANG_OPER_LESS:
return new_node2(IR_SLT,
_slang_gen_operation(A, &oper->children[0]),
_slang_gen_operation(A, &oper->children[1]));
return _slang_gen_compare(A, oper, IR_SLT);
case SLANG_OPER_GREATEREQUAL:
return new_node2(IR_SGE,
_slang_gen_operation(A, &oper->children[0]),
_slang_gen_operation(A, &oper->children[1]));
return _slang_gen_compare(A, oper, IR_SGE);
case SLANG_OPER_LESSEQUAL:
return new_node2(IR_SLE,
_slang_gen_operation(A, &oper->children[0]),
_slang_gen_operation(A, &oper->children[1]));
return _slang_gen_compare(A, oper, IR_SLE);
case SLANG_OPER_ADD:
{
slang_ir_node *n;
@ -3344,6 +3575,8 @@ _slang_gen_operation(slang_assemble_ctx * A, slang_operation *oper)
for (i = 0; i < oper->num_children; i++) {
slang_ir_node *n = _slang_gen_operation(A, &oper->children[i]);
tree = new_seq(tree, n);
if (n)
tree->Store = n->Store;
}
if (oper->type == SLANG_OPER_NON_INLINED_CALL) {
tree = new_function_call(tree, oper->label);
@ -3416,19 +3649,45 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
* store->Index = sampler number (0..7, typically)
* store->Size = texture type index (1D, 2D, 3D, cube, etc)
*/
GLint sampNum = _mesa_add_sampler(prog->Parameters, varName, datatype);
store = _slang_new_ir_storage(PROGRAM_SAMPLER, sampNum, texIndex);
if (var->initializer) {
slang_info_log_error(A->log, "illegal assignment to '%s'", varName);
return GL_FALSE;
}
#if FEATURE_es2_glsl /* XXX should use FEATURE_texture_rect */
/* disallow rect samplers */
if (var->type.specifier.type == SLANG_SPEC_SAMPLER2DRECT ||
var->type.specifier.type == SLANG_SPEC_SAMPLER2DRECTSHADOW) {
slang_info_log_error(A->log, "invalid sampler type for '%s'", varName);
return GL_FALSE;
}
#endif
{
GLint sampNum = _mesa_add_sampler(prog->Parameters, varName, datatype);
store = _slang_new_ir_storage(PROGRAM_SAMPLER, sampNum, texIndex);
}
if (dbg) printf("SAMPLER ");
}
else if (var->type.qualifier == SLANG_QUAL_UNIFORM) {
/* Uniform variable */
const GLint totalSize = array_size(size, var->array_len);
const GLuint swizzle = _slang_var_swizzle(totalSize, 0);
if (var->initializer) {
slang_info_log_error(A->log, "illegal initializer for uniform '%s'", varName);
return GL_FALSE;
}
if (prog) {
/* user-defined uniform */
if (datatype == GL_NONE) {
if (var->type.specifier.type == SLANG_SPEC_STRUCT) {
_mesa_problem(NULL, "user-declared uniform structs not supported yet");
/* temporary work-around */
GLenum datatype = GL_FLOAT;
GLint uniformLoc = _mesa_add_uniform(prog->Parameters, varName,
totalSize, datatype);
store = _slang_new_ir_storage_swz(PROGRAM_UNIFORM, uniformLoc,
totalSize, swizzle);
/* XXX what we need to do is unroll the struct into its
* basic types, creating a uniform variable for each.
* For example:
@ -3446,9 +3705,9 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
else {
slang_info_log_error(A->log,
"invalid datatype for uniform variable %s",
(char *) var->a_name);
varName);
return GL_FALSE;
}
return GL_FALSE;
}
else {
GLint uniformLoc = _mesa_add_uniform(prog->Parameters, varName,
@ -3468,12 +3727,29 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
if (dbg) printf("UNIFORM (sz %d) ", totalSize);
}
else if (var->type.qualifier == SLANG_QUAL_VARYING) {
const GLint totalSize = array_size(size, var->array_len);
/* varyings must be float, vec or mat */
if (!_slang_type_is_float_vec_mat(var->type.specifier.type) &&
var->type.specifier.type != SLANG_SPEC_ARRAY) {
slang_info_log_error(A->log,
"varying '%s' must be float/vector/matrix",
varName);
return GL_FALSE;
}
if (var->initializer) {
slang_info_log_error(A->log, "illegal initializer for varying '%s'",
varName);
return GL_FALSE;
}
if (prog) {
/* user-defined varying */
GLint varyingLoc = _mesa_add_varying(prog->Varying, varName, size);
GLint varyingLoc = _mesa_add_varying(prog->Varying, varName, totalSize);
GLuint swizzle = _slang_var_swizzle(size, 0);
store = _slang_new_ir_storage_swz(PROGRAM_VARYING, varyingLoc,
size, swizzle);
totalSize, swizzle);
}
else {
/* pre-defined varying, like gl_Color or gl_TexCoord */
@ -3502,6 +3778,14 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
if (dbg) printf("VARYING ");
}
else if (var->type.qualifier == SLANG_QUAL_ATTRIBUTE) {
/* attributes must be float, vec or mat */
if (!_slang_type_is_float_vec_mat(var->type.specifier.type)) {
slang_info_log_error(A->log,
"attribute '%s' must be float/vector/matrix",
varName);
return GL_FALSE;
}
if (prog) {
/* user-defined vertex attribute */
const GLint attr = -1; /* unknown */
@ -3557,7 +3841,7 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
if (var->initializer) {
slang_ir_node *lhs, *rhs, *init;
/* Generate IR_MOVE instruction to initialize the variable */
/* Generate IR_COPY instruction to initialize the variable */
lhs = new_node0(IR_VAR);
lhs->Var = var;
lhs->Store = n->Store;
@ -3567,7 +3851,7 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
rhs = _slang_gen_operation(A, var->initializer);
assert(rhs);
init = new_node2(IR_MOVE, lhs, rhs);
init = new_node2(IR_COPY, lhs, rhs);
n = new_seq(n, init);
}

View file

@ -27,7 +27,7 @@
#define SLANG_CODEGEN_H
#include "imports.h"
#include "main/imports.h"
#include "slang_compile.h"

View file

@ -60,6 +60,20 @@
#define TYPE_SPECIFIER_COUNT 32
/**
* Check if the given identifier is legal.
*/
static GLboolean
legal_identifier(slang_atom name)
{
/* "gl_" is a reserved prefix */
if (_mesa_strncmp((char *) name, "gl_", 3) == 0) {
return GL_FALSE;
}
return GL_TRUE;
}
/**
* Allocate storage for a variable of 'size' bytes from given pool.
* Return the allocated address for the variable.
@ -223,7 +237,7 @@ parse_float(slang_parse_ctx * C, float *number)
}
/* revision number - increment after each change affecting emitted output */
#define REVISION 3
#define REVISION 4
static int
check_revision(slang_parse_ctx * C)
@ -677,14 +691,49 @@ parse_type_specifier(slang_parse_ctx * C, slang_output_ctx * O,
return 1;
}
#define PRECISION_DEFAULT 0
#define PRECISION_LOW 1
#define PRECISION_MEDIUM 2
#define PRECISION_HIGH 3
static int
parse_fully_specified_type(slang_parse_ctx * C, slang_output_ctx * O,
slang_fully_specified_type * type)
{
GLuint precision;
if (!parse_type_qualifier(C, &type->qualifier))
return 0;
precision = *C->I++;
if (!parse_type_specifier(C, O, &type->specifier))
return 0;
switch (precision) {
case PRECISION_DEFAULT:
assert(type->specifier.type < TYPE_SPECIFIER_COUNT);
if (type->specifier.type < TYPE_SPECIFIER_COUNT)
type->precision = O->default_precision[type->specifier.type];
break;
case PRECISION_LOW:
type->precision = SLANG_PREC_LOW;
break;
case PRECISION_MEDIUM:
type->precision = SLANG_PREC_MEDIUM;
break;
case PRECISION_HIGH:
type->precision = SLANG_PREC_HIGH;
break;
default:
return 0;
}
#if !FEATURE_es2_glsl
if (precision != PRECISION_DEFAULT) {
slang_info_log_error(C->L, "precision qualifiers not allowed");
return 0;
}
#endif
return 1;
}
@ -835,6 +884,12 @@ parse_statement(slang_parse_ctx * C, slang_output_ctx * O,
o->type = SLANG_OPER_VARIABLE_DECL;
o->locals->outer_scope = O->vars;
o->a_id = O->vars->variables[i]->a_name;
if (!legal_identifier(o->a_id)) {
slang_info_log_error(C->L, "illegal variable name '%s'",
(char *) o->a_id);
return 0;
}
}
}
}
@ -1404,6 +1459,7 @@ parse_operator_name(slang_parse_ctx * C)
return 0;
}
static int
parse_function_prototype(slang_parse_ctx * C, slang_output_ctx * O,
slang_function * func)
@ -1441,6 +1497,12 @@ parse_function_prototype(slang_parse_ctx * C, slang_output_ctx * O,
return 0;
}
if (!legal_identifier(func->header.a_name)) {
slang_info_log_error(C->L, "illegal function name '%s'",
(char *) func->header.a_name);
return 0;
}
/* parse function parameters */
while (*C->I++ == PARAMETER_NEXT) {
slang_variable *p = slang_variable_scope_grow(func->parameters);
@ -1842,11 +1904,6 @@ parse_declaration(slang_parse_ctx * C, slang_output_ctx * O)
return 1;
}
#define PRECISION_LOW 0
#define PRECISION_MEDIUM 1
#define PRECISION_HIGH 2
static int
parse_default_precision(slang_parse_ctx * C, slang_output_ctx * O)
{
@ -2025,6 +2082,12 @@ parse_code_unit(slang_parse_ctx * C, slang_code_unit * unit,
A.vartable = o.vartable;
A.log = C->L;
/* main() takes no parameters */
if (mainFunc->param_count > 0) {
slang_info_log_error(A.log, "main() takes no arguments");
return GL_FALSE;
}
_slang_codegen_function(&A, mainFunc);
shader->Main = GL_TRUE; /* this shader defines main() */
@ -2368,19 +2431,20 @@ _slang_compile(GLcontext *ctx, struct gl_shader *shader)
_slang_delete_mempool((slang_mempool *) ctx->Shader.MemPool);
ctx->Shader.MemPool = NULL;
/* remove any reads of output registers */
#if 0
printf("Pre-remove output reads:\n");
_mesa_print_program(shader->Program);
#endif
_mesa_remove_output_reads(shader->Program, PROGRAM_OUTPUT);
if (shader->Type == GL_VERTEX_SHADER) {
/* remove any reads of varying (output) registers */
#if 0
printf("Pre-remove output reads:\n");
_mesa_print_program(shader->Programs);
#endif
/* and remove writes to varying vars in vertex programs */
_mesa_remove_output_reads(shader->Program, PROGRAM_VARYING);
_mesa_remove_output_reads(shader->Program, PROGRAM_OUTPUT);
#if 0
printf("Post-remove output reads:\n");
_mesa_print_program(shader->Programs);
#endif
}
#if 0
printf("Post-remove output reads:\n");
_mesa_print_program(shader->Program);
#endif
return success;
}

View file

@ -25,8 +25,8 @@
#if !defined SLANG_COMPILE_H
#define SLANG_COMPILE_H
#include "imports.h"
#include "mtypes.h"
#include "main/imports.h"
#include "main/mtypes.h"
#include "slang_typeinfo.h"
#include "slang_compile_variable.h"
#include "slang_compile_struct.h"

View file

@ -28,7 +28,7 @@
* \author Michal Krol
*/
#include "imports.h"
#include "main/imports.h"
#include "slang_compile.h"
#include "slang_mem.h"

View file

@ -28,7 +28,7 @@
* \author Michal Krol
*/
#include "imports.h"
#include "main/imports.h"
#include "slang_compile.h"
#include "slang_mem.h"

View file

@ -28,7 +28,7 @@
* \author Michal Krol
*/
#include "imports.h"
#include "main/imports.h"
#include "slang_mem.h"
#include "slang_compile.h"
@ -124,8 +124,7 @@ slang_struct_destruct(slang_struct * stru)
{
slang_variable_scope_destruct(stru->fields);
_slang_free(stru->fields);
if (stru->structs)
slang_struct_scope_destruct(stru->structs);
slang_struct_scope_destruct(stru->structs);
_slang_free(stru->structs);
}

View file

@ -28,7 +28,7 @@
* \author Michal Krol
*/
#include "imports.h"
#include "main/imports.h"
#include "slang_compile.h"
#include "slang_mem.h"

View file

@ -51,10 +51,20 @@ slang_type_specifier_type_to_string(slang_type_specifier_type);
typedef enum slang_type_precision_
{
SLANG_PREC_DEFAULT,
SLANG_PREC_LOW,
SLANG_PREC_MEDIUM,
SLANG_PREC_HIGH
} slang_type_precision;
typedef struct slang_fully_specified_type_
{
slang_type_qualifier qualifier;
slang_type_specifier specifier;
slang_type_precision precision;
} slang_fully_specified_type;
extern int

View file

@ -127,22 +127,33 @@ _slang_swizzle_swizzle(GLuint swz1, GLuint swz2)
/**
* Allocate temporary storage for an intermediate result (such as for
* a multiply or add, etc.
* Allocate storage for the given node (if it hasn't already been allocated).
*
* Typically this is temporary storage for an intermediate result (such as
* for a multiply or add, etc).
*
* If n->Store does not exist it will be created and will be of the size
* specified by defaultSize.
*/
static GLboolean
alloc_temp_storage(slang_emit_info *emitInfo, slang_ir_node *n, GLint size)
alloc_node_storage(slang_emit_info *emitInfo, slang_ir_node *n,
GLint defaultSize)
{
assert(!n->Var);
assert(!n->Store);
assert(size > 0);
n->Store = _slang_new_ir_storage(PROGRAM_TEMPORARY, -1, size);
if (!_slang_alloc_temp(emitInfo->vt, n->Store)) {
slang_info_log_error(emitInfo->log,
"Ran out of registers, too many temporaries");
_slang_free(n->Store);
n->Store = NULL;
return GL_FALSE;
if (!n->Store) {
assert(defaultSize > 0);
n->Store = _slang_new_ir_storage(PROGRAM_TEMPORARY, -1, defaultSize);
}
/* now allocate actual register(s). I.e. set n->Store->Index >= 0 */
if (n->Store->Index < 0) {
if (!_slang_alloc_temp(emitInfo->vt, n->Store)) {
slang_info_log_error(emitInfo->log,
"Ran out of registers, too many temporaries");
_slang_free(n->Store);
n->Store = NULL;
return GL_FALSE;
}
}
return GL_TRUE;
}
@ -153,7 +164,7 @@ alloc_temp_storage(slang_emit_info *emitInfo, slang_ir_node *n, GLint size)
* Otherwise, no-op.
*/
static void
free_temp_storage(slang_var_table *vt, slang_ir_node *n)
free_node_storage(slang_var_table *vt, slang_ir_node *n)
{
if (n->Store->File == PROGRAM_TEMPORARY &&
n->Store->Index >= 0 &&
@ -167,6 +178,22 @@ free_temp_storage(slang_var_table *vt, slang_ir_node *n)
}
/**
* Helper function to allocate a short-term temporary.
* Free it with _slang_free_temp().
*/
static GLboolean
alloc_local_temp(slang_emit_info *emitInfo, slang_ir_storage *temp, GLint size)
{
assert(size >= 1);
assert(size <= 4);
_mesa_bzero(temp, sizeof(*temp));
temp->Size = size;
temp->File = PROGRAM_TEMPORARY;
temp->Index = -1;
return _slang_alloc_temp(emitInfo->vt, temp);
}
/**
* Remove any SWIZZLE_NIL terms from given swizzle mask.
@ -584,19 +611,15 @@ emit_arith(slang_emit_info *emitInfo, slang_ir_node *n)
}
/* result storage */
if (!n->Store) {
GLint size = info->ResultSize;
if (!alloc_temp_storage(emitInfo, n, size))
return NULL;
#if 0000 /* this should work, but doesn't yet */
if (size == 2)
n->Writemask = WRITEMASK_XY;
else if (size == 3)
n->Writemask = WRITEMASK_XYZ;
else if (size == 1)
n->Writemask = WRITEMASK_X << GET_SWZ(n->Store->Swizzle,0);
#endif
}
alloc_node_storage(emitInfo, n, -1);
assert(n->Store->Index >= 0);
if (n->Store->Size == 2)
n->Writemask = WRITEMASK_XY;
else if (n->Store->Size == 3)
n->Writemask = WRITEMASK_XYZ;
else if (n->Store->Size == 1)
n->Writemask = WRITEMASK_X << GET_SWZ(n->Store->Swizzle, 0);
storage_to_dst_reg(&inst->DstReg, n->Store, n->Writemask);
@ -608,7 +631,7 @@ emit_arith(slang_emit_info *emitInfo, slang_ir_node *n)
/* really free temps now */
for (i = 0; i < 3; i++)
if (temps[i])
free_temp_storage(emitInfo->vt, temps[i]);
free_node_storage(emitInfo->vt, temps[i]);
/*_mesa_print_instruction(inst);*/
return inst;
@ -636,16 +659,15 @@ emit_compare(slang_emit_info *emitInfo, slang_ir_node *n)
return NULL;
}
/* final result is 1 bool */
if (!alloc_node_storage(emitInfo, n, 1))
return NULL;
size = n->Children[0]->Store->Size;
if (size == 1) {
gl_inst_opcode opcode;
if (!n->Store) {
if (!alloc_temp_storage(emitInfo, n, 1)) /* 1 bool */
return NULL;
}
opcode = n->Opcode == IR_EQUAL ? OPCODE_SEQ : OPCODE_SNE;
inst = new_instruction(emitInfo, opcode);
storage_to_src_reg(&inst->SrcReg[0], n->Children[0]->Store);
@ -655,11 +677,11 @@ emit_compare(slang_emit_info *emitInfo, slang_ir_node *n)
else if (size <= 4) {
GLuint swizzle;
gl_inst_opcode dotOp;
assert(!n->Store);
if (!n->Store) {
if (!alloc_temp_storage(emitInfo, n, size)) /* 'size' bools */
return NULL;
slang_ir_storage tempStore;
if (!alloc_local_temp(emitInfo, &tempStore, 4)) {
return NULL;
/* out of temps */
}
if (size == 4) {
@ -676,26 +698,25 @@ emit_compare(slang_emit_info *emitInfo, slang_ir_node *n)
swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y);
}
/* Compute equality, inequality (tmp1 = (A ?= B)) */
/* Compute inequality (temp = (A != B)) */
inst = new_instruction(emitInfo, OPCODE_SNE);
storage_to_dst_reg(&inst->DstReg, &tempStore, n->Writemask);
storage_to_src_reg(&inst->SrcReg[0], n->Children[0]->Store);
storage_to_src_reg(&inst->SrcReg[1], n->Children[1]->Store);
storage_to_dst_reg(&inst->DstReg, n->Store, n->Writemask);
inst->Comment = _mesa_strdup("Compare values");
/* Compute tmp2 = DOT(tmp1, tmp1) (reduction) */
/* Compute val = DOT(temp, temp) (reduction) */
inst = new_instruction(emitInfo, dotOp);
storage_to_src_reg(&inst->SrcReg[0], n->Store);
storage_to_src_reg(&inst->SrcReg[1], n->Store);
inst->SrcReg[0].Swizzle = inst->SrcReg[1].Swizzle = swizzle; /*override*/
free_temp_storage(emitInfo->vt, n); /* free tmp1 */
if (!alloc_temp_storage(emitInfo, n, 1)) /* alloc tmp2 */
return NULL;
storage_to_dst_reg(&inst->DstReg, n->Store, n->Writemask);
storage_to_src_reg(&inst->SrcReg[0], &tempStore);
storage_to_src_reg(&inst->SrcReg[1], &tempStore);
inst->SrcReg[0].Swizzle = inst->SrcReg[1].Swizzle = swizzle; /*override*/
inst->Comment = _mesa_strdup("Reduce vec to bool");
_slang_free_temp(emitInfo->vt, &tempStore); /* free temp */
if (n->Opcode == IR_EQUAL) {
/* compute tmp2.x = !tmp2.x via tmp2.x = (tmp2.x == 0) */
/* compute val = !val.x with SEQ val, val, 0; */
inst = new_instruction(emitInfo, OPCODE_SEQ);
storage_to_src_reg(&inst->SrcReg[0], n->Store);
constant_to_src_reg(&inst->SrcReg[1], 0.0, emitInfo);
@ -708,73 +729,59 @@ emit_compare(slang_emit_info *emitInfo, slang_ir_node *n)
* XXX this won't work reliably for structs with padding!!
*/
GLint i, num = (n->Children[0]->Store->Size + 3) / 4;
slang_ir_storage accTemp;
slang_ir_storage accTemp, sneTemp;
if (!n->Store) {
if (!alloc_temp_storage(emitInfo, n, 4))
return NULL;
}
accTemp.Size = 4;
accTemp.File = PROGRAM_TEMPORARY;
if (!_slang_alloc_temp(emitInfo->vt, &accTemp)) {
if (!alloc_local_temp(emitInfo, &accTemp, 4))
return NULL;
if (!alloc_local_temp(emitInfo, &sneTemp, 4))
return NULL;
/* out of temps */
}
for (i = 0; i < num; i++) {
/* SNE t0, left[i], right[i] */
/* SNE sneTemp, left[i], right[i] */
inst = new_instruction(emitInfo, OPCODE_SNE);
storage_to_src_reg(&inst->SrcReg[0], n->Children[0]->Store);
storage_to_src_reg(&inst->SrcReg[1], n->Children[1]->Store);
inst->SrcReg[0].Index += i;
inst->SrcReg[1].Index += i;
if (i == 0) {
inst->DstReg.File = accTemp.File;
inst->DstReg.Index = accTemp.Index;
storage_to_dst_reg(&inst->DstReg, &accTemp, WRITEMASK_XYZW);
inst->Comment = _mesa_strdup("Begin struct/array comparison");
}
else {
inst->DstReg.File = n->Store->File;
inst->DstReg.Index = n->Store->Index;
}
if (i > 0) {
/* ADD accTemp, accTemp, temp; # like logical-OR */
storage_to_dst_reg(&inst->DstReg, &sneTemp, WRITEMASK_XYZW);
/* ADD accTemp, accTemp, sneTemp; # like logical-OR */
inst = new_instruction(emitInfo, OPCODE_ADD);
inst->SrcReg[0].File = accTemp.File;
inst->SrcReg[0].Index = accTemp.Index;
inst->SrcReg[1].File = n->Store->File;
inst->SrcReg[1].Index = n->Store->Index;
inst->DstReg.File = accTemp.File;
inst->DstReg.Index = accTemp.Index;
storage_to_dst_reg(&inst->DstReg, &accTemp, WRITEMASK_XYZW);
storage_to_src_reg(&inst->SrcReg[0], &accTemp);
storage_to_src_reg(&inst->SrcReg[1], &sneTemp);
}
}
/* compute accTemp.x || accTemp.y || accTemp.z || accTemp.w with DOT4 */
inst = new_instruction(emitInfo, OPCODE_DP4);
inst->SrcReg[0].File = accTemp.File;
inst->SrcReg[0].Index = accTemp.Index;
inst->SrcReg[1].File = accTemp.File;
inst->SrcReg[1].Index = accTemp.Index;
inst->DstReg.File = n->Store->File;
inst->DstReg.Index = n->Store->Index;
storage_to_dst_reg(&inst->DstReg, n->Store, n->Writemask);
storage_to_src_reg(&inst->SrcReg[0], &accTemp);
storage_to_src_reg(&inst->SrcReg[1], &accTemp);
inst->Comment = _mesa_strdup("End struct/array comparison");
if (n->Opcode == IR_EQUAL) {
/* compute tmp.x = !tmp.x via tmp.x = (tmp.x == 0) */
inst = new_instruction(emitInfo, OPCODE_SEQ);
storage_to_dst_reg(&inst->DstReg, n->Store, n->Writemask);
storage_to_src_reg(&inst->SrcReg[0], n->Store);
constant_to_src_reg(&inst->SrcReg[1], 0.0, emitInfo);
storage_to_dst_reg(&inst->DstReg, n->Store, n->Writemask);
inst->Comment = _mesa_strdup("Invert true/false");
}
_slang_free_temp(emitInfo->vt, &accTemp);
_slang_free_temp(emitInfo->vt, &sneTemp);
}
/* free temps */
free_temp_storage(emitInfo->vt, n->Children[0]);
free_temp_storage(emitInfo->vt, n->Children[1]);
free_node_storage(emitInfo->vt, n->Children[0]);
free_node_storage(emitInfo->vt, n->Children[1]);
return inst;
}
@ -827,9 +834,8 @@ emit_clamp(slang_emit_info *emitInfo, slang_ir_node *n)
}
#endif
if (!n->Store)
if (!alloc_temp_storage(emitInfo, n, n->Children[0]->Store->Size))
return NULL;
if (!alloc_node_storage(emitInfo, n, n->Children[0]->Store->Size))
return NULL;
emit(emitInfo, n->Children[1]);
emit(emitInfo, n->Children[2]);
@ -839,7 +845,7 @@ emit_clamp(slang_emit_info *emitInfo, slang_ir_node *n)
* the intermediate result. Use a temp register instead.
*/
_mesa_bzero(&tmpNode, sizeof(tmpNode));
alloc_temp_storage(emitInfo, &tmpNode, n->Store->Size);
alloc_node_storage(emitInfo, &tmpNode, n->Store->Size);
/* tmp = max(ch[0], ch[1]) */
inst = new_instruction(emitInfo, OPCODE_MAX);
@ -853,7 +859,7 @@ emit_clamp(slang_emit_info *emitInfo, slang_ir_node *n)
storage_to_src_reg(&inst->SrcReg[0], tmpNode.Store);
storage_to_src_reg(&inst->SrcReg[1], n->Children[2]->Store);
free_temp_storage(emitInfo->vt, &tmpNode);
free_node_storage(emitInfo->vt, &tmpNode);
return inst;
}
@ -870,9 +876,8 @@ emit_negation(slang_emit_info *emitInfo, slang_ir_node *n)
emit(emitInfo, n->Children[0]);
if (!n->Store)
if (!alloc_temp_storage(emitInfo, n, n->Children[0]->Store->Size))
return NULL;
if (!alloc_node_storage(emitInfo, n, n->Children[0]->Store->Size))
return NULL;
inst = new_instruction(emitInfo, OPCODE_MOV);
storage_to_dst_reg(&inst->DstReg, n->Store, n->Writemask);
@ -986,7 +991,7 @@ emit_kill(slang_emit_info *emitInfo)
* Note that ARB-KILL depends on sign of vector operand.
*/
inst = new_instruction(emitInfo, OPCODE_KIL_NV);
inst->DstReg.CondMask = COND_TR; /* always branch */
inst->DstReg.CondMask = COND_TR; /* always kill */
assert(emitInfo->prog->Target == GL_FRAGMENT_PROGRAM_ARB);
fp = (struct gl_fragment_program *) emitInfo->prog;
@ -1014,14 +1019,12 @@ emit_tex(slang_emit_info *emitInfo, slang_ir_node *n)
inst = new_instruction(emitInfo, OPCODE_TXP);
}
if (!n->Store)
if (!alloc_temp_storage(emitInfo, n, 4))
return NULL;
if (!alloc_node_storage(emitInfo, n, 4))
return NULL;
storage_to_dst_reg(&inst->DstReg, n->Store, n->Writemask);
/* Child[1] is the coord */
/*assert(n->Children[1]->Store->File != PROGRAM_UNDEFINED);*/
assert(n->Children[1]->Store->Index >= 0);
storage_to_src_reg(&inst->SrcReg[0], n->Children[1]->Store);
@ -1046,12 +1049,15 @@ emit_tex(slang_emit_info *emitInfo, slang_ir_node *n)
}
/**
* Assignment/copy
*/
static struct prog_instruction *
emit_move(slang_emit_info *emitInfo, slang_ir_node *n)
emit_copy(slang_emit_info *emitInfo, slang_ir_node *n)
{
struct prog_instruction *inst;
assert(n->Opcode == IR_MOVE);
assert(n->Opcode == IR_COPY);
/* lhs */
emit(emitInfo, n->Children[0]);
@ -1116,7 +1122,7 @@ emit_move(slang_emit_info *emitInfo, slang_ir_node *n)
srcStore.Size = 4;
while (size >= 4) {
inst = new_instruction(emitInfo, OPCODE_MOV);
inst->Comment = _mesa_strdup("IR_MOVE block");
inst->Comment = _mesa_strdup("IR_COPY block");
storage_to_dst_reg(&inst->DstReg, &dstStore, n->Writemask);
storage_to_src_reg(&inst->SrcReg[0], &srcStore);
srcStore.Index++;
@ -1136,7 +1142,7 @@ emit_move(slang_emit_info *emitInfo, slang_ir_node *n)
inst->Comment = instruction_annotation(inst->Opcode, dstAnnot,
srcAnnot, NULL, NULL);
}
free_temp_storage(emitInfo->vt, n->Children[1]);
free_node_storage(emitInfo->vt, n->Children[1]);
return inst;
}
}
@ -1185,7 +1191,7 @@ emit_cond(slang_emit_info *emitInfo, slang_ir_node *n)
* is normally generated for the expression "i".
* Generate a move instruction just to set condition codes.
*/
if (!alloc_temp_storage(emitInfo, n, 1))
if (!alloc_node_storage(emitInfo, n, 1))
return NULL;
inst = new_instruction(emitInfo, OPCODE_MOV);
inst->CondUpdate = GL_TRUE;
@ -1241,15 +1247,14 @@ emit_not(slang_emit_info *emitInfo, slang_ir_node *n)
#endif
/* else, invert using SEQ (v = v == 0) */
if (!n->Store)
if (!alloc_temp_storage(emitInfo, n, n->Children[0]->Store->Size))
return NULL;
if (!alloc_node_storage(emitInfo, n, n->Children[0]->Store->Size))
return NULL;
inst = new_instruction(emitInfo, OPCODE_SEQ);
storage_to_dst_reg(&inst->DstReg, n->Store, n->Writemask);
storage_to_src_reg(&inst->SrcReg[0], n->Children[0]->Store);
constant_to_src_reg(&inst->SrcReg[1], 0.0, emitInfo);
free_temp_storage(emitInfo->vt, n->Children[0]);
free_node_storage(emitInfo->vt, n->Children[0]);
inst->Comment = _mesa_strdup("NOT");
return inst;
@ -1622,6 +1627,10 @@ emit_struct_field(slang_emit_info *emitInfo, slang_ir_node *n)
return NULL;
}
}
else {
/* do codegen for struct */
emit(emitInfo, n->Children[0]);
}
return NULL; /* no instruction */
}
@ -1634,12 +1643,18 @@ emit(slang_emit_info *emitInfo, slang_ir_node *n)
if (!n)
return NULL;
if (emitInfo->log->error_flag) {
return NULL;
}
switch (n->Opcode) {
case IR_SEQ:
/* sequence of two sub-trees */
assert(n->Children[0]);
assert(n->Children[1]);
emit(emitInfo, n->Children[0]);
if (emitInfo->log->error_flag)
return NULL;
inst = emit(emitInfo, n->Children[1]);
#if 0
assert(!n->Store);
@ -1722,27 +1737,15 @@ emit(slang_emit_info *emitInfo, slang_ir_node *n)
case IR_SWIZZLE:
return emit_swizzle(emitInfo, n);
case IR_I_TO_F:
/* just move */
emit(emitInfo, n->Children[0]);
inst = new_instruction(emitInfo, OPCODE_MOV);
if (!n->Store) {
if (!alloc_temp_storage(emitInfo, n, 1))
return NULL;
}
storage_to_dst_reg(&inst->DstReg, n->Store, n->Writemask);
storage_to_src_reg(&inst->SrcReg[0], n->Children[0]->Store);
if (emitInfo->EmitComments)
inst->Comment = _mesa_strdup("int to float");
return NULL;
/* Simple arithmetic */
/* unary */
case IR_MOVE:
case IR_RSQ:
case IR_RCP:
case IR_FLOOR:
case IR_FRAC:
case IR_F_TO_I:
case IR_I_TO_F:
case IR_ABS:
case IR_SIN:
case IR_COS:
@ -1799,8 +1802,8 @@ emit(slang_emit_info *emitInfo, slang_ir_node *n)
}
return NULL;
case IR_MOVE:
return emit_move(emitInfo, n);
case IR_COPY:
return emit_copy(emitInfo, n);
case IR_COND:
return emit_cond(emitInfo, n);

View file

@ -26,10 +26,10 @@
#define SLANG_EMIT_H
#include "imports.h"
#include "main/imports.h"
#include "slang_compile.h"
#include "slang_ir.h"
#include "mtypes.h"
#include "main/mtypes.h"
extern void

View file

@ -23,8 +23,8 @@
*/
#include "imports.h"
#include "context.h"
#include "main/imports.h"
#include "main/context.h"
#include "slang_ir.h"
#include "slang_mem.h"
#include "shader/prog_print.h"
@ -54,7 +54,8 @@ static const slang_ir_info IrInfo[] = {
{ IR_NOTEQUAL, "IR_NOTEQUAL", OPCODE_NOP, 1, 2 },
/* unary ops */
{ IR_I_TO_F, "IR_I_TO_F", OPCODE_NOP, 1, 1 },
{ IR_MOVE, "IR_MOVE", OPCODE_MOV, 4, 1 },
{ IR_I_TO_F, "IR_I_TO_F", OPCODE_MOV, 4, 1 }, /* int[4] to float[4] */
{ IR_F_TO_I, "IR_F_TO_I", OPCODE_INT, 4, 1 }, /* 4 floats to 4 ints */
{ IR_EXP, "IR_EXP", OPCODE_EXP, 1, 1 },
{ IR_EXP2, "IR_EXP2", OPCODE_EX2, 1, 1 },
@ -82,7 +83,7 @@ static const slang_ir_info IrInfo[] = {
{ IR_KILL, "IR_KILL", OPCODE_NOP, 0, 0 },
{ IR_COND, "IR_COND", OPCODE_NOP, 0, 0 },
{ IR_CALL, "IR_CALL", OPCODE_NOP, 0, 0 },
{ IR_MOVE, "IR_MOVE", OPCODE_NOP, 0, 1 },
{ IR_COPY, "IR_COPY", OPCODE_NOP, 0, 1 },
{ IR_NOT, "IR_NOT", OPCODE_NOP, 1, 1 },
{ IR_VAR, "IR_VAR", OPCODE_NOP, 0, 0 },
{ IR_VAR_DECL, "IR_VAR_DECL", OPCODE_NOP, 0, 0 },
@ -326,8 +327,8 @@ _slang_print_ir_tree(const slang_ir_node *n, int indent)
assert(!n->Children[1]);
_slang_print_ir_tree(n->Children[0], indent + 3);
break;
case IR_MOVE:
printf("MOVE (writemask = %s)\n", writemask_string(n->Writemask));
case IR_COPY:
printf("COPY (writemask = %s)\n", writemask_string(n->Writemask));
_slang_print_ir_tree(n->Children[0], indent+3);
_slang_print_ir_tree(n->Children[1], indent+3);
break;

View file

@ -33,10 +33,10 @@
#define SLANG_IR_H
#include "imports.h"
#include "main/imports.h"
#include "slang_compile.h"
#include "slang_label.h"
#include "mtypes.h"
#include "main/mtypes.h"
/**
@ -70,14 +70,14 @@ typedef enum
/* n->Parent = ptr to parent IR_LOOP Node */
IR_BREAK, /* break loop */
IR_BREAK_IF_TRUE,
IR_BREAK_IF_TRUE, /**< Children[0] = the condition expression */
IR_CONT_IF_TRUE,
/* Children[0] = the condition expression */
IR_MOVE,
IR_COPY, /**< assignment/copy */
IR_MOVE, /**< assembly MOV instruction */
/* vector ops: */
IR_ADD,
IR_ADD, /**< assembly ADD instruction */
IR_SUB,
IR_MUL,
IR_DIV,

View file

@ -49,7 +49,7 @@
*/
#include "imports.h"
#include "main/imports.h"
#include "slang_library_noise.h"
#define FASTFLOOR(x) ( ((x)>0) ? ((int)x) : (((int)x)-1) )

View file

@ -42,6 +42,20 @@
#include "slang_link.h"
/**
* Record a linking error.
*/
static void
link_error(struct gl_shader_program *shProg, const char *msg)
{
if (shProg->InfoLog) {
_mesa_free(shProg->InfoLog);
}
shProg->InfoLog = _mesa_strdup(msg);
shProg->LinkStatus = GL_FALSE;
}
/**
* Linking varying vars involves rearranging varying vars so that the
@ -52,7 +66,6 @@ static GLboolean
link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog)
{
GLuint *map, i, firstVarying, newFile;
GLbitfield varsWritten, varsRead;
map = (GLuint *) malloc(prog->Varying->NumParameters * sizeof(GLuint));
if (!map)
@ -60,14 +73,13 @@ link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog)
for (i = 0; i < prog->Varying->NumParameters; i++) {
/* see if this varying is in the linked varying list */
const struct gl_program_parameter *var
= prog->Varying->Parameters + i;
const struct gl_program_parameter *var = prog->Varying->Parameters + i;
GLint j = _mesa_lookup_parameter_index(shProg->Varying, -1, var->Name);
if (j >= 0) {
/* already in list, check size */
if (var->Size != shProg->Varying->Parameters[j].Size) {
/* error */
link_error(shProg, "mismatched varying variable types");
return GL_FALSE;
}
}
@ -75,9 +87,19 @@ link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog)
/* not already in linked list */
j = _mesa_add_varying(shProg->Varying, var->Name, var->Size);
}
ASSERT(j >= 0);
map[i] = j;
/* map varying[i] to varying[j].
* Note: the loop here takes care of arrays or large (sz>4) vars.
*/
{
GLint sz = var->Size;
while (sz > 0) {
/*printf("Link varying from %d to %d\n", i, j);*/
map[i++] = j++;
sz -= 4;
}
i--; /* go back one */
}
}
@ -96,9 +118,6 @@ link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog)
newFile = PROGRAM_INPUT;
}
/* keep track of which varying vars we read and write */
varsWritten = varsRead = 0x0;
/* OK, now scan the program/shader instructions looking for varying vars,
* replacing the old index with the new index.
*/
@ -109,30 +128,22 @@ link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog)
if (inst->DstReg.File == PROGRAM_VARYING) {
inst->DstReg.File = newFile;
inst->DstReg.Index = map[ inst->DstReg.Index ] + firstVarying;
varsWritten |= (1 << inst->DstReg.Index);
}
for (j = 0; j < 3; j++) {
if (inst->SrcReg[j].File == PROGRAM_VARYING) {
inst->SrcReg[j].File = newFile;
inst->SrcReg[j].Index = map[ inst->SrcReg[j].Index ] + firstVarying;
varsRead |= (1 << inst->SrcReg[j].Index);
}
}
}
if (prog->Target == GL_VERTEX_PROGRAM_ARB) {
prog->OutputsWritten |= varsWritten;
/*printf("VERT OUTPUTS: 0x%x \n", varsWritten);*/
}
else {
assert(prog->Target == GL_FRAGMENT_PROGRAM_ARB);
prog->InputsRead |= varsRead;
/*printf("FRAG INPUTS: 0x%x\n", varsRead);*/
}
free(map);
/* these will get recomputed before linking is completed */
prog->InputsRead = 0x0;
prog->OutputsWritten = 0x0;
return GL_TRUE;
}
@ -296,7 +307,7 @@ _slang_count_temporaries(struct gl_program *prog)
maxIndex = inst->SrcReg[j].Index;
}
if (inst->DstReg.File == PROGRAM_TEMPORARY) {
if (maxIndex < inst->DstReg.Index)
if (maxIndex < (GLint) inst->DstReg.Index)
maxIndex = inst->DstReg.Index;
}
}
@ -381,21 +392,6 @@ fragment_program(struct gl_program *prog)
}
/**
* Record a linking error.
*/
static void
link_error(struct gl_shader_program *shProg, const char *msg)
{
if (shProg->InfoLog) {
_mesa_free(shProg->InfoLog);
}
shProg->InfoLog = _mesa_strdup(msg);
shProg->LinkStatus = GL_FALSE;
}
/**
* Shader linker. Currently:
*
@ -445,6 +441,18 @@ _slang_link(GLcontext *ctx,
_mesa_problem(ctx, "unexpected shader target in slang_link()");
}
#if FEATURE_es2_glsl
/* must have both a vertex and fragment program for ES2 */
if (!vertProg) {
link_error(shProg, "missing vertex shader\n");
return;
}
if (!fragProg) {
link_error(shProg, "missing fragment shader\n");
return;
}
#endif
/*
* Make copies of the vertex/fragment programs now since we'll be
* changing src/dst registers after merging the uniforms and varying vars.
@ -466,10 +474,14 @@ _slang_link(GLcontext *ctx,
}
/* link varying vars */
if (shProg->VertexProgram)
link_varying_vars(shProg, &shProg->VertexProgram->Base);
if (shProg->FragmentProgram)
link_varying_vars(shProg, &shProg->FragmentProgram->Base);
if (shProg->VertexProgram) {
if (!link_varying_vars(shProg, &shProg->VertexProgram->Base))
return;
}
if (shProg->FragmentProgram) {
if (!link_varying_vars(shProg, &shProg->FragmentProgram->Base))
return;
}
/* link uniform vars */
if (shProg->VertexProgram)
@ -517,12 +529,6 @@ _slang_link(GLcontext *ctx,
}
}
/* Check that the vertex program doesn't use too many sampler units */
if (shProg->VertexProgram &&
_mesa_bitcount(shProg->VertexProgram->Base.SamplersUsed) > ctx->Const.MaxVertexTextureImageUnits) {
link_error(shProg, "Vertex program uses too many samplers.\n");
return;
}
if (fragProg && shProg->FragmentProgram) {
/* notify driver that a new fragment program has been compiled/linked */

View file

@ -22,7 +22,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "imports.h"
#include "main/imports.h"
#include "slang_log.h"
#include "slang_utility.h"

View file

@ -32,8 +32,8 @@
* \author Brian Paul
*/
#include "context.h"
#include "macros.h"
#include "main/context.h"
#include "main/macros.h"
#include "slang_mem.h"

View file

@ -27,7 +27,7 @@
#define SLANG_MEM_H
#include "imports.h"
#include "main/imports.h"
typedef struct slang_mempool_ slang_mempool;

View file

@ -28,7 +28,7 @@
* \author Michal Krol
*/
#include "imports.h"
#include "main/imports.h"
#include "shader/grammar/grammar_mesa.h"
#include "slang_preprocess.h"
@ -537,7 +537,11 @@ pp_state_init (pp_state *self, slang_info_log *elog)
{
self->line = 0;
self->file = 1;
#if FEATURE_es2_glsl
self->version = 100;
#else
self->version = 110;
#endif
pp_symbols_init (&self->symbols);
pp_ext_init (&self->ext);
self->elog = elog;

View file

@ -4,7 +4,7 @@
*/
#include "imports.h"
#include "main/imports.h"
#include "slang_compile.h"
#include "slang_print.h"

View file

@ -27,6 +27,7 @@
* call casting.
*/
#include "main/imports.h"
#include "main/macros.h"
#include "main/get.h"
@ -36,6 +37,15 @@
#include "slang_print.h"
#ifndef GL_MAX_FRAGMENT_UNIFORM_VECTORS
#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
#endif
#ifndef GL_MAX_VERTEX_UNIFORM_VECTORS
#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
#endif
#ifndef GL_MAX_VARYING_VECTORS
#define GL_MAX_VARYING_VECTORS 0x8DFC
#endif
/**
@ -62,6 +72,11 @@ _slang_lookup_constant(const char *name)
{ "gl_MaxVaryingFloats", GL_MAX_VARYING_FLOATS },
{ "gl_MaxVertexTextureImageUnits", GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS },
{ "gl_MaxTextureImageUnits", GL_MAX_TEXTURE_IMAGE_UNITS },
#if FEATURE_es2_glsl
{ "gl_MaxVertexUniformVectors", GL_MAX_VERTEX_UNIFORM_VECTORS },
{ "gl_MaxVaryingVectors", GL_MAX_VARYING_VECTORS },
{ "gl_MaxFragmentUniformVectors", GL_MAX_FRAGMENT_UNIFORM_VECTORS },
#endif
{ NULL, 0 }
};
GLuint i;
@ -79,6 +94,15 @@ _slang_lookup_constant(const char *name)
}
static slang_operation_type
literal_type(slang_operation_type t1, slang_operation_type t2)
{
if (t1 == SLANG_OPER_LITERAL_FLOAT || t2 == SLANG_OPER_LITERAL_FLOAT)
return SLANG_OPER_LITERAL_FLOAT;
else
return SLANG_OPER_LITERAL_INT;
}
/**
* Recursively traverse an AST tree, applying simplifications wherever
@ -99,6 +123,7 @@ _slang_simplify(slang_operation *oper,
if (oper->type == SLANG_OPER_IDENTIFIER) {
/* see if it's a named constant */
GLint value = _slang_lookup_constant((char *) oper->a_id);
/*printf("value[%s] = %d\n", (char*) oper->a_id, value);*/
if (value >= 0) {
oper->literal[0] =
oper->literal[1] =
@ -107,6 +132,29 @@ _slang_simplify(slang_operation *oper,
oper->type = SLANG_OPER_LITERAL_INT;
return;
}
/* look for user-defined constant */
{
slang_variable *var;
var = _slang_locate_variable(oper->locals, oper->a_id, GL_TRUE);
if (var) {
if (var->type.qualifier == SLANG_QUAL_CONST &&
var->initializer &&
(var->initializer->type == SLANG_OPER_LITERAL_INT ||
var->initializer->type == SLANG_OPER_LITERAL_FLOAT)) {
oper->literal[0] = var->initializer->literal[0];
oper->literal[1] = var->initializer->literal[1];
oper->literal[2] = var->initializer->literal[2];
oper->literal[3] = var->initializer->literal[3];
oper->literal_size = var->initializer->literal_size;
oper->type = var->initializer->type;
/*
printf("value[%s] = %f\n",
(char*) oper->a_id, oper->literal[0]);
*/
return;
}
}
}
}
/* first, simplify children */
@ -131,8 +179,9 @@ _slang_simplify(slang_operation *oper,
= oper->children[0].literal[i] + oper->children[1].literal[i];
}
oper->literal_size = oper->children[0].literal_size;
slang_operation_destruct(oper);
oper->type = SLANG_OPER_LITERAL_FLOAT;
oper->type = literal_type(oper->children[0].type,
oper->children[1].type);
slang_operation_destruct(oper); /* frees unused children */
return;
case SLANG_OPER_SUBTRACT:
for (i = 0; i < 4; i++) {
@ -140,8 +189,9 @@ _slang_simplify(slang_operation *oper,
= oper->children[0].literal[i] - oper->children[1].literal[i];
}
oper->literal_size = oper->children[0].literal_size;
oper->type = literal_type(oper->children[0].type,
oper->children[1].type);
slang_operation_destruct(oper);
oper->type = SLANG_OPER_LITERAL_FLOAT;
return;
case SLANG_OPER_MULTIPLY:
for (i = 0; i < 4; i++) {
@ -149,8 +199,9 @@ _slang_simplify(slang_operation *oper,
= oper->children[0].literal[i] * oper->children[1].literal[i];
}
oper->literal_size = oper->children[0].literal_size;
oper->type = literal_type(oper->children[0].type,
oper->children[1].type);
slang_operation_destruct(oper);
oper->type = SLANG_OPER_LITERAL_FLOAT;
return;
case SLANG_OPER_DIVIDE:
for (i = 0; i < 4; i++) {
@ -158,8 +209,9 @@ _slang_simplify(slang_operation *oper,
= oper->children[0].literal[i] / oper->children[1].literal[i];
}
oper->literal_size = oper->children[0].literal_size;
oper->type = literal_type(oper->children[0].type,
oper->children[1].type);
slang_operation_destruct(oper);
oper->type = SLANG_OPER_LITERAL_FLOAT;
return;
default:
; /* nothing */

View file

@ -28,7 +28,7 @@
* \author Michal Krol
*/
#include "imports.h"
#include "main/imports.h"
#include "slang_storage.h"
#include "slang_mem.h"

View file

@ -273,7 +273,7 @@ slang_type_specifier_compatible(const slang_type_specifier * x,
GLboolean
slang_typeinfo_construct(slang_typeinfo * ti)
{
/*_mesa_bzero(ti, sizeof(*ti));*/
_mesa_bzero(ti, sizeof(*ti));
slang_type_specifier_ctr(&ti->spec);
ti->array_len = 0;
return GL_TRUE;
@ -392,7 +392,6 @@ _slang_typeof_operation_(slang_operation * op,
switch (op->type) {
case SLANG_OPER_BLOCK_NO_NEW_SCOPE:
case SLANG_OPER_BLOCK_NEW_SCOPE:
case SLANG_OPER_VARIABLE_DECL:
case SLANG_OPER_ASM:
case SLANG_OPER_BREAK:
case SLANG_OPER_CONTINUE:
@ -477,6 +476,7 @@ _slang_typeof_operation_(slang_operation * op,
}
break;
case SLANG_OPER_IDENTIFIER:
case SLANG_OPER_VARIABLE_DECL:
{
slang_variable *var;
var = _slang_locate_variable(op->locals, op->a_id, GL_TRUE);
@ -874,6 +874,34 @@ _slang_type_is_vector(slang_type_specifier_type ty)
}
/**
* Determine if a type is a float, float vector or float matrix.
* \return GL_TRUE if so, GL_FALSE otherwise
*/
GLboolean
_slang_type_is_float_vec_mat(slang_type_specifier_type ty)
{
switch (ty) {
case SLANG_SPEC_FLOAT:
case SLANG_SPEC_VEC2:
case SLANG_SPEC_VEC3:
case SLANG_SPEC_VEC4:
case SLANG_SPEC_MAT2:
case SLANG_SPEC_MAT3:
case SLANG_SPEC_MAT4:
case SLANG_SPEC_MAT23:
case SLANG_SPEC_MAT32:
case SLANG_SPEC_MAT24:
case SLANG_SPEC_MAT42:
case SLANG_SPEC_MAT34:
case SLANG_SPEC_MAT43:
return GL_TRUE;
default:
return GL_FALSE;
}
}
/**
* Given a vector type, return the type of the vector's elements.
* For a matrix, return the type of the columns.

View file

@ -25,8 +25,8 @@
#ifndef SLANG_TYPEINFO_H
#define SLANG_TYPEINFO_H 1
#include "imports.h"
#include "mtypes.h"
#include "main/imports.h"
#include "main/mtypes.h"
#include "slang_log.h"
#include "slang_utility.h"
#include "slang_vartable.h"
@ -191,6 +191,9 @@ _slang_type_is_matrix(slang_type_specifier_type);
extern GLboolean
_slang_type_is_vector(slang_type_specifier_type);
extern GLboolean
_slang_type_is_float_vec_mat(slang_type_specifier_type);
extern slang_type_specifier_type
_slang_type_base(slang_type_specifier_type);

View file

@ -28,7 +28,7 @@
* \author Michal Krol
*/
#include "imports.h"
#include "main/imports.h"
#include "slang_utility.h"
#include "slang_mem.h"

View file

@ -110,9 +110,10 @@ _slang_pop_var_table(slang_var_table *vt)
slang_ir_storage *store = (slang_ir_storage *) t->Vars[i]->aux;
GLint j;
GLuint comp;
if (dbg) printf(" Free var %s, size %d at %d\n",
if (dbg) printf(" Free var %s, size %d at %d.%s\n",
(char*) t->Vars[i]->a_name, store->Size,
store->Index);
store->Index,
_mesa_swizzle_string(store->Swizzle, 0, 0));
if (store->Size == 1)
comp = GET_SWZ(store->Swizzle, 0);
@ -159,7 +160,7 @@ _slang_add_variable(slang_var_table *vt, slang_variable *v)
assert(vt);
t = vt->Top;
assert(t);
if (dbg) printf("Adding var %s\n", (char *) v->a_name);
if (dbg) printf("Adding var %s, store %p\n", (char *) v->a_name, v->aux);
t->Vars = (slang_variable **)
_slang_realloc(t->Vars,
t->NumVars * sizeof(slang_variable *),
@ -262,10 +263,11 @@ _slang_alloc_var(slang_var_table *vt, slang_ir_storage *store)
}
if (dbg)
printf("Alloc var sz %d at %d.%s (level %d)\n",
printf("Alloc var storage sz %d at %d.%s (level %d) store %p\n",
store->Size, store->Index,
_mesa_swizzle_string(store->Swizzle, 0, 0),
t->Level);
t->Level,
(void*) store);
return GL_TRUE;
}
@ -283,19 +285,29 @@ _slang_alloc_temp(slang_var_table *vt, slang_ir_storage *store)
if (i < 0)
return GL_FALSE;
assert(store->Index < 0);
store->Index = i / 4;
if (store->Size == 1) {
const GLuint comp = i % 4;
store->Swizzle = MAKE_SWIZZLE4(comp, comp, comp, comp);
if (dbg) printf("Alloc temp sz %d at %d.%c (level %d)\n",
store->Size, store->Index, "xyzw"[comp], t->Level);
}
else {
/* XXX improve swizzled for size=2/3, use for writemask... */
#if 1
if (store->Size == 2) {
store->Swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y,
SWIZZLE_NIL, SWIZZLE_NIL);
}
#endif
store->Swizzle = SWIZZLE_NOOP;
if (dbg) printf("Alloc temp sz %d at %d.xyzw (level %d)\n",
store->Size, store->Index, t->Level);
}
if (dbg) printf("Alloc temp sz %d at %d.%s (level %d) store %p\n",
store->Size, store->Index,
_mesa_swizzle_string(store->Swizzle, 0, 0), t->Level,
(void *) store);
return GL_TRUE;
}
@ -309,12 +321,20 @@ _slang_free_temp(slang_var_table *vt, slang_ir_storage *store)
assert(store->Size > 0);
assert(r >= 0);
assert(r + store->Size <= vt->MaxRegisters * 4);
if (dbg) printf("Free temp sz %d at %d (level %d)\n", store->Size, r, t->Level);
if (dbg) printf("Free temp sz %d at %d.%s (level %d) store %p\n",
store->Size, r,
_mesa_swizzle_string(store->Swizzle, 0, 0),
t->Level, (void *) store);
if (store->Size == 1) {
const GLuint comp = GET_SWZ(store->Swizzle, 0);
/* we can actually fail some of these assertions because of the
* troublesome IR_SWIZZLE handling.
*/
#if 0
assert(store->Swizzle == MAKE_SWIZZLE4(comp, comp, comp, comp));
assert(comp < 4);
assert(t->ValSize[r * 4 + comp] == 1);
#endif
assert(t->Temps[r * 4 + comp] == TEMP);
t->Temps[r * 4 + comp] = FREE;
}