/*
* Use GL_ARB_fragment_shader and GL_ARB_vertex_shader to implement
- * simple per-pixel lighting.\r
- *\r
- * Michal Krol\r
+ * simple per-pixel lighting.
+ *
+ * Michal Krol
* 20 February 2006
- *\r
+ *
* Based on the original demo by:
* Brian Paul
* 17 April 2003
- */\r
-\r
-#ifdef WIN32\r
-#include <windows.h>\r
+ */
+
+#ifdef WIN32
+#include <windows.h>
#endif
#include <stdio.h>
-#include <stdlib.h>\r
+#include <stdlib.h>
#include <GL/gl.h>
-#include <GL/glut.h>\r
-#include <GL/glext.h>\r
-\r
-#ifdef WIN32\r
-#define GETPROCADDRESS wglGetProcAddress\r
-#else\r
-#define GETPROCADDRESS glutGetProcAddress\r
-#endif\r
+#include <GL/glut.h>
+#include <GL/glext.h>
+
+#ifdef WIN32
+#define GETPROCADDRESS wglGetProcAddress
+#else
+#define GETPROCADDRESS glutGetProcAddress
+#endif
static GLfloat diffuse[4] = { 0.5f, 0.5f, 1.0f, 1.0f };
static GLfloat specular[4] = { 0.8f, 0.8f, 0.8f, 1.0f };
static GLfloat delta = 1.0f;
static GLhandleARB fragShader;
-static GLhandleARB vertShader;\r
-static GLhandleARB program;\r
-\r
-static GLint uLightPos;\r
-static GLint uDiffuse;\r
-static GLint uSpecular;\r
+static GLhandleARB vertShader;
+static GLhandleARB program;
+
+static GLint uLightPos;
+static GLint uDiffuse;
+static GLint uSpecular;
static GLboolean anim = GL_TRUE;
static GLboolean wire = GL_FALSE;
static GLint t0 = 0;
static GLint frames = 0;
-static GLfloat xRot = 0.0f, yRot = 0.0f;\r
-\r
-static PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB = NULL;\r
-static PFNGLSHADERSOURCEARBPROC glShaderSourceARB = NULL;\r
-static PFNGLCOMPILESHADERARBPROC glCompileShaderARB = NULL;\r
-static PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB = NULL;\r
-static PFNGLATTACHOBJECTARBPROC glAttachObjectARB = NULL;\r
-static PFNGLLINKPROGRAMARBPROC glLinkProgramARB = NULL;\r
-static PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB = NULL;\r
-static PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB = NULL;\r
+static GLfloat xRot = 0.0f, yRot = 0.0f;
+
+static PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB = NULL;
+static PFNGLSHADERSOURCEARBPROC glShaderSourceARB = NULL;
+static PFNGLCOMPILESHADERARBPROC glCompileShaderARB = NULL;
+static PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB = NULL;
+static PFNGLATTACHOBJECTARBPROC glAttachObjectARB = NULL;
+static PFNGLLINKPROGRAMARBPROC glLinkProgramARB = NULL;
+static PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB = NULL;
+static PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB = NULL;
static PFNGLUNIFORM4FVARBPROC glUniform4fvARB = NULL;
static void Redisplay (void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- if (pixelLight)\r
- {\r
- glUseProgramObjectARB (program);\r
+ if (pixelLight)
+ {
+ glUseProgramObjectARB (program);
glUniform4fvARB (uLightPos, 1, lightPos);
glDisable(GL_LIGHTING);
}
- else\r
- {\r
+ else
+ {
glUseProgramObjectARB (0);
glLightfv (GL_LIGHT0, GL_POSITION, lightPos);
glEnable(GL_LIGHTING);
glPushMatrix ();
glRotatef (xRot, 1.0f, 0.0f, 0.0f);
glRotatef (yRot, 0.0f, 1.0f, 0.0f);
- glutSolidSphere (2.0, 10, 5);\r
+ glutSolidSphere (2.0, 10, 5);
glPopMatrix ();
glutSwapBuffers();
frames++;
- if (anim)\r
+ if (anim)
{
GLint t = glutGet (GLUT_ELAPSED_TIME);
- if (t - t0 >= 5000)\r
+ if (t - t0 >= 5000)
{
GLfloat seconds = (GLfloat) (t - t0) / 1000.0f;
GLfloat fps = frames / seconds;
static void Key (unsigned char key, int x, int y)
{
(void) x;
- (void) y;\r
+ (void) y;
- switch (key)\r
+ switch (key)
{
case ' ':
case 'a':
static void SpecialKey (int key, int x, int y)
{
- const GLfloat step = 3.0f;\r
+ const GLfloat step = 3.0f;
(void) x;
- (void) y;\r
+ (void) y;
- switch (key)\r
+ switch (key)
{
case GLUT_KEY_UP:
xRot -= step;
static void Init (void)
{
- static const char *fragShaderText =\r
- "uniform vec4 lightPos;\n"\r
- "uniform vec4 diffuse;\n"\r
+ static const char *fragShaderText =
+ "uniform vec4 lightPos;\n"
+ "uniform vec4 diffuse;\n"
"uniform vec4 specular;\n"
- "void main () {\n"\r
- " // Compute dot product of light direction and normal vector\n"\r
- " float dotProd;\n"\r
- " dotProd = clamp (dot (normalize (lightPos).xyz, normalize (gl_TexCoord[0]).xyz), 0.0, 1.0);\n"\r
- " // Compute diffuse and specular contributions\n"\r
- " gl_FragColor = diffuse * dotProd + specular * pow (dotProd, 20.0);\n"\r
+ "void main () {\n"
+ " // Compute dot product of light direction and normal vector\n"
+ " float dotProd;\n"
+ " dotProd = clamp (dot (normalize (lightPos).xyz, normalize (gl_TexCoord[0]).xyz), 0.0, 1.0);\n"
+ " // Compute diffuse and specular contributions\n"
+ " gl_FragColor = diffuse * dotProd + specular * pow (dotProd, 20.0);\n"
"}\n"
;
static const char *vertShaderText =
- "void main () {\n"\r
- " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"\r
- " gl_TexCoord[0] = vec4 (gl_NormalMatrix * gl_Normal, 1.0);\n"\r
+ "void main () {\n"
+ " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
+ " gl_TexCoord[0] = vec4 (gl_NormalMatrix * gl_Normal, 1.0);\n"
"}\n"
;
-\r
- if (!glutExtensionSupported ("GL_ARB_fragment_shader"))\r
+
+ if (!glutExtensionSupported ("GL_ARB_fragment_shader"))
{
printf ("Sorry, this demo requires GL_ARB_fragment_shader\n");
exit(1);
- }\r
- if (!glutExtensionSupported ("GL_ARB_shader_objects"))\r
- {\r
- printf ("Sorry, this demo requires GL_ARB_shader_objects\n");\r
- exit(1);\r
- }\r
- if (!glutExtensionSupported ("GL_ARB_shading_language_100"))\r
- {\r
- printf ("Sorry, this demo requires GL_ARB_shading_language_100\n");\r
- exit(1);\r
- }\r
- if (!glutExtensionSupported ("GL_ARB_vertex_shader"))\r
- {\r
- printf ("Sorry, this demo requires GL_ARB_vertex_shader\n");\r
- exit(1);\r
+ }
+ if (!glutExtensionSupported ("GL_ARB_shader_objects"))
+ {
+ printf ("Sorry, this demo requires GL_ARB_shader_objects\n");
+ exit(1);
+ }
+ if (!glutExtensionSupported ("GL_ARB_shading_language_100"))
+ {
+ printf ("Sorry, this demo requires GL_ARB_shading_language_100\n");
+ exit(1);
+ }
+ if (!glutExtensionSupported ("GL_ARB_vertex_shader"))
+ {
+ printf ("Sorry, this demo requires GL_ARB_vertex_shader\n");
+ exit(1);
}
- glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) GETPROCADDRESS ("glCreateShaderObjectARB");\r
- glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) GETPROCADDRESS ("glShaderSourceARB");\r
- glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) GETPROCADDRESS ("glCompileShaderARB");\r
- glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) GETPROCADDRESS ("glCreateProgramObjectARB");\r
- glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) GETPROCADDRESS ("glAttachObjectARB");\r
- glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) GETPROCADDRESS ("glLinkProgramARB");\r
- glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) GETPROCADDRESS ("glUseProgramObjectARB");\r
- glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) GETPROCADDRESS ("glGetUniformLocationARB");\r
- glUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) GETPROCADDRESS ("glUniform4fvARB");\r
-\r
- fragShader = glCreateShaderObjectARB (GL_FRAGMENT_SHADER_ARB);\r
- glShaderSourceARB (fragShader, 1, &fragShaderText, NULL);\r
+ glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) GETPROCADDRESS ("glCreateShaderObjectARB");
+ glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) GETPROCADDRESS ("glShaderSourceARB");
+ glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) GETPROCADDRESS ("glCompileShaderARB");
+ glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) GETPROCADDRESS ("glCreateProgramObjectARB");
+ glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) GETPROCADDRESS ("glAttachObjectARB");
+ glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) GETPROCADDRESS ("glLinkProgramARB");
+ glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) GETPROCADDRESS ("glUseProgramObjectARB");
+ glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) GETPROCADDRESS ("glGetUniformLocationARB");
+ glUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) GETPROCADDRESS ("glUniform4fvARB");
+
+ fragShader = glCreateShaderObjectARB (GL_FRAGMENT_SHADER_ARB);
+ glShaderSourceARB (fragShader, 1, &fragShaderText, NULL);
glCompileShaderARB (fragShader);
-\r
- vertShader = glCreateShaderObjectARB (GL_VERTEX_SHADER_ARB);\r
- glShaderSourceARB (vertShader, 1, &vertShaderText, NULL);\r
- glCompileShaderARB (vertShader);\r
-\r
- program = glCreateProgramObjectARB ();\r
- glAttachObjectARB (program, fragShader);\r
- glAttachObjectARB (program, vertShader);\r
- glLinkProgramARB (program);\r
- glUseProgramObjectARB (program);\r
-\r
- uLightPos = glGetUniformLocationARB (program, "lightPos");\r
- uDiffuse = glGetUniformLocationARB (program, "diffuse");\r
- uSpecular = glGetUniformLocationARB (program, "specular");\r
-\r
- glUniform4fvARB (uDiffuse, 1, diffuse);\r
- glUniform4fvARB (uSpecular, 1, specular);\r
+
+ vertShader = glCreateShaderObjectARB (GL_VERTEX_SHADER_ARB);
+ glShaderSourceARB (vertShader, 1, &vertShaderText, NULL);
+ glCompileShaderARB (vertShader);
+
+ program = glCreateProgramObjectARB ();
+ glAttachObjectARB (program, fragShader);
+ glAttachObjectARB (program, vertShader);
+ glLinkProgramARB (program);
+ glUseProgramObjectARB (program);
+
+ uLightPos = glGetUniformLocationARB (program, "lightPos");
+ uDiffuse = glGetUniformLocationARB (program, "diffuse");
+ uSpecular = glGetUniformLocationARB (program, "specular");
+
+ glUniform4fvARB (uDiffuse, 1, diffuse);
+ glUniform4fvARB (uSpecular, 1, specular);
glClearColor (0.3f, 0.3f, 0.3f, 0.0f);
glEnable (GL_DEPTH_TEST);
- glEnable (GL_LIGHT0);\r
+ glEnable (GL_LIGHT0);
glEnable (GL_LIGHTING);
glMaterialfv (GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse);
glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, specular);
glutMainLoop ();
return 0;
}
-\r
+
static const char *version_1_3 = "1.3 Mesa " MESA_VERSION_STRING;
static const char *version_1_4 = "1.4 Mesa " MESA_VERSION_STRING;
static const char *version_1_5 = "1.5 Mesa " MESA_VERSION_STRING;
- static const char *version_2_0 = "1.5 Mesa " MESA_VERSION_STRING;/*XXX FIX*/\r
+ static const char *version_2_0 = "1.5 Mesa " MESA_VERSION_STRING;/*XXX FIX*/
static const char *sl_version_110 = "1.10 Mesa " MESA_VERSION_STRING;
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL);
case GL_EXTENSIONS:
if (!ctx->Extensions.String)
ctx->Extensions.String = _mesa_make_extension_string(ctx);
- return (const GLubyte *) ctx->Extensions.String;\r
-#if FEATURE_ARB_shading_language_100\r
- case GL_SHADING_LANGUAGE_VERSION_ARB:\r
- if (ctx->Extensions.ARB_shading_language_100)\r
- return (const GLubyte *) sl_version_110;\r
- goto error;\r
+ return (const GLubyte *) ctx->Extensions.String;
+#if FEATURE_ARB_shading_language_100
+ case GL_SHADING_LANGUAGE_VERSION_ARB:
+ if (ctx->Extensions.ARB_shading_language_100)
+ return (const GLubyte *) sl_version_110;
+ goto error;
#endif
#if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program || \
FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
return (const GLubyte *) ctx->Program.ErrorString;
}
/* FALL-THROUGH */
-#endif\r
+#endif
error:
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glGetString" );
#else
return sin(a);
#endif
-}\r
-\r
-/** Single precision wrapper around either sin() or xf86sin() */\r
-float\r
-_mesa_sinf(float a)\r
-{\r
-#if defined(XFree86LOADER) && defined(IN_MODULE)\r
- return (float) xf86sin((double) a);\r
-#else\r
- return (float) sin((double) a);\r
-#endif\r
+}
+
+/** Single precision wrapper around either sin() or xf86sin() */
+float
+_mesa_sinf(float a)
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ return (float) xf86sin((double) a);
+#else
+ return (float) sin((double) a);
+#endif
}
/** Wrapper around either cos() or xf86cos() */
if (light->SpotCutoff == params[0])
return;
FLUSH_VERTICES(ctx, _NEW_LIGHT);
- light->SpotCutoff = params[0];\r
+ light->SpotCutoff = params[0];
light->_CosCutoffNeg = (GLfloat) (_mesa_cos(light->SpotCutoff * DEG2RAD));
if (light->_CosCutoffNeg < 0)
- light->_CosCutoff = 0;\r
- else\r
+ light->_CosCutoff = 0;
+ else
light->_CosCutoff = light->_CosCutoffNeg;
if (light->SpotCutoff != 180.0F)
light->_Flags |= LIGHT_SPOT;
ASSIGN_3V( l->EyeDirection, 0.0, 0.0, -1.0 );
l->SpotExponent = 0.0;
_mesa_invalidate_spot_exp_table( l );
- l->SpotCutoff = 180.0;\r
+ l->SpotCutoff = 180.0;
l->_CosCutoffNeg = -1.0f;
l->_CosCutoff = 0.0; /* KW: -ve values not admitted */
l->ConstantAttenuation = 1.0;
-/*\r
- * Mesa 3-D graphics library\r
- * Version: 6.5\r
- *\r
- * Copyright (C) 2006 Brian Paul All Rights Reserved.\r
- *\r
- * Permission is hereby granted, free of charge, to any person obtaining a\r
- * copy of this software and associated documentation files (the "Software"),\r
- * to deal in the Software without restriction, including without limitation\r
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
- * and/or sell copies of the Software, and to permit persons to whom the\r
- * Software is furnished to do so, subject to the following conditions:\r
- *\r
- * The above copyright notice and this permission notice shall be included\r
- * in all copies or substantial portions of the Software.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\r
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
- */\r
-\r
-/**\r
- * \file slang_export.c\r
- * interface between assembly code and the application\r
- * \author Michal Krol\r
- */\r
-\r
-#include "imports.h"\r
-#include "slang_export.h"\r
-\r
-/*\r
- * slang_export_data_quant\r
- */\r
-\r
-GLvoid slang_export_data_quant_ctr (slang_export_data_quant *self)\r
-{\r
- self->name = SLANG_ATOM_NULL;\r
- self->size = 0;\r
- self->array_len = 0;\r
- self->structure = NULL;\r
- self->u.basic_type = GL_FLOAT;\r
-}\r
-\r
-GLvoid slang_export_data_quant_dtr (slang_export_data_quant *self)\r
-{\r
- if (self->structure != NULL)\r
- {\r
- GLuint i;\r
-\r
- for (i = 0; i < self->u.field_count; i++)\r
- slang_export_data_quant_dtr (&self->structure[i]);\r
- slang_alloc_free (self->structure);\r
- }\r
-}\r
-\r
-slang_export_data_quant *slang_export_data_quant_add_field (slang_export_data_quant *self)\r
-{\r
- const GLuint n = self->u.field_count;\r
-\r
- self->structure = (slang_export_data_quant *) slang_alloc_realloc (self->structure,\r
- n * sizeof (slang_export_data_quant), (n + 1) * sizeof (slang_export_data_quant));\r
- if (self->structure == NULL)\r
- return NULL;\r
- slang_export_data_quant_ctr (&self->structure[n]);\r
- self->u.field_count++;\r
- return &self->structure[n];\r
-}\r
-\r
-GLboolean slang_export_data_quant_array (slang_export_data_quant *self)\r
-{\r
- return self->array_len != 0;\r
-}\r
-\r
-GLboolean slang_export_data_quant_struct (slang_export_data_quant *self)\r
-{\r
- return self->structure != NULL;\r
-}\r
-\r
-GLboolean slang_export_data_quant_simple (slang_export_data_quant *self)\r
-{\r
- return self->array_len == 0 && self->structure == NULL;\r
-}\r
-\r
-GLenum slang_export_data_quant_type (slang_export_data_quant *self)\r
-{\r
- assert (self->structure == NULL);\r
- return self->u.basic_type;\r
-}\r
-\r
-GLuint slang_export_data_quant_fields (slang_export_data_quant *self)\r
-{\r
- assert (self->structure != NULL);\r
- return self->u.field_count;\r
-}\r
-\r
-GLuint slang_export_data_quant_elements (slang_export_data_quant *self)\r
-{\r
- if (self->array_len == 0)\r
- return 1;\r
- return self->array_len;\r
-}\r
-\r
-GLuint slang_export_data_quant_components (slang_export_data_quant *self)\r
-{\r
- return self->size / 4;\r
-}\r
-\r
-GLuint slang_export_data_quant_size (slang_export_data_quant *self)\r
-{\r
- return self->size;\r
-}\r
-\r
-/*\r
- * slang_export_data_entry\r
- */\r
-\r
-GLvoid slang_export_data_entry_ctr (slang_export_data_entry *self)\r
-{\r
- slang_export_data_quant_ctr (&self->quant);\r
- self->access = slang_exp_uniform;\r
- self->address = ~0;\r
-}\r
-\r
-GLvoid slang_export_data_entry_dtr (slang_export_data_entry *self)\r
-{\r
- slang_export_data_quant_dtr (&self->quant);\r
-}\r
-\r
-/*\r
- * slang_export_data_table\r
- */\r
-\r
-GLvoid slang_export_data_table_ctr (slang_export_data_table *self)\r
-{\r
- self->entries = NULL;\r
- self->count = 0;\r
- self->atoms = NULL;\r
-}\r
-\r
-GLvoid slang_export_data_table_dtr (slang_export_data_table *self)\r
-{\r
- if (self->entries != NULL)\r
- {\r
- GLuint i;\r
-\r
- for (i = 0; i < self->count; i++)\r
- slang_export_data_entry_dtr (&self->entries[i]);\r
- slang_alloc_free (self->entries);\r
- }\r
-}\r
-\r
-slang_export_data_entry *slang_export_data_table_add (slang_export_data_table *self)\r
-{\r
- const GLuint n = self->count;\r
-\r
- self->entries = (slang_export_data_entry *) slang_alloc_realloc (self->entries,\r
- n * sizeof (slang_export_data_entry), (n + 1) * sizeof (slang_export_data_entry));\r
- if (self->entries == NULL)\r
- return NULL;\r
- slang_export_data_entry_ctr (&self->entries[n]);\r
- self->count++;\r
- return &self->entries[n];\r
-}\r
-\r
-/*\r
- * slang_export_code_entry\r
- */\r
-\r
-static GLvoid slang_export_code_entry_ctr (slang_export_code_entry *self)\r
-{\r
- self->name = SLANG_ATOM_NULL;\r
- self->address = ~0;\r
-}\r
-\r
-static GLvoid slang_export_code_entry_dtr (slang_export_code_entry *self)\r
-{\r
-}\r
-\r
-/*\r
- * slang_export_code_table\r
- */\r
-\r
-GLvoid slang_export_code_table_ctr (slang_export_code_table *self)\r
-{\r
- self->entries = NULL;\r
- self->count = 0;\r
- self->atoms = NULL;\r
-}\r
-\r
-GLvoid slang_export_code_table_dtr (slang_export_code_table *self)\r
-{\r
- if (self->entries != NULL)\r
- {\r
- GLuint i;\r
-\r
- for (i = 0; i < self->count; i++)\r
- slang_export_code_entry_dtr (&self->entries[i]);\r
- slang_alloc_free (self->entries);\r
- }\r
-}\r
-\r
-slang_export_code_entry *slang_export_code_table_add (slang_export_code_table *self)\r
-{\r
- const GLuint n = self->count;\r
-\r
- self->entries = (slang_export_code_entry *) slang_alloc_realloc (self->entries,\r
- n * sizeof (slang_export_code_entry), (n + 1) * sizeof (slang_export_code_entry));\r
- if (self->entries == NULL)\r
- return NULL;\r
- slang_export_code_entry_ctr (&self->entries[n]);\r
- self->count++;\r
- return &self->entries[n];\r
-}\r
-\r
-/*\r
- * _slang_find_exported_data()\r
- */\r
-\r
-#define EXTRACT_ERROR 0\r
-#define EXTRACT_BASIC 1\r
-#define EXTRACT_ARRAY 2\r
-#define EXTRACT_STRUCT 3\r
-#define EXTRACT_STRUCT_ARRAY 4\r
-\r
-#define EXTRACT_MAXLEN 255\r
-\r
-static GLuint extract_name (const char *name, char *parsed, GLuint *element, const char **end)\r
-{\r
- GLuint i;\r
-\r
- if ((name[0] >= 'a' && name[0] <= 'z') || (name[0] >= 'A' && name[0] <= 'Z') || name[0] == '_')\r
- {\r
- parsed[0] = name[0];\r
-\r
- for (i = 1; i < EXTRACT_MAXLEN; i++)\r
- {\r
- if ((name[i] >= 'a' && name[i] <= 'z') || (name[i] >= 'A' && name[i] <= 'Z') ||\r
- (name[i] >= '0' && name[i] <= '9') || name[0] == '_')\r
- {\r
- parsed[i] = name[i];\r
- }\r
- else\r
- {\r
- if (name[i] == '\0')\r
- {\r
- parsed[i] = '\0';\r
- return EXTRACT_BASIC;\r
- }\r
- if (name[i] == '.')\r
- {\r
- parsed[i] = '\0';\r
- *end = &name[i + 1];\r
- return EXTRACT_STRUCT;\r
- }\r
- if (name[i] == '[')\r
- {\r
- parsed[i] = '\0';\r
- i++;\r
- if (name[i] >= '0' && name[i] <= '9')\r
- {\r
- *element = name[i] - '0';\r
- for (i++; ; i++)\r
- {\r
- if (name[i] >= '0' && name[i] <= '9')\r
- *element = *element * 10 + (name[i] - '0');\r
- else\r
- {\r
- if (name[i] == ']')\r
- {\r
- i++;\r
- if (name[i] == '.')\r
- {\r
- *end = &name[i + 1];\r
- return EXTRACT_STRUCT_ARRAY;\r
- }\r
- *end = &name[i];\r
- return EXTRACT_ARRAY;\r
- }\r
- break;\r
- }\r
- }\r
- }\r
- }\r
- break;\r
- }\r
- }\r
- }\r
- return EXTRACT_ERROR;\r
-}\r
-\r
-static GLboolean validate_extracted (slang_export_data_quant *q, GLuint element, GLuint extr)\r
-{\r
- switch (extr)\r
- {\r
- case EXTRACT_BASIC:\r
- return GL_TRUE;\r
- case EXTRACT_ARRAY:\r
- return element < slang_export_data_quant_elements (q);\r
- case EXTRACT_STRUCT:\r
- return slang_export_data_quant_struct (q);\r
- case EXTRACT_STRUCT_ARRAY:\r
- return slang_export_data_quant_struct (q) && element < slang_export_data_quant_elements (q);\r
- }\r
- return GL_FALSE;\r
-}\r
-\r
-static GLuint calculate_offset (slang_export_data_quant *q, GLuint element)\r
-{\r
- if (slang_export_data_quant_array (q))\r
- return element * slang_export_data_quant_size (q);\r
- return 0;\r
-}\r
-\r
-static GLboolean find_exported_data (slang_export_data_quant *q, const char *name,\r
- slang_export_data_quant **quant, GLuint *offset, slang_atom_pool *atoms)\r
-{\r
- char parsed[EXTRACT_MAXLEN];\r
- GLuint result, element, i;\r
- const char *end;\r
- slang_atom atom;\r
- const GLuint fields = slang_export_data_quant_fields (q);\r
-\r
- result = extract_name (name, parsed, &element, &end);\r
- if (result == EXTRACT_ERROR)\r
- return GL_FALSE;\r
-\r
- atom = slang_atom_pool_atom (atoms, parsed);\r
- if (atom == SLANG_ATOM_NULL)\r
- return GL_FALSE;\r
-\r
- for (i = 0; i < fields; i++)\r
- if (q->structure[i].name == atom)\r
- {\r
- if (!validate_extracted (&q->structure[i], element, result))\r
- return GL_FALSE;\r
- *offset += calculate_offset (&q->structure[i], element);\r
- if (result == EXTRACT_BASIC || result == EXTRACT_ARRAY)\r
- {\r
- if (*end != '\0')\r
- return GL_FALSE;\r
- *quant = &q->structure[i];\r
- return GL_TRUE;\r
- }\r
- return find_exported_data (&q->structure[i], end, quant, offset, atoms);\r
- }\r
- return GL_FALSE;\r
-}\r
-\r
-GLboolean _slang_find_exported_data (slang_export_data_table *table, const char *name,\r
- slang_export_data_entry **entry, slang_export_data_quant **quant, GLuint *offset)\r
-{\r
- char parsed[EXTRACT_MAXLEN];\r
- GLuint result, element, i;\r
- const char *end;\r
- slang_atom atom;\r
-\r
- result = extract_name (name, parsed, &element, &end);\r
- if (result == EXTRACT_ERROR)\r
- return GL_FALSE;\r
-\r
- atom = slang_atom_pool_atom (table->atoms, parsed);\r
- if (atom == SLANG_ATOM_NULL)\r
- return GL_FALSE;\r
-\r
- for (i = 0; i < table->count; i++)\r
- if (table->entries[i].quant.name == atom)\r
- {\r
- if (!validate_extracted (&table->entries[i].quant, element, result))\r
- return GL_FALSE;\r
- *entry = &table->entries[i];\r
- *offset = calculate_offset (&table->entries[i].quant, element);\r
- if (result == EXTRACT_BASIC || result == EXTRACT_ARRAY)\r
- {\r
- if (*end != '\0')\r
- return GL_FALSE;\r
- *quant = &table->entries[i].quant;\r
- return GL_TRUE;\r
- }\r
- return find_exported_data (&table->entries[i].quant, end, quant, offset, table->atoms);\r
- }\r
- return GL_FALSE;\r
-}\r
-\r
+/*
+ * 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_export.c
+ * interface between assembly code and the application
+ * \author Michal Krol
+ */
+
+#include "imports.h"
+#include "slang_export.h"
+
+/*
+ * slang_export_data_quant
+ */
+
+GLvoid slang_export_data_quant_ctr (slang_export_data_quant *self)
+{
+ self->name = SLANG_ATOM_NULL;
+ self->size = 0;
+ self->array_len = 0;
+ self->structure = NULL;
+ self->u.basic_type = GL_FLOAT;
+}
+
+GLvoid slang_export_data_quant_dtr (slang_export_data_quant *self)
+{
+ if (self->structure != NULL)
+ {
+ GLuint i;
+
+ for (i = 0; i < self->u.field_count; i++)
+ slang_export_data_quant_dtr (&self->structure[i]);
+ slang_alloc_free (self->structure);
+ }
+}
+
+slang_export_data_quant *slang_export_data_quant_add_field (slang_export_data_quant *self)
+{
+ const GLuint n = self->u.field_count;
+
+ self->structure = (slang_export_data_quant *) slang_alloc_realloc (self->structure,
+ n * sizeof (slang_export_data_quant), (n + 1) * sizeof (slang_export_data_quant));
+ if (self->structure == NULL)
+ return NULL;
+ slang_export_data_quant_ctr (&self->structure[n]);
+ self->u.field_count++;
+ return &self->structure[n];
+}
+
+GLboolean slang_export_data_quant_array (slang_export_data_quant *self)
+{
+ return self->array_len != 0;
+}
+
+GLboolean slang_export_data_quant_struct (slang_export_data_quant *self)
+{
+ return self->structure != NULL;
+}
+
+GLboolean slang_export_data_quant_simple (slang_export_data_quant *self)
+{
+ return self->array_len == 0 && self->structure == NULL;
+}
+
+GLenum slang_export_data_quant_type (slang_export_data_quant *self)
+{
+ assert (self->structure == NULL);
+ return self->u.basic_type;
+}
+
+GLuint slang_export_data_quant_fields (slang_export_data_quant *self)
+{
+ assert (self->structure != NULL);
+ return self->u.field_count;
+}
+
+GLuint slang_export_data_quant_elements (slang_export_data_quant *self)
+{
+ if (self->array_len == 0)
+ return 1;
+ return self->array_len;
+}
+
+GLuint slang_export_data_quant_components (slang_export_data_quant *self)
+{
+ return self->size / 4;
+}
+
+GLuint slang_export_data_quant_size (slang_export_data_quant *self)
+{
+ return self->size;
+}
+
+/*
+ * slang_export_data_entry
+ */
+
+GLvoid slang_export_data_entry_ctr (slang_export_data_entry *self)
+{
+ slang_export_data_quant_ctr (&self->quant);
+ self->access = slang_exp_uniform;
+ self->address = ~0;
+}
+
+GLvoid slang_export_data_entry_dtr (slang_export_data_entry *self)
+{
+ slang_export_data_quant_dtr (&self->quant);
+}
+
+/*
+ * slang_export_data_table
+ */
+
+GLvoid slang_export_data_table_ctr (slang_export_data_table *self)
+{
+ self->entries = NULL;
+ self->count = 0;
+ self->atoms = NULL;
+}
+
+GLvoid slang_export_data_table_dtr (slang_export_data_table *self)
+{
+ if (self->entries != NULL)
+ {
+ GLuint i;
+
+ for (i = 0; i < self->count; i++)
+ slang_export_data_entry_dtr (&self->entries[i]);
+ slang_alloc_free (self->entries);
+ }
+}
+
+slang_export_data_entry *slang_export_data_table_add (slang_export_data_table *self)
+{
+ const GLuint n = self->count;
+
+ self->entries = (slang_export_data_entry *) slang_alloc_realloc (self->entries,
+ n * sizeof (slang_export_data_entry), (n + 1) * sizeof (slang_export_data_entry));
+ if (self->entries == NULL)
+ return NULL;
+ slang_export_data_entry_ctr (&self->entries[n]);
+ self->count++;
+ return &self->entries[n];
+}
+
+/*
+ * slang_export_code_entry
+ */
+
+static GLvoid slang_export_code_entry_ctr (slang_export_code_entry *self)
+{
+ self->name = SLANG_ATOM_NULL;
+ self->address = ~0;
+}
+
+static GLvoid slang_export_code_entry_dtr (slang_export_code_entry *self)
+{
+}
+
+/*
+ * slang_export_code_table
+ */
+
+GLvoid slang_export_code_table_ctr (slang_export_code_table *self)
+{
+ self->entries = NULL;
+ self->count = 0;
+ self->atoms = NULL;
+}
+
+GLvoid slang_export_code_table_dtr (slang_export_code_table *self)
+{
+ if (self->entries != NULL)
+ {
+ GLuint i;
+
+ for (i = 0; i < self->count; i++)
+ slang_export_code_entry_dtr (&self->entries[i]);
+ slang_alloc_free (self->entries);
+ }
+}
+
+slang_export_code_entry *slang_export_code_table_add (slang_export_code_table *self)
+{
+ const GLuint n = self->count;
+
+ self->entries = (slang_export_code_entry *) slang_alloc_realloc (self->entries,
+ n * sizeof (slang_export_code_entry), (n + 1) * sizeof (slang_export_code_entry));
+ if (self->entries == NULL)
+ return NULL;
+ slang_export_code_entry_ctr (&self->entries[n]);
+ self->count++;
+ return &self->entries[n];
+}
+
+/*
+ * _slang_find_exported_data()
+ */
+
+#define EXTRACT_ERROR 0
+#define EXTRACT_BASIC 1
+#define EXTRACT_ARRAY 2
+#define EXTRACT_STRUCT 3
+#define EXTRACT_STRUCT_ARRAY 4
+
+#define EXTRACT_MAXLEN 255
+
+static GLuint extract_name (const char *name, char *parsed, GLuint *element, const char **end)
+{
+ GLuint i;
+
+ if ((name[0] >= 'a' && name[0] <= 'z') || (name[0] >= 'A' && name[0] <= 'Z') || name[0] == '_')
+ {
+ parsed[0] = name[0];
+
+ for (i = 1; i < EXTRACT_MAXLEN; i++)
+ {
+ if ((name[i] >= 'a' && name[i] <= 'z') || (name[i] >= 'A' && name[i] <= 'Z') ||
+ (name[i] >= '0' && name[i] <= '9') || name[0] == '_')
+ {
+ parsed[i] = name[i];
+ }
+ else
+ {
+ if (name[i] == '\0')
+ {
+ parsed[i] = '\0';
+ return EXTRACT_BASIC;
+ }
+ if (name[i] == '.')
+ {
+ parsed[i] = '\0';
+ *end = &name[i + 1];
+ return EXTRACT_STRUCT;
+ }
+ if (name[i] == '[')
+ {
+ parsed[i] = '\0';
+ i++;
+ if (name[i] >= '0' && name[i] <= '9')
+ {
+ *element = name[i] - '0';
+ for (i++; ; i++)
+ {
+ if (name[i] >= '0' && name[i] <= '9')
+ *element = *element * 10 + (name[i] - '0');
+ else
+ {
+ if (name[i] == ']')
+ {
+ i++;
+ if (name[i] == '.')
+ {
+ *end = &name[i + 1];
+ return EXTRACT_STRUCT_ARRAY;
+ }
+ *end = &name[i];
+ return EXTRACT_ARRAY;
+ }
+ break;
+ }
+ }
+ }
+ }
+ break;
+ }
+ }
+ }
+ return EXTRACT_ERROR;
+}
+
+static GLboolean validate_extracted (slang_export_data_quant *q, GLuint element, GLuint extr)
+{
+ switch (extr)
+ {
+ case EXTRACT_BASIC:
+ return GL_TRUE;
+ case EXTRACT_ARRAY:
+ return element < slang_export_data_quant_elements (q);
+ case EXTRACT_STRUCT:
+ return slang_export_data_quant_struct (q);
+ case EXTRACT_STRUCT_ARRAY:
+ return slang_export_data_quant_struct (q) && element < slang_export_data_quant_elements (q);
+ }
+ return GL_FALSE;
+}
+
+static GLuint calculate_offset (slang_export_data_quant *q, GLuint element)
+{
+ if (slang_export_data_quant_array (q))
+ return element * slang_export_data_quant_size (q);
+ return 0;
+}
+
+static GLboolean find_exported_data (slang_export_data_quant *q, const char *name,
+ slang_export_data_quant **quant, GLuint *offset, slang_atom_pool *atoms)
+{
+ char parsed[EXTRACT_MAXLEN];
+ GLuint result, element, i;
+ const char *end;
+ slang_atom atom;
+ const GLuint fields = slang_export_data_quant_fields (q);
+
+ result = extract_name (name, parsed, &element, &end);
+ if (result == EXTRACT_ERROR)
+ return GL_FALSE;
+
+ atom = slang_atom_pool_atom (atoms, parsed);
+ if (atom == SLANG_ATOM_NULL)
+ return GL_FALSE;
+
+ for (i = 0; i < fields; i++)
+ if (q->structure[i].name == atom)
+ {
+ if (!validate_extracted (&q->structure[i], element, result))
+ return GL_FALSE;
+ *offset += calculate_offset (&q->structure[i], element);
+ if (result == EXTRACT_BASIC || result == EXTRACT_ARRAY)
+ {
+ if (*end != '\0')
+ return GL_FALSE;
+ *quant = &q->structure[i];
+ return GL_TRUE;
+ }
+ return find_exported_data (&q->structure[i], end, quant, offset, atoms);
+ }
+ return GL_FALSE;
+}
+
+GLboolean _slang_find_exported_data (slang_export_data_table *table, const char *name,
+ slang_export_data_entry **entry, slang_export_data_quant **quant, GLuint *offset)
+{
+ char parsed[EXTRACT_MAXLEN];
+ GLuint result, element, i;
+ const char *end;
+ slang_atom atom;
+
+ result = extract_name (name, parsed, &element, &end);
+ if (result == EXTRACT_ERROR)
+ return GL_FALSE;
+
+ atom = slang_atom_pool_atom (table->atoms, parsed);
+ if (atom == SLANG_ATOM_NULL)
+ return GL_FALSE;
+
+ for (i = 0; i < table->count; i++)
+ if (table->entries[i].quant.name == atom)
+ {
+ if (!validate_extracted (&table->entries[i].quant, element, result))
+ return GL_FALSE;
+ *entry = &table->entries[i];
+ *offset = calculate_offset (&table->entries[i].quant, element);
+ if (result == EXTRACT_BASIC || result == EXTRACT_ARRAY)
+ {
+ if (*end != '\0')
+ return GL_FALSE;
+ *quant = &table->entries[i].quant;
+ return GL_TRUE;
+ }
+ return find_exported_data (&table->entries[i].quant, end, quant, offset, table->atoms);
+ }
+ return GL_FALSE;
+}
+
-/*\r
- * Mesa 3-D graphics library\r
- * Version: 6.5\r
- *\r
- * Copyright (C) 2006 Brian Paul All Rights Reserved.\r
- *\r
- * Permission is hereby granted, free of charge, to any person obtaining a\r
- * copy of this software and associated documentation files (the "Software"),\r
- * to deal in the Software without restriction, including without limitation\r
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
- * and/or sell copies of the Software, and to permit persons to whom the\r
- * Software is furnished to do so, subject to the following conditions:\r
- *\r
- * The above copyright notice and this permission notice shall be included\r
- * in all copies or substantial portions of the Software.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\r
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
- */\r
-\r
-#if !defined SLANG_EXPORT_H\r
-#define SLANG_EXPORT_H\r
-\r
-#include "slang_utility.h"\r
-\r
-#if defined __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-/*\r
- * Basic data quantity to transfer between application and assembly.\r
- * The <size> is the actual size of the data quantity including padding, if any. It is\r
- * used to calculate offsets from the beginning of the data.\r
- * If the <array_len> is not 0, the data quantity is an array of <array_len> size.\r
- * If the <structure> is not NULL, the data quantity is a struct. The <basic_type> is\r
- * invalid and the <field_count> holds the size of the <structure> array.\r
- * The <basic_type> values match those of <type> parameter for glGetActiveUniformARB.\r
- */\r
-\r
-typedef struct slang_export_data_quant_\r
-{\r
- slang_atom name;\r
- GLuint size;\r
- GLuint array_len;\r
- struct slang_export_data_quant_ *structure;\r
- union\r
- {\r
- GLenum basic_type;\r
- GLuint field_count;\r
- } u;\r
-} slang_export_data_quant;\r
-\r
-GLvoid slang_export_data_quant_ctr (slang_export_data_quant *);\r
-GLvoid slang_export_data_quant_dtr (slang_export_data_quant *);\r
-slang_export_data_quant *slang_export_data_quant_add_field (slang_export_data_quant *);\r
-\r
-/*\r
- * Returns GL_FALSE if the quant is not an array.\r
- */\r
-GLboolean slang_export_data_quant_array (slang_export_data_quant *);\r
-\r
-/*\r
- * Returns GL_FALSE if the quant is not a structure.\r
- */\r
-GLboolean slang_export_data_quant_struct (slang_export_data_quant *);\r
-\r
-/*\r
- * Returns GL_TRUE if the quant is neither an array nor a structure.\r
- */\r
-GLboolean slang_export_data_quant_simple (slang_export_data_quant *);\r
-\r
-/*\r
- * Returns basic type of the quant. It must not be a structure.\r
- */\r
-GLenum slang_export_data_quant_type (slang_export_data_quant *);\r
-\r
-/*\r
- * Returns number of fields in the quant that is a structure.\r
- */\r
-GLuint slang_export_data_quant_fields (slang_export_data_quant *);\r
-\r
-/*\r
- * Return number of elements in the quant.\r
- * For arrays, return the size of the array.\r
- * Otherwise, return 1.\r
- */\r
-GLuint slang_export_data_quant_elements (slang_export_data_quant *);\r
-\r
-/*\r
- * Returns total number of components withing the quant element.\r
- */\r
-GLuint slang_export_data_quant_components (slang_export_data_quant *);\r
-\r
-/*\r
- * Returns size of the quant element.\r
- */\r
-GLuint slang_export_data_quant_size (slang_export_data_quant *);\r
-\r
-/*\r
- * Data access pattern. Specifies how data is accessed at what frequency.\r
- */\r
-\r
-typedef enum\r
-{\r
- slang_exp_uniform,\r
- slang_exp_varying,\r
- slang_exp_attribute\r
-} slang_export_data_access;\r
-\r
-/*\r
- * Data export entry. Holds the data type information, access pattern and base address.\r
- */\r
-\r
-typedef struct\r
-{\r
- slang_export_data_quant quant;\r
- slang_export_data_access access;\r
- GLuint address;\r
-} slang_export_data_entry;\r
-\r
-GLvoid slang_export_data_entry_ctr (slang_export_data_entry *);\r
-GLvoid slang_export_data_entry_dtr (slang_export_data_entry *);\r
-\r
-/*\r
- * Data export table.\r
- */\r
-\r
-typedef struct\r
-{\r
- slang_export_data_entry *entries;\r
- GLuint count;\r
- slang_atom_pool *atoms;\r
-} slang_export_data_table;\r
-\r
-GLvoid slang_export_data_table_ctr (slang_export_data_table *);\r
-GLvoid slang_export_data_table_dtr (slang_export_data_table *);\r
-slang_export_data_entry *slang_export_data_table_add (slang_export_data_table *);\r
-\r
-/*\r
- * Code export entry. Contains label name and its entry point (label, address).\r
- */\r
-\r
-typedef struct\r
-{\r
- slang_atom name;\r
- GLuint address;\r
-} slang_export_code_entry;\r
-\r
-/*\r
- * Code export table.\r
- */\r
-\r
-typedef struct\r
-{\r
- slang_export_code_entry *entries;\r
- GLuint count;\r
- slang_atom_pool *atoms;\r
-} slang_export_code_table;\r
-\r
-GLvoid slang_export_code_table_ctr (slang_export_code_table *);\r
-GLvoid slang_export_code_table_dtr (slang_export_code_table *);\r
-slang_export_code_entry *slang_export_code_table_add (slang_export_code_table *);\r
-\r
-/*\r
- * _slang_find_exported_data()\r
- *\r
- * Parses the name string and returns corresponding data entry, data quantity and offset.\r
- * Returns GL_TRUE if the data is found, returns GL_FALSE otherwise.\r
- */\r
-\r
-GLboolean _slang_find_exported_data (slang_export_data_table *, const char *,\r
- slang_export_data_entry **, slang_export_data_quant **, GLuint *);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif\r
-\r
+/*
+ * 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_EXPORT_H
+#define SLANG_EXPORT_H
+
+#include "slang_utility.h"
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Basic data quantity to transfer between application and assembly.
+ * The <size> is the actual size of the data quantity including padding, if any. It is
+ * used to calculate offsets from the beginning of the data.
+ * If the <array_len> is not 0, the data quantity is an array of <array_len> size.
+ * If the <structure> is not NULL, the data quantity is a struct. The <basic_type> is
+ * invalid and the <field_count> holds the size of the <structure> array.
+ * The <basic_type> values match those of <type> parameter for glGetActiveUniformARB.
+ */
+
+typedef struct slang_export_data_quant_
+{
+ slang_atom name;
+ GLuint size;
+ GLuint array_len;
+ struct slang_export_data_quant_ *structure;
+ union
+ {
+ GLenum basic_type;
+ GLuint field_count;
+ } u;
+} slang_export_data_quant;
+
+GLvoid slang_export_data_quant_ctr (slang_export_data_quant *);
+GLvoid slang_export_data_quant_dtr (slang_export_data_quant *);
+slang_export_data_quant *slang_export_data_quant_add_field (slang_export_data_quant *);
+
+/*
+ * Returns GL_FALSE if the quant is not an array.
+ */
+GLboolean slang_export_data_quant_array (slang_export_data_quant *);
+
+/*
+ * Returns GL_FALSE if the quant is not a structure.
+ */
+GLboolean slang_export_data_quant_struct (slang_export_data_quant *);
+
+/*
+ * Returns GL_TRUE if the quant is neither an array nor a structure.
+ */
+GLboolean slang_export_data_quant_simple (slang_export_data_quant *);
+
+/*
+ * Returns basic type of the quant. It must not be a structure.
+ */
+GLenum slang_export_data_quant_type (slang_export_data_quant *);
+
+/*
+ * Returns number of fields in the quant that is a structure.
+ */
+GLuint slang_export_data_quant_fields (slang_export_data_quant *);
+
+/*
+ * Return number of elements in the quant.
+ * For arrays, return the size of the array.
+ * Otherwise, return 1.
+ */
+GLuint slang_export_data_quant_elements (slang_export_data_quant *);
+
+/*
+ * Returns total number of components withing the quant element.
+ */
+GLuint slang_export_data_quant_components (slang_export_data_quant *);
+
+/*
+ * Returns size of the quant element.
+ */
+GLuint slang_export_data_quant_size (slang_export_data_quant *);
+
+/*
+ * Data access pattern. Specifies how data is accessed at what frequency.
+ */
+
+typedef enum
+{
+ slang_exp_uniform,
+ slang_exp_varying,
+ slang_exp_attribute
+} slang_export_data_access;
+
+/*
+ * Data export entry. Holds the data type information, access pattern and base address.
+ */
+
+typedef struct
+{
+ slang_export_data_quant quant;
+ slang_export_data_access access;
+ GLuint address;
+} slang_export_data_entry;
+
+GLvoid slang_export_data_entry_ctr (slang_export_data_entry *);
+GLvoid slang_export_data_entry_dtr (slang_export_data_entry *);
+
+/*
+ * Data export table.
+ */
+
+typedef struct
+{
+ slang_export_data_entry *entries;
+ GLuint count;
+ slang_atom_pool *atoms;
+} slang_export_data_table;
+
+GLvoid slang_export_data_table_ctr (slang_export_data_table *);
+GLvoid slang_export_data_table_dtr (slang_export_data_table *);
+slang_export_data_entry *slang_export_data_table_add (slang_export_data_table *);
+
+/*
+ * Code export entry. Contains label name and its entry point (label, address).
+ */
+
+typedef struct
+{
+ slang_atom name;
+ GLuint address;
+} slang_export_code_entry;
+
+/*
+ * Code export table.
+ */
+
+typedef struct
+{
+ slang_export_code_entry *entries;
+ GLuint count;
+ slang_atom_pool *atoms;
+} slang_export_code_table;
+
+GLvoid slang_export_code_table_ctr (slang_export_code_table *);
+GLvoid slang_export_code_table_dtr (slang_export_code_table *);
+slang_export_code_entry *slang_export_code_table_add (slang_export_code_table *);
+
+/*
+ * _slang_find_exported_data()
+ *
+ * Parses the name string and returns corresponding data entry, data quantity and offset.
+ * Returns GL_TRUE if the data is found, returns GL_FALSE otherwise.
+ */
+
+GLboolean _slang_find_exported_data (slang_export_data_table *, const char *,
+ slang_export_data_entry **, slang_export_data_quant **, GLuint *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
-/*\r
- * Mesa 3-D graphics library\r
- * Version: 6.5\r
- *\r
- * Copyright (C) 2006 Brian Paul All Rights Reserved.\r
- *\r
- * Permission is hereby granted, free of charge, to any person obtaining a\r
- * copy of this software and associated documentation files (the "Software"),\r
- * to deal in the Software without restriction, including without limitation\r
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
- * and/or sell copies of the Software, and to permit persons to whom the\r
- * Software is furnished to do so, subject to the following conditions:\r
- *\r
- * The above copyright notice and this permission notice shall be included\r
- * in all copies or substantial portions of the Software.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\r
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
- */\r
-\r
-/**\r
- * \file slang_link.c\r
- * slang linker\r
- * \author Michal Krol\r
- */\r
-\r
-#include "imports.h"\r
-#include "slang_link.h"\r
-#include "slang_analyse.h"\r
-\r
-static GLboolean entry_has_gl_prefix (slang_atom name, slang_atom_pool *atoms)\r
-{\r
- const char *str = slang_atom_pool_id (atoms, name);\r
- return str[0] == 'g' && str[1] == 'l' && str[2] == '_';\r
-}\r
-\r
-/*\r
- * slang_active_variables\r
- */\r
-\r
-static GLvoid slang_active_variables_ctr (slang_active_variables *self)\r
-{\r
- self->table = NULL;\r
- self->count = 0;\r
-}\r
-\r
-static GLvoid slang_active_variables_dtr (slang_active_variables *self)\r
-{\r
- GLuint i;\r
-\r
- for (i = 0; i < self->count; i++)\r
- slang_alloc_free (self->table[i].name);\r
- slang_alloc_free (self->table);\r
-}\r
-\r
-static GLboolean add_simple_variable (slang_active_variables *self, slang_export_data_quant *q,\r
- const char *name)\r
-{\r
- const GLuint n = self->count;\r
-\r
- self->table = (slang_active_variable *) slang_alloc_realloc (self->table,\r
- n * sizeof (slang_active_variable), (n + 1) * sizeof (slang_active_variable));\r
- if (self->table == NULL)\r
- return GL_FALSE;\r
-\r
- self->table[n].quant = q;\r
- self->table[n].name = slang_string_duplicate (name);\r
- if (self->table[n].name == NULL)\r
- return GL_FALSE;\r
- self->count++;\r
-\r
- return GL_TRUE;\r
-}\r
-\r
-static GLboolean add_complex_variable (slang_active_variables *self, slang_export_data_quant *q,\r
- char *name, slang_atom_pool *atoms)\r
-{\r
- slang_string_concat (name, slang_atom_pool_id (atoms, q->name));\r
- if (slang_export_data_quant_array (q))\r
- slang_string_concat (name, "[0]");\r
-\r
- if (slang_export_data_quant_struct (q))\r
- {\r
- GLuint dot_pos, i;\r
- const GLuint fields = slang_export_data_quant_fields (q);\r
-\r
- slang_string_concat (name, ".");\r
- dot_pos = slang_string_length (name);\r
-\r
- for (i = 0; i < fields; i++)\r
- {\r
- if (!add_complex_variable (self, &q->structure[i], name, atoms))\r
- return GL_FALSE;\r
-\r
- name[dot_pos] = '\0';\r
- }\r
-\r
- return GL_TRUE;\r
- }\r
-\r
- return add_simple_variable (self, q, name);\r
-}\r
-\r
-static GLboolean gather_active_variables (slang_active_variables *self,\r
- slang_export_data_table *tbl, slang_export_data_access access)\r
-{\r
- GLuint i;\r
-\r
- for (i = 0; i < tbl->count; i++)\r
- if (tbl->entries[i].access == access)\r
- {\r
- char name[1024] = "";\r
-\r
- if (!add_complex_variable (self, &tbl->entries[i].quant, name, tbl->atoms))\r
- return GL_FALSE;\r
- }\r
-\r
- return GL_TRUE;\r
-}\r
-\r
-/*\r
- * slang_attrib_overrides\r
- */\r
-\r
-static GLvoid slang_attrib_overrides_ctr (slang_attrib_overrides *self)\r
-{\r
- self->table = NULL;\r
- self->count = 0;\r
-}\r
-\r
-static GLvoid slang_attrib_overrides_dtr (slang_attrib_overrides *self)\r
-{\r
- GLuint i;\r
-\r
- for (i = 0; i < self->count; i++)\r
- slang_alloc_free (self->table[i].name);\r
- slang_alloc_free (self->table);\r
-}\r
-\r
-GLboolean slang_attrib_overrides_add (slang_attrib_overrides *self, GLuint index, const GLchar *name)\r
-{\r
- const GLuint n = self->count;\r
- GLuint i;\r
-\r
- for (i = 0; i < n; i++)\r
- if (slang_string_compare (name, self->table[i].name) == 0)\r
- {\r
- self->table[i].index = index;\r
- return GL_TRUE;\r
- }\r
-\r
- self->table = (slang_attrib_override *) slang_alloc_realloc (self->table,\r
- n * sizeof (slang_attrib_override), (n + 1) * sizeof (slang_attrib_override));\r
- if (self->table == NULL)\r
- return GL_FALSE;\r
-\r
- self->table[n].index = index;\r
- self->table[n].name = slang_string_duplicate (name);\r
- if (self->table[n].name == NULL)\r
- return GL_FALSE;\r
- self->count++;\r
-\r
- return GL_TRUE;\r
-}\r
-\r
-static GLuint lookup_attrib_override (slang_attrib_overrides *self, const GLchar *name)\r
-{\r
- GLuint i;\r
-\r
- for (i = 0; self->count; i++)\r
- if (slang_string_compare (name, self->table[i].name) == 0)\r
- return self->table[i].index;\r
- return MAX_VERTEX_ATTRIBS;\r
-}\r
-\r
-/*\r
- * slang_uniform_bindings\r
- */\r
-\r
-static GLvoid slang_uniform_bindings_ctr (slang_uniform_bindings *self)\r
-{\r
- self->table = NULL;\r
- self->count = 0;\r
-}\r
-\r
-static GLvoid slang_uniform_bindings_dtr (slang_uniform_bindings *self)\r
-{\r
- GLuint i;\r
-\r
- for (i = 0; i < self->count; i++)\r
- slang_alloc_free (self->table[i].name);\r
- slang_alloc_free (self->table);\r
-}\r
-\r
-static GLboolean add_simple_uniform_binding (slang_uniform_bindings *self,\r
- slang_export_data_quant *q, const char *name, GLuint index, GLuint addr)\r
-{\r
- const GLuint n = self->count;\r
- GLuint i;\r
-\r
- for (i = 0; i < n; i++)\r
- if (slang_string_compare (self->table[i].name, name) == 0)\r
- {\r
- self->table[i].address[index] = addr;\r
- return GL_TRUE;\r
- }\r
-\r
- self->table = (slang_uniform_binding *) slang_alloc_realloc (self->table,\r
- n * sizeof (slang_uniform_binding), (n + 1) * sizeof (slang_uniform_binding));\r
- if (self->table == NULL)\r
- return GL_FALSE;\r
-\r
- self->table[n].quant = q;\r
- self->table[n].name = slang_string_duplicate (name);\r
- if (self->table[n].name == NULL)\r
- return GL_FALSE;\r
- for (i = 0; i < SLANG_SHADER_MAX; i++)\r
- self->table[n].address[i] = ~0;\r
- self->table[n].address[index] = addr;\r
- self->count++;\r
-\r
- return GL_TRUE;\r
-}\r
-\r
-static GLboolean add_complex_uniform_binding (slang_uniform_bindings *self,\r
- slang_export_data_quant *q, char *name, slang_atom_pool *atoms, GLuint index, GLuint addr)\r
-{\r
- GLuint count, i;\r
-\r
- slang_string_concat (name, slang_atom_pool_id (atoms, q->name));\r
- count = slang_export_data_quant_elements (q);\r
- for (i = 0; i < count; i++)\r
- {\r
- GLuint bracket_pos;\r
-\r
- bracket_pos = slang_string_length (name);\r
- if (slang_export_data_quant_array (q))\r
- _mesa_sprintf (name + slang_string_length (name), "[%d]", i);\r
-\r
- if (slang_export_data_quant_struct (q))\r
- {\r
- GLuint dot_pos, i;\r
- const GLuint fields = slang_export_data_quant_fields (q);\r
-\r
- slang_string_concat (name, ".");\r
- dot_pos = slang_string_length (name);\r
-\r
- for (i = 0; i < fields; i++)\r
- {\r
- if (!add_complex_uniform_binding (self, &q->structure[i], name, atoms, index, addr))\r
- return GL_FALSE;\r
-\r
- name[dot_pos] = '\0';\r
- addr += slang_export_data_quant_size (&q->structure[i]);\r
- }\r
- }\r
- else\r
- {\r
- if (!add_simple_uniform_binding (self, q, name, index, addr))\r
- return GL_FALSE;\r
-\r
- addr += slang_export_data_quant_size (q);\r
- }\r
-\r
- name[bracket_pos] = '\0';\r
- }\r
-\r
- return GL_TRUE;\r
-}\r
-\r
-static GLboolean gather_uniform_bindings (slang_uniform_bindings *self,\r
- slang_export_data_table *tbl, GLuint index)\r
-{\r
- GLuint i;\r
-\r
- for (i = 0; i < tbl->count; i++)\r
- if (tbl->entries[i].access == slang_exp_uniform)\r
- {\r
- char name[1024] = "";\r
-\r
- if (!add_complex_uniform_binding (self, &tbl->entries[i].quant, name, tbl->atoms, index,\r
- tbl->entries[i].address))\r
- return GL_FALSE;\r
- }\r
-\r
- return GL_TRUE;\r
-}\r
-\r
-/*\r
- * slang_attrib_bindings\r
- */\r
-\r
-static GLvoid slang_attrib_bindings_ctr (slang_attrib_bindings *self)\r
-{\r
- GLuint i;\r
-\r
- self->binding_count = 0;\r
- for (i = 0; i < MAX_VERTEX_ATTRIBS; i++)\r
- self->slots[i].addr = ~0;\r
-}\r
-\r
-static GLvoid slang_attrib_bindings_dtr (slang_attrib_bindings *self)\r
-{\r
- GLuint i;\r
-\r
- for (i = 0; i < self->binding_count; i++)\r
- slang_alloc_free (self->bindings[i].name);\r
-}\r
-\r
-static GLuint can_allocate_attrib_slots (slang_attrib_bindings *self, GLuint index, GLuint count)\r
-{\r
- GLuint i;\r
-\r
- for (i = 0; i < count; i++)\r
- if (self->slots[index + i].addr != ~0)\r
- break;\r
- return i;\r
-}\r
-\r
-static GLuint allocate_attrib_slots (slang_attrib_bindings *self, GLuint count)\r
-{\r
- GLuint i;\r
-\r
- for (i = 0; i <= MAX_VERTEX_ATTRIBS - count; i++)\r
- {\r
- GLuint size;\r
- \r
- size = can_allocate_attrib_slots (self, i, count);\r
- if (size == count)\r
- return i;\r
-\r
- /* speed-up the search a bit */\r
- i += count;\r
- }\r
- return MAX_VERTEX_ATTRIBS;\r
-}\r
-\r
-static GLboolean add_attrib_binding (slang_attrib_bindings *self, slang_export_data_quant *q,\r
- const char *name, GLuint addr, GLuint index_override)\r
-{\r
- const GLuint n = self->binding_count;\r
- GLuint slot_span, slot_index;\r
- GLuint i;\r
-\r
- assert (slang_export_data_quant_simple (q));\r
-\r
- switch (slang_export_data_quant_type (q))\r
- {\r
- case GL_FLOAT:\r
- case GL_FLOAT_VEC2:\r
- case GL_FLOAT_VEC3:\r
- case GL_FLOAT_VEC4:\r
- slot_span = 1;\r
- break;\r
- case GL_FLOAT_MAT2:\r
- slot_span = 2;\r
- break;\r
- case GL_FLOAT_MAT3:\r
- slot_span = 3;\r
- break;\r
- case GL_FLOAT_MAT4:\r
- slot_span = 4;\r
- break;\r
- default:\r
- assert (0);\r
- }\r
-\r
- if (index_override == MAX_VERTEX_ATTRIBS)\r
- slot_index = allocate_attrib_slots (self, slot_span);\r
- else if (can_allocate_attrib_slots (self, index_override, slot_span) == slot_span)\r
- slot_index = index_override;\r
- else\r
- slot_index = MAX_VERTEX_ATTRIBS;\r
- \r
- if (slot_index == MAX_VERTEX_ATTRIBS)\r
- {\r
- /* TODO: info log: error: MAX_VERTEX_ATTRIBS exceeded */\r
- return GL_FALSE;\r
- }\r
-\r
- self->bindings[n].quant = q;\r
- self->bindings[n].name = slang_string_duplicate (name);\r
- if (self->bindings[n].name == NULL)\r
- return GL_FALSE;\r
- self->bindings[n].first_slot_index = slot_index;\r
- self->binding_count++;\r
-\r
- for (i = 0; i < slot_span; i++)\r
- self->slots[self->bindings[n].first_slot_index + i].addr = addr + i * 4;\r
-\r
- return GL_TRUE;\r
-}\r
-\r
-static GLboolean gather_attrib_bindings (slang_attrib_bindings *self, slang_export_data_table *tbl,\r
- slang_attrib_overrides *ovr)\r
-{\r
- GLuint i;\r
-\r
- /* First pass. Gather attribs that have overriden index slots. */\r
- for (i = 0; i < tbl->count; i++)\r
- if (tbl->entries[i].access == slang_exp_attribute &&\r
- !entry_has_gl_prefix (tbl->entries[i].quant.name, tbl->atoms))\r
- {\r
- slang_export_data_quant *quant = &tbl->entries[i].quant;\r
- const GLchar *id = slang_atom_pool_id (tbl->atoms, quant->name);\r
- GLuint index = lookup_attrib_override (ovr, id);\r
-\r
- if (index != MAX_VERTEX_ATTRIBS)\r
- {\r
- if (!add_attrib_binding (self, quant, id, tbl->entries[i].address, index))\r
- return GL_FALSE;\r
- }\r
- }\r
-\r
- /* Second pass. Gather attribs that have *NOT* overriden index slots. */\r
- for (i = 0; i < tbl->count; i++)\r
- if (tbl->entries[i].access == slang_exp_attribute &&\r
- !entry_has_gl_prefix (tbl->entries[i].quant.name, tbl->atoms))\r
- {\r
- slang_export_data_quant *quant = &tbl->entries[i].quant;\r
- const GLchar *id = slang_atom_pool_id (tbl->atoms, quant->name);\r
- GLuint index = lookup_attrib_override (ovr, id);\r
-\r
- if (index == MAX_VERTEX_ATTRIBS)\r
- {\r
- if (!add_attrib_binding (self, quant, id, tbl->entries[i].address, index))\r
- return GL_FALSE;\r
- }\r
- }\r
-\r
- return GL_TRUE;\r
-}\r
-\r
-/*\r
- * slang_varying_bindings\r
- */\r
-\r
-static GLvoid slang_varying_bindings_ctr (slang_varying_bindings *self)\r
-{\r
- self->binding_count = 0;\r
- self->slot_count = 0;\r
-}\r
-\r
-static GLvoid slang_varying_bindings_dtr (slang_varying_bindings *self)\r
-{\r
- GLuint i;\r
-\r
- for (i = 0; i < self->binding_count; i++)\r
- slang_alloc_free (self->bindings[i].name);\r
-}\r
-\r
-static GLvoid update_varying_slots (slang_varying_slot *slots, GLuint count, GLboolean is_vert,\r
- GLuint addr, GLuint do_offset)\r
-{\r
- GLuint i;\r
-\r
- for (i = 0; i < count; i++)\r
- *(is_vert ? &slots[i].vert_addr : &slots[i].frag_addr) = addr + i * 4 * do_offset;\r
-}\r
-\r
-static GLboolean add_varying_binding (slang_varying_bindings *self,\r
- slang_export_data_quant *q, const char *name, GLboolean is_vert, GLuint addr)\r
-{\r
- const GLuint n = self->binding_count;\r
- const GLuint slot_span =\r
- slang_export_data_quant_components (q) * slang_export_data_quant_elements (q);\r
- GLuint i;\r
-\r
- for (i = 0; i < n; i++)\r
- if (slang_string_compare (self->bindings[i].name, name) == 0)\r
- {\r
- /* TODO: data quantities must match, or else link fails */\r
- update_varying_slots (&self->slots[self->bindings[i].first_slot_index], slot_span,\r
- is_vert, addr, 1);\r
- return GL_TRUE;\r
- }\r
-\r
- if (self->slot_count + slot_span > MAX_VARYING_FLOATS)\r
- {\r
- /* TODO: info log: error: MAX_VARYING_FLOATS exceeded */\r
- return GL_FALSE;\r
- }\r
-\r
- self->bindings[n].quant = q;\r
- self->bindings[n].name = slang_string_duplicate (name);\r
- if (self->bindings[n].name == NULL)\r
- return GL_FALSE;\r
- self->bindings[n].first_slot_index = self->slot_count;\r
- self->binding_count++;\r
-\r
- update_varying_slots (&self->slots[self->bindings[n].first_slot_index], slot_span, is_vert,\r
- addr, 1);\r
- update_varying_slots (&self->slots[self->bindings[n].first_slot_index], slot_span, !is_vert,\r
- ~0, 0);\r
- self->slot_count += slot_span;\r
-\r
- return GL_TRUE;\r
-}\r
-\r
-static GLboolean gather_varying_bindings (slang_varying_bindings *self,\r
- slang_export_data_table *tbl, GLboolean is_vert)\r
-{\r
- GLuint i;\r
-\r
- for (i = 0; i < tbl->count; i++)\r
- if (tbl->entries[i].access == slang_exp_varying &&\r
- !entry_has_gl_prefix (tbl->entries[i].quant.name, tbl->atoms))\r
- {\r
- if (!add_varying_binding (self, &tbl->entries[i].quant, slang_atom_pool_id (tbl->atoms,\r
- tbl->entries[i].quant.name), is_vert, tbl->entries[i].address))\r
- return GL_FALSE;\r
- }\r
-\r
- return GL_TRUE;\r
-}\r
-\r
-/*\r
- * slang_texture_bindings\r
- */\r
-\r
-GLvoid slang_texture_usages_ctr (slang_texture_usages *self)\r
-{\r
- self->table = NULL;\r
- self->count = 0;\r
-}\r
-\r
-GLvoid slang_texture_usages_dtr (slang_texture_usages *self)\r
-{\r
- slang_alloc_free (self->table);\r
-}\r
-\r
-/*\r
- * slang_program\r
- */\r
-\r
-GLvoid slang_program_ctr (slang_program *self)\r
-{\r
- GLuint i;\r
-\r
- slang_active_variables_ctr (&self->active_uniforms);\r
- slang_active_variables_ctr (&self->active_attribs);\r
- slang_attrib_overrides_ctr (&self->attrib_overrides);\r
- slang_uniform_bindings_ctr (&self->uniforms);\r
- slang_attrib_bindings_ctr (&self->attribs);\r
- slang_varying_bindings_ctr (&self->varyings);\r
- slang_texture_usages_ctr (&self->texture_usage);\r
- for (i = 0; i < SLANG_SHADER_MAX; i++)\r
- {\r
- GLuint j;\r
-\r
- for (j = 0; j < SLANG_COMMON_FIXED_MAX; j++)\r
- self->common_fixed_entries[i][j] = ~0;\r
- for (j = 0; j < SLANG_COMMON_CODE_MAX; j++)\r
- self->code[i][j] = ~0;\r
- self->machines[i] = NULL;\r
- self->assemblies[i] = NULL;\r
- }\r
- for (i = 0; i < SLANG_VERTEX_FIXED_MAX; i++)\r
- self->vertex_fixed_entries[i] = ~0;\r
- for (i = 0; i < SLANG_FRAGMENT_FIXED_MAX; i++)\r
- self->fragment_fixed_entries[i] = ~0;\r
-}\r
-\r
-GLvoid slang_program_dtr (slang_program *self)\r
-{\r
- slang_active_variables_dtr (&self->active_uniforms);\r
- slang_active_variables_dtr (&self->active_attribs);\r
- slang_attrib_overrides_dtr (&self->attrib_overrides);\r
- slang_uniform_bindings_dtr (&self->uniforms);\r
- slang_attrib_bindings_dtr (&self->attribs);\r
- slang_varying_bindings_dtr (&self->varyings);\r
- slang_texture_usages_dtr (&self->texture_usage);\r
-}\r
-\r
-static GLvoid slang_program_rst (slang_program *self)\r
-{\r
- GLuint i;\r
-\r
- slang_active_variables_dtr (&self->active_uniforms);\r
- slang_active_variables_dtr (&self->active_attribs);\r
- slang_uniform_bindings_dtr (&self->uniforms);\r
- slang_attrib_bindings_dtr (&self->attribs);\r
- slang_varying_bindings_dtr (&self->varyings);\r
- slang_texture_usages_dtr (&self->texture_usage);\r
-\r
- slang_active_variables_ctr (&self->active_uniforms);\r
- slang_active_variables_ctr (&self->active_attribs);\r
- slang_uniform_bindings_ctr (&self->uniforms);\r
- slang_attrib_bindings_ctr (&self->attribs);\r
- slang_varying_bindings_ctr (&self->varyings);\r
- slang_texture_usages_ctr (&self->texture_usage);\r
- for (i = 0; i < SLANG_SHADER_MAX; i++)\r
- {\r
- GLuint j;\r
-\r
- for (j = 0; j < SLANG_COMMON_FIXED_MAX; j++)\r
- self->common_fixed_entries[i][j] = ~0;\r
- for (j = 0; j < SLANG_COMMON_CODE_MAX; j++)\r
- self->code[i][j] = ~0;\r
- }\r
- for (i = 0; i < SLANG_VERTEX_FIXED_MAX; i++)\r
- self->vertex_fixed_entries[i] = ~0;\r
- for (i = 0; i < SLANG_FRAGMENT_FIXED_MAX; i++)\r
- self->fragment_fixed_entries[i] = ~0;\r
-}\r
-\r
-/*\r
- * _slang_link()\r
- */\r
-\r
-static GLuint gd (slang_export_data_table *tbl, const char *name)\r
-{\r
- slang_atom atom;\r
- GLuint i;\r
-\r
- atom = slang_atom_pool_atom (tbl->atoms, name);\r
- if (atom == SLANG_ATOM_NULL)\r
- return ~0;\r
-\r
- for (i = 0; i < tbl->count; i++)\r
- if (atom == tbl->entries[i].quant.name)\r
- return tbl->entries[i].address;\r
- return ~0;\r
-}\r
-\r
-static GLvoid resolve_common_fixed (GLuint e[], slang_export_data_table *tbl)\r
-{\r
- e[SLANG_COMMON_FIXED_MODELVIEWMATRIX] = gd (tbl, "gl_ModelViewMatrix");\r
- e[SLANG_COMMON_FIXED_PROJECTIONMATRIX] = gd (tbl, "gl_ProjectionMatrix");\r
- e[SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIX] = gd (tbl, "gl_ModelViewProjectionMatrix");\r
- e[SLANG_COMMON_FIXED_TEXTUREMATRIX] = gd (tbl, "gl_TextureMatrix");\r
- e[SLANG_COMMON_FIXED_NORMALMATRIX] = gd (tbl, "gl_NormalMatrix");\r
- e[SLANG_COMMON_FIXED_MODELVIEWMATRIXINVERSE] = gd (tbl, "gl_ModelViewMatrixInverse");\r
- e[SLANG_COMMON_FIXED_PROJECTIONMATRIXINVERSE] = gd (tbl, "gl_ProjectionMatrixInverse");\r
- e[SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIXINVERSE] =\r
- gd (tbl, "gl_ModelViewProjectionMatrixInverse");\r
- e[SLANG_COMMON_FIXED_TEXTUREMATRIXINVERSE] = gd (tbl, "gl_TextureMatrixInverse");\r
- e[SLANG_COMMON_FIXED_MODELVIEWMATRIXTRANSPOSE] = gd (tbl, "gl_ModelViewMatrixTranspose");\r
- e[SLANG_COMMON_FIXED_PROJECTIONMATRIXTRANSPOSE] = gd (tbl, "gl_ProjectionMatrixTranspose");\r
- e[SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIXTRANSPOSE] =\r
- gd (tbl, "gl_ModelViewProjectionMatrixTranspose");\r
- e[SLANG_COMMON_FIXED_TEXTUREMATRIXTRANSPOSE] = gd (tbl, "gl_TextureMatrixTranspose");\r
- e[SLANG_COMMON_FIXED_MODELVIEWMATRIXINVERSETRANSPOSE] =\r
- gd (tbl, "gl_ModelViewMatrixInverseTranspose");\r
- e[SLANG_COMMON_FIXED_PROJECTIONMATRIXINVERSETRANSPOSE] =\r
- gd (tbl, "gl_ProjectionMatrixInverseTranspose");\r
- e[SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIXINVERSETRANSPOSE] =\r
- gd (tbl, "gl_ModelViewProjectionMatrixInverseTranspose");\r
- e[SLANG_COMMON_FIXED_TEXTUREMATRIXINVERSETRANSPOSE] =\r
- gd (tbl, "gl_TextureMatrixInverseTranspose");\r
- e[SLANG_COMMON_FIXED_NORMALSCALE] = gd (tbl, "gl_NormalScale");\r
- e[SLANG_COMMON_FIXED_DEPTHRANGE] = gd (tbl, "gl_DepthRange");\r
- e[SLANG_COMMON_FIXED_CLIPPLANE] = gd (tbl, "gl_ClipPlane");\r
- e[SLANG_COMMON_FIXED_POINT] = gd (tbl, "gl_Point");\r
- e[SLANG_COMMON_FIXED_FRONTMATERIAL] = gd (tbl, "gl_FrontMaterial");\r
- e[SLANG_COMMON_FIXED_BACKMATERIAL] = gd (tbl, "gl_BackMaterial");\r
- e[SLANG_COMMON_FIXED_LIGHTSOURCE] = gd (tbl, "gl_LightSource");\r
- e[SLANG_COMMON_FIXED_LIGHTMODEL] = gd (tbl, "gl_LightModel");\r
- e[SLANG_COMMON_FIXED_FRONTLIGHTMODELPRODUCT] = gd (tbl, "gl_FrontLightModelProduct");\r
- e[SLANG_COMMON_FIXED_BACKLIGHTMODELPRODUCT] = gd (tbl, "gl_BackLightModelProduct");\r
- e[SLANG_COMMON_FIXED_FRONTLIGHTPRODUCT] = gd (tbl, "gl_FrontLightProduct");\r
- e[SLANG_COMMON_FIXED_BACKLIGHTPRODUCT] = gd (tbl, "gl_BackLightProduct");\r
- e[SLANG_COMMON_FIXED_TEXTUREENVCOLOR] = gd (tbl, "gl_TextureEnvColor");\r
- e[SLANG_COMMON_FIXED_EYEPLANES] = gd (tbl, "gl_EyePlaneS");\r
- e[SLANG_COMMON_FIXED_EYEPLANET] = gd (tbl, "gl_EyePlaneT");\r
- e[SLANG_COMMON_FIXED_EYEPLANER] = gd (tbl, "gl_EyePlaneR");\r
- e[SLANG_COMMON_FIXED_EYEPLANEQ] = gd (tbl, "gl_EyePlaneQ");\r
- e[SLANG_COMMON_FIXED_OBJECTPLANES] = gd (tbl, "gl_ObjectPlaneS");\r
- e[SLANG_COMMON_FIXED_OBJECTPLANET] = gd (tbl, "gl_ObjectPlaneT");\r
- e[SLANG_COMMON_FIXED_OBJECTPLANER] = gd (tbl, "gl_ObjectPlaneR");\r
- e[SLANG_COMMON_FIXED_OBJECTPLANEQ] = gd (tbl, "gl_ObjectPlaneQ");\r
- e[SLANG_COMMON_FIXED_FOG] = gd (tbl, "gl_Fog");\r
-}\r
-\r
-static GLvoid resolve_vertex_fixed (GLuint e[], slang_export_data_table *tbl)\r
-{\r
- e[SLANG_VERTEX_FIXED_POSITION] = gd (tbl, "gl_Position");\r
- e[SLANG_VERTEX_FIXED_POINTSIZE] = gd (tbl, "gl_PointSize");\r
- e[SLANG_VERTEX_FIXED_CLIPVERTEX] = gd (tbl, "gl_ClipVertex");\r
- e[SLANG_VERTEX_FIXED_COLOR] = gd (tbl, "gl_Color");\r
- e[SLANG_VERTEX_FIXED_SECONDARYCOLOR] = gd (tbl, "gl_SecondaryColor");\r
- e[SLANG_VERTEX_FIXED_NORMAL] = gd (tbl, "gl_Normal");\r
- e[SLANG_VERTEX_FIXED_VERTEX] = gd (tbl, "gl_Vertex");\r
- e[SLANG_VERTEX_FIXED_MULTITEXCOORD0] = gd (tbl, "gl_MultiTexCoord0");\r
- e[SLANG_VERTEX_FIXED_MULTITEXCOORD1] = gd (tbl, "gl_MultiTexCoord1");\r
- e[SLANG_VERTEX_FIXED_MULTITEXCOORD2] = gd (tbl, "gl_MultiTexCoord2");\r
- e[SLANG_VERTEX_FIXED_MULTITEXCOORD3] = gd (tbl, "gl_MultiTexCoord3");\r
- e[SLANG_VERTEX_FIXED_MULTITEXCOORD4] = gd (tbl, "gl_MultiTexCoord4");\r
- e[SLANG_VERTEX_FIXED_MULTITEXCOORD5] = gd (tbl, "gl_MultiTexCoord5");\r
- e[SLANG_VERTEX_FIXED_MULTITEXCOORD6] = gd (tbl, "gl_MultiTexCoord6");\r
- e[SLANG_VERTEX_FIXED_MULTITEXCOORD7] = gd (tbl, "gl_MultiTexCoord7");\r
- e[SLANG_VERTEX_FIXED_FOGCOORD] = gd (tbl, "gl_FogCoord");\r
- e[SLANG_VERTEX_FIXED_FRONTCOLOR] = gd (tbl, "gl_FrontColor");\r
- e[SLANG_VERTEX_FIXED_BACKCOLOR] = gd (tbl, "gl_BackColor");\r
- e[SLANG_VERTEX_FIXED_FRONTSECONDARYCOLOR] = gd (tbl, "gl_FrontSecondaryColor");\r
- e[SLANG_VERTEX_FIXED_BACKSECONDARYCOLOR] = gd (tbl, "gl_BackSecondaryColor");\r
- e[SLANG_VERTEX_FIXED_TEXCOORD] = gd (tbl, "gl_TexCoord");\r
- e[SLANG_VERTEX_FIXED_FOGFRAGCOORD] = gd (tbl, "gl_FogFragCoord");\r
-}\r
-\r
-static GLvoid resolve_fragment_fixed (GLuint e[], slang_export_data_table *tbl)\r
-{\r
- e[SLANG_FRAGMENT_FIXED_FRAGCOORD] = gd (tbl, "gl_FragCoord");\r
- e[SLANG_FRAGMENT_FIXED_FRONTFACING] = gd (tbl, "gl_FrontFacing");\r
- e[SLANG_FRAGMENT_FIXED_FRAGCOLOR] = gd (tbl, "gl_FragColor");\r
- e[SLANG_FRAGMENT_FIXED_FRAGDATA] = gd (tbl, "gl_FragData");\r
- e[SLANG_FRAGMENT_FIXED_FRAGDEPTH] = gd (tbl, "gl_FragDepth");\r
- e[SLANG_FRAGMENT_FIXED_COLOR] = gd (tbl, "gl_Color");\r
- e[SLANG_FRAGMENT_FIXED_SECONDARYCOLOR] = gd (tbl, "gl_SecondaryColor");\r
- e[SLANG_FRAGMENT_FIXED_TEXCOORD] = gd (tbl, "gl_TexCoord");\r
- e[SLANG_FRAGMENT_FIXED_FOGFRAGCOORD] = gd (tbl, "gl_FogFragCoord");\r
-}\r
-\r
-static GLuint gc (slang_export_code_table *tbl, const char *name)\r
-{\r
- slang_atom atom;\r
- GLuint i;\r
-\r
- atom = slang_atom_pool_atom (tbl->atoms, name);\r
- if (atom == SLANG_ATOM_NULL)\r
- return ~0;\r
-\r
- for (i = 0; i < tbl->count; i++)\r
- if (atom == tbl->entries[i].name)\r
- return tbl->entries[i].address;\r
- return ~0;\r
-}\r
-\r
-static GLvoid resolve_common_code (GLuint code[], slang_export_code_table *tbl)\r
-{\r
- code[SLANG_COMMON_CODE_MAIN] = gc (tbl, "@main");\r
-}\r
-\r
-GLboolean _slang_link (slang_program *prog, slang_translation_unit **units, GLuint count)\r
-{\r
- GLuint i;\r
-\r
- slang_program_rst (prog);\r
-\r
- for (i = 0; i < count; i++)\r
- {\r
- GLuint index;\r
-\r
- if (units[i]->type == slang_unit_fragment_shader)\r
- {\r
- index = SLANG_SHADER_FRAGMENT;\r
- resolve_fragment_fixed (prog->fragment_fixed_entries, &units[i]->exp_data);\r
- }\r
- else\r
- {\r
- index = SLANG_SHADER_VERTEX;\r
- resolve_vertex_fixed (prog->vertex_fixed_entries, &units[i]->exp_data);\r
- if (!gather_attrib_bindings (&prog->attribs, &units[i]->exp_data,\r
- &prog->attrib_overrides))\r
- return GL_FALSE;\r
- }\r
-\r
- if (!gather_active_variables (&prog->active_uniforms, &units[i]->exp_data,\r
- slang_exp_uniform))\r
- return GL_FALSE;\r
- if (!gather_active_variables (&prog->active_attribs, &units[i]->exp_data,\r
- slang_exp_attribute))\r
- return GL_FALSE;\r
- if (!gather_uniform_bindings (&prog->uniforms, &units[i]->exp_data, index))\r
- return GL_FALSE;\r
- if (!gather_varying_bindings (&prog->varyings, &units[i]->exp_data,\r
- index == SLANG_SHADER_VERTEX))\r
- return GL_FALSE;\r
- resolve_common_fixed (prog->common_fixed_entries[index], &units[i]->exp_data);\r
- resolve_common_code (prog->code[index], &units[i]->exp_code);\r
- prog->machines[index] = units[i]->machine;\r
- prog->assemblies[index] = units[i]->assembly;\r
- }\r
-\r
- /* TODO: all varyings read by fragment shader must be written by vertex shader */\r
-\r
- if (!_slang_analyse_texture_usage (prog))\r
- return GL_FALSE;\r
-\r
- return GL_TRUE;\r
-}\r
-\r
+/*
+ * 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_link.c
+ * slang linker
+ * \author Michal Krol
+ */
+
+#include "imports.h"
+#include "slang_link.h"
+#include "slang_analyse.h"
+
+static GLboolean entry_has_gl_prefix (slang_atom name, slang_atom_pool *atoms)
+{
+ const char *str = slang_atom_pool_id (atoms, name);
+ return str[0] == 'g' && str[1] == 'l' && str[2] == '_';
+}
+
+/*
+ * slang_active_variables
+ */
+
+static GLvoid slang_active_variables_ctr (slang_active_variables *self)
+{
+ self->table = NULL;
+ self->count = 0;
+}
+
+static GLvoid slang_active_variables_dtr (slang_active_variables *self)
+{
+ GLuint i;
+
+ for (i = 0; i < self->count; i++)
+ slang_alloc_free (self->table[i].name);
+ slang_alloc_free (self->table);
+}
+
+static GLboolean add_simple_variable (slang_active_variables *self, slang_export_data_quant *q,
+ const char *name)
+{
+ const GLuint n = self->count;
+
+ self->table = (slang_active_variable *) slang_alloc_realloc (self->table,
+ n * sizeof (slang_active_variable), (n + 1) * sizeof (slang_active_variable));
+ if (self->table == NULL)
+ return GL_FALSE;
+
+ self->table[n].quant = q;
+ self->table[n].name = slang_string_duplicate (name);
+ if (self->table[n].name == NULL)
+ return GL_FALSE;
+ self->count++;
+
+ return GL_TRUE;
+}
+
+static GLboolean add_complex_variable (slang_active_variables *self, slang_export_data_quant *q,
+ char *name, slang_atom_pool *atoms)
+{
+ slang_string_concat (name, slang_atom_pool_id (atoms, q->name));
+ if (slang_export_data_quant_array (q))
+ slang_string_concat (name, "[0]");
+
+ if (slang_export_data_quant_struct (q))
+ {
+ GLuint dot_pos, i;
+ const GLuint fields = slang_export_data_quant_fields (q);
+
+ slang_string_concat (name, ".");
+ dot_pos = slang_string_length (name);
+
+ for (i = 0; i < fields; i++)
+ {
+ if (!add_complex_variable (self, &q->structure[i], name, atoms))
+ return GL_FALSE;
+
+ name[dot_pos] = '\0';
+ }
+
+ return GL_TRUE;
+ }
+
+ return add_simple_variable (self, q, name);
+}
+
+static GLboolean gather_active_variables (slang_active_variables *self,
+ slang_export_data_table *tbl, slang_export_data_access access)
+{
+ GLuint i;
+
+ for (i = 0; i < tbl->count; i++)
+ if (tbl->entries[i].access == access)
+ {
+ char name[1024] = "";
+
+ if (!add_complex_variable (self, &tbl->entries[i].quant, name, tbl->atoms))
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+/*
+ * slang_attrib_overrides
+ */
+
+static GLvoid slang_attrib_overrides_ctr (slang_attrib_overrides *self)
+{
+ self->table = NULL;
+ self->count = 0;
+}
+
+static GLvoid slang_attrib_overrides_dtr (slang_attrib_overrides *self)
+{
+ GLuint i;
+
+ for (i = 0; i < self->count; i++)
+ slang_alloc_free (self->table[i].name);
+ slang_alloc_free (self->table);
+}
+
+GLboolean slang_attrib_overrides_add (slang_attrib_overrides *self, GLuint index, const GLchar *name)
+{
+ const GLuint n = self->count;
+ GLuint i;
+
+ for (i = 0; i < n; i++)
+ if (slang_string_compare (name, self->table[i].name) == 0)
+ {
+ self->table[i].index = index;
+ return GL_TRUE;
+ }
+
+ self->table = (slang_attrib_override *) slang_alloc_realloc (self->table,
+ n * sizeof (slang_attrib_override), (n + 1) * sizeof (slang_attrib_override));
+ if (self->table == NULL)
+ return GL_FALSE;
+
+ self->table[n].index = index;
+ self->table[n].name = slang_string_duplicate (name);
+ if (self->table[n].name == NULL)
+ return GL_FALSE;
+ self->count++;
+
+ return GL_TRUE;
+}
+
+static GLuint lookup_attrib_override (slang_attrib_overrides *self, const GLchar *name)
+{
+ GLuint i;
+
+ for (i = 0; self->count; i++)
+ if (slang_string_compare (name, self->table[i].name) == 0)
+ return self->table[i].index;
+ return MAX_VERTEX_ATTRIBS;
+}
+
+/*
+ * slang_uniform_bindings
+ */
+
+static GLvoid slang_uniform_bindings_ctr (slang_uniform_bindings *self)
+{
+ self->table = NULL;
+ self->count = 0;
+}
+
+static GLvoid slang_uniform_bindings_dtr (slang_uniform_bindings *self)
+{
+ GLuint i;
+
+ for (i = 0; i < self->count; i++)
+ slang_alloc_free (self->table[i].name);
+ slang_alloc_free (self->table);
+}
+
+static GLboolean add_simple_uniform_binding (slang_uniform_bindings *self,
+ slang_export_data_quant *q, const char *name, GLuint index, GLuint addr)
+{
+ const GLuint n = self->count;
+ GLuint i;
+
+ for (i = 0; i < n; i++)
+ if (slang_string_compare (self->table[i].name, name) == 0)
+ {
+ self->table[i].address[index] = addr;
+ return GL_TRUE;
+ }
+
+ self->table = (slang_uniform_binding *) slang_alloc_realloc (self->table,
+ n * sizeof (slang_uniform_binding), (n + 1) * sizeof (slang_uniform_binding));
+ if (self->table == NULL)
+ return GL_FALSE;
+
+ self->table[n].quant = q;
+ self->table[n].name = slang_string_duplicate (name);
+ if (self->table[n].name == NULL)
+ return GL_FALSE;
+ for (i = 0; i < SLANG_SHADER_MAX; i++)
+ self->table[n].address[i] = ~0;
+ self->table[n].address[index] = addr;
+ self->count++;
+
+ return GL_TRUE;
+}
+
+static GLboolean add_complex_uniform_binding (slang_uniform_bindings *self,
+ slang_export_data_quant *q, char *name, slang_atom_pool *atoms, GLuint index, GLuint addr)
+{
+ GLuint count, i;
+
+ slang_string_concat (name, slang_atom_pool_id (atoms, q->name));
+ count = slang_export_data_quant_elements (q);
+ for (i = 0; i < count; i++)
+ {
+ GLuint bracket_pos;
+
+ bracket_pos = slang_string_length (name);
+ if (slang_export_data_quant_array (q))
+ _mesa_sprintf (name + slang_string_length (name), "[%d]", i);
+
+ if (slang_export_data_quant_struct (q))
+ {
+ GLuint dot_pos, i;
+ const GLuint fields = slang_export_data_quant_fields (q);
+
+ slang_string_concat (name, ".");
+ dot_pos = slang_string_length (name);
+
+ for (i = 0; i < fields; i++)
+ {
+ if (!add_complex_uniform_binding (self, &q->structure[i], name, atoms, index, addr))
+ return GL_FALSE;
+
+ name[dot_pos] = '\0';
+ addr += slang_export_data_quant_size (&q->structure[i]);
+ }
+ }
+ else
+ {
+ if (!add_simple_uniform_binding (self, q, name, index, addr))
+ return GL_FALSE;
+
+ addr += slang_export_data_quant_size (q);
+ }
+
+ name[bracket_pos] = '\0';
+ }
+
+ return GL_TRUE;
+}
+
+static GLboolean gather_uniform_bindings (slang_uniform_bindings *self,
+ slang_export_data_table *tbl, GLuint index)
+{
+ GLuint i;
+
+ for (i = 0; i < tbl->count; i++)
+ if (tbl->entries[i].access == slang_exp_uniform)
+ {
+ char name[1024] = "";
+
+ if (!add_complex_uniform_binding (self, &tbl->entries[i].quant, name, tbl->atoms, index,
+ tbl->entries[i].address))
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+/*
+ * slang_attrib_bindings
+ */
+
+static GLvoid slang_attrib_bindings_ctr (slang_attrib_bindings *self)
+{
+ GLuint i;
+
+ self->binding_count = 0;
+ for (i = 0; i < MAX_VERTEX_ATTRIBS; i++)
+ self->slots[i].addr = ~0;
+}
+
+static GLvoid slang_attrib_bindings_dtr (slang_attrib_bindings *self)
+{
+ GLuint i;
+
+ for (i = 0; i < self->binding_count; i++)
+ slang_alloc_free (self->bindings[i].name);
+}
+
+static GLuint can_allocate_attrib_slots (slang_attrib_bindings *self, GLuint index, GLuint count)
+{
+ GLuint i;
+
+ for (i = 0; i < count; i++)
+ if (self->slots[index + i].addr != ~0)
+ break;
+ return i;
+}
+
+static GLuint allocate_attrib_slots (slang_attrib_bindings *self, GLuint count)
+{
+ GLuint i;
+
+ for (i = 0; i <= MAX_VERTEX_ATTRIBS - count; i++)
+ {
+ GLuint size;
+
+ size = can_allocate_attrib_slots (self, i, count);
+ if (size == count)
+ return i;
+
+ /* speed-up the search a bit */
+ i += count;
+ }
+ return MAX_VERTEX_ATTRIBS;
+}
+
+static GLboolean add_attrib_binding (slang_attrib_bindings *self, slang_export_data_quant *q,
+ const char *name, GLuint addr, GLuint index_override)
+{
+ const GLuint n = self->binding_count;
+ GLuint slot_span, slot_index;
+ GLuint i;
+
+ assert (slang_export_data_quant_simple (q));
+
+ switch (slang_export_data_quant_type (q))
+ {
+ case GL_FLOAT:
+ case GL_FLOAT_VEC2:
+ case GL_FLOAT_VEC3:
+ case GL_FLOAT_VEC4:
+ slot_span = 1;
+ break;
+ case GL_FLOAT_MAT2:
+ slot_span = 2;
+ break;
+ case GL_FLOAT_MAT3:
+ slot_span = 3;
+ break;
+ case GL_FLOAT_MAT4:
+ slot_span = 4;
+ break;
+ default:
+ assert (0);
+ }
+
+ if (index_override == MAX_VERTEX_ATTRIBS)
+ slot_index = allocate_attrib_slots (self, slot_span);
+ else if (can_allocate_attrib_slots (self, index_override, slot_span) == slot_span)
+ slot_index = index_override;
+ else
+ slot_index = MAX_VERTEX_ATTRIBS;
+
+ if (slot_index == MAX_VERTEX_ATTRIBS)
+ {
+ /* TODO: info log: error: MAX_VERTEX_ATTRIBS exceeded */
+ return GL_FALSE;
+ }
+
+ self->bindings[n].quant = q;
+ self->bindings[n].name = slang_string_duplicate (name);
+ if (self->bindings[n].name == NULL)
+ return GL_FALSE;
+ self->bindings[n].first_slot_index = slot_index;
+ self->binding_count++;
+
+ for (i = 0; i < slot_span; i++)
+ self->slots[self->bindings[n].first_slot_index + i].addr = addr + i * 4;
+
+ return GL_TRUE;
+}
+
+static GLboolean gather_attrib_bindings (slang_attrib_bindings *self, slang_export_data_table *tbl,
+ slang_attrib_overrides *ovr)
+{
+ GLuint i;
+
+ /* First pass. Gather attribs that have overriden index slots. */
+ for (i = 0; i < tbl->count; i++)
+ if (tbl->entries[i].access == slang_exp_attribute &&
+ !entry_has_gl_prefix (tbl->entries[i].quant.name, tbl->atoms))
+ {
+ slang_export_data_quant *quant = &tbl->entries[i].quant;
+ const GLchar *id = slang_atom_pool_id (tbl->atoms, quant->name);
+ GLuint index = lookup_attrib_override (ovr, id);
+
+ if (index != MAX_VERTEX_ATTRIBS)
+ {
+ if (!add_attrib_binding (self, quant, id, tbl->entries[i].address, index))
+ return GL_FALSE;
+ }
+ }
+
+ /* Second pass. Gather attribs that have *NOT* overriden index slots. */
+ for (i = 0; i < tbl->count; i++)
+ if (tbl->entries[i].access == slang_exp_attribute &&
+ !entry_has_gl_prefix (tbl->entries[i].quant.name, tbl->atoms))
+ {
+ slang_export_data_quant *quant = &tbl->entries[i].quant;
+ const GLchar *id = slang_atom_pool_id (tbl->atoms, quant->name);
+ GLuint index = lookup_attrib_override (ovr, id);
+
+ if (index == MAX_VERTEX_ATTRIBS)
+ {
+ if (!add_attrib_binding (self, quant, id, tbl->entries[i].address, index))
+ return GL_FALSE;
+ }
+ }
+
+ return GL_TRUE;
+}
+
+/*
+ * slang_varying_bindings
+ */
+
+static GLvoid slang_varying_bindings_ctr (slang_varying_bindings *self)
+{
+ self->binding_count = 0;
+ self->slot_count = 0;
+}
+
+static GLvoid slang_varying_bindings_dtr (slang_varying_bindings *self)
+{
+ GLuint i;
+
+ for (i = 0; i < self->binding_count; i++)
+ slang_alloc_free (self->bindings[i].name);
+}
+
+static GLvoid update_varying_slots (slang_varying_slot *slots, GLuint count, GLboolean is_vert,
+ GLuint addr, GLuint do_offset)
+{
+ GLuint i;
+
+ for (i = 0; i < count; i++)
+ *(is_vert ? &slots[i].vert_addr : &slots[i].frag_addr) = addr + i * 4 * do_offset;
+}
+
+static GLboolean add_varying_binding (slang_varying_bindings *self,
+ slang_export_data_quant *q, const char *name, GLboolean is_vert, GLuint addr)
+{
+ const GLuint n = self->binding_count;
+ const GLuint slot_span =
+ slang_export_data_quant_components (q) * slang_export_data_quant_elements (q);
+ GLuint i;
+
+ for (i = 0; i < n; i++)
+ if (slang_string_compare (self->bindings[i].name, name) == 0)
+ {
+ /* TODO: data quantities must match, or else link fails */
+ update_varying_slots (&self->slots[self->bindings[i].first_slot_index], slot_span,
+ is_vert, addr, 1);
+ return GL_TRUE;
+ }
+
+ if (self->slot_count + slot_span > MAX_VARYING_FLOATS)
+ {
+ /* TODO: info log: error: MAX_VARYING_FLOATS exceeded */
+ return GL_FALSE;
+ }
+
+ self->bindings[n].quant = q;
+ self->bindings[n].name = slang_string_duplicate (name);
+ if (self->bindings[n].name == NULL)
+ return GL_FALSE;
+ self->bindings[n].first_slot_index = self->slot_count;
+ self->binding_count++;
+
+ update_varying_slots (&self->slots[self->bindings[n].first_slot_index], slot_span, is_vert,
+ addr, 1);
+ update_varying_slots (&self->slots[self->bindings[n].first_slot_index], slot_span, !is_vert,
+ ~0, 0);
+ self->slot_count += slot_span;
+
+ return GL_TRUE;
+}
+
+static GLboolean gather_varying_bindings (slang_varying_bindings *self,
+ slang_export_data_table *tbl, GLboolean is_vert)
+{
+ GLuint i;
+
+ for (i = 0; i < tbl->count; i++)
+ if (tbl->entries[i].access == slang_exp_varying &&
+ !entry_has_gl_prefix (tbl->entries[i].quant.name, tbl->atoms))
+ {
+ if (!add_varying_binding (self, &tbl->entries[i].quant, slang_atom_pool_id (tbl->atoms,
+ tbl->entries[i].quant.name), is_vert, tbl->entries[i].address))
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+/*
+ * slang_texture_bindings
+ */
+
+GLvoid slang_texture_usages_ctr (slang_texture_usages *self)
+{
+ self->table = NULL;
+ self->count = 0;
+}
+
+GLvoid slang_texture_usages_dtr (slang_texture_usages *self)
+{
+ slang_alloc_free (self->table);
+}
+
+/*
+ * slang_program
+ */
+
+GLvoid slang_program_ctr (slang_program *self)
+{
+ GLuint i;
+
+ slang_active_variables_ctr (&self->active_uniforms);
+ slang_active_variables_ctr (&self->active_attribs);
+ slang_attrib_overrides_ctr (&self->attrib_overrides);
+ slang_uniform_bindings_ctr (&self->uniforms);
+ slang_attrib_bindings_ctr (&self->attribs);
+ slang_varying_bindings_ctr (&self->varyings);
+ slang_texture_usages_ctr (&self->texture_usage);
+ for (i = 0; i < SLANG_SHADER_MAX; i++)
+ {
+ GLuint j;
+
+ for (j = 0; j < SLANG_COMMON_FIXED_MAX; j++)
+ self->common_fixed_entries[i][j] = ~0;
+ for (j = 0; j < SLANG_COMMON_CODE_MAX; j++)
+ self->code[i][j] = ~0;
+ self->machines[i] = NULL;
+ self->assemblies[i] = NULL;
+ }
+ for (i = 0; i < SLANG_VERTEX_FIXED_MAX; i++)
+ self->vertex_fixed_entries[i] = ~0;
+ for (i = 0; i < SLANG_FRAGMENT_FIXED_MAX; i++)
+ self->fragment_fixed_entries[i] = ~0;
+}
+
+GLvoid slang_program_dtr (slang_program *self)
+{
+ slang_active_variables_dtr (&self->active_uniforms);
+ slang_active_variables_dtr (&self->active_attribs);
+ slang_attrib_overrides_dtr (&self->attrib_overrides);
+ slang_uniform_bindings_dtr (&self->uniforms);
+ slang_attrib_bindings_dtr (&self->attribs);
+ slang_varying_bindings_dtr (&self->varyings);
+ slang_texture_usages_dtr (&self->texture_usage);
+}
+
+static GLvoid slang_program_rst (slang_program *self)
+{
+ GLuint i;
+
+ slang_active_variables_dtr (&self->active_uniforms);
+ slang_active_variables_dtr (&self->active_attribs);
+ slang_uniform_bindings_dtr (&self->uniforms);
+ slang_attrib_bindings_dtr (&self->attribs);
+ slang_varying_bindings_dtr (&self->varyings);
+ slang_texture_usages_dtr (&self->texture_usage);
+
+ slang_active_variables_ctr (&self->active_uniforms);
+ slang_active_variables_ctr (&self->active_attribs);
+ slang_uniform_bindings_ctr (&self->uniforms);
+ slang_attrib_bindings_ctr (&self->attribs);
+ slang_varying_bindings_ctr (&self->varyings);
+ slang_texture_usages_ctr (&self->texture_usage);
+ for (i = 0; i < SLANG_SHADER_MAX; i++)
+ {
+ GLuint j;
+
+ for (j = 0; j < SLANG_COMMON_FIXED_MAX; j++)
+ self->common_fixed_entries[i][j] = ~0;
+ for (j = 0; j < SLANG_COMMON_CODE_MAX; j++)
+ self->code[i][j] = ~0;
+ }
+ for (i = 0; i < SLANG_VERTEX_FIXED_MAX; i++)
+ self->vertex_fixed_entries[i] = ~0;
+ for (i = 0; i < SLANG_FRAGMENT_FIXED_MAX; i++)
+ self->fragment_fixed_entries[i] = ~0;
+}
+
+/*
+ * _slang_link()
+ */
+
+static GLuint gd (slang_export_data_table *tbl, const char *name)
+{
+ slang_atom atom;
+ GLuint i;
+
+ atom = slang_atom_pool_atom (tbl->atoms, name);
+ if (atom == SLANG_ATOM_NULL)
+ return ~0;
+
+ for (i = 0; i < tbl->count; i++)
+ if (atom == tbl->entries[i].quant.name)
+ return tbl->entries[i].address;
+ return ~0;
+}
+
+static GLvoid resolve_common_fixed (GLuint e[], slang_export_data_table *tbl)
+{
+ e[SLANG_COMMON_FIXED_MODELVIEWMATRIX] = gd (tbl, "gl_ModelViewMatrix");
+ e[SLANG_COMMON_FIXED_PROJECTIONMATRIX] = gd (tbl, "gl_ProjectionMatrix");
+ e[SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIX] = gd (tbl, "gl_ModelViewProjectionMatrix");
+ e[SLANG_COMMON_FIXED_TEXTUREMATRIX] = gd (tbl, "gl_TextureMatrix");
+ e[SLANG_COMMON_FIXED_NORMALMATRIX] = gd (tbl, "gl_NormalMatrix");
+ e[SLANG_COMMON_FIXED_MODELVIEWMATRIXINVERSE] = gd (tbl, "gl_ModelViewMatrixInverse");
+ e[SLANG_COMMON_FIXED_PROJECTIONMATRIXINVERSE] = gd (tbl, "gl_ProjectionMatrixInverse");
+ e[SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIXINVERSE] =
+ gd (tbl, "gl_ModelViewProjectionMatrixInverse");
+ e[SLANG_COMMON_FIXED_TEXTUREMATRIXINVERSE] = gd (tbl, "gl_TextureMatrixInverse");
+ e[SLANG_COMMON_FIXED_MODELVIEWMATRIXTRANSPOSE] = gd (tbl, "gl_ModelViewMatrixTranspose");
+ e[SLANG_COMMON_FIXED_PROJECTIONMATRIXTRANSPOSE] = gd (tbl, "gl_ProjectionMatrixTranspose");
+ e[SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIXTRANSPOSE] =
+ gd (tbl, "gl_ModelViewProjectionMatrixTranspose");
+ e[SLANG_COMMON_FIXED_TEXTUREMATRIXTRANSPOSE] = gd (tbl, "gl_TextureMatrixTranspose");
+ e[SLANG_COMMON_FIXED_MODELVIEWMATRIXINVERSETRANSPOSE] =
+ gd (tbl, "gl_ModelViewMatrixInverseTranspose");
+ e[SLANG_COMMON_FIXED_PROJECTIONMATRIXINVERSETRANSPOSE] =
+ gd (tbl, "gl_ProjectionMatrixInverseTranspose");
+ e[SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIXINVERSETRANSPOSE] =
+ gd (tbl, "gl_ModelViewProjectionMatrixInverseTranspose");
+ e[SLANG_COMMON_FIXED_TEXTUREMATRIXINVERSETRANSPOSE] =
+ gd (tbl, "gl_TextureMatrixInverseTranspose");
+ e[SLANG_COMMON_FIXED_NORMALSCALE] = gd (tbl, "gl_NormalScale");
+ e[SLANG_COMMON_FIXED_DEPTHRANGE] = gd (tbl, "gl_DepthRange");
+ e[SLANG_COMMON_FIXED_CLIPPLANE] = gd (tbl, "gl_ClipPlane");
+ e[SLANG_COMMON_FIXED_POINT] = gd (tbl, "gl_Point");
+ e[SLANG_COMMON_FIXED_FRONTMATERIAL] = gd (tbl, "gl_FrontMaterial");
+ e[SLANG_COMMON_FIXED_BACKMATERIAL] = gd (tbl, "gl_BackMaterial");
+ e[SLANG_COMMON_FIXED_LIGHTSOURCE] = gd (tbl, "gl_LightSource");
+ e[SLANG_COMMON_FIXED_LIGHTMODEL] = gd (tbl, "gl_LightModel");
+ e[SLANG_COMMON_FIXED_FRONTLIGHTMODELPRODUCT] = gd (tbl, "gl_FrontLightModelProduct");
+ e[SLANG_COMMON_FIXED_BACKLIGHTMODELPRODUCT] = gd (tbl, "gl_BackLightModelProduct");
+ e[SLANG_COMMON_FIXED_FRONTLIGHTPRODUCT] = gd (tbl, "gl_FrontLightProduct");
+ e[SLANG_COMMON_FIXED_BACKLIGHTPRODUCT] = gd (tbl, "gl_BackLightProduct");
+ e[SLANG_COMMON_FIXED_TEXTUREENVCOLOR] = gd (tbl, "gl_TextureEnvColor");
+ e[SLANG_COMMON_FIXED_EYEPLANES] = gd (tbl, "gl_EyePlaneS");
+ e[SLANG_COMMON_FIXED_EYEPLANET] = gd (tbl, "gl_EyePlaneT");
+ e[SLANG_COMMON_FIXED_EYEPLANER] = gd (tbl, "gl_EyePlaneR");
+ e[SLANG_COMMON_FIXED_EYEPLANEQ] = gd (tbl, "gl_EyePlaneQ");
+ e[SLANG_COMMON_FIXED_OBJECTPLANES] = gd (tbl, "gl_ObjectPlaneS");
+ e[SLANG_COMMON_FIXED_OBJECTPLANET] = gd (tbl, "gl_ObjectPlaneT");
+ e[SLANG_COMMON_FIXED_OBJECTPLANER] = gd (tbl, "gl_ObjectPlaneR");
+ e[SLANG_COMMON_FIXED_OBJECTPLANEQ] = gd (tbl, "gl_ObjectPlaneQ");
+ e[SLANG_COMMON_FIXED_FOG] = gd (tbl, "gl_Fog");
+}
+
+static GLvoid resolve_vertex_fixed (GLuint e[], slang_export_data_table *tbl)
+{
+ e[SLANG_VERTEX_FIXED_POSITION] = gd (tbl, "gl_Position");
+ e[SLANG_VERTEX_FIXED_POINTSIZE] = gd (tbl, "gl_PointSize");
+ e[SLANG_VERTEX_FIXED_CLIPVERTEX] = gd (tbl, "gl_ClipVertex");
+ e[SLANG_VERTEX_FIXED_COLOR] = gd (tbl, "gl_Color");
+ e[SLANG_VERTEX_FIXED_SECONDARYCOLOR] = gd (tbl, "gl_SecondaryColor");
+ e[SLANG_VERTEX_FIXED_NORMAL] = gd (tbl, "gl_Normal");
+ e[SLANG_VERTEX_FIXED_VERTEX] = gd (tbl, "gl_Vertex");
+ e[SLANG_VERTEX_FIXED_MULTITEXCOORD0] = gd (tbl, "gl_MultiTexCoord0");
+ e[SLANG_VERTEX_FIXED_MULTITEXCOORD1] = gd (tbl, "gl_MultiTexCoord1");
+ e[SLANG_VERTEX_FIXED_MULTITEXCOORD2] = gd (tbl, "gl_MultiTexCoord2");
+ e[SLANG_VERTEX_FIXED_MULTITEXCOORD3] = gd (tbl, "gl_MultiTexCoord3");
+ e[SLANG_VERTEX_FIXED_MULTITEXCOORD4] = gd (tbl, "gl_MultiTexCoord4");
+ e[SLANG_VERTEX_FIXED_MULTITEXCOORD5] = gd (tbl, "gl_MultiTexCoord5");
+ e[SLANG_VERTEX_FIXED_MULTITEXCOORD6] = gd (tbl, "gl_MultiTexCoord6");
+ e[SLANG_VERTEX_FIXED_MULTITEXCOORD7] = gd (tbl, "gl_MultiTexCoord7");
+ e[SLANG_VERTEX_FIXED_FOGCOORD] = gd (tbl, "gl_FogCoord");
+ e[SLANG_VERTEX_FIXED_FRONTCOLOR] = gd (tbl, "gl_FrontColor");
+ e[SLANG_VERTEX_FIXED_BACKCOLOR] = gd (tbl, "gl_BackColor");
+ e[SLANG_VERTEX_FIXED_FRONTSECONDARYCOLOR] = gd (tbl, "gl_FrontSecondaryColor");
+ e[SLANG_VERTEX_FIXED_BACKSECONDARYCOLOR] = gd (tbl, "gl_BackSecondaryColor");
+ e[SLANG_VERTEX_FIXED_TEXCOORD] = gd (tbl, "gl_TexCoord");
+ e[SLANG_VERTEX_FIXED_FOGFRAGCOORD] = gd (tbl, "gl_FogFragCoord");
+}
+
+static GLvoid resolve_fragment_fixed (GLuint e[], slang_export_data_table *tbl)
+{
+ e[SLANG_FRAGMENT_FIXED_FRAGCOORD] = gd (tbl, "gl_FragCoord");
+ e[SLANG_FRAGMENT_FIXED_FRONTFACING] = gd (tbl, "gl_FrontFacing");
+ e[SLANG_FRAGMENT_FIXED_FRAGCOLOR] = gd (tbl, "gl_FragColor");
+ e[SLANG_FRAGMENT_FIXED_FRAGDATA] = gd (tbl, "gl_FragData");
+ e[SLANG_FRAGMENT_FIXED_FRAGDEPTH] = gd (tbl, "gl_FragDepth");
+ e[SLANG_FRAGMENT_FIXED_COLOR] = gd (tbl, "gl_Color");
+ e[SLANG_FRAGMENT_FIXED_SECONDARYCOLOR] = gd (tbl, "gl_SecondaryColor");
+ e[SLANG_FRAGMENT_FIXED_TEXCOORD] = gd (tbl, "gl_TexCoord");
+ e[SLANG_FRAGMENT_FIXED_FOGFRAGCOORD] = gd (tbl, "gl_FogFragCoord");
+}
+
+static GLuint gc (slang_export_code_table *tbl, const char *name)
+{
+ slang_atom atom;
+ GLuint i;
+
+ atom = slang_atom_pool_atom (tbl->atoms, name);
+ if (atom == SLANG_ATOM_NULL)
+ return ~0;
+
+ for (i = 0; i < tbl->count; i++)
+ if (atom == tbl->entries[i].name)
+ return tbl->entries[i].address;
+ return ~0;
+}
+
+static GLvoid resolve_common_code (GLuint code[], slang_export_code_table *tbl)
+{
+ code[SLANG_COMMON_CODE_MAIN] = gc (tbl, "@main");
+}
+
+GLboolean _slang_link (slang_program *prog, slang_translation_unit **units, GLuint count)
+{
+ GLuint i;
+
+ slang_program_rst (prog);
+
+ for (i = 0; i < count; i++)
+ {
+ GLuint index;
+
+ if (units[i]->type == slang_unit_fragment_shader)
+ {
+ index = SLANG_SHADER_FRAGMENT;
+ resolve_fragment_fixed (prog->fragment_fixed_entries, &units[i]->exp_data);
+ }
+ else
+ {
+ index = SLANG_SHADER_VERTEX;
+ resolve_vertex_fixed (prog->vertex_fixed_entries, &units[i]->exp_data);
+ if (!gather_attrib_bindings (&prog->attribs, &units[i]->exp_data,
+ &prog->attrib_overrides))
+ return GL_FALSE;
+ }
+
+ if (!gather_active_variables (&prog->active_uniforms, &units[i]->exp_data,
+ slang_exp_uniform))
+ return GL_FALSE;
+ if (!gather_active_variables (&prog->active_attribs, &units[i]->exp_data,
+ slang_exp_attribute))
+ return GL_FALSE;
+ if (!gather_uniform_bindings (&prog->uniforms, &units[i]->exp_data, index))
+ return GL_FALSE;
+ if (!gather_varying_bindings (&prog->varyings, &units[i]->exp_data,
+ index == SLANG_SHADER_VERTEX))
+ return GL_FALSE;
+ resolve_common_fixed (prog->common_fixed_entries[index], &units[i]->exp_data);
+ resolve_common_code (prog->code[index], &units[i]->exp_code);
+ prog->machines[index] = units[i]->machine;
+ prog->assemblies[index] = units[i]->assembly;
+ }
+
+ /* TODO: all varyings read by fragment shader must be written by vertex shader */
+
+ if (!_slang_analyse_texture_usage (prog))
+ return GL_FALSE;
+
+ return GL_TRUE;
+}
+
-/*\r
- * Mesa 3-D graphics library\r
- * Version: 6.5\r
- *\r
- * Copyright (C) 2006 Brian Paul All Rights Reserved.\r
- *\r
- * Permission is hereby granted, free of charge, to any person obtaining a\r
- * copy of this software and associated documentation files (the "Software"),\r
- * to deal in the Software without restriction, including without limitation\r
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
- * and/or sell copies of the Software, and to permit persons to whom the\r
- * Software is furnished to do so, subject to the following conditions:\r
- *\r
- * The above copyright notice and this permission notice shall be included\r
- * in all copies or substantial portions of the Software.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\r
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
- */\r
-\r
-#if !defined SLANG_LINK_H\r
-#define SLANG_LINK_H\r
-\r
-#include "slang_compile.h"\r
-\r
-#if defined __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-enum\r
-{\r
- SLANG_SHADER_VERTEX,\r
- SLANG_SHADER_FRAGMENT,\r
- SLANG_SHADER_MAX\r
-};\r
-\r
-/* Active variables.\r
- *\r
- * Active uniforms or attribs can be queried by the application to get a list of uniforms\r
- * or attribs actually used by shaders (uniforms) or vertex shader (attribs).\r
- */\r
-\r
-typedef struct\r
-{\r
- slang_export_data_quant *quant;\r
- char *name;\r
-} slang_active_variable;\r
-\r
-typedef struct\r
-{\r
- slang_active_variable *table;\r
- GLuint count;\r
-} slang_active_variables;\r
-\r
-/*\r
- * Attrib binding override.\r
- *\r
- * The application can override GL attrib binding by specifying its preferred index assignment\r
- * for a given attrib name. Those overrides are taken into account while linking the program.\r
- */\r
-\r
-typedef struct\r
-{\r
- GLuint index;\r
- GLchar *name;\r
-} slang_attrib_override;\r
-\r
-typedef struct\r
-{\r
- slang_attrib_override *table;\r
- GLuint count;\r
-} slang_attrib_overrides;\r
-\r
-GLboolean slang_attrib_overrides_add (slang_attrib_overrides *, GLuint, const GLchar *);\r
-\r
-/*\r
- * Uniform bindings.\r
- *\r
- * Each slang_uniform_binding holds an array of addresses to actual memory locations in those\r
- * shader types that use that uniform. Uniform bindings are held in an array and accessed\r
- * by array index which is seen to the application as a uniform location.\r
- *\r
- * When the application writes to a particular uniform, it specifies its location.\r
- * This location is treated as an array index to slang_uniform_bindings::table and tested\r
- * against slang_uniform_bindings::count limit. The result is a pointer to slang_uniform_binding.\r
- * The type of data being written to uniform is tested against slang_uniform_binding::quant.\r
- * If the types are compatible, the array slang_uniform_binding::address is iterated for\r
- * each shader type and if the address is valid (i.e. the uniform is used by this shader type),\r
- * the new uniform value is written at that address.\r
- */\r
-\r
-typedef struct\r
-{\r
- slang_export_data_quant *quant;\r
- char *name;\r
- GLuint address[SLANG_SHADER_MAX];\r
-} slang_uniform_binding;\r
-\r
-typedef struct\r
-{\r
- slang_uniform_binding *table;\r
- GLuint count;\r
-} slang_uniform_bindings;\r
-\r
-/*\r
- * Attrib bindings.\r
- *\r
- * There is a fixed number of vertex attrib vectors (attrib slots). The slang_attrib_slot::addr\r
- * maps vertex attrib index to the actual memory location of the attrib in vertex shader.\r
- * One vertex attrib can span over many attrib slots (this is the case for matrices). The\r
- * slang_attrib_binding::first_slot_index holds the first slot index that the attrib is bound to.\r
- */\r
-\r
-typedef struct\r
-{\r
- slang_export_data_quant *quant;\r
- char *name;\r
- GLuint first_slot_index;\r
-} slang_attrib_binding;\r
-\r
-typedef struct\r
-{\r
- GLuint addr;\r
-} slang_attrib_slot;\r
-\r
-typedef struct\r
-{\r
- slang_attrib_binding bindings[MAX_VERTEX_ATTRIBS];\r
- GLuint binding_count;\r
- slang_attrib_slot slots[MAX_VERTEX_ATTRIBS];\r
-} slang_attrib_bindings;\r
-\r
-/*\r
- * Varying bindings.\r
- *\r
- * There is a fixed number of varying floats (varying slots). The slang_varying_slot::vert_addr\r
- * maps varying float index to the actual memory location of the output variable in vertex shader.\r
- * The slang_varying_slot::frag_addr maps varying float index to the actual memory location of\r
- * the input variable in fragment shader.\r
- */\r
-\r
-typedef struct\r
-{\r
- GLuint vert_addr;\r
- GLuint frag_addr;\r
-} slang_varying_slot;\r
-\r
-typedef struct\r
-{\r
- slang_export_data_quant *quant;\r
- char *name;\r
- GLuint first_slot_index;\r
-} slang_varying_binding;\r
-\r
-typedef struct\r
-{\r
- slang_varying_binding bindings[MAX_VARYING_FLOATS];\r
- GLuint binding_count;\r
- slang_varying_slot slots[MAX_VARYING_FLOATS];\r
- GLuint slot_count;\r
-} slang_varying_bindings;\r
-\r
-/*\r
- * Texture usage.\r
- *\r
- * A slang_texture_usage struct holds indirect information about texture image unit usage. The\r
- * slang_texture_usages::table is derived from active uniform table by extracting only uniforms\r
- * that are samplers.\r
- *\r
- * To collect current texture usage one must iterate the slang_texture_usages::table and read\r
- * uniform at address slang_texture_usage::frag_address to get texture unit index. This\r
- * index, coupled with texture access type (target) taken from slang_texture_usage::quant\r
- * forms texture usage for that texture unit.\r
- */\r
-\r
-typedef struct\r
-{\r
- slang_export_data_quant *quant;\r
- GLuint frag_address;\r
-} slang_texture_usage;\r
-\r
-typedef struct\r
-{\r
- slang_texture_usage *table;\r
- GLuint count;\r
-} slang_texture_usages;\r
-\r
-GLvoid slang_texture_usages_ctr (slang_texture_usages *);\r
-GLvoid slang_texture_usages_dtr (slang_texture_usages *);\r
-\r
-enum\r
-{\r
- SLANG_COMMON_FIXED_MODELVIEWMATRIX,\r
- SLANG_COMMON_FIXED_PROJECTIONMATRIX,\r
- SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIX,\r
- SLANG_COMMON_FIXED_TEXTUREMATRIX,\r
- SLANG_COMMON_FIXED_NORMALMATRIX,\r
- SLANG_COMMON_FIXED_MODELVIEWMATRIXINVERSE,\r
- SLANG_COMMON_FIXED_PROJECTIONMATRIXINVERSE,\r
- SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIXINVERSE,\r
- SLANG_COMMON_FIXED_TEXTUREMATRIXINVERSE,\r
- SLANG_COMMON_FIXED_MODELVIEWMATRIXTRANSPOSE,\r
- SLANG_COMMON_FIXED_PROJECTIONMATRIXTRANSPOSE,\r
- SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIXTRANSPOSE,\r
- SLANG_COMMON_FIXED_TEXTUREMATRIXTRANSPOSE,\r
- SLANG_COMMON_FIXED_MODELVIEWMATRIXINVERSETRANSPOSE,\r
- SLANG_COMMON_FIXED_PROJECTIONMATRIXINVERSETRANSPOSE,\r
- SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIXINVERSETRANSPOSE,\r
- SLANG_COMMON_FIXED_TEXTUREMATRIXINVERSETRANSPOSE,\r
- SLANG_COMMON_FIXED_NORMALSCALE,\r
- SLANG_COMMON_FIXED_DEPTHRANGE,\r
- SLANG_COMMON_FIXED_CLIPPLANE,\r
- SLANG_COMMON_FIXED_POINT,\r
- SLANG_COMMON_FIXED_FRONTMATERIAL,\r
- SLANG_COMMON_FIXED_BACKMATERIAL,\r
- SLANG_COMMON_FIXED_LIGHTSOURCE,\r
- SLANG_COMMON_FIXED_LIGHTMODEL,\r
- SLANG_COMMON_FIXED_FRONTLIGHTMODELPRODUCT,\r
- SLANG_COMMON_FIXED_BACKLIGHTMODELPRODUCT,\r
- SLANG_COMMON_FIXED_FRONTLIGHTPRODUCT,\r
- SLANG_COMMON_FIXED_BACKLIGHTPRODUCT,\r
- SLANG_COMMON_FIXED_TEXTUREENVCOLOR,\r
- SLANG_COMMON_FIXED_EYEPLANES,\r
- SLANG_COMMON_FIXED_EYEPLANET,\r
- SLANG_COMMON_FIXED_EYEPLANER,\r
- SLANG_COMMON_FIXED_EYEPLANEQ,\r
- SLANG_COMMON_FIXED_OBJECTPLANES,\r
- SLANG_COMMON_FIXED_OBJECTPLANET,\r
- SLANG_COMMON_FIXED_OBJECTPLANER,\r
- SLANG_COMMON_FIXED_OBJECTPLANEQ,\r
- SLANG_COMMON_FIXED_FOG,\r
- SLANG_COMMON_FIXED_MAX\r
-};\r
-\r
-enum\r
-{\r
- SLANG_VERTEX_FIXED_POSITION,\r
- SLANG_VERTEX_FIXED_POINTSIZE,\r
- SLANG_VERTEX_FIXED_CLIPVERTEX,\r
- SLANG_VERTEX_FIXED_COLOR,\r
- SLANG_VERTEX_FIXED_SECONDARYCOLOR,\r
- SLANG_VERTEX_FIXED_NORMAL,\r
- SLANG_VERTEX_FIXED_VERTEX,\r
- SLANG_VERTEX_FIXED_MULTITEXCOORD0,\r
- SLANG_VERTEX_FIXED_MULTITEXCOORD1,\r
- SLANG_VERTEX_FIXED_MULTITEXCOORD2,\r
- SLANG_VERTEX_FIXED_MULTITEXCOORD3,\r
- SLANG_VERTEX_FIXED_MULTITEXCOORD4,\r
- SLANG_VERTEX_FIXED_MULTITEXCOORD5,\r
- SLANG_VERTEX_FIXED_MULTITEXCOORD6,\r
- SLANG_VERTEX_FIXED_MULTITEXCOORD7,\r
- SLANG_VERTEX_FIXED_FOGCOORD,\r
- SLANG_VERTEX_FIXED_FRONTCOLOR,\r
- SLANG_VERTEX_FIXED_BACKCOLOR,\r
- SLANG_VERTEX_FIXED_FRONTSECONDARYCOLOR,\r
- SLANG_VERTEX_FIXED_BACKSECONDARYCOLOR,\r
- SLANG_VERTEX_FIXED_TEXCOORD,\r
- SLANG_VERTEX_FIXED_FOGFRAGCOORD,\r
- SLANG_VERTEX_FIXED_MAX\r
-};\r
-\r
-enum\r
-{\r
- SLANG_FRAGMENT_FIXED_FRAGCOORD,\r
- SLANG_FRAGMENT_FIXED_FRONTFACING,\r
- SLANG_FRAGMENT_FIXED_FRAGCOLOR,\r
- SLANG_FRAGMENT_FIXED_FRAGDATA,\r
- SLANG_FRAGMENT_FIXED_FRAGDEPTH,\r
- SLANG_FRAGMENT_FIXED_COLOR,\r
- SLANG_FRAGMENT_FIXED_SECONDARYCOLOR,\r
- SLANG_FRAGMENT_FIXED_TEXCOORD,\r
- SLANG_FRAGMENT_FIXED_FOGFRAGCOORD,\r
- SLANG_FRAGMENT_FIXED_MAX\r
-};\r
-\r
-enum\r
-{\r
- SLANG_COMMON_CODE_MAIN,\r
- SLANG_COMMON_CODE_MAX\r
-};\r
-\r
-typedef struct\r
-{\r
- slang_active_variables active_uniforms;\r
- slang_active_variables active_attribs;\r
- slang_attrib_overrides attrib_overrides;\r
- slang_uniform_bindings uniforms;\r
- slang_attrib_bindings attribs;\r
- slang_varying_bindings varyings;\r
- slang_texture_usages texture_usage;\r
- GLuint common_fixed_entries[SLANG_SHADER_MAX][SLANG_COMMON_FIXED_MAX];\r
- GLuint vertex_fixed_entries[SLANG_VERTEX_FIXED_MAX];\r
- GLuint fragment_fixed_entries[SLANG_FRAGMENT_FIXED_MAX];\r
- GLuint code[SLANG_SHADER_MAX][SLANG_COMMON_CODE_MAX];\r
- slang_machine *machines[SLANG_SHADER_MAX];\r
- slang_assembly_file *assemblies[SLANG_SHADER_MAX];\r
-} slang_program;\r
-\r
-GLvoid slang_program_ctr (slang_program *);\r
-GLvoid slang_program_dtr (slang_program *);\r
-\r
-GLboolean _slang_link (slang_program *, slang_translation_unit **, GLuint);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif\r
-\r
+/*
+ * 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_LINK_H
+#define SLANG_LINK_H
+
+#include "slang_compile.h"
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+enum
+{
+ SLANG_SHADER_VERTEX,
+ SLANG_SHADER_FRAGMENT,
+ SLANG_SHADER_MAX
+};
+
+/* Active variables.
+ *
+ * Active uniforms or attribs can be queried by the application to get a list of uniforms
+ * or attribs actually used by shaders (uniforms) or vertex shader (attribs).
+ */
+
+typedef struct
+{
+ slang_export_data_quant *quant;
+ char *name;
+} slang_active_variable;
+
+typedef struct
+{
+ slang_active_variable *table;
+ GLuint count;
+} slang_active_variables;
+
+/*
+ * Attrib binding override.
+ *
+ * The application can override GL attrib binding by specifying its preferred index assignment
+ * for a given attrib name. Those overrides are taken into account while linking the program.
+ */
+
+typedef struct
+{
+ GLuint index;
+ GLchar *name;
+} slang_attrib_override;
+
+typedef struct
+{
+ slang_attrib_override *table;
+ GLuint count;
+} slang_attrib_overrides;
+
+GLboolean slang_attrib_overrides_add (slang_attrib_overrides *, GLuint, const GLchar *);
+
+/*
+ * Uniform bindings.
+ *
+ * Each slang_uniform_binding holds an array of addresses to actual memory locations in those
+ * shader types that use that uniform. Uniform bindings are held in an array and accessed
+ * by array index which is seen to the application as a uniform location.
+ *
+ * When the application writes to a particular uniform, it specifies its location.
+ * This location is treated as an array index to slang_uniform_bindings::table and tested
+ * against slang_uniform_bindings::count limit. The result is a pointer to slang_uniform_binding.
+ * The type of data being written to uniform is tested against slang_uniform_binding::quant.
+ * If the types are compatible, the array slang_uniform_binding::address is iterated for
+ * each shader type and if the address is valid (i.e. the uniform is used by this shader type),
+ * the new uniform value is written at that address.
+ */
+
+typedef struct
+{
+ slang_export_data_quant *quant;
+ char *name;
+ GLuint address[SLANG_SHADER_MAX];
+} slang_uniform_binding;
+
+typedef struct
+{
+ slang_uniform_binding *table;
+ GLuint count;
+} slang_uniform_bindings;
+
+/*
+ * Attrib bindings.
+ *
+ * There is a fixed number of vertex attrib vectors (attrib slots). The slang_attrib_slot::addr
+ * maps vertex attrib index to the actual memory location of the attrib in vertex shader.
+ * One vertex attrib can span over many attrib slots (this is the case for matrices). The
+ * slang_attrib_binding::first_slot_index holds the first slot index that the attrib is bound to.
+ */
+
+typedef struct
+{
+ slang_export_data_quant *quant;
+ char *name;
+ GLuint first_slot_index;
+} slang_attrib_binding;
+
+typedef struct
+{
+ GLuint addr;
+} slang_attrib_slot;
+
+typedef struct
+{
+ slang_attrib_binding bindings[MAX_VERTEX_ATTRIBS];
+ GLuint binding_count;
+ slang_attrib_slot slots[MAX_VERTEX_ATTRIBS];
+} slang_attrib_bindings;
+
+/*
+ * Varying bindings.
+ *
+ * There is a fixed number of varying floats (varying slots). The slang_varying_slot::vert_addr
+ * maps varying float index to the actual memory location of the output variable in vertex shader.
+ * The slang_varying_slot::frag_addr maps varying float index to the actual memory location of
+ * the input variable in fragment shader.
+ */
+
+typedef struct
+{
+ GLuint vert_addr;
+ GLuint frag_addr;
+} slang_varying_slot;
+
+typedef struct
+{
+ slang_export_data_quant *quant;
+ char *name;
+ GLuint first_slot_index;
+} slang_varying_binding;
+
+typedef struct
+{
+ slang_varying_binding bindings[MAX_VARYING_FLOATS];
+ GLuint binding_count;
+ slang_varying_slot slots[MAX_VARYING_FLOATS];
+ GLuint slot_count;
+} slang_varying_bindings;
+
+/*
+ * Texture usage.
+ *
+ * A slang_texture_usage struct holds indirect information about texture image unit usage. The
+ * slang_texture_usages::table is derived from active uniform table by extracting only uniforms
+ * that are samplers.
+ *
+ * To collect current texture usage one must iterate the slang_texture_usages::table and read
+ * uniform at address slang_texture_usage::frag_address to get texture unit index. This
+ * index, coupled with texture access type (target) taken from slang_texture_usage::quant
+ * forms texture usage for that texture unit.
+ */
+
+typedef struct
+{
+ slang_export_data_quant *quant;
+ GLuint frag_address;
+} slang_texture_usage;
+
+typedef struct
+{
+ slang_texture_usage *table;
+ GLuint count;
+} slang_texture_usages;
+
+GLvoid slang_texture_usages_ctr (slang_texture_usages *);
+GLvoid slang_texture_usages_dtr (slang_texture_usages *);
+
+enum
+{
+ SLANG_COMMON_FIXED_MODELVIEWMATRIX,
+ SLANG_COMMON_FIXED_PROJECTIONMATRIX,
+ SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIX,
+ SLANG_COMMON_FIXED_TEXTUREMATRIX,
+ SLANG_COMMON_FIXED_NORMALMATRIX,
+ SLANG_COMMON_FIXED_MODELVIEWMATRIXINVERSE,
+ SLANG_COMMON_FIXED_PROJECTIONMATRIXINVERSE,
+ SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIXINVERSE,
+ SLANG_COMMON_FIXED_TEXTUREMATRIXINVERSE,
+ SLANG_COMMON_FIXED_MODELVIEWMATRIXTRANSPOSE,
+ SLANG_COMMON_FIXED_PROJECTIONMATRIXTRANSPOSE,
+ SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIXTRANSPOSE,
+ SLANG_COMMON_FIXED_TEXTUREMATRIXTRANSPOSE,
+ SLANG_COMMON_FIXED_MODELVIEWMATRIXINVERSETRANSPOSE,
+ SLANG_COMMON_FIXED_PROJECTIONMATRIXINVERSETRANSPOSE,
+ SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIXINVERSETRANSPOSE,
+ SLANG_COMMON_FIXED_TEXTUREMATRIXINVERSETRANSPOSE,
+ SLANG_COMMON_FIXED_NORMALSCALE,
+ SLANG_COMMON_FIXED_DEPTHRANGE,
+ SLANG_COMMON_FIXED_CLIPPLANE,
+ SLANG_COMMON_FIXED_POINT,
+ SLANG_COMMON_FIXED_FRONTMATERIAL,
+ SLANG_COMMON_FIXED_BACKMATERIAL,
+ SLANG_COMMON_FIXED_LIGHTSOURCE,
+ SLANG_COMMON_FIXED_LIGHTMODEL,
+ SLANG_COMMON_FIXED_FRONTLIGHTMODELPRODUCT,
+ SLANG_COMMON_FIXED_BACKLIGHTMODELPRODUCT,
+ SLANG_COMMON_FIXED_FRONTLIGHTPRODUCT,
+ SLANG_COMMON_FIXED_BACKLIGHTPRODUCT,
+ SLANG_COMMON_FIXED_TEXTUREENVCOLOR,
+ SLANG_COMMON_FIXED_EYEPLANES,
+ SLANG_COMMON_FIXED_EYEPLANET,
+ SLANG_COMMON_FIXED_EYEPLANER,
+ SLANG_COMMON_FIXED_EYEPLANEQ,
+ SLANG_COMMON_FIXED_OBJECTPLANES,
+ SLANG_COMMON_FIXED_OBJECTPLANET,
+ SLANG_COMMON_FIXED_OBJECTPLANER,
+ SLANG_COMMON_FIXED_OBJECTPLANEQ,
+ SLANG_COMMON_FIXED_FOG,
+ SLANG_COMMON_FIXED_MAX
+};
+
+enum
+{
+ SLANG_VERTEX_FIXED_POSITION,
+ SLANG_VERTEX_FIXED_POINTSIZE,
+ SLANG_VERTEX_FIXED_CLIPVERTEX,
+ SLANG_VERTEX_FIXED_COLOR,
+ SLANG_VERTEX_FIXED_SECONDARYCOLOR,
+ SLANG_VERTEX_FIXED_NORMAL,
+ SLANG_VERTEX_FIXED_VERTEX,
+ SLANG_VERTEX_FIXED_MULTITEXCOORD0,
+ SLANG_VERTEX_FIXED_MULTITEXCOORD1,
+ SLANG_VERTEX_FIXED_MULTITEXCOORD2,
+ SLANG_VERTEX_FIXED_MULTITEXCOORD3,
+ SLANG_VERTEX_FIXED_MULTITEXCOORD4,
+ SLANG_VERTEX_FIXED_MULTITEXCOORD5,
+ SLANG_VERTEX_FIXED_MULTITEXCOORD6,
+ SLANG_VERTEX_FIXED_MULTITEXCOORD7,
+ SLANG_VERTEX_FIXED_FOGCOORD,
+ SLANG_VERTEX_FIXED_FRONTCOLOR,
+ SLANG_VERTEX_FIXED_BACKCOLOR,
+ SLANG_VERTEX_FIXED_FRONTSECONDARYCOLOR,
+ SLANG_VERTEX_FIXED_BACKSECONDARYCOLOR,
+ SLANG_VERTEX_FIXED_TEXCOORD,
+ SLANG_VERTEX_FIXED_FOGFRAGCOORD,
+ SLANG_VERTEX_FIXED_MAX
+};
+
+enum
+{
+ SLANG_FRAGMENT_FIXED_FRAGCOORD,
+ SLANG_FRAGMENT_FIXED_FRONTFACING,
+ SLANG_FRAGMENT_FIXED_FRAGCOLOR,
+ SLANG_FRAGMENT_FIXED_FRAGDATA,
+ SLANG_FRAGMENT_FIXED_FRAGDEPTH,
+ SLANG_FRAGMENT_FIXED_COLOR,
+ SLANG_FRAGMENT_FIXED_SECONDARYCOLOR,
+ SLANG_FRAGMENT_FIXED_TEXCOORD,
+ SLANG_FRAGMENT_FIXED_FOGFRAGCOORD,
+ SLANG_FRAGMENT_FIXED_MAX
+};
+
+enum
+{
+ SLANG_COMMON_CODE_MAIN,
+ SLANG_COMMON_CODE_MAX
+};
+
+typedef struct
+{
+ slang_active_variables active_uniforms;
+ slang_active_variables active_attribs;
+ slang_attrib_overrides attrib_overrides;
+ slang_uniform_bindings uniforms;
+ slang_attrib_bindings attribs;
+ slang_varying_bindings varyings;
+ slang_texture_usages texture_usage;
+ GLuint common_fixed_entries[SLANG_SHADER_MAX][SLANG_COMMON_FIXED_MAX];
+ GLuint vertex_fixed_entries[SLANG_VERTEX_FIXED_MAX];
+ GLuint fragment_fixed_entries[SLANG_FRAGMENT_FIXED_MAX];
+ GLuint code[SLANG_SHADER_MAX][SLANG_COMMON_CODE_MAX];
+ slang_machine *machines[SLANG_SHADER_MAX];
+ slang_assembly_file *assemblies[SLANG_SHADER_MAX];
+} slang_program;
+
+GLvoid slang_program_ctr (slang_program *);
+GLvoid slang_program_dtr (slang_program *);
+
+GLboolean _slang_link (slang_program *, slang_translation_unit **, GLuint);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
-/*\r
- * Mesa 3-D graphics library\r
- * Version: 6.5\r
- *\r
- * Copyright (C) 2006 David Airlie All Rights Reserved.\r
- *\r
- * Permission is hereby granted, free of charge, to any person obtaining a\r
- * copy of this software and associated documentation files (the "Software"),\r
- * to deal in the Software without restriction, including without limitation\r
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
- * and/or sell copies of the Software, and to permit persons to whom the\r
- * Software is furnished to do so, subject to the following conditions:\r
- *\r
- * The above copyright notice and this permission notice shall be included\r
- * in all copies or substantial portions of the Software.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\r
- * DAVID AIRLIE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
- */\r
-\r
-\r
-#ifndef S_ARBSHADER_H\r
-#define S_ARBSHADER_H\r
-\r
-#include "s_context.h"\r
-\r
-extern void _swrast_exec_arbshader (GLcontext *ctx, struct sw_span *span);\r
-\r
-#endif\r
-\r
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 2006 David Airlie 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
+ * DAVID AIRLIE 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.
+ */
+
+
+#ifndef S_ARBSHADER_H
+#define S_ARBSHADER_H
+
+#include "s_context.h"
+
+extern void _swrast_exec_arbshader (GLcontext *ctx, struct sw_span *span);
+
+#endif
+
#define INTERP_RGB 1
#define INTERP_ALPHA 1
#define INTERP_SPEC 1
-#define INTERP_MULTITEX 1\r
+#define INTERP_MULTITEX 1
#define INTERP_VARYING 1
#define RENDER_SPAN( span ) _swrast_write_rgba_span(ctx, &span);
#include "s_tritemp.h"
}
}
- if (ctx->Texture._EnabledCoordUnits || ctx->FragmentProgram._Active ||\r
+ if (ctx->Texture._EnabledCoordUnits || ctx->FragmentProgram._Active ||
ctx->ATIFragmentShader._Enabled || ctx->ShaderObjects._FragmentShaderPresent) {
/* Ugh, we do a _lot_ of tests to pick the best textured tri func */
const struct gl_texture_object *texObj2D;
/* First see if we can use an optimized 2-D texture function */
if (ctx->Texture._EnabledCoordUnits == 0x1
&& !ctx->FragmentProgram._Active
- && !ctx->ATIFragmentShader._Enabled\r
+ && !ctx->ATIFragmentShader._Enabled
&& !ctx->ShaderObjects._FragmentShaderPresent
&& ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT
&& texObj2D->WrapS == GL_REPEAT
-/*\r
- * Mesa 3-D graphics library\r
- * Version: 6.5\r
- *\r
- * Copyright (C) 2006 Brian Paul All Rights Reserved.\r
- *\r
- * Permission is hereby granted, free of charge, to any person obtaining a\r
- * copy of this software and associated documentation files (the "Software"),\r
- * to deal in the Software without restriction, including without limitation\r
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
- * and/or sell copies of the Software, and to permit persons to whom the\r
- * Software is furnished to do so, subject to the following conditions:\r
- *\r
- * The above copyright notice and this permission notice shall be included\r
- * in all copies or substantial portions of the Software.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\r
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
- *\r
- * Authors:\r
- * Michal Krol\r
- */\r
-\r
-#include "glheader.h"\r
-#include "imports.h"\r
-#include "macros.h"\r
-#include "shaderobjects.h"\r
-#include "shaderobjects_3dlabs.h"\r
-#include "t_pipeline.h"\r
-#include "slang_utility.h"\r
-#include "slang_link.h"\r
-\r
-typedef struct\r
-{\r
- GLvector4f outputs[VERT_RESULT_MAX];\r
- GLvector4f varyings[MAX_VARYING_VECTORS];\r
- GLvector4f ndc_coords;\r
- GLubyte *clipmask;\r
- GLubyte ormask;\r
- GLubyte andmask;\r
-} arbvs_stage_data;\r
-\r
-#define ARBVS_STAGE_DATA(stage) ((arbvs_stage_data *) stage->privatePtr)\r
-\r
-static GLboolean construct_arb_vertex_shader (GLcontext *ctx, struct tnl_pipeline_stage *stage)\r
-{\r
- TNLcontext *tnl = TNL_CONTEXT(ctx);\r
- struct vertex_buffer *vb = &tnl->vb;\r
- arbvs_stage_data *store;\r
- GLuint size = vb->Size;\r
- GLuint i;\r
-\r
- stage->privatePtr = _mesa_malloc (sizeof (arbvs_stage_data));\r
- store = ARBVS_STAGE_DATA(stage);\r
- if (store == NULL)\r
- return GL_FALSE;\r
-\r
- for (i = 0; i < VERT_RESULT_MAX; i++)\r
- {\r
- _mesa_vector4f_alloc (&store->outputs[i], 0, size, 32);\r
- store->outputs[i].size = 4;\r
- }\r
- for (i = 0; i < MAX_VARYING_VECTORS; i++)\r
- {\r
- _mesa_vector4f_alloc (&store->varyings[i], 0, size, 32);\r
- store->varyings[i].size = 4;\r
- }\r
- _mesa_vector4f_alloc (&store->ndc_coords, 0, size, 32);\r
- store->clipmask = (GLubyte *) ALIGN_MALLOC (size, 32);\r
-\r
- return GL_TRUE;\r
-}\r
-\r
-static void destruct_arb_vertex_shader (struct tnl_pipeline_stage *stage)\r
-{\r
- arbvs_stage_data *store = ARBVS_STAGE_DATA(stage);\r
-\r
- if (store != NULL)\r
- {\r
- GLuint i;\r
-\r
- for (i = 0; i < VERT_RESULT_MAX; i++)\r
- _mesa_vector4f_free (&store->outputs[i]);\r
- for (i = 0; i < MAX_VARYING_VECTORS; i++)\r
- _mesa_vector4f_free (&store->varyings[i]);\r
- _mesa_vector4f_free (&store->ndc_coords);\r
- ALIGN_FREE (store->clipmask);\r
-\r
- _mesa_free (store);\r
- stage->privatePtr = NULL;\r
- }\r
-}\r
-\r
-static void validate_arb_vertex_shader (GLcontext *ctx, struct tnl_pipeline_stage *stage)\r
-{\r
-}\r
-\r
-static GLvoid fetch_input_float (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i,\r
- struct vertex_buffer *vb)\r
-{\r
- const GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data;\r
- const GLuint stride = vb->AttribPtr[attr]->stride;\r
- const GLfloat *data = (const GLfloat *) (ptr + stride * i);\r
- GLfloat vec[1];\r
-\r
- vec[0] = data[0];\r
- (**pro).UpdateFixedAttribute (pro, index, vec, 0, sizeof (GLfloat), GL_TRUE);\r
-}\r
-\r
-static GLvoid fetch_input_vec3 (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i,\r
- struct vertex_buffer *vb)\r
-{\r
- const GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data;\r
- const GLuint stride = vb->AttribPtr[attr]->stride;\r
- const GLfloat *data = (const GLfloat *) (ptr + stride * i);\r
- GLfloat vec[3];\r
-\r
- vec[0] = data[0];\r
- vec[1] = data[1];\r
- vec[2] = data[2];\r
- (**pro).UpdateFixedAttribute (pro, index, vec, 0, 3 * sizeof (GLfloat), GL_TRUE);\r
-}\r
-\r
-static void fetch_input_vec4 (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i,\r
- struct vertex_buffer *vb)\r
-{\r
- const GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data;\r
- const GLuint size = vb->AttribPtr[attr]->size;\r
- const GLuint stride = vb->AttribPtr[attr]->stride;\r
- const GLfloat *data = (const GLfloat *) (ptr + stride * i);\r
- GLfloat vec[4];\r
-\r
- switch (size)\r
- {\r
- case 2:\r
- vec[0] = data[0];\r
- vec[1] = data[1];\r
- vec[2] = 0.0f;\r
- vec[3] = 1.0f;\r
- break;\r
- case 3:\r
- vec[0] = data[0];\r
- vec[1] = data[1];\r
- vec[2] = data[2];\r
- vec[3] = 1.0f;\r
- break;\r
- case 4:\r
- vec[0] = data[0];\r
- vec[1] = data[1];\r
- vec[2] = data[2];\r
- vec[3] = data[3];\r
- break;\r
- }\r
- (**pro).UpdateFixedAttribute (pro, index, vec, 0, 4 * sizeof (GLfloat), GL_TRUE);\r
-}\r
-\r
-static GLvoid fetch_output_float (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i,\r
- arbvs_stage_data *store)\r
-{\r
- (**pro).UpdateFixedAttribute (pro, index, &store->outputs[attr].data[i], 0, sizeof (GLfloat),\r
- GL_FALSE);\r
-}\r
-\r
-static void fetch_output_vec4 (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i,\r
- GLuint offset, arbvs_stage_data *store)\r
-{\r
- (**pro).UpdateFixedAttribute (pro, index, &store->outputs[attr].data[i], offset,\r
- 4 * sizeof (GLfloat), GL_FALSE);\r
-}\r
-\r
-static GLboolean run_arb_vertex_shader (GLcontext *ctx, struct tnl_pipeline_stage *stage)\r
-{\r
- TNLcontext *tnl = TNL_CONTEXT(ctx);\r
- struct vertex_buffer *vb = &tnl->vb;\r
- arbvs_stage_data *store = ARBVS_STAGE_DATA(stage);\r
- struct gl2_program_intf **pro;\r
- GLsizei i, j;\r
-\r
- if (!ctx->ShaderObjects._VertexShaderPresent)\r
- return GL_TRUE;\r
-\r
- pro = ctx->ShaderObjects.CurrentProgram;\r
- (**pro).UpdateFixedUniforms (pro);\r
-\r
- for (i = 0; i < vb->Count; i++)\r
- {\r
- fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_VERTEX, _TNL_ATTRIB_POS, i, vb);\r
- fetch_input_vec3 (pro, SLANG_VERTEX_FIXED_NORMAL, _TNL_ATTRIB_NORMAL, i, vb);\r
- fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_COLOR, _TNL_ATTRIB_COLOR0, i, vb);\r
- fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_SECONDARYCOLOR, _TNL_ATTRIB_COLOR1, i, vb);\r
- fetch_input_float (pro, SLANG_VERTEX_FIXED_FOGCOORD, _TNL_ATTRIB_FOG, i, vb);\r
- fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD0, _TNL_ATTRIB_TEX0, i, vb);\r
- fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD1, _TNL_ATTRIB_TEX1, i, vb);\r
- fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD2, _TNL_ATTRIB_TEX2, i, vb);\r
- fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD3, _TNL_ATTRIB_TEX3, i, vb);\r
- fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD4, _TNL_ATTRIB_TEX4, i, vb);\r
- fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD5, _TNL_ATTRIB_TEX5, i, vb);\r
- fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD6, _TNL_ATTRIB_TEX6, i, vb);\r
- fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD7, _TNL_ATTRIB_TEX7, i, vb);\r
-\r
- _slang_exec_vertex_shader (pro);\r
-\r
- fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_POSITION, VERT_RESULT_HPOS, i, 0, store);\r
- fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_FRONTCOLOR, VERT_RESULT_COL0, i, 0, store);\r
- fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_FRONTSECONDARYCOLOR, VERT_RESULT_COL1, i, 0, store);\r
- fetch_output_float (pro, SLANG_VERTEX_FIXED_FOGFRAGCOORD, VERT_RESULT_FOGC, i, store);\r
- for (j = 0; j < 8; j++)\r
- fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_TEXCOORD, VERT_RESULT_TEX0 + j, i, j, store);\r
- fetch_output_float (pro, SLANG_VERTEX_FIXED_POINTSIZE, VERT_RESULT_PSIZ, i, store);\r
- fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_BACKCOLOR, VERT_RESULT_BFC0, i, 0, store);\r
- fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_BACKSECONDARYCOLOR, VERT_RESULT_BFC1, i, 0, store);\r
- /* XXX: fetch output SLANG_VERTEX_FIXED_CLIPVERTEX */\r
-\r
- for (j = 0; j < MAX_VARYING_VECTORS; j++)\r
- {\r
- GLuint k;\r
-\r
- for (k = 0; k < VARYINGS_PER_VECTOR; k++)\r
- {\r
- (**pro).UpdateVarying (pro, j * VARYINGS_PER_VECTOR + k,\r
- &store->varyings[j].data[i][k], GL_TRUE);\r
- }\r
- }\r
- }\r
-\r
- vb->ClipPtr = &store->outputs[VERT_RESULT_HPOS];\r
- vb->ClipPtr->count = vb->Count;\r
- vb->ColorPtr[0] = &store->outputs[VERT_RESULT_COL0];\r
- vb->SecondaryColorPtr[0] = &store->outputs[VERT_RESULT_COL1];\r
- for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++)\r
- vb->TexCoordPtr[i] = &store->outputs[VERT_RESULT_TEX0 + i];\r
- vb->ColorPtr[1] = &store->outputs[VERT_RESULT_BFC0];\r
- vb->SecondaryColorPtr[1] = &store->outputs[VERT_RESULT_BFC1];\r
- vb->FogCoordPtr = &store->outputs[VERT_RESULT_FOGC];\r
- vb->PointSizePtr = &store->outputs[VERT_RESULT_PSIZ];\r
- for (i = 0; i < MAX_VARYING_VECTORS; i++)\r
- vb->VaryingPtr[i] = &store->varyings[i];\r
-\r
- vb->AttribPtr[VERT_ATTRIB_COLOR0] = vb->ColorPtr[0];\r
- vb->AttribPtr[VERT_ATTRIB_COLOR1] = vb->SecondaryColorPtr[0];\r
- vb->AttribPtr[VERT_ATTRIB_FOG] = vb->FogCoordPtr;\r
- for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++)\r
- vb->AttribPtr[VERT_ATTRIB_TEX0 + i] = vb->TexCoordPtr[i];\r
- vb->AttribPtr[_TNL_ATTRIB_POINTSIZE] = &store->outputs[VERT_RESULT_PSIZ];\r
- for (i = 0; i < MAX_VARYING_VECTORS; i++)\r
- vb->AttribPtr[_TNL_ATTRIB_ATTRIBUTE0 + i] = vb->VaryingPtr[i];\r
-\r
- store->ormask = 0;\r
- store->andmask = CLIP_FRUSTUM_BITS;\r
-\r
- if (tnl->NeedNdcCoords)\r
- {\r
- vb->NdcPtr = _mesa_clip_tab[vb->ClipPtr->size] (vb->ClipPtr, &store->ndc_coords,\r
- store->clipmask, &store->ormask, &store->andmask);\r
- }\r
- else\r
- {\r
- vb->NdcPtr = NULL;\r
- _mesa_clip_np_tab[vb->ClipPtr->size] (vb->ClipPtr, NULL, store->clipmask, &store->ormask,\r
- &store->andmask);\r
- }\r
-\r
- if (store->andmask)\r
- return GL_FALSE;\r
-\r
- vb->ClipAndMask = store->andmask;\r
- vb->ClipOrMask = store->ormask;\r
- vb->ClipMask = store->clipmask;\r
-\r
- return GL_TRUE;\r
-}\r
-\r
-const struct tnl_pipeline_stage _tnl_arb_vertex_shader_stage = {\r
- "ARB_vertex_shader",\r
- NULL,\r
- construct_arb_vertex_shader,\r
- destruct_arb_vertex_shader,\r
- validate_arb_vertex_shader,\r
- run_arb_vertex_shader\r
-};\r
-\r
+/*
+ * 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.
+ *
+ * Authors:
+ * Michal Krol
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "macros.h"
+#include "shaderobjects.h"
+#include "shaderobjects_3dlabs.h"
+#include "t_pipeline.h"
+#include "slang_utility.h"
+#include "slang_link.h"
+
+typedef struct
+{
+ GLvector4f outputs[VERT_RESULT_MAX];
+ GLvector4f varyings[MAX_VARYING_VECTORS];
+ GLvector4f ndc_coords;
+ GLubyte *clipmask;
+ GLubyte ormask;
+ GLubyte andmask;
+} arbvs_stage_data;
+
+#define ARBVS_STAGE_DATA(stage) ((arbvs_stage_data *) stage->privatePtr)
+
+static GLboolean construct_arb_vertex_shader (GLcontext *ctx, struct tnl_pipeline_stage *stage)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *vb = &tnl->vb;
+ arbvs_stage_data *store;
+ GLuint size = vb->Size;
+ GLuint i;
+
+ stage->privatePtr = _mesa_malloc (sizeof (arbvs_stage_data));
+ store = ARBVS_STAGE_DATA(stage);
+ if (store == NULL)
+ return GL_FALSE;
+
+ for (i = 0; i < VERT_RESULT_MAX; i++)
+ {
+ _mesa_vector4f_alloc (&store->outputs[i], 0, size, 32);
+ store->outputs[i].size = 4;
+ }
+ for (i = 0; i < MAX_VARYING_VECTORS; i++)
+ {
+ _mesa_vector4f_alloc (&store->varyings[i], 0, size, 32);
+ store->varyings[i].size = 4;
+ }
+ _mesa_vector4f_alloc (&store->ndc_coords, 0, size, 32);
+ store->clipmask = (GLubyte *) ALIGN_MALLOC (size, 32);
+
+ return GL_TRUE;
+}
+
+static void destruct_arb_vertex_shader (struct tnl_pipeline_stage *stage)
+{
+ arbvs_stage_data *store = ARBVS_STAGE_DATA(stage);
+
+ if (store != NULL)
+ {
+ GLuint i;
+
+ for (i = 0; i < VERT_RESULT_MAX; i++)
+ _mesa_vector4f_free (&store->outputs[i]);
+ for (i = 0; i < MAX_VARYING_VECTORS; i++)
+ _mesa_vector4f_free (&store->varyings[i]);
+ _mesa_vector4f_free (&store->ndc_coords);
+ ALIGN_FREE (store->clipmask);
+
+ _mesa_free (store);
+ stage->privatePtr = NULL;
+ }
+}
+
+static void validate_arb_vertex_shader (GLcontext *ctx, struct tnl_pipeline_stage *stage)
+{
+}
+
+static GLvoid fetch_input_float (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i,
+ struct vertex_buffer *vb)
+{
+ const GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data;
+ const GLuint stride = vb->AttribPtr[attr]->stride;
+ const GLfloat *data = (const GLfloat *) (ptr + stride * i);
+ GLfloat vec[1];
+
+ vec[0] = data[0];
+ (**pro).UpdateFixedAttribute (pro, index, vec, 0, sizeof (GLfloat), GL_TRUE);
+}
+
+static GLvoid fetch_input_vec3 (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i,
+ struct vertex_buffer *vb)
+{
+ const GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data;
+ const GLuint stride = vb->AttribPtr[attr]->stride;
+ const GLfloat *data = (const GLfloat *) (ptr + stride * i);
+ GLfloat vec[3];
+
+ vec[0] = data[0];
+ vec[1] = data[1];
+ vec[2] = data[2];
+ (**pro).UpdateFixedAttribute (pro, index, vec, 0, 3 * sizeof (GLfloat), GL_TRUE);
+}
+
+static void fetch_input_vec4 (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i,
+ struct vertex_buffer *vb)
+{
+ const GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data;
+ const GLuint size = vb->AttribPtr[attr]->size;
+ const GLuint stride = vb->AttribPtr[attr]->stride;
+ const GLfloat *data = (const GLfloat *) (ptr + stride * i);
+ GLfloat vec[4];
+
+ switch (size)
+ {
+ case 2:
+ vec[0] = data[0];
+ vec[1] = data[1];
+ vec[2] = 0.0f;
+ vec[3] = 1.0f;
+ break;
+ case 3:
+ vec[0] = data[0];
+ vec[1] = data[1];
+ vec[2] = data[2];
+ vec[3] = 1.0f;
+ break;
+ case 4:
+ vec[0] = data[0];
+ vec[1] = data[1];
+ vec[2] = data[2];
+ vec[3] = data[3];
+ break;
+ }
+ (**pro).UpdateFixedAttribute (pro, index, vec, 0, 4 * sizeof (GLfloat), GL_TRUE);
+}
+
+static GLvoid fetch_output_float (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i,
+ arbvs_stage_data *store)
+{
+ (**pro).UpdateFixedAttribute (pro, index, &store->outputs[attr].data[i], 0, sizeof (GLfloat),
+ GL_FALSE);
+}
+
+static void fetch_output_vec4 (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i,
+ GLuint offset, arbvs_stage_data *store)
+{
+ (**pro).UpdateFixedAttribute (pro, index, &store->outputs[attr].data[i], offset,
+ 4 * sizeof (GLfloat), GL_FALSE);
+}
+
+static GLboolean run_arb_vertex_shader (GLcontext *ctx, struct tnl_pipeline_stage *stage)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *vb = &tnl->vb;
+ arbvs_stage_data *store = ARBVS_STAGE_DATA(stage);
+ struct gl2_program_intf **pro;
+ GLsizei i, j;
+
+ if (!ctx->ShaderObjects._VertexShaderPresent)
+ return GL_TRUE;
+
+ pro = ctx->ShaderObjects.CurrentProgram;
+ (**pro).UpdateFixedUniforms (pro);
+
+ for (i = 0; i < vb->Count; i++)
+ {
+ fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_VERTEX, _TNL_ATTRIB_POS, i, vb);
+ fetch_input_vec3 (pro, SLANG_VERTEX_FIXED_NORMAL, _TNL_ATTRIB_NORMAL, i, vb);
+ fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_COLOR, _TNL_ATTRIB_COLOR0, i, vb);
+ fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_SECONDARYCOLOR, _TNL_ATTRIB_COLOR1, i, vb);
+ fetch_input_float (pro, SLANG_VERTEX_FIXED_FOGCOORD, _TNL_ATTRIB_FOG, i, vb);
+ fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD0, _TNL_ATTRIB_TEX0, i, vb);
+ fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD1, _TNL_ATTRIB_TEX1, i, vb);
+ fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD2, _TNL_ATTRIB_TEX2, i, vb);
+ fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD3, _TNL_ATTRIB_TEX3, i, vb);
+ fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD4, _TNL_ATTRIB_TEX4, i, vb);
+ fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD5, _TNL_ATTRIB_TEX5, i, vb);
+ fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD6, _TNL_ATTRIB_TEX6, i, vb);
+ fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD7, _TNL_ATTRIB_TEX7, i, vb);
+
+ _slang_exec_vertex_shader (pro);
+
+ fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_POSITION, VERT_RESULT_HPOS, i, 0, store);
+ fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_FRONTCOLOR, VERT_RESULT_COL0, i, 0, store);
+ fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_FRONTSECONDARYCOLOR, VERT_RESULT_COL1, i, 0, store);
+ fetch_output_float (pro, SLANG_VERTEX_FIXED_FOGFRAGCOORD, VERT_RESULT_FOGC, i, store);
+ for (j = 0; j < 8; j++)
+ fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_TEXCOORD, VERT_RESULT_TEX0 + j, i, j, store);
+ fetch_output_float (pro, SLANG_VERTEX_FIXED_POINTSIZE, VERT_RESULT_PSIZ, i, store);
+ fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_BACKCOLOR, VERT_RESULT_BFC0, i, 0, store);
+ fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_BACKSECONDARYCOLOR, VERT_RESULT_BFC1, i, 0, store);
+ /* XXX: fetch output SLANG_VERTEX_FIXED_CLIPVERTEX */
+
+ for (j = 0; j < MAX_VARYING_VECTORS; j++)
+ {
+ GLuint k;
+
+ for (k = 0; k < VARYINGS_PER_VECTOR; k++)
+ {
+ (**pro).UpdateVarying (pro, j * VARYINGS_PER_VECTOR + k,
+ &store->varyings[j].data[i][k], GL_TRUE);
+ }
+ }
+ }
+
+ vb->ClipPtr = &store->outputs[VERT_RESULT_HPOS];
+ vb->ClipPtr->count = vb->Count;
+ vb->ColorPtr[0] = &store->outputs[VERT_RESULT_COL0];
+ vb->SecondaryColorPtr[0] = &store->outputs[VERT_RESULT_COL1];
+ for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++)
+ vb->TexCoordPtr[i] = &store->outputs[VERT_RESULT_TEX0 + i];
+ vb->ColorPtr[1] = &store->outputs[VERT_RESULT_BFC0];
+ vb->SecondaryColorPtr[1] = &store->outputs[VERT_RESULT_BFC1];
+ vb->FogCoordPtr = &store->outputs[VERT_RESULT_FOGC];
+ vb->PointSizePtr = &store->outputs[VERT_RESULT_PSIZ];
+ for (i = 0; i < MAX_VARYING_VECTORS; i++)
+ vb->VaryingPtr[i] = &store->varyings[i];
+
+ vb->AttribPtr[VERT_ATTRIB_COLOR0] = vb->ColorPtr[0];
+ vb->AttribPtr[VERT_ATTRIB_COLOR1] = vb->SecondaryColorPtr[0];
+ vb->AttribPtr[VERT_ATTRIB_FOG] = vb->FogCoordPtr;
+ for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++)
+ vb->AttribPtr[VERT_ATTRIB_TEX0 + i] = vb->TexCoordPtr[i];
+ vb->AttribPtr[_TNL_ATTRIB_POINTSIZE] = &store->outputs[VERT_RESULT_PSIZ];
+ for (i = 0; i < MAX_VARYING_VECTORS; i++)
+ vb->AttribPtr[_TNL_ATTRIB_ATTRIBUTE0 + i] = vb->VaryingPtr[i];
+
+ store->ormask = 0;
+ store->andmask = CLIP_FRUSTUM_BITS;
+
+ if (tnl->NeedNdcCoords)
+ {
+ vb->NdcPtr = _mesa_clip_tab[vb->ClipPtr->size] (vb->ClipPtr, &store->ndc_coords,
+ store->clipmask, &store->ormask, &store->andmask);
+ }
+ else
+ {
+ vb->NdcPtr = NULL;
+ _mesa_clip_np_tab[vb->ClipPtr->size] (vb->ClipPtr, NULL, store->clipmask, &store->ormask,
+ &store->andmask);
+ }
+
+ if (store->andmask)
+ return GL_FALSE;
+
+ vb->ClipAndMask = store->andmask;
+ vb->ClipOrMask = store->ormask;
+ vb->ClipMask = store->clipmask;
+
+ return GL_TRUE;
+}
+
+const struct tnl_pipeline_stage _tnl_arb_vertex_shader_stage = {
+ "ARB_vertex_shader",
+ NULL,
+ construct_arb_vertex_shader,
+ destruct_arb_vertex_shader,
+ validate_arb_vertex_shader,
+ run_arb_vertex_shader
+};
+
case mod_INDIRECT:
break;
case mod_DISP8:
- emit_1b(p, regmem.disp);\r
+ emit_1b(p, regmem.disp);
break;
case mod_DISP32:
- emit_1i(p, regmem.disp);\r
+ emit_1i(p, regmem.disp);
break;
default:
assert(0);
emit_2ub(p, 0x0f, 0x80 + cc);
emit_1i(p, 0);
return x86_get_label(p);
-}\r
-\r
-GLubyte *x86_jmp_forward( struct x86_function *p)\r
-{\r
- emit_1ub(p, 0xe9);\r
- emit_1i(p, 0);\r
- return x86_get_label(p);\r
-}\r
-\r
-GLubyte *x86_call_forward( struct x86_function *p)\r
-{\r
- emit_1ub(p, 0xe8);\r
- emit_1i(p, 0);\r
- return x86_get_label(p);\r
+}
+
+GLubyte *x86_jmp_forward( struct x86_function *p)
+{
+ emit_1ub(p, 0xe9);
+ emit_1i(p, 0);
+ return x86_get_label(p);
+}
+
+GLubyte *x86_call_forward( struct x86_function *p)
+{
+ emit_1ub(p, 0xe8);
+ emit_1i(p, 0);
+ return x86_get_label(p);
}
/* Fixup offset from forward jump:
GLubyte *fixup )
{
*(int *)(fixup - 4) = x86_get_label(p) - fixup;
-}\r
-\r
-void x86_jmp( struct x86_function *p, GLubyte *label)\r
-{\r
- emit_1ub(p, 0xe9);\r
- emit_1i(p, label - x86_get_label(p) - 4);\r
-}\r
-\r
-void x86_call( struct x86_function *p, GLubyte *label)\r
-{\r
- emit_1ub(p, 0xe8);\r
- emit_1i(p, label - x86_get_label(p) - 4);\r
-}\r
-\r
-/* michal:\r
- * Temporary. As I need immediate operands, and dont want to mess with the codegen,\r
- * I load the immediate into general purpose register and use it.\r
- */\r
-void x86_mov_reg_imm( struct x86_function *p, struct x86_reg dst, GLint imm )\r
-{\r
- assert(dst.mod == mod_REG);\r
- emit_1ub(p, 0xb8 + dst.idx);\r
- emit_1i(p, imm);\r
+}
+
+void x86_jmp( struct x86_function *p, GLubyte *label)
+{
+ emit_1ub(p, 0xe9);
+ emit_1i(p, label - x86_get_label(p) - 4);
+}
+
+void x86_call( struct x86_function *p, GLubyte *label)
+{
+ emit_1ub(p, 0xe8);
+ emit_1i(p, label - x86_get_label(p) - 4);
+}
+
+/* michal:
+ * Temporary. As I need immediate operands, and dont want to mess with the codegen,
+ * I load the immediate into general purpose register and use it.
+ */
+void x86_mov_reg_imm( struct x86_function *p, struct x86_reg dst, GLint imm )
+{
+ assert(dst.mod == mod_REG);
+ emit_1ub(p, 0xb8 + dst.idx);
+ emit_1i(p, imm);
}
void x86_push( struct x86_function *p,
{
emit_1ub(p, 0x85);
emit_modrm( p, dst, src );
-}\r
-\r
-void x86_add( struct x86_function *p,\r
- struct x86_reg dst,\r
- struct x86_reg src )\r
-{\r
- emit_op_modrm(p, 0x03, 0x01, dst, src );\r
-}\r
-\r
-void x86_mul( struct x86_function *p,\r
- struct x86_reg src )\r
-{\r
- assert (src.file == file_REG32 && src.mod == mod_REG);\r
- emit_op_modrm(p, 0xf7, 0, x86_make_reg (file_REG32, reg_SP), src );\r
-}\r
-\r
-void x86_sub( struct x86_function *p,\r
- struct x86_reg dst,\r
- struct x86_reg src )\r
-{\r
- emit_op_modrm(p, 0x2b, 0x29, dst, src );\r
+}
+
+void x86_add( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_op_modrm(p, 0x03, 0x01, dst, src );
+}
+
+void x86_mul( struct x86_function *p,
+ struct x86_reg src )
+{
+ assert (src.file == file_REG32 && src.mod == mod_REG);
+ emit_op_modrm(p, 0xf7, 0, x86_make_reg (file_REG32, reg_SP), src );
+}
+
+void x86_sub( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_op_modrm(p, 0x2b, 0x29, dst, src );
}
void x86_init_func( struct x86_function *p )
{
x86_init_func_size(p, 1024);
-}\r
-\r
-void x86_init_func_size( struct x86_function *p, GLuint code_size )\r
-{\r
- p->store = _mesa_exec_malloc(code_size);\r
- p->csr = p->store;\r
+}
+
+void x86_init_func_size( struct x86_function *p, GLuint code_size )
+{
+ p->store = _mesa_exec_malloc(code_size);
+ p->csr = p->store;
}
void x86_release_func( struct x86_function *p )
*/
-void x86_init_func( struct x86_function *p );\r
+void x86_init_func( struct x86_function *p );
void x86_init_func_size( struct x86_function *p, GLuint code_size );
void x86_release_func( struct x86_function *p );
void (*x86_get_func( struct x86_function *p ))( void );
GLubyte *label );
GLubyte *x86_jcc_forward( struct x86_function *p,
- enum x86_cc cc );\r
-\r
-GLubyte *x86_jmp_forward( struct x86_function *p);\r
-\r
+ enum x86_cc cc );
+
+GLubyte *x86_jmp_forward( struct x86_function *p);
+
GLubyte *x86_call_forward( struct x86_function *p);
void x86_fixup_fwd_jump( struct x86_function *p,
- GLubyte *fixup );\r
-\r
-void x86_jmp( struct x86_function *p, GLubyte *label );\r
-\r
-void x86_call( struct x86_function *p, GLubyte *label );\r
-\r
-/* michal:\r
- * Temporary. As I need immediate operands, and dont want to mess with the codegen,\r
- * I load the immediate into general purpose register and use it.\r
- */\r
+ GLubyte *fixup );
+
+void x86_jmp( struct x86_function *p, GLubyte *label );
+
+void x86_call( struct x86_function *p, GLubyte *label );
+
+/* michal:
+ * Temporary. As I need immediate operands, and dont want to mess with the codegen,
+ * I load the immediate into general purpose register and use it.
+ */
void x86_mov_reg_imm( struct x86_function *p, struct x86_reg dst, GLint imm );
void sse_subps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void sse_rsqrtss( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void sse_shufps( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, GLubyte shuf );
-\r
+
void x86_add( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void x86_cmp( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void x86_dec( struct x86_function *p, struct x86_reg reg );
void x86_inc( struct x86_function *p, struct x86_reg reg );
void x86_lea( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
-void x86_mov( struct x86_function *p, struct x86_reg dst, struct x86_reg src );\r
+void x86_mov( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void x86_mul( struct x86_function *p, struct x86_reg src );
void x86_pop( struct x86_function *p, struct x86_reg reg );
void x86_push( struct x86_function *p, struct x86_reg reg );
-void x86_ret( struct x86_function *p );\r
+void x86_ret( struct x86_function *p );
void x86_sub( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void x86_test( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void x86_xor( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
# ADD LINK32 mesa.lib winmm.lib msvcrt.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /nodefaultlib /out:"Release_x86/OPENGL32.DLL" /libpath:"../mesa/Release_x86"\r
# Begin Special Build Tool\r
SOURCE="$(InputPath)"\r
-PostBuild_Cmds=if not exist ..\..\..\..\lib md ..\..\..\..\lib copy Release_x86\OPENGL32.LIB ..\..\..\..\lib copy Release_x86\OPENGL32.DLL ..\..\..\..\lib if exist ..\..\..\..\progs\demos copy Release_x86\OPENGL32.DLL ..\..\..\..\progs\demos\r
+PostBuild_Cmds=if not exist ..\..\..\..\lib md ..\..\..\..\lib copy Release_x86\OPENGL32.LIB ..\..\..\..\lib copy Release_x86\OPENGL32.DLL ..\..\..\..\lib if exist ..\..\..\..\progs\demos copy Release_x86\OPENGL32.DLL ..\..\..\..\progs\demos copy Release_x86\OPENGL32.DLL "C:\Documents and Settings\mjk\Pulpit\pen\noise-demo"\r
# End Special Build Tool\r
\r
!ELSEIF "$(CFG)" == "gdi - Win32 Debug x86"\r
# ADD LINK32 mesa.lib winmm.lib msvcrtd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /debug /machine:I386 /nodefaultlib /out:"Debug_x86/OPENGL32.DLL" /pdbtype:sept /libpath:"../mesa/Debug_x86"\r
# Begin Special Build Tool\r
SOURCE="$(InputPath)"\r
-PostBuild_Cmds=if not exist ..\..\..\..\lib md ..\..\..\..\lib copy Debug_x86\OPENGL32.LIB ..\..\..\..\lib copy Debug_x86\OPENGL32.DLL ..\..\..\..\lib if exist ..\..\..\..\progs\demos copy Debug_x86\OPENGL32.DLL ..\..\..\..\progs\demos\r
+PostBuild_Cmds=if not exist ..\..\..\..\lib md ..\..\..\..\lib copy Debug_x86\OPENGL32.LIB ..\..\..\..\lib copy Debug_x86\OPENGL32.DLL ..\..\..\..\lib if exist ..\..\..\..\progs\demos copy Debug_x86\OPENGL32.DLL ..\..\..\..\progs\demos copy Debug_x86\OPENGL32.DLL "C:\Documents and Settings\mjk\Pulpit\pen\noise-demo"\r
# End Special Build Tool\r
\r
!ENDIF \r