Remove carriage-return chars *ONLY*.

This commit is contained in:
Michal Krol
2006-04-18 10:47:19 +00:00
parent d55de658b5
commit 2f8496b565
48 changed files with 13783 additions and 13783 deletions
+86 -86
View File
@@ -1,86 +1,86 @@
#include "../../grammar/grammar_crt.h"
#include "../../grammar/grammar_crt.c"
#include <stdio.h>
static const char *slang_shader_syn =
#include "slang_shader_syn.h"
;
static void gc_to_bin (grammar id, const char *in, const char *out)
{
FILE *f;
byte *source, *prod;
unsigned int size, i, line = 0;
printf ("Precompiling %s\n", in);
f = fopen (in, "r");
if (f == NULL)
return;
fseek (f, 0, SEEK_END);
size = ftell (f);
fseek (f, 0, SEEK_SET);
source = (byte *) grammar_alloc_malloc (size + 1);
source[fread (source, 1, size, f)] = '\0';
fclose (f);
if (!grammar_fast_check (id, source, &prod, &size, 65536))
{
grammar_alloc_free (source);
return;
}
f = fopen (out, "w");
fprintf (f, "\n");
fprintf (f, "/* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED FROM THE FOLLOWING FILE: */\n");
fprintf (f, "/* %s */\n", in);
fprintf (f, "\n");
for (i = 0; i < size; i++)
{
unsigned int a;
if (prod[i] < 10)
a = 1;
else if (prod[i] < 100)
a = 2;
else
a = 3;
if (i < size - 1)
a++;
if (line + a >= 100)
{
fprintf (f, "\n");
line = 0;
}
line += a;
fprintf (f, "%d", prod[i]);
if (i < size - 1)
fprintf (f, ",");
}
fprintf (f, "\n");
fclose (f);
grammar_alloc_free (prod);
}
int main ()
{
grammar id;
id = grammar_load_from_text ((const byte *) slang_shader_syn);
if (id == 0)
return 1;
grammar_set_reg8 (id, (const byte *) "parsing_builtin", 1);
grammar_set_reg8 (id, (const byte *) "shader_type", 1);
gc_to_bin (id, "slang_core.gc", "slang_core_gc.h");
gc_to_bin (id, "slang_common_builtin.gc", "slang_common_builtin_gc.h");
gc_to_bin (id, "slang_fragment_builtin.gc", "slang_fragment_builtin_gc.h");
grammar_set_reg8 (id, (const byte *) "shader_type", 2);
gc_to_bin (id, "slang_vertex_builtin.gc", "slang_vertex_builtin_gc.h");
grammar_destroy (id);
return 0;
}
#include "../../grammar/grammar_crt.h"
#include "../../grammar/grammar_crt.c"
#include <stdio.h>
static const char *slang_shader_syn =
#include "slang_shader_syn.h"
;
static void gc_to_bin (grammar id, const char *in, const char *out)
{
FILE *f;
byte *source, *prod;
unsigned int size, i, line = 0;
printf ("Precompiling %s\n", in);
f = fopen (in, "r");
if (f == NULL)
return;
fseek (f, 0, SEEK_END);
size = ftell (f);
fseek (f, 0, SEEK_SET);
source = (byte *) grammar_alloc_malloc (size + 1);
source[fread (source, 1, size, f)] = '\0';
fclose (f);
if (!grammar_fast_check (id, source, &prod, &size, 65536))
{
grammar_alloc_free (source);
return;
}
f = fopen (out, "w");
fprintf (f, "\n");
fprintf (f, "/* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED FROM THE FOLLOWING FILE: */\n");
fprintf (f, "/* %s */\n", in);
fprintf (f, "\n");
for (i = 0; i < size; i++)
{
unsigned int a;
if (prod[i] < 10)
a = 1;
else if (prod[i] < 100)
a = 2;
else
a = 3;
if (i < size - 1)
a++;
if (line + a >= 100)
{
fprintf (f, "\n");
line = 0;
}
line += a;
fprintf (f, "%d", prod[i]);
if (i < size - 1)
fprintf (f, ",");
}
fprintf (f, "\n");
fclose (f);
grammar_alloc_free (prod);
}
int main ()
{
grammar id;
id = grammar_load_from_text ((const byte *) slang_shader_syn);
if (id == 0)
return 1;
grammar_set_reg8 (id, (const byte *) "parsing_builtin", 1);
grammar_set_reg8 (id, (const byte *) "shader_type", 1);
gc_to_bin (id, "slang_core.gc", "slang_core_gc.h");
gc_to_bin (id, "slang_common_builtin.gc", "slang_common_builtin_gc.h");
gc_to_bin (id, "slang_fragment_builtin.gc", "slang_fragment_builtin_gc.h");
grammar_set_reg8 (id, (const byte *) "shader_type", 2);
gc_to_bin (id, "slang_vertex_builtin.gc", "slang_vertex_builtin_gc.h");
grammar_destroy (id);
return 0;
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1,26 +1,26 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//
// TODO:
@@ -46,67 +46,67 @@ varying float gl_FogFragCoord;
// 8.7 Texture Lookup Functions
//
vec4 texture1D (sampler1D sampler, float coord, float bias) {
vec4 texel;
__asm vec4_tex1d texel, sampler, coord, bias;
vec4 texture1D (sampler1D sampler, float coord, float bias) {
vec4 texel;
__asm vec4_tex1d texel, sampler, coord, bias;
return texel;
}
}
vec4 texture1DProj (sampler1D sampler, vec2 coord, float bias) {
return texture1D (sampler, coord.s / coord.t, bias);
}
}
vec4 texture1DProj (sampler1D sampler, vec4 coord, float bias) {
return texture1D (sampler, coord.s / coord.q, bias);
}
vec4 texture2D (sampler2D sampler, vec2 coord, float bias) {
vec4 texel;
__asm vec4_tex2d texel, sampler, coord, bias;
vec4 texture2D (sampler2D sampler, vec2 coord, float bias) {
vec4 texel;
__asm vec4_tex2d texel, sampler, coord, bias;
return texel;
}
}
vec4 texture2DProj (sampler2D sampler, vec3 coord, float bias) {
vec4 texture2DProj (sampler2D sampler, vec3 coord, float bias) {
return texture2D (sampler, vec2 (coord.s / coord.p, coord.t / coord.p), bias);
}
}
vec4 texture2DProj (sampler2D sampler, vec4 coord, float bias) {
vec4 texture2DProj (sampler2D sampler, vec4 coord, float bias) {
return texture2D (sampler, vec2 (coord.s / coord.q, coord.t / coord.q), bias);
}
vec4 texture3D (sampler3D sampler, vec3 coord, float bias) {
vec4 texel;
__asm vec4_tex3d texel, sampler, coord, bias;
vec4 texture3D (sampler3D sampler, vec3 coord, float bias) {
vec4 texel;
__asm vec4_tex3d texel, sampler, coord, bias;
return texel;
}
}
vec4 texture3DProj (sampler3D sampler, vec4 coord, float bias) {
vec4 texture3DProj (sampler3D sampler, vec4 coord, float bias) {
return texture3D (sampler, vec3 (coord.s / coord.q, coord.t / coord.q, coord.p / coord.q), bias);
}
vec4 textureCube (samplerCube sampler, vec3 coord, float bias) {
vec4 texel;
__asm vec4_texcube texel, sampler, coord, bias;
vec4 textureCube (samplerCube sampler, vec3 coord, float bias) {
vec4 texel;
__asm vec4_texcube texel, sampler, coord, bias;
return texel;
}
vec4 shadow1D (sampler1DShadow sampler, vec3 coord, float bias) {
vec4 texel;
__asm vec4_shad1d texel, sampler, coord, bias;
vec4 shadow1D (sampler1DShadow sampler, vec3 coord, float bias) {
vec4 texel;
__asm vec4_shad1d texel, sampler, coord, bias;
return texel;
}
}
vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord, float bias) {
return shadow1D (sampler, vec3 (coord.s / coord.q, 0.0, coord.p / coord.q), bias);
}
vec4 shadow2D (sampler2DShadow sampler, vec3 coord, float bias) {
vec4 texel;
__asm vec4_shad2d texel, sampler, coord, bias;
vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord, float bias) {
return shadow1D (sampler, vec3 (coord.s / coord.q, 0.0, coord.p / coord.q), bias);
}
vec4 shadow2D (sampler2DShadow sampler, vec3 coord, float bias) {
vec4 texel;
__asm vec4_shad2d texel, sampler, coord, bias;
return texel;
}
}
vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord, float bias) {
vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord, float bias) {
return shadow2D (sampler, vec3 (coord.s / coord.q, coord.t / coord.q, coord.p / coord.q), bias);
}
@@ -114,57 +114,57 @@ vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord, float bias) {
// 8.8 Fragment Processing Functions
//
float dFdx (float p) {
float dFdx (float p) {
// XXX:
return 0.001;
}
vec2 dFdx (vec2 p) {
vec2 dFdx (vec2 p) {
// XXX:
return vec2 (0.001);
}
vec3 dFdx (vec3 p) {
vec3 dFdx (vec3 p) {
// XXX:
return vec3 (0.001);
}
vec4 dFdx (vec4 p) {
vec4 dFdx (vec4 p) {
// XXX:
return vec4 (0.001);
}
float dFdy (float p) {
float dFdy (float p) {
// XXX:
return 0.001;
}
vec2 dFdy (vec2 p) {
vec2 dFdy (vec2 p) {
// XXX:
return vec2 (0.001);
}
vec3 dFdy (vec3 p) {
vec3 dFdy (vec3 p) {
// XXX:
return vec3 (0.001);
}
vec4 dFdy (vec4 p) {
vec4 dFdy (vec4 p) {
// XXX:
return vec4 (0.001);
}
float fwidth (float p) {
return abs (dFdx (p)) + abs (dFdy (p));
}
}
vec2 fwidth (vec2 p) {
return abs (dFdx (p)) + abs (dFdy (p));
}
}
vec3 fwidth (vec3 p) {
return abs (dFdx (p)) + abs (dFdy (p));
}
}
vec4 fwidth (vec4 p) {
return abs (dFdx (p)) + abs (dFdy (p));
@@ -1,79 +1,79 @@
/* DO NOT EDIT - THIS FILE 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,0,0,16,115,97,109,112,108,
101,114,0,0,1,0,0,9,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,3,2,0,12,1,116,101,120,
101,108,0,0,0,4,118,101,99,52,95,116,101,120,49,100,0,18,116,101,120,101,108,0,0,18,115,97,109,112,
108,101,114,0,0,18,99,111,111,114,100,0,0,18,98,105,97,115,0,0,0,8,18,116,101,120,101,108,0,0,0,1,
0,12,0,116,101,120,116,117,114,101,49,68,80,114,111,106,0,1,0,0,16,115,97,109,112,108,101,114,0,0,
1,0,0,10,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,116,101,120,116,117,114,101,49,
68,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,
116,0,49,0,18,98,105,97,115,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,49,68,80,114,111,106,0,
1,0,0,16,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,
0,1,8,58,116,101,120,116,117,114,101,49,68,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,
100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,18,98,105,97,115,0,0,0,0,0,1,0,12,0,116,101,
120,116,117,114,101,50,68,0,1,0,0,17,115,97,109,112,108,101,114,0,0,1,0,0,10,99,111,111,114,100,0,
0,1,0,0,9,98,105,97,115,0,0,0,1,3,2,0,12,1,116,101,120,101,108,0,0,0,4,118,101,99,52,95,116,101,
120,50,100,0,18,116,101,120,101,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,
0,18,98,105,97,115,0,0,0,8,18,116,101,120,101,108,0,0,0,1,0,12,0,116,101,120,116,117,114,101,50,68,
80,114,111,106,0,1,0,0,17,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,1,0,0,9,
98,105,97,115,0,0,0,1,8,58,116,101,120,116,117,114,101,50,68,0,18,115,97,109,112,108,101,114,0,0,
58,118,101,99,50,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,112,0,49,0,18,99,
111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,112,0,49,0,0,0,18,98,105,97,115,0,0,0,0,0,1,
0,12,0,116,101,120,116,117,114,101,50,68,80,114,111,106,0,1,0,0,17,115,97,109,112,108,101,114,0,0,
1,0,0,12,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,116,101,120,116,117,114,101,50,
68,0,18,115,97,109,112,108,101,114,0,0,58,118,101,99,50,0,18,99,111,111,114,100,0,59,115,0,18,99,
111,111,114,100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,113,0,
49,0,0,0,18,98,105,97,115,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,51,68,0,1,0,0,18,115,97,
109,112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,3,2,0,12,1,
116,101,120,101,108,0,0,0,4,118,101,99,52,95,116,101,120,51,100,0,18,116,101,120,101,108,0,0,18,
115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,18,98,105,97,115,0,0,0,8,18,116,101,120,
101,108,0,0,0,1,0,12,0,116,101,120,116,117,114,101,51,68,80,114,111,106,0,1,0,0,18,115,97,109,112,
108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,116,101,120,116,
117,114,101,51,68,0,18,115,97,109,112,108,101,114,0,0,58,118,101,99,51,0,18,99,111,111,114,100,0,
59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,
100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,18,
98,105,97,115,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,67,117,98,101,0,1,0,0,19,115,97,109,
112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,3,2,0,12,1,116,
101,120,101,108,0,0,0,4,118,101,99,52,95,116,101,120,99,117,98,101,0,18,116,101,120,101,108,0,0,18,
115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,18,98,105,97,115,0,0,0,8,18,116,101,120,
101,108,0,0,0,1,0,12,0,115,104,97,100,111,119,49,68,0,1,0,0,20,115,97,109,112,108,101,114,0,0,1,0,
0,11,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,3,2,0,12,1,116,101,120,101,108,0,0,0,4,
118,101,99,52,95,115,104,97,100,49,100,0,18,116,101,120,101,108,0,0,18,115,97,109,112,108,101,114,
0,0,18,99,111,111,114,100,0,0,18,98,105,97,115,0,0,0,8,18,116,101,120,101,108,0,0,0,1,0,12,0,115,
104,97,100,111,119,49,68,80,114,111,106,0,1,0,0,20,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,
111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,115,104,97,100,111,119,49,68,0,18,115,97,109,
112,108,101,114,0,0,58,118,101,99,51,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,
113,0,49,0,17,48,0,48,0,0,0,18,99,111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,49,0,
0,0,18,98,105,97,115,0,0,0,0,0,1,0,12,0,115,104,97,100,111,119,50,68,0,1,0,0,21,115,97,109,112,108,
101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,3,2,0,12,1,116,101,120,
101,108,0,0,0,4,118,101,99,52,95,115,104,97,100,50,100,0,18,116,101,120,101,108,0,0,18,115,97,109,
112,108,101,114,0,0,18,99,111,111,114,100,0,0,18,98,105,97,115,0,0,0,8,18,116,101,120,101,108,0,0,
0,1,0,12,0,115,104,97,100,111,119,50,68,80,114,111,106,0,1,0,0,21,115,97,109,112,108,101,114,0,0,1,
0,0,12,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,115,104,97,100,111,119,50,68,0,18,
115,97,109,112,108,101,114,0,0,58,118,101,99,51,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,
114,100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,113,0,49,0,18,
99,111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,18,98,105,97,115,0,0,0,0,0,
1,0,9,0,100,70,100,120,0,1,0,0,9,112,0,0,0,1,8,17,48,0,48,48,49,0,0,0,0,1,0,10,0,100,70,100,120,0,
1,0,0,10,112,0,0,0,1,8,58,118,101,99,50,0,17,48,0,48,48,49,0,0,0,0,0,0,1,0,11,0,100,70,100,120,0,1,
0,0,11,112,0,0,0,1,8,58,118,101,99,51,0,17,48,0,48,48,49,0,0,0,0,0,0,1,0,12,0,100,70,100,120,0,1,0,
0,12,112,0,0,0,1,8,58,118,101,99,52,0,17,48,0,48,48,49,0,0,0,0,0,0,1,0,9,0,100,70,100,121,0,1,0,0,
9,112,0,0,0,1,8,17,48,0,48,48,49,0,0,0,0,1,0,10,0,100,70,100,121,0,1,0,0,10,112,0,0,0,1,8,58,118,
101,99,50,0,17,48,0,48,48,49,0,0,0,0,0,0,1,0,11,0,100,70,100,121,0,1,0,0,11,112,0,0,0,1,8,58,118,
101,99,51,0,17,48,0,48,48,49,0,0,0,0,0,0,1,0,12,0,100,70,100,121,0,1,0,0,12,112,0,0,0,1,8,58,118,
101,99,52,0,17,48,0,48,48,49,0,0,0,0,0,0,1,0,9,0,102,119,105,100,116,104,0,1,0,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,0,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,0,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,0,
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
/* DO NOT EDIT - THIS FILE 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,0,0,16,115,97,109,112,108,
101,114,0,0,1,0,0,9,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,3,2,0,12,1,116,101,120,
101,108,0,0,0,4,118,101,99,52,95,116,101,120,49,100,0,18,116,101,120,101,108,0,0,18,115,97,109,112,
108,101,114,0,0,18,99,111,111,114,100,0,0,18,98,105,97,115,0,0,0,8,18,116,101,120,101,108,0,0,0,1,
0,12,0,116,101,120,116,117,114,101,49,68,80,114,111,106,0,1,0,0,16,115,97,109,112,108,101,114,0,0,
1,0,0,10,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,116,101,120,116,117,114,101,49,
68,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,
116,0,49,0,18,98,105,97,115,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,49,68,80,114,111,106,0,
1,0,0,16,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,
0,1,8,58,116,101,120,116,117,114,101,49,68,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,
100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,18,98,105,97,115,0,0,0,0,0,1,0,12,0,116,101,
120,116,117,114,101,50,68,0,1,0,0,17,115,97,109,112,108,101,114,0,0,1,0,0,10,99,111,111,114,100,0,
0,1,0,0,9,98,105,97,115,0,0,0,1,3,2,0,12,1,116,101,120,101,108,0,0,0,4,118,101,99,52,95,116,101,
120,50,100,0,18,116,101,120,101,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,
0,18,98,105,97,115,0,0,0,8,18,116,101,120,101,108,0,0,0,1,0,12,0,116,101,120,116,117,114,101,50,68,
80,114,111,106,0,1,0,0,17,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,1,0,0,9,
98,105,97,115,0,0,0,1,8,58,116,101,120,116,117,114,101,50,68,0,18,115,97,109,112,108,101,114,0,0,
58,118,101,99,50,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,112,0,49,0,18,99,
111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,112,0,49,0,0,0,18,98,105,97,115,0,0,0,0,0,1,
0,12,0,116,101,120,116,117,114,101,50,68,80,114,111,106,0,1,0,0,17,115,97,109,112,108,101,114,0,0,
1,0,0,12,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,116,101,120,116,117,114,101,50,
68,0,18,115,97,109,112,108,101,114,0,0,58,118,101,99,50,0,18,99,111,111,114,100,0,59,115,0,18,99,
111,111,114,100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,113,0,
49,0,0,0,18,98,105,97,115,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,51,68,0,1,0,0,18,115,97,
109,112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,3,2,0,12,1,
116,101,120,101,108,0,0,0,4,118,101,99,52,95,116,101,120,51,100,0,18,116,101,120,101,108,0,0,18,
115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,18,98,105,97,115,0,0,0,8,18,116,101,120,
101,108,0,0,0,1,0,12,0,116,101,120,116,117,114,101,51,68,80,114,111,106,0,1,0,0,18,115,97,109,112,
108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,116,101,120,116,
117,114,101,51,68,0,18,115,97,109,112,108,101,114,0,0,58,118,101,99,51,0,18,99,111,111,114,100,0,
59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,
100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,18,
98,105,97,115,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,67,117,98,101,0,1,0,0,19,115,97,109,
112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,3,2,0,12,1,116,
101,120,101,108,0,0,0,4,118,101,99,52,95,116,101,120,99,117,98,101,0,18,116,101,120,101,108,0,0,18,
115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,18,98,105,97,115,0,0,0,8,18,116,101,120,
101,108,0,0,0,1,0,12,0,115,104,97,100,111,119,49,68,0,1,0,0,20,115,97,109,112,108,101,114,0,0,1,0,
0,11,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,3,2,0,12,1,116,101,120,101,108,0,0,0,4,
118,101,99,52,95,115,104,97,100,49,100,0,18,116,101,120,101,108,0,0,18,115,97,109,112,108,101,114,
0,0,18,99,111,111,114,100,0,0,18,98,105,97,115,0,0,0,8,18,116,101,120,101,108,0,0,0,1,0,12,0,115,
104,97,100,111,119,49,68,80,114,111,106,0,1,0,0,20,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,
111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,115,104,97,100,111,119,49,68,0,18,115,97,109,
112,108,101,114,0,0,58,118,101,99,51,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,
113,0,49,0,17,48,0,48,0,0,0,18,99,111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,49,0,
0,0,18,98,105,97,115,0,0,0,0,0,1,0,12,0,115,104,97,100,111,119,50,68,0,1,0,0,21,115,97,109,112,108,
101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,3,2,0,12,1,116,101,120,
101,108,0,0,0,4,118,101,99,52,95,115,104,97,100,50,100,0,18,116,101,120,101,108,0,0,18,115,97,109,
112,108,101,114,0,0,18,99,111,111,114,100,0,0,18,98,105,97,115,0,0,0,8,18,116,101,120,101,108,0,0,
0,1,0,12,0,115,104,97,100,111,119,50,68,80,114,111,106,0,1,0,0,21,115,97,109,112,108,101,114,0,0,1,
0,0,12,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,115,104,97,100,111,119,50,68,0,18,
115,97,109,112,108,101,114,0,0,58,118,101,99,51,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,
114,100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,113,0,49,0,18,
99,111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,18,98,105,97,115,0,0,0,0,0,
1,0,9,0,100,70,100,120,0,1,0,0,9,112,0,0,0,1,8,17,48,0,48,48,49,0,0,0,0,1,0,10,0,100,70,100,120,0,
1,0,0,10,112,0,0,0,1,8,58,118,101,99,50,0,17,48,0,48,48,49,0,0,0,0,0,0,1,0,11,0,100,70,100,120,0,1,
0,0,11,112,0,0,0,1,8,58,118,101,99,51,0,17,48,0,48,48,49,0,0,0,0,0,0,1,0,12,0,100,70,100,120,0,1,0,
0,12,112,0,0,0,1,8,58,118,101,99,52,0,17,48,0,48,48,49,0,0,0,0,0,0,1,0,9,0,100,70,100,121,0,1,0,0,
9,112,0,0,0,1,8,17,48,0,48,48,49,0,0,0,0,1,0,10,0,100,70,100,121,0,1,0,0,10,112,0,0,0,1,8,58,118,
101,99,50,0,17,48,0,48,48,49,0,0,0,0,0,0,1,0,11,0,100,70,100,121,0,1,0,0,11,112,0,0,0,1,8,58,118,
101,99,51,0,17,48,0,48,48,49,0,0,0,0,0,0,1,0,12,0,100,70,100,121,0,1,0,0,12,112,0,0,0,1,8,58,118,
101,99,52,0,17,48,0,48,48,49,0,0,0,0,0,0,1,0,9,0,102,119,105,100,116,104,0,1,0,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,0,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,0,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,0,
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
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+118 -118
View File
@@ -1,118 +1,118 @@
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file slang_version.syn
* slang #version directive syntax
* \author Michal Krol
*/
.syntax version_directive;
version_directive
version_directive_1 .and .loop version_directive_2;
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;
version_directive_body
'#' .and optional_space .and "version" .and space .and version_number .and optional_space .and
new_line;
version_number
version_number_110;
version_number_110
leading_zeroes .and "110" .emit 10 .emit 1;
leading_zeroes
.loop zero;
zero
'0';
space
single_space .and .loop single_space;
optional_space
.loop single_space;
single_space
' ' .or '\t';
prior_optional_spaces
.loop prior_space;
prior_space
c_style_comment_block .or cpp_style_comment_block .or space .or new_line;
c_style_comment_block
'/' .and '*' .and c_style_comment_rest;
c_style_comment_rest
.loop c_style_comment_char_no_star .and c_style_comment_rest_1;
c_style_comment_rest_1
c_style_comment_end .or c_style_comment_rest_2;
c_style_comment_rest_2
'*' .and c_style_comment_rest;
c_style_comment_char_no_star
'\x2B'-'\xFF' .or '\x01'-'\x29';
c_style_comment_end
'*' .and '/';
cpp_style_comment_block
'/' .and '/' .and cpp_style_comment_block_1;
cpp_style_comment_block_1
cpp_style_comment_block_2 .or cpp_style_comment_block_3;
cpp_style_comment_block_2
.loop cpp_style_comment_char .and new_line;
cpp_style_comment_block_3
.loop cpp_style_comment_char;
cpp_style_comment_char
'\x0E'-'\xFF' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
new_line
cr_lf .or lf_cr .or '\n' .or '\r';
cr_lf
'\r' .and '\n';
lf_cr
'\n' .and '\r';
.string __string_filter;
__string_filter
.loop __identifier_char;
__identifier_char
'a'-'z' .or 'A'-'Z' .or '_' .or '0'-'9';
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file slang_version.syn
* slang #version directive syntax
* \author Michal Krol
*/
.syntax version_directive;
version_directive
version_directive_1 .and .loop version_directive_2;
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;
version_directive_body
'#' .and optional_space .and "version" .and space .and version_number .and optional_space .and
new_line;
version_number
version_number_110;
version_number_110
leading_zeroes .and "110" .emit 10 .emit 1;
leading_zeroes
.loop zero;
zero
'0';
space
single_space .and .loop single_space;
optional_space
.loop single_space;
single_space
' ' .or '\t';
prior_optional_spaces
.loop prior_space;
prior_space
c_style_comment_block .or cpp_style_comment_block .or space .or new_line;
c_style_comment_block
'/' .and '*' .and c_style_comment_rest;
c_style_comment_rest
.loop c_style_comment_char_no_star .and c_style_comment_rest_1;
c_style_comment_rest_1
c_style_comment_end .or c_style_comment_rest_2;
c_style_comment_rest_2
'*' .and c_style_comment_rest;
c_style_comment_char_no_star
'\x2B'-'\xFF' .or '\x01'-'\x29';
c_style_comment_end
'*' .and '/';
cpp_style_comment_block
'/' .and '/' .and cpp_style_comment_block_1;
cpp_style_comment_block_1
cpp_style_comment_block_2 .or cpp_style_comment_block_3;
cpp_style_comment_block_2
.loop cpp_style_comment_char .and new_line;
cpp_style_comment_block_3
.loop cpp_style_comment_char;
cpp_style_comment_char
'\x0E'-'\xFF' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
new_line
cr_lf .or lf_cr .or '\n' .or '\r';
cr_lf
'\r' .and '\n';
lf_cr
'\n' .and '\r';
.string __string_filter;
__string_filter
.loop __identifier_char;
__identifier_char
'a'-'z' .or 'A'-'Z' .or '_' .or '0'-'9';
@@ -1,64 +1,64 @@
".syntax version_directive;\n"
"version_directive\n"
" version_directive_1 .and .loop version_directive_2;\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;\n"
"version_number_110\n"
" leading_zeroes .and \"110\" .emit 10 .emit 1;\n"
"leading_zeroes\n"
" .loop zero;\n"
"zero\n"
" '0';\n"
"space\n"
" single_space .and .loop single_space;\n"
"optional_space\n"
" .loop single_space;\n"
"single_space\n"
" ' ' .or '\\t';\n"
"prior_optional_spaces\n"
" .loop prior_space;\n"
"prior_space\n"
" c_style_comment_block .or cpp_style_comment_block .or space .or new_line;\n"
"c_style_comment_block\n"
" '/' .and '*' .and c_style_comment_rest;\n"
"c_style_comment_rest\n"
" .loop c_style_comment_char_no_star .and c_style_comment_rest_1;\n"
"c_style_comment_rest_1\n"
" c_style_comment_end .or c_style_comment_rest_2;\n"
"c_style_comment_rest_2\n"
" '*' .and c_style_comment_rest;\n"
"c_style_comment_char_no_star\n"
" '\\x2B'-'\\xFF' .or '\\x01'-'\\x29';\n"
"c_style_comment_end\n"
" '*' .and '/';\n"
"cpp_style_comment_block\n"
" '/' .and '/' .and cpp_style_comment_block_1;\n"
"cpp_style_comment_block_1\n"
" cpp_style_comment_block_2 .or cpp_style_comment_block_3;\n"
"cpp_style_comment_block_2\n"
" .loop cpp_style_comment_char .and new_line;\n"
"cpp_style_comment_block_3\n"
" .loop cpp_style_comment_char;\n"
"cpp_style_comment_char\n"
" '\\x0E'-'\\xFF' .or '\\x01'-'\\x09' .or '\\x0B'-'\\x0C';\n"
"new_line\n"
" cr_lf .or lf_cr .or '\\n' .or '\\r';\n"
"cr_lf\n"
" '\\r' .and '\\n';\n"
"lf_cr\n"
" '\\n' .and '\\r';\n"
".string __string_filter;\n"
"__string_filter\n"
" .loop __identifier_char;\n"
"__identifier_char\n"
" 'a'-'z' .or 'A'-'Z' .or '_' .or '0'-'9';\n"
""
".syntax version_directive;\n"
"version_directive\n"
" version_directive_1 .and .loop version_directive_2;\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;\n"
"version_number_110\n"
" leading_zeroes .and \"110\" .emit 10 .emit 1;\n"
"leading_zeroes\n"
" .loop zero;\n"
"zero\n"
" '0';\n"
"space\n"
" single_space .and .loop single_space;\n"
"optional_space\n"
" .loop single_space;\n"
"single_space\n"
" ' ' .or '\\t';\n"
"prior_optional_spaces\n"
" .loop prior_space;\n"
"prior_space\n"
" c_style_comment_block .or cpp_style_comment_block .or space .or new_line;\n"
"c_style_comment_block\n"
" '/' .and '*' .and c_style_comment_rest;\n"
"c_style_comment_rest\n"
" .loop c_style_comment_char_no_star .and c_style_comment_rest_1;\n"
"c_style_comment_rest_1\n"
" c_style_comment_end .or c_style_comment_rest_2;\n"
"c_style_comment_rest_2\n"
" '*' .and c_style_comment_rest;\n"
"c_style_comment_char_no_star\n"
" '\\x2B'-'\\xFF' .or '\\x01'-'\\x29';\n"
"c_style_comment_end\n"
" '*' .and '/';\n"
"cpp_style_comment_block\n"
" '/' .and '/' .and cpp_style_comment_block_1;\n"
"cpp_style_comment_block_1\n"
" cpp_style_comment_block_2 .or cpp_style_comment_block_3;\n"
"cpp_style_comment_block_2\n"
" .loop cpp_style_comment_char .and new_line;\n"
"cpp_style_comment_block_3\n"
" .loop cpp_style_comment_char;\n"
"cpp_style_comment_char\n"
" '\\x0E'-'\\xFF' .or '\\x01'-'\\x09' .or '\\x0B'-'\\x0C';\n"
"new_line\n"
" cr_lf .or lf_cr .or '\\n' .or '\\r';\n"
"cr_lf\n"
" '\\r' .and '\\n';\n"
"lf_cr\n"
" '\\n' .and '\\r';\n"
".string __string_filter;\n"
"__string_filter\n"
" .loop __identifier_char;\n"
"__identifier_char\n"
" 'a'-'z' .or 'A'-'Z' .or '_' .or '0'-'9';\n"
""
@@ -1,26 +1,26 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//
// From Shader Spec, ver. 1.10, rev. 59
@@ -54,7 +54,7 @@ varying float gl_FogFragCoord;
//
// Geometric Functions
//
vec4 ftransform () {
return gl_ModelViewProjectionMatrix * gl_Vertex;
}
@@ -63,66 +63,66 @@ vec4 ftransform () {
// 8.7 Texture Lookup Functions
//
vec4 texture1DLod (sampler1D sampler, float coord, float lod) {
vec4 texel;
__asm vec4_tex1d texel, sampler, coord, lod;
vec4 texture1DLod (sampler1D sampler, float coord, float lod) {
vec4 texel;
__asm vec4_tex1d texel, sampler, coord, lod;
return texel;
}
}
vec4 texture1DProjLod (sampler1D sampler, vec2 coord, float lod) {
return texture1DLod (sampler, coord.s / coord.t, lod);
}
}
vec4 texture1DProjLod (sampler1D sampler, vec4 coord, float lod) {
return texture1DLod (sampler, coord.s / coord.q, lod);
}
vec4 texture2DLod (sampler2D sampler, vec2 coord, float lod) {
vec4 texel;
__asm vec4_tex2d texel, sampler, coord, lod;
vec4 texture2DLod (sampler2D sampler, vec2 coord, float lod) {
vec4 texel;
__asm vec4_tex2d texel, sampler, coord, lod;
return texel;
}
}
vec4 texture2DProjLod (sampler2D sampler, vec3 coord, float lod) {
vec4 texture2DProjLod (sampler2D sampler, vec3 coord, float lod) {
return texture2DLod (sampler, vec2 (coord.s / coord.p, coord.t / coord.p), lod);
}
}
vec4 texture2DProjLod (sampler2D sampler, vec4 coord, float lod) {
vec4 texture2DProjLod (sampler2D sampler, vec4 coord, float lod) {
return texture2DLod (sampler, vec2 (coord.s / coord.q, coord.t / coord.q), lod);
}
vec4 texture3DLod (sampler3D sampler, vec3 coord, float lod) {
vec4 texel;
__asm vec4_tex3d texel, sampler, coord, lod;
vec4 texture3DLod (sampler3D sampler, vec3 coord, float lod) {
vec4 texel;
__asm vec4_tex3d texel, sampler, coord, lod;
return texel;
}
vec4 texture3DProjLod (sampler3D sampler, vec4 coord, float lod) {
vec4 texture3DProjLod (sampler3D sampler, vec4 coord, float lod) {
return texture3DLod (sampler, vec3 (coord.s / coord.q, coord.t / coord.q, coord.p / coord.q), lod);
}
vec4 textureCubeLod (samplerCube sampler, vec3 coord, float lod) {
vec4 texel;
__asm vec4_texcube texel, sampler, coord, lod;
vec4 textureCubeLod (samplerCube sampler, vec3 coord, float lod) {
vec4 texel;
__asm vec4_texcube texel, sampler, coord, lod;
return texel;
}
vec4 shadow1DLod (sampler1DShadow sampler, vec3 coord, float lod) {
vec4 texel;
__asm vec4_shad1d texel, sampler, coord, lod;
vec4 shadow1DLod (sampler1DShadow sampler, vec3 coord, float lod) {
vec4 texel;
__asm vec4_shad1d texel, sampler, coord, lod;
return texel;
}
vec4 shadow1DProjLod (sampler1DShadow sampler, vec4 coord, float lod) {
return shadow1DLod (sampler, vec3 (coord.s / coord.q, 0.0, coord.p / coord.q), lod);
}
vec4 shadow2DLod (sampler2DShadow sampler, vec3 coord, float lod) {
vec4 texel;
__asm vec4_shad2d texel, sampler, coord, lod;
return texel;
}
vec4 shadow1DProjLod (sampler1DShadow sampler, vec4 coord, float lod) {
return shadow1DLod (sampler, vec3 (coord.s / coord.q, 0.0, coord.p / coord.q), lod);
}
vec4 shadow2DProjLod (sampler2DShadow sampler, vec4 coord, float lod) {
vec4 shadow2DLod (sampler2DShadow sampler, vec3 coord, float lod) {
vec4 texel;
__asm vec4_shad2d texel, sampler, coord, lod;
return texel;
}
vec4 shadow2DProjLod (sampler2DShadow sampler, vec4 coord, float lod) {
return shadow2DLod (sampler, vec3 (coord.s / coord.q, coord.t / coord.q, coord.p / coord.q), lod);
}
@@ -1,78 +1,78 @@
/* DO NOT EDIT - THIS FILE 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,8,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,0,18,103,108,95,86,101,114,116,101,120,0,48,0,0,1,0,12,0,
116,101,120,116,117,114,101,49,68,76,111,100,0,1,0,0,16,115,97,109,112,108,101,114,0,0,1,0,0,9,99,
111,111,114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,3,2,0,12,1,116,101,120,101,108,0,0,0,4,118,101,99,
52,95,116,101,120,49,100,0,18,116,101,120,101,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,
111,114,100,0,0,18,108,111,100,0,0,0,8,18,116,101,120,101,108,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,0,0,16,115,97,109,112,108,101,114,0,0,1,0,0,10,99,111,
111,114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,8,58,116,101,120,116,117,114,101,49,68,76,111,100,0,18,
115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,116,0,
49,0,18,108,111,100,0,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,0,0,16,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,1,0,0,9,108,111,100,0,0,
0,1,8,58,116,101,120,116,117,114,101,49,68,76,111,100,0,18,115,97,109,112,108,101,114,0,0,18,99,
111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,18,108,111,100,0,0,0,0,0,1,0,12,0,
116,101,120,116,117,114,101,50,68,76,111,100,0,1,0,0,17,115,97,109,112,108,101,114,0,0,1,0,0,10,99,
111,111,114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,3,2,0,12,1,116,101,120,101,108,0,0,0,4,118,101,99,
52,95,116,101,120,50,100,0,18,116,101,120,101,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,
111,114,100,0,0,18,108,111,100,0,0,0,8,18,116,101,120,101,108,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,0,0,17,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,
111,114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,8,58,116,101,120,116,117,114,101,50,68,76,111,100,0,18,
115,97,109,112,108,101,114,0,0,58,118,101,99,50,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,
114,100,0,59,112,0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,112,0,49,0,0,0,
18,108,111,100,0,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,
0,0,17,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,
8,58,116,101,120,116,117,114,101,50,68,76,111,100,0,18,115,97,109,112,108,101,114,0,0,58,118,101,
99,50,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,111,111,114,
100,0,59,116,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,18,108,111,100,0,0,0,0,0,1,0,12,0,116,101,
120,116,117,114,101,51,68,76,111,100,0,1,0,0,18,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,111,
114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,3,2,0,12,1,116,101,120,101,108,0,0,0,4,118,101,99,52,95,
116,101,120,51,100,0,18,116,101,120,101,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,
114,100,0,0,18,108,111,100,0,0,0,8,18,116,101,120,101,108,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,0,0,18,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,111,
114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,8,58,116,101,120,116,117,114,101,51,68,76,111,100,0,18,115,
97,109,112,108,101,114,0,0,58,118,101,99,51,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,
100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,
111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,18,108,111,100,0,0,0,0,0,1,0,
12,0,116,101,120,116,117,114,101,67,117,98,101,76,111,100,0,1,0,0,19,115,97,109,112,108,101,114,0,
0,1,0,0,11,99,111,111,114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,3,2,0,12,1,116,101,120,101,108,0,0,0,
4,118,101,99,52,95,116,101,120,99,117,98,101,0,18,116,101,120,101,108,0,0,18,115,97,109,112,108,
101,114,0,0,18,99,111,111,114,100,0,0,18,108,111,100,0,0,0,8,18,116,101,120,101,108,0,0,0,1,0,12,0,
115,104,97,100,111,119,49,68,76,111,100,0,1,0,0,20,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,
111,114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,3,2,0,12,1,116,101,120,101,108,0,0,0,4,118,101,99,52,
95,115,104,97,100,49,100,0,18,116,101,120,101,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,
111,114,100,0,0,18,108,111,100,0,0,0,8,18,116,101,120,101,108,0,0,0,1,0,12,0,115,104,97,100,111,
119,49,68,80,114,111,106,76,111,100,0,1,0,0,20,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,111,
114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,8,58,115,104,97,100,111,119,49,68,76,111,100,0,18,115,97,
109,112,108,101,114,0,0,58,118,101,99,51,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,
0,59,113,0,49,0,17,48,0,48,0,0,0,18,99,111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,
49,0,0,0,18,108,111,100,0,0,0,0,0,1,0,12,0,115,104,97,100,111,119,50,68,76,111,100,0,1,0,0,21,115,
97,109,112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,3,2,0,12,1,
116,101,120,101,108,0,0,0,4,118,101,99,52,95,115,104,97,100,50,100,0,18,116,101,120,101,108,0,0,18,
115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,18,108,111,100,0,0,0,8,18,116,101,120,101,
108,0,0,0,1,0,12,0,115,104,97,100,111,119,50,68,80,114,111,106,76,111,100,0,1,0,0,21,115,97,109,
112,108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,8,58,115,104,97,
100,111,119,50,68,76,111,100,0,18,115,97,109,112,108,101,114,0,0,58,118,101,99,51,0,18,99,111,111,
114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,
111,111,114,100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,
49,0,0,0,18,108,111,100,0,0,0,0,0,0
/* DO NOT EDIT - THIS FILE 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,8,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,0,18,103,108,95,86,101,114,116,101,120,0,48,0,0,1,0,12,0,
116,101,120,116,117,114,101,49,68,76,111,100,0,1,0,0,16,115,97,109,112,108,101,114,0,0,1,0,0,9,99,
111,111,114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,3,2,0,12,1,116,101,120,101,108,0,0,0,4,118,101,99,
52,95,116,101,120,49,100,0,18,116,101,120,101,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,
111,114,100,0,0,18,108,111,100,0,0,0,8,18,116,101,120,101,108,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,0,0,16,115,97,109,112,108,101,114,0,0,1,0,0,10,99,111,
111,114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,8,58,116,101,120,116,117,114,101,49,68,76,111,100,0,18,
115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,116,0,
49,0,18,108,111,100,0,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,0,0,16,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,1,0,0,9,108,111,100,0,0,
0,1,8,58,116,101,120,116,117,114,101,49,68,76,111,100,0,18,115,97,109,112,108,101,114,0,0,18,99,
111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,18,108,111,100,0,0,0,0,0,1,0,12,0,
116,101,120,116,117,114,101,50,68,76,111,100,0,1,0,0,17,115,97,109,112,108,101,114,0,0,1,0,0,10,99,
111,111,114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,3,2,0,12,1,116,101,120,101,108,0,0,0,4,118,101,99,
52,95,116,101,120,50,100,0,18,116,101,120,101,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,
111,114,100,0,0,18,108,111,100,0,0,0,8,18,116,101,120,101,108,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,0,0,17,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,
111,114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,8,58,116,101,120,116,117,114,101,50,68,76,111,100,0,18,
115,97,109,112,108,101,114,0,0,58,118,101,99,50,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,
114,100,0,59,112,0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,112,0,49,0,0,0,
18,108,111,100,0,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,
0,0,17,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,
8,58,116,101,120,116,117,114,101,50,68,76,111,100,0,18,115,97,109,112,108,101,114,0,0,58,118,101,
99,50,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,111,111,114,
100,0,59,116,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,18,108,111,100,0,0,0,0,0,1,0,12,0,116,101,
120,116,117,114,101,51,68,76,111,100,0,1,0,0,18,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,111,
114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,3,2,0,12,1,116,101,120,101,108,0,0,0,4,118,101,99,52,95,
116,101,120,51,100,0,18,116,101,120,101,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,
114,100,0,0,18,108,111,100,0,0,0,8,18,116,101,120,101,108,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,0,0,18,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,111,
114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,8,58,116,101,120,116,117,114,101,51,68,76,111,100,0,18,115,
97,109,112,108,101,114,0,0,58,118,101,99,51,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,
100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,
111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,18,108,111,100,0,0,0,0,0,1,0,
12,0,116,101,120,116,117,114,101,67,117,98,101,76,111,100,0,1,0,0,19,115,97,109,112,108,101,114,0,
0,1,0,0,11,99,111,111,114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,3,2,0,12,1,116,101,120,101,108,0,0,0,
4,118,101,99,52,95,116,101,120,99,117,98,101,0,18,116,101,120,101,108,0,0,18,115,97,109,112,108,
101,114,0,0,18,99,111,111,114,100,0,0,18,108,111,100,0,0,0,8,18,116,101,120,101,108,0,0,0,1,0,12,0,
115,104,97,100,111,119,49,68,76,111,100,0,1,0,0,20,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,
111,114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,3,2,0,12,1,116,101,120,101,108,0,0,0,4,118,101,99,52,
95,115,104,97,100,49,100,0,18,116,101,120,101,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,
111,114,100,0,0,18,108,111,100,0,0,0,8,18,116,101,120,101,108,0,0,0,1,0,12,0,115,104,97,100,111,
119,49,68,80,114,111,106,76,111,100,0,1,0,0,20,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,111,
114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,8,58,115,104,97,100,111,119,49,68,76,111,100,0,18,115,97,
109,112,108,101,114,0,0,58,118,101,99,51,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,
0,59,113,0,49,0,17,48,0,48,0,0,0,18,99,111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,
49,0,0,0,18,108,111,100,0,0,0,0,0,1,0,12,0,115,104,97,100,111,119,50,68,76,111,100,0,1,0,0,21,115,
97,109,112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,3,2,0,12,1,
116,101,120,101,108,0,0,0,4,118,101,99,52,95,115,104,97,100,50,100,0,18,116,101,120,101,108,0,0,18,
115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,18,108,111,100,0,0,0,8,18,116,101,120,101,
108,0,0,0,1,0,12,0,115,104,97,100,111,119,50,68,80,114,111,106,76,111,100,0,1,0,0,21,115,97,109,
112,108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,8,58,115,104,97,
100,111,119,50,68,76,111,100,0,18,115,97,109,112,108,101,114,0,0,58,118,101,99,51,0,18,99,111,111,
114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,
111,111,114,100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,
49,0,0,0,18,108,111,100,0,0,0,0,0,0
+100 -100
View File
@@ -1,100 +1,100 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file slang_analyse.c
* slang assembly code analysis
* \author Michal Krol
*/
#include "imports.h"
#include "slang_analyse.h"
#include "slang_utility.h"
GLboolean _slang_analyse_texture_usage (slang_program *prog)
{
GLuint i, count = 0;
slang_texture_usages_dtr (&prog->texture_usage);
slang_texture_usages_ctr (&prog->texture_usage);
/*
* We could do a full code analysis to find out which uniforms are actually used.
* For now, we are very conservative and extract them from uniform binding table, which
* in turn also do not come from code analysis.
*/
for (i = 0; i < prog->uniforms.count; i++)
{
slang_uniform_binding *b = &prog->uniforms.table[i];
if (b->address[SLANG_SHADER_FRAGMENT] != ~0 && !slang_export_data_quant_struct (b->quant))
{
switch (slang_export_data_quant_type (b->quant))
{
case GL_SAMPLER_1D_ARB:
case GL_SAMPLER_2D_ARB:
case GL_SAMPLER_3D_ARB:
case GL_SAMPLER_CUBE_ARB:
case GL_SAMPLER_1D_SHADOW_ARB:
case GL_SAMPLER_2D_SHADOW_ARB:
count++;
break;
}
}
}
if (count == 0)
return GL_TRUE;
prog->texture_usage.table = (slang_texture_usage *) slang_alloc_malloc (
count * sizeof (slang_texture_usage));
if (prog->texture_usage.table == NULL)
return GL_FALSE;
prog->texture_usage.count = count;
for (count = i = 0; i < prog->uniforms.count; i++)
{
slang_uniform_binding *b = &prog->uniforms.table[i];
if (b->address[SLANG_SHADER_FRAGMENT] != ~0 && !slang_export_data_quant_struct (b->quant))
{
switch (slang_export_data_quant_type (b->quant))
{
case GL_SAMPLER_1D_ARB:
case GL_SAMPLER_2D_ARB:
case GL_SAMPLER_3D_ARB:
case GL_SAMPLER_CUBE_ARB:
case GL_SAMPLER_1D_SHADOW_ARB:
case GL_SAMPLER_2D_SHADOW_ARB:
prog->texture_usage.table[count].quant = b->quant;
prog->texture_usage.table[count].frag_address = b->address[SLANG_SHADER_FRAGMENT];
count++;
break;
}
}
}
return GL_TRUE;
}
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file slang_analyse.c
* slang assembly code analysis
* \author Michal Krol
*/
#include "imports.h"
#include "slang_analyse.h"
#include "slang_utility.h"
GLboolean _slang_analyse_texture_usage (slang_program *prog)
{
GLuint i, count = 0;
slang_texture_usages_dtr (&prog->texture_usage);
slang_texture_usages_ctr (&prog->texture_usage);
/*
* We could do a full code analysis to find out which uniforms are actually used.
* For now, we are very conservative and extract them from uniform binding table, which
* in turn also do not come from code analysis.
*/
for (i = 0; i < prog->uniforms.count; i++)
{
slang_uniform_binding *b = &prog->uniforms.table[i];
if (b->address[SLANG_SHADER_FRAGMENT] != ~0 && !slang_export_data_quant_struct (b->quant))
{
switch (slang_export_data_quant_type (b->quant))
{
case GL_SAMPLER_1D_ARB:
case GL_SAMPLER_2D_ARB:
case GL_SAMPLER_3D_ARB:
case GL_SAMPLER_CUBE_ARB:
case GL_SAMPLER_1D_SHADOW_ARB:
case GL_SAMPLER_2D_SHADOW_ARB:
count++;
break;
}
}
}
if (count == 0)
return GL_TRUE;
prog->texture_usage.table = (slang_texture_usage *) slang_alloc_malloc (
count * sizeof (slang_texture_usage));
if (prog->texture_usage.table == NULL)
return GL_FALSE;
prog->texture_usage.count = count;
for (count = i = 0; i < prog->uniforms.count; i++)
{
slang_uniform_binding *b = &prog->uniforms.table[i];
if (b->address[SLANG_SHADER_FRAGMENT] != ~0 && !slang_export_data_quant_struct (b->quant))
{
switch (slang_export_data_quant_type (b->quant))
{
case GL_SAMPLER_1D_ARB:
case GL_SAMPLER_2D_ARB:
case GL_SAMPLER_3D_ARB:
case GL_SAMPLER_CUBE_ARB:
case GL_SAMPLER_1D_SHADOW_ARB:
case GL_SAMPLER_2D_SHADOW_ARB:
prog->texture_usage.table[count].quant = b->quant;
prog->texture_usage.table[count].frag_address = b->address[SLANG_SHADER_FRAGMENT];
count++;
break;
}
}
}
return GL_TRUE;
}
+50 -50
View File
@@ -1,50 +1,50 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_ANALYSE_H
#define SLANG_ANALYSE_H
#include "slang_link.h"
#if defined __cplusplus
extern "C" {
#endif
/*
* Texture usage analysis is a bit more difficult than for fragment programs. While fragment
* programs statically link to texture targets and texture units, shaders statically link
* only to texture targets. The texture unit linkage is determined just before the execution
* of a given primitive by reading active uniform samplers.
*
* This procedure retrieves a list of uniforms that reach texture sample instructions.
*/
GLboolean _slang_analyse_texture_usage (slang_program *);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_ANALYSE_H
#define SLANG_ANALYSE_H
#include "slang_link.h"
#if defined __cplusplus
extern "C" {
#endif
/*
* Texture usage analysis is a bit more difficult than for fragment programs. While fragment
* programs statically link to texture targets and texture units, shaders statically link
* only to texture targets. The texture unit linkage is determined just before the execution
* of a given primitive by reading active uniform samplers.
*
* This procedure retrieves a list of uniforms that reach texture sample instructions.
*/
GLboolean _slang_analyse_texture_usage (slang_program *);
#ifdef __cplusplus
}
#endif
#endif
File diff suppressed because it is too large Load Diff
+214 -214
View File
@@ -1,214 +1,214 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_ASSEMBLE_H
#define SLANG_ASSEMBLE_H
#include "slang_utility.h"
#if defined __cplusplus
extern "C" {
#endif
struct slang_operation_;
typedef enum slang_assembly_type_
{
/* core */
slang_asm_none,
slang_asm_float_copy,
slang_asm_float_move,
slang_asm_float_push,
slang_asm_float_deref,
slang_asm_float_add,
slang_asm_float_multiply,
slang_asm_float_divide,
slang_asm_float_negate,
slang_asm_float_less,
slang_asm_float_equal_exp,
slang_asm_float_equal_int,
slang_asm_float_to_int,
slang_asm_float_sine,
slang_asm_float_arcsine,
slang_asm_float_arctan,
slang_asm_float_power,
slang_asm_float_log2,
slang_asm_float_floor,
slang_asm_float_ceil,
slang_asm_float_noise1,
slang_asm_float_noise2,
slang_asm_float_noise3,
slang_asm_float_noise4,
slang_asm_int_copy,
slang_asm_int_move,
slang_asm_int_push,
slang_asm_int_deref,
slang_asm_int_to_float,
slang_asm_int_to_addr,
slang_asm_bool_copy,
slang_asm_bool_move,
slang_asm_bool_push,
slang_asm_bool_deref,
slang_asm_addr_copy,
slang_asm_addr_push,
slang_asm_addr_deref,
slang_asm_addr_add,
slang_asm_addr_multiply,
slang_asm_vec4_tex1d,
slang_asm_vec4_tex2d,
slang_asm_vec4_tex3d,
slang_asm_vec4_texcube,
slang_asm_vec4_shad1d,
slang_asm_vec4_shad2d,
slang_asm_jump,
slang_asm_jump_if_zero,
slang_asm_enter,
slang_asm_leave,
slang_asm_local_alloc,
slang_asm_local_free,
slang_asm_local_addr,
slang_asm_global_addr,
slang_asm_call,
slang_asm_return,
slang_asm_discard,
slang_asm_exit,
/* mesa-specific extensions */
slang_asm_float_print,
slang_asm_int_print,
slang_asm_bool_print,
slang_asm__last
} slang_assembly_type;
typedef struct slang_assembly_
{
slang_assembly_type type;
GLfloat literal;
GLuint param[2];
} slang_assembly;
typedef struct slang_assembly_file_
{
slang_assembly *code;
GLuint count;
GLuint capacity;
} slang_assembly_file;
GLboolean slang_assembly_file_construct (slang_assembly_file *);
GLvoid slang_assembly_file_destruct (slang_assembly_file *);
GLboolean slang_assembly_file_push (slang_assembly_file *, slang_assembly_type);
GLboolean slang_assembly_file_push_label (slang_assembly_file *, slang_assembly_type, GLuint);
GLboolean slang_assembly_file_push_label2 (slang_assembly_file *, slang_assembly_type, GLuint, GLuint);
GLboolean slang_assembly_file_push_literal (slang_assembly_file *, slang_assembly_type, GLfloat);
typedef struct slang_assembly_file_restore_point_
{
GLuint count;
} slang_assembly_file_restore_point;
GLboolean slang_assembly_file_restore_point_save (slang_assembly_file *,
slang_assembly_file_restore_point *);
GLboolean slang_assembly_file_restore_point_load (slang_assembly_file *,
slang_assembly_file_restore_point *);
typedef struct slang_assembly_flow_control_
{
GLuint loop_start; /* for "continue" statement */
GLuint loop_end; /* for "break" statement */
GLuint function_end; /* for "return" statement */
} slang_assembly_flow_control;
typedef struct slang_assembly_local_info_
{
GLuint ret_size;
GLuint addr_tmp;
GLuint swizzle_tmp;
} slang_assembly_local_info;
typedef enum
{
slang_ref_force,
slang_ref_forbid/*,
slang_ref_freelance*/
} slang_ref_type;
/*
* Holds a complete information about vector swizzle - the <swizzle> array contains
* vector component source indices, where 0 is "x", 1 is "y", 2 is "z" and 3 is "w".
* Example: "xwz" --> { 3, { 0, 3, 2, not used } }.
*/
typedef struct slang_swizzle_
{
GLuint num_components;
GLuint swizzle[4];
} slang_swizzle;
typedef struct slang_assembly_name_space_
{
struct slang_function_scope_ *funcs;
struct slang_struct_scope_ *structs;
struct slang_variable_scope_ *vars;
} slang_assembly_name_space;
typedef struct slang_assemble_ctx_
{
slang_assembly_file *file;
struct slang_machine_ *mach;
slang_atom_pool *atoms;
slang_assembly_name_space space;
slang_assembly_flow_control flow;
slang_assembly_local_info local;
slang_ref_type ref;
slang_swizzle swz;
} slang_assemble_ctx;
struct slang_function_ *_slang_locate_function (struct slang_function_scope_ *funcs, slang_atom name,
struct slang_operation_ *params, GLuint num_params, slang_assembly_name_space *space,
slang_atom_pool *);
GLboolean _slang_assemble_function (slang_assemble_ctx *, struct slang_function_ *);
GLboolean _slang_cleanup_stack (slang_assemble_ctx *, struct slang_operation_ *);
GLboolean _slang_dereference (slang_assemble_ctx *, struct slang_operation_ *);
GLboolean _slang_assemble_function_call (slang_assemble_ctx *, struct slang_function_ *,
struct slang_operation_ *, GLuint, GLboolean);
GLboolean _slang_assemble_function_call_name (slang_assemble_ctx *, const char *,
struct slang_operation_ *, GLuint, GLboolean);
GLboolean _slang_assemble_operation (slang_assemble_ctx *, struct slang_operation_ *,
slang_ref_type);
#ifdef __cplusplus
}
#endif
#include "slang_assemble_assignment.h"
#include "slang_assemble_typeinfo.h"
#include "slang_assemble_constructor.h"
#include "slang_assemble_conditional.h"
#endif
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_ASSEMBLE_H
#define SLANG_ASSEMBLE_H
#include "slang_utility.h"
#if defined __cplusplus
extern "C" {
#endif
struct slang_operation_;
typedef enum slang_assembly_type_
{
/* core */
slang_asm_none,
slang_asm_float_copy,
slang_asm_float_move,
slang_asm_float_push,
slang_asm_float_deref,
slang_asm_float_add,
slang_asm_float_multiply,
slang_asm_float_divide,
slang_asm_float_negate,
slang_asm_float_less,
slang_asm_float_equal_exp,
slang_asm_float_equal_int,
slang_asm_float_to_int,
slang_asm_float_sine,
slang_asm_float_arcsine,
slang_asm_float_arctan,
slang_asm_float_power,
slang_asm_float_log2,
slang_asm_float_floor,
slang_asm_float_ceil,
slang_asm_float_noise1,
slang_asm_float_noise2,
slang_asm_float_noise3,
slang_asm_float_noise4,
slang_asm_int_copy,
slang_asm_int_move,
slang_asm_int_push,
slang_asm_int_deref,
slang_asm_int_to_float,
slang_asm_int_to_addr,
slang_asm_bool_copy,
slang_asm_bool_move,
slang_asm_bool_push,
slang_asm_bool_deref,
slang_asm_addr_copy,
slang_asm_addr_push,
slang_asm_addr_deref,
slang_asm_addr_add,
slang_asm_addr_multiply,
slang_asm_vec4_tex1d,
slang_asm_vec4_tex2d,
slang_asm_vec4_tex3d,
slang_asm_vec4_texcube,
slang_asm_vec4_shad1d,
slang_asm_vec4_shad2d,
slang_asm_jump,
slang_asm_jump_if_zero,
slang_asm_enter,
slang_asm_leave,
slang_asm_local_alloc,
slang_asm_local_free,
slang_asm_local_addr,
slang_asm_global_addr,
slang_asm_call,
slang_asm_return,
slang_asm_discard,
slang_asm_exit,
/* mesa-specific extensions */
slang_asm_float_print,
slang_asm_int_print,
slang_asm_bool_print,
slang_asm__last
} slang_assembly_type;
typedef struct slang_assembly_
{
slang_assembly_type type;
GLfloat literal;
GLuint param[2];
} slang_assembly;
typedef struct slang_assembly_file_
{
slang_assembly *code;
GLuint count;
GLuint capacity;
} slang_assembly_file;
GLboolean slang_assembly_file_construct (slang_assembly_file *);
GLvoid slang_assembly_file_destruct (slang_assembly_file *);
GLboolean slang_assembly_file_push (slang_assembly_file *, slang_assembly_type);
GLboolean slang_assembly_file_push_label (slang_assembly_file *, slang_assembly_type, GLuint);
GLboolean slang_assembly_file_push_label2 (slang_assembly_file *, slang_assembly_type, GLuint, GLuint);
GLboolean slang_assembly_file_push_literal (slang_assembly_file *, slang_assembly_type, GLfloat);
typedef struct slang_assembly_file_restore_point_
{
GLuint count;
} slang_assembly_file_restore_point;
GLboolean slang_assembly_file_restore_point_save (slang_assembly_file *,
slang_assembly_file_restore_point *);
GLboolean slang_assembly_file_restore_point_load (slang_assembly_file *,
slang_assembly_file_restore_point *);
typedef struct slang_assembly_flow_control_
{
GLuint loop_start; /* for "continue" statement */
GLuint loop_end; /* for "break" statement */
GLuint function_end; /* for "return" statement */
} slang_assembly_flow_control;
typedef struct slang_assembly_local_info_
{
GLuint ret_size;
GLuint addr_tmp;
GLuint swizzle_tmp;
} slang_assembly_local_info;
typedef enum
{
slang_ref_force,
slang_ref_forbid/*,
slang_ref_freelance*/
} slang_ref_type;
/*
* Holds a complete information about vector swizzle - the <swizzle> array contains
* vector component source indices, where 0 is "x", 1 is "y", 2 is "z" and 3 is "w".
* Example: "xwz" --> { 3, { 0, 3, 2, not used } }.
*/
typedef struct slang_swizzle_
{
GLuint num_components;
GLuint swizzle[4];
} slang_swizzle;
typedef struct slang_assembly_name_space_
{
struct slang_function_scope_ *funcs;
struct slang_struct_scope_ *structs;
struct slang_variable_scope_ *vars;
} slang_assembly_name_space;
typedef struct slang_assemble_ctx_
{
slang_assembly_file *file;
struct slang_machine_ *mach;
slang_atom_pool *atoms;
slang_assembly_name_space space;
slang_assembly_flow_control flow;
slang_assembly_local_info local;
slang_ref_type ref;
slang_swizzle swz;
} slang_assemble_ctx;
struct slang_function_ *_slang_locate_function (struct slang_function_scope_ *funcs, slang_atom name,
struct slang_operation_ *params, GLuint num_params, slang_assembly_name_space *space,
slang_atom_pool *);
GLboolean _slang_assemble_function (slang_assemble_ctx *, struct slang_function_ *);
GLboolean _slang_cleanup_stack (slang_assemble_ctx *, struct slang_operation_ *);
GLboolean _slang_dereference (slang_assemble_ctx *, struct slang_operation_ *);
GLboolean _slang_assemble_function_call (slang_assemble_ctx *, struct slang_function_ *,
struct slang_operation_ *, GLuint, GLboolean);
GLboolean _slang_assemble_function_call_name (slang_assemble_ctx *, const char *,
struct slang_operation_ *, GLuint, GLboolean);
GLboolean _slang_assemble_operation (slang_assemble_ctx *, struct slang_operation_ *,
slang_ref_type);
#ifdef __cplusplus
}
#endif
#include "slang_assemble_assignment.h"
#include "slang_assemble_typeinfo.h"
#include "slang_assemble_constructor.h"
#include "slang_assemble_conditional.h"
#endif
+194 -194
View File
@@ -1,194 +1,194 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file slang_assemble_assignment.c
* slang assignment expressions assembler
* \author Michal Krol
*/
#include "imports.h"
#include "slang_assemble.h"
#include "slang_storage.h"
/*
* _slang_assemble_assignment()
*
* Copies values on the stack (<component 0> to <component N-1>) to a memory
* location pointed by <addr of variable>.
*
* in:
* +------------------+
* | addr of variable |
* +------------------+
* | component N-1 |
* | ... |
* | component 0 |
* +------------------+
*
* out:
* +------------------+
* | addr of variable |
* +------------------+
*/
static GLboolean assign_aggregate (slang_assemble_ctx *A, const slang_storage_aggregate *agg,
GLuint *index, GLuint size)
{
GLuint i;
for (i = 0; i < agg->count; i++)
{
const slang_storage_array *arr = &agg->arrays[i];
GLuint j;
for (j = 0; j < arr->length; j++)
{
if (arr->type == slang_stor_aggregate)
{
if (!assign_aggregate (A, arr->aggregate, index, size))
return GL_FALSE;
}
else
{
GLuint dst_addr_loc, dst_offset;
slang_assembly_type ty;
/* calculate the distance from top of the stack to the destination address */
dst_addr_loc = size - *index;
/* calculate the offset within destination variable to write */
if (A->swz.num_components != 0)
{
/* swizzle the index to get the actual offset */
dst_offset = A->swz.swizzle[*index / 4] * 4;
}
else
{
/* no swizzling - write sequentially */
dst_offset = *index;
}
switch (arr->type)
{
case slang_stor_bool:
ty = slang_asm_bool_copy;
break;
case slang_stor_int:
ty = slang_asm_int_copy;
break;
case slang_stor_float:
ty = slang_asm_float_copy;
break;
default:
break;
}
if (!slang_assembly_file_push_label2 (A->file, ty, dst_addr_loc, dst_offset))
return GL_FALSE;
*index += 4;
}
}
}
return GL_TRUE;
}
GLboolean _slang_assemble_assignment (slang_assemble_ctx *A, slang_operation *op)
{
slang_assembly_typeinfo ti;
GLboolean result = GL_FALSE;
slang_storage_aggregate agg;
GLuint index, size;
if (!slang_assembly_typeinfo_construct (&ti))
return GL_FALSE;
if (!_slang_typeof_operation (A, op, &ti))
goto end1;
if (!slang_storage_aggregate_construct (&agg))
goto end1;
if (!_slang_aggregate_variable (&agg, &ti.spec, 0, A->space.funcs, A->space.structs,
A->space.vars, A->mach, A->file, A->atoms))
goto end;
index = 0;
size = _slang_sizeof_aggregate (&agg);
result = assign_aggregate (A, &agg, &index, size);
end1:
slang_storage_aggregate_destruct (&agg);
end:
slang_assembly_typeinfo_destruct (&ti);
return result;
}
/*
* _slang_assemble_assign()
*
* Performs unary (pre ++ and --) or binary (=, +=, -=, *=, /=) assignment on the operation's
* children.
*/
GLboolean _slang_assemble_assign (slang_assemble_ctx *A, slang_operation *op, const char *oper,
slang_ref_type ref)
{
slang_swizzle swz;
if (ref == slang_ref_forbid)
{
if (!slang_assembly_file_push_label2 (A->file, slang_asm_local_addr, A->local.addr_tmp, 4))
return GL_FALSE;
}
if (slang_string_compare ("=", oper) == 0)
{
if (!_slang_assemble_operation (A, &op->children[0], slang_ref_force))
return GL_FALSE;
swz = A->swz;
if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid))
return GL_FALSE;
A->swz = swz;
if (!_slang_assemble_assignment (A, op->children))
return GL_FALSE;
}
else
{
if (!_slang_assemble_function_call_name (A, oper, op->children, op->num_children, GL_TRUE))
return GL_FALSE;
}
if (ref == slang_ref_forbid)
{
if (!slang_assembly_file_push (A->file, slang_asm_addr_copy))
return GL_FALSE;
if (!slang_assembly_file_push_label (A->file, slang_asm_local_free, 4))
return GL_FALSE;
if (!_slang_dereference (A, op->children))
return GL_FALSE;
}
return GL_TRUE;
}
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file slang_assemble_assignment.c
* slang assignment expressions assembler
* \author Michal Krol
*/
#include "imports.h"
#include "slang_assemble.h"
#include "slang_storage.h"
/*
* _slang_assemble_assignment()
*
* Copies values on the stack (<component 0> to <component N-1>) to a memory
* location pointed by <addr of variable>.
*
* in:
* +------------------+
* | addr of variable |
* +------------------+
* | component N-1 |
* | ... |
* | component 0 |
* +------------------+
*
* out:
* +------------------+
* | addr of variable |
* +------------------+
*/
static GLboolean assign_aggregate (slang_assemble_ctx *A, const slang_storage_aggregate *agg,
GLuint *index, GLuint size)
{
GLuint i;
for (i = 0; i < agg->count; i++)
{
const slang_storage_array *arr = &agg->arrays[i];
GLuint j;
for (j = 0; j < arr->length; j++)
{
if (arr->type == slang_stor_aggregate)
{
if (!assign_aggregate (A, arr->aggregate, index, size))
return GL_FALSE;
}
else
{
GLuint dst_addr_loc, dst_offset;
slang_assembly_type ty;
/* calculate the distance from top of the stack to the destination address */
dst_addr_loc = size - *index;
/* calculate the offset within destination variable to write */
if (A->swz.num_components != 0)
{
/* swizzle the index to get the actual offset */
dst_offset = A->swz.swizzle[*index / 4] * 4;
}
else
{
/* no swizzling - write sequentially */
dst_offset = *index;
}
switch (arr->type)
{
case slang_stor_bool:
ty = slang_asm_bool_copy;
break;
case slang_stor_int:
ty = slang_asm_int_copy;
break;
case slang_stor_float:
ty = slang_asm_float_copy;
break;
default:
break;
}
if (!slang_assembly_file_push_label2 (A->file, ty, dst_addr_loc, dst_offset))
return GL_FALSE;
*index += 4;
}
}
}
return GL_TRUE;
}
GLboolean _slang_assemble_assignment (slang_assemble_ctx *A, slang_operation *op)
{
slang_assembly_typeinfo ti;
GLboolean result = GL_FALSE;
slang_storage_aggregate agg;
GLuint index, size;
if (!slang_assembly_typeinfo_construct (&ti))
return GL_FALSE;
if (!_slang_typeof_operation (A, op, &ti))
goto end1;
if (!slang_storage_aggregate_construct (&agg))
goto end1;
if (!_slang_aggregate_variable (&agg, &ti.spec, 0, A->space.funcs, A->space.structs,
A->space.vars, A->mach, A->file, A->atoms))
goto end;
index = 0;
size = _slang_sizeof_aggregate (&agg);
result = assign_aggregate (A, &agg, &index, size);
end1:
slang_storage_aggregate_destruct (&agg);
end:
slang_assembly_typeinfo_destruct (&ti);
return result;
}
/*
* _slang_assemble_assign()
*
* Performs unary (pre ++ and --) or binary (=, +=, -=, *=, /=) assignment on the operation's
* children.
*/
GLboolean _slang_assemble_assign (slang_assemble_ctx *A, slang_operation *op, const char *oper,
slang_ref_type ref)
{
slang_swizzle swz;
if (ref == slang_ref_forbid)
{
if (!slang_assembly_file_push_label2 (A->file, slang_asm_local_addr, A->local.addr_tmp, 4))
return GL_FALSE;
}
if (slang_string_compare ("=", oper) == 0)
{
if (!_slang_assemble_operation (A, &op->children[0], slang_ref_force))
return GL_FALSE;
swz = A->swz;
if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid))
return GL_FALSE;
A->swz = swz;
if (!_slang_assemble_assignment (A, op->children))
return GL_FALSE;
}
else
{
if (!_slang_assemble_function_call_name (A, oper, op->children, op->num_children, GL_TRUE))
return GL_FALSE;
}
if (ref == slang_ref_forbid)
{
if (!slang_assembly_file_push (A->file, slang_asm_addr_copy))
return GL_FALSE;
if (!slang_assembly_file_push_label (A->file, slang_asm_local_free, 4))
return GL_FALSE;
if (!_slang_dereference (A, op->children))
return GL_FALSE;
}
return GL_TRUE;
}
@@ -1,42 +1,42 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_ASSEMBLE_ASSIGNMENT_H
#define SLANG_ASSEMBLE_ASSIGNMENT_H
#if defined __cplusplus
extern "C" {
#endif
GLboolean _slang_assemble_assignment (slang_assemble_ctx *, struct slang_operation_ *);
GLboolean _slang_assemble_assign (slang_assemble_ctx *, struct slang_operation_ *, const char *,
slang_ref_type);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_ASSEMBLE_ASSIGNMENT_H
#define SLANG_ASSEMBLE_ASSIGNMENT_H
#if defined __cplusplus
extern "C" {
#endif
GLboolean _slang_assemble_assignment (slang_assemble_ctx *, struct slang_operation_ *);
GLboolean _slang_assemble_assign (slang_assemble_ctx *, struct slang_operation_ *, const char *,
slang_ref_type);
#ifdef __cplusplus
}
#endif
#endif
+448 -448
View File
@@ -1,448 +1,448 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file slang_assemble_conditional.c
* slang condtional expressions assembler
* \author Michal Krol
*/
#include "imports.h"
#include "slang_assemble.h"
#include "slang_compile.h"
/*
* _slang_assemble_logicaland()
*
* and:
* <left-expression>
* jumpz zero
* <right-expression>
* jump end
* zero:
* push 0
* end:
*/
GLboolean _slang_assemble_logicaland (slang_assemble_ctx *A, slang_operation *op)
{
GLuint zero_jump, end_jump;
/* evaluate left expression */
if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid))
return GL_FALSE;
/* jump to pushing 0 if not true */
zero_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero))
return GL_FALSE;
/* evaluate right expression */
if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid))
return GL_FALSE;
/* jump to the end of the expression */
end_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump))
return GL_FALSE;
/* push 0 on stack */
A->file->code[zero_jump].param[0] = A->file->count;
if (!slang_assembly_file_push_literal (A->file, slang_asm_bool_push, (GLfloat) 0))
return GL_FALSE;
/* the end of the expression */
A->file->code[end_jump].param[0] = A->file->count;
return GL_TRUE;
}
/*
* _slang_assemble_logicalor()
*
* or:
* <left-expression>
* jumpz right
* push 1
* jump end
* right:
* <right-expression>
* end:
*/
GLboolean _slang_assemble_logicalor (slang_assemble_ctx *A, slang_operation *op)
{
GLuint right_jump, end_jump;
/* evaluate left expression */
if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid))
return GL_FALSE;
/* jump to evaluation of right expression if not true */
right_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero))
return GL_FALSE;
/* push 1 on stack */
if (!slang_assembly_file_push_literal (A->file, slang_asm_bool_push, (GLfloat) 1))
return GL_FALSE;
/* jump to the end of the expression */
end_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump))
return GL_FALSE;
/* evaluate right expression */
A->file->code[right_jump].param[0] = A->file->count;
if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid))
return GL_FALSE;
/* the end of the expression */
A->file->code[end_jump].param[0] = A->file->count;
return GL_TRUE;
}
/*
* _slang_assemble_select()
*
* select:
* <condition-expression>
* jumpz false
* <true-expression>
* jump end
* false:
* <false-expression>
* end:
*/
GLboolean _slang_assemble_select (slang_assemble_ctx *A, slang_operation *op)
{
GLuint cond_jump, end_jump;
/* execute condition expression */
if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid))
return GL_FALSE;
/* jump to false expression if not true */
cond_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero))
return GL_FALSE;
/* execute true expression */
if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid))
return GL_FALSE;
/* jump to the end of the expression */
end_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump))
return GL_FALSE;
/* resolve false point */
A->file->code[cond_jump].param[0] = A->file->count;
/* execute false expression */
if (!_slang_assemble_operation (A, &op->children[2], slang_ref_forbid))
return GL_FALSE;
/* resolve the end of the expression */
A->file->code[end_jump].param[0] = A->file->count;
return GL_TRUE;
}
/*
* _slang_assemble_for()
*
* for:
* <init-statement>
* jump start
* break:
* jump end
* continue:
* <loop-increment>
* start:
* <condition-statement>
* jumpz end
* <loop-body>
* jump continue
* end:
*/
GLboolean _slang_assemble_for (slang_assemble_ctx *A, slang_operation *op)
{
GLuint start_jump, end_jump, cond_jump;
GLuint break_label, cont_label;
slang_assembly_flow_control save_flow = A->flow;
/* execute initialization statement */
if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid/*slang_ref_freelance*/))
return GL_FALSE;
if (!_slang_cleanup_stack (A, &op->children[0]))
return GL_FALSE;
/* skip the "go to the end of the loop" and loop-increment statements */
start_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump))
return GL_FALSE;
/* go to the end of the loop - break statements are directed here */
break_label = A->file->count;
end_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump))
return GL_FALSE;
/* resolve the beginning of the loop - continue statements are directed here */
cont_label = A->file->count;
/* execute loop-increment statement */
if (!_slang_assemble_operation (A, &op->children[2], slang_ref_forbid/*slang_ref_freelance*/))
return GL_FALSE;
if (!_slang_cleanup_stack (A, &op->children[2]))
return GL_FALSE;
/* resolve the condition point */
A->file->code[start_jump].param[0] = A->file->count;
/* execute condition statement */
if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid))
return GL_FALSE;
/* jump to the end of the loop if not true */
cond_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero))
return GL_FALSE;
/* execute loop body */
A->flow.loop_start = cont_label;
A->flow.loop_end = break_label;
if (!_slang_assemble_operation (A, &op->children[3], slang_ref_forbid/*slang_ref_freelance*/))
return GL_FALSE;
if (!_slang_cleanup_stack (A, &op->children[3]))
return GL_FALSE;
A->flow = save_flow;
/* go to the beginning of the loop */
if (!slang_assembly_file_push_label (A->file, slang_asm_jump, cont_label))
return GL_FALSE;
/* resolve the end of the loop */
A->file->code[end_jump].param[0] = A->file->count;
A->file->code[cond_jump].param[0] = A->file->count;
return GL_TRUE;
}
/*
* _slang_assemble_do()
*
* do:
* jump start
* break:
* jump end
* continue:
* jump condition
* start:
* <loop-body>
* condition:
* <condition-statement>
* jumpz end
* jump start
* end:
*/
GLboolean _slang_assemble_do (slang_assemble_ctx *A, slang_operation *op)
{
GLuint skip_jump, end_jump, cont_jump, cond_jump;
GLuint break_label, cont_label;
slang_assembly_flow_control save_flow = A->flow;
/* skip the "go to the end of the loop" and "go to condition" statements */
skip_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump))
return GL_FALSE;
/* go to the end of the loop - break statements are directed here */
break_label = A->file->count;
end_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump))
return GL_FALSE;
/* go to condition - continue statements are directed here */
cont_label = A->file->count;
cont_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump))
return GL_FALSE;
/* resolve the beginning of the loop */
A->file->code[skip_jump].param[0] = A->file->count;
/* execute loop body */
A->flow.loop_start = cont_label;
A->flow.loop_end = break_label;
if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid/*slang_ref_freelance*/))
return GL_FALSE;
if (!_slang_cleanup_stack (A, &op->children[0]))
return GL_FALSE;
A->flow = save_flow;
/* resolve condition point */
A->file->code[cont_jump].param[0] = A->file->count;
/* execute condition statement */
if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid))
return GL_FALSE;
/* jump to the end of the loop if not true */
cond_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero))
return GL_FALSE;
/* jump to the beginning of the loop */
if (!slang_assembly_file_push_label (A->file, slang_asm_jump, A->file->code[skip_jump].param[0]))
return GL_FALSE;
/* resolve the end of the loop */
A->file->code[end_jump].param[0] = A->file->count;
A->file->code[cond_jump].param[0] = A->file->count;
return GL_TRUE;
}
/*
* _slang_assemble_while()
*
* while:
* jump continue
* break:
* jump end
* continue:
* <condition-statement>
* jumpz end
* <loop-body>
* jump continue
* end:
*/
GLboolean _slang_assemble_while (slang_assemble_ctx *A, slang_operation *op)
{
GLuint skip_jump, end_jump, cond_jump;
GLuint break_label;
slang_assembly_flow_control save_flow = A->flow;
/* skip the "go to the end of the loop" statement */
skip_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump))
return GL_FALSE;
/* go to the end of the loop - break statements are directed here */
break_label = A->file->count;
end_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump))
return GL_FALSE;
/* resolve the beginning of the loop - continue statements are directed here */
A->file->code[skip_jump].param[0] = A->file->count;
/* execute condition statement */
if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid))
return GL_FALSE;
/* jump to the end of the loop if not true */
cond_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero))
return GL_FALSE;
/* execute loop body */
A->flow.loop_start = A->file->code[skip_jump].param[0];
A->flow.loop_end = break_label;
if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid/*slang_ref_freelance*/))
return GL_FALSE;
if (!_slang_cleanup_stack (A, &op->children[1]))
return GL_FALSE;
A->flow = save_flow;
/* jump to the beginning of the loop */
if (!slang_assembly_file_push_label (A->file, slang_asm_jump, A->file->code[skip_jump].param[0]))
return GL_FALSE;
/* resolve the end of the loop */
A->file->code[end_jump].param[0] = A->file->count;
A->file->code[cond_jump].param[0] = A->file->count;
return GL_TRUE;
}
/*
* _slang_assemble_if()
*
* if:
* <condition-statement>
* jumpz else
* <true-statement>
* jump end
* else:
* <false-statement>
* end:
*/
GLboolean _slang_assemble_if (slang_assemble_ctx *A, slang_operation *op)
{
GLuint cond_jump, else_jump;
/* execute condition statement */
if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid))
return GL_FALSE;
/* jump to false-statement if not true */
cond_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero))
return GL_FALSE;
/* execute true-statement */
if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid/*slang_ref_freelance*/))
return GL_FALSE;
if (!_slang_cleanup_stack (A, &op->children[1]))
return GL_FALSE;
/* skip if-false statement */
else_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump))
return GL_FALSE;
/* resolve start of false-statement */
A->file->code[cond_jump].param[0] = A->file->count;
/* execute false-statement */
if (!_slang_assemble_operation (A, &op->children[2], slang_ref_forbid/*slang_ref_freelance*/))
return GL_FALSE;
if (!_slang_cleanup_stack (A, &op->children[2]))
return GL_FALSE;
/* resolve end of if-false statement */
A->file->code[else_jump].param[0] = A->file->count;
return GL_TRUE;
}
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file slang_assemble_conditional.c
* slang condtional expressions assembler
* \author Michal Krol
*/
#include "imports.h"
#include "slang_assemble.h"
#include "slang_compile.h"
/*
* _slang_assemble_logicaland()
*
* and:
* <left-expression>
* jumpz zero
* <right-expression>
* jump end
* zero:
* push 0
* end:
*/
GLboolean _slang_assemble_logicaland (slang_assemble_ctx *A, slang_operation *op)
{
GLuint zero_jump, end_jump;
/* evaluate left expression */
if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid))
return GL_FALSE;
/* jump to pushing 0 if not true */
zero_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero))
return GL_FALSE;
/* evaluate right expression */
if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid))
return GL_FALSE;
/* jump to the end of the expression */
end_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump))
return GL_FALSE;
/* push 0 on stack */
A->file->code[zero_jump].param[0] = A->file->count;
if (!slang_assembly_file_push_literal (A->file, slang_asm_bool_push, (GLfloat) 0))
return GL_FALSE;
/* the end of the expression */
A->file->code[end_jump].param[0] = A->file->count;
return GL_TRUE;
}
/*
* _slang_assemble_logicalor()
*
* or:
* <left-expression>
* jumpz right
* push 1
* jump end
* right:
* <right-expression>
* end:
*/
GLboolean _slang_assemble_logicalor (slang_assemble_ctx *A, slang_operation *op)
{
GLuint right_jump, end_jump;
/* evaluate left expression */
if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid))
return GL_FALSE;
/* jump to evaluation of right expression if not true */
right_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero))
return GL_FALSE;
/* push 1 on stack */
if (!slang_assembly_file_push_literal (A->file, slang_asm_bool_push, (GLfloat) 1))
return GL_FALSE;
/* jump to the end of the expression */
end_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump))
return GL_FALSE;
/* evaluate right expression */
A->file->code[right_jump].param[0] = A->file->count;
if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid))
return GL_FALSE;
/* the end of the expression */
A->file->code[end_jump].param[0] = A->file->count;
return GL_TRUE;
}
/*
* _slang_assemble_select()
*
* select:
* <condition-expression>
* jumpz false
* <true-expression>
* jump end
* false:
* <false-expression>
* end:
*/
GLboolean _slang_assemble_select (slang_assemble_ctx *A, slang_operation *op)
{
GLuint cond_jump, end_jump;
/* execute condition expression */
if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid))
return GL_FALSE;
/* jump to false expression if not true */
cond_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero))
return GL_FALSE;
/* execute true expression */
if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid))
return GL_FALSE;
/* jump to the end of the expression */
end_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump))
return GL_FALSE;
/* resolve false point */
A->file->code[cond_jump].param[0] = A->file->count;
/* execute false expression */
if (!_slang_assemble_operation (A, &op->children[2], slang_ref_forbid))
return GL_FALSE;
/* resolve the end of the expression */
A->file->code[end_jump].param[0] = A->file->count;
return GL_TRUE;
}
/*
* _slang_assemble_for()
*
* for:
* <init-statement>
* jump start
* break:
* jump end
* continue:
* <loop-increment>
* start:
* <condition-statement>
* jumpz end
* <loop-body>
* jump continue
* end:
*/
GLboolean _slang_assemble_for (slang_assemble_ctx *A, slang_operation *op)
{
GLuint start_jump, end_jump, cond_jump;
GLuint break_label, cont_label;
slang_assembly_flow_control save_flow = A->flow;
/* execute initialization statement */
if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid/*slang_ref_freelance*/))
return GL_FALSE;
if (!_slang_cleanup_stack (A, &op->children[0]))
return GL_FALSE;
/* skip the "go to the end of the loop" and loop-increment statements */
start_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump))
return GL_FALSE;
/* go to the end of the loop - break statements are directed here */
break_label = A->file->count;
end_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump))
return GL_FALSE;
/* resolve the beginning of the loop - continue statements are directed here */
cont_label = A->file->count;
/* execute loop-increment statement */
if (!_slang_assemble_operation (A, &op->children[2], slang_ref_forbid/*slang_ref_freelance*/))
return GL_FALSE;
if (!_slang_cleanup_stack (A, &op->children[2]))
return GL_FALSE;
/* resolve the condition point */
A->file->code[start_jump].param[0] = A->file->count;
/* execute condition statement */
if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid))
return GL_FALSE;
/* jump to the end of the loop if not true */
cond_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero))
return GL_FALSE;
/* execute loop body */
A->flow.loop_start = cont_label;
A->flow.loop_end = break_label;
if (!_slang_assemble_operation (A, &op->children[3], slang_ref_forbid/*slang_ref_freelance*/))
return GL_FALSE;
if (!_slang_cleanup_stack (A, &op->children[3]))
return GL_FALSE;
A->flow = save_flow;
/* go to the beginning of the loop */
if (!slang_assembly_file_push_label (A->file, slang_asm_jump, cont_label))
return GL_FALSE;
/* resolve the end of the loop */
A->file->code[end_jump].param[0] = A->file->count;
A->file->code[cond_jump].param[0] = A->file->count;
return GL_TRUE;
}
/*
* _slang_assemble_do()
*
* do:
* jump start
* break:
* jump end
* continue:
* jump condition
* start:
* <loop-body>
* condition:
* <condition-statement>
* jumpz end
* jump start
* end:
*/
GLboolean _slang_assemble_do (slang_assemble_ctx *A, slang_operation *op)
{
GLuint skip_jump, end_jump, cont_jump, cond_jump;
GLuint break_label, cont_label;
slang_assembly_flow_control save_flow = A->flow;
/* skip the "go to the end of the loop" and "go to condition" statements */
skip_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump))
return GL_FALSE;
/* go to the end of the loop - break statements are directed here */
break_label = A->file->count;
end_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump))
return GL_FALSE;
/* go to condition - continue statements are directed here */
cont_label = A->file->count;
cont_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump))
return GL_FALSE;
/* resolve the beginning of the loop */
A->file->code[skip_jump].param[0] = A->file->count;
/* execute loop body */
A->flow.loop_start = cont_label;
A->flow.loop_end = break_label;
if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid/*slang_ref_freelance*/))
return GL_FALSE;
if (!_slang_cleanup_stack (A, &op->children[0]))
return GL_FALSE;
A->flow = save_flow;
/* resolve condition point */
A->file->code[cont_jump].param[0] = A->file->count;
/* execute condition statement */
if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid))
return GL_FALSE;
/* jump to the end of the loop if not true */
cond_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero))
return GL_FALSE;
/* jump to the beginning of the loop */
if (!slang_assembly_file_push_label (A->file, slang_asm_jump, A->file->code[skip_jump].param[0]))
return GL_FALSE;
/* resolve the end of the loop */
A->file->code[end_jump].param[0] = A->file->count;
A->file->code[cond_jump].param[0] = A->file->count;
return GL_TRUE;
}
/*
* _slang_assemble_while()
*
* while:
* jump continue
* break:
* jump end
* continue:
* <condition-statement>
* jumpz end
* <loop-body>
* jump continue
* end:
*/
GLboolean _slang_assemble_while (slang_assemble_ctx *A, slang_operation *op)
{
GLuint skip_jump, end_jump, cond_jump;
GLuint break_label;
slang_assembly_flow_control save_flow = A->flow;
/* skip the "go to the end of the loop" statement */
skip_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump))
return GL_FALSE;
/* go to the end of the loop - break statements are directed here */
break_label = A->file->count;
end_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump))
return GL_FALSE;
/* resolve the beginning of the loop - continue statements are directed here */
A->file->code[skip_jump].param[0] = A->file->count;
/* execute condition statement */
if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid))
return GL_FALSE;
/* jump to the end of the loop if not true */
cond_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero))
return GL_FALSE;
/* execute loop body */
A->flow.loop_start = A->file->code[skip_jump].param[0];
A->flow.loop_end = break_label;
if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid/*slang_ref_freelance*/))
return GL_FALSE;
if (!_slang_cleanup_stack (A, &op->children[1]))
return GL_FALSE;
A->flow = save_flow;
/* jump to the beginning of the loop */
if (!slang_assembly_file_push_label (A->file, slang_asm_jump, A->file->code[skip_jump].param[0]))
return GL_FALSE;
/* resolve the end of the loop */
A->file->code[end_jump].param[0] = A->file->count;
A->file->code[cond_jump].param[0] = A->file->count;
return GL_TRUE;
}
/*
* _slang_assemble_if()
*
* if:
* <condition-statement>
* jumpz else
* <true-statement>
* jump end
* else:
* <false-statement>
* end:
*/
GLboolean _slang_assemble_if (slang_assemble_ctx *A, slang_operation *op)
{
GLuint cond_jump, else_jump;
/* execute condition statement */
if (!_slang_assemble_operation (A, &op->children[0], slang_ref_forbid))
return GL_FALSE;
/* jump to false-statement if not true */
cond_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump_if_zero))
return GL_FALSE;
/* execute true-statement */
if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid/*slang_ref_freelance*/))
return GL_FALSE;
if (!_slang_cleanup_stack (A, &op->children[1]))
return GL_FALSE;
/* skip if-false statement */
else_jump = A->file->count;
if (!slang_assembly_file_push (A->file, slang_asm_jump))
return GL_FALSE;
/* resolve start of false-statement */
A->file->code[cond_jump].param[0] = A->file->count;
/* execute false-statement */
if (!_slang_assemble_operation (A, &op->children[2], slang_ref_forbid/*slang_ref_freelance*/))
return GL_FALSE;
if (!_slang_cleanup_stack (A, &op->children[2]))
return GL_FALSE;
/* resolve end of if-false statement */
A->file->code[else_jump].param[0] = A->file->count;
return GL_TRUE;
}
@@ -1,51 +1,51 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_ASSEMBLE_CONDITIONAL_H
#define SLANG_ASSEMBLE_CONDITIONAL_H
#if defined __cplusplus
extern "C" {
#endif
GLboolean _slang_assemble_logicaland (slang_assemble_ctx *, struct slang_operation_ *);
GLboolean _slang_assemble_logicalor (slang_assemble_ctx *, struct slang_operation_ *);
GLboolean _slang_assemble_select (slang_assemble_ctx *, struct slang_operation_ *);
GLboolean _slang_assemble_for (slang_assemble_ctx *, struct slang_operation_ *);
GLboolean _slang_assemble_do (slang_assemble_ctx *, struct slang_operation_ *);
GLboolean _slang_assemble_while (slang_assemble_ctx *, struct slang_operation_ *);
GLboolean _slang_assemble_if (slang_assemble_ctx *, struct slang_operation_ *);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_ASSEMBLE_CONDITIONAL_H
#define SLANG_ASSEMBLE_CONDITIONAL_H
#if defined __cplusplus
extern "C" {
#endif
GLboolean _slang_assemble_logicaland (slang_assemble_ctx *, struct slang_operation_ *);
GLboolean _slang_assemble_logicalor (slang_assemble_ctx *, struct slang_operation_ *);
GLboolean _slang_assemble_select (slang_assemble_ctx *, struct slang_operation_ *);
GLboolean _slang_assemble_for (slang_assemble_ctx *, struct slang_operation_ *);
GLboolean _slang_assemble_do (slang_assemble_ctx *, struct slang_operation_ *);
GLboolean _slang_assemble_while (slang_assemble_ctx *, struct slang_operation_ *);
GLboolean _slang_assemble_if (slang_assemble_ctx *, struct slang_operation_ *);
#ifdef __cplusplus
}
#endif
#endif
+385 -385
View File
@@ -1,385 +1,385 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file slang_assemble_constructor.c
* slang constructor and vector swizzle assembler
* \author Michal Krol
*/
#include "imports.h"
#include "slang_assemble.h"
#include "slang_storage.h"
/* _slang_is_swizzle() */
GLboolean _slang_is_swizzle (const char *field, GLuint rows, slang_swizzle *swz)
{
GLuint i;
GLboolean xyzw = GL_FALSE, rgba = GL_FALSE, stpq = GL_FALSE;
/* the swizzle can be at most 4-component long */
swz->num_components = slang_string_length (field);
if (swz->num_components > 4)
return GL_FALSE;
for (i = 0; i < swz->num_components; i++)
{
/* mark which swizzle group is used */
switch (field[i])
{
case 'x':
case 'y':
case 'z':
case 'w':
xyzw = GL_TRUE;
break;
case 'r':
case 'g':
case 'b':
case 'a':
rgba = GL_TRUE;
break;
case 's':
case 't':
case 'p':
case 'q':
stpq = GL_TRUE;
break;
default:
return GL_FALSE;
}
/* collect swizzle component */
switch (field[i])
{
case 'x':
case 'r':
case 's':
swz->swizzle[i] = 0;
break;
case 'y':
case 'g':
case 't':
swz->swizzle[i] = 1;
break;
case 'z':
case 'b':
case 'p':
swz->swizzle[i] = 2;
break;
case 'w':
case 'a':
case 'q':
swz->swizzle[i] = 3;
break;
}
/* check if the component is valid for given vector's row count */
if (rows <= swz->swizzle[i])
return GL_FALSE;
}
/* only one swizzle group can be used */
if ((xyzw && rgba) || (xyzw && stpq) || (rgba && stpq))
return GL_FALSE;
return GL_TRUE;
}
/* _slang_is_swizzle_mask() */
GLboolean _slang_is_swizzle_mask (const slang_swizzle *swz, GLuint rows)
{
GLuint i, c = 0;
/* the swizzle may not be longer than the vector dim */
if (swz->num_components > rows)
return GL_FALSE;
/* the swizzle components cannot be duplicated */
for (i = 0; i < swz->num_components; i++)
{
if ((c & (1 << swz->swizzle[i])) != 0)
return GL_FALSE;
c |= 1 << swz->swizzle[i];
}
return GL_TRUE;
}
/* _slang_multiply_swizzles() */
GLvoid _slang_multiply_swizzles (slang_swizzle *dst, const slang_swizzle *left,
const slang_swizzle *right)
{
GLuint i;
dst->num_components = right->num_components;
for (i = 0; i < right->num_components; i++)
dst->swizzle[i] = left->swizzle[right->swizzle[i]];
}
/* _slang_assemble_constructor() */
static GLboolean sizeof_argument (slang_assemble_ctx *A, GLuint *size, slang_operation *op)
{
slang_assembly_typeinfo ti;
GLboolean result = GL_FALSE;
slang_storage_aggregate agg, flat_agg;
if (!slang_assembly_typeinfo_construct (&ti))
return GL_FALSE;
if (!_slang_typeof_operation (A, op, &ti))
goto end1;
if (!slang_storage_aggregate_construct (&agg))
goto end1;
if (!_slang_aggregate_variable (&agg, &ti.spec, 0, A->space.funcs, A->space.structs,
A->space.vars, A->mach, A->file, A->atoms))
goto end2;
if (!slang_storage_aggregate_construct (&flat_agg))
goto end2;
if (!_slang_flatten_aggregate (&flat_agg, &agg))
goto end;
*size = flat_agg.count * 4;
result = GL_TRUE;
end:
slang_storage_aggregate_destruct (&flat_agg);
end2:
slang_storage_aggregate_destruct (&agg);
end1:
slang_assembly_typeinfo_destruct (&ti);
return result;
}
static GLboolean constructor_aggregate (slang_assemble_ctx *A, const slang_storage_aggregate *flat,
slang_operation *op, GLuint garbage_size)
{
slang_assembly_typeinfo ti;
GLboolean result = GL_FALSE;
slang_storage_aggregate agg, flat_agg;
if (!slang_assembly_typeinfo_construct (&ti))
return GL_FALSE;
if (!_slang_typeof_operation (A, op, &ti))
goto end1;
if (!slang_storage_aggregate_construct (&agg))
goto end1;
if (!_slang_aggregate_variable (&agg, &ti.spec, 0, A->space.funcs, A->space.structs,
A->space.vars, A->mach, A->file, A->atoms))
goto end2;
if (!slang_storage_aggregate_construct (&flat_agg))
goto end2;
if (!_slang_flatten_aggregate (&flat_agg, &agg))
goto end;
if (!_slang_assemble_operation (A, op, slang_ref_forbid))
goto end;
/* TODO: convert (generic) elements */
/* free the garbage */
if (garbage_size != 0)
{
GLuint i;
/* move the non-garbage part to the end of the argument */
if (!slang_assembly_file_push_label (A->file, slang_asm_addr_push, 0))
goto end;
for (i = flat_agg.count * 4 - garbage_size; i > 0; i -= 4)
{
if (!slang_assembly_file_push_label2 (A->file, slang_asm_float_move,
garbage_size + i, i))
{
goto end;
}
}
if (!slang_assembly_file_push_label (A->file, slang_asm_local_free, garbage_size + 4))
goto end;
}
result = GL_TRUE;
end:
slang_storage_aggregate_destruct (&flat_agg);
end2:
slang_storage_aggregate_destruct (&agg);
end1:
slang_assembly_typeinfo_destruct (&ti);
return result;
}
GLboolean _slang_assemble_constructor (slang_assemble_ctx *A, slang_operation *op)
{
slang_assembly_typeinfo ti;
GLboolean result = GL_FALSE;
slang_storage_aggregate agg, flat;
GLuint size, i;
GLuint arg_sums[2];
/* get typeinfo of the constructor (the result of constructor expression) */
if (!slang_assembly_typeinfo_construct (&ti))
return GL_FALSE;
if (!_slang_typeof_operation (A, op, &ti))
goto end1;
/* create an aggregate of the constructor */
if (!slang_storage_aggregate_construct (&agg))
goto end1;
if (!_slang_aggregate_variable (&agg, &ti.spec, 0, A->space.funcs, A->space.structs,
A->space.vars, A->mach, A->file, A->atoms))
goto end2;
/* calculate size of the constructor */
size = _slang_sizeof_aggregate (&agg);
/* flatten the constructor */
if (!slang_storage_aggregate_construct (&flat))
goto end2;
if (!_slang_flatten_aggregate (&flat, &agg))
goto end;
/* collect the last two constructor's argument size sums */
arg_sums[0] = 0; /* will hold all but the last argument's size sum */
arg_sums[1] = 0; /* will hold all argument's size sum */
for (i = 0; i < op->num_children; i++)
{
GLuint arg_size;
if (!sizeof_argument (A, &arg_size, &op->children[i]))
goto end;
if (i > 0)
arg_sums[0] = arg_sums[1];
arg_sums[1] += arg_size;
}
/* check if there are too many arguments */
if (arg_sums[0] >= size)
{
/* TODO: info log: too many arguments in constructor list */
goto end;
}
/* check if there are too few arguments */
if (arg_sums[1] < size)
{
/* TODO: info log: too few arguments in constructor list */
goto end;
}
/* traverse the children that form the constructor expression */
for (i = op->num_children; i > 0; i--)
{
GLuint garbage_size;
/* the last argument may be too big - calculate the unnecessary data size */
if (i == op->num_children)
garbage_size = arg_sums[1] - size;
else
garbage_size = 0;
if (!constructor_aggregate (A, &flat, &op->children[i - 1], garbage_size))
goto end;
}
result = GL_TRUE;
end:
slang_storage_aggregate_destruct (&flat);
end2:
slang_storage_aggregate_destruct (&agg);
end1:
slang_assembly_typeinfo_destruct (&ti);
return result;
}
/* _slang_assemble_constructor_from_swizzle() */
GLboolean _slang_assemble_constructor_from_swizzle (slang_assemble_ctx *A, const slang_swizzle *swz,
slang_type_specifier *spec, slang_type_specifier *master_spec)
{
GLuint master_rows, i;
master_rows = _slang_type_dim (master_spec->type);
for (i = 0; i < master_rows; i++)
{
switch (_slang_type_base (master_spec->type))
{
case slang_spec_bool:
if (!slang_assembly_file_push_label2 (A->file, slang_asm_bool_copy,
(master_rows - i) * 4, i * 4))
return GL_FALSE;
break;
case slang_spec_int:
if (!slang_assembly_file_push_label2 (A->file, slang_asm_int_copy,
(master_rows - i) * 4, i * 4))
return GL_FALSE;
break;
case slang_spec_float:
if (!slang_assembly_file_push_label2 (A->file, slang_asm_float_copy,
(master_rows - i) * 4, i * 4))
return GL_FALSE;
break;
default:
break;
}
}
if (!slang_assembly_file_push_label (A->file, slang_asm_local_free, 4))
return GL_FALSE;
for (i = swz->num_components; i > 0; i--)
{
GLuint n = i - 1;
if (!slang_assembly_file_push_label2 (A->file, slang_asm_local_addr, A->local.swizzle_tmp, 16))
return GL_FALSE;
if (!slang_assembly_file_push_label (A->file, slang_asm_addr_push, swz->swizzle[n] * 4))
return GL_FALSE;
if (!slang_assembly_file_push (A->file, slang_asm_addr_add))
return GL_FALSE;
switch (_slang_type_base (master_spec->type))
{
case slang_spec_bool:
if (!slang_assembly_file_push (A->file, slang_asm_bool_deref))
return GL_FALSE;
break;
case slang_spec_int:
if (!slang_assembly_file_push (A->file, slang_asm_int_deref))
return GL_FALSE;
break;
case slang_spec_float:
if (!slang_assembly_file_push (A->file, slang_asm_float_deref))
return GL_FALSE;
break;
default:
break;
}
}
return GL_TRUE;
}
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file slang_assemble_constructor.c
* slang constructor and vector swizzle assembler
* \author Michal Krol
*/
#include "imports.h"
#include "slang_assemble.h"
#include "slang_storage.h"
/* _slang_is_swizzle() */
GLboolean _slang_is_swizzle (const char *field, GLuint rows, slang_swizzle *swz)
{
GLuint i;
GLboolean xyzw = GL_FALSE, rgba = GL_FALSE, stpq = GL_FALSE;
/* the swizzle can be at most 4-component long */
swz->num_components = slang_string_length (field);
if (swz->num_components > 4)
return GL_FALSE;
for (i = 0; i < swz->num_components; i++)
{
/* mark which swizzle group is used */
switch (field[i])
{
case 'x':
case 'y':
case 'z':
case 'w':
xyzw = GL_TRUE;
break;
case 'r':
case 'g':
case 'b':
case 'a':
rgba = GL_TRUE;
break;
case 's':
case 't':
case 'p':
case 'q':
stpq = GL_TRUE;
break;
default:
return GL_FALSE;
}
/* collect swizzle component */
switch (field[i])
{
case 'x':
case 'r':
case 's':
swz->swizzle[i] = 0;
break;
case 'y':
case 'g':
case 't':
swz->swizzle[i] = 1;
break;
case 'z':
case 'b':
case 'p':
swz->swizzle[i] = 2;
break;
case 'w':
case 'a':
case 'q':
swz->swizzle[i] = 3;
break;
}
/* check if the component is valid for given vector's row count */
if (rows <= swz->swizzle[i])
return GL_FALSE;
}
/* only one swizzle group can be used */
if ((xyzw && rgba) || (xyzw && stpq) || (rgba && stpq))
return GL_FALSE;
return GL_TRUE;
}
/* _slang_is_swizzle_mask() */
GLboolean _slang_is_swizzle_mask (const slang_swizzle *swz, GLuint rows)
{
GLuint i, c = 0;
/* the swizzle may not be longer than the vector dim */
if (swz->num_components > rows)
return GL_FALSE;
/* the swizzle components cannot be duplicated */
for (i = 0; i < swz->num_components; i++)
{
if ((c & (1 << swz->swizzle[i])) != 0)
return GL_FALSE;
c |= 1 << swz->swizzle[i];
}
return GL_TRUE;
}
/* _slang_multiply_swizzles() */
GLvoid _slang_multiply_swizzles (slang_swizzle *dst, const slang_swizzle *left,
const slang_swizzle *right)
{
GLuint i;
dst->num_components = right->num_components;
for (i = 0; i < right->num_components; i++)
dst->swizzle[i] = left->swizzle[right->swizzle[i]];
}
/* _slang_assemble_constructor() */
static GLboolean sizeof_argument (slang_assemble_ctx *A, GLuint *size, slang_operation *op)
{
slang_assembly_typeinfo ti;
GLboolean result = GL_FALSE;
slang_storage_aggregate agg, flat_agg;
if (!slang_assembly_typeinfo_construct (&ti))
return GL_FALSE;
if (!_slang_typeof_operation (A, op, &ti))
goto end1;
if (!slang_storage_aggregate_construct (&agg))
goto end1;
if (!_slang_aggregate_variable (&agg, &ti.spec, 0, A->space.funcs, A->space.structs,
A->space.vars, A->mach, A->file, A->atoms))
goto end2;
if (!slang_storage_aggregate_construct (&flat_agg))
goto end2;
if (!_slang_flatten_aggregate (&flat_agg, &agg))
goto end;
*size = flat_agg.count * 4;
result = GL_TRUE;
end:
slang_storage_aggregate_destruct (&flat_agg);
end2:
slang_storage_aggregate_destruct (&agg);
end1:
slang_assembly_typeinfo_destruct (&ti);
return result;
}
static GLboolean constructor_aggregate (slang_assemble_ctx *A, const slang_storage_aggregate *flat,
slang_operation *op, GLuint garbage_size)
{
slang_assembly_typeinfo ti;
GLboolean result = GL_FALSE;
slang_storage_aggregate agg, flat_agg;
if (!slang_assembly_typeinfo_construct (&ti))
return GL_FALSE;
if (!_slang_typeof_operation (A, op, &ti))
goto end1;
if (!slang_storage_aggregate_construct (&agg))
goto end1;
if (!_slang_aggregate_variable (&agg, &ti.spec, 0, A->space.funcs, A->space.structs,
A->space.vars, A->mach, A->file, A->atoms))
goto end2;
if (!slang_storage_aggregate_construct (&flat_agg))
goto end2;
if (!_slang_flatten_aggregate (&flat_agg, &agg))
goto end;
if (!_slang_assemble_operation (A, op, slang_ref_forbid))
goto end;
/* TODO: convert (generic) elements */
/* free the garbage */
if (garbage_size != 0)
{
GLuint i;
/* move the non-garbage part to the end of the argument */
if (!slang_assembly_file_push_label (A->file, slang_asm_addr_push, 0))
goto end;
for (i = flat_agg.count * 4 - garbage_size; i > 0; i -= 4)
{
if (!slang_assembly_file_push_label2 (A->file, slang_asm_float_move,
garbage_size + i, i))
{
goto end;
}
}
if (!slang_assembly_file_push_label (A->file, slang_asm_local_free, garbage_size + 4))
goto end;
}
result = GL_TRUE;
end:
slang_storage_aggregate_destruct (&flat_agg);
end2:
slang_storage_aggregate_destruct (&agg);
end1:
slang_assembly_typeinfo_destruct (&ti);
return result;
}
GLboolean _slang_assemble_constructor (slang_assemble_ctx *A, slang_operation *op)
{
slang_assembly_typeinfo ti;
GLboolean result = GL_FALSE;
slang_storage_aggregate agg, flat;
GLuint size, i;
GLuint arg_sums[2];
/* get typeinfo of the constructor (the result of constructor expression) */
if (!slang_assembly_typeinfo_construct (&ti))
return GL_FALSE;
if (!_slang_typeof_operation (A, op, &ti))
goto end1;
/* create an aggregate of the constructor */
if (!slang_storage_aggregate_construct (&agg))
goto end1;
if (!_slang_aggregate_variable (&agg, &ti.spec, 0, A->space.funcs, A->space.structs,
A->space.vars, A->mach, A->file, A->atoms))
goto end2;
/* calculate size of the constructor */
size = _slang_sizeof_aggregate (&agg);
/* flatten the constructor */
if (!slang_storage_aggregate_construct (&flat))
goto end2;
if (!_slang_flatten_aggregate (&flat, &agg))
goto end;
/* collect the last two constructor's argument size sums */
arg_sums[0] = 0; /* will hold all but the last argument's size sum */
arg_sums[1] = 0; /* will hold all argument's size sum */
for (i = 0; i < op->num_children; i++)
{
GLuint arg_size;
if (!sizeof_argument (A, &arg_size, &op->children[i]))
goto end;
if (i > 0)
arg_sums[0] = arg_sums[1];
arg_sums[1] += arg_size;
}
/* check if there are too many arguments */
if (arg_sums[0] >= size)
{
/* TODO: info log: too many arguments in constructor list */
goto end;
}
/* check if there are too few arguments */
if (arg_sums[1] < size)
{
/* TODO: info log: too few arguments in constructor list */
goto end;
}
/* traverse the children that form the constructor expression */
for (i = op->num_children; i > 0; i--)
{
GLuint garbage_size;
/* the last argument may be too big - calculate the unnecessary data size */
if (i == op->num_children)
garbage_size = arg_sums[1] - size;
else
garbage_size = 0;
if (!constructor_aggregate (A, &flat, &op->children[i - 1], garbage_size))
goto end;
}
result = GL_TRUE;
end:
slang_storage_aggregate_destruct (&flat);
end2:
slang_storage_aggregate_destruct (&agg);
end1:
slang_assembly_typeinfo_destruct (&ti);
return result;
}
/* _slang_assemble_constructor_from_swizzle() */
GLboolean _slang_assemble_constructor_from_swizzle (slang_assemble_ctx *A, const slang_swizzle *swz,
slang_type_specifier *spec, slang_type_specifier *master_spec)
{
GLuint master_rows, i;
master_rows = _slang_type_dim (master_spec->type);
for (i = 0; i < master_rows; i++)
{
switch (_slang_type_base (master_spec->type))
{
case slang_spec_bool:
if (!slang_assembly_file_push_label2 (A->file, slang_asm_bool_copy,
(master_rows - i) * 4, i * 4))
return GL_FALSE;
break;
case slang_spec_int:
if (!slang_assembly_file_push_label2 (A->file, slang_asm_int_copy,
(master_rows - i) * 4, i * 4))
return GL_FALSE;
break;
case slang_spec_float:
if (!slang_assembly_file_push_label2 (A->file, slang_asm_float_copy,
(master_rows - i) * 4, i * 4))
return GL_FALSE;
break;
default:
break;
}
}
if (!slang_assembly_file_push_label (A->file, slang_asm_local_free, 4))
return GL_FALSE;
for (i = swz->num_components; i > 0; i--)
{
GLuint n = i - 1;
if (!slang_assembly_file_push_label2 (A->file, slang_asm_local_addr, A->local.swizzle_tmp, 16))
return GL_FALSE;
if (!slang_assembly_file_push_label (A->file, slang_asm_addr_push, swz->swizzle[n] * 4))
return GL_FALSE;
if (!slang_assembly_file_push (A->file, slang_asm_addr_add))
return GL_FALSE;
switch (_slang_type_base (master_spec->type))
{
case slang_spec_bool:
if (!slang_assembly_file_push (A->file, slang_asm_bool_deref))
return GL_FALSE;
break;
case slang_spec_int:
if (!slang_assembly_file_push (A->file, slang_asm_int_deref))
return GL_FALSE;
break;
case slang_spec_float:
if (!slang_assembly_file_push (A->file, slang_asm_float_deref))
return GL_FALSE;
break;
default:
break;
}
}
return GL_TRUE;
}
@@ -1,64 +1,64 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_ASSEMBLE_CONSTRUCTOR_H
#define SLANG_ASSEMBLE_CONSTRUCTOR_H
#if defined __cplusplus
extern "C" {
#endif
/*
* Checks if a field selector is a general swizzle (an r-value swizzle with replicated
* components or an l-value swizzle mask) for a vector.
* Returns GL_TRUE if this is the case, <swz> is filled with swizzle information.
* Returns GL_FALSE otherwise.
*/
GLboolean _slang_is_swizzle (const char *field, GLuint rows, slang_swizzle *swz);
/*
* Checks if a general swizzle is an l-value swizzle - these swizzles do not have
* duplicated fields.
* Returns GL_TRUE if this is a swizzle mask.
* Returns GL_FALSE otherwise
*/
GLboolean _slang_is_swizzle_mask (const slang_swizzle *swz, GLuint rows);
/*
* Combines (multiplies) two swizzles to form single swizzle.
* Example: "vec.wzyx.yx" --> "vec.zw".
*/
GLvoid _slang_multiply_swizzles (slang_swizzle *, const slang_swizzle *, const slang_swizzle *);
GLboolean _slang_assemble_constructor (slang_assemble_ctx *, struct slang_operation_ *);
GLboolean _slang_assemble_constructor_from_swizzle (slang_assemble_ctx *, const slang_swizzle *,
slang_type_specifier *, slang_type_specifier *);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_ASSEMBLE_CONSTRUCTOR_H
#define SLANG_ASSEMBLE_CONSTRUCTOR_H
#if defined __cplusplus
extern "C" {
#endif
/*
* Checks if a field selector is a general swizzle (an r-value swizzle with replicated
* components or an l-value swizzle mask) for a vector.
* Returns GL_TRUE if this is the case, <swz> is filled with swizzle information.
* Returns GL_FALSE otherwise.
*/
GLboolean _slang_is_swizzle (const char *field, GLuint rows, slang_swizzle *swz);
/*
* Checks if a general swizzle is an l-value swizzle - these swizzles do not have
* duplicated fields.
* Returns GL_TRUE if this is a swizzle mask.
* Returns GL_FALSE otherwise
*/
GLboolean _slang_is_swizzle_mask (const slang_swizzle *swz, GLuint rows);
/*
* Combines (multiplies) two swizzles to form single swizzle.
* Example: "vec.wzyx.yx" --> "vec.zw".
*/
GLvoid _slang_multiply_swizzles (slang_swizzle *, const slang_swizzle *, const slang_swizzle *);
GLboolean _slang_assemble_constructor (slang_assemble_ctx *, struct slang_operation_ *);
GLboolean _slang_assemble_constructor_from_swizzle (slang_assemble_ctx *, const slang_swizzle *,
slang_type_specifier *, slang_type_specifier *);
#ifdef __cplusplus
}
#endif
#endif
File diff suppressed because it is too large Load Diff
+116 -116
View File
@@ -1,116 +1,116 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_ASSEMBLE_TYPEINFO_H
#define SLANG_ASSEMBLE_TYPEINFO_H
#if defined __cplusplus
extern "C" {
#endif
typedef enum slang_type_specifier_type_
{
slang_spec_void,
slang_spec_bool,
slang_spec_bvec2,
slang_spec_bvec3,
slang_spec_bvec4,
slang_spec_int,
slang_spec_ivec2,
slang_spec_ivec3,
slang_spec_ivec4,
slang_spec_float,
slang_spec_vec2,
slang_spec_vec3,
slang_spec_vec4,
slang_spec_mat2,
slang_spec_mat3,
slang_spec_mat4,
slang_spec_sampler1D,
slang_spec_sampler2D,
slang_spec_sampler3D,
slang_spec_samplerCube,
slang_spec_sampler1DShadow,
slang_spec_sampler2DShadow,
slang_spec_struct,
slang_spec_array
} slang_type_specifier_type;
typedef struct slang_type_specifier_
{
slang_type_specifier_type type;
struct slang_struct_ *_struct; /* type: spec_struct */
struct slang_type_specifier_ *_array; /* type: spec_array */
} slang_type_specifier;
GLvoid slang_type_specifier_ctr (slang_type_specifier *);
GLvoid slang_type_specifier_dtr (slang_type_specifier *);
GLboolean slang_type_specifier_copy (slang_type_specifier *, const slang_type_specifier *);
GLboolean slang_type_specifier_equal (const slang_type_specifier *, const slang_type_specifier *);
typedef struct slang_assembly_typeinfo_
{
GLboolean can_be_referenced;
GLboolean is_swizzled;
slang_swizzle swz;
slang_type_specifier spec;
GLuint array_len;
} slang_assembly_typeinfo;
GLboolean slang_assembly_typeinfo_construct (slang_assembly_typeinfo *);
GLvoid slang_assembly_typeinfo_destruct (slang_assembly_typeinfo *);
/*
* Retrieves type information about an operation.
* Returns GL_TRUE on success.
* Returns GL_FALSE otherwise.
*/
GLboolean _slang_typeof_operation (slang_assemble_ctx *, struct slang_operation_ *,
slang_assembly_typeinfo *);
GLboolean _slang_typeof_operation_ (struct slang_operation_ *, slang_assembly_name_space *,
slang_assembly_typeinfo *, slang_atom_pool *);
/*
* Retrieves type of a function prototype, if one exists.
* Returns GL_TRUE on success, even if the function was not found.
* Returns GL_FALSE otherwise.
*/
GLboolean _slang_typeof_function (slang_atom a_name, struct slang_operation_ *params,
GLuint num_params, slang_assembly_name_space *, slang_type_specifier *spec, GLboolean *exists,
slang_atom_pool *);
GLboolean _slang_type_is_matrix (slang_type_specifier_type);
GLboolean _slang_type_is_vector (slang_type_specifier_type);
slang_type_specifier_type _slang_type_base (slang_type_specifier_type);
GLuint _slang_type_dim (slang_type_specifier_type);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_ASSEMBLE_TYPEINFO_H
#define SLANG_ASSEMBLE_TYPEINFO_H
#if defined __cplusplus
extern "C" {
#endif
typedef enum slang_type_specifier_type_
{
slang_spec_void,
slang_spec_bool,
slang_spec_bvec2,
slang_spec_bvec3,
slang_spec_bvec4,
slang_spec_int,
slang_spec_ivec2,
slang_spec_ivec3,
slang_spec_ivec4,
slang_spec_float,
slang_spec_vec2,
slang_spec_vec3,
slang_spec_vec4,
slang_spec_mat2,
slang_spec_mat3,
slang_spec_mat4,
slang_spec_sampler1D,
slang_spec_sampler2D,
slang_spec_sampler3D,
slang_spec_samplerCube,
slang_spec_sampler1DShadow,
slang_spec_sampler2DShadow,
slang_spec_struct,
slang_spec_array
} slang_type_specifier_type;
typedef struct slang_type_specifier_
{
slang_type_specifier_type type;
struct slang_struct_ *_struct; /* type: spec_struct */
struct slang_type_specifier_ *_array; /* type: spec_array */
} slang_type_specifier;
GLvoid slang_type_specifier_ctr (slang_type_specifier *);
GLvoid slang_type_specifier_dtr (slang_type_specifier *);
GLboolean slang_type_specifier_copy (slang_type_specifier *, const slang_type_specifier *);
GLboolean slang_type_specifier_equal (const slang_type_specifier *, const slang_type_specifier *);
typedef struct slang_assembly_typeinfo_
{
GLboolean can_be_referenced;
GLboolean is_swizzled;
slang_swizzle swz;
slang_type_specifier spec;
GLuint array_len;
} slang_assembly_typeinfo;
GLboolean slang_assembly_typeinfo_construct (slang_assembly_typeinfo *);
GLvoid slang_assembly_typeinfo_destruct (slang_assembly_typeinfo *);
/*
* Retrieves type information about an operation.
* Returns GL_TRUE on success.
* Returns GL_FALSE otherwise.
*/
GLboolean _slang_typeof_operation (slang_assemble_ctx *, struct slang_operation_ *,
slang_assembly_typeinfo *);
GLboolean _slang_typeof_operation_ (struct slang_operation_ *, slang_assembly_name_space *,
slang_assembly_typeinfo *, slang_atom_pool *);
/*
* Retrieves type of a function prototype, if one exists.
* Returns GL_TRUE on success, even if the function was not found.
* Returns GL_FALSE otherwise.
*/
GLboolean _slang_typeof_function (slang_atom a_name, struct slang_operation_ *params,
GLuint num_params, slang_assembly_name_space *, slang_type_specifier *spec, GLboolean *exists,
slang_atom_pool *);
GLboolean _slang_type_is_matrix (slang_type_specifier_type);
GLboolean _slang_type_is_vector (slang_type_specifier_type);
slang_type_specifier_type _slang_type_base (slang_type_specifier_type);
GLuint _slang_type_dim (slang_type_specifier_type);
#ifdef __cplusplus
}
#endif
#endif
+26 -26
View File
@@ -23,13 +23,13 @@
*/
#if !defined SLANG_COMPILE_H
#define SLANG_COMPILE_H
#include "slang_export.h"
#include "slang_execute.h"
#include "slang_compile_variable.h"
#include "slang_compile_struct.h"
#include "slang_compile_operation.h"
#define SLANG_COMPILE_H
#include "slang_export.h"
#include "slang_execute.h"
#include "slang_compile_variable.h"
#include "slang_compile_struct.h"
#include "slang_compile_operation.h"
#include "slang_compile_function.h"
#if defined __cplusplus
@@ -42,33 +42,33 @@ typedef enum slang_unit_type_
slang_unit_vertex_shader,
slang_unit_fragment_builtin,
slang_unit_vertex_builtin
} slang_unit_type;
typedef struct slang_var_pool_
{
GLuint next_addr;
} slang_var_pool;
} slang_unit_type;
typedef struct slang_var_pool_
{
GLuint next_addr;
} slang_var_pool;
typedef struct slang_translation_unit_
{
slang_variable_scope globals;
slang_function_scope functions;
slang_struct_scope structs;
slang_unit_type type;
slang_assembly_file *assembly;
int free_assembly;
slang_var_pool *global_pool;
int free_global_pool;
slang_machine *machine;
int free_machine;
slang_atom_pool *atom_pool;
int free_atom_pool;
slang_export_data_table exp_data;
slang_unit_type type;
slang_assembly_file *assembly;
int free_assembly;
slang_var_pool *global_pool;
int free_global_pool;
slang_machine *machine;
int free_machine;
slang_atom_pool *atom_pool;
int free_atom_pool;
slang_export_data_table exp_data;
slang_export_code_table exp_code;
} slang_translation_unit;
int slang_translation_unit_construct (slang_translation_unit *);
int slang_translation_unit_construct2 (slang_translation_unit *, slang_assembly_file *,
int slang_translation_unit_construct (slang_translation_unit *);
int slang_translation_unit_construct2 (slang_translation_unit *, slang_assembly_file *,
slang_var_pool *, slang_machine *, slang_atom_pool *);
void slang_translation_unit_destruct (slang_translation_unit *);
+190 -190
View File
@@ -1,190 +1,190 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file slang_compile_function.c
* slang front-end compiler
* \author Michal Krol
*/
#include "imports.h"
#include "slang_compile.h"
/* slang_fixup_table */
void slang_fixup_table_init (slang_fixup_table *fix)
{
fix->table = NULL;
fix->count = 0;
}
void slang_fixup_table_free (slang_fixup_table *fix)
{
slang_alloc_free (fix->table);
slang_fixup_table_init (fix);
}
/* slang_function */
int slang_function_construct (slang_function *func)
{
func->kind = slang_func_ordinary;
if (!slang_variable_construct (&func->header))
return 0;
func->parameters = (slang_variable_scope *) slang_alloc_malloc (sizeof (slang_variable_scope));
if (func->parameters == NULL)
{
slang_variable_destruct (&func->header);
return 0;
}
if (!slang_variable_scope_construct (func->parameters))
{
slang_alloc_free (func->parameters);
slang_variable_destruct (&func->header);
return 0;
}
func->param_count = 0;
func->body = NULL;
func->address = ~0;
slang_fixup_table_init (&func->fixups);
return 1;
}
void slang_function_destruct (slang_function *func)
{
slang_variable_destruct (&func->header);
slang_variable_scope_destruct (func->parameters);
slang_alloc_free (func->parameters);
if (func->body != NULL)
{
slang_operation_destruct (func->body);
slang_alloc_free (func->body);
}
slang_fixup_table_free (&func->fixups);
}
/* slang_function_scope */
int slang_function_scope_construct (slang_function_scope *scope)
{
scope->functions = NULL;
scope->num_functions = 0;
scope->outer_scope = NULL;
return 1;
}
void slang_function_scope_destruct (slang_function_scope *scope)
{
unsigned int i;
for (i = 0; i < scope->num_functions; i++)
slang_function_destruct (scope->functions + i);
slang_alloc_free (scope->functions);
}
int slang_function_scope_find_by_name (slang_function_scope *funcs, slang_atom a_name, int all_scopes)
{
unsigned int i;
for (i = 0; i < funcs->num_functions; i++)
if (a_name == funcs->functions[i].header.a_name)
return 1;
if (all_scopes && funcs->outer_scope != NULL)
return slang_function_scope_find_by_name (funcs->outer_scope, a_name, 1);
return 0;
}
slang_function *slang_function_scope_find (slang_function_scope *funcs, slang_function *fun,
int all_scopes)
{
unsigned int i;
for (i = 0; i < funcs->num_functions; i++)
{
slang_function *f = &funcs->functions[i];
unsigned int j;
if (fun->header.a_name != f->header.a_name)
continue;
if (fun->param_count != f->param_count)
continue;
for (j = 0; j < fun->param_count; j++)
{
if (!slang_type_specifier_equal (&fun->parameters->variables[j].type.specifier,
&f->parameters->variables[j].type.specifier))
break;
}
if (j == fun->param_count)
return f;
}
if (all_scopes && funcs->outer_scope != NULL)
return slang_function_scope_find (funcs->outer_scope, fun, 1);
return NULL;
}
/*
* _slang_build_export_code_table()
*/
GLboolean _slang_build_export_code_table (slang_export_code_table *tbl, slang_function_scope *funs,
slang_translation_unit *unit)
{
slang_atom mainAtom;
GLuint i;
mainAtom = slang_atom_pool_atom (tbl->atoms, "main");
if (mainAtom == SLANG_ATOM_NULL)
return GL_FALSE;
for (i = 0; i < funs->num_functions; i++)
{
if (funs->functions[i].header.a_name == mainAtom)
{
slang_function *fun = &funs->functions[i];
slang_export_code_entry *e;
slang_assemble_ctx A;
e = slang_export_code_table_add (tbl);
if (e == NULL)
return GL_FALSE;
e->address = unit->assembly->count;
e->name = slang_atom_pool_atom (tbl->atoms, "@main");
if (e->name == SLANG_ATOM_NULL)
return GL_FALSE;
A.file = unit->assembly;
A.mach = unit->machine;
A.atoms = unit->atom_pool;
A.space.funcs = &unit->functions;
A.space.structs = &unit->structs;
A.space.vars = &unit->globals;
slang_assembly_file_push_label (unit->assembly, slang_asm_local_alloc, 20);
slang_assembly_file_push_label (unit->assembly, slang_asm_enter, 20);
_slang_assemble_function_call (&A, fun, NULL, 0, GL_FALSE);
slang_assembly_file_push (unit->assembly, slang_asm_exit);
}
}
return GL_TRUE;
}
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file slang_compile_function.c
* slang front-end compiler
* \author Michal Krol
*/
#include "imports.h"
#include "slang_compile.h"
/* slang_fixup_table */
void slang_fixup_table_init (slang_fixup_table *fix)
{
fix->table = NULL;
fix->count = 0;
}
void slang_fixup_table_free (slang_fixup_table *fix)
{
slang_alloc_free (fix->table);
slang_fixup_table_init (fix);
}
/* slang_function */
int slang_function_construct (slang_function *func)
{
func->kind = slang_func_ordinary;
if (!slang_variable_construct (&func->header))
return 0;
func->parameters = (slang_variable_scope *) slang_alloc_malloc (sizeof (slang_variable_scope));
if (func->parameters == NULL)
{
slang_variable_destruct (&func->header);
return 0;
}
if (!slang_variable_scope_construct (func->parameters))
{
slang_alloc_free (func->parameters);
slang_variable_destruct (&func->header);
return 0;
}
func->param_count = 0;
func->body = NULL;
func->address = ~0;
slang_fixup_table_init (&func->fixups);
return 1;
}
void slang_function_destruct (slang_function *func)
{
slang_variable_destruct (&func->header);
slang_variable_scope_destruct (func->parameters);
slang_alloc_free (func->parameters);
if (func->body != NULL)
{
slang_operation_destruct (func->body);
slang_alloc_free (func->body);
}
slang_fixup_table_free (&func->fixups);
}
/* slang_function_scope */
int slang_function_scope_construct (slang_function_scope *scope)
{
scope->functions = NULL;
scope->num_functions = 0;
scope->outer_scope = NULL;
return 1;
}
void slang_function_scope_destruct (slang_function_scope *scope)
{
unsigned int i;
for (i = 0; i < scope->num_functions; i++)
slang_function_destruct (scope->functions + i);
slang_alloc_free (scope->functions);
}
int slang_function_scope_find_by_name (slang_function_scope *funcs, slang_atom a_name, int all_scopes)
{
unsigned int i;
for (i = 0; i < funcs->num_functions; i++)
if (a_name == funcs->functions[i].header.a_name)
return 1;
if (all_scopes && funcs->outer_scope != NULL)
return slang_function_scope_find_by_name (funcs->outer_scope, a_name, 1);
return 0;
}
slang_function *slang_function_scope_find (slang_function_scope *funcs, slang_function *fun,
int all_scopes)
{
unsigned int i;
for (i = 0; i < funcs->num_functions; i++)
{
slang_function *f = &funcs->functions[i];
unsigned int j;
if (fun->header.a_name != f->header.a_name)
continue;
if (fun->param_count != f->param_count)
continue;
for (j = 0; j < fun->param_count; j++)
{
if (!slang_type_specifier_equal (&fun->parameters->variables[j].type.specifier,
&f->parameters->variables[j].type.specifier))
break;
}
if (j == fun->param_count)
return f;
}
if (all_scopes && funcs->outer_scope != NULL)
return slang_function_scope_find (funcs->outer_scope, fun, 1);
return NULL;
}
/*
* _slang_build_export_code_table()
*/
GLboolean _slang_build_export_code_table (slang_export_code_table *tbl, slang_function_scope *funs,
slang_translation_unit *unit)
{
slang_atom mainAtom;
GLuint i;
mainAtom = slang_atom_pool_atom (tbl->atoms, "main");
if (mainAtom == SLANG_ATOM_NULL)
return GL_FALSE;
for (i = 0; i < funs->num_functions; i++)
{
if (funs->functions[i].header.a_name == mainAtom)
{
slang_function *fun = &funs->functions[i];
slang_export_code_entry *e;
slang_assemble_ctx A;
e = slang_export_code_table_add (tbl);
if (e == NULL)
return GL_FALSE;
e->address = unit->assembly->count;
e->name = slang_atom_pool_atom (tbl->atoms, "@main");
if (e->name == SLANG_ATOM_NULL)
return GL_FALSE;
A.file = unit->assembly;
A.mach = unit->machine;
A.atoms = unit->atom_pool;
A.space.funcs = &unit->functions;
A.space.structs = &unit->structs;
A.space.vars = &unit->globals;
slang_assembly_file_push_label (unit->assembly, slang_asm_local_alloc, 20);
slang_assembly_file_push_label (unit->assembly, slang_asm_enter, 20);
_slang_assemble_function_call (&A, fun, NULL, 0, GL_FALSE);
slang_assembly_file_push (unit->assembly, slang_asm_exit);
}
}
return GL_TRUE;
}
+84 -84
View File
@@ -1,84 +1,84 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_COMPILE_FUNCTION_H
#define SLANG_COMPILE_FUNCTION_H
#if defined __cplusplus
extern "C" {
#endif
struct slang_translation_unit_;
typedef enum slang_function_kind_
{
slang_func_ordinary,
slang_func_constructor,
slang_func_operator
} slang_function_kind;
typedef struct slang_fixup_table_
{
GLuint *table;
GLuint count;
} slang_fixup_table;
void slang_fixup_table_init (slang_fixup_table *);
void slang_fixup_table_free (slang_fixup_table *);
typedef struct slang_function_
{
slang_function_kind kind;
slang_variable header;
slang_variable_scope *parameters;
unsigned int param_count;
slang_operation *body;
unsigned int address;
slang_fixup_table fixups;
} slang_function;
int slang_function_construct (slang_function *);
void slang_function_destruct (slang_function *);
typedef struct slang_function_scope_
{
slang_function *functions;
unsigned int num_functions;
struct slang_function_scope_ *outer_scope;
} slang_function_scope;
int slang_function_scope_construct (slang_function_scope *);
void slang_function_scope_destruct (slang_function_scope *);
int slang_function_scope_find_by_name (slang_function_scope *, slang_atom, int);
slang_function *slang_function_scope_find (slang_function_scope *, slang_function *, int);
GLboolean _slang_build_export_code_table (slang_export_code_table *, slang_function_scope *,
struct slang_translation_unit_ *);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_COMPILE_FUNCTION_H
#define SLANG_COMPILE_FUNCTION_H
#if defined __cplusplus
extern "C" {
#endif
struct slang_translation_unit_;
typedef enum slang_function_kind_
{
slang_func_ordinary,
slang_func_constructor,
slang_func_operator
} slang_function_kind;
typedef struct slang_fixup_table_
{
GLuint *table;
GLuint count;
} slang_fixup_table;
void slang_fixup_table_init (slang_fixup_table *);
void slang_fixup_table_free (slang_fixup_table *);
typedef struct slang_function_
{
slang_function_kind kind;
slang_variable header;
slang_variable_scope *parameters;
unsigned int param_count;
slang_operation *body;
unsigned int address;
slang_fixup_table fixups;
} slang_function;
int slang_function_construct (slang_function *);
void slang_function_destruct (slang_function *);
typedef struct slang_function_scope_
{
slang_function *functions;
unsigned int num_functions;
struct slang_function_scope_ *outer_scope;
} slang_function_scope;
int slang_function_scope_construct (slang_function_scope *);
void slang_function_scope_destruct (slang_function_scope *);
int slang_function_scope_find_by_name (slang_function_scope *, slang_atom, int);
slang_function *slang_function_scope_find (slang_function_scope *, slang_function *, int);
GLboolean _slang_build_export_code_table (slang_export_code_table *, slang_function_scope *,
struct slang_translation_unit_ *);
#ifdef __cplusplus
}
#endif
#endif
+102 -102
View File
@@ -1,102 +1,102 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file slang_compile_operation.c
* slang front-end compiler
* \author Michal Krol
*/
#include "imports.h"
#include "slang_compile.h"
/* slang_operation */
int slang_operation_construct (slang_operation *oper)
{
oper->type = slang_oper_none;
oper->children = NULL;
oper->num_children = 0;
oper->literal = (float) 0;
oper->a_id = SLANG_ATOM_NULL;
oper->locals = (slang_variable_scope *) slang_alloc_malloc (sizeof (slang_variable_scope));
if (oper->locals == NULL)
return 0;
if (!slang_variable_scope_construct (oper->locals))
{
slang_alloc_free (oper->locals);
return 0;
}
return 1;
}
void slang_operation_destruct (slang_operation *oper)
{
unsigned int i;
for (i = 0; i < oper->num_children; i++)
slang_operation_destruct (oper->children + i);
slang_alloc_free (oper->children);
slang_variable_scope_destruct (oper->locals);
slang_alloc_free (oper->locals);
}
int slang_operation_copy (slang_operation *x, const slang_operation *y)
{
slang_operation z;
unsigned int i;
if (!slang_operation_construct (&z))
return 0;
z.type = y->type;
z.children = (slang_operation *) slang_alloc_malloc (y->num_children * sizeof (slang_operation));
if (z.children == NULL)
{
slang_operation_destruct (&z);
return 0;
}
for (z.num_children = 0; z.num_children < y->num_children; z.num_children++)
if (!slang_operation_construct (&z.children[z.num_children]))
{
slang_operation_destruct (&z);
return 0;
}
for (i = 0; i < z.num_children; i++)
if (!slang_operation_copy (&z.children[i], &y->children[i]))
{
slang_operation_destruct (&z);
return 0;
}
z.literal = y->literal;
z.a_id = y->a_id;
if (!slang_variable_scope_copy (z.locals, y->locals))
{
slang_operation_destruct (&z);
return 0;
}
slang_operation_destruct (x);
*x = z;
return 1;
}
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file slang_compile_operation.c
* slang front-end compiler
* \author Michal Krol
*/
#include "imports.h"
#include "slang_compile.h"
/* slang_operation */
int slang_operation_construct (slang_operation *oper)
{
oper->type = slang_oper_none;
oper->children = NULL;
oper->num_children = 0;
oper->literal = (float) 0;
oper->a_id = SLANG_ATOM_NULL;
oper->locals = (slang_variable_scope *) slang_alloc_malloc (sizeof (slang_variable_scope));
if (oper->locals == NULL)
return 0;
if (!slang_variable_scope_construct (oper->locals))
{
slang_alloc_free (oper->locals);
return 0;
}
return 1;
}
void slang_operation_destruct (slang_operation *oper)
{
unsigned int i;
for (i = 0; i < oper->num_children; i++)
slang_operation_destruct (oper->children + i);
slang_alloc_free (oper->children);
slang_variable_scope_destruct (oper->locals);
slang_alloc_free (oper->locals);
}
int slang_operation_copy (slang_operation *x, const slang_operation *y)
{
slang_operation z;
unsigned int i;
if (!slang_operation_construct (&z))
return 0;
z.type = y->type;
z.children = (slang_operation *) slang_alloc_malloc (y->num_children * sizeof (slang_operation));
if (z.children == NULL)
{
slang_operation_destruct (&z);
return 0;
}
for (z.num_children = 0; z.num_children < y->num_children; z.num_children++)
if (!slang_operation_construct (&z.children[z.num_children]))
{
slang_operation_destruct (&z);
return 0;
}
for (i = 0; i < z.num_children; i++)
if (!slang_operation_copy (&z.children[i], &y->children[i]))
{
slang_operation_destruct (&z);
return 0;
}
z.literal = y->literal;
z.a_id = y->a_id;
if (!slang_variable_scope_copy (z.locals, y->locals))
{
slang_operation_destruct (&z);
return 0;
}
slang_operation_destruct (x);
*x = z;
return 1;
}
+117 -117
View File
@@ -1,117 +1,117 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_COMPILE_OPERATION_H
#define SLANG_COMPILE_OPERATION_H
#if defined __cplusplus
extern "C" {
#endif
typedef enum slang_operation_type_
{
slang_oper_none,
slang_oper_block_no_new_scope,
slang_oper_block_new_scope,
slang_oper_variable_decl,
slang_oper_asm,
slang_oper_break,
slang_oper_continue,
slang_oper_discard,
slang_oper_return,
slang_oper_expression,
slang_oper_if,
slang_oper_while,
slang_oper_do,
slang_oper_for,
slang_oper_void,
slang_oper_literal_bool,
slang_oper_literal_int,
slang_oper_literal_float,
slang_oper_identifier,
slang_oper_sequence,
slang_oper_assign,
slang_oper_addassign,
slang_oper_subassign,
slang_oper_mulassign,
slang_oper_divassign,
/*slang_oper_modassign,*/
/*slang_oper_lshassign,*/
/*slang_oper_rshassign,*/
/*slang_oper_orassign,*/
/*slang_oper_xorassign,*/
/*slang_oper_andassign,*/
slang_oper_select,
slang_oper_logicalor,
slang_oper_logicalxor,
slang_oper_logicaland,
/*slang_oper_bitor,*/
/*slang_oper_bitxor,*/
/*slang_oper_bitand,*/
slang_oper_equal,
slang_oper_notequal,
slang_oper_less,
slang_oper_greater,
slang_oper_lessequal,
slang_oper_greaterequal,
/*slang_oper_lshift,*/
/*slang_oper_rshift,*/
slang_oper_add,
slang_oper_subtract,
slang_oper_multiply,
slang_oper_divide,
/*slang_oper_modulus,*/
slang_oper_preincrement,
slang_oper_predecrement,
slang_oper_plus,
slang_oper_minus,
/*slang_oper_complement,*/
slang_oper_not,
slang_oper_subscript,
slang_oper_call,
slang_oper_field,
slang_oper_postincrement,
slang_oper_postdecrement
} slang_operation_type;
typedef struct slang_operation_
{
slang_operation_type type;
struct slang_operation_ *children;
unsigned int num_children;
float literal; /* type: bool, literal_int, literal_float */
slang_atom a_id; /* type: asm, identifier, call, field */
slang_variable_scope *locals;
} slang_operation;
int slang_operation_construct (slang_operation *);
void slang_operation_destruct (slang_operation *);
int slang_operation_copy (slang_operation *, const slang_operation *);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_COMPILE_OPERATION_H
#define SLANG_COMPILE_OPERATION_H
#if defined __cplusplus
extern "C" {
#endif
typedef enum slang_operation_type_
{
slang_oper_none,
slang_oper_block_no_new_scope,
slang_oper_block_new_scope,
slang_oper_variable_decl,
slang_oper_asm,
slang_oper_break,
slang_oper_continue,
slang_oper_discard,
slang_oper_return,
slang_oper_expression,
slang_oper_if,
slang_oper_while,
slang_oper_do,
slang_oper_for,
slang_oper_void,
slang_oper_literal_bool,
slang_oper_literal_int,
slang_oper_literal_float,
slang_oper_identifier,
slang_oper_sequence,
slang_oper_assign,
slang_oper_addassign,
slang_oper_subassign,
slang_oper_mulassign,
slang_oper_divassign,
/*slang_oper_modassign,*/
/*slang_oper_lshassign,*/
/*slang_oper_rshassign,*/
/*slang_oper_orassign,*/
/*slang_oper_xorassign,*/
/*slang_oper_andassign,*/
slang_oper_select,
slang_oper_logicalor,
slang_oper_logicalxor,
slang_oper_logicaland,
/*slang_oper_bitor,*/
/*slang_oper_bitxor,*/
/*slang_oper_bitand,*/
slang_oper_equal,
slang_oper_notequal,
slang_oper_less,
slang_oper_greater,
slang_oper_lessequal,
slang_oper_greaterequal,
/*slang_oper_lshift,*/
/*slang_oper_rshift,*/
slang_oper_add,
slang_oper_subtract,
slang_oper_multiply,
slang_oper_divide,
/*slang_oper_modulus,*/
slang_oper_preincrement,
slang_oper_predecrement,
slang_oper_plus,
slang_oper_minus,
/*slang_oper_complement,*/
slang_oper_not,
slang_oper_subscript,
slang_oper_call,
slang_oper_field,
slang_oper_postincrement,
slang_oper_postdecrement
} slang_operation_type;
typedef struct slang_operation_
{
slang_operation_type type;
struct slang_operation_ *children;
unsigned int num_children;
float literal; /* type: bool, literal_int, literal_float */
slang_atom a_id; /* type: asm, identifier, call, field */
slang_variable_scope *locals;
} slang_operation;
int slang_operation_construct (slang_operation *);
void slang_operation_destruct (slang_operation *);
int slang_operation_copy (slang_operation *, const slang_operation *);
#ifdef __cplusplus
}
#endif
#endif
+178 -178
View File
@@ -1,178 +1,178 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file slang_compile_struct.c
* slang front-end compiler
* \author Michal Krol
*/
#include "imports.h"
#include "slang_compile.h"
/* slang_struct_scope */
int slang_struct_scope_construct (slang_struct_scope *scope)
{
scope->structs = NULL;
scope->num_structs = 0;
scope->outer_scope = NULL;
return 1;
}
void slang_struct_scope_destruct (slang_struct_scope *scope)
{
unsigned int i;
for (i = 0; i < scope->num_structs; i++)
slang_struct_destruct (scope->structs + i);
slang_alloc_free (scope->structs);
/* do not free scope->outer_scope */
}
int slang_struct_scope_copy (slang_struct_scope *x, const slang_struct_scope *y)
{
slang_struct_scope z;
unsigned int i;
if (!slang_struct_scope_construct (&z))
return 0;
z.structs = (slang_struct *) slang_alloc_malloc (y->num_structs * sizeof (slang_struct));
if (z.structs == NULL)
{
slang_struct_scope_destruct (&z);
return 0;
}
for (z.num_structs = 0; z.num_structs < y->num_structs; z.num_structs++)
if (!slang_struct_construct (&z.structs[z.num_structs]))
{
slang_struct_scope_destruct (&z);
return 0;
}
for (i = 0; i < z.num_structs; i++)
if (!slang_struct_copy (&z.structs[i], &y->structs[i]))
{
slang_struct_scope_destruct (&z);
return 0;
}
z.outer_scope = y->outer_scope;
slang_struct_scope_destruct (x);
*x = z;
return 1;
}
slang_struct *slang_struct_scope_find (slang_struct_scope *stru, slang_atom a_name, int all_scopes)
{
unsigned int i;
for (i = 0; i < stru->num_structs; i++)
if (a_name == stru->structs[i].a_name)
return &stru->structs[i];
if (all_scopes && stru->outer_scope != NULL)
return slang_struct_scope_find (stru->outer_scope, a_name, 1);
return NULL;
}
/* slang_struct */
int slang_struct_construct (slang_struct *stru)
{
stru->a_name = SLANG_ATOM_NULL;
stru->fields = (slang_variable_scope *) slang_alloc_malloc (sizeof (slang_variable_scope));
if (stru->fields == NULL)
return 0;
if (!slang_variable_scope_construct (stru->fields))
{
slang_alloc_free (stru->fields);
return 0;
}
stru->structs = (slang_struct_scope *) slang_alloc_malloc (sizeof (slang_struct_scope));
if (stru->structs == NULL)
{
slang_variable_scope_destruct (stru->fields);
slang_alloc_free (stru->fields);
return 0;
}
if (!slang_struct_scope_construct (stru->structs))
{
slang_variable_scope_destruct (stru->fields);
slang_alloc_free (stru->fields);
slang_alloc_free (stru->structs);
return 0;
}
return 1;
}
void slang_struct_destruct (slang_struct *stru)
{
slang_variable_scope_destruct (stru->fields);
slang_alloc_free (stru->fields);
slang_struct_scope_destruct (stru->structs);
slang_alloc_free (stru->structs);
}
int slang_struct_copy (slang_struct *x, const slang_struct *y)
{
slang_struct z;
if (!slang_struct_construct (&z))
return 0;
z.a_name = y->a_name;
if (!slang_variable_scope_copy (z.fields, y->fields))
{
slang_struct_destruct (&z);
return 0;
}
if (!slang_struct_scope_copy (z.structs, y->structs))
{
slang_struct_destruct (&z);
return 0;
}
slang_struct_destruct (x);
*x = z;
return 1;
}
int slang_struct_equal (const slang_struct *x, const slang_struct *y)
{
unsigned int i;
if (x->fields->num_variables != y->fields->num_variables)
return 0;
for (i = 0; i < x->fields->num_variables; i++)
{
slang_variable *varx = &x->fields->variables[i];
slang_variable *vary = &y->fields->variables[i];
if (varx->a_name != vary->a_name)
return 0;
if (!slang_type_specifier_equal (&varx->type.specifier, &vary->type.specifier))
return 0;
if (varx->type.specifier.type == slang_spec_array)
if (varx->array_len != vary->array_len)
return GL_FALSE;
}
return 1;
}
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file slang_compile_struct.c
* slang front-end compiler
* \author Michal Krol
*/
#include "imports.h"
#include "slang_compile.h"
/* slang_struct_scope */
int slang_struct_scope_construct (slang_struct_scope *scope)
{
scope->structs = NULL;
scope->num_structs = 0;
scope->outer_scope = NULL;
return 1;
}
void slang_struct_scope_destruct (slang_struct_scope *scope)
{
unsigned int i;
for (i = 0; i < scope->num_structs; i++)
slang_struct_destruct (scope->structs + i);
slang_alloc_free (scope->structs);
/* do not free scope->outer_scope */
}
int slang_struct_scope_copy (slang_struct_scope *x, const slang_struct_scope *y)
{
slang_struct_scope z;
unsigned int i;
if (!slang_struct_scope_construct (&z))
return 0;
z.structs = (slang_struct *) slang_alloc_malloc (y->num_structs * sizeof (slang_struct));
if (z.structs == NULL)
{
slang_struct_scope_destruct (&z);
return 0;
}
for (z.num_structs = 0; z.num_structs < y->num_structs; z.num_structs++)
if (!slang_struct_construct (&z.structs[z.num_structs]))
{
slang_struct_scope_destruct (&z);
return 0;
}
for (i = 0; i < z.num_structs; i++)
if (!slang_struct_copy (&z.structs[i], &y->structs[i]))
{
slang_struct_scope_destruct (&z);
return 0;
}
z.outer_scope = y->outer_scope;
slang_struct_scope_destruct (x);
*x = z;
return 1;
}
slang_struct *slang_struct_scope_find (slang_struct_scope *stru, slang_atom a_name, int all_scopes)
{
unsigned int i;
for (i = 0; i < stru->num_structs; i++)
if (a_name == stru->structs[i].a_name)
return &stru->structs[i];
if (all_scopes && stru->outer_scope != NULL)
return slang_struct_scope_find (stru->outer_scope, a_name, 1);
return NULL;
}
/* slang_struct */
int slang_struct_construct (slang_struct *stru)
{
stru->a_name = SLANG_ATOM_NULL;
stru->fields = (slang_variable_scope *) slang_alloc_malloc (sizeof (slang_variable_scope));
if (stru->fields == NULL)
return 0;
if (!slang_variable_scope_construct (stru->fields))
{
slang_alloc_free (stru->fields);
return 0;
}
stru->structs = (slang_struct_scope *) slang_alloc_malloc (sizeof (slang_struct_scope));
if (stru->structs == NULL)
{
slang_variable_scope_destruct (stru->fields);
slang_alloc_free (stru->fields);
return 0;
}
if (!slang_struct_scope_construct (stru->structs))
{
slang_variable_scope_destruct (stru->fields);
slang_alloc_free (stru->fields);
slang_alloc_free (stru->structs);
return 0;
}
return 1;
}
void slang_struct_destruct (slang_struct *stru)
{
slang_variable_scope_destruct (stru->fields);
slang_alloc_free (stru->fields);
slang_struct_scope_destruct (stru->structs);
slang_alloc_free (stru->structs);
}
int slang_struct_copy (slang_struct *x, const slang_struct *y)
{
slang_struct z;
if (!slang_struct_construct (&z))
return 0;
z.a_name = y->a_name;
if (!slang_variable_scope_copy (z.fields, y->fields))
{
slang_struct_destruct (&z);
return 0;
}
if (!slang_struct_scope_copy (z.structs, y->structs))
{
slang_struct_destruct (&z);
return 0;
}
slang_struct_destruct (x);
*x = z;
return 1;
}
int slang_struct_equal (const slang_struct *x, const slang_struct *y)
{
unsigned int i;
if (x->fields->num_variables != y->fields->num_variables)
return 0;
for (i = 0; i < x->fields->num_variables; i++)
{
slang_variable *varx = &x->fields->variables[i];
slang_variable *vary = &y->fields->variables[i];
if (varx->a_name != vary->a_name)
return 0;
if (!slang_type_specifier_equal (&varx->type.specifier, &vary->type.specifier))
return 0;
if (varx->type.specifier.type == slang_spec_array)
if (varx->array_len != vary->array_len)
return GL_FALSE;
}
return 1;
}
+61 -61
View File
@@ -1,61 +1,61 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_COMPILE_STRUCT_H
#define SLANG_COMPILE_STRUCT_H
#if defined __cplusplus
extern "C" {
#endif
typedef struct slang_struct_scope_
{
struct slang_struct_ *structs;
unsigned int num_structs;
struct slang_struct_scope_ *outer_scope;
} slang_struct_scope;
int slang_struct_scope_construct (slang_struct_scope *);
void slang_struct_scope_destruct (slang_struct_scope *);
int slang_struct_scope_copy (slang_struct_scope *, const slang_struct_scope *);
struct slang_struct_ *slang_struct_scope_find (slang_struct_scope *, slang_atom, int);
typedef struct slang_struct_
{
slang_atom a_name;
struct slang_variable_scope_ *fields;
slang_struct_scope *structs;
} slang_struct;
int slang_struct_construct (slang_struct *);
void slang_struct_destruct (slang_struct *);
int slang_struct_copy (slang_struct *, const slang_struct *);
int slang_struct_equal (const slang_struct *, const slang_struct *);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_COMPILE_STRUCT_H
#define SLANG_COMPILE_STRUCT_H
#if defined __cplusplus
extern "C" {
#endif
typedef struct slang_struct_scope_
{
struct slang_struct_ *structs;
unsigned int num_structs;
struct slang_struct_scope_ *outer_scope;
} slang_struct_scope;
int slang_struct_scope_construct (slang_struct_scope *);
void slang_struct_scope_destruct (slang_struct_scope *);
int slang_struct_scope_copy (slang_struct_scope *, const slang_struct_scope *);
struct slang_struct_ *slang_struct_scope_find (slang_struct_scope *, slang_atom, int);
typedef struct slang_struct_
{
slang_atom a_name;
struct slang_variable_scope_ *fields;
slang_struct_scope *structs;
} slang_struct;
int slang_struct_construct (slang_struct *);
void slang_struct_destruct (slang_struct *);
int slang_struct_copy (slang_struct *, const slang_struct *);
int slang_struct_equal (const slang_struct *, const slang_struct *);
#ifdef __cplusplus
}
#endif
#endif
+369 -369
View File
@@ -1,369 +1,369 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file slang_compile_variable.c
* slang front-end compiler
* \author Michal Krol
*/
#include "imports.h"
#include "slang_compile.h"
/* slang_type_specifier_type */
typedef struct
{
const char *name;
slang_type_specifier_type type;
} type_specifier_type_name;
static type_specifier_type_name type_specifier_type_names[] = {
{ "void", slang_spec_void },
{ "bool", slang_spec_bool },
{ "bvec2", slang_spec_bvec2 },
{ "bvec3", slang_spec_bvec3 },
{ "bvec4", slang_spec_bvec4 },
{ "int", slang_spec_int },
{ "ivec2", slang_spec_ivec2 },
{ "ivec3", slang_spec_ivec3 },
{ "ivec4", slang_spec_ivec4 },
{ "float", slang_spec_float },
{ "vec2", slang_spec_vec2 },
{ "vec3", slang_spec_vec3 },
{ "vec4", slang_spec_vec4 },
{ "mat2", slang_spec_mat2 },
{ "mat3", slang_spec_mat3 },
{ "mat4", slang_spec_mat4 },
{ "sampler1D", slang_spec_sampler1D },
{ "sampler2D", slang_spec_sampler2D },
{ "sampler3D", slang_spec_sampler3D },
{ "samplerCube", slang_spec_samplerCube },
{ "sampler1DShadow", slang_spec_sampler1DShadow },
{ "sampler2DShadow", slang_spec_sampler2DShadow },
{ NULL, slang_spec_void }
};
slang_type_specifier_type slang_type_specifier_type_from_string (const char *name)
{
type_specifier_type_name *p = type_specifier_type_names;
while (p->name != NULL)
{
if (slang_string_compare (p->name, name) == 0)
break;
p++;
}
return p->type;
}
const char *slang_type_specifier_type_to_string (slang_type_specifier_type type)
{
type_specifier_type_name *p = type_specifier_type_names;
while (p->name != NULL)
{
if (p->type == type)
break;
p++;
}
return p->name;
}
/* slang_fully_specified_type */
int slang_fully_specified_type_construct (slang_fully_specified_type *type)
{
type->qualifier = slang_qual_none;
slang_type_specifier_ctr (&type->specifier);
return 1;
}
void slang_fully_specified_type_destruct (slang_fully_specified_type *type)
{
slang_type_specifier_dtr (&type->specifier);
}
int slang_fully_specified_type_copy (slang_fully_specified_type *x, const slang_fully_specified_type *y)
{
slang_fully_specified_type z;
if (!slang_fully_specified_type_construct (&z))
return 0;
z.qualifier = y->qualifier;
if (!slang_type_specifier_copy (&z.specifier, &y->specifier))
{
slang_fully_specified_type_destruct (&z);
return 0;
}
slang_fully_specified_type_destruct (x);
*x = z;
return 1;
}
/* slang_variable_scope */
int slang_variable_scope_construct (slang_variable_scope *scope)
{
scope->variables = NULL;
scope->num_variables = 0;
scope->outer_scope = NULL;
return 1;
}
void slang_variable_scope_destruct (slang_variable_scope *scope)
{
unsigned int i;
for (i = 0; i < scope->num_variables; i++)
slang_variable_destruct (scope->variables + i);
slang_alloc_free (scope->variables);
/* do not free scope->outer_scope */
}
int slang_variable_scope_copy (slang_variable_scope *x, const slang_variable_scope *y)
{
slang_variable_scope z;
unsigned int i;
if (!slang_variable_scope_construct (&z))
return 0;
z.variables = (slang_variable *) slang_alloc_malloc (y->num_variables * sizeof (slang_variable));
if (z.variables == NULL)
{
slang_variable_scope_destruct (&z);
return 0;
}
for (z.num_variables = 0; z.num_variables < y->num_variables; z.num_variables++)
if (!slang_variable_construct (&z.variables[z.num_variables]))
{
slang_variable_scope_destruct (&z);
return 0;
}
for (i = 0; i < z.num_variables; i++)
if (!slang_variable_copy (&z.variables[i], &y->variables[i]))
{
slang_variable_scope_destruct (&z);
return 0;
}
z.outer_scope = y->outer_scope;
slang_variable_scope_destruct (x);
*x = z;
return 1;
}
/* slang_variable */
int slang_variable_construct (slang_variable *var)
{
if (!slang_fully_specified_type_construct (&var->type))
return 0;
var->a_name = SLANG_ATOM_NULL;
var->array_len = 0;
var->initializer = NULL;
var->address = ~0;
var->size = 0;
var->global = 0;
return 1;
}
void slang_variable_destruct (slang_variable *var)
{
slang_fully_specified_type_destruct (&var->type);
if (var->initializer != NULL)
{
slang_operation_destruct (var->initializer);
slang_alloc_free (var->initializer);
}
}
int slang_variable_copy (slang_variable *x, const slang_variable *y)
{
slang_variable z;
if (!slang_variable_construct (&z))
return 0;
if (!slang_fully_specified_type_copy (&z.type, &y->type))
{
slang_variable_destruct (&z);
return 0;
}
z.a_name = y->a_name;
z.array_len = y->array_len;
if (y->initializer != NULL)
{
z.initializer = (slang_operation *) slang_alloc_malloc (sizeof (slang_operation));
if (z.initializer == NULL)
{
slang_variable_destruct (&z);
return 0;
}
if (!slang_operation_construct (z.initializer))
{
slang_alloc_free (z.initializer);
slang_variable_destruct (&z);
return 0;
}
if (!slang_operation_copy (z.initializer, y->initializer))
{
slang_variable_destruct (&z);
return 0;
}
}
z.address = y->address;
z.size = y->size;
z.global = y->global;
slang_variable_destruct (x);
*x = z;
return 1;
}
slang_variable *_slang_locate_variable (slang_variable_scope *scope, slang_atom a_name, GLboolean all)
{
GLuint i;
for (i = 0; i < scope->num_variables; i++)
if (a_name == scope->variables[i].a_name)
return &scope->variables[i];
if (all && scope->outer_scope != NULL)
return _slang_locate_variable (scope->outer_scope, a_name, 1);
return NULL;
}
/*
* _slang_build_export_data_table()
*/
static GLenum gl_type_from_specifier (const slang_type_specifier *type)
{
switch (type->type)
{
case slang_spec_bool:
return GL_BOOL_ARB;
case slang_spec_bvec2:
return GL_BOOL_VEC2_ARB;
case slang_spec_bvec3:
return GL_BOOL_VEC3_ARB;
case slang_spec_bvec4:
return GL_BOOL_VEC4_ARB;
case slang_spec_int:
return GL_INT;
case slang_spec_ivec2:
return GL_INT_VEC2_ARB;
case slang_spec_ivec3:
return GL_INT_VEC3_ARB;
case slang_spec_ivec4:
return GL_INT_VEC4_ARB;
case slang_spec_float:
return GL_FLOAT;
case slang_spec_vec2:
return GL_FLOAT_VEC2_ARB;
case slang_spec_vec3:
return GL_FLOAT_VEC3_ARB;
case slang_spec_vec4:
return GL_FLOAT_VEC4_ARB;
case slang_spec_mat2:
return GL_FLOAT_MAT2_ARB;
case slang_spec_mat3:
return GL_FLOAT_MAT3_ARB;
case slang_spec_mat4:
return GL_FLOAT_MAT4_ARB;
case slang_spec_sampler1D:
return GL_SAMPLER_1D_ARB;
case slang_spec_sampler2D:
return GL_SAMPLER_2D_ARB;
case slang_spec_sampler3D:
return GL_SAMPLER_3D_ARB;
case slang_spec_samplerCube:
return GL_SAMPLER_CUBE_ARB;
case slang_spec_sampler1DShadow:
return GL_SAMPLER_1D_SHADOW_ARB;
case slang_spec_sampler2DShadow:
return GL_SAMPLER_2D_SHADOW_ARB;
case slang_spec_array:
return gl_type_from_specifier (type->_array);
default:
return GL_FLOAT;
}
}
static GLboolean build_quant (slang_export_data_quant *q, slang_variable *var)
{
slang_type_specifier *spec = &var->type.specifier;
q->name = var->a_name;
q->size = var->size;
if (spec->type == slang_spec_array)
{
q->array_len = var->array_len;
q->size /= var->array_len;
spec = spec->_array;
}
if (spec->type == slang_spec_struct)
{
GLuint i;
q->u.field_count = spec->_struct->fields->num_variables;
q->structure = (slang_export_data_quant *) slang_alloc_malloc (
q->u.field_count * sizeof (slang_export_data_quant));
if (q->structure == NULL)
return GL_FALSE;
for (i = 0; i < q->u.field_count; i++)
slang_export_data_quant_ctr (&q->structure[i]);
for (i = 0; i < q->u.field_count; i++)
if (!build_quant (&q->structure[i], &spec->_struct->fields->variables[i]))
return GL_FALSE;
}
else
q->u.basic_type = gl_type_from_specifier (spec);
return GL_TRUE;
}
GLboolean _slang_build_export_data_table (slang_export_data_table *tbl, slang_variable_scope *vars)
{
GLuint i;
for (i = 0; i < vars->num_variables; i++)
{
slang_variable *var = &vars->variables[i];
slang_export_data_entry *e;
e = slang_export_data_table_add (tbl);
if (e == NULL)
return GL_FALSE;
if (!build_quant (&e->quant, var))
return GL_FALSE;
if (var->type.qualifier == slang_qual_uniform)
e->access = slang_exp_uniform;
else if (var->type.qualifier == slang_qual_attribute)
e->access = slang_exp_attribute;
else
e->access = slang_exp_varying;
e->address = var->address;
}
if (vars->outer_scope != NULL)
return _slang_build_export_data_table (tbl, vars->outer_scope);
return GL_TRUE;
}
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file slang_compile_variable.c
* slang front-end compiler
* \author Michal Krol
*/
#include "imports.h"
#include "slang_compile.h"
/* slang_type_specifier_type */
typedef struct
{
const char *name;
slang_type_specifier_type type;
} type_specifier_type_name;
static type_specifier_type_name type_specifier_type_names[] = {
{ "void", slang_spec_void },
{ "bool", slang_spec_bool },
{ "bvec2", slang_spec_bvec2 },
{ "bvec3", slang_spec_bvec3 },
{ "bvec4", slang_spec_bvec4 },
{ "int", slang_spec_int },
{ "ivec2", slang_spec_ivec2 },
{ "ivec3", slang_spec_ivec3 },
{ "ivec4", slang_spec_ivec4 },
{ "float", slang_spec_float },
{ "vec2", slang_spec_vec2 },
{ "vec3", slang_spec_vec3 },
{ "vec4", slang_spec_vec4 },
{ "mat2", slang_spec_mat2 },
{ "mat3", slang_spec_mat3 },
{ "mat4", slang_spec_mat4 },
{ "sampler1D", slang_spec_sampler1D },
{ "sampler2D", slang_spec_sampler2D },
{ "sampler3D", slang_spec_sampler3D },
{ "samplerCube", slang_spec_samplerCube },
{ "sampler1DShadow", slang_spec_sampler1DShadow },
{ "sampler2DShadow", slang_spec_sampler2DShadow },
{ NULL, slang_spec_void }
};
slang_type_specifier_type slang_type_specifier_type_from_string (const char *name)
{
type_specifier_type_name *p = type_specifier_type_names;
while (p->name != NULL)
{
if (slang_string_compare (p->name, name) == 0)
break;
p++;
}
return p->type;
}
const char *slang_type_specifier_type_to_string (slang_type_specifier_type type)
{
type_specifier_type_name *p = type_specifier_type_names;
while (p->name != NULL)
{
if (p->type == type)
break;
p++;
}
return p->name;
}
/* slang_fully_specified_type */
int slang_fully_specified_type_construct (slang_fully_specified_type *type)
{
type->qualifier = slang_qual_none;
slang_type_specifier_ctr (&type->specifier);
return 1;
}
void slang_fully_specified_type_destruct (slang_fully_specified_type *type)
{
slang_type_specifier_dtr (&type->specifier);
}
int slang_fully_specified_type_copy (slang_fully_specified_type *x, const slang_fully_specified_type *y)
{
slang_fully_specified_type z;
if (!slang_fully_specified_type_construct (&z))
return 0;
z.qualifier = y->qualifier;
if (!slang_type_specifier_copy (&z.specifier, &y->specifier))
{
slang_fully_specified_type_destruct (&z);
return 0;
}
slang_fully_specified_type_destruct (x);
*x = z;
return 1;
}
/* slang_variable_scope */
int slang_variable_scope_construct (slang_variable_scope *scope)
{
scope->variables = NULL;
scope->num_variables = 0;
scope->outer_scope = NULL;
return 1;
}
void slang_variable_scope_destruct (slang_variable_scope *scope)
{
unsigned int i;
for (i = 0; i < scope->num_variables; i++)
slang_variable_destruct (scope->variables + i);
slang_alloc_free (scope->variables);
/* do not free scope->outer_scope */
}
int slang_variable_scope_copy (slang_variable_scope *x, const slang_variable_scope *y)
{
slang_variable_scope z;
unsigned int i;
if (!slang_variable_scope_construct (&z))
return 0;
z.variables = (slang_variable *) slang_alloc_malloc (y->num_variables * sizeof (slang_variable));
if (z.variables == NULL)
{
slang_variable_scope_destruct (&z);
return 0;
}
for (z.num_variables = 0; z.num_variables < y->num_variables; z.num_variables++)
if (!slang_variable_construct (&z.variables[z.num_variables]))
{
slang_variable_scope_destruct (&z);
return 0;
}
for (i = 0; i < z.num_variables; i++)
if (!slang_variable_copy (&z.variables[i], &y->variables[i]))
{
slang_variable_scope_destruct (&z);
return 0;
}
z.outer_scope = y->outer_scope;
slang_variable_scope_destruct (x);
*x = z;
return 1;
}
/* slang_variable */
int slang_variable_construct (slang_variable *var)
{
if (!slang_fully_specified_type_construct (&var->type))
return 0;
var->a_name = SLANG_ATOM_NULL;
var->array_len = 0;
var->initializer = NULL;
var->address = ~0;
var->size = 0;
var->global = 0;
return 1;
}
void slang_variable_destruct (slang_variable *var)
{
slang_fully_specified_type_destruct (&var->type);
if (var->initializer != NULL)
{
slang_operation_destruct (var->initializer);
slang_alloc_free (var->initializer);
}
}
int slang_variable_copy (slang_variable *x, const slang_variable *y)
{
slang_variable z;
if (!slang_variable_construct (&z))
return 0;
if (!slang_fully_specified_type_copy (&z.type, &y->type))
{
slang_variable_destruct (&z);
return 0;
}
z.a_name = y->a_name;
z.array_len = y->array_len;
if (y->initializer != NULL)
{
z.initializer = (slang_operation *) slang_alloc_malloc (sizeof (slang_operation));
if (z.initializer == NULL)
{
slang_variable_destruct (&z);
return 0;
}
if (!slang_operation_construct (z.initializer))
{
slang_alloc_free (z.initializer);
slang_variable_destruct (&z);
return 0;
}
if (!slang_operation_copy (z.initializer, y->initializer))
{
slang_variable_destruct (&z);
return 0;
}
}
z.address = y->address;
z.size = y->size;
z.global = y->global;
slang_variable_destruct (x);
*x = z;
return 1;
}
slang_variable *_slang_locate_variable (slang_variable_scope *scope, slang_atom a_name, GLboolean all)
{
GLuint i;
for (i = 0; i < scope->num_variables; i++)
if (a_name == scope->variables[i].a_name)
return &scope->variables[i];
if (all && scope->outer_scope != NULL)
return _slang_locate_variable (scope->outer_scope, a_name, 1);
return NULL;
}
/*
* _slang_build_export_data_table()
*/
static GLenum gl_type_from_specifier (const slang_type_specifier *type)
{
switch (type->type)
{
case slang_spec_bool:
return GL_BOOL_ARB;
case slang_spec_bvec2:
return GL_BOOL_VEC2_ARB;
case slang_spec_bvec3:
return GL_BOOL_VEC3_ARB;
case slang_spec_bvec4:
return GL_BOOL_VEC4_ARB;
case slang_spec_int:
return GL_INT;
case slang_spec_ivec2:
return GL_INT_VEC2_ARB;
case slang_spec_ivec3:
return GL_INT_VEC3_ARB;
case slang_spec_ivec4:
return GL_INT_VEC4_ARB;
case slang_spec_float:
return GL_FLOAT;
case slang_spec_vec2:
return GL_FLOAT_VEC2_ARB;
case slang_spec_vec3:
return GL_FLOAT_VEC3_ARB;
case slang_spec_vec4:
return GL_FLOAT_VEC4_ARB;
case slang_spec_mat2:
return GL_FLOAT_MAT2_ARB;
case slang_spec_mat3:
return GL_FLOAT_MAT3_ARB;
case slang_spec_mat4:
return GL_FLOAT_MAT4_ARB;
case slang_spec_sampler1D:
return GL_SAMPLER_1D_ARB;
case slang_spec_sampler2D:
return GL_SAMPLER_2D_ARB;
case slang_spec_sampler3D:
return GL_SAMPLER_3D_ARB;
case slang_spec_samplerCube:
return GL_SAMPLER_CUBE_ARB;
case slang_spec_sampler1DShadow:
return GL_SAMPLER_1D_SHADOW_ARB;
case slang_spec_sampler2DShadow:
return GL_SAMPLER_2D_SHADOW_ARB;
case slang_spec_array:
return gl_type_from_specifier (type->_array);
default:
return GL_FLOAT;
}
}
static GLboolean build_quant (slang_export_data_quant *q, slang_variable *var)
{
slang_type_specifier *spec = &var->type.specifier;
q->name = var->a_name;
q->size = var->size;
if (spec->type == slang_spec_array)
{
q->array_len = var->array_len;
q->size /= var->array_len;
spec = spec->_array;
}
if (spec->type == slang_spec_struct)
{
GLuint i;
q->u.field_count = spec->_struct->fields->num_variables;
q->structure = (slang_export_data_quant *) slang_alloc_malloc (
q->u.field_count * sizeof (slang_export_data_quant));
if (q->structure == NULL)
return GL_FALSE;
for (i = 0; i < q->u.field_count; i++)
slang_export_data_quant_ctr (&q->structure[i]);
for (i = 0; i < q->u.field_count; i++)
if (!build_quant (&q->structure[i], &spec->_struct->fields->variables[i]))
return GL_FALSE;
}
else
q->u.basic_type = gl_type_from_specifier (spec);
return GL_TRUE;
}
GLboolean _slang_build_export_data_table (slang_export_data_table *tbl, slang_variable_scope *vars)
{
GLuint i;
for (i = 0; i < vars->num_variables; i++)
{
slang_variable *var = &vars->variables[i];
slang_export_data_entry *e;
e = slang_export_data_table_add (tbl);
if (e == NULL)
return GL_FALSE;
if (!build_quant (&e->quant, var))
return GL_FALSE;
if (var->type.qualifier == slang_qual_uniform)
e->access = slang_exp_uniform;
else if (var->type.qualifier == slang_qual_attribute)
e->access = slang_exp_attribute;
else
e->access = slang_exp_varying;
e->address = var->address;
}
if (vars->outer_scope != NULL)
return _slang_build_export_data_table (tbl, vars->outer_scope);
return GL_TRUE;
}
+93 -93
View File
@@ -1,93 +1,93 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_COMPILE_VARIABLE_H
#define SLANG_COMPILE_VARIABLE_H
#if defined __cplusplus
extern "C" {
#endif
typedef enum slang_type_qualifier_
{
slang_qual_none,
slang_qual_const,
slang_qual_attribute,
slang_qual_varying,
slang_qual_uniform,
slang_qual_out,
slang_qual_inout,
slang_qual_fixedoutput, /* internal */
slang_qual_fixedinput /* internal */
} slang_type_qualifier;
slang_type_specifier_type slang_type_specifier_type_from_string (const char *);
const char *slang_type_specifier_type_to_string (slang_type_specifier_type);
typedef struct slang_fully_specified_type_
{
slang_type_qualifier qualifier;
slang_type_specifier specifier;
} slang_fully_specified_type;
int slang_fully_specified_type_construct (slang_fully_specified_type *);
void slang_fully_specified_type_destruct (slang_fully_specified_type *);
int slang_fully_specified_type_copy (slang_fully_specified_type *, const slang_fully_specified_type *);
typedef struct slang_variable_scope_
{
struct slang_variable_ *variables;
unsigned int num_variables;
struct slang_variable_scope_ *outer_scope;
} slang_variable_scope;
int slang_variable_scope_construct (slang_variable_scope *);
void slang_variable_scope_destruct (slang_variable_scope *);
int slang_variable_scope_copy (slang_variable_scope *, const slang_variable_scope *);
typedef struct slang_variable_
{
slang_fully_specified_type type;
slang_atom a_name;
GLuint array_len; /* type: spec_array */
struct slang_operation_ *initializer;
unsigned int address;
unsigned int size;
int global;
} slang_variable;
int slang_variable_construct (slang_variable *);
void slang_variable_destruct (slang_variable *);
int slang_variable_copy (slang_variable *, const slang_variable *);
slang_variable *_slang_locate_variable (slang_variable_scope *, slang_atom a_name, GLboolean all);
GLboolean _slang_build_export_data_table (slang_export_data_table *, slang_variable_scope *);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_COMPILE_VARIABLE_H
#define SLANG_COMPILE_VARIABLE_H
#if defined __cplusplus
extern "C" {
#endif
typedef enum slang_type_qualifier_
{
slang_qual_none,
slang_qual_const,
slang_qual_attribute,
slang_qual_varying,
slang_qual_uniform,
slang_qual_out,
slang_qual_inout,
slang_qual_fixedoutput, /* internal */
slang_qual_fixedinput /* internal */
} slang_type_qualifier;
slang_type_specifier_type slang_type_specifier_type_from_string (const char *);
const char *slang_type_specifier_type_to_string (slang_type_specifier_type);
typedef struct slang_fully_specified_type_
{
slang_type_qualifier qualifier;
slang_type_specifier specifier;
} slang_fully_specified_type;
int slang_fully_specified_type_construct (slang_fully_specified_type *);
void slang_fully_specified_type_destruct (slang_fully_specified_type *);
int slang_fully_specified_type_copy (slang_fully_specified_type *, const slang_fully_specified_type *);
typedef struct slang_variable_scope_
{
struct slang_variable_ *variables;
unsigned int num_variables;
struct slang_variable_scope_ *outer_scope;
} slang_variable_scope;
int slang_variable_scope_construct (slang_variable_scope *);
void slang_variable_scope_destruct (slang_variable_scope *);
int slang_variable_scope_copy (slang_variable_scope *, const slang_variable_scope *);
typedef struct slang_variable_
{
slang_fully_specified_type type;
slang_atom a_name;
GLuint array_len; /* type: spec_array */
struct slang_operation_ *initializer;
unsigned int address;
unsigned int size;
int global;
} slang_variable;
int slang_variable_construct (slang_variable *);
void slang_variable_destruct (slang_variable *);
int slang_variable_copy (slang_variable *, const slang_variable *);
slang_variable *_slang_locate_variable (slang_variable_scope *, slang_atom a_name, GLboolean all);
GLboolean _slang_build_export_data_table (slang_export_data_table *, slang_variable_scope *);
#ifdef __cplusplus
}
#endif
#endif
File diff suppressed because it is too large Load Diff
+84 -84
View File
@@ -1,84 +1,84 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_EXECUTE_H
#define SLANG_EXECUTE_H
#include "slang_assemble.h"
#if defined __cplusplus
extern "C" {
#endif
typedef union slang_machine_slot_
{
GLfloat _float;
GLuint _addr;
} slang_machine_slot;
#define SLANG_MACHINE_GLOBAL_SIZE 3072
#define SLANG_MACHINE_STACK_SIZE 1024
#define SLANG_MACHINE_MEMORY_SIZE (SLANG_MACHINE_GLOBAL_SIZE + SLANG_MACHINE_STACK_SIZE)
#if defined(USE_X86_ASM) || defined(SLANG_X86)
typedef struct
{
GLvoid (* compiled_func) (struct slang_machine_ *);
GLuint esp_restore;
GLshort fpucntl_rnd_neg;
GLshort fpucntl_restore;
} slang_machine_x86;
#endif
typedef struct slang_machine_
{
GLuint ip; /* instruction pointer, for flow control */
GLuint sp; /* stack pointer, for stack access */
GLuint bp; /* base pointer, for local variable access */
GLuint kill; /* discard the fragment */
GLuint exit; /* terminate the shader */
slang_machine_slot mem[SLANG_MACHINE_MEMORY_SIZE];
#if defined(USE_X86_ASM) || defined(SLANG_X86)
slang_machine_x86 x86;
#endif
} slang_machine;
GLvoid slang_machine_ctr (slang_machine *);
GLvoid slang_machine_dtr (slang_machine *);
void slang_machine_init (slang_machine *);
int _slang_execute (const slang_assembly_file *);
int _slang_execute2 (const slang_assembly_file *, slang_machine *);
#if defined(USE_X86_ASM) || defined(SLANG_X86)
GLboolean _slang_x86_codegen (slang_machine *, slang_assembly_file *, GLuint);
#endif
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_EXECUTE_H
#define SLANG_EXECUTE_H
#include "slang_assemble.h"
#if defined __cplusplus
extern "C" {
#endif
typedef union slang_machine_slot_
{
GLfloat _float;
GLuint _addr;
} slang_machine_slot;
#define SLANG_MACHINE_GLOBAL_SIZE 3072
#define SLANG_MACHINE_STACK_SIZE 1024
#define SLANG_MACHINE_MEMORY_SIZE (SLANG_MACHINE_GLOBAL_SIZE + SLANG_MACHINE_STACK_SIZE)
#if defined(USE_X86_ASM) || defined(SLANG_X86)
typedef struct
{
GLvoid (* compiled_func) (struct slang_machine_ *);
GLuint esp_restore;
GLshort fpucntl_rnd_neg;
GLshort fpucntl_restore;
} slang_machine_x86;
#endif
typedef struct slang_machine_
{
GLuint ip; /* instruction pointer, for flow control */
GLuint sp; /* stack pointer, for stack access */
GLuint bp; /* base pointer, for local variable access */
GLuint kill; /* discard the fragment */
GLuint exit; /* terminate the shader */
slang_machine_slot mem[SLANG_MACHINE_MEMORY_SIZE];
#if defined(USE_X86_ASM) || defined(SLANG_X86)
slang_machine_x86 x86;
#endif
} slang_machine;
GLvoid slang_machine_ctr (slang_machine *);
GLvoid slang_machine_dtr (slang_machine *);
void slang_machine_init (slang_machine *);
int _slang_execute (const slang_assembly_file *);
int _slang_execute2 (const slang_assembly_file *, slang_machine *);
#if defined(USE_X86_ASM) || defined(SLANG_X86)
GLboolean _slang_x86_codegen (slang_machine *, slang_assembly_file *, GLuint);
#endif
#ifdef __cplusplus
}
#endif
#endif
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+42 -42
View File
@@ -1,42 +1,42 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_LIBRARY_NOISE_H
#define SLANG_LIBRARY_NOISE_H
#if defined __cplusplus
extern "C" {
#endif
GLfloat _slang_library_noise1 (GLfloat);
GLfloat _slang_library_noise2 (GLfloat, GLfloat);
GLfloat _slang_library_noise3 (GLfloat, GLfloat, GLfloat);
GLfloat _slang_library_noise4 (GLfloat, GLfloat, GLfloat, GLfloat);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_LIBRARY_NOISE_H
#define SLANG_LIBRARY_NOISE_H
#if defined __cplusplus
extern "C" {
#endif
GLfloat _slang_library_noise1 (GLfloat);
GLfloat _slang_library_noise2 (GLfloat, GLfloat);
GLfloat _slang_library_noise3 (GLfloat, GLfloat, GLfloat);
GLfloat _slang_library_noise4 (GLfloat, GLfloat, GLfloat, GLfloat);
#ifdef __cplusplus
}
#endif
#endif
+142 -142
View File
@@ -1,142 +1,142 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file slang_library_texsample.c
* built-in library functions for texture and shadow sampling
* \author Michal Krol
*/
#include "imports.h"
#include "context.h"
#include "colormac.h"
#include "swrast/s_context.h"
#include "slang_library_texsample.h"
GLvoid _slang_library_tex1d (GLfloat bias, GLfloat s, GLfloat sampler, GLfloat *color)
{
GET_CURRENT_CONTEXT(ctx);
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLuint unit = (GLuint) sampler;
GLfloat texcoord[4] = { s, 0.0f, 0.0f, 1.0f };
GLfloat lambda = bias;
GLchan rgba[4];
swrast->TextureSample[unit] (ctx, ctx->Texture.Unit[unit]._Current, 1,
(const GLfloat (*)[4]) texcoord, &lambda, &rgba);
color[0] = CHAN_TO_FLOAT(rgba[0]);
color[1] = CHAN_TO_FLOAT(rgba[1]);
color[2] = CHAN_TO_FLOAT(rgba[2]);
color[3] = CHAN_TO_FLOAT(rgba[3]);
}
GLvoid _slang_library_tex2d (GLfloat bias, GLfloat s, GLfloat t, GLfloat sampler, GLfloat *color)
{
GET_CURRENT_CONTEXT(ctx);
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLuint unit = (GLuint) sampler;
GLfloat texcoord[4] = { s, t, 0.0f, 1.0f };
GLfloat lambda = bias;
GLchan rgba[4];
swrast->TextureSample[unit] (ctx, ctx->Texture.Unit[unit]._Current, 1,
(const GLfloat (*)[4]) texcoord, &lambda, &rgba);
color[0] = CHAN_TO_FLOAT(rgba[0]);
color[1] = CHAN_TO_FLOAT(rgba[1]);
color[2] = CHAN_TO_FLOAT(rgba[2]);
color[3] = CHAN_TO_FLOAT(rgba[3]);
}
GLvoid _slang_library_tex3d (GLfloat bias, GLfloat s, GLfloat t, GLfloat r, GLfloat sampler,
GLfloat *color)
{
GET_CURRENT_CONTEXT(ctx);
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLuint unit = (GLuint) sampler;
GLfloat texcoord[4] = { s, t, r, 1.0f };
GLfloat lambda = bias;
GLchan rgba[4];
swrast->TextureSample[unit] (ctx, ctx->Texture.Unit[unit]._Current, 1,
(const GLfloat (*)[4]) texcoord, &lambda, &rgba);
color[0] = CHAN_TO_FLOAT(rgba[0]);
color[1] = CHAN_TO_FLOAT(rgba[1]);
color[2] = CHAN_TO_FLOAT(rgba[2]);
color[3] = CHAN_TO_FLOAT(rgba[3]);
}
GLvoid _slang_library_texcube (GLfloat bias, GLfloat s, GLfloat t, GLfloat r, GLfloat sampler,
GLfloat *color)
{
GET_CURRENT_CONTEXT(ctx);
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLuint unit = (GLuint) sampler;
GLfloat texcoord[4] = { s, t, r, 1.0f };
GLfloat lambda = bias;
GLchan rgba[4];
swrast->TextureSample[unit] (ctx, ctx->Texture.Unit[unit]._Current, 1,
(const GLfloat (*)[4]) texcoord, &lambda, &rgba);
color[0] = CHAN_TO_FLOAT(rgba[0]);
color[1] = CHAN_TO_FLOAT(rgba[1]);
color[2] = CHAN_TO_FLOAT(rgba[2]);
color[3] = CHAN_TO_FLOAT(rgba[3]);
}
GLvoid _slang_library_shad1d (GLfloat bias, GLfloat s, GLfloat t, GLfloat r, GLfloat sampler,
GLfloat *color)
{
GET_CURRENT_CONTEXT(ctx);
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLuint unit = (GLuint) sampler;
GLfloat texcoord[4] = { s, t, r, 1.0f };
GLfloat lambda = bias;
GLchan rgba[4];
swrast->TextureSample[unit] (ctx, ctx->Texture.Unit[unit]._Current, 1,
(const GLfloat (*)[4]) texcoord, &lambda, &rgba);
color[0] = CHAN_TO_FLOAT(rgba[0]);
color[1] = CHAN_TO_FLOAT(rgba[1]);
color[2] = CHAN_TO_FLOAT(rgba[2]);
color[3] = CHAN_TO_FLOAT(rgba[3]);
}
GLvoid _slang_library_shad2d (GLfloat bias, GLfloat s, GLfloat t, GLfloat r, GLfloat sampler,
GLfloat *color)
{
GET_CURRENT_CONTEXT(ctx);
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLuint unit = (GLuint) sampler;
GLfloat texcoord[4] = { s, t, r, 1.0f };
GLfloat lambda = bias;
GLchan rgba[4];
swrast->TextureSample[unit] (ctx, ctx->Texture.Unit[unit]._Current, 1,
(const GLfloat (*)[4]) texcoord, &lambda, &rgba);
color[0] = CHAN_TO_FLOAT(rgba[0]);
color[1] = CHAN_TO_FLOAT(rgba[1]);
color[2] = CHAN_TO_FLOAT(rgba[2]);
color[3] = CHAN_TO_FLOAT(rgba[3]);
}
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file slang_library_texsample.c
* built-in library functions for texture and shadow sampling
* \author Michal Krol
*/
#include "imports.h"
#include "context.h"
#include "colormac.h"
#include "swrast/s_context.h"
#include "slang_library_texsample.h"
GLvoid _slang_library_tex1d (GLfloat bias, GLfloat s, GLfloat sampler, GLfloat *color)
{
GET_CURRENT_CONTEXT(ctx);
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLuint unit = (GLuint) sampler;
GLfloat texcoord[4] = { s, 0.0f, 0.0f, 1.0f };
GLfloat lambda = bias;
GLchan rgba[4];
swrast->TextureSample[unit] (ctx, ctx->Texture.Unit[unit]._Current, 1,
(const GLfloat (*)[4]) texcoord, &lambda, &rgba);
color[0] = CHAN_TO_FLOAT(rgba[0]);
color[1] = CHAN_TO_FLOAT(rgba[1]);
color[2] = CHAN_TO_FLOAT(rgba[2]);
color[3] = CHAN_TO_FLOAT(rgba[3]);
}
GLvoid _slang_library_tex2d (GLfloat bias, GLfloat s, GLfloat t, GLfloat sampler, GLfloat *color)
{
GET_CURRENT_CONTEXT(ctx);
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLuint unit = (GLuint) sampler;
GLfloat texcoord[4] = { s, t, 0.0f, 1.0f };
GLfloat lambda = bias;
GLchan rgba[4];
swrast->TextureSample[unit] (ctx, ctx->Texture.Unit[unit]._Current, 1,
(const GLfloat (*)[4]) texcoord, &lambda, &rgba);
color[0] = CHAN_TO_FLOAT(rgba[0]);
color[1] = CHAN_TO_FLOAT(rgba[1]);
color[2] = CHAN_TO_FLOAT(rgba[2]);
color[3] = CHAN_TO_FLOAT(rgba[3]);
}
GLvoid _slang_library_tex3d (GLfloat bias, GLfloat s, GLfloat t, GLfloat r, GLfloat sampler,
GLfloat *color)
{
GET_CURRENT_CONTEXT(ctx);
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLuint unit = (GLuint) sampler;
GLfloat texcoord[4] = { s, t, r, 1.0f };
GLfloat lambda = bias;
GLchan rgba[4];
swrast->TextureSample[unit] (ctx, ctx->Texture.Unit[unit]._Current, 1,
(const GLfloat (*)[4]) texcoord, &lambda, &rgba);
color[0] = CHAN_TO_FLOAT(rgba[0]);
color[1] = CHAN_TO_FLOAT(rgba[1]);
color[2] = CHAN_TO_FLOAT(rgba[2]);
color[3] = CHAN_TO_FLOAT(rgba[3]);
}
GLvoid _slang_library_texcube (GLfloat bias, GLfloat s, GLfloat t, GLfloat r, GLfloat sampler,
GLfloat *color)
{
GET_CURRENT_CONTEXT(ctx);
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLuint unit = (GLuint) sampler;
GLfloat texcoord[4] = { s, t, r, 1.0f };
GLfloat lambda = bias;
GLchan rgba[4];
swrast->TextureSample[unit] (ctx, ctx->Texture.Unit[unit]._Current, 1,
(const GLfloat (*)[4]) texcoord, &lambda, &rgba);
color[0] = CHAN_TO_FLOAT(rgba[0]);
color[1] = CHAN_TO_FLOAT(rgba[1]);
color[2] = CHAN_TO_FLOAT(rgba[2]);
color[3] = CHAN_TO_FLOAT(rgba[3]);
}
GLvoid _slang_library_shad1d (GLfloat bias, GLfloat s, GLfloat t, GLfloat r, GLfloat sampler,
GLfloat *color)
{
GET_CURRENT_CONTEXT(ctx);
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLuint unit = (GLuint) sampler;
GLfloat texcoord[4] = { s, t, r, 1.0f };
GLfloat lambda = bias;
GLchan rgba[4];
swrast->TextureSample[unit] (ctx, ctx->Texture.Unit[unit]._Current, 1,
(const GLfloat (*)[4]) texcoord, &lambda, &rgba);
color[0] = CHAN_TO_FLOAT(rgba[0]);
color[1] = CHAN_TO_FLOAT(rgba[1]);
color[2] = CHAN_TO_FLOAT(rgba[2]);
color[3] = CHAN_TO_FLOAT(rgba[3]);
}
GLvoid _slang_library_shad2d (GLfloat bias, GLfloat s, GLfloat t, GLfloat r, GLfloat sampler,
GLfloat *color)
{
GET_CURRENT_CONTEXT(ctx);
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLuint unit = (GLuint) sampler;
GLfloat texcoord[4] = { s, t, r, 1.0f };
GLfloat lambda = bias;
GLchan rgba[4];
swrast->TextureSample[unit] (ctx, ctx->Texture.Unit[unit]._Current, 1,
(const GLfloat (*)[4]) texcoord, &lambda, &rgba);
color[0] = CHAN_TO_FLOAT(rgba[0]);
color[1] = CHAN_TO_FLOAT(rgba[1]);
color[2] = CHAN_TO_FLOAT(rgba[2]);
color[3] = CHAN_TO_FLOAT(rgba[3]);
}
+44 -44
View File
@@ -1,44 +1,44 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_LIBRARY_TEXSAMPLE_H
#define SLANG_LIBRARY_TEXSAMPLE_H
#if defined __cplusplus
extern "C" {
#endif
GLvoid _slang_library_tex1d (GLfloat, GLfloat, GLfloat, GLfloat *);
GLvoid _slang_library_tex2d (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat *);
GLvoid _slang_library_tex3d (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat *);
GLvoid _slang_library_texcube (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat *);
GLvoid _slang_library_shad1d (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat *);
GLvoid _slang_library_shad2d (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat *);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_LIBRARY_TEXSAMPLE_H
#define SLANG_LIBRARY_TEXSAMPLE_H
#if defined __cplusplus
extern "C" {
#endif
GLvoid _slang_library_tex1d (GLfloat, GLfloat, GLfloat, GLfloat *);
GLvoid _slang_library_tex2d (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat *);
GLvoid _slang_library_tex3d (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat *);
GLvoid _slang_library_texcube (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat *);
GLvoid _slang_library_shad1d (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat *);
GLvoid _slang_library_shad2d (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat *);
#ifdef __cplusplus
}
#endif
#endif
+36 -36
View File
@@ -1,36 +1,36 @@
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if defined __cplusplus
extern "C" {
#endif
int _mesa_isalnum (char);
int _glslang_3dlabs_InitProcess ();
int _glslang_3dlabs_ShInitialize ();
#if defined __cplusplus
}
#endif
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if defined __cplusplus
extern "C" {
#endif
int _mesa_isalnum (char);
int _glslang_3dlabs_InitProcess ();
int _glslang_3dlabs_ShInitialize ();
#if defined __cplusplus
}
#endif
+86 -86
View File
@@ -1,86 +1,86 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file slang_preprocess.c
* slang preprocessor
* \author Michal Krol
*/
#include "imports.h"
#include "grammar_mesa.h"
#include "slang_preprocess.h"
static const char *slang_version_syn =
#include "library/slang_version_syn.h"
;
int _slang_preprocess_version (const char *text, unsigned int *version, unsigned int *eaten,
slang_info_log *log)
{
grammar id;
byte *prod, *I;
unsigned int size;
id = grammar_load_from_text ((const byte *) slang_version_syn);
if (id == 0)
{
char buf[1024];
unsigned int pos;
grammar_get_last_error ( (unsigned char*) buf, 1024, (int*) &pos);
slang_info_log_error (log, buf);
return 0;
}
if (!grammar_fast_check (id, (const byte *) text, &prod, &size, 8))
{
char buf[1024];
unsigned int pos;
grammar_get_last_error ( (unsigned char*) buf, 1024, (int*) &pos);
slang_info_log_error (log, buf);
grammar_destroy (id);
return 0;
}
grammar_destroy (id);
/* there can be multiple #version directives - grab the last one */
I = prod;
while (I < prod + size)
{
*version =
(unsigned int) I[0] +
(unsigned int) I[1] * 100;
*eaten =
((unsigned int) I[2]) +
((unsigned int) I[3] << 8) +
((unsigned int) I[4] << 16) +
((unsigned int) I[5] << 24);
I += 6;
}
grammar_alloc_free (prod);
return 1;
}
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file slang_preprocess.c
* slang preprocessor
* \author Michal Krol
*/
#include "imports.h"
#include "grammar_mesa.h"
#include "slang_preprocess.h"
static const char *slang_version_syn =
#include "library/slang_version_syn.h"
;
int _slang_preprocess_version (const char *text, unsigned int *version, unsigned int *eaten,
slang_info_log *log)
{
grammar id;
byte *prod, *I;
unsigned int size;
id = grammar_load_from_text ((const byte *) slang_version_syn);
if (id == 0)
{
char buf[1024];
unsigned int pos;
grammar_get_last_error ( (unsigned char*) buf, 1024, (int*) &pos);
slang_info_log_error (log, buf);
return 0;
}
if (!grammar_fast_check (id, (const byte *) text, &prod, &size, 8))
{
char buf[1024];
unsigned int pos;
grammar_get_last_error ( (unsigned char*) buf, 1024, (int*) &pos);
slang_info_log_error (log, buf);
grammar_destroy (id);
return 0;
}
grammar_destroy (id);
/* there can be multiple #version directives - grab the last one */
I = prod;
while (I < prod + size)
{
*version =
(unsigned int) I[0] +
(unsigned int) I[1] * 100;
*eaten =
((unsigned int) I[2]) +
((unsigned int) I[3] << 8) +
((unsigned int) I[4] << 16) +
((unsigned int) I[5] << 24);
I += 6;
}
grammar_alloc_free (prod);
return 1;
}
+41 -41
View File
@@ -1,41 +1,41 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_PREPROCESS_H
#define SLANG_PREPROCESS_H
#include "slang_compile.h"
#if defined __cplusplus
extern "C" {
#endif
int _slang_preprocess_version (const char *, unsigned int *, unsigned int *, slang_info_log *);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_PREPROCESS_H
#define SLANG_PREPROCESS_H
#include "slang_compile.h"
#if defined __cplusplus
extern "C" {
#endif
int _slang_preprocess_version (const char *, unsigned int *, unsigned int *, slang_info_log *);
#ifdef __cplusplus
}
#endif
#endif
+79 -79
View File
@@ -37,7 +37,7 @@ GLboolean slang_storage_array_construct (slang_storage_array *arr)
{
arr->type = slang_stor_aggregate;
arr->aggregate = NULL;
arr->length = 0;
arr->length = 0;
return GL_TRUE;
}
@@ -55,13 +55,13 @@ GLvoid slang_storage_array_destruct (slang_storage_array *arr)
GLboolean slang_storage_aggregate_construct (slang_storage_aggregate *agg)
{
agg->arrays = NULL;
agg->count = 0;
agg->count = 0;
return GL_TRUE;
}
GLvoid slang_storage_aggregate_destruct (slang_storage_aggregate *agg)
{
GLuint i;
GLuint i;
for (i = 0; i < agg->count; i++)
slang_storage_array_destruct (agg->arrays + i);
@@ -70,14 +70,14 @@ GLvoid slang_storage_aggregate_destruct (slang_storage_aggregate *agg)
static slang_storage_array *slang_storage_aggregate_push_new (slang_storage_aggregate *agg)
{
slang_storage_array *arr = NULL;
slang_storage_array *arr = NULL;
agg->arrays = (slang_storage_array *) slang_alloc_realloc (agg->arrays, agg->count * sizeof (
slang_storage_array), (agg->count + 1) * sizeof (slang_storage_array));
if (agg->arrays != NULL)
{
arr = agg->arrays + agg->count;
if (!slang_storage_array_construct (arr))
if (!slang_storage_array_construct (arr))
return NULL;
agg->count++;
}
@@ -100,7 +100,7 @@ static GLboolean aggregate_vector (slang_storage_aggregate *agg, slang_storage_t
static GLboolean aggregate_matrix (slang_storage_aggregate *agg, slang_storage_type basic_type,
GLuint dimension)
{
slang_storage_array *arr = slang_storage_aggregate_push_new (agg);
slang_storage_array *arr = slang_storage_aggregate_push_new (agg);
if (arr == NULL)
return GL_FALSE;
arr->type = slang_stor_aggregate;
@@ -108,11 +108,11 @@ static GLboolean aggregate_matrix (slang_storage_aggregate *agg, slang_storage_t
arr->aggregate = (slang_storage_aggregate *) slang_alloc_malloc (sizeof (slang_storage_aggregate));
if (arr->aggregate == NULL)
return GL_FALSE;
if (!slang_storage_aggregate_construct (arr->aggregate))
{
slang_alloc_free (arr->aggregate);
arr->aggregate = NULL;
return GL_FALSE;
if (!slang_storage_aggregate_construct (arr->aggregate))
{
slang_alloc_free (arr->aggregate);
arr->aggregate = NULL;
return GL_FALSE;
}
if (!aggregate_vector (arr->aggregate, basic_type, dimension))
return GL_FALSE;
@@ -120,10 +120,10 @@ static GLboolean aggregate_matrix (slang_storage_aggregate *agg, slang_storage_t
}
static GLboolean aggregate_variables (slang_storage_aggregate *agg, slang_variable_scope *vars,
slang_function_scope *funcs, slang_struct_scope *structs, slang_variable_scope *globals,
slang_function_scope *funcs, slang_struct_scope *structs, slang_variable_scope *globals,
slang_machine *mach, slang_assembly_file *file, slang_atom_pool *atoms)
{
GLuint i;
GLuint i;
for (i = 0; i < vars->num_variables; i++)
if (!_slang_aggregate_variable (agg, &vars->variables[i].type.specifier,
@@ -131,60 +131,60 @@ static GLboolean aggregate_variables (slang_storage_aggregate *agg, slang_variab
return GL_FALSE;
return GL_TRUE;
}
GLboolean _slang_evaluate_int (slang_assembly_file *file, slang_machine *pmach,
slang_assembly_name_space *space, slang_operation *array_size, GLuint *pint,
slang_atom_pool *atoms)
{
slang_assembly_file_restore_point point;
slang_machine mach;
slang_assemble_ctx A;
A.file = file;
A.mach = pmach;
A.atoms = atoms;
A.space = *space;
A.local.ret_size = 0;
A.local.addr_tmp = 0;
A.local.swizzle_tmp = 4;
/* save the current assembly */
if (!slang_assembly_file_restore_point_save (file, &point))
return GL_FALSE;
/* setup the machine */
mach = *pmach;
mach.ip = file->count;
/* allocate local storage for expression */
if (!slang_assembly_file_push_label (file, slang_asm_local_alloc, 20))
return GL_FALSE;
if (!slang_assembly_file_push_label (file, slang_asm_enter, 20))
return GL_FALSE;
/* insert the actual expression */
if (!_slang_assemble_operation (&A, array_size, slang_ref_forbid))
return GL_FALSE;
if (!slang_assembly_file_push (file, slang_asm_exit))
return GL_FALSE;
/* execute the expression */
if (!_slang_execute2 (file, &mach))
return GL_FALSE;
/* the evaluated expression is on top of the stack */
*pint = (GLuint) mach.mem[mach.sp + SLANG_MACHINE_GLOBAL_SIZE]._float;
/* restore the old assembly */
if (!slang_assembly_file_restore_point_load (file, &point))
return GL_FALSE;
return GL_TRUE;
}
GLboolean _slang_evaluate_int (slang_assembly_file *file, slang_machine *pmach,
slang_assembly_name_space *space, slang_operation *array_size, GLuint *pint,
slang_atom_pool *atoms)
{
slang_assembly_file_restore_point point;
slang_machine mach;
slang_assemble_ctx A;
A.file = file;
A.mach = pmach;
A.atoms = atoms;
A.space = *space;
A.local.ret_size = 0;
A.local.addr_tmp = 0;
A.local.swizzle_tmp = 4;
/* save the current assembly */
if (!slang_assembly_file_restore_point_save (file, &point))
return GL_FALSE;
/* setup the machine */
mach = *pmach;
mach.ip = file->count;
/* allocate local storage for expression */
if (!slang_assembly_file_push_label (file, slang_asm_local_alloc, 20))
return GL_FALSE;
if (!slang_assembly_file_push_label (file, slang_asm_enter, 20))
return GL_FALSE;
/* insert the actual expression */
if (!_slang_assemble_operation (&A, array_size, slang_ref_forbid))
return GL_FALSE;
if (!slang_assembly_file_push (file, slang_asm_exit))
return GL_FALSE;
/* execute the expression */
if (!_slang_execute2 (file, &mach))
return GL_FALSE;
/* the evaluated expression is on top of the stack */
*pint = (GLuint) mach.mem[mach.sp + SLANG_MACHINE_GLOBAL_SIZE]._float;
/* restore the old assembly */
if (!slang_assembly_file_restore_point_load (file, &point))
return GL_FALSE;
return GL_TRUE;
}
GLboolean _slang_aggregate_variable (slang_storage_aggregate *agg, slang_type_specifier *spec,
GLuint array_len, slang_function_scope *funcs, slang_struct_scope *structs,
slang_variable_scope *vars, slang_machine *mach, slang_assembly_file *file,
slang_variable_scope *vars, slang_machine *mach, slang_assembly_file *file,
slang_atom_pool *atoms)
{
switch (spec->type)
@@ -227,11 +227,11 @@ GLboolean _slang_aggregate_variable (slang_storage_aggregate *agg, slang_type_sp
case slang_spec_sampler2DShadow:
return aggregate_vector (agg, slang_stor_int, 1);
case slang_spec_struct:
return aggregate_variables (agg, spec->_struct->fields, funcs, structs, vars, mach,
return aggregate_variables (agg, spec->_struct->fields, funcs, structs, vars, mach,
file, atoms);
case slang_spec_array:
{
slang_storage_array *arr;
slang_storage_array *arr;
arr = slang_storage_aggregate_push_new (agg);
if (arr == NULL)
@@ -240,16 +240,16 @@ GLboolean _slang_aggregate_variable (slang_storage_aggregate *agg, slang_type_sp
arr->aggregate = (slang_storage_aggregate *) slang_alloc_malloc (sizeof (slang_storage_aggregate));
if (arr->aggregate == NULL)
return GL_FALSE;
if (!slang_storage_aggregate_construct (arr->aggregate))
{
slang_alloc_free (arr->aggregate);
arr->aggregate = NULL;
return GL_FALSE;
if (!slang_storage_aggregate_construct (arr->aggregate))
{
slang_alloc_free (arr->aggregate);
arr->aggregate = NULL;
return GL_FALSE;
}
if (!_slang_aggregate_variable (arr->aggregate, spec->_array, 0, funcs, structs,
if (!_slang_aggregate_variable (arr->aggregate, spec->_array, 0, funcs, structs,
vars, mach, file, atoms))
return GL_FALSE;
arr->length = array_len;
return GL_FALSE;
arr->length = array_len;
/* TODO: check if 0 < arr->length <= 65535 */
}
return GL_TRUE;
@@ -262,11 +262,11 @@ GLboolean _slang_aggregate_variable (slang_storage_aggregate *agg, slang_type_sp
GLuint _slang_sizeof_aggregate (const slang_storage_aggregate *agg)
{
GLuint i, size = 0;
GLuint i, size = 0;
for (i = 0; i < agg->count; i++)
{
GLuint element_size;
GLuint element_size;
if (agg->arrays[i].type == slang_stor_aggregate)
element_size = _slang_sizeof_aggregate (agg->arrays[i].aggregate);
@@ -281,11 +281,11 @@ GLuint _slang_sizeof_aggregate (const slang_storage_aggregate *agg)
GLboolean _slang_flatten_aggregate (slang_storage_aggregate *flat, const slang_storage_aggregate *agg)
{
GLuint i;
GLuint i;
for (i = 0; i < agg->count; i++)
{
GLuint j;
GLuint j;
for (j = 0; j < agg->arrays[i].length; j++)
{
@@ -296,7 +296,7 @@ GLboolean _slang_flatten_aggregate (slang_storage_aggregate *flat, const slang_s
}
else
{
slang_storage_array *arr;
slang_storage_array *arr;
arr = slang_storage_aggregate_push_new (flat);
if (arr == NULL)
+112 -112
View File
@@ -1,112 +1,112 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file slang_utility.c
* slang utilities
* \author Michal Krol
*/
#include "imports.h"
#include "slang_utility.h"
char *slang_string_concat (char *dst, const char *src)
{
return _mesa_strcpy (dst + _mesa_strlen (dst), src);
}
/* slang_atom_pool */
void slang_atom_pool_construct (slang_atom_pool *pool)
{
GLuint i;
for (i = 0; i < SLANG_ATOM_POOL_SIZE; i++)
pool->entries[i] = NULL;
}
void slang_atom_pool_destruct (slang_atom_pool *pool)
{
GLuint i;
for (i = 0; i < SLANG_ATOM_POOL_SIZE; i++)
{
slang_atom_entry *entry;
entry = pool->entries[i];
while (entry != NULL)
{
slang_atom_entry *next;
next = entry->next;
slang_alloc_free (entry->id);
slang_alloc_free (entry);
entry = next;
}
}
}
slang_atom slang_atom_pool_atom (slang_atom_pool *pool, const char *id)
{
GLuint hash;
const char *p = id;
slang_atom_entry **entry;
hash = 0;
while (*p != '\0')
{
GLuint g;
hash = (hash << 4) + (GLuint) *p++;
g = hash & 0xf0000000;
if (g != 0)
hash ^= g >> 24;
hash &= ~g;
}
hash %= SLANG_ATOM_POOL_SIZE;
entry = &pool->entries[hash];
while (*entry != NULL)
{
if (slang_string_compare ((**entry).id, id) == 0)
return (slang_atom) (**entry).id;
entry = &(**entry).next;
}
*entry = (slang_atom_entry *) slang_alloc_malloc (sizeof (slang_atom_entry));
if (*entry == NULL)
return SLANG_ATOM_NULL;
(**entry).next = NULL;
(**entry).id = slang_string_duplicate (id);
if ((**entry).id == NULL)
return SLANG_ATOM_NULL;
return (slang_atom) (**entry).id;
}
const char *slang_atom_pool_id (slang_atom_pool *pool, slang_atom atom)
{
return (const char *) atom;
}
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file slang_utility.c
* slang utilities
* \author Michal Krol
*/
#include "imports.h"
#include "slang_utility.h"
char *slang_string_concat (char *dst, const char *src)
{
return _mesa_strcpy (dst + _mesa_strlen (dst), src);
}
/* slang_atom_pool */
void slang_atom_pool_construct (slang_atom_pool *pool)
{
GLuint i;
for (i = 0; i < SLANG_ATOM_POOL_SIZE; i++)
pool->entries[i] = NULL;
}
void slang_atom_pool_destruct (slang_atom_pool *pool)
{
GLuint i;
for (i = 0; i < SLANG_ATOM_POOL_SIZE; i++)
{
slang_atom_entry *entry;
entry = pool->entries[i];
while (entry != NULL)
{
slang_atom_entry *next;
next = entry->next;
slang_alloc_free (entry->id);
slang_alloc_free (entry);
entry = next;
}
}
}
slang_atom slang_atom_pool_atom (slang_atom_pool *pool, const char *id)
{
GLuint hash;
const char *p = id;
slang_atom_entry **entry;
hash = 0;
while (*p != '\0')
{
GLuint g;
hash = (hash << 4) + (GLuint) *p++;
g = hash & 0xf0000000;
if (g != 0)
hash ^= g >> 24;
hash &= ~g;
}
hash %= SLANG_ATOM_POOL_SIZE;
entry = &pool->entries[hash];
while (*entry != NULL)
{
if (slang_string_compare ((**entry).id, id) == 0)
return (slang_atom) (**entry).id;
entry = &(**entry).next;
}
*entry = (slang_atom_entry *) slang_alloc_malloc (sizeof (slang_atom_entry));
if (*entry == NULL)
return SLANG_ATOM_NULL;
(**entry).next = NULL;
(**entry).id = slang_string_duplicate (id);
if ((**entry).id == NULL)
return SLANG_ATOM_NULL;
return (slang_atom) (**entry).id;
}
const char *slang_atom_pool_id (slang_atom_pool *pool, slang_atom atom)
{
return (const char *) atom;
}
+74 -74
View File
@@ -1,74 +1,74 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_UTILITY_H
#define SLANG_UTILITY_H
#if defined __cplusplus
extern "C" {
#endif
/* Compile-time assertions. If the expression is zero, try to declare an
* array of size [-1] to cause compilation error.
*/
#define static_assert(expr) do { int _array[(expr) ? 1 : -1]; (void) _array[0]; } while (0)
#define slang_alloc_free(ptr) _mesa_free (ptr)
#define slang_alloc_malloc(size) _mesa_malloc (size)
#define slang_alloc_realloc(ptr, old_size, size) _mesa_realloc (ptr, old_size, size)
#define slang_string_compare(str1, str2) _mesa_strcmp (str1, str2)
#define slang_string_copy(dst, src) _mesa_strcpy (dst, src)
#define slang_string_duplicate(src) _mesa_strdup (src)
#define slang_string_length(str) _mesa_strlen (str)
char *slang_string_concat (char *, const char *);
typedef GLvoid *slang_atom;
#define SLANG_ATOM_NULL ((slang_atom) 0)
typedef struct slang_atom_entry_
{
char *id;
struct slang_atom_entry_ *next;
} slang_atom_entry;
#define SLANG_ATOM_POOL_SIZE 1023
typedef struct slang_atom_pool_
{
slang_atom_entry *entries[SLANG_ATOM_POOL_SIZE];
} slang_atom_pool;
GLvoid slang_atom_pool_construct (slang_atom_pool *);
GLvoid slang_atom_pool_destruct (slang_atom_pool *);
slang_atom slang_atom_pool_atom (slang_atom_pool *, const char *);
const char *slang_atom_pool_id (slang_atom_pool *, slang_atom);
#ifdef __cplusplus
}
#endif
#endif
/*
* Mesa 3-D graphics library
* Version: 6.5
*
* Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if !defined SLANG_UTILITY_H
#define SLANG_UTILITY_H
#if defined __cplusplus
extern "C" {
#endif
/* Compile-time assertions. If the expression is zero, try to declare an
* array of size [-1] to cause compilation error.
*/
#define static_assert(expr) do { int _array[(expr) ? 1 : -1]; (void) _array[0]; } while (0)
#define slang_alloc_free(ptr) _mesa_free (ptr)
#define slang_alloc_malloc(size) _mesa_malloc (size)
#define slang_alloc_realloc(ptr, old_size, size) _mesa_realloc (ptr, old_size, size)
#define slang_string_compare(str1, str2) _mesa_strcmp (str1, str2)
#define slang_string_copy(dst, src) _mesa_strcpy (dst, src)
#define slang_string_duplicate(src) _mesa_strdup (src)
#define slang_string_length(str) _mesa_strlen (str)
char *slang_string_concat (char *, const char *);
typedef GLvoid *slang_atom;
#define SLANG_ATOM_NULL ((slang_atom) 0)
typedef struct slang_atom_entry_
{
char *id;
struct slang_atom_entry_ *next;
} slang_atom_entry;
#define SLANG_ATOM_POOL_SIZE 1023
typedef struct slang_atom_pool_
{
slang_atom_entry *entries[SLANG_ATOM_POOL_SIZE];
} slang_atom_pool;
GLvoid slang_atom_pool_construct (slang_atom_pool *);
GLvoid slang_atom_pool_destruct (slang_atom_pool *);
slang_atom slang_atom_pool_atom (slang_atom_pool *, const char *);
const char *slang_atom_pool_id (slang_atom_pool *, slang_atom);
#ifdef __cplusplus
}
#endif
#endif
+112 -112
View File
@@ -1,112 +1,112 @@
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file traverse_wrap.h
* Handy TIntermTraverser class wrapper
* \author Michal Krol
*/
#ifndef __TRAVERSE_WRAP_H__
#define __TRAVERSE_WRAP_H__
#include "Include/intermediate.h"
/*
The original TIntermTraverser class that is used to walk the intermediate tree,
is not very elegant in its design. One must define static functions with
appropriate prototypes, construct TIntermTraverser object, and set its member
function pointers to one's static functions. If traversal-specific data
is needed, a new class must be derived, and one must up-cast the object
passed as a parameter to the static function.
The class below eliminates this burden by providing virtual methods that are
to be overridden in the derived class.
*/
class traverse_wrap: private TIntermTraverser
{
private:
static void _visitSymbol (TIntermSymbol *S, TIntermTraverser *T) {
static_cast<traverse_wrap *> (T)->Symbol (*S);
}
static void _visitConstantUnion (TIntermConstantUnion *U, TIntermTraverser *T) {
static_cast<traverse_wrap *> (T)->ConstantUnion (*U);
}
static bool _visitBinary (bool preVisit, TIntermBinary *B, TIntermTraverser *T) {
return static_cast<traverse_wrap *> (T)->Binary (preVisit, *B);
}
static bool _visitUnary (bool preVisit, TIntermUnary *U, TIntermTraverser *T) {
return static_cast<traverse_wrap *> (T)->Unary (preVisit, *U);
}
static bool _visitSelection (bool preVisit, TIntermSelection *S, TIntermTraverser *T) {
return static_cast<traverse_wrap *> (T)->Selection (preVisit, *S);
}
static bool _visitAggregate (bool preVisit, TIntermAggregate *A, TIntermTraverser *T) {
return static_cast<traverse_wrap *> (T)->Aggregate (preVisit, *A);
}
static bool _visitLoop (bool preVisit, TIntermLoop *L, TIntermTraverser *T) {
return static_cast<traverse_wrap *> (T)->Loop (preVisit, *L);
}
static bool _visitBranch (bool preVisit, TIntermBranch *B, TIntermTraverser *T) {
return static_cast<traverse_wrap *> (T)->Branch (preVisit, *B);
}
public:
traverse_wrap () {
visitSymbol = _visitSymbol;
visitConstantUnion = _visitConstantUnion;
visitBinary = _visitBinary;
visitUnary = _visitUnary;
visitSelection = _visitSelection;
visitAggregate = _visitAggregate;
visitLoop = _visitLoop;
visitBranch = _visitBranch;
}
protected:
virtual void Symbol (const TIntermSymbol &) {
}
virtual void ConstantUnion (const TIntermConstantUnion &) {
}
virtual bool Binary (bool, const TIntermBinary &) {
return true;
}
virtual bool Unary (bool, const TIntermUnary &) {
return true;
}
virtual bool Selection (bool, const TIntermSelection &) {
return true;
}
virtual bool Aggregate (bool, const TIntermAggregate &) {
return true;
}
virtual bool Loop (bool, const TIntermLoop &) {
return true;
}
virtual bool Branch (bool, const TIntermBranch &) {
return true;
}
};
#endif
/*
* Mesa 3-D graphics library
* Version: 6.3
*
* Copyright (C) 2005 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file traverse_wrap.h
* Handy TIntermTraverser class wrapper
* \author Michal Krol
*/
#ifndef __TRAVERSE_WRAP_H__
#define __TRAVERSE_WRAP_H__
#include "Include/intermediate.h"
/*
The original TIntermTraverser class that is used to walk the intermediate tree,
is not very elegant in its design. One must define static functions with
appropriate prototypes, construct TIntermTraverser object, and set its member
function pointers to one's static functions. If traversal-specific data
is needed, a new class must be derived, and one must up-cast the object
passed as a parameter to the static function.
The class below eliminates this burden by providing virtual methods that are
to be overridden in the derived class.
*/
class traverse_wrap: private TIntermTraverser
{
private:
static void _visitSymbol (TIntermSymbol *S, TIntermTraverser *T) {
static_cast<traverse_wrap *> (T)->Symbol (*S);
}
static void _visitConstantUnion (TIntermConstantUnion *U, TIntermTraverser *T) {
static_cast<traverse_wrap *> (T)->ConstantUnion (*U);
}
static bool _visitBinary (bool preVisit, TIntermBinary *B, TIntermTraverser *T) {
return static_cast<traverse_wrap *> (T)->Binary (preVisit, *B);
}
static bool _visitUnary (bool preVisit, TIntermUnary *U, TIntermTraverser *T) {
return static_cast<traverse_wrap *> (T)->Unary (preVisit, *U);
}
static bool _visitSelection (bool preVisit, TIntermSelection *S, TIntermTraverser *T) {
return static_cast<traverse_wrap *> (T)->Selection (preVisit, *S);
}
static bool _visitAggregate (bool preVisit, TIntermAggregate *A, TIntermTraverser *T) {
return static_cast<traverse_wrap *> (T)->Aggregate (preVisit, *A);
}
static bool _visitLoop (bool preVisit, TIntermLoop *L, TIntermTraverser *T) {
return static_cast<traverse_wrap *> (T)->Loop (preVisit, *L);
}
static bool _visitBranch (bool preVisit, TIntermBranch *B, TIntermTraverser *T) {
return static_cast<traverse_wrap *> (T)->Branch (preVisit, *B);
}
public:
traverse_wrap () {
visitSymbol = _visitSymbol;
visitConstantUnion = _visitConstantUnion;
visitBinary = _visitBinary;
visitUnary = _visitUnary;
visitSelection = _visitSelection;
visitAggregate = _visitAggregate;
visitLoop = _visitLoop;
visitBranch = _visitBranch;
}
protected:
virtual void Symbol (const TIntermSymbol &) {
}
virtual void ConstantUnion (const TIntermConstantUnion &) {
}
virtual bool Binary (bool, const TIntermBinary &) {
return true;
}
virtual bool Unary (bool, const TIntermUnary &) {
return true;
}
virtual bool Selection (bool, const TIntermSelection &) {
return true;
}
virtual bool Aggregate (bool, const TIntermAggregate &) {
return true;
}
virtual bool Loop (bool, const TIntermLoop &) {
return true;
}
virtual bool Branch (bool, const TIntermBranch &) {
return true;
}
};
#endif