summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader/slang
diff options
context:
space:
mode:
authorMichal Krol <[email protected]>2006-02-27 14:41:41 +0000
committerMichal Krol <[email protected]>2006-02-27 14:41:41 +0000
commit9ac9605de156408580b81ba7e2780bd3f5372c6d (patch)
treee0dfe1127ed3b7f9674c450dea59b921e84c4dfc /src/mesa/shader/slang
parentc56f2c49a51e7ad1106c46e3e86dfe2756ef87c4 (diff)
More GLSL code:
- add x86 code generator; - add full support for uniforms in ARB_shader_objects; - add assembly instruction: global_addr; - reorganize #includes; - built-in uniforms accessed by index, rather than by name; - add some entries to x86sse rtasm; - add configurations to VC6 projects: 'Release x86' and 'Debug x86'; - #define SLANG_X86 active only on VC6 x86 builds; - introduce code export table for a shader; - remove GNU license from the noise library;
Diffstat (limited to 'src/mesa/shader/slang')
-rw-r--r--src/mesa/shader/slang/slang_assemble.c8
-rw-r--r--src/mesa/shader/slang/slang_assemble.h27
-rw-r--r--src/mesa/shader/slang/slang_assemble_assignment.c5
-rw-r--r--src/mesa/shader/slang/slang_assemble_assignment.h6
-rw-r--r--src/mesa/shader/slang/slang_assemble_conditional.c4
-rw-r--r--src/mesa/shader/slang/slang_assemble_conditional.h16
-rw-r--r--src/mesa/shader/slang/slang_assemble_constructor.c4
-rw-r--r--src/mesa/shader/slang/slang_assemble_constructor.h5
-rw-r--r--src/mesa/shader/slang/slang_assemble_typeinfo.c91
-rw-r--r--src/mesa/shader/slang/slang_assemble_typeinfo.h53
-rw-r--r--src/mesa/shader/slang/slang_compile.c70
-rw-r--r--src/mesa/shader/slang/slang_compile.h12
-rw-r--r--src/mesa/shader/slang/slang_compile_function.c50
-rw-r--r--src/mesa/shader/slang/slang_compile_function.h3
-rw-r--r--src/mesa/shader/slang/slang_compile_operation.c4
-rw-r--r--src/mesa/shader/slang/slang_compile_struct.c4
-rw-r--r--src/mesa/shader/slang/slang_compile_variable.c194
-rw-r--r--src/mesa/shader/slang/slang_compile_variable.h61
-rw-r--r--src/mesa/shader/slang/slang_execute.c32
-rw-r--r--src/mesa/shader/slang/slang_execute.h18
-rw-r--r--src/mesa/shader/slang/slang_execute_x86.c536
-rw-r--r--src/mesa/shader/slang/slang_export.c51
-rw-r--r--src/mesa/shader/slang/slang_export.h29
-rw-r--r--src/mesa/shader/slang/slang_library_noise.c20
-rw-r--r--src/mesa/shader/slang/slang_link.c243
-rw-r--r--src/mesa/shader/slang/slang_link.h115
-rw-r--r--src/mesa/shader/slang/slang_preprocess.c2
-rw-r--r--src/mesa/shader/slang/slang_preprocess.h6
-rw-r--r--src/mesa/shader/slang/slang_storage.c3
-rw-r--r--src/mesa/shader/slang/slang_storage.h2
-rw-r--r--src/mesa/shader/slang/slang_utility.h4
31 files changed, 1292 insertions, 386 deletions
diff --git a/src/mesa/shader/slang/slang_assemble.c b/src/mesa/shader/slang/slang_assemble.c
index 2e1e13d1f5d..b24d3183841 100644
--- a/src/mesa/shader/slang/slang_assemble.c
+++ b/src/mesa/shader/slang/slang_assemble.c
@@ -29,13 +29,9 @@
*/
#include "imports.h"
-#include "slang_utility.h"
#include "slang_assemble.h"
+#include "slang_compile.h"
#include "slang_storage.h"
-#include "slang_assemble_typeinfo.h"
-#include "slang_assemble_conditional.h"
-#include "slang_assemble_assignment.h"
-#include "slang_execute.h"
/* slang_assembly */
@@ -1138,7 +1134,7 @@ GLboolean _slang_assemble_operation (slang_assemble_ctx *A, slang_operation *op,
/* push the variable's address */
if (var->global)
{
- if (!PLAB (A->file, slang_asm_addr_push, var->address))
+ if (!PLAB (A->file, slang_asm_global_addr, var->address))
return GL_FALSE;
}
else
diff --git a/src/mesa/shader/slang/slang_assemble.h b/src/mesa/shader/slang/slang_assemble.h
index 99c407d75ae..ddb59f83a1e 100644
--- a/src/mesa/shader/slang/slang_assemble.h
+++ b/src/mesa/shader/slang/slang_assemble.h
@@ -25,7 +25,7 @@
#if !defined SLANG_ASSEMBLE_H
#define SLANG_ASSEMBLE_H
-#include "slang_compile.h"
+#include "slang_utility.h"
#if defined __cplusplus
extern "C" {
@@ -81,6 +81,7 @@ typedef enum slang_assembly_type_
slang_asm_local_alloc,
slang_asm_local_free,
slang_asm_local_addr,
+ slang_asm_global_addr,
slang_asm_call,
slang_asm_return,
slang_asm_discard,
@@ -174,27 +175,33 @@ typedef struct slang_assemble_ctx_
slang_swizzle swz;
} slang_assemble_ctx;
-slang_function *_slang_locate_function (slang_function_scope *funcs, slang_atom a_name,
- slang_operation *params, GLuint num_params, slang_assembly_name_space *space,
+struct slang_function_ *_slang_locate_function (struct slang_function_scope_ *funcs, slang_atom name,
+ struct slang_operation_ *params, GLuint num_params, slang_assembly_name_space *space,
slang_atom_pool *);
GLboolean _slang_assemble_function (slang_assemble_ctx *, struct slang_function_ *);
-GLboolean _slang_cleanup_stack (slang_assemble_ctx *, slang_operation *);
+GLboolean _slang_cleanup_stack (slang_assemble_ctx *, struct slang_operation_ *);
-GLboolean _slang_dereference (slang_assemble_ctx *, slang_operation *);
+GLboolean _slang_dereference (slang_assemble_ctx *, struct slang_operation_ *);
-GLboolean _slang_assemble_function_call (slang_assemble_ctx *, slang_function *, slang_operation *,
- GLuint, GLboolean);
+GLboolean _slang_assemble_function_call (slang_assemble_ctx *, struct slang_function_ *,
+ struct slang_operation_ *, GLuint, GLboolean);
-GLboolean _slang_assemble_function_call_name (slang_assemble_ctx *, const char *, slang_operation *,
- GLuint, GLboolean);
+GLboolean _slang_assemble_function_call_name (slang_assemble_ctx *, const char *,
+ struct slang_operation_ *, GLuint, GLboolean);
-GLboolean _slang_assemble_operation (slang_assemble_ctx *, struct slang_operation_ *, slang_ref_type);
+GLboolean _slang_assemble_operation (slang_assemble_ctx *, struct slang_operation_ *,
+ slang_ref_type);
#ifdef __cplusplus
}
#endif
+#include "slang_assemble_assignment.h"
+#include "slang_assemble_typeinfo.h"
+#include "slang_assemble_constructor.h"
+#include "slang_assemble_conditional.h"
+
#endif
diff --git a/src/mesa/shader/slang/slang_assemble_assignment.c b/src/mesa/shader/slang/slang_assemble_assignment.c
index d4799b05be1..868724ed3e5 100644
--- a/src/mesa/shader/slang/slang_assemble_assignment.c
+++ b/src/mesa/shader/slang/slang_assemble_assignment.c
@@ -29,11 +29,8 @@
*/
#include "imports.h"
-#include "slang_utility.h"
-#include "slang_assemble_assignment.h"
-#include "slang_assemble_typeinfo.h"
+#include "slang_assemble.h"
#include "slang_storage.h"
-#include "slang_execute.h"
/*
* _slang_assemble_assignment()
diff --git a/src/mesa/shader/slang/slang_assemble_assignment.h b/src/mesa/shader/slang/slang_assemble_assignment.h
index ef05ebd71d4..111459be920 100644
--- a/src/mesa/shader/slang/slang_assemble_assignment.h
+++ b/src/mesa/shader/slang/slang_assemble_assignment.h
@@ -25,15 +25,13 @@
#if !defined SLANG_ASSEMBLE_ASSIGNMENT_H
#define SLANG_ASSEMBLE_ASSIGNMENT_H
-#include "slang_assemble.h"
-
#if defined __cplusplus
extern "C" {
#endif
-GLboolean _slang_assemble_assignment (slang_assemble_ctx *, slang_operation *);
+GLboolean _slang_assemble_assignment (slang_assemble_ctx *, struct slang_operation_ *);
-GLboolean _slang_assemble_assign (slang_assemble_ctx *, slang_operation *, const char *,
+GLboolean _slang_assemble_assign (slang_assemble_ctx *, struct slang_operation_ *, const char *,
slang_ref_type);
#ifdef __cplusplus
diff --git a/src/mesa/shader/slang/slang_assemble_conditional.c b/src/mesa/shader/slang/slang_assemble_conditional.c
index 115e292609e..b29d0cf30c5 100644
--- a/src/mesa/shader/slang/slang_assemble_conditional.c
+++ b/src/mesa/shader/slang/slang_assemble_conditional.c
@@ -29,10 +29,8 @@
*/
#include "imports.h"
-#include "slang_utility.h"
-#include "slang_assemble_conditional.h"
#include "slang_assemble.h"
-#include "slang_execute.h"
+#include "slang_compile.h"
/*
* _slang_assemble_logicaland()
diff --git a/src/mesa/shader/slang/slang_assemble_conditional.h b/src/mesa/shader/slang/slang_assemble_conditional.h
index 9ea1ed265ea..ef0c2172c93 100644
--- a/src/mesa/shader/slang/slang_assemble_conditional.h
+++ b/src/mesa/shader/slang/slang_assemble_conditional.h
@@ -25,25 +25,23 @@
#if !defined SLANG_ASSEMBLE_CONDITIONAL_H
#define SLANG_ASSEMBLE_CONDITIONAL_H
-#include "slang_assemble.h"
-
#if defined __cplusplus
extern "C" {
#endif
-GLboolean _slang_assemble_logicaland (slang_assemble_ctx *, slang_operation *);
+GLboolean _slang_assemble_logicaland (slang_assemble_ctx *, struct slang_operation_ *);
-GLboolean _slang_assemble_logicalor (slang_assemble_ctx *, slang_operation *);
+GLboolean _slang_assemble_logicalor (slang_assemble_ctx *, struct slang_operation_ *);
-GLboolean _slang_assemble_select (slang_assemble_ctx *, slang_operation *);
+GLboolean _slang_assemble_select (slang_assemble_ctx *, struct slang_operation_ *);
-GLboolean _slang_assemble_for (slang_assemble_ctx *, slang_operation *);
+GLboolean _slang_assemble_for (slang_assemble_ctx *, struct slang_operation_ *);
-GLboolean _slang_assemble_do (slang_assemble_ctx *, slang_operation *);
+GLboolean _slang_assemble_do (slang_assemble_ctx *, struct slang_operation_ *);
-GLboolean _slang_assemble_while (slang_assemble_ctx *, slang_operation *);
+GLboolean _slang_assemble_while (slang_assemble_ctx *, struct slang_operation_ *);
-GLboolean _slang_assemble_if (slang_assemble_ctx *, slang_operation *);
+GLboolean _slang_assemble_if (slang_assemble_ctx *, struct slang_operation_ *);
#ifdef __cplusplus
}
diff --git a/src/mesa/shader/slang/slang_assemble_constructor.c b/src/mesa/shader/slang/slang_assemble_constructor.c
index 278d490d9d2..5a8addeae0f 100644
--- a/src/mesa/shader/slang/slang_assemble_constructor.c
+++ b/src/mesa/shader/slang/slang_assemble_constructor.c
@@ -29,9 +29,7 @@
*/
#include "imports.h"
-#include "slang_utility.h"
-#include "slang_assemble_constructor.h"
-#include "slang_assemble_typeinfo.h"
+#include "slang_assemble.h"
#include "slang_storage.h"
/* _slang_is_swizzle() */
diff --git a/src/mesa/shader/slang/slang_assemble_constructor.h b/src/mesa/shader/slang/slang_assemble_constructor.h
index 3b556379978..4bd120c4a81 100644
--- a/src/mesa/shader/slang/slang_assemble_constructor.h
+++ b/src/mesa/shader/slang/slang_assemble_constructor.h
@@ -25,9 +25,6 @@
#if !defined SLANG_ASSEMBLE_CONSTRUCTOR_H
#define SLANG_ASSEMBLE_CONSTRUCTOR_H
-#include "slang_assemble.h"
-#include "slang_compile.h"
-
#if defined __cplusplus
extern "C" {
#endif
@@ -54,7 +51,7 @@ GLboolean _slang_is_swizzle_mask (const slang_swizzle *swz, GLuint rows);
*/
GLvoid _slang_multiply_swizzles (slang_swizzle *, const slang_swizzle *, const slang_swizzle *);
-GLboolean _slang_assemble_constructor (slang_assemble_ctx *, slang_operation *);
+GLboolean _slang_assemble_constructor (slang_assemble_ctx *, struct slang_operation_ *);
GLboolean _slang_assemble_constructor_from_swizzle (slang_assemble_ctx *, const slang_swizzle *,
slang_type_specifier *, slang_type_specifier *);
diff --git a/src/mesa/shader/slang/slang_assemble_typeinfo.c b/src/mesa/shader/slang/slang_assemble_typeinfo.c
index 48fba8ff612..8c5275f7d5b 100644
--- a/src/mesa/shader/slang/slang_assemble_typeinfo.c
+++ b/src/mesa/shader/slang/slang_assemble_typeinfo.c
@@ -29,22 +29,103 @@
*/
#include "imports.h"
-#include "slang_utility.h"
-#include "slang_assemble_typeinfo.h"
+#include "slang_assemble.h"
+#include "slang_compile.h"
+
+/*
+ * slang_type_specifier
+ */
+
+GLvoid slang_type_specifier_ctr (slang_type_specifier *self)
+{
+ self->type = slang_spec_void;
+ self->_struct = NULL;
+ self->_array = NULL;
+}
+
+GLvoid slang_type_specifier_dtr (slang_type_specifier *self)
+{
+ if (self->_struct != NULL)
+ {
+ slang_struct_destruct (self->_struct);
+ slang_alloc_free (self->_struct);
+ }
+ if (self->_array != NULL)
+ {
+ slang_type_specifier_dtr (self->_array);
+ slang_alloc_free (self->_array);
+ }
+}
+
+GLboolean slang_type_specifier_copy (slang_type_specifier *x, const slang_type_specifier *y)
+{
+ slang_type_specifier z;
+
+ slang_type_specifier_ctr (&z);
+ z.type = y->type;
+ if (z.type == slang_spec_struct)
+ {
+ z._struct = (slang_struct *) slang_alloc_malloc (sizeof (slang_struct));
+ if (z._struct == NULL)
+ {
+ slang_type_specifier_dtr (&z);
+ return GL_FALSE;
+ }
+ if (!slang_struct_construct (z._struct))
+ {
+ slang_alloc_free (z._struct);
+ slang_type_specifier_dtr (&z);
+ return GL_FALSE;
+ }
+ if (!slang_struct_copy (z._struct, y->_struct))
+ {
+ slang_type_specifier_dtr (&z);
+ return GL_FALSE;
+ }
+ }
+ else if (z.type == slang_spec_array)
+ {
+ z._array = (slang_type_specifier *) slang_alloc_malloc (sizeof (slang_type_specifier));
+ if (z._array == NULL)
+ {
+ slang_type_specifier_dtr (&z);
+ return GL_FALSE;
+ }
+ slang_type_specifier_ctr (z._array);
+ if (!slang_type_specifier_copy (z._array, y->_array))
+ {
+ slang_type_specifier_dtr (&z);
+ return GL_FALSE;
+ }
+ }
+ slang_type_specifier_dtr (x);
+ *x = z;
+ return GL_TRUE;
+}
+
+GLboolean slang_type_specifier_equal (const slang_type_specifier *x, const slang_type_specifier *y)
+{
+ if (x->type != y->type)
+ return 0;
+ if (x->type == slang_spec_struct)
+ return slang_struct_equal (x->_struct, y->_struct);
+ if (x->type == slang_spec_array)
+ return slang_type_specifier_equal (x->_array, y->_array);
+ return 1;
+}
/* slang_assembly_typeinfo */
GLboolean slang_assembly_typeinfo_construct (slang_assembly_typeinfo *ti)
{
- if (!slang_type_specifier_construct (&ti->spec))
- return GL_FALSE;
+ slang_type_specifier_ctr (&ti->spec);
ti->array_len = 0;
return GL_TRUE;
}
GLvoid slang_assembly_typeinfo_destruct (slang_assembly_typeinfo *ti)
{
- slang_type_specifier_destruct (&ti->spec);
+ slang_type_specifier_dtr (&ti->spec);
}
/* _slang_typeof_operation() */
diff --git a/src/mesa/shader/slang/slang_assemble_typeinfo.h b/src/mesa/shader/slang/slang_assemble_typeinfo.h
index b189dbed734..257793990b9 100644
--- a/src/mesa/shader/slang/slang_assemble_typeinfo.h
+++ b/src/mesa/shader/slang/slang_assemble_typeinfo.h
@@ -25,13 +25,50 @@
#if !defined SLANG_ASSEMBLE_TYPEINFO_H
#define SLANG_ASSEMBLE_TYPEINFO_H
-#include "slang_assemble_constructor.h"
-#include "slang_compile.h"
-
#if defined __cplusplus
extern "C" {
#endif
+typedef enum slang_type_specifier_type_
+{
+ slang_spec_void,
+ slang_spec_bool,
+ slang_spec_bvec2,
+ slang_spec_bvec3,
+ slang_spec_bvec4,
+ slang_spec_int,
+ slang_spec_ivec2,
+ slang_spec_ivec3,
+ slang_spec_ivec4,
+ slang_spec_float,
+ slang_spec_vec2,
+ slang_spec_vec3,
+ slang_spec_vec4,
+ slang_spec_mat2,
+ slang_spec_mat3,
+ slang_spec_mat4,
+ slang_spec_sampler1D,
+ slang_spec_sampler2D,
+ slang_spec_sampler3D,
+ slang_spec_samplerCube,
+ slang_spec_sampler1DShadow,
+ slang_spec_sampler2DShadow,
+ slang_spec_struct,
+ slang_spec_array
+} slang_type_specifier_type;
+
+typedef struct slang_type_specifier_
+{
+ slang_type_specifier_type type;
+ struct slang_struct_ *_struct; /* type: spec_struct */
+ struct slang_type_specifier_ *_array; /* type: spec_array */
+} slang_type_specifier;
+
+GLvoid slang_type_specifier_ctr (slang_type_specifier *);
+GLvoid slang_type_specifier_dtr (slang_type_specifier *);
+GLboolean slang_type_specifier_copy (slang_type_specifier *, const slang_type_specifier *);
+GLboolean slang_type_specifier_equal (const slang_type_specifier *, const slang_type_specifier *);
+
typedef struct slang_assembly_typeinfo_
{
GLboolean can_be_referenced;
@@ -49,8 +86,9 @@ GLvoid slang_assembly_typeinfo_destruct (slang_assembly_typeinfo *);
* Returns GL_TRUE on success.
* Returns GL_FALSE otherwise.
*/
-GLboolean _slang_typeof_operation (slang_assemble_ctx *, slang_operation *, slang_assembly_typeinfo *);
-GLboolean _slang_typeof_operation_ (slang_operation *, slang_assembly_name_space *,
+GLboolean _slang_typeof_operation (slang_assemble_ctx *, struct slang_operation_ *,
+ slang_assembly_typeinfo *);
+GLboolean _slang_typeof_operation_ (struct slang_operation_ *, slang_assembly_name_space *,
slang_assembly_typeinfo *, slang_atom_pool *);
/*
@@ -58,8 +96,9 @@ GLboolean _slang_typeof_operation_ (slang_operation *, slang_assembly_name_space
* Returns GL_TRUE on success, even if the function was not found.
* Returns GL_FALSE otherwise.
*/
-GLboolean _slang_typeof_function (slang_atom a_name, slang_operation *params, GLuint num_params,
- slang_assembly_name_space *, slang_type_specifier *spec, GLboolean *exists, slang_atom_pool *);
+GLboolean _slang_typeof_function (slang_atom a_name, struct slang_operation_ *params,
+ GLuint num_params, slang_assembly_name_space *, slang_type_specifier *spec, GLboolean *exists,
+ slang_atom_pool *);
GLboolean _slang_type_is_matrix (slang_type_specifier_type);
diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c
index 54aca6dd79d..5576821411f 100644
--- a/src/mesa/shader/slang/slang_compile.c
+++ b/src/mesa/shader/slang/slang_compile.c
@@ -29,13 +29,10 @@
*/
#include "imports.h"
-#include "grammar_mesa.h"
-#include "slang_utility.h"
-#include "slang_compile.h"
-#include "slang_preprocess.h"
-#include "slang_storage.h"
-#include "slang_assemble.h"
-#include "slang_execute.h"
+#include "grammar_mesa.h"
+#include "slang_compile.h"
+#include "slang_preprocess.h"
+#include "slang_storage.h"
/*
* This is a straightforward implementation of the slang front-end compiler.
@@ -83,7 +80,7 @@ int slang_translation_unit_construct (slang_translation_unit *unit)
slang_alloc_free (unit->assembly);
return 0;
}
- slang_machine_init (unit->machine);
+ slang_machine_ctr (unit->machine);
unit->atom_pool = (slang_atom_pool *) slang_alloc_malloc (sizeof (slang_atom_pool));
if (unit->atom_pool == NULL)
{
@@ -136,7 +133,7 @@ int slang_translation_unit_construct2 (slang_translation_unit *unit, slang_assem
unit->atom_pool = atoms;
unit->free_atom_pool = 0;
slang_export_data_table_ctr (&unit->exp_data);
- slang_active_uniforms_ctr (&unit->uniforms);
+ slang_export_code_table_ctr (&unit->exp_code);
return 1;
}
@@ -152,15 +149,18 @@ void slang_translation_unit_destruct (slang_translation_unit *unit)
}
if (unit->free_global_pool)
slang_alloc_free (unit->global_pool);
- if (unit->free_machine)
- slang_alloc_free (unit->machine);
+ if (unit->free_machine)
+ {
+ slang_machine_dtr (unit->machine);
+ slang_alloc_free (unit->machine);
+ }
if (unit->free_atom_pool)
{
slang_atom_pool_destruct (unit->atom_pool);
slang_alloc_free (unit->atom_pool);
}
- slang_active_uniforms_dtr (&unit->uniforms);
- slang_export_data_table_dtr (&unit->exp_data);
+ slang_export_data_table_dtr (&unit->exp_data);
+ slang_export_code_table_ctr (&unit->exp_code);
}
/* slang_info_log */
@@ -407,13 +407,7 @@ static GLboolean convert_to_array (slang_parse_ctx *C, slang_variable *var,
slang_info_log_memory (C->L);
return GL_FALSE;
}
- if (!slang_type_specifier_construct (var->type.specifier._array))
- {
- slang_alloc_free (var->type.specifier._array);
- var->type.specifier._array = NULL;
- slang_info_log_memory (C->L);
- return GL_FALSE;
- }
+ slang_type_specifier_ctr (var->type.specifier._array);
return slang_type_specifier_copy (var->type.specifier._array, sp);
}
@@ -518,14 +512,13 @@ static int parse_struct (slang_parse_ctx *C, slang_output_ctx *O, slang_struct *
{
slang_type_specifier sp;
- if (!slang_type_specifier_construct (&sp))
- return 0;
+ slang_type_specifier_ctr (&sp);
if (!parse_struct_field (C, O, *st, &sp))
{
- slang_type_specifier_destruct (&sp);
+ slang_type_specifier_dtr (&sp);
return 0;
}
- slang_type_specifier_destruct (&sp);
+ slang_type_specifier_dtr (&sp);
}
while (*C->I++ != FIELD_NONE);
@@ -1320,19 +1313,18 @@ static int parse_parameter_declaration (slang_parse_ctx *C, slang_output_ctx *O,
{
slang_type_specifier p;
- if (!slang_type_specifier_construct (&p))
- return GL_FALSE;
+ slang_type_specifier_ctr (&p);
if (!slang_type_specifier_copy (&p, &param->type.specifier))
{
- slang_type_specifier_destruct (&p);
+ slang_type_specifier_dtr (&p);
return GL_FALSE;
}
if (!convert_to_array (C, param, &p))
{
- slang_type_specifier_destruct (&p);
+ slang_type_specifier_dtr (&p);
return GL_FALSE;
}
- slang_type_specifier_destruct (&p);
+ slang_type_specifier_dtr (&p);
if (!parse_array_len (C, O, &param->array_len))
return GL_FALSE;
}
@@ -2102,7 +2094,12 @@ static int compile (grammar *id, slang_translation_unit *builtin_units, int *com
return 0;
return 1;
-}
+}
+
+#if defined(USE_X86_ASM) || defined(SLANG_X86)
+/* XXX */
+GLboolean _slang_x86_codegen (slang_machine *, slang_assembly_file *, GLuint);
+#endif
int _slang_compile (const char *source, slang_translation_unit *unit, slang_unit_type type,
slang_info_log *log)
@@ -2136,11 +2133,20 @@ int _slang_compile (const char *source, slang_translation_unit *unit, slang_unit
if (!success)
return 0;
+
unit->exp_data.atoms = unit->atom_pool;
if (!_slang_build_export_data_table (&unit->exp_data, &unit->globals))
return 0;
- if (!_slang_gather_active_uniforms (&unit->uniforms, &unit->exp_data))
- return 0;
+
+ unit->exp_code.atoms = unit->atom_pool;
+ if (!_slang_build_export_code_table (&unit->exp_code, &unit->functions, unit))
+ return 0;
+
+#if defined(USE_X86_ASM) || defined(SLANG_X86)
+ /* XXX: lookup the @main label */
+ if (!_slang_x86_codegen (unit->machine, unit->assembly, unit->exp_code.entries[0].address))
+ return 0;
+#endif
return 1;
}
diff --git a/src/mesa/shader/slang/slang_compile.h b/src/mesa/shader/slang/slang_compile.h
index 7695235c21c..cbf0bf907a1 100644
--- a/src/mesa/shader/slang/slang_compile.h
+++ b/src/mesa/shader/slang/slang_compile.h
@@ -25,6 +25,8 @@
#if !defined SLANG_COMPILE_H
#define SLANG_COMPILE_H
+#include "slang_export.h"
+#include "slang_execute.h"
#include "slang_compile_variable.h"
#include "slang_compile_struct.h"
#include "slang_compile_operation.h"
@@ -53,21 +55,21 @@ typedef struct slang_translation_unit_
slang_function_scope functions;
slang_struct_scope structs;
slang_unit_type type;
- struct slang_assembly_file_ *assembly;
+ slang_assembly_file *assembly;
int free_assembly;
slang_var_pool *global_pool;
int free_global_pool;
- struct slang_machine_ *machine;
+ slang_machine *machine;
int free_machine;
slang_atom_pool *atom_pool;
int free_atom_pool;
slang_export_data_table exp_data;
- slang_active_uniforms uniforms;
+ slang_export_code_table exp_code;
} slang_translation_unit;
int slang_translation_unit_construct (slang_translation_unit *);
-int slang_translation_unit_construct2 (slang_translation_unit *, struct slang_assembly_file_ *,
- slang_var_pool *, struct slang_machine_ *, slang_atom_pool *);
+int slang_translation_unit_construct2 (slang_translation_unit *, slang_assembly_file *,
+ slang_var_pool *, slang_machine *, slang_atom_pool *);
void slang_translation_unit_destruct (slang_translation_unit *);
typedef struct slang_info_log_
diff --git a/src/mesa/shader/slang/slang_compile_function.c b/src/mesa/shader/slang/slang_compile_function.c
index 5edba72cf77..50828d0b076 100644
--- a/src/mesa/shader/slang/slang_compile_function.c
+++ b/src/mesa/shader/slang/slang_compile_function.c
@@ -29,10 +29,7 @@
*/
#include "imports.h"
-#include "slang_utility.h"
-#include "slang_compile_variable.h"
-#include "slang_compile_operation.h"
-#include "slang_compile_function.h"
+#include "slang_compile.h"
/* slang_fixup_table */
@@ -146,3 +143,48 @@ slang_function *slang_function_scope_find (slang_function_scope *funcs, slang_fu
return NULL;
}
+/*
+ * _slang_build_export_code_table()
+ */
+
+GLboolean _slang_build_export_code_table (slang_export_code_table *tbl, slang_function_scope *funs,
+ slang_translation_unit *unit)
+{
+ slang_atom main;
+ GLuint i;
+
+ main = slang_atom_pool_atom (tbl->atoms, "main");
+ if (main == SLANG_ATOM_NULL)
+ return GL_FALSE;
+
+ for (i = 0; i < funs->num_functions; i++)
+ {
+ if (funs->functions[i].header.a_name == main)
+ {
+ slang_function *fun = &funs->functions[i];
+ slang_export_code_entry *e;
+ slang_assemble_ctx A;
+
+ e = slang_export_code_table_add (tbl);
+ if (e == NULL)
+ return GL_FALSE;
+ e->address = unit->assembly->count;
+ e->name = slang_atom_pool_atom (tbl->atoms, "@main");
+ if (e->name == SLANG_ATOM_NULL)
+ return GL_FALSE;
+
+ A.file = unit->assembly;
+ A.mach = unit->machine;
+ A.atoms = unit->atom_pool;
+ A.space.funcs = &unit->functions;
+ A.space.structs = &unit->structs;
+ A.space.vars = &unit->globals;
+ slang_assembly_file_push_label (unit->assembly, slang_asm_local_alloc, 20);
+ slang_assembly_file_push_label (unit->assembly, slang_asm_enter, 20);
+ _slang_assemble_function_call (&A, fun, NULL, 0, GL_FALSE);
+ slang_assembly_file_push (unit->assembly, slang_asm_exit);
+ }
+ }
+ return GL_TRUE;
+}
+
diff --git a/src/mesa/shader/slang/slang_compile_function.h b/src/mesa/shader/slang/slang_compile_function.h
index d1208817cfa..2ad1d053b01 100644
--- a/src/mesa/shader/slang/slang_compile_function.h
+++ b/src/mesa/shader/slang/slang_compile_function.h
@@ -71,6 +71,9 @@ void slang_function_scope_destruct (slang_function_scope *);
int slang_function_scope_find_by_name (slang_function_scope *, slang_atom, int);
slang_function *slang_function_scope_find (slang_function_scope *, slang_function *, int);
+GLboolean _slang_build_export_code_table (slang_export_code_table *, slang_function_scope *,
+ struct slang_translation_unit_ *);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/mesa/shader/slang/slang_compile_operation.c b/src/mesa/shader/slang/slang_compile_operation.c
index 6783f1dc78d..8af8d1f82be 100644
--- a/src/mesa/shader/slang/slang_compile_operation.c
+++ b/src/mesa/shader/slang/slang_compile_operation.c
@@ -29,9 +29,7 @@
*/
#include "imports.h"
-#include "slang_utility.h"
-#include "slang_compile_variable.h"
-#include "slang_compile_operation.h"
+#include "slang_compile.h"
/* slang_operation */
diff --git a/src/mesa/shader/slang/slang_compile_struct.c b/src/mesa/shader/slang/slang_compile_struct.c
index 30c15ffd5d8..627f0597e1c 100644
--- a/src/mesa/shader/slang/slang_compile_struct.c
+++ b/src/mesa/shader/slang/slang_compile_struct.c
@@ -29,9 +29,7 @@
*/
#include "imports.h"
-#include "slang_utility.h"
-#include "slang_compile_variable.h"
-#include "slang_compile_struct.h"
+#include "slang_compile.h"
/* slang_struct_scope */
diff --git a/src/mesa/shader/slang/slang_compile_variable.c b/src/mesa/shader/slang/slang_compile_variable.c
index 6f56872b593..0c8f6c57276 100644
--- a/src/mesa/shader/slang/slang_compile_variable.c
+++ b/src/mesa/shader/slang/slang_compile_variable.c
@@ -29,10 +29,7 @@
*/
#include "imports.h"
-#include "slang_utility.h"
-#include "slang_compile_variable.h"
-#include "slang_compile_struct.h"
-#include "slang_compile_operation.h"
+#include "slang_compile.h"
/* slang_type_specifier_type */
@@ -92,106 +89,18 @@ const char *slang_type_specifier_type_to_string (slang_type_specifier_type type)
return p->name;
}
-/* slang_type_specifier */
-
-int slang_type_specifier_construct (slang_type_specifier *spec)
-{
- spec->type = slang_spec_void;
- spec->_struct = NULL;
- spec->_array = NULL;
- return 1;
-}
-
-void slang_type_specifier_destruct (slang_type_specifier *spec)
-{
- if (spec->_struct != NULL)
- {
- slang_struct_destruct (spec->_struct);
- slang_alloc_free (spec->_struct);
- }
- if (spec->_array != NULL)
- {
- slang_type_specifier_destruct (spec->_array);
- slang_alloc_free (spec->_array);
- }
-}
-
-int slang_type_specifier_copy (slang_type_specifier *x, const slang_type_specifier *y)
-{
- slang_type_specifier z;
-
- if (!slang_type_specifier_construct (&z))
- return 0;
- z.type = y->type;
- if (z.type == slang_spec_struct)
- {
- z._struct = (slang_struct *) slang_alloc_malloc (sizeof (slang_struct));
- if (z._struct == NULL)
- {
- slang_type_specifier_destruct (&z);
- return 0;
- }
- if (!slang_struct_construct (z._struct))
- {
- slang_alloc_free (z._struct);
- slang_type_specifier_destruct (&z);
- return 0;
- }
- if (!slang_struct_copy (z._struct, y->_struct))
- {
- slang_type_specifier_destruct (&z);
- return 0;
- }
- }
- else if (z.type == slang_spec_array)
- {
- z._array = (slang_type_specifier *) slang_alloc_malloc (sizeof (slang_type_specifier));
- if (z._array == NULL)
- {
- slang_type_specifier_destruct (&z);
- return 0;
- }
- if (!slang_type_specifier_construct (z._array))
- {
- slang_alloc_free (z._array);
- slang_type_specifier_destruct (&z);
- return 0;
- }
- if (!slang_type_specifier_copy (z._array, y->_array))
- {
- slang_type_specifier_destruct (&z);
- return 0;
- }
- }
- slang_type_specifier_destruct (x);
- *x = z;
- return 1;
-}
-
-int slang_type_specifier_equal (const slang_type_specifier *x, const slang_type_specifier *y)
-{
- if (x->type != y->type)
- return 0;
- if (x->type == slang_spec_struct)
- return slang_struct_equal (x->_struct, y->_struct);
- if (x->type == slang_spec_array)
- return slang_type_specifier_equal (x->_array, y->_array);
- return 1;
-}
-
/* slang_fully_specified_type */
int slang_fully_specified_type_construct (slang_fully_specified_type *type)
{
type->qualifier = slang_qual_none;
- if (!slang_type_specifier_construct (&type->specifier))
- return 0;
+ slang_type_specifier_ctr (&type->specifier);
return 1;
}
void slang_fully_specified_type_destruct (slang_fully_specified_type *type)
{
- slang_type_specifier_destruct (&type->specifier);
+ slang_type_specifier_dtr (&type->specifier);
}
int slang_fully_specified_type_copy (slang_fully_specified_type *x, const slang_fully_specified_type *y)
@@ -341,41 +250,9 @@ slang_variable *_slang_locate_variable (slang_variable_scope *scope, slang_atom
}
/*
- * slang_active_uniforms
+ * _slang_build_export_data_table()
*/
-GLvoid slang_active_uniforms_ctr (slang_active_uniforms *self)
-{
- self->table = NULL;
- self->count = 0;
-}
-
-GLvoid slang_active_uniforms_dtr (slang_active_uniforms *self)
-{
- GLuint i;
-
- for (i = 0; i < self->count; i++)
- slang_alloc_free (self->table[i].name);
- slang_alloc_free (self->table);
-}
-
-GLboolean slang_active_uniforms_add (slang_active_uniforms *self, slang_export_data_quant *q,
- const char *name)
-{
- const GLuint n = self->count;
-
- self->table = (slang_active_uniform *) slang_alloc_realloc (self->table,
- n * sizeof (slang_active_uniform), (n + 1) * sizeof (slang_active_uniform));
- 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 GLenum gl_type_from_specifier (const slang_type_specifier *type)
{
switch (type->type)
@@ -469,17 +346,20 @@ GLboolean _slang_build_export_data_table (slang_export_data_table *tbl, slang_va
for (i = 0; i < vars->num_variables; i++)
{
slang_variable *var = &vars->variables[i];
-
+ slang_export_data_entry *e;
+
+ e = slang_export_data_table_add (tbl);
+ if (e == NULL)
+ return GL_FALSE;
+ if (!build_quant (&e->quant, var))
+ return GL_FALSE;
if (var->type.qualifier == slang_qual_uniform)
- {
- slang_export_data_entry *e = slang_export_data_table_add (tbl);
- if (e == NULL)
- return GL_FALSE;
- if (!build_quant (&e->quant, var))
- return GL_FALSE;
e->access = slang_exp_uniform;
- e->address = var->address;
- }
+ else if (var->type.qualifier == slang_qual_attribute)
+ e->access = slang_exp_attribute;
+ else
+ e->access = slang_exp_varying;
+ e->address = var->address;
}
if (vars->outer_scope != NULL)
@@ -487,45 +367,3 @@ GLboolean _slang_build_export_data_table (slang_export_data_table *tbl, slang_va
return GL_TRUE;
}
-static GLboolean insert_uniform (slang_active_uniforms *u, slang_export_data_quant *q, char *name,
- slang_atom_pool *atoms)
-{
- slang_string_concat (name, slang_atom_pool_id (atoms, q->name));
- if (q->array_len != 0)
- slang_string_concat (name, "[0]");
-
- if (q->structure != NULL)
- {
- GLuint save, i;
-
- slang_string_concat (name, ".");
- save = slang_string_length (name);
-
- for (i = 0; i < q->u.field_count; i++)
- {
- if (!insert_uniform (u, &q->structure[i], name, atoms))
- return GL_FALSE;
- name[save] = '\0';
- }
-
- return GL_TRUE;
- }
-
- return slang_active_uniforms_add (u, q, name);
-}
-
-GLboolean _slang_gather_active_uniforms (slang_active_uniforms *u, slang_export_data_table *tbl)
-{
- GLuint i;
-
- for (i = 0; i < tbl->count; i++)
- {
- char name[1024] = "";
-
- if (!insert_uniform (u, &tbl->entries[i].quant, name, tbl->atoms))
- return GL_FALSE;
- }
-
- return GL_TRUE;
-}
-
diff --git a/src/mesa/shader/slang/slang_compile_variable.h b/src/mesa/shader/slang/slang_compile_variable.h
index 4261dd16896..6d2e23702f5 100644
--- a/src/mesa/shader/slang/slang_compile_variable.h
+++ b/src/mesa/shader/slang/slang_compile_variable.h
@@ -25,8 +25,6 @@
#if !defined SLANG_COMPILE_VARIABLE_H
#define SLANG_COMPILE_VARIABLE_H
-#include "slang_export.h"
-
#if defined __cplusplus
extern "C" {
#endif
@@ -44,49 +42,9 @@ typedef enum slang_type_qualifier_
slang_qual_fixedinput /* internal */
} slang_type_qualifier;
-typedef enum slang_type_specifier_type_
-{
- slang_spec_void,
- slang_spec_bool,
- slang_spec_bvec2,
- slang_spec_bvec3,
- slang_spec_bvec4,
- slang_spec_int,
- slang_spec_ivec2,
- slang_spec_ivec3,
- slang_spec_ivec4,
- slang_spec_float,
- slang_spec_vec2,
- slang_spec_vec3,
- slang_spec_vec4,
- slang_spec_mat2,
- slang_spec_mat3,
- slang_spec_mat4,
- slang_spec_sampler1D,
- slang_spec_sampler2D,
- slang_spec_sampler3D,
- slang_spec_samplerCube,
- slang_spec_sampler1DShadow,
- slang_spec_sampler2DShadow,
- slang_spec_struct,
- slang_spec_array
-} slang_type_specifier_type;
-
slang_type_specifier_type slang_type_specifier_type_from_string (const char *);
const char *slang_type_specifier_type_to_string (slang_type_specifier_type);
-typedef struct slang_type_specifier_
-{
- slang_type_specifier_type type;
- struct slang_struct_ *_struct; /* type: spec_struct */
- struct slang_type_specifier_ *_array; /* type: spec_array */
-} slang_type_specifier;
-
-int slang_type_specifier_construct (slang_type_specifier *);
-void slang_type_specifier_destruct (slang_type_specifier *);
-int slang_type_specifier_copy (slang_type_specifier *, const slang_type_specifier *);
-int slang_type_specifier_equal (const slang_type_specifier *, const slang_type_specifier *);
-
typedef struct slang_fully_specified_type_
{
slang_type_qualifier qualifier;
@@ -125,27 +83,8 @@ int slang_variable_copy (slang_variable *, const slang_variable *);
slang_variable *_slang_locate_variable (slang_variable_scope *, slang_atom a_name, GLboolean all);
-typedef struct
-{
- slang_export_data_quant *quant;
- char *name;
-} slang_active_uniform;
-
-typedef struct
-{
- slang_active_uniform *table;
- GLuint count;
-} slang_active_uniforms;
-
-GLvoid slang_active_uniforms_ctr (slang_active_uniforms *);
-GLvoid slang_active_uniforms_dtr (slang_active_uniforms *);
-GLboolean slang_active_uniforms_add (slang_active_uniforms *, slang_export_data_quant *,
- const char *);
-
GLboolean _slang_build_export_data_table (slang_export_data_table *, slang_variable_scope *);
-GLboolean _slang_gather_active_uniforms (slang_active_uniforms *, slang_export_data_table *);
-
#ifdef __cplusplus
}
#endif
diff --git a/src/mesa/shader/slang/slang_execute.c b/src/mesa/shader/slang/slang_execute.c
index 06f0eefdf60..0714ddff0d9 100644
--- a/src/mesa/shader/slang/slang_execute.c
+++ b/src/mesa/shader/slang/slang_execute.c
@@ -32,14 +32,26 @@
#include "context.h"
#include "swrast/s_context.h"
#include "colormac.h"
-#include "slang_utility.h"
-#include "slang_assemble.h"
-#include "slang_storage.h"
#include "slang_execute.h"
#include "slang_library_noise.h"
#define DEBUG_SLANG 0
+GLvoid slang_machine_ctr (slang_machine *self)
+{
+ slang_machine_init (self);
+#if defined(USE_X86_ASM) || defined(SLANG_X86)
+ self->x86.compiled_func = NULL;
+#endif
+}
+
+GLvoid slang_machine_dtr (slang_machine *self)
+{
+#if defined(USE_X86_ASM) || defined(SLANG_X86)
+ /* TODO: free self->x86.compiled_func */
+#endif
+}
+
void slang_machine_init (slang_machine *mach)
{
mach->ip = 0;
@@ -53,7 +65,7 @@ int _slang_execute (const slang_assembly_file *file)
{
slang_machine mach;
- slang_machine_init (&mach);
+ slang_machine_ctr (&mach);
return _slang_execute2 (file, &mach);
}
@@ -207,6 +219,9 @@ static void dump_instruction (FILE *f, slang_assembly *a, unsigned int i)
case slang_asm_local_addr:
fprintf (f, "local_addr\t%u, %u", a->param[0], a->param[1]);
break;
+ case slang_asm_global_addr:
+ fprintf (f, "global_addr\t%u", a->param[0]);
+ break;
case slang_asm_call:
fprintf (f, "call\t%u", a->param[0]);
break;
@@ -293,6 +308,14 @@ int _slang_execute2 (const slang_assembly_file *file, slang_machine *mach)
f = fopen (filename, "w");
#endif
+#if defined(USE_X86_ASM) || defined(SLANG_X86)
+ if (mach->x86.compiled_func != NULL)
+ {
+ mach->x86.compiled_func (mach);
+ return 1;
+ }
+#endif
+
stack = mach->mem + SLANG_MACHINE_GLOBAL_SIZE;
while (!mach->exit)
@@ -427,6 +450,7 @@ int _slang_execute2 (const slang_assembly_file *file, slang_machine *mach)
mach->sp++;
break;
case slang_asm_addr_push:
+ case slang_asm_global_addr:
mach->sp--;
stack[mach->sp]._addr = a->param[0];
break;
diff --git a/src/mesa/shader/slang/slang_execute.h b/src/mesa/shader/slang/slang_execute.h
index a3b326f3155..588b0cac3fe 100644
--- a/src/mesa/shader/slang/slang_execute.h
+++ b/src/mesa/shader/slang/slang_execute.h
@@ -25,6 +25,8 @@
#if !defined SLANG_EXECUTE_H
#define SLANG_EXECUTE_H
+#include "slang_assemble.h"
+
#if defined __cplusplus
extern "C" {
#endif
@@ -39,6 +41,16 @@ typedef union slang_machine_slot_
#define SLANG_MACHINE_STACK_SIZE 1024
#define SLANG_MACHINE_MEMORY_SIZE (SLANG_MACHINE_GLOBAL_SIZE + SLANG_MACHINE_STACK_SIZE)
+#if defined(USE_X86_ASM) || defined(SLANG_X86)
+typedef struct
+{
+ GLvoid (* compiled_func) (struct slang_machine_ *);
+ GLuint esp_restore;
+ GLshort fpucntl_rnd_neg;
+ GLshort fpucntl_restore;
+} slang_machine_x86;
+#endif
+
typedef struct slang_machine_
{
GLuint ip; /* instruction pointer, for flow control */
@@ -47,8 +59,14 @@ typedef struct slang_machine_
GLuint kill; /* discard the fragment */
GLuint exit; /* terminate the shader */
slang_machine_slot mem[SLANG_MACHINE_MEMORY_SIZE];
+#if defined(USE_X86_ASM) || defined(SLANG_X86)
+ slang_machine_x86 x86;
+#endif
} slang_machine;
+GLvoid slang_machine_ctr (slang_machine *);
+GLvoid slang_machine_dtr (slang_machine *);
+
void slang_machine_init (slang_machine *);
int _slang_execute (const slang_assembly_file *);
diff --git a/src/mesa/shader/slang/slang_execute_x86.c b/src/mesa/shader/slang/slang_execute_x86.c
new file mode 100644
index 00000000000..d6395632390
--- /dev/null
+++ b/src/mesa/shader/slang/slang_execute_x86.c
@@ -0,0 +1,536 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file slang_execute_x86.c
+ * x86 back end compiler
+ * \author Michal Krol, Keith Whitwell
+ */
+
+#include "imports.h"
+#include "context.h"
+#include "colormac.h"
+#include "swrast/s_context.h"
+#include "slang_execute.h"
+#include "slang_library_noise.h"
+
+#if defined(USE_X86_ASM) || defined(SLANG_X86)
+
+#include "x86/rtasm/x86sse.h"
+
+typedef struct
+{
+ GLuint index;
+ GLubyte *csr;
+} fixup;
+
+typedef struct
+{
+ struct x86_function f;
+ struct x86_reg r_eax;
+ struct x86_reg r_ecx;
+ struct x86_reg r_edx;
+ struct x86_reg r_esp;
+ struct x86_reg r_ebp;
+ struct x86_reg r_st0;
+ struct x86_reg r_st1;
+ struct x86_reg r_st2;
+ struct x86_reg r_st3;
+ fixup *fixups;
+ GLuint fixup_count;
+ GLubyte **labels;
+ slang_machine *mach;
+ GLubyte *l_discard;
+ GLubyte *l_exit;
+ GLshort fpucntl;
+} codegen_ctx;
+
+static GLvoid add_fixup (codegen_ctx *G, GLuint index, GLubyte *csr)
+{
+ G->fixups = (fixup *) slang_alloc_realloc (G->fixups, G->fixup_count * sizeof (fixup),
+ (G->fixup_count + 1) * sizeof (fixup));
+ G->fixups[G->fixup_count].index = index;
+ G->fixups[G->fixup_count].csr = csr;
+ G->fixup_count++;
+}
+
+#ifdef NO_FAST_MATH
+#define RESTORE_FPU (DEFAULT_X86_FPU)
+#define RND_NEG_FPU (DEFAULT_X86_FPU | 0x400)
+#else
+#define RESTORE_FPU (FAST_X86_FPU)
+#define RND_NEG_FPU (FAST_X86_FPU | 0x400)
+#endif
+
+static void set_fpu_round_neg_inf (codegen_ctx *G)
+{
+ if (G->fpucntl != RND_NEG_FPU)
+ {
+ G->fpucntl = RND_NEG_FPU;
+ x87_fnclex (&G->f);
+ x86_mov_reg_imm (&G->f, G->r_eax, (GLint) &G->mach->x86.fpucntl_rnd_neg);
+ x87_fldcw (&G->f, x86_deref (G->r_eax));
+ }
+}
+
+static void emit_x87_ex2 (codegen_ctx *G)
+{
+ set_fpu_round_neg_inf (G);
+
+ x87_fld (&G->f, G->r_st0); /* a a */
+ x87_fprndint (&G->f); /* int(a) a */
+ x87_fld (&G->f, G->r_st0); /* int(a) int(a) a */
+ x87_fstp (&G->f, G->r_st3); /* int(a) a int(a)*/
+ x87_fsubp (&G->f, G->r_st1);/* frac(a) int(a) */
+ x87_f2xm1 (&G->f); /* (2^frac(a))-1 int(a)*/
+ x87_fld1 (&G->f); /* 1 (2^frac(a))-1 int(a)*/
+ x87_faddp (&G->f, G->r_st1);/* 2^frac(a) int(a) */
+ x87_fscale (&G->f); /* 2^a */
+}
+
+static GLfloat do_ceilf (GLfloat x)
+{
+ return CEILF (x);
+}
+
+static void fetch_texel (GLuint sampler, const GLfloat texcoord[4], GLfloat lambda, GLfloat color[4])
+{
+ GET_CURRENT_CONTEXT(ctx);
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLchan rgba[4];
+
+ /* XXX: the function pointer is NULL! */
+ swrast->TextureSample[sampler] (ctx, ctx->Texture.Unit[sampler]._Current, 1,
+ (const GLfloat (*)[4]) texcoord, &lambda, &rgba);
+ color[0] = CHAN_TO_FLOAT(rgba[0]);
+ color[1] = CHAN_TO_FLOAT(rgba[1]);
+ color[2] = CHAN_TO_FLOAT(rgba[2]);
+ color[3] = CHAN_TO_FLOAT(rgba[3]);
+}
+
+static GLvoid do_vec4_tex2d (GLfloat s, GLfloat t, GLuint sampler, GLfloat *rgba)
+{
+ GLfloat st[4] = { s, t, 0.0f, 1.0f };
+
+ fetch_texel (sampler, st, 0.0f, rgba);
+}
+
+static GLvoid do_print_float (GLfloat x)
+{
+ _mesa_printf ("slang print: %f\n", x);
+}
+
+static GLvoid do_print_int (GLfloat x)
+{
+ _mesa_printf ("slang print: %d\n", (GLint) x);
+}
+
+static GLvoid do_print_bool (GLfloat x)
+{
+ _mesa_printf ("slang print: %s\n", (GLint) x ? "true" : "false");
+}
+
+static GLvoid codegen_assem (codegen_ctx *G, slang_assembly *a)
+{
+ GLint disp;
+
+ switch (a->type)
+ {
+ case slang_asm_none:
+ break;
+ case slang_asm_float_copy:
+ case slang_asm_int_copy:
+ case slang_asm_bool_copy:
+ x86_mov (&G->f, G->r_eax, x86_make_disp (G->r_esp, a->param[0]));
+ x86_pop (&G->f, G->r_ecx);
+ x86_mov (&G->f, x86_make_disp (G->r_eax, a->param[1]), G->r_ecx);
+ break;
+ case slang_asm_float_move:
+ case slang_asm_int_move:
+ case slang_asm_bool_move:
+ x86_lea (&G->f, G->r_eax, x86_make_disp (G->r_esp, a->param[1]));
+ x86_add (&G->f, G->r_eax, x86_deref (G->r_esp));
+ x86_mov (&G->f, G->r_eax, x86_deref (G->r_eax));
+ x86_mov (&G->f, x86_make_disp (G->r_esp, a->param[0]), G->r_eax);
+ break;
+ case slang_asm_float_push:
+ case slang_asm_int_push:
+ case slang_asm_bool_push:
+ /* TODO: use push imm32 */
+ x86_mov_reg_imm (&G->f, G->r_eax, *((GLint *) &a->literal));
+ x86_push (&G->f, G->r_eax);
+ break;
+ case slang_asm_float_deref:
+ case slang_asm_int_deref:
+ case slang_asm_bool_deref:
+ case slang_asm_addr_deref:
+ x86_mov (&G->f, G->r_eax, x86_deref (G->r_esp));
+ x86_mov (&G->f, G->r_eax, x86_deref (G->r_eax));
+ x86_mov (&G->f, x86_deref (G->r_esp), G->r_eax);
+ break;
+ case slang_asm_float_add:
+ x87_fld (&G->f, x86_make_disp (G->r_esp, 4));
+ x87_fld (&G->f, x86_deref (G->r_esp));
+ x87_faddp (&G->f, G->r_st1);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 4));
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_multiply:
+ x87_fld (&G->f, x86_make_disp (G->r_esp, 4));
+ x87_fld (&G->f, x86_deref (G->r_esp));
+ x87_fmulp (&G->f, G->r_st1);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 4));
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_divide:
+ x87_fld (&G->f, x86_make_disp (G->r_esp, 4));
+ x87_fld (&G->f, x86_deref (G->r_esp));
+ x87_fdivp (&G->f, G->r_st1);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 4));
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_negate:
+ x87_fld (&G->f, x86_deref (G->r_esp));
+ x87_fchs (&G->f);
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_less:
+ x87_fld (&G->f, x86_make_disp (G->r_esp, 4));
+ x87_fcomp (&G->f, x86_deref (G->r_esp));
+ x87_fnstsw (&G->f, G->r_eax);
+ /* TODO: use test r8,imm8 */
+ x86_mov_reg_imm (&G->f, G->r_ecx, 0x100);
+ x86_test (&G->f, G->r_eax, G->r_ecx);
+ {
+ GLfloat one = 1.0f, zero = 0.0f;
+ GLubyte *lab0, *lab1;
+
+ /* TODO: use jcc rel8 */
+ lab0 = x86_jcc_forward (&G->f, cc_E);
+ x86_mov_reg_imm (&G->f, G->r_ecx, *((GLint *) &one));
+ /* TODO: use jmp rel8 */
+ lab1 = x86_jmp_forward (&G->f);
+ x86_fixup_fwd_jump (&G->f, lab0);
+ x86_mov_reg_imm (&G->f, G->r_ecx, *((GLint *) &zero));
+ x86_fixup_fwd_jump (&G->f, lab1);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 4));
+ x86_mov (&G->f, x86_deref (G->r_esp), G->r_ecx);
+ }
+ break;
+ case slang_asm_float_equal_exp:
+ x87_fld (&G->f, x86_make_disp (G->r_esp, 4));
+ x87_fcomp (&G->f, x86_deref (G->r_esp));
+ x87_fnstsw (&G->f, G->r_eax);
+ /* TODO: use test r8,imm8 */
+ x86_mov_reg_imm (&G->f, G->r_ecx, 0x4000);
+ x86_test (&G->f, G->r_eax, G->r_ecx);
+ {
+ GLfloat one = 1.0f, zero = 0.0f;
+ GLubyte *lab0, *lab1;
+
+ /* TODO: use jcc rel8 */
+ lab0 = x86_jcc_forward (&G->f, cc_E);
+ x86_mov_reg_imm (&G->f, G->r_ecx, *((GLint *) &one));
+ /* TODO: use jmp rel8 */
+ lab1 = x86_jmp_forward (&G->f);
+ x86_fixup_fwd_jump (&G->f, lab0);
+ x86_mov_reg_imm (&G->f, G->r_ecx, *((GLint *) &zero));
+ x86_fixup_fwd_jump (&G->f, lab1);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 4));
+ x86_mov (&G->f, x86_deref (G->r_esp), G->r_ecx);
+ }
+ break;
+ case slang_asm_float_equal_int:
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, -4));
+ x87_fld (&G->f, x86_make_disp (G->r_esp, a->param[0] + 4));
+ x87_fcomp (&G->f, x86_make_disp (G->r_esp, a->param[1] + 4));
+ x87_fnstsw (&G->f, G->r_eax);
+ /* TODO: use test r8,imm8 */
+ x86_mov_reg_imm (&G->f, G->r_ecx, 0x4000);
+ x86_test (&G->f, G->r_eax, G->r_ecx);
+ {
+ GLfloat one = 1.0f, zero = 0.0f;
+ GLubyte *lab0, *lab1;
+
+ /* TODO: use jcc rel8 */
+ lab0 = x86_jcc_forward (&G->f, cc_E);
+ x86_mov_reg_imm (&G->f, G->r_ecx, *((GLint *) &one));
+ /* TODO: use jmp rel8 */
+ lab1 = x86_jmp_forward (&G->f);
+ x86_fixup_fwd_jump (&G->f, lab0);
+ x86_mov_reg_imm (&G->f, G->r_ecx, *((GLint *) &zero));
+ x86_fixup_fwd_jump (&G->f, lab1);
+ x86_mov (&G->f, x86_deref (G->r_esp), G->r_ecx);
+ }
+ break;
+ case slang_asm_float_to_int:
+ x87_fld (&G->f, x86_deref (G->r_esp));
+ x87_fistp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_sine:
+ /* TODO: use fsin */
+ x86_call (&G->f, (GLubyte *) _mesa_sinf);
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_arcsine:
+ /* TODO: use fpatan (?) */
+ x86_call (&G->f, (GLubyte *) _mesa_asinf);
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_arctan:
+ /* TODO: use fpatan */
+ x86_call (&G->f, (GLubyte *) _mesa_atanf);
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_power:
+ x87_fld (&G->f, x86_deref (G->r_esp));
+ x87_fld (&G->f, x86_make_disp (G->r_esp, 4));
+ x87_fyl2x (&G->f);
+ emit_x87_ex2 (G);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 4));
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_log2:
+ x87_fld1 (&G->f);
+ x87_fld (&G->f, x86_deref (G->r_esp));
+ x87_fyl2x (&G->f);
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_floor:
+ set_fpu_round_neg_inf (G);
+ x87_fld (&G->f, x86_deref (G->r_esp));
+ x87_fprndint (&G->f);
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_ceil:
+ /* TODO: use frndint */
+ x86_call (&G->f, (GLubyte *) do_ceilf);
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_noise1:
+ x86_call (&G->f, (GLubyte *) _slang_library_noise1);
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_noise2:
+ x86_call (&G->f, (GLubyte *) _slang_library_noise2);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 4));
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_noise3:
+ x86_call (&G->f, (GLubyte *) _slang_library_noise4);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 8));
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_noise4:
+ x86_call (&G->f, (GLubyte *) _slang_library_noise4);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 12));
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_int_to_float:
+ break;
+ case slang_asm_int_to_addr:
+ x87_fld (&G->f, x86_deref (G->r_esp));
+ x87_fistp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_addr_copy:
+ x86_pop (&G->f, G->r_eax);
+ x86_mov (&G->f, G->r_ecx, x86_deref (G->r_esp));
+ x86_mov (&G->f, x86_deref (G->r_ecx), G->r_eax);
+ break;
+ case slang_asm_addr_push:
+ /* TODO: use push imm32 */
+ x86_mov_reg_imm (&G->f, G->r_eax, (GLint) a->param[0]);
+ x86_push (&G->f, G->r_eax);
+ break;
+ case slang_asm_addr_add:
+ x86_pop (&G->f, G->r_eax);
+ x86_add (&G->f, x86_deref (G->r_esp), G->r_eax);
+ break;
+ case slang_asm_addr_multiply:
+ x86_pop (&G->f, G->r_ecx);
+ x86_mov (&G->f, G->r_eax, x86_deref (G->r_esp));
+ x86_mul (&G->f, G->r_ecx);
+ x86_mov (&G->f, x86_deref (G->r_esp), G->r_eax);
+ break;
+ case slang_asm_vec4_tex2d:
+ x86_call (&G->f, (GLubyte *) do_vec4_tex2d);
+ x86_lea (&G->f, G->r_ebp, x86_make_disp (G->r_esp, 12));
+ break;
+ case slang_asm_jump:
+ add_fixup (G, a->param[0], x86_jmp_forward (&G->f));
+ break;
+ case slang_asm_jump_if_zero:
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 4));
+ x86_xor (&G->f, G->r_eax, G->r_eax);
+ x86_cmp (&G->f, G->r_eax, x86_make_disp (G->r_esp, -4));
+ {
+ GLubyte *lab0;
+
+ /* TODO: use jcc rel8 */
+ lab0 = x86_jcc_forward (&G->f, cc_NE);
+ add_fixup (G, a->param[0], x86_jmp_forward (&G->f));
+ x86_fixup_fwd_jump (&G->f, lab0);
+ }
+ break;
+ case slang_asm_enter:
+ /* FIXME: x86_make_disp(esp, 0) + x86_lea() generates bogus code */
+ assert (a->param[0] != 0);
+ x86_push (&G->f, G->r_ebp);
+ x86_lea (&G->f, G->r_ebp, x86_make_disp (G->r_esp, (GLint) a->param[0]));
+ break;
+ case slang_asm_leave:
+ x86_pop (&G->f, G->r_ebp);
+ break;
+ case slang_asm_local_alloc:
+ /* FIXME: x86_make_disp(esp, 0) + x86_lea() generates bogus code */
+ assert (a->param[0] != 0);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, -(GLint) a->param[0]));
+ break;
+ case slang_asm_local_free:
+ /* FIXME: x86_make_disp(esp, 0) + x86_lea() generates bogus code */
+ assert (a->param[0] != 0);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, (GLint) a->param[0]));
+ break;
+ case slang_asm_local_addr:
+ disp = -(GLint) (a->param[0] + a->param[1]) + 4;
+ if (disp != 0)
+ {
+ x86_lea (&G->f, G->r_eax, x86_make_disp (G->r_ebp, disp));
+ x86_push (&G->f, G->r_eax);
+ }
+ else
+ x86_push (&G->f, G->r_ebp);
+ break;
+ case slang_asm_global_addr:
+ /* TODO: use push imm32 */
+ x86_mov_reg_imm (&G->f, G->r_eax, (GLint) &G->mach->mem + a->param[0]);
+ x86_push (&G->f, G->r_eax);
+ break;
+ case slang_asm_call:
+ add_fixup (G, a->param[0], x86_call_forward (&G->f));
+ break;
+ case slang_asm_return:
+ x86_ret (&G->f);
+ break;
+ case slang_asm_discard:
+ x86_jmp (&G->f, G->l_discard);
+ break;
+ case slang_asm_exit:
+ x86_jmp (&G->f, G->l_exit);
+ break;
+ /* mesa-specific extensions */
+ case slang_asm_float_print:
+ x86_call (&G->f, (GLubyte *) do_print_float);
+ break;
+ case slang_asm_int_print:
+ x86_call (&G->f, (GLubyte *) do_print_int);
+ break;
+ case slang_asm_bool_print:
+ x86_call (&G->f, (GLubyte *) do_print_bool);
+ break;
+ default:
+ assert (0);
+ }
+}
+
+GLboolean _slang_x86_codegen (slang_machine *mach, slang_assembly_file *file, GLuint start)
+{
+ codegen_ctx G;
+ GLubyte *j_body, *j_exit;
+ GLuint i;
+
+ x86_init_func_size (&G.f, 4*1048576);
+ G.r_eax = x86_make_reg (file_REG32, reg_AX);
+ G.r_ecx = x86_make_reg (file_REG32, reg_CX);
+ G.r_edx = x86_make_reg (file_REG32, reg_DX);
+ G.r_esp = x86_make_reg (file_REG32, reg_SP);
+ G.r_ebp = x86_make_reg (file_REG32, reg_BP);
+ G.r_st0 = x86_make_reg (file_x87, 0);
+ G.r_st1 = x86_make_reg (file_x87, 1);
+ G.r_st2 = x86_make_reg (file_x87, 2);
+ G.r_st3 = x86_make_reg (file_x87, 3);
+ G.fixups = NULL;
+ G.fixup_count = 0;
+ G.labels = (GLubyte **) slang_alloc_malloc (file->count * sizeof (GLubyte *));
+ G.mach = mach;
+ G.fpucntl = RESTORE_FPU;
+
+ mach->x86.fpucntl_rnd_neg = RND_NEG_FPU;
+ mach->x86.fpucntl_restore = RESTORE_FPU;
+
+ /* prepare stack and jump to start */
+ x86_push (&G.f, G.r_ebp);
+ x86_mov_reg_imm (&G.f, G.r_eax, (GLint) &mach->x86.esp_restore);
+ x86_push (&G.f, G.r_esp);
+ x86_pop (&G.f, G.r_ecx);
+ x86_mov (&G.f, x86_deref (G.r_eax), G.r_ecx);
+ j_body = x86_jmp_forward (&G.f);
+
+ /* discard keywords go here */
+ G.l_discard = x86_get_label (&G.f);
+ x86_mov_reg_imm (&G.f, G.r_eax, (GLint) &G.mach->kill);
+ x86_mov_reg_imm (&G.f, G.r_ecx, 1);
+ x86_mov (&G.f, x86_deref (G.r_eax), G.r_ecx);
+ G.l_exit = x86_get_label (&G.f);
+ j_exit = x86_jmp_forward (&G.f);
+
+ for (i = 0; i < file->count; i++)
+ {
+ G.labels[i] = x86_get_label (&G.f);
+ if (i == start)
+ x86_fixup_fwd_jump (&G.f, j_body);
+ codegen_assem (&G, &file->code[i]);
+ }
+
+ /* restore stack and return */
+ x86_fixup_fwd_jump (&G.f, j_exit);
+ x86_mov_reg_imm (&G.f, G.r_eax, (GLint) &mach->x86.esp_restore);
+ x86_mov (&G.f, G.r_esp, x86_deref (G.r_eax));
+ x86_pop (&G.f, G.r_ebp);
+ if (G.fpucntl != RESTORE_FPU)
+ {
+ x87_fnclex (&G.f);
+ x86_mov_reg_imm (&G.f, G.r_eax, (GLint) &G.mach->x86.fpucntl_restore);
+ x87_fldcw (&G.f, x86_deref (G.r_eax));
+ }
+ x86_ret (&G.f);
+
+ /* fixup forward labels */
+ for (i = 0; i < G.fixup_count; i++)
+ {
+ G.f.csr = G.labels[G.fixups[i].index];
+ x86_fixup_fwd_jump (&G.f, G.fixups[i].csr);
+ }
+
+ slang_alloc_free (G.fixups);
+ slang_alloc_free (G.labels);
+
+ /* TODO: free previous instance, if not NULL */
+ mach->x86.compiled_func = (GLvoid (*) (slang_machine *)) x86_get_func (&G.f);
+
+ return GL_TRUE;
+}
+
+#endif
+
diff --git a/src/mesa/shader/slang/slang_export.c b/src/mesa/shader/slang/slang_export.c
index 8103994336c..ffc2ec975ea 100644
--- a/src/mesa/shader/slang/slang_export.c
+++ b/src/mesa/shader/slang/slang_export.c
@@ -29,7 +29,6 @@
*/
#include "imports.h"
-#include "slang_utility.h"
#include "slang_export.h"
/*
@@ -123,6 +122,56 @@ slang_export_data_entry *slang_export_data_table_add (slang_export_data_table *s
}
/*
+ * slang_export_code_entry
+ */
+
+GLvoid slang_export_code_entry_ctr (slang_export_code_entry *self)
+{
+ self->name = SLANG_ATOM_NULL;
+ self->address = ~0;
+}
+
+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()
*/
diff --git a/src/mesa/shader/slang/slang_export.h b/src/mesa/shader/slang/slang_export.h
index 57e7d51279e..88a74fe26b0 100644
--- a/src/mesa/shader/slang/slang_export.h
+++ b/src/mesa/shader/slang/slang_export.h
@@ -25,6 +25,8 @@
#if !defined SLANG_EXPORT_H
#define SLANG_EXPORT_H
+#include "slang_utility.h"
+
#if defined __cplusplus
extern "C" {
#endif
@@ -82,7 +84,7 @@ GLvoid slang_export_data_entry_ctr (slang_export_data_entry *);
GLvoid slang_export_data_entry_dtr (slang_export_data_entry *);
/*
- * Data export table. Holds <count> elements in <entries> array.
+ * Data export table.
*/
typedef struct
@@ -97,6 +99,31 @@ 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.
diff --git a/src/mesa/shader/slang/slang_library_noise.c b/src/mesa/shader/slang/slang_library_noise.c
index 4dddf33e724..d0081c542a9 100644
--- a/src/mesa/shader/slang/slang_library_noise.c
+++ b/src/mesa/shader/slang/slang_library_noise.c
@@ -22,28 +22,11 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "imports.h"
-#include "slang_library_noise.h"
-
/*
* SimplexNoise1234
* Copyright � 2003-2005, Stefan Gustavson
*
* Contact: [email protected]
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/** \file
@@ -66,6 +49,9 @@
*/
+#include "imports.h"
+#include "slang_library_noise.h"
+
#define FASTFLOOR(x) ( ((x)>0) ? ((int)x) : (((int)x)-1) )
/*
diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c
index c4303ac020d..7216663e3f1 100644
--- a/src/mesa/shader/slang/slang_link.c
+++ b/src/mesa/shader/slang/slang_link.c
@@ -29,9 +29,6 @@
*/
#include "imports.h"
-#include "slang_utility.h"
-#include "slang_compile.h"
-#include "slang_export.h"
#include "slang_link.h"
/*
@@ -134,14 +131,94 @@ static GLboolean gather_uniform_bindings (slang_uniform_bindings *bind, slang_ex
GLuint i;
for (i = 0; i < tbl->count; i++)
+ if (tbl->entries[i].access == slang_exp_uniform)
+ {
+ char name[1024] = "";
+
+ if (!insert_binding (bind, &tbl->entries[i].quant, name, tbl->atoms, index,
+ tbl->entries[i].address))
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+/*
+ * slang_active_uniforms
+ */
+
+static GLvoid slang_active_uniforms_ctr (slang_active_uniforms *self)
+{
+ self->table = NULL;
+ self->count = 0;
+}
+
+static GLvoid slang_active_uniforms_dtr (slang_active_uniforms *self)
+{
+ GLuint i;
+
+ for (i = 0; i < self->count; i++)
+ slang_alloc_free (self->table[i].name);
+ slang_alloc_free (self->table);
+}
+
+static GLboolean slang_active_uniforms_add (slang_active_uniforms *self, slang_export_data_quant *q,
+ const char *name)
+{
+ const GLuint n = self->count;
+
+ self->table = (slang_active_uniform *) slang_alloc_realloc (self->table,
+ n * sizeof (slang_active_uniform), (n + 1) * sizeof (slang_active_uniform));
+ 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 insert_uniform (slang_active_uniforms *u, slang_export_data_quant *q, char *name,
+ slang_atom_pool *atoms)
+{
+ slang_string_concat (name, slang_atom_pool_id (atoms, q->name));
+ if (q->array_len != 0)
+ slang_string_concat (name, "[0]");
+
+ if (q->structure != NULL)
{
- char name[1024] = "";
+ GLuint save, i;
- if (!insert_binding (bind, &tbl->entries[i].quant, name, tbl->atoms, index,
- tbl->entries[i].address))
- return GL_FALSE;
+ slang_string_concat (name, ".");
+ save = slang_string_length (name);
+
+ for (i = 0; i < q->u.field_count; i++)
+ {
+ if (!insert_uniform (u, &q->structure[i], name, atoms))
+ return GL_FALSE;
+ name[save] = '\0';
+ }
+
+ return GL_TRUE;
}
+ return slang_active_uniforms_add (u, q, name);
+}
+
+static GLboolean gather_active_uniforms (slang_active_uniforms *u, slang_export_data_table *tbl)
+{
+ GLuint i;
+
+ for (i = 0; i < tbl->count; i++)
+ if (tbl->entries[i].access == slang_exp_uniform)
+ {
+ char name[1024] = "";
+
+ if (!insert_uniform (u, &tbl->entries[i].quant, name, tbl->atoms))
+ return GL_FALSE;
+ }
+
return GL_TRUE;
}
@@ -151,18 +228,159 @@ static GLboolean gather_uniform_bindings (slang_uniform_bindings *bind, slang_ex
GLvoid slang_program_ctr (slang_program *self)
{
+ GLuint i;
+
slang_uniform_bindings_ctr (&self->uniforms);
+ slang_active_uniforms_ctr (&self->active_uniforms);
+ for (i = 0; i < SLANG_UNIFORM_BINDING_MAX; i++)
+ {
+ GLuint j;
+
+ for (j = 0; j < SLANG_COMMON_FIXED_MAX; j++)
+ self->common_fixed_entries[i][j] = ~0;
+ self->code[i] = ~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_uniform_bindings_dtr (&self->uniforms);
+ slang_active_uniforms_dtr (&self->active_uniforms);
}
/*
* _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 fill_common_fixed_entries (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 fill_vertex_fixed_entries (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 fill_fragment_fixed_entries (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_code (GLuint code[], slang_export_code_table *tbl)
+{
+ code[0] = gc (tbl, "@main");
+}
+
GLboolean _slang_link (slang_program *prog, slang_translation_unit **units, GLuint count)
{
GLuint i;
@@ -172,13 +390,24 @@ GLboolean _slang_link (slang_program *prog, slang_translation_unit **units, GLui
GLuint index;
if (units[i]->type == slang_unit_fragment_shader)
+ {
index = SLANG_UNIFORM_BINDING_FRAGMENT;
+ fill_fragment_fixed_entries (prog->fragment_fixed_entries, &units[i]->exp_data);
+ }
else
+ {
index = SLANG_UNIFORM_BINDING_VERTEX;
+ fill_vertex_fixed_entries (prog->vertex_fixed_entries, &units[i]->exp_data);
+ }
if (!gather_uniform_bindings (&prog->uniforms, &units[i]->exp_data, index))
return GL_FALSE;
+ if (!gather_active_uniforms (&prog->active_uniforms, &units[i]->exp_data))
+ return GL_FALSE;
+ fill_common_fixed_entries (prog->common_fixed_entries[index], &units[i]->exp_data);
+ resolve_code (&prog->code[index], &units[i]->exp_code);
prog->machines[index] = units[i]->machine;
+ prog->assemblies[index] = units[i]->assembly;
}
return GL_TRUE;
diff --git a/src/mesa/shader/slang/slang_link.h b/src/mesa/shader/slang/slang_link.h
index 7395c77c5df..2f4fd254cec 100644
--- a/src/mesa/shader/slang/slang_link.h
+++ b/src/mesa/shader/slang/slang_link.h
@@ -25,16 +25,18 @@
#if !defined SLANG_LINK_H
#define SLANG_LINK_H
-#include "slang_assemble.h"
-#include "slang_execute.h"
+#include "slang_compile.h"
#if defined __cplusplus
extern "C" {
#endif
-#define SLANG_UNIFORM_BINDING_VERTEX 0
-#define SLANG_UNIFORM_BINDING_FRAGMENT 1
-#define SLANG_UNIFORM_BINDING_MAX 2
+typedef enum
+{
+ SLANG_UNIFORM_BINDING_VERTEX,
+ SLANG_UNIFORM_BINDING_FRAGMENT,
+ SLANG_UNIFORM_BINDING_MAX
+};
typedef struct
{
@@ -51,8 +53,111 @@ typedef struct
typedef struct
{
+ slang_export_data_quant *quant;
+ char *name;
+} slang_active_uniform;
+
+typedef struct
+{
+ slang_active_uniform *table;
+ GLuint count;
+} slang_active_uniforms;
+
+typedef 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
+};
+
+typedef 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
+};
+
+typedef 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
+};
+
+typedef struct
+{
slang_uniform_bindings uniforms;
+ slang_active_uniforms active_uniforms;
+ GLuint common_fixed_entries[SLANG_UNIFORM_BINDING_MAX][SLANG_COMMON_FIXED_MAX];
+ GLuint vertex_fixed_entries[SLANG_VERTEX_FIXED_MAX];
+ GLuint fragment_fixed_entries[SLANG_FRAGMENT_FIXED_MAX];
+ GLuint code[SLANG_UNIFORM_BINDING_MAX];
slang_machine *machines[SLANG_UNIFORM_BINDING_MAX];
+ slang_assembly_file *assemblies[SLANG_UNIFORM_BINDING_MAX];
} slang_program;
GLvoid slang_program_ctr (slang_program *);
diff --git a/src/mesa/shader/slang/slang_preprocess.c b/src/mesa/shader/slang/slang_preprocess.c
index 3601a384f7a..0be167e2ed9 100644
--- a/src/mesa/shader/slang/slang_preprocess.c
+++ b/src/mesa/shader/slang/slang_preprocess.c
@@ -30,8 +30,6 @@
#include "imports.h"
#include "grammar_mesa.h"
-#include "slang_utility.h"
-#include "slang_compile.h"
#include "slang_preprocess.h"
static const char *slang_version_syn =
diff --git a/src/mesa/shader/slang/slang_preprocess.h b/src/mesa/shader/slang/slang_preprocess.h
index 7901e78580c..c27556d67ea 100644
--- a/src/mesa/shader/slang/slang_preprocess.h
+++ b/src/mesa/shader/slang/slang_preprocess.h
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.3
+ * Version: 6.5
*
- * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ * Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -25,6 +25,8 @@
#if !defined SLANG_PREPROCESS_H
#define SLANG_PREPROCESS_H
+#include "slang_compile.h"
+
#if defined __cplusplus
extern "C" {
#endif
diff --git a/src/mesa/shader/slang/slang_storage.c b/src/mesa/shader/slang/slang_storage.c
index 4afee2ccc79..946dc2e6fc8 100644
--- a/src/mesa/shader/slang/slang_storage.c
+++ b/src/mesa/shader/slang/slang_storage.c
@@ -29,10 +29,7 @@
*/
#include "imports.h"
-#include "slang_utility.h"
#include "slang_storage.h"
-#include "slang_assemble.h"
-#include "slang_execute.h"
/* slang_storage_array */
diff --git a/src/mesa/shader/slang/slang_storage.h b/src/mesa/shader/slang/slang_storage.h
index 4537223d81b..532ea638ee7 100644
--- a/src/mesa/shader/slang/slang_storage.h
+++ b/src/mesa/shader/slang/slang_storage.h
@@ -56,7 +56,7 @@ typedef enum slang_storage_type_
* elements. They are also required to support indirect addressing. That is, if B references
* first data slot in the array, S is the size of the data slot and I is the integral index that
* is not known at compile time, B+I*S references I-th data slot.
- *
+ *
* This structure is also used to break down built-in data types that are not supported directly.
* Vectors, like vec3, are constructed from arrays of their basic types. Matrices are formed of
* an array of column vectors, which are in turn processed as other vectors.
diff --git a/src/mesa/shader/slang/slang_utility.h b/src/mesa/shader/slang/slang_utility.h
index 2d2ac8e42e4..b4bde3d5388 100644
--- a/src/mesa/shader/slang/slang_utility.h
+++ b/src/mesa/shader/slang/slang_utility.h
@@ -61,8 +61,8 @@ typedef struct slang_atom_pool_
slang_atom_entry *entries[SLANG_ATOM_POOL_SIZE];
} slang_atom_pool;
-void slang_atom_pool_construct (slang_atom_pool *);
-void slang_atom_pool_destruct (slang_atom_pool *);
+GLvoid slang_atom_pool_construct (slang_atom_pool *);
+GLvoid slang_atom_pool_destruct (slang_atom_pool *);
slang_atom slang_atom_pool_atom (slang_atom_pool *, const char *);
const char *slang_atom_pool_id (slang_atom_pool *, slang_atom);